# HG changeset patch # User John Tsiombikas # Date 1330837601 -7200 # Node ID c50064b181c2016db050f72012517b33ce9ee99d # Parent 875ef6085efc6b11155fe500fdb36504242435b7 stuff diff -r 875ef6085efc -r c50064b181c2 Makefile --- a/Makefile Sun Mar 04 04:04:25 2012 +0200 +++ b/Makefile Sun Mar 04 07:06:41 2012 +0200 @@ -4,10 +4,10 @@ obj = $(src:.c=.o) liba = libgbasys.a -CPP = arm-agb-elf-cpp -CC = arm-agb-elf-gcc -AS = arm-agb-elf-as -AR = arm-agb-elf-ar +CPP = arm-eabi-cpp +CC = arm-eabi-gcc +AS = arm-eabi-as +AR = arm-eabi-ar CFLAGS = -pedantic -marm -mcpu=arm7tdmi -Isrc diff -r 875ef6085efc -r c50064b181c2 samples/fonts/fonts.c --- a/samples/fonts/fonts.c Sun Mar 04 04:04:25 2012 +0200 +++ b/samples/fonts/fonts.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,9 +1,12 @@ -#include "libgba.h" +#include "gbasys.h" -int main(void) { +int main(void) +{ int i; struct font *font; + print_vba("foobar\n"); + set_video_mode(VMODE_LFB_240x160_16, 1); font = get_font(); diff -r 875ef6085efc -r c50064b181c2 src/config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/config.h Sun Mar 04 07:06:41 2012 +0200 @@ -0,0 +1,30 @@ +/* +Copyright 2004 John Tsiombikas + +This file is part of libgba, a library for GameBoy Advance development. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _LIBGBA_CONFIG_H_ +#define _LIBGBA_CONFIG_H_ + +/* compile 8x8 font */ +#define CONFIG_FONT_8X8 + +/* compile 8x16 font */ +/*#define CONFIG_FONT_8X16*/ + +#endif /* _LIBGBA_CONFIG_H_ */ diff -r 875ef6085efc -r c50064b181c2 src/dma.c --- a/src/dma.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/dma.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,11 +18,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "libgba_config.h" +#include "config.h" #include "dma.h" /* DMA Options */ -#define DMA_ENABLE 0x80000000 +#define DMA_ENABLE 0x80000000 #define DMA_INT_ENABLE 0x40000000 #define DMA_TIMING_IMMED 0x00000000 #define DMA_TIMING_VBLANK 0x10000000 @@ -48,13 +48,15 @@ /* --- perform a copy of words or halfwords using DMA --- */ -void dma_copy32(int channel, void *dst, void *src, int words) { +void dma_copy32(int channel, void *dst, void *src, int words) +{ reg_dma[channel][DMA_SRC] = (unsigned long)src; reg_dma[channel][DMA_DST] = (unsigned long)dst; reg_dma[channel][DMA_CTRL] = words | DMA_TIMING_IMMED | DMA_32 | DMA_ENABLE; } -void dma_copy16(int channel, void *dst, void *src, int halfwords) { +void dma_copy16(int channel, void *dst, void *src, int halfwords) +{ reg_dma[channel][DMA_SRC] = (unsigned long)src; reg_dma[channel][DMA_DST] = (unsigned long)dst; reg_dma[channel][DMA_CTRL] = halfwords | DMA_TIMING_IMMED | DMA_16 | DMA_ENABLE; @@ -62,14 +64,16 @@ /* --- fill a buffer with an ammount of words and halfwords using DMA --- */ -void dma_fill32(int channel, void *dst, unsigned long val, int words) { +void dma_fill32(int channel, void *dst, unsigned long val, int words) +{ unsigned long valmem = val; reg_dma[channel][DMA_SRC] = (unsigned long)&valmem; reg_dma[channel][DMA_DST] = (unsigned long)dst; reg_dma[channel][DMA_CTRL] = words | DMA_SRC_FIX | DMA_TIMING_IMMED | DMA_32 | DMA_ENABLE; } -void dma_fill16(int channel, void *dst, unsigned short val, int halfwords) { +void dma_fill16(int channel, void *dst, unsigned short val, int halfwords) +{ unsigned short valmem = val; reg_dma[channel][DMA_SRC] = (unsigned long)&valmem; reg_dma[channel][DMA_DST] = (unsigned long)dst; diff -r 875ef6085efc -r c50064b181c2 src/font.c --- a/src/font.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/font.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "libgba_config.h" +#include "config.h" #include #include "font.h" #include "gfx.h" @@ -97,7 +97,7 @@ struct pixel_buffer *glyph; if(!(glyph = get_glyph(c, fg_color, bg_color, pbuf->bpp))) return -1; - + if(pbuf->bpp == 16) { int i, j; unsigned short *dptr = (unsigned short*)pbuf->pixels + y * pbuf->x + x; diff -r 875ef6085efc -r c50064b181c2 src/font.h --- a/src/font.h Sun Mar 04 04:04:25 2012 +0200 +++ b/src/font.h Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #ifndef _FONT_H_ #define _FONT_H_ -#include "libgba_config.h" +#include "config.h" struct pixel_buffer; diff -r 875ef6085efc -r c50064b181c2 src/font_8x16.c --- a/src/font_8x16.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/font_8x16.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ * the Linux 2.6.7 kernel (drivers/video/console/font_8x8.c) */ -#include "libgba_config.h" +#include "config.h" #ifdef CONFIG_FONT_8X16 diff -r 875ef6085efc -r c50064b181c2 src/font_8x8.c --- a/src/font_8x8.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/font_8x8.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ * the Linux 2.6.7 kernel (drivers/video/console/font_8x8.c) */ -#include "libgba_config.h" +#include "config.h" #ifdef CONFIG_FONT_8X8 diff -r 875ef6085efc -r c50064b181c2 src/gbasys.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gbasys.c Sun Mar 04 07:06:41 2012 +0200 @@ -0,0 +1,34 @@ +/* +Copyright 2004 John Tsiombikas + +This file is part of gbasys, a library for GameBoy Advance development. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "config.h" +#include "gbasys.h" + +void gba_init(void) +{ + intr_init(); + sig_init(); + term_init(); + + enable_key_interrupts(KEY_ALL); + set_int(); + + reset_msec_timer(); +} diff -r 875ef6085efc -r c50064b181c2 src/gbasys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gbasys.h Sun Mar 04 07:06:41 2012 +0200 @@ -0,0 +1,37 @@ +/* +Copyright 2004 John Tsiombikas + +This file is part of libgba, a library for GameBoy Advance development. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _LIBGBA_H_ +#define _LIBGBA_H_ + +#include "gfx.h" +#include "dma.h" +#include "syscall.h" +#include "font.h" +#include "input.h" +#include "intr.h" +#include "error.h" +#include "signal.h" +#include "timer.h" +#include "term.h" + +void gba_init(void); + +#endif /* _LIBGBA_H_ */ diff -r 875ef6085efc -r c50064b181c2 src/gfx.c --- a/src/gfx.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/gfx.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "libgba_config.h" +#include "config.h" #include #include "gfx.h" @@ -70,7 +70,7 @@ front_buffer->x = back_buffer->x = xres; front_buffer->y = back_buffer->y = yres; front_buffer->bpp = back_buffer->bpp = sizeof_pixel * 8; - + if(mode > 3) { page_flipping = 1; back_buffer->pixels = (void*)0x600a000; @@ -84,7 +84,7 @@ void flip(void) { static void *tmp; - + if(page_flipping) { swap_page(); tmp = front_buffer->pixels; @@ -121,13 +121,13 @@ color |= color << 8; sz >>= 1; } - + dma_fill16(3, pbuf->pixels, color, sz); } void copy_buffer(const struct pixel_buffer *src, struct pixel_buffer *dst) { int words; - + if(src->x != dst->x || src->y != dst->y || src->bpp != dst->bpp) return; words = (src->x * src->y) >> (src->bpp == 16 ? 1 : 2); @@ -145,21 +145,21 @@ ptr += y1 * pbuf->x + x1; dx = x2 - x1; dy = y2 - y1; - + if(dx >= 0) { x_inc = 1; } else { x_inc = -1; dx = -dx; } - + if(dy >= 0) { y_inc = pbuf->x; } else { y_inc = -pbuf->x; dy = -dy; } - + dx2 = dx << 1; dy2 = dy << 1; diff -r 875ef6085efc -r c50064b181c2 src/libgba.c --- a/src/libgba.c Sun Mar 04 04:04:25 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -Copyright 2004 John Tsiombikas - -This file is part of libgba, a library for GameBoy Advance development. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "libgba_config.h" -#include "libgba.h" - -void gba_init(void) { - intr_init(); - sig_init(); - term_init(); - - enable_key_interrupts(KEY_ALL); - set_int(); - - reset_msec_timer(); -} diff -r 875ef6085efc -r c50064b181c2 src/libgba.h --- a/src/libgba.h Sun Mar 04 04:04:25 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* -Copyright 2004 John Tsiombikas - -This file is part of libgba, a library for GameBoy Advance development. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _LIBGBA_H_ -#define _LIBGBA_H_ - -#include "gfx.h" -#include "dma.h" -#include "syscall.h" -#include "font.h" -#include "input.h" -#include "intr.h" -#include "error.h" -#include "signal.h" -#include "timer.h" -#include "term.h" - -void gba_init(void); - -#endif /* _LIBGBA_H_ */ diff -r 875ef6085efc -r c50064b181c2 src/libgba_config.h --- a/src/libgba_config.h Sun Mar 04 04:04:25 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -Copyright 2004 John Tsiombikas - -This file is part of libgba, a library for GameBoy Advance development. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _LIBGBA_CONFIG_H_ -#define _LIBGBA_CONFIG_H_ - -/* compile 8x8 font */ -#define CONFIG_FONT_8X8 - -/* compile 8x16 font */ -/*#define CONFIG_FONT_8X16*/ - -#endif /* _LIBGBA_CONFIG_H_ */ diff -r 875ef6085efc -r c50064b181c2 src/syscall.c --- a/src/syscall.c Sun Mar 04 04:04:25 2012 +0200 +++ b/src/syscall.c Sun Mar 04 07:06:41 2012 +0200 @@ -1,7 +1,7 @@ /* Copyright 2004 John Tsiombikas -This file is part of libgba, a library for GameBoy Advance development. +This file is part of gbasys, a library for GameBoy Advance development. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,21 +18,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "libgba_config.h" +#include "config.h" #include #include #include "syscall.h" -void halt(void) { +void halt(void) +{ __syscall(2); } -void stop(void) { +void stop(void) +{ __syscall(3); } -void print_vba(const char *str, ...) { +void print_vba(const char *str, ...) +{ char buf[128]; va_list arg_list;