diff --git a/gba/Makefile b/gba/Makefile index 4365d6a..2ff5991 100644 --- a/gba/Makefile +++ b/gba/Makefile @@ -49,14 +49,15 @@ LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $*.map) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lgba +LIBS := -ltonc #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- -LIBDIRS := $(LIBGBA) +LIBTONC := $(DEVKITPRO)/libtonc +LIBDIRS := $(LIBTONC) #--------------------------------------------------------------------------------- # Python executable name depends on operating system. diff --git a/gba/src/4bcanvas.c b/gba/src/4bcanvas.c index 7b1504a..56be95f 100644 --- a/gba/src/4bcanvas.c +++ b/gba/src/4bcanvas.c @@ -29,19 +29,19 @@ it freely, subject to the following restrictions: #include "4bcanvas.h" #include -#include +#include void dma_memset16(void *dst, unsigned int c16, size_t n); const TileCanvas screen = { .left = 0, .top = 0, .width = 32, .height = 20, - .chrBase = (uint32_t *)PATRAM4(0, 0), + .chrBase = tile_mem[0][0].data, .map = 23, .core = 0, .mapTileBase = 0 }; static -void fillcol(uint32_t *dst, unsigned int colStride, +void fillcol(u32 *dst, unsigned int colStride, unsigned int l, unsigned int t, unsigned int r, unsigned int b, unsigned int c) @@ -58,13 +58,13 @@ void fillcol(uint32_t *dst, unsigned int colStride, void canvasRectfill(const TileCanvas *v, int l, int t, int r, int b, int c) { - uint32_t *dst = v->chrBase; + u32 *dst = v->chrBase; c &= 0x0000000F; c *= 0x11111111; unsigned int x = l; unsigned int stride = v->height * 8; - uint32_t *tile = dst + stride * (l >> 3); + u32 *tile = dst + stride * (l >> 3); if (t < 0) { t = 0; @@ -176,9 +176,9 @@ void canvasBlitAligned(const TileCanvas *src, const TileCanvas *dst, void canvasInit(const TileCanvas *w, unsigned int color) { #if ARM9 - NAMETABLE *dst = w->core ? &(MAP_SUB[w->map]) : &(MAP[w->map]); + SCREENMAT *dst = w->core ? &(se_mat_sub[w->map]) : &(se_mat[w->map]); #else - NAMETABLE *dst = &(MAP[w->map]); + SCREENMAT *dst = &(se_mat[w->map]); #endif int mapTile = w->mapTileBase; diff --git a/gba/src/4bcanvas.h b/gba/src/4bcanvas.h index 130cb51..2f1f5bc 100644 --- a/gba/src/4bcanvas.h +++ b/gba/src/4bcanvas.h @@ -28,13 +28,14 @@ it freely, subject to the following restrictions: #define P8_CANVAS_H #include +#include typedef struct TileCanvas { uint8_t left; // in 8 pixel units on nametable uint8_t top; // in 8 pixel units on nametable uint8_t width; // in 8 pixel units on nametable uint8_t height; // in 8 pixel units on nametable - uint32_t *chrBase; + u32 *chrBase; uint8_t map; // in 2 KiB units on VRAM uint8_t core; // 0: main; 1: sub uint16_t mapTileBase; diff --git a/gba/src/audiosync.c b/gba/src/audiosync.c index bb8b3e3..1d34e78 100644 --- a/gba/src/audiosync.c +++ b/gba/src/audiosync.c @@ -18,9 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include +#include #define PFMAP 23 @@ -70,19 +68,19 @@ void activity_audio_sync() { } unsigned int y = (progress < 60) ? 128 - progress : 8 + progress; - SOAM[0].attr0 = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_SQUARE; + SOAM[0].attr0 = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_SQUARE; SOAM[0].attr1 = 119 | ATTR1_SIZE_8; SOAM[0].attr2 = 0x0023; ppu_clear_oam(1); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; for (unsigned int i = 0; i < 6; ++i) { - BG_COLORS[i] = progress >= min_progress[i] ? RGB5(31, 31, 31) : RGB5(0, 0, 0); + pal_bg_mem[i] = progress >= min_progress[i] ? RGB5(31, 31, 31) : RGB5(0, 0, 0); } - OBJ_COLORS[1] = RGB5(31, 31, 31); + pal_obj_mem[1] = RGB5(31, 31, 31); ppu_copy_oam(); if (progress == 120) { diff --git a/gba/src/backlight.c b/gba/src/backlight.c index 6221831..2e889a0 100644 --- a/gba/src/backlight.c +++ b/gba/src/backlight.c @@ -18,8 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include +#include void activity_backlight_zone(void) { unsigned inverted = 0, hidden = 0, high_gear = 0, held_keys = 0, sz = 1; @@ -77,17 +76,17 @@ void activity_backlight_zone(void) { oam_used = 0; if (!hidden) { unsigned int i = oam_used; - SOAM[i].attr0 = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_SQUARE; - SOAM[i].attr1 = OBJ_X(x) | ATTR1_SIZE_8; + SOAM[i].attr0 = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_SQUARE; + SOAM[i].attr1 = ATTR1_X(x) | ATTR1_SIZE_8; SOAM[i].attr2 = (sz < 3) ? sz + 0x22 : 1; oam_used = i + 1; } ppu_clear_oam(oam_used); VBlankIntrWait(); - BG_COLORS[0] = inverted ? RGB5(31, 31, 31) : RGB5(0, 0, 0); - OBJ_COLORS[1] = inverted ? RGB5(0, 0, 0): RGB5(31, 31, 31); + pal_bg_mem[0] = inverted ? RGB5(31, 31, 31) : RGB5(0, 0, 0); + pal_obj_mem[1] = inverted ? RGB5(0, 0, 0): RGB5(31, 31, 31); ppu_copy_oam(); - REG_DISPCNT = MODE_0 | OBJ_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ; } } diff --git a/gba/src/global.h b/gba/src/global.h index 70f1be1..1ef3193 100644 --- a/gba/src/global.h +++ b/gba/src/global.h @@ -21,8 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define GLOBAL_H #include #include -#include -#include +#include #include "helppages.h" // Size of a statically sized array @@ -105,7 +104,7 @@ unsigned int autorepeat(unsigned int allowed_keys); typedef unsigned short VBTILE[8]; typedef unsigned char ONEBTILE[8]; extern unsigned char oam_used; -extern OBJATTR SOAM[128]; +extern OBJ_ATTR SOAM[128]; void ppu_clear_oam(size_t start); void ppu_copy_oam(void); void dma_memset16(void *s, unsigned int c, size_t n); @@ -121,13 +120,26 @@ int lcg_rand(void); // vwfdraw.c void loadMapRowMajor(unsigned short *dst, unsigned int tilenum, unsigned int width, unsigned int height); -void vwf8PutTile(uint32_t *dst, unsigned int glyphnum, +void vwf8PutTile(u32 *dst, unsigned int glyphnum, unsigned int x, unsigned int color); -const char *vwf8Puts(uint32_t *restrict dst, const char *restrict s, +const char *vwf8Puts(u32 *restrict dst, const char *restrict s, unsigned int x, unsigned int color); unsigned int vwf8StrWidth(const char *s); // vwflabels.c void vwfDrawLabels(const char *labelset, unsigned int sbb, unsigned int tilenum); +// Shims for the libgba to libtonc port +// Note: tonc.h uses u32 (unsigned) instead of standard uint32_t +// (unsigned long) for pointers into video memory +#define MAP se_mat +#define BG_WID_32 BG_SIZE0 +#define BG_WID_64 BG_SIZE1 +#define BG_HT_32 BG_SIZE0 +#define BG_HT_64 BG_SIZE2 +// write these as macros instead of static inline to make them constexpr +#define RGB5(r, g, b) (((r)<<0) | ((g)<<5) | ((b)<<10)) +#define PATRAM4(cbb, tile) (tile_mem[(cbb)][(tile)].data) +#define SPR_VRAM(tile) (tile_mem_obj[0][(tile)].data) + #endif diff --git a/gba/src/help.c b/gba/src/help.c index 64e67d3..21c7a62 100644 --- a/gba/src/help.c +++ b/gba/src/help.c @@ -17,11 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include -#include -#include -#include #include "global.h" #include "posprintf.h" #include "helpsprites_chr.h" @@ -105,7 +100,7 @@ static void load_help_bg(void) { // Clear VWF canvas dma_memset16(PATRAM4(3, 0), 0x1111 * FG_BGCOLOR, 32*WINDOW_WIDTH*17); - // Load background nametable + // Load background SCREENMAT dma_memset16(MAP[BGMAP][0], TILE_BACK_WALL, 64*(BACK_WALL_HT - 1)); dma_memset16(MAP[BGMAP][BACK_WALL_HT - 1], TILE_BACK_WALL_BOTTOM, 30*2); dma_memset16(MAP[BGMAP][BACK_WALL_HT], TILE_FLOOR_TOP, 30*2); @@ -118,7 +113,7 @@ static void load_help_bg(void) { MAP[BGMAP][SHADOW_Y + 1][SHADOW_X + 4 + x] = TILE_FLOOR_SHADOW + 0x0C03 - x; } - // Clear window nametable + // Clear window SCREENMAT dma_memset16(MAP[FGMAP], TILE_FG_BLANK, 32*21*2); dma_memset16(MAP[FGMAP + 1], TILE_FG_XPARENT, 32*21*2); @@ -153,22 +148,22 @@ static void help_draw_character(void) { unsigned int ou = oam_used; if (++blink_time < 8) { - SOAM[ou].attr0 = 49 | OBJ_16_COLOR | ATTR0_SQUARE; + SOAM[ou].attr0 = 49 | ATTR0_4BPP | ATTR0_SQUARE; SOAM[ou].attr1 = 48 | ATTR1_SIZE_8; - SOAM[ou].attr2 = BLINK_TILE | ATTR2_PALETTE(0); + SOAM[ou].attr2 = BLINK_TILE | ATTR2_PALBANK(0); ++ou; - SOAM[ou].attr0 = 49 | OBJ_16_COLOR | ATTR0_SQUARE; - SOAM[ou].attr1 = 40 | ATTR1_SIZE_8 | OBJ_HFLIP; - SOAM[ou].attr2 = BLINK_TILE | ATTR2_PALETTE(0); + SOAM[ou].attr0 = 49 | ATTR0_4BPP | ATTR0_SQUARE; + SOAM[ou].attr1 = 40 | ATTR1_SIZE_8 | ATTR1_HFLIP; + SOAM[ou].attr2 = BLINK_TILE | ATTR2_PALBANK(0); ++ou; } for (unsigned int i = 0; i < 2; ++i) { - unsigned int a0 = (18 + i * 64) | OBJ_16_COLOR | ATTR0_TALL; + unsigned int a0 = (18 + i * 64) | ATTR0_4BPP | ATTR0_TALL; unsigned int a1 = 16 | ATTR1_SIZE_64; - unsigned int a2 = (CHARACTER_VRAM_BASE + 32 * i) | ATTR2_PALETTE(0); + unsigned int a2 = (CHARACTER_VRAM_BASE + 32 * i) | ATTR2_PALBANK(0); SOAM[ou].attr0 = a0; - SOAM[ou].attr1 = a1 | OBJ_HFLIP; + SOAM[ou].attr1 = a1 | ATTR1_HFLIP; SOAM[ou].attr2 = a2; ++ou; SOAM[ou].attr0 = a0; @@ -183,9 +178,9 @@ static void help_draw_cursor(unsigned int objx) { if (objx >= 240) return; unsigned int ou = oam_used; - SOAM[ou].attr0 = (20 + help_cursor_y * 8) | OBJ_16_COLOR | ATTR0_SQUARE; + SOAM[ou].attr0 = (20 + help_cursor_y * 8) | ATTR0_4BPP | ATTR0_SQUARE; SOAM[ou].attr1 = objx | ATTR1_SIZE_8; - SOAM[ou].attr2 = ARROW_TILE | ATTR2_PALETTE(0); + SOAM[ou].attr2 = ARROW_TILE | ATTR2_PALBANK(0); oam_used = ou + 1; } @@ -201,7 +196,7 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Draw lines of text to the screen while (y < PAGE_MAX_LINES) { - unsigned long *dst = PATRAM4(3, (y + 1)*WINDOW_WIDTH); + u32 *dst = PATRAM4(3, (y + 1)*WINDOW_WIDTH); ++y; dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); src = vwf8Puts(dst, src, left, FG_FGCOLOR); @@ -213,7 +208,7 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Clear unused lines that had been used for (unsigned int clear_y = y; clear_y < help_height; ++clear_y) { - unsigned long *dst = PATRAM4(3, (clear_y + 1)*WINDOW_WIDTH); + u32 *dst = PATRAM4(3, (clear_y + 1)*WINDOW_WIDTH); dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); } @@ -225,7 +220,7 @@ static void help_draw_page(helpdoc_kind doc_num, unsigned int left, unsigned int // Draw status line depending on size of document and which // keys are enabled - unsigned long *dst = PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH); + u32 *dst = PATRAM4(3, (PAGE_MAX_LINES + 1)*WINDOW_WIDTH); dma_memset16(dst, FG_BGCOLOR*0x1111, WINDOW_WIDTH * 32); if (help_cumul_pages[doc_num + 1] - help_cumul_pages[doc_num] > 1) { @@ -297,7 +292,7 @@ unsigned int helpscreen(helpdoc_kind doc_num, unsigned int keymask) { // If the help VRAM needs to be reloaded, reload its tiles and map if (!help_bg_loaded) { - REG_DISPCNT = LCDC_OFF; + REG_DISPCNT = DCNT_BLANK; load_help_bg(); REG_DISPCNT = 0; } else { @@ -313,15 +308,15 @@ unsigned int helpscreen(helpdoc_kind doc_num, unsigned int keymask) { // Load palette VBlankIntrWait(); - dmaCopy(helpbgtiles_chrPal, BG_COLORS+0x00, sizeof(helpbgtiles_chrPal)); - dmaCopy(helpsprites_chrPal, OBJ_COLORS+0x00, sizeof(helpsprites_chrPal)); + tonccpy(pal_bg_mem+0x00, helpbgtiles_chrPal, sizeof(helpbgtiles_chrPal)); + tonccpy(pal_obj_mem+0x00, helpsprites_chrPal, sizeof(helpsprites_chrPal)); // Set up background regs (except DISPCNT) - BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(3)|SCREEN_BASE(BGMAP); - BGCTRL[0] = BG_16_COLOR|BG_WID_64|BG_HT_32|CHAR_BASE(3)|SCREEN_BASE(FGMAP); - BG_OFFSET[1].x = BG_OFFSET[1].y = 0; - BG_OFFSET[0].x = help_wnd_progress ? WXBASE : 256; - BG_OFFSET[0].y = 4; + REG_BGCNT[1] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(3)|BG_SBB(BGMAP); + REG_BGCNT[0] = BG_4BPP|BG_WID_64|BG_HT_32|BG_CBB(3)|BG_SBB(FGMAP); + REG_BG_OFS[1].x = REG_BG_OFS[1].y = 0; + REG_BG_OFS[0].x = help_wnd_progress ? WXBASE : 256; + REG_BG_OFS[0].y = 4; // Freeze while (1) { @@ -374,8 +369,8 @@ unsigned int helpscreen(helpdoc_kind doc_num, unsigned int keymask) { if (help_show_cursor) help_draw_cursor(512 - wx + 6); ppu_clear_oam(oam_used); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG1_ON | BG0_ON | OBJ_1D_MAP | OBJ_ON; - BG_OFFSET[0].x = wx; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG1 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; + REG_BG_OFS[0].x = wx; ppu_copy_oam(); } } diff --git a/gba/src/helppages.txt b/gba/src/helppages.txt index e6fa54f..a64381a 100644 --- a/gba/src/helppages.txt +++ b/gba/src/helppages.txt @@ -187,7 +187,6 @@ Like the Game Boy Color, the Game Boy Advance has a TFT display with a decent response time. - All GB LCDs use row inversion that can look like interlace, drawing @@ -195,9 +194,10 @@ even or odd lines darker in alternate frames. The Game Boy Player -accessory has a "Screen -Filter" effect that applies -a form of motion blur. +accessory's "Screen Filter" +effect applies motion blur +to pixel areas that match +two frames ago. == Sharpness == @@ -665,10 +665,10 @@ Select: Show or hide == 160p Test Suite == $COMMIT -HDMA is right for you +Welcome to Tonc © 2011-2016 Artemio Urbina -© 2015-2023 Damian Yerrick +© 2015-2024 Damian Yerrick This is free software; see the source for copying conditions. The program diff --git a/gba/src/main.c b/gba/src/main.c index 908dd2f..a788d6f 100644 --- a/gba/src/main.c +++ b/gba/src/main.c @@ -17,10 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include -#include -#include +#include #include #include #include "global.h" @@ -79,8 +76,8 @@ int main(void) { unsigned int last_page, last_y; // Enable vblank IRQ, without which VBlankIntrWait() won't work - irqInit(); - irqEnable(IRQ_VBLANK); + irq_init(NULL); + irq_add(II_VBLANK, NULL); //activity_overscan(); //helpscreen(helpsect_to_do, KEY_A|KEY_START|KEY_B|KEY_LEFT|KEY_RIGHT); activity_credits(); diff --git a/gba/src/megaton.c b/gba/src/megaton.c index ffe22f9..cd4bb83 100644 --- a/gba/src/megaton.c +++ b/gba/src/megaton.c @@ -18,9 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include +#include #include "posprintf.h" #define PFMAP 23 @@ -54,21 +52,21 @@ static void megaton_draw_boolean(unsigned int y, unsigned int value) { static void megaton_draw_reticle(unsigned int x, unsigned int y) { unsigned int i = oam_used; - y = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_SQUARE; - x = OBJ_X(x) | ATTR1_SIZE_16; + y = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_SQUARE; + x = ATTR1_X(x) | ATTR1_SIZE_16; SOAM[i].attr0 = y; SOAM[i].attr1 = x; SOAM[i++].attr2 = RETICLE_TILE; SOAM[i].attr0 = y; - SOAM[i].attr1 = x + 16 + OBJ_HFLIP; + SOAM[i].attr1 = x + 16 + ATTR1_HFLIP; SOAM[i++].attr2 = RETICLE_TILE; y += 16; SOAM[i].attr0 = y; - SOAM[i].attr1 = x + OBJ_VFLIP; + SOAM[i].attr1 = x + ATTR1_VFLIP; SOAM[i++].attr2 = RETICLE_TILE; SOAM[i].attr0 = y; - SOAM[i].attr1 = x + 16 + OBJ_HFLIP + OBJ_VFLIP; + SOAM[i].attr1 = x + 16 + ATTR1_HFLIP + ATTR1_VFLIP; SOAM[i++].attr2 = RETICLE_TILE; oam_used = i; } @@ -115,7 +113,7 @@ void activity_megaton() { if (xtarget < 128) diff = -diff; unsigned int early = diff < 0; unsigned int value = early ? -diff : diff; - uint32_t *tileaddr = PATRAM4(0, 0x30 + progress * 2); + u32 *tileaddr = PATRAM4(0, 0x30 + progress * 2); dma_memset16(tileaddr, 0x0000, 32 * 2); if (early) { vwf8PutTile(tileaddr, 'E', 0, 1); @@ -168,12 +166,12 @@ void activity_megaton() { ppu_clear_oam(oam_used); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - BG_COLORS[0] = (x == 128 && with_audio) ? RGB5(31, 31, 31) : RGB5(0, 0, 0); - BG_COLORS[1] = OBJ_COLORS[1] = RGB5(31, 31, 31); - BG_COLORS[2] = RGB5(20, 25, 31); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + pal_bg_mem[0] = (x == 128 && with_audio) ? RGB5(31, 31, 31) : RGB5(0, 0, 0); + pal_bg_mem[1] = pal_obj_mem[1] = RGB5(31, 31, 31); + pal_bg_mem[2] = RGB5(20, 25, 31); ppu_copy_oam(); // Draw the cursor @@ -191,7 +189,7 @@ void activity_megaton() { REG_SOUND1CNT_X = (2048 - 131) | 0x8000; } while (!(new_keys & KEY_B) && (progress < NUM_TRIALS)); - BG_COLORS[0] = RGB5(0, 0, 0); + pal_bg_mem[0] = RGB5(0, 0, 0); REG_SOUNDCNT_X = 0; // reset audio if (progress < 10) return; diff --git a/gba/src/motionblur.c b/gba/src/motionblur.c index c1ce878..f13ee10 100644 --- a/gba/src/motionblur.c +++ b/gba/src/motionblur.c @@ -18,8 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include +#include #define PFMAP 23 #define NUM_PARAMS 6 @@ -105,10 +104,10 @@ void activity_motion_blur() { if (!running) bgc1[1] = bgc1[1] >= 16 ? 0 : 31; VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; for (unsigned int i = 0; i < 4; ++i) { - BG_COLORS[i] = RGB5(1, 1, 1) * bgc1[i]; + pal_bg_mem[i] = RGB5(1, 1, 1) * bgc1[i]; } for (unsigned int i = 0; i < 6; ++i) { MAP[PFMAP][13 + i][10] = (i == y) ? ARROW_TILE : BLANK_TILE; @@ -123,6 +122,6 @@ void activity_motion_blur() { unsigned int stripes_tile = params[5] ? 0x22 : 0x20; // On and Off MAP[PFMAP][18][18] = stripes_tile; MAP[PFMAP][18][19] = stripes_tile + 1; - REG_DISPCNT = MODE_0 | BG0_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } while (!(new_keys & KEY_B)); } diff --git a/gba/src/overscan.c b/gba/src/overscan.c index 7a68b28..530e127 100644 --- a/gba/src/overscan.c +++ b/gba/src/overscan.c @@ -18,8 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include +#include #include #define PFMAP 23 @@ -57,16 +56,16 @@ static void overscan_draw_arrow(unsigned int side, unsigned int dist) { y = 144 - dist; break; } - SOAM[i].attr0 = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_SQUARE; - SOAM[i].attr1 = OBJ_X(x) | OBJ_HFLIP | OBJ_VFLIP; + SOAM[i].attr0 = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_SQUARE; + SOAM[i].attr1 = ATTR1_X(x) | ATTR1_HFLIP | ATTR1_VFLIP; SOAM[i].attr2 = tilenum; if (side & 0x02) { y += 8; } else { x += 8; } - SOAM[i + 1].attr0 = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_SQUARE; - SOAM[i + 1].attr1 = OBJ_X(x); + SOAM[i + 1].attr0 = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_SQUARE; + SOAM[i + 1].attr1 = ATTR1_X(x); SOAM[i + 1].attr2 = tilenum; oam_used = i + 2; } @@ -78,7 +77,7 @@ void activity_overscan() { load_common_obj_tiles(); load_common_bg_tiles(); // Make all BG tiles opaque - for (uint32_t *c = PATRAM4(0, 0); c < PATRAM4(0, 32); ++c) { + for (u32 *c = PATRAM4(0, 0); c < PATRAM4(0, 32); ++c) { *c |= 0x44444444; } dma_memset16(MAP[PFMAP], 0x0004, 32*20*2); @@ -112,17 +111,17 @@ void activity_overscan() { VBlankIntrWait(); // Color 0: outside - BG_COLORS[0] = BG_COLORS[5] = inverted ? RGB5(0, 0, 0) : RGB5(31, 31, 31); - BG_COLORS[4] = inverted ? RGB5(23, 23, 23) : RGB5(15, 15, 15); + pal_bg_mem[0] = pal_bg_mem[5] = inverted ? RGB5(0, 0, 0) : RGB5(31, 31, 31); + pal_bg_mem[4] = inverted ? RGB5(23, 23, 23) : RGB5(15, 15, 15); if (cur_keys & KEY_A) { - OBJ_COLORS[2] = inverted ? RGB5(31, 31, 31) : RGB5(0, 0, 0); + pal_obj_mem[2] = inverted ? RGB5(31, 31, 31) : RGB5(0, 0, 0); } else { - OBJ_COLORS[2] = inverted ? RGB5(15, 15, 15) : RGB5(23, 23, 23); + pal_obj_mem[2] = inverted ? RGB5(15, 15, 15) : RGB5(23, 23, 23); } - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; ppu_copy_oam(); - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON | WIN0_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ | DCNT_WIN0; REG_WINOUT = 0x10; // BG0 inside, BG1 outside REG_WININ = 0x11; // start<<8 | end diff --git a/gba/src/pads.c b/gba/src/pads.c index c4178e4..b8b2c7e 100644 --- a/gba/src/pads.c +++ b/gba/src/pads.c @@ -22,7 +22,7 @@ it freely, subject to the following restrictions: "Source" is the preferred form of a work for making changes to it. */ -#include +#include #include "global.h" #define DAS_DELAY 12 diff --git a/gba/src/placeholder.c b/gba/src/placeholder.c index 12ace63..20de40e 100644 --- a/gba/src/placeholder.c +++ b/gba/src/placeholder.c @@ -22,10 +22,7 @@ it freely, subject to the following restrictions: "Source" is the preferred form of a work for making changes to it. */ -#include -#include -#include -#include +#include #include #include "global.h" @@ -57,7 +54,7 @@ static void move_player(void) { if (cur_keys & KEY_RIGHT) { player_dx += WALK_ACCEL; if (player_dx > WALK_SPD) player_dx = WALK_SPD; - player_facing &= ~OBJ_HFLIP; + player_facing &= ~ATTR1_HFLIP; } else { player_dx -= WALK_BRAKE; if (player_dx < 0) player_dx = 0; @@ -69,7 +66,7 @@ static void move_player(void) { if (cur_keys & KEY_LEFT) { player_dx -= WALK_ACCEL; if (player_dx < -WALK_SPD) player_dx = -WALK_SPD; - player_facing |= OBJ_HFLIP; + player_facing |= ATTR1_HFLIP; } else { player_dx += WALK_BRAKE; if (player_dx > 0) player_dx = 0; @@ -107,15 +104,15 @@ static void draw_player_sprite(void) { unsigned int player_hotspot_x = (player_x >> 8) - 8; if ((player_frame >> 8) == 7) { // Frame 1 needs to be drawn 1 pixel forward - player_hotspot_x += (player_facing & OBJ_HFLIP) ? -1 : 1; + player_hotspot_x += (player_facing & ATTR1_HFLIP) ? -1 : 1; } - unsigned int attr1 = OBJ_X(player_hotspot_x) | player_facing; + unsigned int attr1 = ATTR1_X(player_hotspot_x) | player_facing; - SOAM[i].attr0 = OBJ_Y(player_y - 24) | OBJ_16_COLOR | ATTR0_WIDE; + SOAM[i].attr0 = ATTR0_Y(player_y - 24) | ATTR0_4BPP | ATTR0_WIDE; SOAM[i].attr1 = attr1 | ATTR1_SIZE_8; SOAM[i].attr2 = tile; ++i; - SOAM[i].attr0 = OBJ_Y(player_y - 16) | OBJ_16_COLOR | ATTR0_SQUARE; + SOAM[i].attr0 = ATTR0_Y(player_y - 16) | ATTR0_4BPP | ATTR0_SQUARE; SOAM[i].attr1 = attr1 | ATTR1_SIZE_16; SOAM[i].attr2 = tile + 2; ++i; @@ -170,7 +167,7 @@ static void draw_bg(void) { void lame_boy_demo() { // Forced blanking - REG_DISPCNT = LCDC_OFF; + REG_DISPCNT = DCNT_BLANK; draw_bg(); load_player(); REG_DISPCNT = 0; @@ -185,12 +182,12 @@ void lame_boy_demo() { ppu_clear_oam(oam_used); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - dmaCopy(bgcolors00, BG_COLORS+0x00, sizeof(bgcolors00)); - dmaCopy(bgcolors10, BG_COLORS+0x10, sizeof(bgcolors10)); - dmaCopy(spritegfx_chrPal, OBJ_COLORS+0x00, sizeof(spritegfx_chrPal)); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + tonccpy(pal_bg_mem+0x00, bgcolors00, sizeof(bgcolors00)); + tonccpy(pal_bg_mem+0x10, bgcolors10, sizeof(bgcolors10)); + tonccpy(pal_obj_mem+0x00, spritegfx_chrPal, sizeof(spritegfx_chrPal)); ppu_copy_oam(); } while (!(new_keys & KEY_B)); } diff --git a/gba/src/ppuclear.c b/gba/src/ppuclear.c index 8eb98a8..1c5d83f 100644 --- a/gba/src/ppuclear.c +++ b/gba/src/ppuclear.c @@ -23,10 +23,10 @@ it freely, subject to the following restrictions: */ #include "global.h" -#include -#include +#include -EWRAM_BSS OBJATTR SOAM[128]; + +EWRAM_BSS OBJ_ATTR SOAM[128]; unsigned char oam_used; /** @@ -34,24 +34,23 @@ unsigned char oam_used; */ void ppu_clear_oam(size_t start) { for (; start < 128; ++start) { - SOAM[start].attr0 = OBJ_DISABLE; + SOAM[start].attr0 = ATTR0_HIDE; } } void ppu_copy_oam() { - dmaCopy(SOAM, OAM, sizeof(SOAM)); + tonccpy(oam_mem, SOAM, sizeof(SOAM)); } -void dma_memset16(void *dst, unsigned int c16, size_t n) { - volatile unsigned short src = c16; - DMA_Copy(3, &src, dst, DMA_SRC_FIXED | DMA16 | (n>>1)); +void dma_memset16(void *dst, unsigned int c16, size_t length_bytes) { + dma_fill(dst, c16, length_bytes >> 1, 3, DMA_16|DMA_ENABLE); } void bitunpack2(void *restrict dst, const void *restrict src, size_t len) { // Load tiles BUP bgtilespec = { - .SrcNum=len, .SrcBitNum=2, .DestBitNum=4, - .DestOffset=0, .DestOffset0_On=0 + .src_len=len, .src_bpp=2, .dst_bpp=4, + .dst_ofs=0 }; BitUnPack(src, dst, &bgtilespec); } @@ -59,15 +58,15 @@ void bitunpack2(void *restrict dst, const void *restrict src, size_t len) { void bitunpack1(void *restrict dst, const void *restrict src, size_t len) { // Load tiles BUP bgtilespec = { - .SrcNum=len, .SrcBitNum=1, .DestBitNum=4, - .DestOffset=0, .DestOffset0_On=0 + .src_len=len, .src_bpp=1, .dst_bpp=4, + .dst_ofs=0 }; BitUnPack(src, dst, &bgtilespec); } void load_flat_map(unsigned short *dst, const unsigned short *src, unsigned int w, unsigned int h) { for (; h > 0; --h) { - dmaCopy(src, dst, w * 2); + tonccpy(dst, src, w * 2); src += w; dst += 32; } diff --git a/gba/src/scrolltest.c b/gba/src/scrolltest.c index 12aade0..812bb3f 100644 --- a/gba/src/scrolltest.c +++ b/gba/src/scrolltest.c @@ -18,11 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include -#include -#include +#include + #include "kikitiles_chr.h" #include "kikimap_chr.h" @@ -84,12 +81,12 @@ void activity_grid_scroll(void) { y += scrolltest_dy; } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - BG_OFFSET[0].x = x; - BG_OFFSET[0].y = y; - BG_COLORS[0] = inverted ? RGB5(31,31,31) : RGB5(0, 0, 0); - BG_COLORS[1] = inverted ? RGB5(0, 0, 0) : RGB5(31,31,31); - REG_DISPCNT = MODE_0 | BG0_ON; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + REG_BG_OFS[0].x = x; + REG_BG_OFS[0].y = y; + pal_bg_mem[0] = inverted ? RGB5(31,31,31) : RGB5(0, 0, 0); + pal_bg_mem[1] = inverted ? RGB5(0, 0, 0) : RGB5(31,31,31); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } while (!(new_keys & KEY_B)); } @@ -208,12 +205,12 @@ void activity_kiki_scroll(void) { move_1d_scroll(); VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_64|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - BG_OFFSET[0].y = scrolltest_y >> 1; - BG_OFFSET[0].x = 8; - REG_DISPCNT = MODE_0 | BG0_ON; - dmaCopy(kikipalette0, BG_COLORS+0, sizeof(kikipalette0)); - dmaCopy(kikipalette1, BG_COLORS+16, sizeof(kikipalette1)); + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_64|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + REG_BG_OFS[0].y = scrolltest_y >> 1; + REG_BG_OFS[0].x = 8; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; + tonccpy(pal_bg_mem+0, kikipalette0, sizeof(kikipalette0)); + tonccpy(pal_bg_mem+16, kikipalette1, sizeof(kikipalette1)); } while (!(new_keys & KEY_B)); } @@ -226,8 +223,8 @@ void hill_zone_load_bg(void) { // Parallax scrolling for hill zone void hill_zone_set_scroll(uint16_t *hdmaTable, unsigned int x) { - BGCTRL[1] = BG_16_COLOR|BG_WID_64|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - dmaCopy(greenhillzone_chrPal, BG_COLORS+0, sizeof(greenhillzone_chrPal)); + REG_BGCNT[1] = BG_4BPP|BG_WID_64|BG_HT_32|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + tonccpy(pal_bg_mem+0, greenhillzone_chrPal, sizeof(greenhillzone_chrPal)); // Because libgba's ISR takes so long, we're already out of hblank // before Halt() returns. @@ -243,9 +240,9 @@ void hill_zone_set_scroll(uint16_t *hdmaTable, unsigned int x) { REG_DMA0CNT = 0; REG_DMA0SAD = (intptr_t)&(hdmaTable[1]); - REG_DMA0DAD = (intptr_t)&(BG_OFFSET[1].x); - REG_DMA0CNT = 1|DMA_DST_RELOAD|DMA_SRC_INC|DMA_REPEAT|DMA16|DMA_HBLANK|DMA_ENABLE; - BG_OFFSET[1].x = hdmaTable[0]; + REG_DMA0DAD = (intptr_t)&(REG_BG_OFS[1].x); + REG_DMA0CNT = 1|DMA_DST_RELOAD|DMA_SRC_INC|DMA_REPEAT|DMA_16|DMA_AT_HBLANK|DMA_ENABLE; + REG_BG_OFS[1].x = hdmaTable[0]; } void activity_hill_zone_scroll(void) { @@ -259,7 +256,7 @@ void activity_hill_zone_scroll(void) { move_1d_scroll(); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG1_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG1; hill_zone_set_scroll(hdmaTable, scrolltest_y); } while (!(new_keys & KEY_B)); REG_DMA0CNT = 0; diff --git a/gba/src/shadowsprite.c b/gba/src/shadowsprite.c index d19e936..f6e022b 100644 --- a/gba/src/shadowsprite.c +++ b/gba/src/shadowsprite.c @@ -18,10 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include -#include +#include #include #include "Donna_chr.h" @@ -40,10 +37,10 @@ static void gus_bg_setup(void) { static void gus_bg_set_scroll(uint16_t *hdmaTable, unsigned int unused) { (void)hdmaTable; (void)unused; - BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - BG_OFFSET[1].x = 0; - BG_OFFSET[1].y = 0; - dmaCopy(Gus_portrait_chrPal, BG_COLORS, sizeof(Gus_portrait_chrPal)); + REG_BGCNT[1] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + REG_BG_OFS[1].x = 0; + REG_BG_OFS[1].y = 0; + tonccpy(pal_bg_mem, Gus_portrait_chrPal, sizeof(Gus_portrait_chrPal)); } static void donna_bg_setup(void) { @@ -55,10 +52,10 @@ static void donna_bg_setup(void) { static void donna_bg_set_scroll(uint16_t *hdmaTable, unsigned int unused) { (void)hdmaTable; (void)unused; - BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - BG_OFFSET[1].x = 0; - BG_OFFSET[1].y = 0; - dmaCopy(Donna_chrPal, BG_COLORS, sizeof(Donna_chrPal)); + REG_BGCNT[1] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + REG_BG_OFS[1].x = 0; + REG_BG_OFS[1].y = 0; + tonccpy(pal_bg_mem, Donna_chrPal, sizeof(Donna_chrPal)); } static void striped_bg_setup(unsigned int tilenum) { @@ -77,11 +74,11 @@ static void bg_3_setup() { static void striped_bg_set_scroll(uint16_t *hdmaTable, unsigned int unused) { (void)hdmaTable; (void)unused; - BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFSCROLLTEST); - BG_OFFSET[1].x = 0; - BG_OFFSET[1].y = 0; - BG_COLORS[0] = BG_COLORS[2] = 0; - BG_COLORS[3] = RGB5(31, 31, 31); + REG_BGCNT[1] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFSCROLLTEST); + REG_BG_OFS[1].x = 0; + REG_BG_OFS[1].y = 0; + pal_bg_mem[0] = pal_bg_mem[2] = 0; + pal_bg_mem[3] = RGB5(31, 31, 31); } typedef struct ShadowSpriteBG { @@ -138,10 +135,10 @@ void activity_shadow_sprite() { bitunpack2(SPR_VRAM(0), hepsie_chrTiles, sizeof(hepsie_chrTiles)); // Generate stippled masks at 32, 64, and 96 for (unsigned int maskid = 0; maskid < 3; ++maskid) { - const uint32_t *src = SPR_VRAM(0); - uint32_t *dst = SPR_VRAM(32 + 32 * maskid); - uint32_t maskA = 0x01010101 * shadowmasks[maskid][0]; - uint32_t maskB = 0x01010101 * shadowmasks[maskid][1]; + const u32 *src = SPR_VRAM(0); + u32 *dst = SPR_VRAM(32 + 32 * maskid); + u32 maskA = 0x01010101 * shadowmasks[maskid][0]; + u32 maskB = 0x01010101 * shadowmasks[maskid][1]; for(; src < SPR_VRAM(32); src += 2, dst += 2) { dst[0] = src[0] & maskA; @@ -163,13 +160,13 @@ void activity_shadow_sprite() { if (cur_keys & KEY_A) { if (new_keys & KEY_RIGHT) { if (++cur_bg >= NUM_BGTYPES) cur_bg = 0; - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; bgtypes[cur_bg].setup(); held_keys &= ~KEY_A; } if (new_keys & KEY_LEFT) { cur_bg = cur_bg ? cur_bg - 1 : NUM_BGTYPES - 1; - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; bgtypes[cur_bg].setup(); held_keys &= ~KEY_A; } @@ -197,7 +194,7 @@ void activity_shadow_sprite() { } if ((cur_keys & KEY_LEFT) && x > 0) { x -= 1; - facing = OBJ_HFLIP; + facing = ATTR1_HFLIP; } if ((cur_keys & KEY_DOWN) && y < 160 - 32) { y += 1; @@ -210,12 +207,12 @@ void activity_shadow_sprite() { unsigned int i = 0, sx = x, sy = y; if (cur_shape) { // Draw the nontransparent part of Hepsie - SOAM[i].attr0 = OBJ_Y(y) | OBJ_16_COLOR | ATTR0_WIDE; - SOAM[i].attr1 = OBJ_X(x - 4) | ATTR1_SIZE_32 | facing; + SOAM[i].attr0 = ATTR0_Y(y) | ATTR0_4BPP | ATTR0_WIDE; + SOAM[i].attr1 = ATTR1_X(x - 4) | ATTR1_SIZE_32 | facing; SOAM[i].attr2 = 0x0010; ++i; - SOAM[i].attr0 = OBJ_Y(y + 16) | OBJ_16_COLOR | ATTR0_WIDE; - SOAM[i].attr1 = OBJ_X(x - 4) | ATTR1_SIZE_32 | facing; + SOAM[i].attr0 = ATTR0_Y(y + 16) | ATTR0_4BPP | ATTR0_WIDE; + SOAM[i].attr1 = ATTR1_X(x - 4) | ATTR1_SIZE_32 | facing; SOAM[i].attr2 = 0x1018; ++i; sx += 4; @@ -226,8 +223,8 @@ void activity_shadow_sprite() { // Draw the actual shadow using palette 2 unsigned int tilenum = shadow_type - (shadow_type > 0); tilenum = tilenum * 32 + cur_shape * 16; - SOAM[i].attr0 = OBJ_Y(sy) | OBJ_16_COLOR | ATTR0_SQUARE; - SOAM[i].attr1 = OBJ_X(sx) | ATTR1_SIZE_32 | facing; + SOAM[i].attr0 = ATTR0_Y(sy) | ATTR0_4BPP | ATTR0_SQUARE; + SOAM[i].attr1 = ATTR1_X(sx) | ATTR1_SIZE_32 | facing; SOAM[i].attr2 = 0x2000 + tilenum; ++i; } @@ -235,17 +232,17 @@ void activity_shadow_sprite() { VBlankIntrWait(); REG_DMA0CNT = 0; - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(2)|SCREEN_BASE(PFOVERLAY); - BG_OFFSET[0].x = 0; - BG_OFFSET[0].y = (changetimeout > 8) ? 8 : changetimeout; - BG_COLORS[241] = RGB5(31, 31, 31); - BG_COLORS[242] = RGB5(0, 0, 0); + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(2)|BG_SBB(PFOVERLAY); + REG_BG_OFS[0].x = 0; + REG_BG_OFS[0].y = (changetimeout > 8) ? 8 : changetimeout; + pal_bg_mem[241] = RGB5(31, 31, 31); + pal_bg_mem[242] = RGB5(0, 0, 0); for (unsigned int y = 0; y < 3; ++y) { for (unsigned int x = 0; x < 3; ++x) { - OBJ_COLORS[y * 16 + x + 1] = shadow_sprite_palettes[y][x]; + pal_obj_mem[y * 16 + x + 1] = shadow_sprite_palettes[y][x]; } } - REG_DISPCNT = MODE_0 | BG0_ON | BG1_ON | OBJ_1D_MAP | OBJ_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ_1D | DCNT_OBJ; ppu_copy_oam(); bgtypes[cur_bg].set_scroll(hdmaTable, x * 4); } while (!(new_keys & KEY_B)); diff --git a/gba/src/soundtest.c b/gba/src/soundtest.c index 0fbc30c..e20d057 100644 --- a/gba/src/soundtest.c +++ b/gba/src/soundtest.c @@ -18,11 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include -#include -#include +#include // PSG ////////////////////////////////////////////////////////////// @@ -44,12 +40,12 @@ const unsigned char waveram_sin16x[16] __attribute__((aligned (2))) = { }; static void wait24() { - ((volatile u16 *)BG_COLORS)[6] = RGB5(31, 0, 0); + ((volatile u16 *)pal_bg_mem)[6] = RGB5(31, 0, 0); for (unsigned int i = 24; i > 0; --i) { VBlankIntrWait(); - dma_memset16(BG_COLORS + 6, RGB5(31, 0, 0), 2); + dma_memset16(pal_bg_mem + 6, RGB5(31, 0, 0), 2); } - BG_COLORS[6] = RGB5(31, 31, 31); + pal_bg_mem[6] = RGB5(31, 31, 31); } static void reinitAudio(void) { @@ -61,7 +57,7 @@ static void reinitAudio(void) { static void beepTri(const unsigned char *wave, unsigned int period) { REG_SOUND3CNT_L = 0; // unlock waveram - dmaCopy(wave, (void *)WAVE_RAM, 16); + tonccpy((void *)REG_WAVE_RAM, wave, 16); REG_SOUND3CNT_L = 0xC0; // lock waveram REG_SOUND3CNT_H = 0x2000; // full volume REG_SOUND3CNT_X = (2048 - period) + 0x8000; // pitch @@ -188,7 +184,7 @@ IWRAM_CODE static void beepPCM(void) { (voices[ch].delaylineend - i) / 4); } - ((volatile u16 *)BG_COLORS)[6] = RGB5(31, 0, 0); + ((volatile u16 *)pal_bg_mem)[6] = RGB5(31, 0, 0); REG_TM0CNT_L = 65536 - PCM_PERIOD; // 18157 Hz REG_TM0CNT_H = 0x0080; // enable timer REG_SOUNDBIAS = 0x4200; // 65.5 kHz PWM (for PCM) @@ -226,7 +222,7 @@ IWRAM_CODE static void beepPCM(void) { } while (!new_keys && frames < 400); REG_TM0CNT_H = 0; // stop timer REG_DMA1CNT = 0; // stop DMA - BG_COLORS[6] = RGB5(31, 31, 31); + pal_bg_mem[6] = RGB5(31, 31, 31); REG_SOUNDBIAS = 0xC200; // 65.5 kHz PWM (for PCM) } diff --git a/gba/src/stills.c b/gba/src/stills.c index 8bc4d2c..6dd79b7 100644 --- a/gba/src/stills.c +++ b/gba/src/stills.c @@ -17,12 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include -#include -#include -#include -#include +#include #include #include "global.h" #include "4bcanvas.h" @@ -140,12 +135,12 @@ void activity_monoscope(void) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - BG_PALETTE[0] = (brightness >= 4) ? RGB5(13,13,13) : 0; - BG_PALETTE[1] = monoscope_whites[brightness]; - BG_PALETTE[2] = RGB5(31, 0, 0); - REG_DISPCNT = MODE_0 | BG0_ON; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + pal_bg_mem[0] = (brightness >= 4) ? RGB5(13,13,13) : 0; + pal_bg_mem[1] = monoscope_whites[brightness]; + pal_bg_mem[2] = RGB5(31, 0, 0); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } } @@ -155,7 +150,7 @@ void activity_sharpness(void) { bitunpack2(PATRAM4(0, 0), sharpness_chrTiles, sizeof(sharpness_chrTiles)); RLUnCompVram(sharpness_chrMap, MAP[PFMAP]); - dmaCopy(brickstile, PATRAM4(0, 63), sizeof(brickstile)); + tonccpy(PATRAM4(0, 63), brickstile, sizeof(brickstile)); dma_memset16(MAP[PFOVERLAY], 0x043F, 32*20*2); while (1) { @@ -171,13 +166,13 @@ void activity_sharpness(void) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0) - |SCREEN_BASE(is_bricks ? PFOVERLAY : PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0) + |BG_SBB(is_bricks ? PFOVERLAY : PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; const unsigned short *palsrc = inverted ? invgray4pal : gray4pal; if (is_bricks) palsrc = brickspal; - dmaCopy(palsrc, BG_COLORS+0x00, sizeof(gray4pal)); - REG_DISPCNT = MODE_0 | BG0_ON; + tonccpy(pal_bg_mem+0x00, palsrc, sizeof(gray4pal)); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } } @@ -259,7 +254,7 @@ static void do_bars(const BarsListEntry *rects, helpdoc_kind helpsect) { REG_SOUNDCNT_H = 0x0002; // PSG/PCM mixing REG_SOUNDCNT_L = 0xFF77; // PSG vol/pan REG_SOUND3CNT_L = 0; // unlock waveram - dmaCopy(waveram_sin2x, (void *)WAVE_RAM, 16); + tonccpy((void *)REG_WAVE_RAM, waveram_sin2x, 16); REG_SOUND3CNT_L = 0xC0; // lock waveram REG_SOUND3CNT_H = 0; // volume control REG_SOUND3CNT_X = (2048 - 131) + 0x8000; // full volume @@ -280,10 +275,10 @@ static void do_bars(const BarsListEntry *rects, helpdoc_kind helpsect) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - dmaCopy(smptePalettes[bright], BG_COLORS+0x00, sizeof(smptePalettes[0])); - REG_DISPCNT = MODE_0 | BG0_ON; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + tonccpy(pal_bg_mem+0x00, smptePalettes[bright], sizeof(smptePalettes[0])); + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; REG_SOUND3CNT_H = beep; } } @@ -307,7 +302,7 @@ void activity_pluge(void) { for (unsigned int x = 6; x < 24; x += 1) { if (x == 8) x = 22; unsigned int stride = screen.height * 8; - uint32_t *tile = screen.chrBase + stride * x + 8; + u32 *tile = screen.chrBase + stride * x + 8; for (unsigned int yleft = 72; yleft > 0; --yleft) { *tile++ = 0x23232323; *tile++ = 0x32323232; @@ -336,14 +331,16 @@ void activity_pluge(void) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(shark ? PFOVERLAY : PFMAP); - BG_OFFSET[0].y = BG_OFFSET[0].x = 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(shark ? PFOVERLAY : PFMAP); + REG_BG_OFS[0].y = REG_BG_OFS[0].x = 0; if (shark) { - dmaCopy(pluge_shark_palettes[bright], BG_COLORS+0x00, sizeof(pluge_shark_6color_chrPal)); + tonccpy(pal_bg_mem+0x00, pluge_shark_palettes[bright], + sizeof(pluge_shark_6color_chrPal)); } else { - dmaCopy(bright ? plugePaletteNTSCJ : plugePaletteNTSC, BG_COLORS+0x00, sizeof(plugePaletteNTSC)); + tonccpy(pal_bg_mem+0x00, bright ? plugePaletteNTSCJ : plugePaletteNTSC, + sizeof(plugePaletteNTSC)); } - REG_DISPCNT = MODE_0 | BG0_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } } @@ -369,7 +366,7 @@ static const char gcbars_labels[] = "\x10""\x78""White"; void activity_gcbars(void) { - unsigned int bgctrl0 = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); + unsigned int REG_BGCNT0 = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); load_common_bg_tiles(); // Draw 5-pixel-wide vertical bars @@ -423,14 +420,14 @@ void activity_gcbars(void) { return; } if (new_keys & KEY_A) { - bgctrl0 ^= SCREEN_BASE(PFMAP) ^ SCREEN_BASE(PFOVERLAY); + REG_BGCNT0 ^= BG_SBB(PFMAP) ^ BG_SBB(PFOVERLAY); } VBlankIntrWait(); - BGCTRL[0] = bgctrl0; - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - BG_COLORS[0] = RGB5(0, 0, 0); - BG_COLORS[1] = RGB5(31, 31, 31); + REG_BGCNT[0] = REG_BGCNT0; + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + pal_bg_mem[0] = RGB5(0, 0, 0); + pal_bg_mem[1] = RGB5(31, 31, 31); // Calculate the color gradient unsigned int c = 0; @@ -443,10 +440,10 @@ void activity_gcbars(void) { c = 0; } } - BG_COLORS[p] = c; + pal_bg_mem[p] = c; c += *palramp; } - REG_DISPCNT = MODE_0 | BG0_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } } @@ -486,16 +483,16 @@ void activity_gray_ramp(void) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; unsigned int c = 0; for (unsigned int p = 1; p < 64; ++p) { - BG_COLORS[p] = c; + pal_bg_mem[p] = c; c += RGB5(1, 1, 1); if ((p & 0x0F) == 8) p += 8; } - REG_DISPCNT = MODE_0 | BG0_ON; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; } } @@ -521,7 +518,7 @@ static const unsigned short full_stripes_colors[10][2] = { static void do_full_stripes(helpdoc_kind helpsect) { unsigned int pattern = 0, inverted = 0, frame = 0; - unsigned int lcdcvalue = MODE_1 | BG1_ON; + unsigned int lcdcvalue = DCNT_MODE1 | DCNT_BG1; // tile 0: blank dma_memset16(PATRAM4(0, 0), 0x0000, 32); @@ -538,7 +535,7 @@ static void do_full_stripes(helpdoc_kind helpsect) { if (++pattern >= 3) pattern = 0; } if (new_keys & KEY_SELECT) { - lcdcvalue ^= BG0_ON; + lcdcvalue ^= DCNT_BG0; } if (new_keys & (KEY_UP|KEY_DOWN|KEY_LEFT|KEY_RIGHT)) { inverted ^= 0x33333333; @@ -551,19 +548,19 @@ static void do_full_stripes(helpdoc_kind helpsect) { posprintf(help_line_buffer, "Frame %02d", frame); VBlankIntrWait(); - BGCTRL[1] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFOVERLAY); - BG_OFFSET[0].x = BG_OFFSET[0].y = BG_OFFSET[1].x = 0; - BG_OFFSET[1].y = 4; - BG_COLORS[0] = RGB5(0, 0, 0); + REG_BGCNT[1] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFOVERLAY); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = REG_BG_OFS[1].x = 0; + REG_BG_OFS[1].y = 4; + pal_bg_mem[0] = RGB5(0, 0, 0); for (int c = 0; c < 10; ++c) { - BG_COLORS[c * 16 + 1] = full_stripes_colors[c][0]; - BG_COLORS[c * 16 + 2] = full_stripes_colors[c][1]; + pal_bg_mem[c * 16 + 1] = full_stripes_colors[c][0]; + pal_bg_mem[c * 16 + 2] = full_stripes_colors[c][1]; } REG_DISPCNT = lcdcvalue; // Draw the pattern - uint32_t *dst = PATRAM4(0, 1); + u32 *dst = PATRAM4(0, 1); for (unsigned int i = 4; i > 0; --i) { *dst++ = full_stripes_patterns[pattern][0] ^ inverted; *dst++ = full_stripes_patterns[pattern][1] ^ inverted; @@ -610,7 +607,7 @@ static const unsigned char rgbnames[3] = {'R', 'G', 'B'}; static void solid_color_draw_edit_box(const unsigned char rgb[3], unsigned int y) { dma_memset16(PATRAM4(0, 1), 0x2222, 32*9); for (unsigned int i = 0; i < 3; ++i) { - uint32_t *dst = PATRAM4(0, 3 * i + 1); + u32 *dst = PATRAM4(0, 3 * i + 1); // Draw label if (i == y) vwf8PutTile(dst, '>', 1, 1); @@ -669,12 +666,12 @@ void activity_solid_color(void) { } VBlankIntrWait(); - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - BG_COLORS[0] = x < 4 ? solid_colors[x] : RGB5(rgb[0], rgb[1], rgb[2]); - BG_COLORS[1] = RGB5(31, 31, 31); - BG_COLORS[2] = RGB5(0, 0, 0); - REG_DISPCNT = showeditbox ? (MODE_0 | BG0_ON) : 0; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + pal_bg_mem[0] = x < 4 ? solid_colors[x] : RGB5(rgb[0], rgb[1], rgb[2]); + pal_bg_mem[1] = RGB5(31, 31, 31); + pal_bg_mem[2] = RGB5(0, 0, 0); + REG_DISPCNT = showeditbox ? (DCNT_MODE0 | DCNT_BG0) : 0; } } @@ -712,24 +709,24 @@ void activity_convergence(void) { } VBlankIntrWait(); - BGCTRL[0] = (BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0) - |SCREEN_BASE(PFMAP-cur_side)); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - REG_DISPCNT = MODE_0 | BG0_ON; + REG_BGCNT[0] = (BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0) + |BG_SBB(PFMAP-cur_side)); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0; if (cur_side != 0) { - BG_COLORS[0x03] = RGB5(31,31,31); - BG_COLORS[0x13] = RGB5( 0, 0,31); - BG_COLORS[0x23] = RGB5( 0,31, 0); - BG_COLORS[0x33] = RGB5(31, 0, 0); - BG_COLORS[0x02] = colors_border ? 0 : RGB5(31,31,31); - BG_COLORS[0x12] = colors_border ? 0 : RGB5( 0, 0,31); - BG_COLORS[0x22] = colors_border ? 0 : RGB5( 0,31, 0); - BG_COLORS[0x32] = colors_border ? 0 : RGB5(31, 0, 0); + pal_bg_mem[0x03] = RGB5(31,31,31); + pal_bg_mem[0x13] = RGB5( 0, 0,31); + pal_bg_mem[0x23] = RGB5( 0,31, 0); + pal_bg_mem[0x33] = RGB5(31, 0, 0); + pal_bg_mem[0x02] = colors_border ? 0 : RGB5(31,31,31); + pal_bg_mem[0x12] = colors_border ? 0 : RGB5( 0, 0,31); + pal_bg_mem[0x22] = colors_border ? 0 : RGB5( 0,31, 0); + pal_bg_mem[0x32] = colors_border ? 0 : RGB5(31, 0, 0); } else { // Set palette for grid unsigned int color = gridinvert ? 0x7FFF : 0; for (unsigned int i = 0; i < 4; ++i) { - BG_COLORS[i] = color; + pal_bg_mem[i] = color; if (i == griddepth) color = color ^ 0x7FFF; } } diff --git a/gba/src/stopwatch.c b/gba/src/stopwatch.c index a20cd58..3462658 100644 --- a/gba/src/stopwatch.c +++ b/gba/src/stopwatch.c @@ -18,9 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "global.h" -#include -#include -#include +#include #include "stopwatchhand_chr.h" #include "stopwatchface_chr.h" @@ -63,8 +61,8 @@ static const char sw_labels[] = static void draw_stopwatch_hand(unsigned int phase) { unsigned int i = oam_used; - unsigned int a0 = OBJ_Y(sw_face_y[phase] - 12) | OBJ_16_COLOR | ATTR0_SQUARE; - unsigned int a1 = OBJ_X(sw_face_x[phase] + 28) | ATTR1_SIZE_16; + unsigned int a0 = ATTR0_Y(sw_face_y[phase] - 12) | ATTR0_4BPP | ATTR0_SQUARE; + unsigned int a1 = ATTR1_X(sw_face_x[phase] + 28) | ATTR1_SIZE_16; // draw digit SOAM[i].attr0 = a0 + 8; @@ -74,18 +72,18 @@ static void draw_stopwatch_hand(unsigned int phase) { SOAM[i].attr1 = a1; SOAM[i++].attr2 = 40; SOAM[i].attr0 = a0; - SOAM[i].attr1 = a1 + 16 + OBJ_HFLIP; + SOAM[i].attr1 = a1 + 16 + ATTR1_HFLIP; SOAM[i++].attr2 = 40; SOAM[i].attr0 = a0 + 16; - SOAM[i].attr1 = a1 + OBJ_VFLIP; + SOAM[i].attr1 = a1 + ATTR1_VFLIP; SOAM[i++].attr2 = 40; SOAM[i].attr0 = a0 + 16; - SOAM[i].attr1 = a1 + 16 + OBJ_HFLIP + OBJ_VFLIP; + SOAM[i].attr1 = a1 + 16 + ATTR1_HFLIP + ATTR1_VFLIP; SOAM[i++].attr2 = 40; // draw hand - a0 = OBJ_Y(sw_face_y[phase] / 2 + 48) | OBJ_16_COLOR | ATTR0_SQUARE; - a1 = OBJ_X(sw_face_x[phase] / 2 + 78) | ATTR1_SIZE_8; + a0 = ATTR0_Y(sw_face_y[phase] / 2 + 48) | ATTR0_4BPP | ATTR0_SQUARE; + a1 = ATTR1_X(sw_face_x[phase] / 2 + 78) | ATTR1_SIZE_8; SOAM[i].attr0 = a0; SOAM[i].attr1 = a1; SOAM[i++].attr2 = 44; @@ -157,18 +155,18 @@ void activity_stopwatch() { ppu_clear_oam(oam_used); VBlankIntrWait(); - REG_DISPCNT = MODE_0 | BG0_ON | OBJ_1D_MAP | OBJ_ON; - BGCTRL[0] = BG_16_COLOR|BG_WID_32|BG_HT_32|CHAR_BASE(0)|SCREEN_BASE(PFMAP); - BG_OFFSET[0].x = BG_OFFSET[0].y = 0; - BG_COLORS[0] = RGB5(31, 31, 31); - BG_COLORS[1] = hide_face ? RGB5(31, 31, 31) : RGB5(23, 23, 23); - BG_COLORS[3] = (show_ruler & (1 << (face_phase & 1))) + REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_OBJ_1D | DCNT_OBJ; + REG_BGCNT[0] = BG_4BPP|BG_WID_32|BG_HT_32|BG_CBB(0)|BG_SBB(PFMAP); + REG_BG_OFS[0].x = REG_BG_OFS[0].y = 0; + pal_bg_mem[0] = RGB5(31, 31, 31); + pal_bg_mem[1] = hide_face ? RGB5(31, 31, 31) : RGB5(23, 23, 23); + pal_bg_mem[3] = (show_ruler & (1 << (face_phase & 1))) ? RGB5(23, 0, 0) : RGB5(31, 31, 31); - BG_COLORS[65] = RGB5(0, 0, 0); - dmaCopy(invgray4pal, BG_COLORS+0x10, sizeof(invgray4pal)); - dmaCopy(bluepalette, BG_COLORS+0x21, sizeof(invgray4pal)); - dmaCopy(redpalette, BG_COLORS+0x31, sizeof(invgray4pal)); - dmaCopy(invgray4pal, OBJ_COLORS+0x00, sizeof(invgray4pal)); + pal_bg_mem[65] = RGB5(0, 0, 0); + tonccpy(pal_bg_mem+0x10, invgray4pal, sizeof(invgray4pal)); + tonccpy(pal_bg_mem+0x21, bluepalette, sizeof(bluepalette)); + tonccpy(pal_bg_mem+0x31, redpalette, sizeof(redpalette)); + tonccpy(pal_obj_mem+0x00, invgray4pal, sizeof(invgray4pal)); ppu_copy_oam(); // Update digits diff --git a/gba/src/vwfdraw.c b/gba/src/vwfdraw.c index 400ab43..9816041 100644 --- a/gba/src/vwfdraw.c +++ b/gba/src/vwfdraw.c @@ -28,7 +28,7 @@ it freely, subject to the following restrictions: #if 0 typedef struct VWFCanvas { - uint32_t *data; + u32 *data; unsigned short width, height; } VWFCanvas; @@ -83,7 +83,7 @@ void loadMapRowMajor(unsigned short *dst, unsigned int tilenum, #define FIRST_PRINTABLE_CU 0x18 -void vwf8PutTile(uint32_t *dst, unsigned int glyphnum, +void vwf8PutTile(u32 *dst, unsigned int glyphnum, unsigned int x, unsigned int color) { const unsigned char *glyph = vwfChrData[glyphnum - FIRST_PRINTABLE_CU]; unsigned int startmask = 0x0F << ((x & 0x07) * 4); @@ -91,13 +91,13 @@ void vwf8PutTile(uint32_t *dst, unsigned int glyphnum, color = (color & 0x0F) * 0x11111111; for (unsigned int htleft = 8; htleft > 0; --htleft) { - unsigned int mask = startmask; - unsigned int glyphdata = *glyph++; - uint32_t *sliver = dst++; + u32 mask = startmask; + u32 glyphdata = *glyph++; + u32 *sliver = dst++; for(; glyphdata; glyphdata >>= 1) { if (glyphdata & 0x01) { - uint32_t s = *sliver; + u32 s = *sliver; *sliver = ((s ^ color) & mask) ^ s; } mask <<= 4; @@ -112,7 +112,7 @@ void vwf8PutTile(uint32_t *dst, unsigned int glyphnum, /** * @return the address of the terminating control character */ -const char *vwf8Puts(uint32_t *restrict dst, const char *restrict s, +const char *vwf8Puts(u32 *restrict dst, const char *restrict s, unsigned int x, unsigned int color) { while (x < 240) { unsigned char c = *s & 0xFF; diff --git a/gba/src/vwflabels.c b/gba/src/vwflabels.c index 0f6e288..ab71d07 100644 --- a/gba/src/vwflabels.c +++ b/gba/src/vwflabels.c @@ -22,7 +22,7 @@ it freely, subject to the following restrictions: "Source" is the preferred form of a work for making changes to it. */ -#include +#include #include "global.h" // Single label: @@ -33,7 +33,7 @@ it freely, subject to the following restrictions: /** * @param labelset a '\n'-separated, '\0'-terminated list of * (x, y, printables) - * @param nt which nametable (tilemap, screenbaseblock) to draw into + * @param nt which SCREENMAT (tilemap, screenbaseblock) to draw into * @param tilenum bits 10-0: which tile number to start at; * bits 15-11: palette id */ @@ -53,7 +53,7 @@ void vwfDrawLabels(const char *labelset, unsigned int sbb, unsigned int tilenum) dma_memset16(chrdst, 0x0000, 32 * txtw); const char *strend = vwf8Puts(chrdst, labelset + 2, x & 0x07, 1); - // Fill the nametable + // Fill the SCREENMAT loadMapRowMajor(&(MAP[sbb][y >> 3][x >> 3]), tilenum & 0xF3FF, txtw, 1); tilenum += txtw;