Clean up some register constant use

This commit is contained in:
GriffinR 2021-11-10 17:01:21 -05:00
parent 343ac99049
commit 4590887359
13 changed files with 30 additions and 29 deletions

View File

@ -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)

View File

@ -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 = &REG_BG1HOFS;
}
else
{
task->data[6] = gBattle_BG2_X;
params.dmaDest = (u16 *)REG_ADDR_BG2HOFS;
params.dmaDest = &REG_BG2HOFS;
}
for (i = task->data[0] - 0x40; i <= task->data[0]; i++)

View File

@ -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;

View File

@ -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 = &REG_BLDALPHA;
params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
params.initState = 1;
params.unused9 = 0;

View File

@ -870,7 +870,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
static const struct ScanlineEffectParams sTourneyTreeScanlineEffectParams =
{
.dmaDest = (void *)REG_ADDR_BG3CNT,
.dmaDest = &REG_BG3CNT,
.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT,
.initState = 1,
};

View File

@ -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
&REG_BG3HOFS, SCANLINE_EFFECT_DMACNT_16BIT, 1
};
// unused
static const struct ScanlineEffectParams sIntroScanlineParams32Bit =
{
(void *)REG_ADDR_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1
&REG_BG3HOFS, SCANLINE_EFFECT_DMACNT_32BIT, 1
};
const struct SpriteTemplate gUnusedBattleInitSprite =

View File

@ -56,7 +56,7 @@ const s32 gMaxFlashLevel = ARRAY_COUNT(sFlashLevelPixelRadii) - 1;
const struct ScanlineEffectParams sFlashEffectParams =
{
(void *)REG_ADDR_WIN0H,
&REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1
};

View File

@ -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)

View File

@ -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 = &REG_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 = &REG_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 = &REG_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 = &REG_IME;
nIME = *pIME;
pWSCNT = (u16 *)REG_ADDR_WAITCNT;
pWSCNT = &REG_WAITCNT;
nOldWSCNT = *pWSCNT;
*pIME = nIME & ~1;
*pWSCNT = WSCNT_DATA;

View File

@ -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 = &REG_TMCNT_L(gSTWIStatus->timerSelect);
vu16* regTMCNTH = &REG_TMCNT_H(gSTWIStatus->timerSelect);
REG_IME = 0;
switch (count)
{

View File

@ -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);

View File

@ -313,7 +313,7 @@ static const struct BgTemplate sOverworldBgTemplates[] =
static const struct ScanlineEffectParams sFlashEffectParams =
{
(void *)REG_ADDR_WIN0H,
&REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1,
0,

View File

@ -490,7 +490,7 @@ static const struct SpriteTemplate sSpriteTemplate_DuoFightPre_KyogreDorsalFin =
static const struct ScanlineEffectParams sScanlineParams_DuoFight_Clouds =
{
.dmaDest = (vu16 *)REG_ADDR_BG1HOFS,
.dmaDest = &REG_BG1HOFS,
.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT,
.initState = 1
};