#149239 - yaazz - Thu Jan 17, 2008 2:37 am
Hello I am attempting to learn GBA programming from the book "how to program the Game Boy Advance", and have run into an issue.
When I try to compile my program the compiler spits this out:
{
C:/gcc-arm/bin/arm-thumb-elf-gcc.exe -I C:/gcc-arm/include -I C:/gcc-arm/arm-thumb-elf/include -I C:/include -I C:/system -c -DHAM_HAM -DHAM_MULTIBOOT -DHAM_ENABLE_MBV2LIB -O2 -DHAM_WITH_LIBHAM -mthumb-interwork -mlong-calls -Wall -save-temps -fverbose-asm -nostartfiles main.c -o main.o
In file included from C:/gcc-arm/arm-thumb-elf/include/stdlib.h:14,
from main.c:5:
C:/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.3.2/include/stddef.h:213: error: syntax error before "typedef"
make: *** [main.o] Error 1
}
For some reason, STDLIB, and STDDEF (which must be linked from stdlib) will not compile.....
Does anyone know how to fix this?
here is the source for my program
[/code]
When I try to compile my program the compiler spits this out:
{
C:/gcc-arm/bin/arm-thumb-elf-gcc.exe -I C:/gcc-arm/include -I C:/gcc-arm/arm-thumb-elf/include -I C:/include -I C:/system -c -DHAM_HAM -DHAM_MULTIBOOT -DHAM_ENABLE_MBV2LIB -O2 -DHAM_WITH_LIBHAM -mthumb-interwork -mlong-calls -Wall -save-temps -fverbose-asm -nostartfiles main.c -o main.o
In file included from C:/gcc-arm/arm-thumb-elf/include/stdlib.h:14,
from main.c:5:
C:/gcc-arm/lib/gcc-lib/arm-thumb-elf/3.3.2/include/stddef.h:213: error: syntax error before "typedef"
make: *** [main.o] Error 1
}
For some reason, STDLIB, and STDDEF (which must be linked from stdlib) will not compile.....
Does anyone know how to fix this?
here is the source for my program
Code: |
#define multiboot int_gba_multiboot MULTIBOOT #include <stdlib.h> //drawing functions void drawPixel(int,int,unsigned short); void drawLine3(int,int,int,int,unsigned short); //defines for the video mode #define REG_DISPCNT *(unsigned long*)0x4000000 #define MODE_3 0x3 #define BG2_ENABLE 0x400 //changes the video mode #define setMode(mode) REG_DISPCNT= (mode) //packs 3 values into 15 bit color #define RGB(r,g,b) ((r)+(g<<5)+(b<<10)) //create a pointer to the video buffer unsigned short* videoBuffer = (unsigned short*)0x6000000; int main(void) { int x1,y1,x2,y2; unsigned short color; setMode(MODE_3 | BG2_ENABLE); while(1) { x1 = rand()*240; y1 = rand()*160; x2 = rand()*240; y2 = rand()*160; color=RGB(rand()%31, rand()%31, rand()%31); drawLine3(x1,y1,x2,y2,color); } return 0; } void drawPixel3(int x, int y, unsigned short c) { videoBuffer[y * 240 + x] = c; } void drawLine3(int x1,int y1, int x2, int y2, unsigned short c) { int i, deltaX, deltaY, numPixels; int d, dinc1, dinc2; int x, xinc1, xinc2; int y, yinc1, yinc2; //calculate deltaX and deltaY deltaX = abs(x2 - x1); deltaY = abs(y2 - y1); //initialize if(deltaX > deltaY) { //If x is an independant variable numPixels = deltaX + 1; d = (2 * deltaY) - deltaX; dinc1 = deltaY << 1; dinc2 = (deltaY - deltaX) << 1; xinc1 = 1; xinc2 = 1; yinc1 = 0; yinc2 = 1; } else { // if y is independant variable numPixels = deltaY + 1; d = (2* deltaX) - deltaY; dinc1 = deltaX << 1; dinc2 = (deltaX - deltaY) << 1; xinc1 = 0; xinc2 = 1; yinc1 = 1; yinc2 = 2; } //move the right direction if (x1>x2) { xinc1 = -xinc1; xinc2 = -xinc2; } if (y1 > y2) { yinc1 = -yinc1; yinc2 = -yinc2; } x = x1; y = y1; //draw the pixels for (i=1;i<numPixels;i++) { drawPixel(x,y,c); if(d<0) { d = d + dinc1; x = x + xinc1; y = y + yinc1; } else { d = d + dinc2; x = x + xinc2; y = y + yinc2; } } } /* END OF FILE */ |