#50890 - pizzach - Sun Aug 14, 2005 7:57 am
I'm new to gameboy developement and just about over the beginning learning curve. I started programming an RPG in Java that was becoming a good FF3 nock-off but decided I would rather get some direct console development experience so I'm starting fresh and getting some good C experience to boot. I learned some things about Windows gba programmers and how they can be lazy on uppercase lowercase. (>_<) I started gba development on my Mac in devkitadvance, I'm now on a linux with devkitpro on my laptop and I have been learning by staring at windows user source code. Agh. Anyway...
My largest battle I'm fighting will right now is figuring out what tile maps should be doing. When I set the rotation map size to 128x128 the map appears to be about one screen in size. 256x256 appears to be two screens in length. 512x512 appears to be the same size as 128x128. 1024x1024 appears to be the same size as 256x256. The other thing is I can't get wrap around to turn off.
My code is below that I had used. I tried to keep it as simple as possible because I'm not trying to build anything yet. I tried to fix up some of the indent problems and hopefully I didn't screw anything up on the copy over to the forums.
Any help would be appreciated! I hope I posted this in the right section.
My largest battle I'm fighting will right now is figuring out what tile maps should be doing. When I set the rotation map size to 128x128 the map appears to be about one screen in size. 256x256 appears to be two screens in length. 512x512 appears to be the same size as 128x128. 1024x1024 appears to be the same size as 256x256. The other thing is I can't get wrap around to turn off.
My code is below that I had used. I tried to keep it as simple as possible because I'm not trying to build anything yet. I tried to fix up some of the indent problems and hopefully I didn't screw anything up on the copy over to the forums.
Any help would be appreciated! I hope I posted this in the right section.
Code: |
#include <gba.h> volatile u16* ScanlineCounter = (volatile u16*)0x4000006; void WaitForVblank(void); u16* ScreenBB = (u16*)SCREEN_BASE_BLOCK(28); u16* CharBB = (u16*) MAP_BASE_BLOCK(0); int main() { u8 i, x, y; //Background setup REG_BG0CNT = (BG_COLOR_256 | ROTBG_SIZE_512x512 | (28 << SCREEN_SHIFT) | (0 << CHAR_SHIFT)); SetMode(MODE_1 | BG0_ENABLE); // input 3 colors into the palette BGPaletteMem[0] = RGB16(31,31,31);//white BGPaletteMem[1] = RGB16(0,30,0);//green BGPaletteMem[2] = RGB16(0,0,25);//blue // input tiles(char data) for(i=0; i<32; i++) { CharBB[i] = 0x0000; // color from palette 0(!! We have to write 2 byte at a time !!) } for(i=32; i<64; i++) { CharBB[i] = 0x0101; // color from palette 1((!! We have to write 2 byte at a time !!) } for(i=64; i<96; i++) { CharBB[i] = 0x0202; // color from palette 2(!! We have to write 2 byte at a time !!) } //Almost two screens of blue tiles int testNum; for (testNum=0; testNum<25*32; testNum++) { ScreenBB[testNum ] = 2; //tile 2 at location (15, 8); } //Some random green tiles x = 0; y = 19; ScreenBB[x+(32*y) ] = 1;//tile 1 at location (5, 3); x = 35; y = 3; ScreenBB[x+(32*y) ] = 1; //tile 2 at location (15, 8); s16 xscroll = 1; REG_BG0HOFS=0; while(1) { void WaitForVblank(void); //buy some time int x = 0x0002; while (x < 10000) x++; if (!(KEY_RIGHT & REG_KEYS)) { xscroll++; REG_BG0HOFS = xscroll; } if (!(KEY_LEFT & REG_KEYS)) { xscroll--; REG_BG0HOFS = xscroll; } } } void WaitForVblank(void) // waits for the drawer to get to end before flip { while(*ScanlineCounter < 160) { // do nothing }//now we are in the vblank period } |