gbasys
changeset 3:06726f0b8cd3
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 08 Mar 2012 14:37:17 +0200 |
parents | e3dc7705ad9c |
children | 5c6cdef01292 |
files | src/comm.c src/comm.h src/gbasys.h src/gfx.c src/gfx.h src/input.c src/input.h src/signal.c src/signal.h src/term.c src/timer.h |
diffstat | 11 files changed, 56 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/src/comm.c Wed Mar 07 06:11:51 2012 +0200 1.2 +++ b/src/comm.c Thu Mar 08 14:37:17 2012 +0200 1.3 @@ -1,6 +1,6 @@ 1.4 /* 1.5 gbasys - a gameboy advance hardware abstraction library 1.6 -Copyright (C) 2005-2012 John Tsiombikas <nuclear@member.fsf.org> 1.7 +Copyright (C) 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 1.8 1.9 This program is free software: you can redistribute it and/or modify 1.10 it under the terms of the GNU General Public License as published by
2.1 --- a/src/comm.h Wed Mar 07 06:11:51 2012 +0200 2.2 +++ b/src/comm.h Thu Mar 08 14:37:17 2012 +0200 2.3 @@ -1,6 +1,6 @@ 2.4 /* 2.5 gbasys - a gameboy advance hardware abstraction library 2.6 -Copyright (C) 2005-2012 John Tsiombikas <nuclear@member.fsf.org> 2.7 +Copyright (C) 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 2.8 2.9 This program is free software: you can redistribute it and/or modify 2.10 it under the terms of the GNU General Public License as published by
3.1 --- a/src/gbasys.h Wed Mar 07 06:11:51 2012 +0200 3.2 +++ b/src/gbasys.h Thu Mar 08 14:37:17 2012 +0200 3.3 @@ -31,6 +31,7 @@ 3.4 #include "signal.h" 3.5 #include "timer.h" 3.6 #include "term.h" 3.7 +#include "comm.h" 3.8 3.9 void gba_init(void); 3.10
4.1 --- a/src/gfx.c Wed Mar 07 06:11:51 2012 +0200 4.2 +++ b/src/gfx.c Thu Mar 08 14:37:17 2012 +0200 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 -Copyright 2004 John Tsiombikas <nuclear@siggraph.org> 4.6 +Copyright 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 4.7 4.8 This file is part of gbasys, a library for GameBoy Advance development. 4.9 4.10 @@ -21,6 +21,7 @@ 4.11 #include "config.h" 4.12 4.13 #include <stdlib.h> 4.14 +#include <string.h> 4.15 #include "gfx.h" 4.16 4.17 #define FRAME_SEL_BIT 0x10 4.18 @@ -134,6 +135,42 @@ 4.19 dma_copy32(3, dst->pixels, src->pixels, words); 4.20 } 4.21 4.22 +#define MIN(a, b) ((a) < (b) ? (a) : (b)) 4.23 + 4.24 +void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h, 4.25 + struct pixel_buffer *dst, int dst_x, int dst_y) 4.26 +{ 4.27 + int i, pixsize, width, height, dstride, sstride; 4.28 + unsigned char *dptr, *sptr; 4.29 + 4.30 + if(dst->bpp != src->bpp) 4.31 + return; 4.32 + 4.33 + if(src_w <= 0) 4.34 + src_w = src->x; 4.35 + if(src_h <= 0) 4.36 + src_h = src->y; 4.37 + 4.38 + width = MIN(src_w, MIN(src->x - src_x, dst->x - dst_x)); 4.39 + height = MIN(src_h, MIN(src->y - src_y, dst->y - dst_y)); 4.40 + 4.41 + if(width <= 0 || height <= 0) 4.42 + return; 4.43 + 4.44 + pixsize = dst->bpp / 8; 4.45 + dptr = (unsigned char*)dst->pixels + (dst_y * dst->x + dst_x) * pixsize; 4.46 + sptr = (unsigned char*)src->pixels + (src_y * src->x + src_x) * pixsize; 4.47 + 4.48 + dstride = dst->x * pixsize; 4.49 + sstride = src->x * pixsize; 4.50 + 4.51 + for(i=0; i<height; i++) { 4.52 + memcpy(dptr, sptr, width * pixsize); 4.53 + sptr += sstride; 4.54 + dptr += dstride; 4.55 + } 4.56 +} 4.57 + 4.58 4.59 void draw_line(int x1, int y1, int x2, int y2, unsigned short col, struct pixel_buffer *pbuf) { 4.60 int dx, dy, dx2, dy2;
5.1 --- a/src/gfx.h Wed Mar 07 06:11:51 2012 +0200 5.2 +++ b/src/gfx.h Thu Mar 08 14:37:17 2012 +0200 5.3 @@ -51,6 +51,8 @@ 5.4 void clear_buffer(struct pixel_buffer *pbuf, unsigned short color); 5.5 5.6 void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst); 5.7 +void blit(struct pixel_buffer *src, int src_x, int src_y, int src_w, int src_h, 5.8 + struct pixel_buffer *dst, int dest_x, int dest_y); 5.9 5.10 #define wait_vsync() while(*((volatile unsigned short*)0x4000006) < front_buffer->y) 5.11
6.1 --- a/src/input.c Wed Mar 07 06:11:51 2012 +0200 6.2 +++ b/src/input.c Thu Mar 08 14:37:17 2012 +0200 6.3 @@ -1,7 +1,7 @@ 6.4 /* 6.5 -Copyright 2004 John Tsiombikas <nuclear@siggraph.org> 6.6 +Copyright 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 6.7 6.8 -This file is part of libgba, a library for GameBoy Advance development. 6.9 +This file is part of gbasys, a library for GameBoy Advance development. 6.10 6.11 This program is free software; you can redistribute it and/or modify 6.12 it under the terms of the GNU General Public License as published by
7.1 --- a/src/input.h Wed Mar 07 06:11:51 2012 +0200 7.2 +++ b/src/input.h Thu Mar 08 14:37:17 2012 +0200 7.3 @@ -1,7 +1,7 @@ 7.4 /* 7.5 -Copyright 2004 John Tsiombikas <nuclear@siggraph.org> 7.6 +Copyright 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 7.7 7.8 -This file is part of libgba, a library for GameBoy Advance development. 7.9 +This file is part of gbasys, a library for GameBoy Advance development. 7.10 7.11 This program is free software; you can redistribute it and/or modify 7.12 it under the terms of the GNU General Public License as published by
8.1 --- a/src/signal.c Wed Mar 07 06:11:51 2012 +0200 8.2 +++ b/src/signal.c Thu Mar 08 14:37:17 2012 +0200 8.3 @@ -41,6 +41,7 @@ 8.4 default_sig_handler[SIGUSR1] = SIG_IGN; 8.5 default_sig_handler[SIGUSR2] = SIG_IGN; 8.6 default_sig_handler[SIGIO] = SIG_IGN; 8.7 + default_sig_handler[SIGTTIN] = SIG_IGN; 8.8 for(i=0; i<SIG_MAX; i++) { 8.9 signal_handler[i] = default_sig_handler[i]; 8.10 }
9.1 --- a/src/signal.h Wed Mar 07 06:11:51 2012 +0200 9.2 +++ b/src/signal.h Thu Mar 08 14:37:17 2012 +0200 9.3 @@ -1,7 +1,7 @@ 9.4 /* 9.5 -Copyright 2004 John Tsiombikas <nuclear@siggraph.org> 9.6 +Copyright 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 9.7 9.8 -This file is part of libgba, a library for GameBoy Advance development. 9.9 +This file is part of gbasys, a library for GameBoy Advance development. 9.10 9.11 This program is free software; you can redistribute it and/or modify 9.12 it under the terms of the GNU General Public License as published by
10.1 --- a/src/term.c Wed Mar 07 06:11:51 2012 +0200 10.2 +++ b/src/term.c Thu Mar 08 14:37:17 2012 +0200 10.3 @@ -46,10 +46,10 @@ 10.4 10.5 if(fp != stdin) panic("getc: only stdin valid"); 10.6 10.7 - save_signal(SIGIO); 10.8 - signal(SIGIO, noop); 10.9 + save_signal(SIGTTIN); 10.10 + signal(SIGTTIN, noop); 10.11 while(!key_queue->next) pause(); 10.12 - restore_signal(SIGIO); 10.13 + restore_signal(SIGTTIN); 10.14 10.15 tmp = key_queue; 10.16 key_queue = key_queue->next; 10.17 @@ -77,5 +77,5 @@ 10.18 key_queue_tail = key; 10.19 } 10.20 } 10.21 - raise(SIGIO); 10.22 + raise(SIGTTIN); 10.23 }
11.1 --- a/src/timer.h Wed Mar 07 06:11:51 2012 +0200 11.2 +++ b/src/timer.h Thu Mar 08 14:37:17 2012 +0200 11.3 @@ -1,7 +1,7 @@ 11.4 /* 11.5 -Copyright 2004 John Tsiombikas <nuclear@siggraph.org> 11.6 +Copyright 2004-2012 John Tsiombikas <nuclear@member.fsf.org> 11.7 11.8 -This file is part of libgba, a library for GameBoy Advance development. 11.9 +This file is part of gbasys, a library for GameBoy Advance development. 11.10 11.11 This program is free software; you can redistribute it and/or modify 11.12 it under the terms of the GNU General Public License as published by