diff options
Diffstat (limited to 'arm9/source/devices')
-rw-r--r-- | arm9/source/devices/screen.c | 28 | ||||
-rw-r--r-- | arm9/source/devices/screen.h | 9 |
2 files changed, 34 insertions, 3 deletions
diff --git a/arm9/source/devices/screen.c b/arm9/source/devices/screen.c index 0d2fc36..5c16d8f 100644 --- a/arm9/source/devices/screen.c +++ b/arm9/source/devices/screen.c @@ -19,6 +19,31 @@ a 16-bit tile index (low 10 bits are tile index, then h-flip, then v-flip, then #include "screen.h" #include "../bang.h" +Screen scr_main = { + .bgv = BG_TILE_RAM(BG_SLOT_VIS), + .fgv = BG_TILE_RAM(FG_SLOT_VIS), + .bg = BG_TILE_RAM(BG_SLOT), + .fg = BG_TILE_RAM(FG_SLOT), + .map = BG_MAP_RAM(MAP_SLOT), + .palv = BG_PALETTE, +}; +Screen scr_sub = { + .bgv = BG_TILE_RAM_SUB(BG_SLOT_VIS), + .fgv = BG_TILE_RAM_SUB(FG_SLOT_VIS), + .bg = BG_TILE_RAM_SUB(BG_SLOT), + .fg = BG_TILE_RAM_SUB(FG_SLOT), + .map = BG_MAP_RAM_SUB(MAP_SLOT), + .palv = BG_PALETTE_SUB, +}; + +void scr_make_main(ScreenDevice *scr) { + scr->nds = &scr_main; +} + +void scr_make_sub(ScreenDevice *scr) { + scr->nds = &scr_sub; +} + void init_screens(void) { // Allocate VRAM for screens videoSetMode(DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | MODE_0_2D); @@ -127,6 +152,9 @@ void erase_screen(Screen *nds) { void flip_buffer(Screen *nds) { dmaCopyWords(0, nds->bg, nds->bgv, TILES_MEM); dmaCopyWords(0, nds->fg, nds->fgv, TILES_MEM); + for (int i=0; i<16; i++) { + nds->palv[i] = nds->pal[i]; + } } void black_screen(Screen *nds) { diff --git a/arm9/source/devices/screen.h b/arm9/source/devices/screen.h index a406051..3e75334 100644 --- a/arm9/source/devices/screen.h +++ b/arm9/source/devices/screen.h @@ -25,9 +25,10 @@ typedef struct { u16 *bgv, *fgv; // visible tile memory - u16 *bg, *fg; // tile memory - u16 *map; // tile map - u16 *pal; // colour palette + u16 *bg, *fg; // buffered tile memory + u16 *map; // tile map (never changes) + u16 *palv; // visible colour palette + u16 pal[16]; // buffered colour palette } Screen; typedef struct { @@ -43,6 +44,8 @@ } ScreenDevice; void init_screens(void); + void scr_make_main(ScreenDevice *scr); + void scr_make_sub(ScreenDevice *scr); void set_palette_high(ScreenDevice *scr, u8 high); void set_palette_low(ScreenDevice *scr, u8 low); |