diff --git a/ld_script.txt b/ld_script.txt index 8a50d087c..b1daf9521 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -448,8 +448,8 @@ SECTIONS { src/title_screen.o(.rodata); data/field_weather.o(.rodata); src/field_weather.o(.rodata); - src/field_weather_effect.o(.rodata); - src/field_screen_effect.o(.rodata); + src/field_weather_effect.o(.rodata); + src/field_screen_effect.o(.rodata); src/battle_setup.o(.rodata); src/cable_club.o(.rodata); src/trainer_see.o(.rodata); diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 0de86d4f4..b0572b393 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1083,9 +1083,9 @@ static void sub_80B028C(u8 a1) u16 color[1]; if (!a1) - color[0] = 0x1F; + color[0] = RGB_RED; else - color[0] = 0x7C00; + color[0] = RGB_BLUE; for (i = 0; i < 16; i++) { @@ -1113,7 +1113,7 @@ static bool8 sub_80B02C8(u16 a1) } } - SetGpuReg(REG_OFFSET_BLDALPHA, (hi << 8) | lo); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(lo, hi)); if (lo == 0 && hi == 0x10) return TRUE; @@ -1135,9 +1135,9 @@ static void sub_80B0318(u8 taskId) data[10] = REG_WINOUT; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON); SetGpuRegBits(REG_OFFSET_BLDCNT, gUnknown_82EC7CC[0]); - SetGpuReg(REG_OFFSET_BLDALPHA, 1804); - SetGpuReg(REG_OFFSET_WININ, 63); - SetGpuReg(REG_OFFSET_WINOUT, 30); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 7)); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ); sub_8199C30(0, 0, 0, 0x1E, 0x14, 0xF); schedule_bg_copy_tilemap_to_vram(0); SetFlash2ScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], data[2], data[3], 1); diff --git a/src/field_weather.c b/src/field_weather.c index be3396c63..f0615dabf 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -75,7 +75,7 @@ IWRAM_DATA static const u8 *sPaletteGammaTypes; // CONST extern const u16 gUnknown_0854014C[][4096]; -// This is a pointer to gWeatherPtr. All code in this file accesses gWeather directly, +// This is a pointer to gWeather. All code in this file accesses gWeather directly, // while code in other field weather files accesses gWeather through this pointer. // This is likely the result of compiler optimization, since using the pointer in // this file produces the same result as accessing gWeather directly. @@ -266,11 +266,11 @@ static u8 None_Finish(void) static void BuildGammaShiftTables(void) { u16 v0; - u8 (*v1)[32]; + u8 (*gammaTable)[32]; u16 v2; u16 v4; u16 v5; - u16 v6; + u16 gammaIndex; u16 v9; u32 v10; u16 v11; @@ -280,9 +280,9 @@ static void BuildGammaShiftTables(void) for (v0 = 0; v0 <= 1; v0++) { if (v0 == 0) - v1 = gWeatherPtr->gammaShifts; + gammaTable = gWeatherPtr->gammaShifts; else - v1 = gWeatherPtr->altGammaShifts; + gammaTable = gWeatherPtr->altGammaShifts; for (v2 = 0; v2 < 32; v2++) { @@ -291,10 +291,10 @@ static void BuildGammaShiftTables(void) v5 = (v2 << 8) / 16; else v5 = 0; - for (v6 = 0; v6 <= 2; v6++) + for (gammaIndex = 0; gammaIndex <= 2; gammaIndex++) { v4 = (v4 - v5); - v1[v6][v2] = v4 >> 8; + gammaTable[gammaIndex][v2] = v4 >> 8; } v9 = v4; v10 = 0x1f00 - v4; @@ -305,25 +305,25 @@ static void BuildGammaShiftTables(void) v11 = v10 >> 4; if (v2 < 12) { - for (; v6 < 19; v6++) + for (; gammaIndex < 19; gammaIndex++) { v4 += v11; dunno = v4 - v9; if (dunno > 0) v4 -= (dunno + ((u16)dunno >> 15)) >> 1; - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) - v1[v6][v2] = 0x1f; + gammaTable[gammaIndex][v2] = v4 >> 8; + if (gammaTable[gammaIndex][v2] > 0x1f) + gammaTable[gammaIndex][v2] = 0x1f; } } else { - for (; v6 < 19; v6++) + for (; gammaIndex < 19; gammaIndex++) { v4 += v11; - v1[v6][v2] = v4 >> 8; - if (v1[v6][v2] > 0x1f) - v1[v6][v2] = 0x1f; + gammaTable[gammaIndex][v2] = v4 >> 8; + if (gammaTable[gammaIndex][v2] > 0x1f) + gammaTable[gammaIndex][v2] = 0x1f; } } } @@ -734,19 +734,19 @@ void FadeScreen(u8 mode, s8 delay) switch (mode) { case FADE_FROM_BLACK: - fadeColor = 0; + fadeColor = RGB_BLACK; fadeOut = FALSE; break; case FADE_FROM_WHITE: - fadeColor = 0xFFFF; + fadeColor = RGB_WHITEALPHA; fadeOut = FALSE; break; case FADE_TO_BLACK: - fadeColor = 0; + fadeColor = RGB_BLACK; fadeOut = TRUE; break; case FADE_TO_WHITE: - fadeColor = 0xFFFF; + fadeColor = RGB_WHITEALPHA; fadeOut = TRUE; break; default: diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 88ebb1936..2ec51a722 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -182,7 +182,7 @@ void CreateCloudSprites(void) { u8 spriteId = CreateSprite(&sCloudSpriteTemplate, 0, 0, 0xFF); - if (spriteId != 64) + if (spriteId != MAX_SPRITES) { struct Sprite *sprite; @@ -794,7 +794,7 @@ bool8 CreateRainSprite(void) spriteNum = gWeatherPtr->rainSpriteCount; spriteId = CreateSpriteAtEnd(&sRainSpriteTemplate, sRainSpriteCoords[spriteNum].x, sRainSpriteCoords[spriteNum].y, 78); - if (spriteId != 64) + if (spriteId != MAX_SPRITES) { gSprites[spriteId].data[5] = 0; gSprites[spriteId].data[1] = spriteNum * 145; @@ -953,7 +953,7 @@ bool8 CreateSnowflakeSprite(void) { u8 spriteId = CreateSpriteAtEnd(&sSnowflakeSpriteTemplate, 0, 0, 78); - if (spriteId == 64) + if (spriteId == MAX_SPRITES) return FALSE; gSprites[spriteId].data[4] = gWeatherPtr->snowflakeSpriteCount; sub_807EC40(&gSprites[spriteId]); @@ -1015,7 +1015,7 @@ void sub_807ED48(struct Sprite *sprite) r3 = (sprite->pos1.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX) & 0x1FF; if (r3 & 0x100) - r3 = -0x100 | r3; // hmm... what is this? + r3 |= -0x100; // hmm... what is this? if (r3 < -3) sprite->pos1.x = 242 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX); else if (r3 > 242) @@ -2034,7 +2034,7 @@ void CreateSandstormSprites_2(void) { for (i = 0; i < 5; i++) { - u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, i * 48 + 0x18, 0xD0, 1); + u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, i * 48 + 24, 208, 1); if (spriteId != MAX_SPRITES) {