diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 1daa99e1d..148ce31db 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -482,6 +482,7 @@ #define REG_SIODATA32 (*(vu32 *)REG_ADDR_SIODATA32) #define REG_SIOMLT_SEND (*(vu16 *)REG_ADDR_SIOMLT_SEND) #define REG_SIOMLT_RECV (*(vu64 *)REG_ADDR_SIOMLT_RECV) +#define REG_SIOMULTI(n) (*(vu16 *)(REG_ADDR_SIOMULTI0 + (n) * 2)) #define REG_SIOMULTI0 (*(vu16 *)REG_ADDR_SIOMULTI0) #define REG_SIOMULTI1 (*(vu16 *)REG_ADDR_SIOMULTI1) #define REG_SIOMULTI2 (*(vu16 *)REG_ADDR_SIOMULTI2) diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 27149873d..5944bc511 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -2394,12 +2394,12 @@ void AnimTask_SketchDrawMon(u8 taskId) if (GetBattlerSpriteBGPriorityRank(gBattleAnimTarget) == 1) { task->data[6] = gBattle_BG1_X; - params.dmaDest = (u16 *)REG_ADDR_BG1HOFS; + params.dmaDest = ®_BG1HOFS; } else { task->data[6] = gBattle_BG2_X; - params.dmaDest = (u16 *)REG_ADDR_BG2HOFS; + params.dmaDest = ®_BG2HOFS; } for (i = task->data[0] - 0x40; i <= task->data[0]; i++) diff --git a/src/battle_anim_ghost.c b/src/battle_anim_ghost.c index 03a003c60..60e943adf 100644 --- a/src/battle_anim_ghost.c +++ b/src/battle_anim_ghost.c @@ -653,9 +653,9 @@ static void AnimTask_SpiteTargetShadow_Step1(u8 taskId) startLine = 0; if (position == 1) - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 4, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG1HOFS, 1); else - task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, 8, 1); + task->data[10] = ScanlineEffect_InitWave(startLine, startLine + 64, 2, 6, 0, SCANLINE_EFFECT_REG_BG2HOFS, 1); task->data[15]++; break; diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 50918a24e..44df78421 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -960,7 +960,7 @@ static void AnimTask_SurfWaveScanlineEffect(u8 taskId) else gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2]; - params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA; + params.dmaDest = ®_BLDALPHA; params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; params.initState = 1; params.unused9 = 0; diff --git a/src/battle_dome.c b/src/battle_dome.c index 45df83c7c..1b067924f 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -870,7 +870,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] = static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams = { - .dmaDest = (void *)REG_ADDR_BG3CNT, + .dmaDest = ®_BG3CNT, .dmaControl = SCANLINE_EFFECT_DMACNT_16BIT, .initState = 1, }; diff --git a/src/battle_main.c b/src/battle_main.c index 8079546d4..85e1e1796 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -249,13 +249,13 @@ u8 gBattleControllerData[MAX_BATTLERS_COUNT]; // Used by the battle controllers static const struct ScanlineEffectParams sIntroScanlineParams16Bit = { - (void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1 + ®_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1 }; // unused static const struct ScanlineEffectParams sIntroScanlineParams32Bit = { - (void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1 + ®_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1 }; const struct SpriteTemplate gUnusedBattleInitSprite = diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index c27ec6c4c..0cf5e4145 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -56,7 +56,7 @@ const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1; const struct ScanlineEffectParams sFlashEffectParams = { - (void *)REG_ADDR_WIN0H, + ®_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, 1 }; diff --git a/src/intro.c b/src/intro.c index 5cf99c97e..024706f6c 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1848,7 +1848,7 @@ static void Task_Scene3_StartGroudon(u8 taskId) { gTasks[taskId].tState = 0; gTasks[taskId].func = Task_Scene3_Groudon; - ScanlineEffect_InitWave(0, 160, 4, 4, 1, 4, 0); + ScanlineEffect_InitWave(0, 160, 4, 4, 1, SCANLINE_EFFECT_REG_BG1HOFS, 0); } #define tScreenX data[1] @@ -2058,7 +2058,7 @@ static void Task_Scene3_LoadKyogre(u8 taskId) gTasks[taskId].tDelay = 16; gTasks[taskId].tZoom = 256; PanFadeAndZoomScreen(gTasks[taskId].tScreenX, gTasks[taskId].tScreenY, gTasks[taskId].tZoom, 0); - ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, 6, 0); + ScanlineEffect_InitWave(0, 0xA0, 4, 4, 1, SCANLINE_EFFECT_REG_BG1VOFS, 0); } static void Task_Scene3_Kyogre(u8 taskId) diff --git a/src/libisagbprn.c b/src/libisagbprn.c index e0e979e95..69c6986ae 100644 --- a/src/libisagbprn.c +++ b/src/libisagbprn.c @@ -31,7 +31,7 @@ void AGBPrintFlush1Block(void); void AGBPrintInit(void) { volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; u16 nOldWSCNT = *pWSCNT; *pWSCNT = WSCNT_DATA; @@ -57,7 +57,7 @@ static void AGBPutcInternal(const char cChr) void AGBPutc(const char cChr) { - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 nOldWSCNT = *pWSCNT; volatile struct AGBPrintStruct *pPrint; *pWSCNT = WSCNT_DATA; @@ -71,7 +71,7 @@ void AGBPutc(const char cChr) void AGBPrint(const char *pBuf) { volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; - u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pWSCNT = ®_WAITCNT; u16 nOldWSCNT = *pWSCNT; *pWSCNT = WSCNT_DATA; while (*pBuf) @@ -105,9 +105,9 @@ static void AGBPrintTransferDataInternal(u32 bAllData) pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; lpfnFuncFlush = (LPFN_PRINT_FLUSH)AGB_PRINT_FLUSH_ADDR; - pIME = (u16 *)REG_ADDR_IME; + pIME = ®_IME; nIME = *pIME; - pWSCNT = (u16 *)REG_ADDR_WAITCNT; + pWSCNT = ®_WAITCNT; nOldWSCNT = *pWSCNT; *pIME = nIME & ~1; *pWSCNT = WSCNT_DATA; diff --git a/src/librfu_intr.c b/src/librfu_intr.c index 19ea60b06..d902b1c45 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -336,8 +336,8 @@ static u16 handshake_wait(u16 slot) static void STWI_set_timer_in_RAM(u8 count) { - vu16* regTMCNTL = (vu16*)(REG_ADDR_TMCNT_L + gSTWIStatus->timerSelect * 4); - vu16* regTMCNTH = (vu16*)(REG_ADDR_TMCNT_H + gSTWIStatus->timerSelect * 4); + vu16* regTMCNTL = ®_TMCNT_L(gSTWIStatus->timerSelect); + vu16* regTMCNTH = ®_TMCNT_H(gSTWIStatus->timerSelect); REG_IME = 0; switch (count) { diff --git a/src/multiboot.c b/src/multiboot.c index 19245b5b3..15b062ed6 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -90,7 +90,7 @@ output_burst: k = 0x0e; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - if (*(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2) != 0xffff) + if (REG_SIOMULTI(i) != 0xffff) { break; } @@ -102,7 +102,7 @@ output_burst: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (mp->client_bit & (1 << i)) { if (j != ((MULTIBOOT_CLIENT_INFO << 8) | (1 << i))) @@ -141,7 +141,7 @@ output_burst: mp->probe_target_bit = 0; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((j >> 8) == MULTIBOOT_CLIENT_INFO) { MultiBoot_required_data[i - 1] = j; @@ -166,7 +166,7 @@ output_burst: { if (mp->probe_target_bit & (1 << i)) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (j != MultiBoot_required_data[i - 1]) { mp->probe_target_bit ^= 1 << i; @@ -179,7 +179,7 @@ output_burst: k = 1; for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); mp->client_data[i - 1] = j; if (mp->probe_target_bit & (1 << i)) { @@ -214,7 +214,7 @@ output_burst: case 0xd1: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if (mp->probe_target_bit & (1 << i)) { if ((j >> 8) != MULTIBOOT_CLIENT_DLREADY) @@ -242,7 +242,7 @@ output_burst: { if (mp->probe_target_bit & (1 << i)) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((j >> 8) != (MULTIBOOT_MASTER_START_PROBE + 1 - (mp->probe_count >> 1)) || ((j & 0xff) != (1 << i))) { @@ -391,7 +391,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp) default: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((mp->client_bit & (1 << i)) && j != must_data) { @@ -413,7 +413,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp) case 0xe8: for (i = MULTIBOOT_NCHILD; i != 0; i--) { - j = *(vu16 *)(REG_ADDR_SIOMULTI0 + i * 2); + j = REG_SIOMULTI(i); if ((mp->client_bit & (1 << i)) && j != must_data) { MultiBootInit(mp); diff --git a/src/overworld.c b/src/overworld.c index 9a5c41a7f..c9aa9ba57 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -313,7 +313,7 @@ static const struct BgTemplate sOverworldBgTemplates[] = static const struct ScanlineEffectParams sFlashEffectParams = { - (void *)REG_ADDR_WIN0H, + ®_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, 1, 0, diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 51498fa1d..6525daa1e 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -490,7 +490,7 @@ static const struct SpriteTemplate sSpriteTemplate_DuoFightPre_KyogreDorsalFin = static const struct ScanlineEffectParams sScanlineParams_DuoFight_Clouds = { - .dmaDest = (vu16 *)REG_ADDR_BG1HOFS, + .dmaDest = ®_BG1HOFS, .dmaControl = SCANLINE_EFFECT_DMACNT_16BIT, .initState = 1 };