#64981 - skycladmonkey - Thu Dec 29, 2005 4:05 am
Hi
I am using devkitpro and im trying to make a map using the island 8 example from gbamappy.
if screenbase is set to 0 i see a corrupt map.
otherwise it doesnt show at all.
i believe im missing something with the screenbase and c har base flags.
can anyone help?
I am using devkitpro and im trying to make a map using the island 8 example from gbamappy.
if screenbase is set to 0 i see a corrupt map.
otherwise it doesnt show at all.
i believe im missing something with the screenbase and c har base flags.
can anyone help?
Code: |
#include <gba_base.h> #include <gba_video.h> #include <gba_systemcalls.h> #include <gba_interrupt.h> #include <gba_input.h> #include "island8.TXT" // -------------------------------------------------------------------- int main() { // Set up the interrupt handlers InitInterrupt(); // Enable Vblank Interrupt to allow VblankIntrWait EnableInterrupt(IE_VBL); // Allow Interrupts REG_IME = 1; // set screen H and V scroll positions BG0HOFS = 0; BG0VOFS = 0; // set the screen base to 31 (0x600F800) and char base to 0 (0x6000000) BGCTRL[0] = SCREEN_BASE(31); BGCTRL[0] = CHAR_BASE(0); // screen mode & background to display SetMode( MODE_0 | BG0_ON ); REG_BG0CNT |=BG_256_COLOR; REG_BG0CNT |=BG_SIZE_0; //REG_BG0CNT |=CHAR_BASE(0); //REG_BG0CNT |=SCREEN_BASE(31); int i, x, y; u16 * gfxpt, * gfxpt2; u16 * mappt; /* Copy the tile graphics to vram 16bits at a time (8bit transfers don't work) */ gfxpt = (u16*)VRAM+0x2000; /* This is actually +0x4000, but 0x2000 because of short ptr */ gfxpt2 = (u16 *) island8_blockgfx; for (i=0;i<(sizeof(island8_blockgfx)/2);i++) { gfxpt[i] = gfxpt2[i]; } /* Copy the 256 colour palette*/ for (i=0;i<256;i++) { BG_COLORS[i] = island8_cmap[i]; } /* Copy the data to the map memory */ mappt = (u16 *) VRAM;//+0x600F800; for (y=0;y<32;y++) { for (x=0;x<32;x++) { mappt[(y*32)+x] = (u16) island8_map0[y] [x]; } } while(1) { VBlankIntrWait(); if(!(REG_KEYINPUT & KEY_LEFT)) x--; if(!(REG_KEYINPUT & KEY_RIGHT)) x++; if(!(REG_KEYINPUT & KEY_UP)) y--; if(!(REG_KEYINPUT & KEY_DOWN)) y++; BG0HOFS = x; BG0VOFS = (y)%(32*8); } return (0); // we'll never reach here } |