From 6553903150b6ee262bead5d8c7c5b304bd323fb2 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Thu, 18 Jan 2018 18:56:44 -0600 Subject: start labeling field_weather --- include/constants/weather.h | 4 +- include/field_weather.h | 35 ++++--- src/field/coord_event_weather.c | 4 +- src/field/field_weather.c | 193 ++++++++++++++++++-------------------- src/field/field_weather_effects.c | 60 ++++++------ 5 files changed, 149 insertions(+), 147 deletions(-) diff --git a/include/constants/weather.h b/include/constants/weather.h index 946316984..1110be7a2 100644 --- a/include/constants/weather.h +++ b/include/constants/weather.h @@ -12,7 +12,7 @@ #define WEATHER_SANDSTORM 8 #define WEATHER_FOG_2 9 #define WEATHER_FOG_3 10 -#define WEATHER_DARK 11 +#define WEATHER_SHADE 11 #define WEATHER_DROUGHT 12 #define WEATHER_RAIN_HEAVY 13 #define WEATHER_BUBBLES 14 @@ -31,7 +31,7 @@ #define COORD_EVENT_WEATHER_FOG_2 7 #define COORD_EVENT_WEATHER_ASH 8 #define COORD_EVENT_WEATHER_SANDSTORM 9 -#define COORD_EVENT_WEATHER_DARK 10 +#define COORD_EVENT_WEATHER_SHADE 10 #define COORD_EVENT_WEATHER_DROUGHT 11 #define COORD_EVENT_WEATHER_ROUTE119_CYCLE 20 #define COORD_EVENT_WEATHER_ROUTE123_CYCLE 21 diff --git a/include/field_weather.h b/include/field_weather.h index 267650a2a..2c56a5a40 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -29,11 +29,11 @@ struct Weather u8 filler4A0[0x6B6-0x4A0]; s8 unknown_6B6; u8 filler_6B7[0xC0-0xB7]; - s8 unknown_6C0; - s8 unknown_6C1; - u8 unknown_6C2; - u8 unknown_6C3; - u16 unknown_6C4; + s8 gammaIndex; + s8 gammaTargetIndex; + u8 gammaStepDelay; + u8 gammaStepFrameCounter; + u16 fadeDestColor; u8 unknown_6C6; u8 unknown_6C7; u8 unknown_6C8; @@ -128,18 +128,27 @@ void nullsub_38(void); void sub_807CB10(void); void sub_807CC24(void); void sub_807CCAC(void); -u8 sub_807CDC4(void); -u8 sub_807CE24(void); -u8 sub_807CE7C(void); +u8 RainSnowShadeBlend_807CDC4(void); +u8 DroughtBlend_807CE24(void); +u8 Fog1Blend_807CE7C(void); void nullsub_39(void); // ASM -void sub_807CEBC(u8, u8, s8); -//void sub_807D1BC(u8, u8, u8, u8, u16); -void sub_807D1BC(u8 a, u8 a2, s8 c, u8 d, u16 e); -void sub_807D304(s8 a, u8 arg2, u16 c); -void sub_807D424(u8, u16); +void BlendSomething_807CEBC(u8, u8, s8); +//void BlendSomething_807D1BC(u8, u8, u8, u8, u16); +void BlendSomething_807D1BC(u8 a, u8 a2, s8 c, u8 d, u16 e); +void BlendSomething_807D304(s8 a, u8 arg2, u16 c); +void BlendSomething_807D424(u8, u16); // ... + +enum +{ + FADE_FROM_BLACK, + FADE_TO_BLACK, + FADE_FROM_WHITE, + FADE_TO_WHITE, +}; + void fade_screen(u8, u8); // ... void sub_807D78C(u8 tag); diff --git a/src/field/coord_event_weather.c b/src/field/coord_event_weather.c index db4e9c161..60b87fa30 100644 --- a/src/field/coord_event_weather.c +++ b/src/field/coord_event_weather.c @@ -34,7 +34,7 @@ static const struct CoordEventWeather sCoordEventWeatherFuncs[] = { COORD_EVENT_WEATHER_FOG_2, CoordEventWeather_DiagonalFog }, { COORD_EVENT_WEATHER_ASH, CoordEventWeather_Ash }, { COORD_EVENT_WEATHER_SANDSTORM, CoordEventWeather_Sandstorm }, - { COORD_EVENT_WEATHER_DARK, CoordEventWeather_Dark }, + { COORD_EVENT_WEATHER_SHADE, CoordEventWeather_Dark }, { COORD_EVENT_WEATHER_DROUGHT, CoordEventWeather_Drought }, { COORD_EVENT_WEATHER_ROUTE119_CYCLE, CoordEventWeather_Route119Cycle }, { COORD_EVENT_WEATHER_ROUTE123_CYCLE, CoordEventWeather_Route123Cycle }, @@ -87,7 +87,7 @@ static void CoordEventWeather_Sandstorm(void) static void CoordEventWeather_Dark(void) { - SetWeather(WEATHER_DARK); + SetWeather(WEATHER_SHADE); } static void CoordEventWeather_Drought(void) diff --git a/src/field/field_weather.c b/src/field/field_weather.c index b6475d8ff..5f3f93096 100644 --- a/src/field/field_weather.c +++ b/src/field/field_weather.c @@ -13,7 +13,7 @@ #include "trig.h" #include "ewram.h" -#define MACRO1(a) ((((a) >> 1) & 0xF) | (((a) >> 2) & 0xF0) | (((a) >> 3) & 0xF00)) +#define MACRO1(color) ((((color) >> 1) & 0xF) | (((color) >> 2) & 0xF0) | (((color) >> 3) & 0xF00)) struct RGBColor { @@ -108,10 +108,10 @@ void Fog1_InitVars(void); void Fog1_Main(void); void Fog1_InitAll(void); bool8 Fog1_Finish(void); -void Weather11_InitVars(void); -void Weather11_Main(void); -void Weather11_InitAll(void); -bool8 Weather11_Finish(void); +void Shade_InitVars(void); +void Shade_Main(void); +void Shade_InitAll(void); +bool8 Shade_Finish(void); void Drought_InitVars(void); void Drought_Main(void); void Drought_InitAll(void); @@ -138,7 +138,7 @@ static const struct WeatherCallbacks sWeatherFuncs[] = {Sandstorm_InitVars, Sandstorm_Main, Sandstorm_InitAll, Sandstorm_Finish}, {Fog2_InitVars, Fog2_Main, Fog2_InitAll, Fog2_Finish}, {Fog1_InitVars, Fog1_Main, Fog1_InitAll, Fog1_Finish}, - {Weather11_InitVars, Weather11_Main, Weather11_InitAll, Weather11_Finish}, + {Shade_InitVars, Shade_Main, Shade_InitAll, Shade_Finish}, {Drought_InitVars, Drought_Main, Drought_InitAll, Drought_Finish}, {HeavyRain_InitVars, Rain_Main, HeavyRain_InitAll, Rain_Finish}, {Bubbles_InitVars, Bubbles_Main, Bubbles_InitAll, Bubbles_Finish}, @@ -152,7 +152,7 @@ void (*const gUnknown_083970B8[])(void) = nullsub_39, }; -const u8 gUnknown_083970C8[] = +const u8 gUnknown_083970C8[32] = { 1, 1, @@ -193,6 +193,7 @@ const u16 gUnknown_083970E8[] = INCBIN_U16("graphics/weather/0.gbapal"); void StartWeather(void) { u8 index; + if (!FuncIsActiveTask(Task_WeatherMain)) { index = AllocSpritePalette(0x1200); @@ -266,7 +267,7 @@ void Task_WeatherMain(u8 taskId) if (!sWeatherFuncs[gWeatherPtr->currWeather].finish()) { sWeatherFuncs[gWeatherPtr->nextWeather].initVars(); - gWeatherPtr->unknown_6C3 = 0; + gWeatherPtr->gammaStepFrameCounter = 0; gWeatherPtr->unknown_6C6 = 0; gWeatherPtr->currWeather = gWeatherPtr->nextWeather; gWeatherPtr->unknown_6D3 = 1; @@ -281,8 +282,8 @@ void Task_WeatherMain(u8 taskId) void None_Init(void) { - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 0; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 0; } void None_Main(void) @@ -315,7 +316,7 @@ void sub_807CB10(void) else v1 = gWeatherPtr->unk460; - for (v2 = 0; (u16)v2 <= 0x1f; v2++) + for (v2 = 0; v2 < 32; v2++) { v4 = v2 << 8; if (v0 == 0) @@ -334,33 +335,27 @@ void sub_807CB10(void) v10 += 0xf; } v11 = v10 >> 4; - if (v2 <= 0xb) + if (v2 < 12) { - for (; v6 <= 0x12; v6++) + for (; v6 < 19; v6++) { 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; - } } } else { - for (; v6 <= 0x12; v6++) + for (; v6 < 19; v6++) { v4 += v11; v1[v6][v2] = v4 >> 8; if (v1[v6][v2] > 0x1f) - { v1[v6][v2] = 0x1f; - } } } } @@ -369,20 +364,20 @@ void sub_807CB10(void) void sub_807CC24(void) { - if (gWeatherPtr->unknown_6C0 == gWeatherPtr->unknown_6C1) + if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex) { gWeatherPtr->unknown_6C6 = 3; } else { - if (++gWeatherPtr->unknown_6C3 >= gWeatherPtr->unknown_6C2) + if (++gWeatherPtr->gammaStepFrameCounter >= gWeatherPtr->gammaStepDelay) { - gWeatherPtr->unknown_6C3 = 0; - if (gWeatherPtr->unknown_6C0 < gWeatherPtr->unknown_6C1) - gWeatherPtr->unknown_6C0++; + gWeatherPtr->gammaStepFrameCounter = 0; + if (gWeatherPtr->gammaIndex < gWeatherPtr->gammaTargetIndex) + gWeatherPtr->gammaIndex++; else - gWeatherPtr->unknown_6C0--; - sub_807CEBC(0, 0x20, gWeatherPtr->unknown_6C0); + gWeatherPtr->gammaIndex--; + BlendSomething_807CEBC(0, 0x20, gWeatherPtr->gammaIndex); } } } @@ -397,24 +392,24 @@ void sub_807CCAC(void) case WEATHER_RAIN_MED: case WEATHER_RAIN_HEAVY: case WEATHER_SNOW: - case WEATHER_DARK: - if (sub_807CDC4() == 0) + case WEATHER_SHADE: + if (RainSnowShadeBlend_807CDC4() == 0) { - gWeatherPtr->unknown_6C0 = 3; + gWeatherPtr->gammaIndex = 3; gWeatherPtr->unknown_6C6 = 3; } break; case WEATHER_DROUGHT: - if (sub_807CE24() == 0) + if (DroughtBlend_807CE24() == 0) { - gWeatherPtr->unknown_6C0 = -6; + gWeatherPtr->gammaIndex = -6; gWeatherPtr->unknown_6C6 = 3; } break; case WEATHER_FOG_1: - if (sub_807CE7C() == 0) + if (Fog1Blend_807CE7C() == 0) { - gWeatherPtr->unknown_6C0 = 0; + gWeatherPtr->gammaIndex = 0; gWeatherPtr->unknown_6C6 = 3; } break; @@ -425,47 +420,47 @@ void sub_807CCAC(void) default: if (!gPaletteFade.active) { - gWeatherPtr->unknown_6C0 = gWeatherPtr->unknown_6C1; + gWeatherPtr->gammaIndex = gWeatherPtr->gammaTargetIndex; gWeatherPtr->unknown_6C6 = 3; } break; } } -u8 sub_807CDC4(void) +u8 RainSnowShadeBlend_807CDC4(void) { if (gWeatherPtr->unknown_6C7 == 0x10) return 0; if (++gWeatherPtr->unknown_6C7 >= 0x10) { - sub_807CEBC(0, 0x20, 3); + BlendSomething_807CEBC(0, 0x20, 3); gWeatherPtr->unknown_6C7 = 0x10; return 0; } - sub_807D1BC(0, 0x20, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); + BlendSomething_807D1BC(0, 0x20, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); return 1; } -u8 sub_807CE24(void) +u8 DroughtBlend_807CE24(void) { if (gWeatherPtr->unknown_6C7 == 0x10) return 0; if (++gWeatherPtr->unknown_6C7 >= 0x10) { - sub_807CEBC(0, 0x20, -6); + BlendSomething_807CEBC(0, 0x20, -6); gWeatherPtr->unknown_6C7 = 0x10; return 0; } - sub_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); + BlendSomething_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); return 1; } -u8 sub_807CE7C(void) +u8 Fog1Blend_807CE7C(void) { if (gWeatherPtr->unknown_6C7 == 0x10) return 0; ++gWeatherPtr->unknown_6C7; - sub_807D424(0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); + BlendSomething_807D424(0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); return 1; } @@ -473,7 +468,7 @@ void nullsub_39(void) { } -void sub_807CEBC(u8 a, u8 b, s8 c) +void BlendSomething_807CEBC(u8 a, u8 b, s8 c) { u16 r4; u16 palOffset; @@ -578,7 +573,7 @@ void sub_807CEBC(u8 a, u8 b, s8 c) } } -void sub_807D1BC(u8 a1, u8 a2, s8 c, u8 d, u16 e) +void BlendSomething_807D1BC(u8 a1, u8 a2, s8 c, u8 d, u16 e) { u16 palOffset; u16 r4; @@ -625,7 +620,7 @@ void sub_807D1BC(u8 a1, u8 a2, s8 c, u8 d, u16 e) } } -void sub_807D304(s8 a, u8 coeff, u16 c) +void BlendSomething_807D304(s8 a, u8 coeff, u16 c) { struct RGBColor color; u8 r_; @@ -681,31 +676,30 @@ void sub_807D304(s8 a, u8 coeff, u16 c) bool8 sub_807D574(u8); -void sub_807D424(u8 a, u16 b) +void BlendSomething_807D424(u8 coeff, u16 blendColor) { struct RGBColor color; - u8 r_; - u8 g_; - u8 b_; - u16 r4; - - BlendPalette(0, 0x100, a, b); - color = *(struct RGBColor *)&b; - r_ = color.r; - g_ = color.g; - b_ = color.b; - - r4 = 16; - while (r4 < 32) + u8 blendR; + u8 blendG; + u8 blendB; + u16 palNum; + + BlendPalette(0, 0x100, coeff, blendColor); + color = *(struct RGBColor *)&blendColor; + blendR = color.r; + blendG = color.g; + blendB = color.b; + + for (palNum = 16; palNum < 32; palNum++) { - if (sub_807D574(r4)) + if (sub_807D574(palNum)) { - u16 r12 = (r4 + 1) * 16; - u16 r6 = r4 * 16; + u16 palEnd = (palNum + 1) * 16; + u16 palOffset = palNum * 16; - while (r6 < r12) + while (palOffset < palEnd) { - struct RGBColor color = *(struct RGBColor *)&gPlttBufferUnfaded[r6]; + struct RGBColor color = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; u8 r = color.r; u8 g = color.g; u8 b = color.b; @@ -714,19 +708,18 @@ void sub_807D424(u8 a, u16 b) g += ((31 - g) * 3) >> 2; b += ((28 - b) * 3) >> 2; - r += ((r_ - r) * a) >> 4; - g += ((g_ - g) * a) >> 4; - b += ((b_ - b) * a) >> 4; + r += ((blendR - r) * coeff) >> 4; + g += ((blendG - g) * coeff) >> 4; + b += ((blendB - b) * coeff) >> 4; - gPlttBufferFaded[r6] = (b << 10) | (g << 5) | r; - r6++; + gPlttBufferFaded[palOffset] = (b << 10) | (g << 5) | r; + palOffset++; } } else { - BlendPalette(r4 * 16, 16, a, b); + BlendPalette(palNum * 16, 16, coeff, blendColor); } - r4++; } } @@ -755,8 +748,8 @@ void sub_807D5BC(s8 a) { if (gWeatherPtr->unknown_6C6 == 3) { - sub_807CEBC(0, 32, a); - gWeatherPtr->unknown_6C0 = a; + BlendSomething_807CEBC(0, 32, a); + gWeatherPtr->gammaIndex = a; } } @@ -765,37 +758,37 @@ void sub_807D5F0(u8 a, u8 b, u8 c) if (gWeatherPtr->unknown_6C6 == 3) { gWeatherPtr->unknown_6C6 = 0; - gWeatherPtr->unknown_6C0 = a; - gWeatherPtr->unknown_6C1 = b; - gWeatherPtr->unknown_6C3 = 0; - gWeatherPtr->unknown_6C2 = c; + gWeatherPtr->gammaIndex = a; + gWeatherPtr->gammaTargetIndex = b; + gWeatherPtr->gammaStepFrameCounter = 0; + gWeatherPtr->gammaStepDelay = c; sub_807D5BC(a); } } -void fade_screen(u8 a, u8 delay) +void fade_screen(u8 mode, u8 delay) { u32 fadeColor; - u32 r1; - u32 r2; + bool8 fadeTo; + bool8 useWeatherPal; - switch (a) + switch (mode) { - case 0: + case FADE_FROM_BLACK: fadeColor = 0; - r1 = 0; + fadeTo = FALSE; break; - case 2: + case FADE_FROM_WHITE: fadeColor = 0xFFFF; - r1 = 0; + fadeTo = FALSE; break; - case 1: + case FADE_TO_BLACK: fadeColor = 0; - r1 = 1; + fadeTo = TRUE; break; - case 3: + case FADE_TO_WHITE: fadeColor = 0xFFFF; - r1 = 1; + fadeTo = TRUE; break; default: return; @@ -808,26 +801,26 @@ void fade_screen(u8 a, u8 delay) case WEATHER_RAIN_HEAVY: case WEATHER_SNOW: case WEATHER_FOG_1: - case WEATHER_DARK: + case WEATHER_SHADE: case WEATHER_DROUGHT: - r2 = 1; + useWeatherPal = TRUE; break; default: - r2 = 0; + useWeatherPal = FALSE; break; } - if (r1 != 0) + if (fadeTo) { - if (r2 != 0) + if (useWeatherPal) CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); BeginNormalPaletteFade(0xFFFFFFFF, delay, 0, 16, fadeColor); gWeatherPtr->unknown_6C6 = 2; } else { - gWeatherPtr->unknown_6C4 = fadeColor; - if (r2 != 0) + gWeatherPtr->fadeDestColor = fadeColor; + if (useWeatherPal) gWeatherPtr->unknown_6C7 = 0; else BeginNormalPaletteFade(0xFFFFFFFF, delay, 16, 0, fadeColor); @@ -858,7 +851,7 @@ void sub_807D78C(u8 a) sub_807D540(r4); r4 *= 16; for (i = 0; i < 16; i++) - gPlttBufferFaded[r4 + i] = gWeatherPtr->unknown_6C4; + gPlttBufferFaded[r4 + i] = gWeatherPtr->fadeDestColor; } break; case 2: @@ -869,7 +862,7 @@ void sub_807D78C(u8 a) default: if (gWeatherPtr->currWeather != WEATHER_FOG_1) { - sub_807CEBC(r4, 1, gWeatherPtr->unknown_6C0); + BlendSomething_807CEBC(r4, 1, gWeatherPtr->gammaIndex); } else { @@ -882,7 +875,7 @@ void sub_807D78C(u8 a) void sub_807D874(u8 a) { - sub_807CEBC(a, 1, gWeatherPtr->unknown_6C0); + BlendSomething_807CEBC(a, 1, gWeatherPtr->gammaIndex); } u8 unref_sub_807D894(void) diff --git a/src/field/field_weather_effects.c b/src/field/field_weather_effects.c index 5a59d6c2a..154cd2e12 100644 --- a/src/field/field_weather_effects.c +++ b/src/field/field_weather_effects.c @@ -91,8 +91,8 @@ extern void sub_807D5F0(u8 a, u8 b, u8 c); void Clouds_InitVars(void) { - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->weatherGfxLoaded = FALSE; gWeatherPtr->initStep = 0; if (gWeatherPtr->cloudSpritesCreated == FALSE) @@ -159,8 +159,8 @@ bool8 Clouds_Finish(void) void Weather2_InitVars(void) { - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; } void Weather2_InitAll(void) @@ -236,8 +236,8 @@ void Drought_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = FALSE; - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 0; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 0; } void Drought_Main(void); @@ -368,8 +368,8 @@ void LightRain_InitVars(void) gWeatherPtr->unknown_6DB = 8; gWeatherPtr->unknown_6DC = 0; gWeatherPtr->unknown_6D9 = 10; - gWeatherPtr->unknown_6C1 = 3; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 3; + gWeatherPtr->gammaStepDelay = 20; SetRainStrengthFromSoundEffect(SE_T_KOAME); } @@ -885,8 +885,8 @@ void Snow_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = FALSE; - gWeatherPtr->unknown_6C1 = 3; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 3; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->unknown_6E5 = 16; gWeatherPtr->unknown_6E0 = 0; } @@ -1074,8 +1074,8 @@ void MedRain_InitVars(void) gWeatherPtr->unknown_6DB = 4; gWeatherPtr->unknown_6DC = 0; gWeatherPtr->unknown_6D9 = 16; - gWeatherPtr->unknown_6C1 = 3; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 3; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment gWeatherPtr->unknown_6ED = 0; SetRainStrengthFromSoundEffect(SE_T_AME); @@ -1102,8 +1102,8 @@ void HeavyRain_InitVars(void) gWeatherPtr->unknown_6DB = 4; gWeatherPtr->unknown_6DC = 1; gWeatherPtr->unknown_6D9 = 24; - gWeatherPtr->unknown_6C1 = 3; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 3; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment SetRainStrengthFromSoundEffect(SE_T_OOAME); } @@ -1296,8 +1296,8 @@ void Fog1_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = FALSE; - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; if (gWeatherPtr->fog1SpritesCreated == 0) { gWeatherPtr->unknown_6F0 = 0; @@ -1446,8 +1446,8 @@ void Ash_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = FALSE; - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->unknown_6FE = 20; if (!gWeatherPtr->ashSpritesCreated) { @@ -1634,8 +1634,8 @@ void Fog2_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = 0; - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; gWeatherPtr->unknown_6F0 = 0; gWeatherPtr->unknown_6F2 = 1; if (gWeatherPtr->fog2SpritesCreated == 0) @@ -1835,8 +1835,8 @@ void Sandstorm_InitVars(void) { gWeatherPtr->initStep = 0; gWeatherPtr->weatherGfxLoaded = 0; - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 20; if (gWeatherPtr->sandstormSprites1Created == 0) { gWeatherPtr->unknown_704 = gWeatherPtr->unknown_708 = 0; @@ -2113,26 +2113,26 @@ void SandstormSpriteCallback3(struct Sprite *sprite) } //------------------------------------------------------------------------------ -// Weather 11 +// Shade //------------------------------------------------------------------------------ -void Weather11_InitVars(void) +void Shade_InitVars(void) { gWeatherPtr->initStep = 0; - gWeatherPtr->unknown_6C1 = 3; - gWeatherPtr->unknown_6C2 = 20; + gWeatherPtr->gammaTargetIndex = 3; + gWeatherPtr->gammaStepDelay = 20; } -void Weather11_InitAll(void) +void Shade_InitAll(void) { - Weather11_InitVars(); + Shade_InitVars(); } -void Weather11_Main(void) +void Shade_Main(void) { } -bool8 Weather11_Finish(void) +bool8 Shade_Finish(void) { return FALSE; } -- cgit v1.2.3 From 428f712da678b3f5b9256d85c0e3248cacd8e7c2 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Fri, 19 Jan 2018 21:30:16 -0800 Subject: Further document weather --- include/ewram.h | 2 +- include/field_effect.h | 1 - include/field_weather.h | 33 ++- include/global.fieldmap.h | 3 +- src/battle/battle_util.c | 6 +- src/field/decoration.c | 6 +- src/field/field_control_avatar.c | 7 +- src/field/field_effect.c | 6 +- src/field/field_weather.c | 486 ++++++++++++++++++++------------------ src/field/field_weather_effects.c | 12 +- src/field/overworld.c | 6 +- src/scene/cable_car.c | 2 +- 12 files changed, 300 insertions(+), 270 deletions(-) diff --git a/include/ewram.h b/include/ewram.h index 6f42925c1..13e478ff1 100644 --- a/include/ewram.h +++ b/include/ewram.h @@ -8,7 +8,7 @@ extern u8 gSharedMem[]; // regions overlap others but have different definitions. Until some // dupes can be determined to be the same, they will be deliberate // seperated. -#define eWeatherPaletteData (*(struct WeatherPaletteData *)gSharedMem) +#define eDroughtPaletteData (*(struct WeatherPaletteData *)gSharedMem) #define gBattleStruct ((struct BattleStruct *) (gSharedMem + 0x0)) #define ewram0_2 (*(struct Struct2000000 *)(gSharedMem + 0x0)) #define namingScreenData (*(struct NamingScreenData *)(gSharedMem + 0x0)) diff --git a/include/field_effect.h b/include/field_effect.h index bb859074f..4d0e90767 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -103,7 +103,6 @@ void FieldEffectActiveListClear(void); void FieldEffectActiveListAdd(u8 id); void FieldEffectActiveListRemove(u8 id); bool8 FieldEffectActiveListContains(u8 id); -void sub_807DE38(u8 index); void SpriteCB_PokeballGlow(struct Sprite *); void SpriteCB_PokecenterMonitor(struct Sprite *); diff --git a/include/field_weather.h b/include/field_weather.h index 2c56a5a40..15be9229d 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -23,12 +23,8 @@ struct Weather struct Sprite *sandstormSprites2[5]; } s2; } sprites; - u8 unknown_200[2][32]; - u8 filler_240[0x460-0x240]; - u8 unk460[2][32]; - u8 filler4A0[0x6B6-0x4A0]; - s8 unknown_6B6; - u8 filler_6B7[0xC0-0xB7]; + u8 gammaShifts[19][32]; + u8 altGammaShifts[19][32]; s8 gammaIndex; s8 gammaTargetIndex; u8 gammaStepDelay; @@ -47,7 +43,7 @@ struct Weather u8 weatherGfxLoaded; u8 unknown_6D3; u8 unknown_6D4; - u8 unknown_6D5; + u8 altGammaSpritePalIndex; u16 unknown_6D6; u8 unknown_6D8; u8 unknown_6D9; @@ -104,8 +100,8 @@ struct Weather u16 currBlendEVB; u16 targetBlendEVA; u16 targetBlendEVB; - u8 unknown_738; - u8 unknown_739; + u8 blendUpdateCounter; + u8 blendFrameCounter; u8 blendDelay; u8 filler_73B[0x3C-0x3B]; s16 unknown_73C; @@ -113,20 +109,18 @@ struct Weather s16 unknown_740; s16 unknown_742; u8 filler_744[0xD-4]; - s8 unknown_74D; - u8 unknown_74E; + s8 loadDroughtPalsIndex; + u8 loadDroughtPalsOffset; }; void StartWeather(void); -void DoWeatherEffect(u8 effect); +void ChangeWeather(u8 weather); void sub_807C988(u8 effect); void sub_807C9B4(u8 effect); void Task_WeatherInit(u8); void Task_WeatherMain(u8); void sub_807CAE8(void); void nullsub_38(void); -void sub_807CB10(void); -void sub_807CC24(void); void sub_807CCAC(void); u8 RainSnowShadeBlend_807CDC4(void); u8 DroughtBlend_807CE24(void); @@ -135,9 +129,7 @@ void nullsub_39(void); // ASM void BlendSomething_807CEBC(u8, u8, s8); -//void BlendSomething_807D1BC(u8, u8, u8, u8, u16); void BlendSomething_807D1BC(u8 a, u8 a2, s8 c, u8 d, u16 e); -void BlendSomething_807D304(s8 a, u8 arg2, u16 c); void BlendSomething_807D424(u8, u16); // ... @@ -156,8 +148,6 @@ void sub_807D874(u8); // ... void Weather_SetBlendCoeffs(u8, u8); // ... -void sub_807DE68(void); -// ... void PlayRainSoundEffect(void); // ... void SetSav1Weather(u32); @@ -171,6 +161,13 @@ bool8 sub_807D770(void); bool8 sub_807DDFC(void); void SetWeather(u32); void UpdateWeatherPerDay(u16); +void PreservePaletteInWeather(u8 index); +void ResetPreservedPalettesInWeather(void); +extern void ResetDroughtWeatherPaletteLoading(void); +void ResetDroughtWeatherPaletteLoading(void); +bool8 LoadDroughtWeatherPalettes(void); +u8 GetCurrentWeather(void); + extern struct Weather gWeather; diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index a828cf131..30047c677 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -101,8 +101,7 @@ struct WarpEvent struct CoordEvent { s16 x, y; - u8 unk4; - u8 filler_5; + u8 elevation; u16 trigger; u16 index; u8 filler_A[0x2]; diff --git a/src/battle/battle_util.c b/src/battle/battle_util.c index f93664593..87b6952ff 100644 --- a/src/battle/battle_util.c +++ b/src/battle/battle_util.c @@ -4,6 +4,7 @@ #include "data2.h" #include "event_data.h" #include "ewram.h" +#include "field_weather.h" #include "item.h" #include "link.h" #include "pokemon.h" @@ -85,7 +86,6 @@ u8 CountTrailingZeroBits(u32 a); u8 GetMoveTarget(u16 move, u8 useMoveTarget); u8 sub_803FC34(u8 bank); u16 sub_803FBFC(u8 a); -u8 weather_get_current(void); void RecordAbilityBattle(u8 bank, u8 ability); void RecordItemBattle(u8 bank, u8 holdEffect); s8 GetPokeFlavourRelation(u32 pid, u8 flavor); @@ -1747,7 +1747,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { case 0xFF: //weather from overworld //_08018586 - switch (weather_get_current()) + switch (GetCurrentWeather()) { case WEATHER_RAIN_LIGHT: case WEATHER_RAIN_MED: @@ -1781,7 +1781,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (effect) { - gBattleCommunication[MULTISTRING_CHOOSER] = weather_get_current(); + gBattleCommunication[MULTISTRING_CHOOSER] = GetCurrentWeather(); BattleScriptPushCursorAndCallback(BattleScript_OverworldWeatherStarts); } break; diff --git a/src/field/decoration.c b/src/field/decoration.c index e1604cfa1..1cc3bbe06 100644 --- a/src/field/decoration.c +++ b/src/field/decoration.c @@ -2289,7 +2289,7 @@ void sub_80FF6AC(u8 taskId) gTasks[taskId].data[2] = 2; break; case 2: - if (sub_807D770() == 1) + if (sub_807D770() == TRUE) { gTasks[taskId].data[12] = 0; sub_810065C(taskId); @@ -3222,7 +3222,7 @@ void c1_overworld_prev_quest(u8 taskId) void sub_8100334(u8 taskId) { - if (sub_807D770() == 1) + if (sub_807D770() == TRUE) { gTasks[taskId].func = sub_80FE948; } @@ -3735,7 +3735,7 @@ void sub_8100C88(u8 taskId) gTasks[taskId].data[2] = 3; break; case 3: - if (sub_807D770() == 1) + if (sub_807D770() == TRUE) { gTasks[taskId].data[13] = -1; DisplayItemMessageOnField(taskId, gSecretBaseText_DecorReturned, sub_81010F0, 0); diff --git a/src/field/field_control_avatar.c b/src/field/field_control_avatar.c index c156df035..bf96c724f 100644 --- a/src/field/field_control_avatar.c +++ b/src/field/field_control_avatar.c @@ -767,20 +767,19 @@ static u8 *trigger_activate(struct CoordEvent *coordEvent) return NULL; } -static u8 *mapheader_trigger_activate_at(struct MapHeader *mapHeader, u16 x, u16 y, u8 d) +static u8 *mapheader_trigger_activate_at(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation) { s32 i; struct CoordEvent *coordEvents = mapHeader->events->coordEvents; u8 coordEventCount = mapHeader->events->coordEventCount; - u8 *script; for (i = 0; i < coordEventCount; i++) { if ((u16)coordEvents[i].x == x && (u16)coordEvents[i].y == y) { - if (coordEvents[i].unk4 == d || coordEvents[i].unk4 == 0) + if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0) { - script = trigger_activate(&coordEvents[i]); + u8 *script = trigger_activate(&coordEvents[i]); if (script != NULL) return script; } diff --git a/src/field/field_effect.c b/src/field/field_effect.c index 5ff89574b..a3134552d 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -543,7 +543,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) LoadCompressedObjectPalette(&gMonPaletteTable[species]); GetMonSpriteTemplate_803C56C(species, 3); gUnknown_02024E8C.paletteTag = gMonPaletteTable[0].tag; - sub_807DE38(IndexOfSpritePaletteTag(gMonPaletteTable[0].tag) + 0x10); + PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[0].tag) + 0x10); return CreateSprite(&gUnknown_02024E8C, x, y, subpriority); } @@ -556,13 +556,13 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio LoadCompressedObjectPalette(spritePalette); GetMonSpriteTemplate_803C56C(species, 3); gUnknown_02024E8C.paletteTag = spritePalette->tag; - sub_807DE38(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); + PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); return CreateSprite(&gUnknown_02024E8C, x, y, subpriority); } void FreeResourcesAndDestroySprite(struct Sprite *sprite) { - sub_807DE68(); + ResetPreservedPalettesInWeather(); FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(sprite->oam.paletteNum)); if (sprite->oam.affineMode != 0) { diff --git a/src/field/field_weather.c b/src/field/field_weather.c index 5f3f93096..2a5c311ab 100644 --- a/src/field/field_weather.c +++ b/src/field/field_weather.c @@ -15,6 +15,12 @@ #define MACRO1(color) ((((color) >> 1) & 0xF) | (((color) >> 2) & 0xF0) | (((color) >> 3) & 0xF00)) +enum { + GAMMA_NONE, + GAMMA_NORMAL, + GAMMA_ALT, +}; + struct RGBColor { u16 r:5; @@ -24,7 +30,7 @@ struct RGBColor struct WeatherPaletteData { - u16 data[0][0x1000]; // unknown length + u16 gammaShiftColors[8][0x1000]; // 0x1000 is the number of bytes that make up all palettes. }; struct WeatherCallbacks @@ -36,10 +42,10 @@ struct WeatherCallbacks }; EWRAM_DATA struct Weather gWeather = {0}; -EWRAM_DATA u8 gUnknown_0202FF38[32] = {0}; +EWRAM_DATA u8 gFieldEffectPaletteGammaTypes[32] = {0}; EWRAM_DATA u16 gUnknown_0202FF58 = {0}; -static const u8 *gUnknown_030006DC; +static const u8 *sPaletteGammaTypes; const u8 DroughtPaletteData_0[] = INCBIN_U8("graphics/weather/drought0.bin.lz"); const u8 DroughtPaletteData_1[] = INCBIN_U8("graphics/weather/drought1.bin.lz"); @@ -56,7 +62,7 @@ static const u8 *const sCompressedDroughtPalettes[] = DroughtPaletteData_3, DroughtPaletteData_4, DroughtPaletteData_5, - gSharedMem, + (u8*)eDroughtPaletteData.gammaShiftColors, }; // This is a pointer to gWeather. All code in this file accesses gWeather directly, @@ -65,6 +71,10 @@ static const u8 *const sCompressedDroughtPalettes[] = // this file produces the same result as accessing gWeather directly. struct Weather *const gWeatherPtr = &gWeather; +static bool8 sub_807D574(u8); +static void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static void BuildGammaShiftTables(void); +static void UpdateGammaShift(void); void None_Init(void); void None_Main(void); bool8 None_Finish(void); @@ -130,7 +140,7 @@ static const struct WeatherCallbacks sWeatherFuncs[] = {None_Init, None_Main, None_Init, None_Finish}, {Clouds_InitVars, Clouds_Main, Clouds_InitAll, Clouds_Finish}, {Weather2_InitVars, Weather2_Main, Weather2_InitAll, Weather2_Finish}, - {LightRain_InitVars, LightRain_Main, LightRain_InitAll, LightRain_Finish}, // light rain + {LightRain_InitVars, LightRain_Main, LightRain_InitAll, LightRain_Finish}, {Snow_InitVars, Snow_Main, Snow_InitAll, Snow_Finish}, {MedRain_InitVars, Rain_Main, MedRain_InitAll, Rain_Finish}, {Fog1_InitVars, Fog1_Main, Fog1_InitAll, Fog1_Finish}, @@ -146,46 +156,50 @@ static const struct WeatherCallbacks sWeatherFuncs[] = void (*const gUnknown_083970B8[])(void) = { - sub_807CC24, + UpdateGammaShift, sub_807CCAC, nullsub_39, nullsub_39, }; -const u8 gUnknown_083970C8[32] = +// This table specifies which of the gamma shift tables should be +// applied to each of the background and sprite palettes. +static const u8 sBasePaletteGammaTypes[32] = { - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 0, - 0, - 2, - 1, - 2, - 2, - 2, - 2, - 1, - 1, - 1, - 1, - 2, - 1, - 1, - 1, - 1, - 1, + // background palettes + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NONE, + GAMMA_NONE, + // sprite palettes + GAMMA_ALT, + GAMMA_NORMAL, + GAMMA_ALT, + GAMMA_ALT, + GAMMA_ALT, + GAMMA_ALT, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_ALT, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, + GAMMA_NORMAL, }; const u16 gUnknown_083970E8[] = INCBIN_U16("graphics/weather/0.gbapal"); @@ -198,8 +212,8 @@ void StartWeather(void) { index = AllocSpritePalette(0x1200); CpuCopy32(gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); - sub_807CB10(); - gWeatherPtr->unknown_6D5 = index; + BuildGammaShiftTables(); + gWeatherPtr->altGammaSpritePalIndex = index; gWeatherPtr->unknown_6D4 = AllocSpritePalette(0x1201); gWeatherPtr->rainSpriteCount = 0; gWeatherPtr->unknown_6D8 = 0; @@ -221,33 +235,35 @@ void StartWeather(void) } } -void DoWeatherEffect(u8 effect) +void ChangeWeather(u8 weather) { - if (effect != WEATHER_RAIN_LIGHT && effect != WEATHER_RAIN_MED && effect != WEATHER_RAIN_HEAVY) + if (weather != WEATHER_RAIN_LIGHT && weather != WEATHER_RAIN_MED && weather != WEATHER_RAIN_HEAVY) { PlayRainSoundEffect(); } - if (gWeatherPtr->nextWeather != effect && gWeatherPtr->currWeather == effect) + + if (gWeatherPtr->nextWeather != weather && gWeatherPtr->currWeather == weather) { - sWeatherFuncs[effect].initVars(); + sWeatherFuncs[weather].initVars(); } + gWeatherPtr->unknown_6D3 = 0; - gWeatherPtr->nextWeather = effect; + gWeatherPtr->nextWeather = weather; gWeatherPtr->finishStep = 0; } -void sub_807C988(u8 effect) +void sub_807C988(u8 weather) { PlayRainSoundEffect(); - gWeatherPtr->currWeather = effect; - gWeatherPtr->nextWeather = effect; + gWeatherPtr->currWeather = weather; + gWeatherPtr->nextWeather = weather; } -void sub_807C9B4(u8 effect) +void sub_807C9B4(u8 weather) { PlayRainSoundEffect(); - gWeatherPtr->currWeather = effect; - gWeatherPtr->nextWeather = effect; + gWeatherPtr->currWeather = weather; + gWeatherPtr->nextWeather = weather; gWeatherPtr->unknown_6C8 = 1; } @@ -295,7 +311,10 @@ u8 None_Finish(void) return 0; } -void sub_807CB10(void) +// Builds two tables that contain gamma shifts for palette colors. +// It's unclear why the two tables aren't declared as const arrays, since +// this function always builds the same two tables. +static void BuildGammaShiftTables(void) { u16 v0; u8 (*v1)[32]; @@ -308,13 +327,13 @@ void sub_807CB10(void) u16 v11; s16 dunno; - gUnknown_030006DC = gUnknown_083970C8; + sPaletteGammaTypes = sBasePaletteGammaTypes; for (v0 = 0; v0 <= 1; v0++) { if (v0 == 0) - v1 = gWeatherPtr->unknown_200; + v1 = gWeatherPtr->gammaShifts; else - v1 = gWeatherPtr->unk460; + v1 = gWeatherPtr->altGammaShifts; for (v2 = 0; v2 < 32; v2++) { @@ -362,7 +381,9 @@ void sub_807CB10(void) } } -void sub_807CC24(void) +// When the weather is changing, it gradually updates the palettes +// towards the desired gamma shift. +static void UpdateGammaShift(void) { if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex) { @@ -377,7 +398,7 @@ void sub_807CC24(void) gWeatherPtr->gammaIndex++; else gWeatherPtr->gammaIndex--; - BlendSomething_807CEBC(0, 0x20, gWeatherPtr->gammaIndex); + BlendSomething_807CEBC(0, 32, gWeatherPtr->gammaIndex); } } } @@ -433,11 +454,11 @@ u8 RainSnowShadeBlend_807CDC4(void) return 0; if (++gWeatherPtr->unknown_6C7 >= 0x10) { - BlendSomething_807CEBC(0, 0x20, 3); + BlendSomething_807CEBC(0, 32, 3); gWeatherPtr->unknown_6C7 = 0x10; return 0; } - BlendSomething_807D1BC(0, 0x20, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); + BlendSomething_807D1BC(0, 32, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); return 1; } @@ -447,11 +468,11 @@ u8 DroughtBlend_807CE24(void) return 0; if (++gWeatherPtr->unknown_6C7 >= 0x10) { - BlendSomething_807CEBC(0, 0x20, -6); + BlendSomething_807CEBC(0, 32, -6); gWeatherPtr->unknown_6C7 = 0x10; return 0; } - BlendSomething_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); + DroughtBlendSomething_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); return 1; } @@ -468,23 +489,26 @@ void nullsub_39(void) { } -void BlendSomething_807CEBC(u8 a, u8 b, s8 c) +void BlendSomething_807CEBC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) { - u16 r4; + u16 curPalIndex; u16 palOffset; - u8 *r6; + u8 *gammaTable; u16 i; - if (c > 0) + if (gammaIndex > 0) { - c = c - 1; - palOffset = a * 16; - b += a; - r4 = a; - while (r4 < b) + gammaIndex--; + palOffset = startPalIndex * 16; + numPalettes += startPalIndex; + curPalIndex = startPalIndex; + + // Loop through the speficied palette range and apply necessary gamma shifts to the colors. + while (curPalIndex < numPalettes) { - if (gUnknown_030006DC[r4] == 0) + if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) { + // No palette change. CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16)); palOffset += 16; } @@ -492,25 +516,27 @@ void BlendSomething_807CEBC(u8 a, u8 b, s8 c) { u8 r, g, b; - if (gUnknown_030006DC[r4] == 2 || r4 - 16 == gWeatherPtr->unknown_6D5) - r6 = gWeatherPtr->unk460[c]; + if (sPaletteGammaTypes[curPalIndex] == GAMMA_ALT || curPalIndex - 16 == gWeatherPtr->altGammaSpritePalIndex) + gammaTable = gWeatherPtr->altGammaShifts[gammaIndex]; else - r6 = gWeatherPtr->unknown_200[c]; - if (r4 == 16 || r4 > 0x1B) + gammaTable = gWeatherPtr->gammaShifts[gammaIndex]; + + if (curPalIndex == 16 || curPalIndex > 27) { for (i = 0; i < 16; i++) { - if (gPlttBufferUnfaded[palOffset] == 0x2D9F) + if (gPlttBufferUnfaded[palOffset] == RGB(31, 12, 11)) { + // Skip gamma shift for this specific color. (Why?) palOffset++; } else { - struct RGBColor color = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; - - r = r6[color.r]; - g = r6[color.g]; - b = r6[color.b]; + // Apply gamma shift to the original color. + struct RGBColor baseColor = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; + r = gammaTable[baseColor.r]; + g = gammaTable[baseColor.g]; + b = gammaTable[baseColor.b]; gPlttBufferFaded[palOffset++] = (b << 10) | (g << 5) | r; } } @@ -519,39 +545,45 @@ void BlendSomething_807CEBC(u8 a, u8 b, s8 c) { for (i = 0; i < 16; i++) { - struct RGBColor color = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; - - r = r6[color.r]; - g = r6[color.g]; - b = r6[color.b]; + // Apply gamma shift to the original color. + struct RGBColor baseColor = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; + r = gammaTable[baseColor.r]; + g = gammaTable[baseColor.g]; + b = gammaTable[baseColor.b]; gPlttBufferFaded[palOffset++] = (b << 10) | (g << 5) | r; } } } - r4++; + + curPalIndex++; } } - else if (c < 0) + else if (gammaIndex < 0) { - c = -c - 1; - palOffset = a * 16; - b += a; - r4 = a; - while (r4 < b) + // A negative gammIndex value means that the blending will come from the special Drought weather's palette tables. + gammaIndex = -gammaIndex - 1; + palOffset = startPalIndex * 16; + numPalettes += startPalIndex; + curPalIndex = startPalIndex; + + while (curPalIndex < numPalettes) { - if (gUnknown_030006DC[r4] == 0) + if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) { + // No palette change. CpuFastCopy(gPlttBufferUnfaded + palOffset, gPlttBufferFaded + palOffset, 16 * sizeof(u16)); palOffset += 16; } else { - if (r4 == 16 || r4 > 0x1B) + if (curPalIndex == 16 || curPalIndex > 27) { for (i = 0; i < 16; i++) { - if (gPlttBufferUnfaded[palOffset] != 0x2D9F) - gPlttBufferFaded[palOffset] = eWeatherPaletteData.data[c][MACRO1(gPlttBufferUnfaded[palOffset])]; + // Skip gamma shift for this specific color. (Why?) + if (gPlttBufferUnfaded[palOffset] != RGB(31, 12, 11)) + gPlttBufferFaded[palOffset] = eDroughtPaletteData.gammaShiftColors[gammaIndex][MACRO1(gPlttBufferUnfaded[palOffset])]; + palOffset++; } } @@ -559,93 +591,100 @@ void BlendSomething_807CEBC(u8 a, u8 b, s8 c) { for (i = 0; i < 16; i++) { - gPlttBufferFaded[palOffset] = eWeatherPaletteData.data[c][MACRO1(gPlttBufferUnfaded[palOffset])]; + gPlttBufferFaded[palOffset] = eDroughtPaletteData.gammaShiftColors[gammaIndex][MACRO1(gPlttBufferUnfaded[palOffset])]; palOffset++; } } } - r4++; + + curPalIndex++; } } else { - CpuFastCopy(gPlttBufferUnfaded + a * 16, gPlttBufferFaded + a * 16, b * 16 * sizeof(u16)); + // No palette blending. + CpuFastCopy(gPlttBufferUnfaded + startPalIndex * 16, gPlttBufferFaded + startPalIndex * 16, numPalettes * 16 * sizeof(u16)); } } -void BlendSomething_807D1BC(u8 a1, u8 a2, s8 c, u8 d, u16 e) +void BlendSomething_807D1BC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor) { u16 palOffset; - u16 r4; + u16 curPalIndex; u16 i; - struct RGBColor color = *(struct RGBColor *)&e; - u8 r_ = color.r; - u8 g_ = color.g; - u8 b_ = color.b; - - palOffset = a1 * 16; - a2 += a1; - c = c - 1; - r4 = a1; - while (r4 < a2) + struct RGBColor color = *(struct RGBColor *)&blendColor; + u8 rBlend = color.r; + u8 gBlend = color.g; + u8 bBlend = color.b; + + palOffset = startPalIndex * 16; + numPalettes += startPalIndex; + gammaIndex--; + curPalIndex = startPalIndex; + + while (curPalIndex < numPalettes) { - if (gUnknown_030006DC[r4] == 0) + if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) { - BlendPalette(palOffset, 16, d, e); + // No gamma shift. Simply blend the colors. + BlendPalette(palOffset, 16, blendCoeff, blendColor); palOffset += 16; } else { - u8 *r5; + u8 *gammaTable; - if (gUnknown_030006DC[r4] == 1) - r5 = gWeatherPtr->unknown_200[c]; + if (sPaletteGammaTypes[curPalIndex] == GAMMA_NORMAL) + gammaTable = gWeatherPtr->gammaShifts[gammaIndex]; else - r5 = gWeatherPtr->unk460[c]; + gammaTable = gWeatherPtr->altGammaShifts[gammaIndex]; for (i = 0; i < 16; i++) { - struct RGBColor color = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; - u8 r = r5[color.r]; - u8 g = r5[color.g]; - u8 b = r5[color.b]; - - r += ((r_ - r) * d) >> 4; - g += ((g_ - g) * d) >> 4; - b += ((b_ - b) * d) >> 4; + struct RGBColor baseColor = *(struct RGBColor *)&gPlttBufferUnfaded[palOffset]; + u8 r = gammaTable[baseColor.r]; + u8 g = gammaTable[baseColor.g]; + u8 b = gammaTable[baseColor.b]; + + // Apply gamma shift and target blend color to the original color. + r += ((rBlend - r) * blendCoeff) >> 4; + g += ((gBlend - g) * blendCoeff) >> 4; + b += ((bBlend - b) * blendCoeff) >> 4; gPlttBufferFaded[palOffset++] = (b << 10) | (g << 5) | r; } } - r4++; + + curPalIndex++; } } -void BlendSomething_807D304(s8 a, u8 coeff, u16 c) +void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor) { struct RGBColor color; - u8 r_; - u8 g_; - u8 b_; - u16 r4; + u8 rBlend; + u8 gBlend; + u8 bBlend; + u16 curPalIndex; u16 palOffset; - u16 r12; + u16 i; - a = -a - 1; - color = *(struct RGBColor *)&c; - r_ = color.r; - g_ = color.g; - b_ = color.b; + gammaIndex = -gammaIndex - 1; + color = *(struct RGBColor *)&blendColor; + rBlend = color.r; + gBlend = color.g; + bBlend = color.b; palOffset = 0; - for (r4 = 0; r4 < 32; r4++) + for (curPalIndex = 0; curPalIndex < 32; curPalIndex++) { - if (gUnknown_030006DC[r4] == 0) + if (sPaletteGammaTypes[curPalIndex] == GAMMA_NONE) { - BlendPalette(palOffset, 16, coeff, c); + // No gamma shift. Simply blend the colors. + BlendPalette(palOffset, 16, blendCoeff, blendColor); palOffset += 16; } else { - for (r12 = 0; r12 < 16; r12++) + for (i = 0; i < 16; i++) { u32 offset; struct RGBColor color1; @@ -659,14 +698,14 @@ void BlendSomething_807D304(s8 a, u8 coeff, u16 c) b1 = color1.b; offset = ((b1 & 0x1E) << 7) | ((g1 & 0x1E) << 3) | ((r1 & 0x1E) >> 1); - color2 = *(struct RGBColor *)&eWeatherPaletteData.data[a][offset]; + color2 = *(struct RGBColor *)&eDroughtPaletteData.gammaShiftColors[gammaIndex][offset]; r2 = color2.r; g2 = color2.g; b2 = color2.b; - r2 += ((r_ - r2) * coeff) >> 4; - g2 += ((g_ - g2) * coeff) >> 4; - b2 += ((b_ - b2) * coeff) >> 4; + r2 += ((rBlend - r2) * blendCoeff) >> 4; + g2 += ((gBlend - g2) * blendCoeff) >> 4; + b2 += ((bBlend - b2) * blendCoeff) >> 4; gPlttBufferFaded[palOffset++] = (b2 << 10) | (g2 << 5) | r2; } @@ -674,28 +713,26 @@ void BlendSomething_807D304(s8 a, u8 coeff, u16 c) } } -bool8 sub_807D574(u8); - -void BlendSomething_807D424(u8 coeff, u16 blendColor) +void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) { struct RGBColor color; - u8 blendR; - u8 blendG; - u8 blendB; - u16 palNum; + u8 rBlend; + u8 gBlend; + u8 bBlend; + u16 curPalIndex; - BlendPalette(0, 0x100, coeff, blendColor); + BlendPalette(0, 0x100, blendCoeff, blendColor); color = *(struct RGBColor *)&blendColor; - blendR = color.r; - blendG = color.g; - blendB = color.b; + rBlend = color.r; + gBlend = color.g; + bBlend = color.b; - for (palNum = 16; palNum < 32; palNum++) + for (curPalIndex = 16; curPalIndex < 32; curPalIndex++) { - if (sub_807D574(palNum)) + if (sub_807D574(curPalIndex)) { - u16 palEnd = (palNum + 1) * 16; - u16 palOffset = palNum * 16; + u16 palEnd = (curPalIndex + 1) * 16; + u16 palOffset = curPalIndex * 16; while (palOffset < palEnd) { @@ -708,9 +745,9 @@ void BlendSomething_807D424(u8 coeff, u16 blendColor) g += ((31 - g) * 3) >> 2; b += ((28 - b) * 3) >> 2; - r += ((blendR - r) * coeff) >> 4; - g += ((blendG - g) * coeff) >> 4; - b += ((blendB - b) * coeff) >> 4; + r += ((rBlend - r) * blendCoeff) >> 4; + g += ((gBlend - g) * blendCoeff) >> 4; + b += ((bBlend - b) * blendCoeff) >> 4; gPlttBufferFaded[palOffset] = (b << 10) | (g << 5) | r; palOffset++; @@ -718,51 +755,52 @@ void BlendSomething_807D424(u8 coeff, u16 blendColor) } else { - BlendPalette(palNum * 16, 16, coeff, blendColor); + BlendPalette(curPalIndex * 16, 16, blendCoeff, blendColor); } } } -void sub_807D540(u8 a) +void sub_807D540(u8 paletteIndex) { if (gWeatherPtr->unknown_6FA < 6) { - gWeatherPtr->unknown_6F4[gWeatherPtr->unknown_6FA] = a; + gWeatherPtr->unknown_6F4[gWeatherPtr->unknown_6FA] = paletteIndex; gWeatherPtr->unknown_6FA++; } } -bool8 sub_807D574(u8 a) +bool8 sub_807D574(u8 paletteIndex) { u16 i; for (i = 0; i < gWeatherPtr->unknown_6FA; i++) { - if (gWeatherPtr->unknown_6F4[i] == a) + if (gWeatherPtr->unknown_6F4[i] == paletteIndex) return TRUE; } + return FALSE; } -void sub_807D5BC(s8 a) +void sub_807D5BC(s8 gammaIndex) { if (gWeatherPtr->unknown_6C6 == 3) { - BlendSomething_807CEBC(0, 32, a); - gWeatherPtr->gammaIndex = a; + BlendSomething_807CEBC(0, 32, gammaIndex); + gWeatherPtr->gammaIndex = gammaIndex; } } -void sub_807D5F0(u8 a, u8 b, u8 c) +void sub_807D5F0(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) { if (gWeatherPtr->unknown_6C6 == 3) { gWeatherPtr->unknown_6C6 = 0; - gWeatherPtr->gammaIndex = a; - gWeatherPtr->gammaTargetIndex = b; + gWeatherPtr->gammaIndex = gammaIndex; + gWeatherPtr->gammaTargetIndex = gammaTargetIndex; gWeatherPtr->gammaStepFrameCounter = 0; - gWeatherPtr->gammaStepDelay = c; - sub_807D5BC(a); + gWeatherPtr->gammaStepDelay = gammaStepDelay; + sub_807D5BC(gammaIndex); } } @@ -837,9 +875,9 @@ bool8 sub_807D770(void) return (gWeatherPtr->unknown_6C6 != 1); } -void sub_807D78C(u8 a) +void sub_807D78C(u8 spritePaletteIndex) { - u16 r4 = 16 + a; + u16 paletteIndex = 16 + spritePaletteIndex; u16 i; switch (gWeatherPtr->unknown_6C6) @@ -848,34 +886,34 @@ void sub_807D78C(u8 a) if (gWeatherPtr->unknown_6CA != 0) { if (gWeatherPtr->currWeather == WEATHER_FOG_1) - sub_807D540(r4); - r4 *= 16; + sub_807D540(paletteIndex); + paletteIndex *= 16; for (i = 0; i < 16; i++) - gPlttBufferFaded[r4 + i] = gWeatherPtr->fadeDestColor; + gPlttBufferFaded[paletteIndex + i] = gWeatherPtr->fadeDestColor; } break; case 2: - r4 *= 16; - CpuFastCopy(gPlttBufferFaded + r4, gPlttBufferUnfaded + r4, 32); - BlendPalette(r4, 16, gPaletteFade.y, gPaletteFade.blendColor); + paletteIndex *= 16; + CpuFastCopy(gPlttBufferFaded + paletteIndex, gPlttBufferUnfaded + paletteIndex, 32); + BlendPalette(paletteIndex, 16, gPaletteFade.y, gPaletteFade.blendColor); break; default: if (gWeatherPtr->currWeather != WEATHER_FOG_1) { - BlendSomething_807CEBC(r4, 1, gWeatherPtr->gammaIndex); + BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); } else { - r4 *= 16; - BlendPalette(r4, 16, 12, 0x73FC); + paletteIndex *= 16; + BlendPalette(paletteIndex, 16, 12, 0x73FC); } break; } } -void sub_807D874(u8 a) +void sub_807D874(u8 paletteIndex) { - BlendSomething_807CEBC(a, 1, gWeatherPtr->gammaIndex); + BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); } u8 unref_sub_807D894(void) @@ -892,54 +930,54 @@ void sub_807D8C0(const u16 *palette) sub_807D78C(gWeatherPtr->unknown_6D4); } -void sub_807D8F0(u8 *a, u8 *b) +static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *b) { - u8 r4 = *a; + u8 gammaIndex = *gammaIndexPtr; u16 i; - if (r4 < 7) + if (gammaIndex < 7) { - r4--; - LZ77UnCompWram(sCompressedDroughtPalettes[r4], eWeatherPaletteData.data[r4]); - if (r4 == 0) + gammaIndex--; + LZ77UnCompWram(sCompressedDroughtPalettes[gammaIndex], eDroughtPaletteData.gammaShiftColors[gammaIndex]); + if (gammaIndex == 0) { - eWeatherPaletteData.data[r4][0] = 0x421; + eDroughtPaletteData.gammaShiftColors[gammaIndex][0] = RGB(1, 1, 1); for (i = 1; i < 0x1000; i++) - eWeatherPaletteData.data[r4][i] += eWeatherPaletteData.data[r4][i - 1]; + eDroughtPaletteData.gammaShiftColors[gammaIndex][i] += eDroughtPaletteData.gammaShiftColors[gammaIndex][i - 1]; } else { for (i = 0; i < 0x1000; i++) - eWeatherPaletteData.data[r4][i] += eWeatherPaletteData.data[r4 - 1][i]; + eDroughtPaletteData.gammaShiftColors[gammaIndex][i] += eDroughtPaletteData.gammaShiftColors[gammaIndex - 1][i]; } - if (++(*a) == 7) + if (++(*gammaIndexPtr) == 7) { - *a = 32; + *gammaIndexPtr = 32; *b = 32; } } } -void sub_807D9A8(void) +void ResetDroughtWeatherPaletteLoading(void) { - gWeatherPtr->unknown_74D = 1; - gWeatherPtr->unknown_74E = 1; + gWeatherPtr->loadDroughtPalsIndex = 1; + gWeatherPtr->loadDroughtPalsOffset = 1; } -bool8 sub_807D9C8(void) +bool8 LoadDroughtWeatherPalettes(void) { - if (gWeatherPtr->unknown_74D < 32) + if (gWeatherPtr->loadDroughtPalsIndex < 32) { - sub_807D8F0(&gWeatherPtr->unknown_74D, &gWeatherPtr->unknown_74E); - if (gWeatherPtr->unknown_74D < 32) + LoadDroughtWeatherPalette(&gWeatherPtr->loadDroughtPalsIndex, &gWeatherPtr->loadDroughtPalsOffset); + if (gWeatherPtr->loadDroughtPalsIndex < 32) return TRUE; } return FALSE; } -void sub_807DA04(s8 a) +void sub_807DA04(s8 gammaIndex) { - sub_807D5BC(-a - 1); + sub_807D5BC(-gammaIndex - 1); } void sub_807DA14(void) @@ -1001,8 +1039,8 @@ void Weather_SetTargetBlendCoeffs(u8 eva, u8 evb, int delay) gWeatherPtr->targetBlendEVA = eva; gWeatherPtr->targetBlendEVB = evb; gWeatherPtr->blendDelay = delay; - gWeatherPtr->unknown_739 = 0; - gWeatherPtr->unknown_738 = 0; + gWeatherPtr->blendFrameCounter = 0; + gWeatherPtr->blendUpdateCounter = 0; } bool8 Weather_UpdateBlend(void) @@ -1011,13 +1049,13 @@ bool8 Weather_UpdateBlend(void) && gWeatherPtr->currBlendEVB == gWeatherPtr->targetBlendEVB) return TRUE; - if (++gWeatherPtr->unknown_739 > gWeatherPtr->blendDelay) + if (++gWeatherPtr->blendFrameCounter > gWeatherPtr->blendDelay) { - gWeatherPtr->unknown_739 = 0; - gWeatherPtr->unknown_738++; + gWeatherPtr->blendFrameCounter = 0; + gWeatherPtr->blendUpdateCounter++; // Update currBlendEVA and currBlendEVB on alternate frames - if (gWeatherPtr->unknown_738 & 1) + if (gWeatherPtr->blendUpdateCounter & 1) { if (gWeatherPtr->currBlendEVA < gWeatherPtr->targetBlendEVA) gWeatherPtr->currBlendEVA++; @@ -1079,7 +1117,7 @@ void unref_sub_807DCB4(u8 a) } } -u8 weather_get_current(void) +u8 GetCurrentWeather(void) { return gWeatherPtr->currWeather; } @@ -1141,14 +1179,14 @@ void unref_sub_807DE24(void) gWeatherPtr->unknown_6C6 = 3; } -void sub_807DE38(u8 a) +void PreservePaletteInWeather(u8 preservedPalIndex) { - CpuCopy16(gUnknown_083970C8, gUnknown_0202FF38, 32); - gUnknown_0202FF38[a] = 0; - gUnknown_030006DC = gUnknown_0202FF38; + CpuCopy16(sBasePaletteGammaTypes, gFieldEffectPaletteGammaTypes, 32); + gFieldEffectPaletteGammaTypes[preservedPalIndex] = GAMMA_NONE; + sPaletteGammaTypes = gFieldEffectPaletteGammaTypes; } -void sub_807DE68(void) +void ResetPreservedPalettesInWeather(void) { - gUnknown_030006DC = gUnknown_083970C8; + sPaletteGammaTypes = sBasePaletteGammaTypes; } diff --git a/src/field/field_weather_effects.c b/src/field/field_weather_effects.c index 4ffa171e8..0fee26b89 100644 --- a/src/field/field_weather_effects.c +++ b/src/field/field_weather_effects.c @@ -74,10 +74,8 @@ static const struct SpriteTemplate sCloudSpriteTemplate = .callback = sub_807E0F4, }; -extern void sub_807D5BC(s8 a); +extern void sub_807D5BC(s8 gammaIndex); extern void sub_807D8C0(const u16 *palette); -extern void sub_807D9A8(void); -extern bool8 sub_807D9C8(void); extern void sub_807DA14(void); extern void sub_807DA4C(void); extern void Weather_SetTargetBlendCoeffs(u8 a, u8 b, int c); @@ -258,11 +256,11 @@ void Drought_Main(void) gWeatherPtr->initStep++; break; case 1: - sub_807D9A8(); + ResetDroughtWeatherPaletteLoading(); gWeatherPtr->initStep++; break; case 2: - if (sub_807D9C8() == FALSE) + if (LoadDroughtWeatherPalettes() == FALSE) gWeatherPtr->initStep++; break; case 3: @@ -2322,7 +2320,7 @@ void SetSav1WeatherFromCurrMapHeader(void) void SetWeather(u32 weather) { SetSav1Weather(weather); - DoWeatherEffect(GetSav1Weather()); + ChangeWeather(GetSav1Weather()); } void SetWeather_Unused(u32 weather) @@ -2333,7 +2331,7 @@ void SetWeather_Unused(u32 weather) void DoCurrentWeather(void) { - DoWeatherEffect(GetSav1Weather()); + ChangeWeather(GetSav1Weather()); } void sub_8080750(void) diff --git a/src/field/overworld.c b/src/field/overworld.c index a6d34e103..fc313693a 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -590,7 +590,7 @@ bool8 sub_80538D0(u16 x, u16 y) void sub_80538F0(u8 mapGroup, u8 mapNum) { - s32 i; + s32 paletteIndex; Overworld_SetWarpDestination(mapGroup, mapNum, -1, -1, -1); sub_8053F0C(); @@ -611,8 +611,8 @@ void sub_80538F0(u8 mapGroup, u8 mapNum) sub_8056D38(gMapHeader.mapData); apply_map_tileset2_palette(gMapHeader.mapData); - for (i = 6; i < 12; i++) - sub_807D874(i); + for (paletteIndex = 6; paletteIndex < 12; paletteIndex++) + sub_807D874(paletteIndex); sub_8072ED0(); UpdateLocationHistoryForRoamer(); diff --git a/src/scene/cable_car.c b/src/scene/cable_car.c index d8e099130..8b4a1bb28 100644 --- a/src/scene/cable_car.c +++ b/src/scene/cable_car.c @@ -357,7 +357,7 @@ static void sub_8123878(u8 taskId) case 0: if (sCableCarPtr->unk_0006 == sCableCarPtr->unk_0004) { - DoWeatherEffect(sCableCarPtr->unk_0002); + ChangeWeather(sCableCarPtr->unk_0002); sCableCarPtr->unk_0001 = 1; } break; -- cgit v1.2.3 From 584a68eb9d7a7c9cfa8e8ee1873ebe495f4fdec7 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 20 Jan 2018 16:02:30 -0600 Subject: use INCLUDE to include EWRAM and COMMON ld scripts --- ld_script.sed | 10 ---------- ld_script.txt | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/ld_script.sed b/ld_script.sed index b91542b6f..76b18c301 100644 --- a/ld_script.sed +++ b/ld_script.sed @@ -1,14 +1,4 @@ -// { - r sym_ewram.ld - d -} - // { r sym_bss.ld d } - -// { - r sym_common.ld - d -} diff --git a/ld_script.txt b/ld_script.txt index 82ba46b9c..18de179bc 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -9,7 +9,7 @@ SECTIONS { ewram (NOLOAD) : ALIGN(4) { - + INCLUDE "sym_ewram.ld" . = 0x40000; } @@ -26,7 +26,7 @@ SECTIONS { src/libs/m4a_2.o(.bss.code); /* COMMON starts at 0x3001760 */ - + INCLUDE "sym_common.ld" tools/agbcc/lib/libc.a:sbrkr.o(COMMON); end = .; . = 0x8000; -- cgit v1.2.3 From 003ed9293b2c51f0481ed31f0e0459cbecbf757e Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 20 Jan 2018 14:17:03 -0800 Subject: More documentation of field_weather --- asm/pokemon_storage_system.s | 4 +- include/decoration.h | 2 +- include/field_weather.h | 49 ++++---- src/battle/battle_transition.c | 4 +- src/engine/cable_club.c | 4 +- src/engine/time_events.c | 2 +- src/field/choose_party.c | 2 +- src/field/decoration.c | 20 +-- src/field/field_effect.c | 12 +- src/field/field_effect_helpers.c | 4 +- src/field/field_fadetransition.c | 14 +-- src/field/field_weather.c | 259 +++++++++++++++++++++----------------- src/field/field_weather_effects.c | 11 +- src/field/item_menu.c | 4 +- src/field/item_use.c | 2 +- src/field/overworld.c | 2 +- src/field/player_pc.c | 12 +- src/field/scrcmd.c | 4 +- src/field/secret_base.c | 8 +- src/field/shop.c | 6 +- src/field/start_menu.c | 2 +- src/pokemon/pokemon_menu.c | 2 +- src/scene/cable_car.c | 7 +- 23 files changed, 229 insertions(+), 207 deletions(-) diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 2ac873fcd..5b5dfbdd5 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -593,7 +593,7 @@ _08095EF4: .align 2, 0 _08095F18: .4byte gUnknown_083B600C _08095F1C: - bl sub_807D770 + bl IsWeatherNotFadingIn lsls r0, 24 cmp r0, 0 bne _08095F28 @@ -732,7 +732,7 @@ _08096030: .4byte gPCText_OnlyOne _08096034: movs r0, 0x1 movs r1, 0 - bl fade_screen + bl FadeScreen movs r0, 0x4 strh r0, [r4, 0x8] b _080960F4 diff --git a/include/decoration.h b/include/decoration.h index 74ca47a3a..c38bd1bcb 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -160,7 +160,7 @@ extern const struct YesNoFuncTable gUnknown_083ECAA0; extern u8 sub_8134194(u8); // src/decoration_inventory extern bool8 sub_81341D4(void); // src/decoration_inventory extern void sub_8134104(u8); // src/decoration_inventory -extern bool8 sub_807D770(void); +extern bool8 IsWeatherNotFadingIn(void); extern void sub_8109DAC(u8); // src/trader extern void ReshowPlayerPC(u8); // src/player_pc void Task_SecretBasePC_Decoration(u8); diff --git a/include/field_weather.h b/include/field_weather.h index 15be9229d..0bdebf747 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -1,7 +1,15 @@ #ifndef GUARD_WEATHER_H #define GUARD_WEATHER_H -struct Sprite; +#include "sprite.h" + +// Controls how the weather should be changing the screen palettes. +enum { + WEATHER_PAL_STATE_CHANGING_WEATHER, + WEATHER_PAL_STATE_SCREEN_FADING_IN, + WEATHER_PAL_STATE_SCREEN_FADING_OUT, + WEATHER_PAL_STATE_IDLE, +}; struct Weather { @@ -30,10 +38,10 @@ struct Weather u8 gammaStepDelay; u8 gammaStepFrameCounter; u16 fadeDestColor; - u8 unknown_6C6; - u8 unknown_6C7; - u8 unknown_6C8; - u8 unknown_6C9; + u8 palProcessingState; + u8 fadeScreenCounter; + bool8 readyForInit; + u8 taskId; u8 unknown_6CA; u8 unknown_6CB; u16 initStep; @@ -41,8 +49,8 @@ struct Weather u8 currWeather; u8 nextWeather; u8 weatherGfxLoaded; - u8 unknown_6D3; - u8 unknown_6D4; + bool8 weatherChangeComplete; + u8 weatherPicSpritePalIndex; u8 altGammaSpritePalIndex; u16 unknown_6D6; u8 unknown_6D8; @@ -66,8 +74,8 @@ struct Weather u16 fog1ScrollPosX; u16 unknown_6F0; u16 unknown_6F2; - u8 unknown_6F4[6]; - u8 unknown_6FA; + u8 lightenedFogSpritePals[6]; + u8 lightenedFogSpritePalsCount; u8 fog1SpritesCreated; u16 unknown_6FC; u16 unknown_6FE; @@ -121,17 +129,7 @@ void Task_WeatherInit(u8); void Task_WeatherMain(u8); void sub_807CAE8(void); void nullsub_38(void); -void sub_807CCAC(void); -u8 RainSnowShadeBlend_807CDC4(void); -u8 DroughtBlend_807CE24(void); -u8 Fog1Blend_807CE7C(void); -void nullsub_39(void); - -// ASM -void BlendSomething_807CEBC(u8, u8, s8); -void BlendSomething_807D1BC(u8 a, u8 a2, s8 c, u8 d, u16 e); -void BlendSomething_807D424(u8, u16); -// ... +void SetWeatherScreenFadeOut(void); enum { @@ -141,10 +139,10 @@ enum FADE_TO_WHITE, }; -void fade_screen(u8, u8); +void FadeScreen(u8, u8); // ... -void sub_807D78C(u8 tag); -void sub_807D874(u8); +void UpdateSpritePaletteWithWeather(u8 tag); +void ApplyWeatherGammaShiftToPal(u8); // ... void Weather_SetBlendCoeffs(u8, u8); // ... @@ -157,8 +155,8 @@ void SetSav1WeatherFromCurrMapHeader(void); void DoCurrentWeather(void); void sub_8080750(); -bool8 sub_807D770(void); -bool8 sub_807DDFC(void); +bool8 IsWeatherNotFadingIn(void); +bool8 IsWeatherChangeComplete(void); void SetWeather(u32); void UpdateWeatherPerDay(u16); void PreservePaletteInWeather(u8 index); @@ -167,6 +165,7 @@ extern void ResetDroughtWeatherPaletteLoading(void); void ResetDroughtWeatherPaletteLoading(void); bool8 LoadDroughtWeatherPalettes(void); u8 GetCurrentWeather(void); +void LoadCustomWeatherSpritePalette(const u16 *palette); extern struct Weather gWeather; diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c index f7cdc0694..a94974b27 100644 --- a/src/battle/battle_transition.c +++ b/src/battle/battle_transition.c @@ -6,6 +6,7 @@ #include "palette.h" #include "trig.h" #include "field_effect.h" +#include "field_weather.h" #include "random.h" #include "sprite.h" #include "sound.h" @@ -15,7 +16,6 @@ #include "ewram.h" #include "scanline_effect.h" -void sub_807DE10(void); void ScanlineEffect_Clear(void); extern const struct OamData gFieldOamData_32x32; @@ -567,7 +567,7 @@ static void Task_BattleTransitionMain(u8 taskID) static bool8 Transition_Phase1(struct Task* task) { - sub_807DE10(); + SetWeatherScreenFadeOut(); CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); if (sPhase1_Tasks[task->tTransitionID] != NULL) { diff --git a/src/engine/cable_club.c b/src/engine/cable_club.c index 44d832e2b..e7c504c7b 100644 --- a/src/engine/cable_club.c +++ b/src/engine/cable_club.c @@ -676,7 +676,7 @@ static void sub_808382C(u8 taskId) switch (task->data[0]) { case 0: - fade_screen(1, 0); + FadeScreen(1, 0); gLinkType = 0x2211; ClearLinkCallback_2(); task->data[0]++; @@ -812,7 +812,7 @@ static void sub_8083AAC(u8 taskId) { case 0: ScriptContext2_Enable(); - fade_screen(1, 0); + FadeScreen(1, 0); ClearLinkCallback_2(); task->data[0]++; break; diff --git a/src/engine/time_events.c b/src/engine/time_events.c index 3e3054aa3..4bd732788 100644 --- a/src/engine/time_events.c +++ b/src/engine/time_events.c @@ -93,7 +93,7 @@ void UpdateShoalTideFlag(void) static void Task_WaitWeather(u8 taskId) { - if (sub_807DDFC()) + if (IsWeatherChangeComplete()) { EnableBothScriptContexts(); DestroyTask(taskId); diff --git a/src/field/choose_party.c b/src/field/choose_party.c index 3ba04e489..18d26f007 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -930,7 +930,7 @@ void sub_81231AC(void) static void sub_81231C4(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { DestroyTask(taskId); ScriptContext2_Disable(); diff --git a/src/field/decoration.c b/src/field/decoration.c index 1cc3bbe06..0e7fa5f41 100644 --- a/src/field/decoration.c +++ b/src/field/decoration.c @@ -2239,7 +2239,7 @@ void sub_80FF5BC(u8 taskId) { if (sub_80FF58C() == TRUE) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_80FF6AC; } else @@ -2289,7 +2289,7 @@ void sub_80FF6AC(u8 taskId) gTasks[taskId].data[2] = 2; break; case 2: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].data[12] = 0; sub_810065C(taskId); @@ -3193,7 +3193,7 @@ void sub_810026C(u8 taskId) void sub_810028C(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = c1_overworld_prev_quest; } @@ -3222,7 +3222,7 @@ void c1_overworld_prev_quest(u8 taskId) void sub_8100334(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].func = sub_80FE948; } @@ -3629,7 +3629,7 @@ void sub_8100A0C(u8 taskId) { if (sub_8100D38(taskId) == 1) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_8100E70; } else @@ -3735,7 +3735,7 @@ void sub_8100C88(u8 taskId) gTasks[taskId].data[2] = 3; break; case 3: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].data[13] = -1; DisplayItemMessageOnField(taskId, gSecretBaseText_DecorReturned, sub_81010F0, 0); @@ -3800,7 +3800,7 @@ void sub_8100E70(u8 taskId) data[2] = 2; break; case 2: - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { data[12] = 1; sub_8100EEC(taskId); @@ -4138,7 +4138,7 @@ void sub_8101518(u8 taskId) void sub_810153C(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_8100C88; } @@ -4157,7 +4157,7 @@ void sub_8101590(u8 taskId) void sub_81015B0(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_81015E0; } @@ -4184,7 +4184,7 @@ void sub_81015E0(u8 taskId) void sub_8101648(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gTasks[taskId].func = Task_DecorationPCProcessMenuInput; } diff --git a/src/field/field_effect.c b/src/field/field_effect.c index a3134552d..ad570cf7f 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -407,7 +407,7 @@ void FieldEffectScript_LoadFadedPalette(u8 **script) { struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); LoadSpritePalette(palette); - sub_807D78C(IndexOfSpritePaletteTag(palette->tag)); + UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); (*script) += 4; } @@ -1091,7 +1091,7 @@ void task00_8084310(u8 taskId) task = &gTasks[taskId]; if (!task->data[0]) { - if (!sub_807D770()) + if (!IsWeatherNotFadingIn()) { return; } @@ -1191,7 +1191,7 @@ bool8 sub_80867AC(struct Task *task) // gUnknown_0839F2CC[0] bool8 sub_8086854(struct Task *task) // gUnknown_0839F2CC[1] { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { task->data[0]++; } @@ -1813,7 +1813,7 @@ bool8 sub_80874CC(struct Task *task, struct MapObject *mapObject, struct Sprite bool8 sub_80874FC(struct Task *task, struct MapObject *mapObject, struct Sprite *sprite) { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { gFieldEffectArguments[0] = mapObject->coords2.x; gFieldEffectArguments[1] = mapObject->coords2.y; @@ -2046,7 +2046,7 @@ void sub_8087A74(u8 taskId) void sub_8087AA4(struct Task *task) { - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { task->data[0]++; task->data[15] = player_get_direction_lower_nybble(); @@ -2199,7 +2199,7 @@ void sub_8087E4C(struct Task *task) { struct Sprite *sprite; s16 centerToCornerVecY; - if (sub_807D770()) + if (IsWeatherNotFadingIn()) { sprite = &gSprites[gPlayerAvatar.spriteId]; centerToCornerVecY = -(sprite->centerToCornerVecY << 1); diff --git a/src/field/field_effect_helpers.c b/src/field/field_effect_helpers.c index 165829a55..93fc62bd5 100644 --- a/src/field/field_effect_helpers.c +++ b/src/field/field_effect_helpers.c @@ -95,7 +95,7 @@ static void npc_pal_op_B(struct MapObject *mapObject, u8 paletteNum) { pal_patch_for_npc(npc_paltag_by_palslot(paletteNum), paletteNum); } - sub_807D78C(paletteNum); + UpdateSpritePaletteWithWeather(paletteNum); } } @@ -107,7 +107,7 @@ static void npc_pal_op_A(struct MapObject *mapObject, u8 paletteNum) if (graphicsInfo->paletteTag2 != 0x11ff) { pal_patch_for_npc(graphicsInfo->paletteTag2, paletteNum); - sub_807D78C(paletteNum); + UpdateSpritePaletteWithWeather(paletteNum); } } diff --git a/src/field/field_fadetransition.c b/src/field/field_fadetransition.c index 5014e97e3..ad1cd4a59 100644 --- a/src/field/field_fadetransition.c +++ b/src/field/field_fadetransition.c @@ -44,18 +44,18 @@ void pal_fill_for_map_transition(void) switch (fade_type_for_given_maplight_pair(map_light, Overworld_GetMapTypeOfSaveblockLocation())) { case 0: - fade_screen(0, 0); + FadeScreen(0, 0); palette_bg_fill_black(); break; case 1: - fade_screen(2, 0); + FadeScreen(2, 0); palette_bg_fill_white(); } } void pal_fill_black(void) { - fade_screen(0, 0); + FadeScreen(0, 0); palette_bg_fill_black(); } @@ -65,10 +65,10 @@ void fade_8080918(void) switch (sub_810CDB8(light_level, warp1_get_mapheader()->mapType)) { case 0: - fade_screen(1, 0); + FadeScreen(1, 0); break; case 1: - fade_screen(3, 0); + FadeScreen(3, 0); } } @@ -366,7 +366,7 @@ bool32 sub_8080E64(void) bool32 sub_8080E70(void) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) return TRUE; else return FALSE; @@ -483,7 +483,7 @@ void sub_8081050(u8 taskId) { case 0: ClearLinkCallback_2(); - fade_screen(1, 0); + FadeScreen(1, 0); sub_8053FF8(); PlaySE(SE_KAIDAN); data[0]++; diff --git a/src/field/field_weather.c b/src/field/field_weather.c index 2a5c311ab..7beb1b440 100644 --- a/src/field/field_weather.c +++ b/src/field/field_weather.c @@ -71,10 +71,18 @@ static const u8 *const sCompressedDroughtPalettes[] = // this file produces the same result as accessing gWeather directly. struct Weather *const gWeatherPtr = &gWeather; -static bool8 sub_807D574(u8); -static void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static bool8 LightenSpritePaletteInFog(u8); static void BuildGammaShiftTables(void); -static void UpdateGammaShift(void); +static void UpdateWeatherGammaShift(void); +static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex); +static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor); +static void ApplyFogBlend(u8 blendCoeff, u16 blendColor); +static bool8 FadeInScreen_RainShowShade(void); +static bool8 FadeInScreen_Drought(void); +static bool8 FadeInScreen_Fog1(void); +static void FadeInScreenWithWeather(void); +static void DoNothing(void); void None_Init(void); void None_Main(void); bool8 None_Finish(void); @@ -154,12 +162,12 @@ static const struct WeatherCallbacks sWeatherFuncs[] = {Bubbles_InitVars, Bubbles_Main, Bubbles_InitAll, Bubbles_Finish}, }; -void (*const gUnknown_083970B8[])(void) = +void (*const gWeatherPalStateFuncs[])(void) = { - UpdateGammaShift, - sub_807CCAC, - nullsub_39, - nullsub_39, + UpdateWeatherGammaShift, // WEATHER_PAL_STATE_CHANGING_WEATHER + FadeInScreenWithWeather, // WEATHER_PAL_STATE_SCREEN_FADING_IN + DoNothing, // WEATHER_PAL_STATE_SCREEN_FADING_OUT + DoNothing, // WEATHER_PAL_STATE_IDLE }; // This table specifies which of the gamma shift tables should be @@ -214,7 +222,7 @@ void StartWeather(void) CpuCopy32(gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); BuildGammaShiftTables(); gWeatherPtr->altGammaSpritePalIndex = index; - gWeatherPtr->unknown_6D4 = AllocSpritePalette(0x1201); + gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(0x1201); gWeatherPtr->rainSpriteCount = 0; gWeatherPtr->unknown_6D8 = 0; gWeatherPtr->cloudSpritesCreated = 0; @@ -225,13 +233,13 @@ void StartWeather(void) gWeatherPtr->sandstormSprites1Created = 0; gWeatherPtr->sandstormSprites2Created = 0; gWeatherPtr->unknown_72E = 0; - gWeatherPtr->unknown_6FA = 0; + gWeatherPtr->lightenedFogSpritePalsCount = 0; Weather_SetBlendCoeffs(16, 0); gWeatherPtr->currWeather = 0; - gWeatherPtr->unknown_6C6 = 3; - gWeatherPtr->unknown_6C8 = 0; - gWeatherPtr->unknown_6D3 = 1; - gWeatherPtr->unknown_6C9 = CreateTask(Task_WeatherInit, 80); + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; + gWeatherPtr->readyForInit = FALSE; + gWeatherPtr->weatherChangeComplete = TRUE; + gWeatherPtr->taskId = CreateTask(Task_WeatherInit, 80); } } @@ -247,7 +255,7 @@ void ChangeWeather(u8 weather) sWeatherFuncs[weather].initVars(); } - gWeatherPtr->unknown_6D3 = 0; + gWeatherPtr->weatherChangeComplete = FALSE; gWeatherPtr->nextWeather = weather; gWeatherPtr->finishStep = 0; } @@ -264,12 +272,14 @@ void sub_807C9B4(u8 weather) PlayRainSoundEffect(); gWeatherPtr->currWeather = weather; gWeatherPtr->nextWeather = weather; - gWeatherPtr->unknown_6C8 = 1; + gWeatherPtr->readyForInit = TRUE; } void Task_WeatherInit(u8 taskId) { - if (gWeatherPtr->unknown_6C8) + // Waits until it's ok to initialize weather. + // When the screen fades in, this is set to TRUE. + if (gWeatherPtr->readyForInit) { sWeatherFuncs[gWeatherPtr->currWeather].initAll(); gTasks[taskId].func = Task_WeatherMain; @@ -282,18 +292,20 @@ void Task_WeatherMain(u8 taskId) { if (!sWeatherFuncs[gWeatherPtr->currWeather].finish()) { + // Finished cleaning up previous weather. Now transition to next weather. sWeatherFuncs[gWeatherPtr->nextWeather].initVars(); gWeatherPtr->gammaStepFrameCounter = 0; - gWeatherPtr->unknown_6C6 = 0; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; gWeatherPtr->currWeather = gWeatherPtr->nextWeather; - gWeatherPtr->unknown_6D3 = 1; + gWeatherPtr->weatherChangeComplete = TRUE; } } else { sWeatherFuncs[gWeatherPtr->currWeather].main(); } - gUnknown_083970B8[gWeatherPtr->unknown_6C6](); + + gWeatherPalStateFuncs[gWeatherPtr->palProcessingState](); } void None_Init(void) @@ -383,11 +395,11 @@ static void BuildGammaShiftTables(void) // When the weather is changing, it gradually updates the palettes // towards the desired gamma shift. -static void UpdateGammaShift(void) +static void UpdateWeatherGammaShift(void) { if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex) { - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } else { @@ -398,15 +410,17 @@ static void UpdateGammaShift(void) gWeatherPtr->gammaIndex++; else gWeatherPtr->gammaIndex--; - BlendSomething_807CEBC(0, 32, gWeatherPtr->gammaIndex); + + ApplyGammaShift(0, 32, gWeatherPtr->gammaIndex); } } } -void sub_807CCAC(void) +static void FadeInScreenWithWeather(void) { if (++gWeatherPtr->unknown_6CB > 1) gWeatherPtr->unknown_6CA = 0; + switch (gWeatherPtr->currWeather) { case WEATHER_RAIN_LIGHT: @@ -414,24 +428,24 @@ void sub_807CCAC(void) case WEATHER_RAIN_HEAVY: case WEATHER_SNOW: case WEATHER_SHADE: - if (RainSnowShadeBlend_807CDC4() == 0) + if (FadeInScreen_RainShowShade() == FALSE) { gWeatherPtr->gammaIndex = 3; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_DROUGHT: - if (DroughtBlend_807CE24() == 0) + if (FadeInScreen_Drought() == FALSE) { gWeatherPtr->gammaIndex = -6; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_FOG_1: - if (Fog1Blend_807CE7C() == 0) + if (FadeInScreen_Fog1() == FALSE) { gWeatherPtr->gammaIndex = 0; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_ASH: @@ -442,54 +456,58 @@ void sub_807CCAC(void) if (!gPaletteFade.active) { gWeatherPtr->gammaIndex = gWeatherPtr->gammaTargetIndex; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; } } -u8 RainSnowShadeBlend_807CDC4(void) +bool8 FadeInScreen_RainShowShade(void) { - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - if (++gWeatherPtr->unknown_6C7 >= 0x10) + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + if (++gWeatherPtr->fadeScreenCounter >= 16) { - BlendSomething_807CEBC(0, 32, 3); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, 3); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - BlendSomething_807D1BC(0, 32, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; + + ApplyGammaShiftWithBlend(0, 32, 3, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -u8 DroughtBlend_807CE24(void) +bool8 FadeInScreen_Drought(void) { - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - if (++gWeatherPtr->unknown_6C7 >= 0x10) + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + if (++gWeatherPtr->fadeScreenCounter >= 16) { - BlendSomething_807CEBC(0, 32, -6); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, -6); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - DroughtBlendSomething_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; -} -u8 Fog1Blend_807CE7C(void) -{ - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - ++gWeatherPtr->unknown_6C7; - BlendSomething_807D424(0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->fadeDestColor); - return 1; + ApplyDroughtGammaShiftWithBlend(-6, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -void nullsub_39(void) +bool8 FadeInScreen_Fog1(void) { + if (gWeatherPtr->fadeScreenCounter == 16) + return FALSE; + + gWeatherPtr->fadeScreenCounter++; + ApplyFogBlend(16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -void BlendSomething_807CEBC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) +static void DoNothing(void) +{ } + +static void ApplyGammaShift(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) { u16 curPalIndex; u16 palOffset; @@ -607,7 +625,7 @@ void BlendSomething_807CEBC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex) } } -void BlendSomething_807D1BC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor) +static void ApplyGammaShiftWithBlend(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 blendCoeff, u16 blendColor) { u16 palOffset; u16 curPalIndex; @@ -658,7 +676,7 @@ void BlendSomething_807D1BC(u8 startPalIndex, u8 numPalettes, s8 gammaIndex, u8 } } -void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor) +void ApplyDroughtGammaShiftWithBlend(s8 gammaIndex, u8 blendCoeff, u16 blendColor) { struct RGBColor color; u8 rBlend; @@ -713,7 +731,7 @@ void DroughtBlendSomething_807D304(s8 gammaIndex, u8 blendCoeff, u16 blendColor) } } -void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) +void ApplyFogBlend(u8 blendCoeff, u16 blendColor) { struct RGBColor color; u8 rBlend; @@ -729,7 +747,7 @@ void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) for (curPalIndex = 16; curPalIndex < 32; curPalIndex++) { - if (sub_807D574(curPalIndex)) + if (LightenSpritePaletteInFog(curPalIndex)) { u16 palEnd = (curPalIndex + 1) * 16; u16 palOffset = curPalIndex * 16; @@ -760,22 +778,22 @@ void BlendSomething_807D424(u8 blendCoeff, u16 blendColor) } } -void sub_807D540(u8 paletteIndex) +static void MarkFogSpritePalToLighten(u8 paletteIndex) { - if (gWeatherPtr->unknown_6FA < 6) + if (gWeatherPtr->lightenedFogSpritePalsCount < 6) { - gWeatherPtr->unknown_6F4[gWeatherPtr->unknown_6FA] = paletteIndex; - gWeatherPtr->unknown_6FA++; + gWeatherPtr->lightenedFogSpritePals[gWeatherPtr->lightenedFogSpritePalsCount] = paletteIndex; + gWeatherPtr->lightenedFogSpritePalsCount++; } } -bool8 sub_807D574(u8 paletteIndex) +static bool8 LightenSpritePaletteInFog(u8 paletteIndex) { u16 i; - for (i = 0; i < gWeatherPtr->unknown_6FA; i++) + for (i = 0; i < gWeatherPtr->lightenedFogSpritePalsCount; i++) { - if (gWeatherPtr->unknown_6F4[i] == paletteIndex) + if (gWeatherPtr->lightenedFogSpritePals[i] == paletteIndex) return TRUE; } @@ -784,18 +802,18 @@ bool8 sub_807D574(u8 paletteIndex) void sub_807D5BC(s8 gammaIndex) { - if (gWeatherPtr->unknown_6C6 == 3) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - BlendSomething_807CEBC(0, 32, gammaIndex); + ApplyGammaShift(0, 32, gammaIndex); gWeatherPtr->gammaIndex = gammaIndex; } } void sub_807D5F0(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) { - if (gWeatherPtr->unknown_6C6 == 3) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - gWeatherPtr->unknown_6C6 = 0; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; gWeatherPtr->gammaIndex = gammaIndex; gWeatherPtr->gammaTargetIndex = gammaTargetIndex; gWeatherPtr->gammaStepFrameCounter = 0; @@ -804,29 +822,29 @@ void sub_807D5F0(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) } } -void fade_screen(u8 mode, u8 delay) +void FadeScreen(u8 mode, u8 delay) { u32 fadeColor; - bool8 fadeTo; + bool8 fadeOut; bool8 useWeatherPal; switch (mode) { case FADE_FROM_BLACK: fadeColor = 0; - fadeTo = FALSE; + fadeOut = FALSE; break; case FADE_FROM_WHITE: fadeColor = 0xFFFF; - fadeTo = FALSE; + fadeOut = FALSE; break; case FADE_TO_BLACK: fadeColor = 0; - fadeTo = TRUE; + fadeOut = TRUE; break; case FADE_TO_WHITE: fadeColor = 0xFFFF; - fadeTo = TRUE; + fadeOut = TRUE; break; default: return; @@ -848,59 +866,63 @@ void fade_screen(u8 mode, u8 delay) break; } - if (fadeTo) + if (fadeOut) { if (useWeatherPal) CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + BeginNormalPaletteFade(0xFFFFFFFF, delay, 0, 16, fadeColor); - gWeatherPtr->unknown_6C6 = 2; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT; } else { gWeatherPtr->fadeDestColor = fadeColor; if (useWeatherPal) - gWeatherPtr->unknown_6C7 = 0; + gWeatherPtr->fadeScreenCounter = 0; else BeginNormalPaletteFade(0xFFFFFFFF, delay, 16, 0, fadeColor); - gWeatherPtr->unknown_6C6 = 1; + + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_IN; gWeatherPtr->unknown_6CA = 1; gWeatherPtr->unknown_6CB = 0; Weather_SetBlendCoeffs(gWeatherPtr->currBlendEVA, gWeatherPtr->currBlendEVB); - gWeatherPtr->unknown_6C8 = 1; + gWeatherPtr->readyForInit = TRUE; } } -bool8 sub_807D770(void) +bool8 IsWeatherNotFadingIn(void) { - return (gWeatherPtr->unknown_6C6 != 1); + return (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_IN); } -void sub_807D78C(u8 spritePaletteIndex) +void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex) { u16 paletteIndex = 16 + spritePaletteIndex; u16 i; - switch (gWeatherPtr->unknown_6C6) + switch (gWeatherPtr->palProcessingState) { - case 1: + case WEATHER_PAL_STATE_SCREEN_FADING_IN: if (gWeatherPtr->unknown_6CA != 0) { if (gWeatherPtr->currWeather == WEATHER_FOG_1) - sub_807D540(paletteIndex); + MarkFogSpritePalToLighten(paletteIndex); paletteIndex *= 16; for (i = 0; i < 16; i++) gPlttBufferFaded[paletteIndex + i] = gWeatherPtr->fadeDestColor; } break; - case 2: + case WEATHER_PAL_STATE_SCREEN_FADING_OUT: paletteIndex *= 16; CpuFastCopy(gPlttBufferFaded + paletteIndex, gPlttBufferUnfaded + paletteIndex, 32); BlendPalette(paletteIndex, 16, gPaletteFade.y, gPaletteFade.blendColor); break; + // WEATHER_PAL_STATE_CHANGING_WEATHER + // WEATHER_PAL_STATE_CHANGING_IDLE default: if (gWeatherPtr->currWeather != WEATHER_FOG_1) { - BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); + ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex); } else { @@ -911,23 +933,23 @@ void sub_807D78C(u8 spritePaletteIndex) } } -void sub_807D874(u8 paletteIndex) +void ApplyWeatherGammaShiftToPal(u8 paletteIndex) { - BlendSomething_807CEBC(paletteIndex, 1, gWeatherPtr->gammaIndex); + ApplyGammaShift(paletteIndex, 1, gWeatherPtr->gammaIndex); } u8 unref_sub_807D894(void) { - if (gWeatherPtr->unknown_6C6 == 1) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_SCREEN_FADING_IN) return gWeatherPtr->unknown_6CA; else return 0; } -void sub_807D8C0(const u16 *palette) +void LoadCustomWeatherSpritePalette(const u16 *palette) { - LoadPalette(palette, 0x100 + gWeatherPtr->unknown_6D4 * 16, 32); - sub_807D78C(gWeatherPtr->unknown_6D4); + LoadPalette(palette, 0x100 + gWeatherPtr->weatherPicSpritePalIndex * 16, 32); + UpdateSpritePaletteWithWeather(gWeatherPtr->weatherPicSpritePalIndex); } static void LoadDroughtWeatherPalette(u8 *gammaIndexPtr, u8 *b) @@ -1085,34 +1107,34 @@ void unref_sub_807DCB4(u8 a) switch (a) { case 1: - SetWeather(1); + SetWeather(WEATHER_CLOUDS); break; case 2: - SetWeather(2); + SetWeather(WEATHER_SUNNY); break; case 3: - SetWeather(3); + SetWeather(WEATHER_RAIN_LIGHT); break; case 4: - SetWeather(4); + SetWeather(WEATHER_SNOW); break; case 5: - SetWeather(5); + SetWeather(WEATHER_RAIN_MED); break; case 6: - SetWeather(6); + SetWeather(WEATHER_FOG_1); break; case 7: - SetWeather(9); + SetWeather(WEATHER_FOG_2); break; case 8: - SetWeather(7); + SetWeather(WEATHER_ASH); break; case 9: - SetWeather(8); + SetWeather(WEATHER_SANDSTORM); break; case 10: - SetWeather(11); + SetWeather(WEATHER_SHADE); break; } } @@ -1122,11 +1144,11 @@ u8 GetCurrentWeather(void) return gWeatherPtr->currWeather; } -void SetRainStrengthFromSoundEffect(u16 sndEff) +void SetRainStrengthFromSoundEffect(u16 soundEffect) { - if (gWeatherPtr->unknown_6C6 != 2) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT) { - switch (sndEff) + switch (soundEffect) { case SE_T_KOAME: gWeatherPtr->rainStrength = 0; @@ -1140,7 +1162,8 @@ void SetRainStrengthFromSoundEffect(u16 sndEff) default: return; } - PlaySE(sndEff); + + PlaySE(soundEffect); } } @@ -1164,19 +1187,19 @@ void PlayRainSoundEffect(void) } } -u8 sub_807DDFC(void) +u8 IsWeatherChangeComplete(void) { - return gWeatherPtr->unknown_6D3; + return gWeatherPtr->weatherChangeComplete; } -void sub_807DE10(void) +void SetWeatherScreenFadeOut(void) { - gWeatherPtr->unknown_6C6 = 2; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT; } void unref_sub_807DE24(void) { - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } void PreservePaletteInWeather(u8 preservedPalIndex) diff --git a/src/field/field_weather_effects.c b/src/field/field_weather_effects.c index 0fee26b89..eff702f8c 100644 --- a/src/field/field_weather_effects.c +++ b/src/field/field_weather_effects.c @@ -75,7 +75,6 @@ static const struct SpriteTemplate sCloudSpriteTemplate = }; extern void sub_807D5BC(s8 gammaIndex); -extern void sub_807D8C0(const u16 *palette); extern void sub_807DA14(void); extern void sub_807DA4C(void); extern void Weather_SetTargetBlendCoeffs(u8 a, u8 b, int c); @@ -182,7 +181,7 @@ void CreateCloudSprites(void) if (gWeatherPtr->cloudSpritesCreated == TRUE) return; LoadSpriteSheet(&sCloudSpriteSheet); - sub_807D8C0(gUnknown_08397108); + LoadCustomWeatherSpritePalette(gUnknown_08397108); for (i = 0; i < 3; i++) { u8 spriteId = CreateSprite(&sCloudSpriteTemplate, 0, 0, 0xFF); @@ -252,7 +251,7 @@ void Drought_Main(void) switch (gWeatherPtr->initStep) { case 0: - if (gWeatherPtr->unknown_6C6 != 0) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER) gWeatherPtr->initStep++; break; case 1: @@ -1137,7 +1136,7 @@ void Rain_Main(void) gWeatherPtr->initStep++; break; case 3: - if (gWeatherPtr->unknown_6C6 == 0) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_CHANGING_WEATHER) break; gWeatherPtr->initStep = 6; break; @@ -1211,7 +1210,7 @@ void Rain_Main(void) gWeatherPtr->initStep++; break; case 14: - if (gWeatherPtr->unknown_6C6 != 3) + if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_IDLE) break; gWeatherPtr->unknown_6EA = 1; gWeatherPtr->initStep = 4; @@ -2013,7 +2012,7 @@ void CreateSandstormSprites_1(void) if (!gWeatherPtr->sandstormSprites1Created) { LoadSpriteSheet(&sSandstormSpriteSheet); - sub_807D8C0(gUnknown_08397128); + LoadCustomWeatherSpritePalette(gUnknown_08397128); for (i = 0; i < 20; i++) { u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, 0, (i / 5) * 64, 1); diff --git a/src/field/item_menu.c b/src/field/item_menu.c index 6bad9f4d6..959eb09ae 100644 --- a/src/field/item_menu.c +++ b/src/field/item_menu.c @@ -47,7 +47,7 @@ extern void sub_808B5B4(); extern u8 sub_80F92F4(); extern void sub_80C9C7C(u8); extern void pal_fill_black(void); -extern bool8 sub_807D770(void); +extern bool8 IsWeatherNotFadingIn(void); extern u8 sub_80F931C(); extern void sub_808A3F8(u8); extern void Shop_FadeReturnToMartMenu(void); @@ -2699,7 +2699,7 @@ void ExecuteItemUseFromBlackPalette(void) static void Task_CallItemUseOnFieldCallback(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) gFieldItemUseCallback(taskId); } diff --git a/src/field/item_use.c b/src/field/item_use.c index cdad3f840..219ef5080 100644 --- a/src/field/item_use.c +++ b/src/field/item_use.c @@ -100,7 +100,7 @@ void ItemMenu_ConfirmNormalFade(u8 var) void ItemMenu_ConfirmComplexFade(u8 var) { ExecuteSwitchToOverworldFromItemUse(var); - fade_screen(1, 0); + FadeScreen(1, 0); } void SetUpItemUseOnFieldCallback(u8 taskId) diff --git a/src/field/overworld.c b/src/field/overworld.c index fc313693a..07453e4fe 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -612,7 +612,7 @@ void sub_80538F0(u8 mapGroup, u8 mapNum) apply_map_tileset2_palette(gMapHeader.mapData); for (paletteIndex = 6; paletteIndex < 12; paletteIndex++) - sub_807D874(paletteIndex); + ApplyWeatherGammaShiftToPal(paletteIndex); sub_8072ED0(); UpdateLocationHistoryForRoamer(); diff --git a/src/field/player_pc.c b/src/field/player_pc.c index 3719b7c7a..27427ecaa 100644 --- a/src/field/player_pc.c +++ b/src/field/player_pc.c @@ -29,7 +29,7 @@ extern void DestroyVerticalScrollIndicator(u8); extern void PauseVerticalScrollIndicator(u8); extern void LoadScrollIndicatorPalette(void); extern void ClearMailStruct(struct MailStruct *); -extern u8 sub_807D770(void); +extern u8 IsWeatherNotFadingIn(void); extern void sub_808B020(void); extern void ClearVerticalScrollIndicatorPalettes(void); @@ -357,12 +357,12 @@ static void Task_ItemStorage_Deposit(u8 taskId) static void ItemStorage_Deposit(u8 taskId) { TASK.FUNC = Task_ItemStorage_Deposit; - fade_screen(1, 0); + FadeScreen(1, 0); } static void ItemStorage_HandleReturnToProcessInput(u8 taskId) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) TASK.FUNC = ItemStorageMenuProcessInput; } @@ -1196,7 +1196,7 @@ static void Mailbox_MailOptionsProcessInput(u8 taskId) static void Mailbox_DoMailRead(u8 taskId) { - fade_screen(1, 0); + FadeScreen(1, 0); TASK.FUNC = Mailbox_FadeAndReadMail; } @@ -1211,7 +1211,7 @@ static void Mailbox_FadeAndReadMail(u8 taskId) static void Mailbox_HandleReturnToProcessInput(u8 taskId) // Mailbox_HandleReturnToProcessInput { - if(sub_807D770() == TRUE) // is black fade finished? why not gPaletteFade.active? + if (IsWeatherNotFadingIn() == TRUE) // is black fade finished? why not gPaletteFade.active? TASK.FUNC = Mailbox_ProcessInput; } @@ -1280,7 +1280,7 @@ static void Mailbox_Give(u8 taskId) Mailbox_NoPokemonForMail(taskId); // cannot be reached normally else { - fade_screen(1, 0); + FadeScreen(1, 0); TASK.FUNC = Mailbox_DoGiveMailPokeMenu; } } diff --git a/src/field/scrcmd.c b/src/field/scrcmd.c index 36edbe472..bc5cd0b1d 100644 --- a/src/field/scrcmd.c +++ b/src/field/scrcmd.c @@ -626,7 +626,7 @@ bool8 IsPaletteNotActive(void) bool8 ScrCmd_fadescreen(struct ScriptContext *ctx) { - fade_screen(ScriptReadByte(ctx), 0); + FadeScreen(ScriptReadByte(ctx), 0); SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } @@ -636,7 +636,7 @@ bool8 ScrCmd_fadescreenspeed(struct ScriptContext *ctx) u8 duration = ScriptReadByte(ctx); u8 delay = ScriptReadByte(ctx); - fade_screen(duration, delay); + FadeScreen(duration, delay); SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } diff --git a/src/field/secret_base.c b/src/field/secret_base.c index 134aebbc6..2d02de004 100644 --- a/src/field/secret_base.c +++ b/src/field/secret_base.c @@ -348,7 +348,7 @@ void sub_80BBA48(u8 taskid) void sub_80BBAF0(void) { CreateTask(sub_80BBA48, 0); - fade_screen(1, 0); + FadeScreen(1, 0); saved_warp2_set(0, gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1); } @@ -362,7 +362,7 @@ bool8 sub_80BBB24(void) void sub_80BBB50(u8 taskid) { FieldObjectTurn(&(gMapObjects[gPlayerAvatar.mapObjectId]), 2); - if (sub_807D770() == 1) { + if (IsWeatherNotFadingIn() == 1) { EnableBothScriptContexts(); DestroyTask(taskid); } @@ -397,7 +397,7 @@ void sub_80BBC78(void) { u8 taskid = CreateTask(sub_80BBBEC, 0); gTasks[taskid].data[0] = 0; - fade_screen(1, 0); + FadeScreen(1, 0); } bool8 CurrentMapIsSecretBase(void) @@ -534,7 +534,7 @@ void sub_80BC074(u8 taskid) void sub_80BC0F8(void) { CreateTask(sub_80BC074, 0); - fade_screen(1, 0); + FadeScreen(1, 0); } void sub_80BC114(void) { diff --git a/src/field/shop.c b/src/field/shop.c index a228ff92f..e087628da 100644 --- a/src/field/shop.c +++ b/src/field/shop.c @@ -173,7 +173,7 @@ static void Task_HandleShopMenuBuy(u8 taskId) gTasks[taskId].data[8] = (u32)BuyMenuDrawGraphics >> 16; gTasks[taskId].data[9] = (u32)BuyMenuDrawGraphics; gTasks[taskId].func = Shop_FadeAndRunBuySellCallback; - fade_screen(1, 0); + FadeScreen(1, 0); } static void Task_HandleShopMenuSell(u8 taskId) @@ -181,7 +181,7 @@ static void Task_HandleShopMenuSell(u8 taskId) gTasks[taskId].data[8] = (u32)ItemMenu_LoadSellMenu >> 16; gTasks[taskId].data[9] = (u32)ItemMenu_LoadSellMenu; gTasks[taskId].func = Shop_FadeAndRunBuySellCallback; - fade_screen(1, 0); + FadeScreen(1, 0); } static void Task_HandleShopMenuQuit(u8 taskId) @@ -213,7 +213,7 @@ static void ReturnToShopMenuAfterExitingSellMenu(u8 taskId) static void Task_ReturnToMartMenu(u8 taskId) { - if (sub_807D770() == 1) + if (IsWeatherNotFadingIn() == 1) { if (gMartInfo.martType == MART_TYPE_2) DisplayItemMessageOnField(taskId, gOtherText_CanIHelpYou, ReturnToShopMenuAfterExitingSellMenu, 0); diff --git a/src/field/start_menu.c b/src/field/start_menu.c index 89cd404e9..381c19bb7 100644 --- a/src/field/start_menu.c +++ b/src/field/start_menu.c @@ -329,7 +329,7 @@ static u8 StartMenu_InputProcessCallback(void) if (gMenuCallback != StartMenu_SaveCallback && gMenuCallback != StartMenu_ExitCallback && gMenuCallback != StartMenu_RetireCallback) - fade_screen(1, 0); + FadeScreen(1, 0); return 0; } if (gMain.newKeys & (START_BUTTON | B_BUTTON)) diff --git a/src/pokemon/pokemon_menu.c b/src/pokemon/pokemon_menu.c index a41e197f2..c0cae9353 100644 --- a/src/pokemon/pokemon_menu.c +++ b/src/pokemon/pokemon_menu.c @@ -786,7 +786,7 @@ void FieldCallback_Teleport(void) static void sub_808ABA8(u8 taskID) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) { gFieldEffectArguments[0] = GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_SPECIES); gUnknown_03005CE4(); diff --git a/src/scene/cable_car.c b/src/scene/cable_car.c index 8b4a1bb28..7faa8d844 100644 --- a/src/scene/cable_car.c +++ b/src/scene/cable_car.c @@ -18,6 +18,7 @@ #include "event_data.h" #include "cable_car_util.h" #include "constants/map_objects.h" +#include "constants/weather.h" // Static type declarations @@ -328,7 +329,7 @@ static void sub_8123740(void) i = 0; sub_8123FBC(0); gSpriteCoordOffsetX = 0; - sub_807C9B4(0); + sub_807C9B4(WEATHER_NONE); for (; i < 20; i++) { gWeatherPtr->sprites.s2.ashSprites[i] = NULL; @@ -769,7 +770,7 @@ static void LoadSprites(void) gSprites[spriteId].data[1] = 0x63; sCableCarPtr->unk_0002 = 7; sCableCarPtr->unk_0004 = 0x15e; - sub_807C9B4(2); + sub_807C9B4(WEATHER_SUNNY); break; case 1: CableCarUtil_CopyWrapped(sCableCarPtr->unk_00fc, eCableCar2->mtChimneyTilemap + 0x24, 0x18, 0x1a, 0x0c, 0x03); @@ -793,7 +794,7 @@ static void LoadSprites(void) gSprites[spriteId].data[1] = 0x41; sCableCarPtr->unk_0002 = 2; sCableCarPtr->unk_0004 = 0x109; - sub_807C9B4(7); + sub_807C9B4(WEATHER_ASH); break; } for (i = 0; i < 9; i++) -- cgit v1.2.3 From 8030b37e7585972f8c1b07b5d9200cf9975b89b0 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 20 Jan 2018 16:18:59 -0600 Subject: use manual ld scripts for common syms --- Makefile | 4 +- sym_common.txt | 854 +++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 616 insertions(+), 242 deletions(-) diff --git a/Makefile b/Makefile index 13c91f71d..7718ee523 100644 --- a/Makefile +++ b/Makefile @@ -115,8 +115,8 @@ $(LD_SCRIPT): $(BUILD_DIR)/sym_bss.ld $(BUILD_DIR)/sym_common.ld $(BUILD_DIR)/sy cd $(BUILD_DIR) && sed -f ../../ld_script.sed ../../ld_script.txt | sed "s#tools/#../../tools/#g" >ld_script.ld $(BUILD_DIR)/sym_bss.ld: sym_bss.txt cd $(BUILD_DIR) && ../../$(RAMSCRGEN) .bss ../../sym_bss.txt $(GAME_LANGUAGE) >sym_bss.ld -$(BUILD_DIR)/sym_common.ld: sym_common.txt $(C_OBJECTS) $(wildcard common_syms/*.txt) - cd $(BUILD_DIR) && ../../$(RAMSCRGEN) COMMON ../../sym_common.txt $(GAME_LANGUAGE) -c src,../../common_syms >sym_common.ld +$(BUILD_DIR)/sym_common.ld: sym_common.txt + $(CPP) -P $(CPPFLAGS) $< > $@ $(BUILD_DIR)/sym_ewram.ld: sym_ewram.txt cd $(BUILD_DIR) && ../../$(RAMSCRGEN) ewram_data ../../sym_ewram.txt $(GAME_LANGUAGE) >sym_ewram.ld diff --git a/sym_common.txt b/sym_common.txt index a37aa05ff..1a523e7cb 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,240 +1,614 @@ - .include "engine/main.o" - .include "engine/sprite.o" - .include "engine/string_util.o" - .include "engine/link.o" - .include "engine/rtc.o" - .include "rom3.o" - -@ battle - - .align 2 -gBattle_BG3_X: @ 30041B0 - .space 0x4 - -gBattle_BG1_Y: @ 30041B4 - .space 0x4 - -gBattle_BG3_Y: @ 30041B8 - .space 0x8 - -gBattleTextBuff1: @ 30041C0 - .space 0x10 - -gUnknown_030041D0: @ 30041D0 - .space 0x30 - -gBattle_WIN1H: @ 3004200 - .space 0x10 - -gUnknown_03004210: @ 3004210 - .space 0x30 - -gBattle_WIN0V: @ 3004240 - .space 0x4 - -gBattle_WIN1V: @ 3004244 - .space 0xC - -gUnknown_03004250: @ 3004250 - .space 0x30 - -gBattle_BG2_Y: @ 3004280 - .space 0x4 - -gUnknown_03004284: @ 3004284 - .space 0x4 - -gBattle_BG2_X: @ 3004288 - .space 0x4 - -gBattleTerrain: @ 300428C - .space 0x4 - -gBattleTextBuff2: @ 3004290 - .space 0x10 - -gBattle_BG0_Y: @ 30042A0 - .space 0x4 - -gBattle_BG0_X: @ 30042A4 - .space 0xC - -gBattleTextBuff3: @ 30042B0 - .space 0x10 - -gBattle_BG1_X: @ 30042C0 - .space 0x4 - -gBattle_WIN0H: @ 30042C4 - .space 0xC - -gPreBattleCallback1: @ 30042D0 - .space 0x4 - -gBattleMainFunc: @ 30042D4 - .space 0xC - -gBattleResults: @ 30042E0 - .space 0x1C - -gUnknown_030042FC: @ 30042FC - .space 0xE - -gUnknown_0300430A: @ 300430A - .space 0xC - -gUnknown_03004316: @ 3004316 - .space 0xE - -gLeveledUpInBattle: @ 3004324 - .space 0xC - -gBattleBankFunc: @ 3004330 - .space 0x10 - -gHealthboxIDs: @ 3004340 - .space 0x4 - -gUnknown_03004344: @ 3004344 - .space 0x4 - -gUnknown_03004348: @ 3004348 - .space 0x4 - -gUnknown_0300434C: @ 300434C - .space 0x4 - - .include "pokemon/pokemon_1.o" - .include "engine/random.o" - .include "scene/egg_hatch.o" - .include "engine/load_save.o" - -@ trade - -gUnknown_03004824: @ 3004824 - .space 0x4 - -gUnknown_03004828: @ 3004828 - .space 0x8 - - .include "scene/berry_blender.o" - .include "field/overworld.o" - .include "field/fieldmap.o" - .include "field/field_camera.o" - .include "field/field_map_obj.o" - .include "field/field_control_avatar.o" - -@ party_menu? - - .align 2 -gPokemonItemUseCallback: @ 3004AE4 - .space 0x4 - - .include "field/start_menu.o" - .include "engine/sound.o" - .include "battle/battle_anim.o" - .include "engine/task.o" - .include "debug/mori_debug_menu.o" - -@ unknown_task - .include "scanline_effect.o" - .include "pokemon/pokemon_menu.o" - .include "pokemon/pokedex.o" - -@ pokemon_summary_screen - - .align 4 -gUnknown_03005CF0: @ 3005CF0 - .space 0x10 - -@ item_menu - - .align 4 -gFieldItemUseCallback: @ 3005D00 - .space 0x10 - -gBagPocketScrollStates: @ 3005D10 - .space 0x14 - -gCurrentBagPocketItemSlots: @ 3005D24 - .space 0x4 - -@ contest - - .align 2 -gUnknown_03005D28: @ 3005D28 - .space 0x4 - - .include "engine/record_mixing.o" - .include "debug/sound_check_menu.o" - .include "field/tv.o" - - .space 0x64 @ unused variable? - -@ mauville_old_man - - .align 4 -gUnknown_03005DA0: @ 3005DA0 - .space 0x48 - -@ cute_sketch - -gUnknown_03005DE8: @ 3005DE8 - .space 0x4 - -gUnknown_03005DEC: @ 3005DEC - .space 0x4 - -gUnknown_03005DF0: @ 3005DF0 - .space 0x4 - -gUnknown_03005DF4: @ 3005DF4 - .space 0x4 - -gUnknown_03005DF8: @ 3005DF8 - .space 0x4 - -gUnknown_03005DFC: @ 3005DFC - .space 0x4 - -gUnknown_03005E00: @ 3005E00 - .space 0x4 - -gUnknown_03005E04: @ 3005E04 - .space 0x4 - -gUnknown_03005E08: @ 3005E08 - .space 0x4 - -gUnknown_03005E0C: @ 3005E0C - .space 0x4 - - .include "scene/contest_painting.o" - .include "scene/evolution_scene.o" - -@ pokedex_cry_screen - -gUnknown_03005E98: @ 3005E98 - .space 0x4 - - .include "engine/save.o" - - .space 0x10 @ unused variable? - - .include "scene/intro.o" - -@ battle_anim_813F0F4 - - .align 2 -gUnknown_03005F0C: @ 3005F0C - .space 0x4 - -gUnknown_03005F10: @ 3005F10 - .space 0x4 - -gUnknown_03005F14: @ 3005F14 - .space 0xC - - .include "pokemon/pokeblock_feed.o" - .include "libs/m4a_2.o" - .include "libs/agb_flash.o" +. = ALIGN(4); +. = ALIGN(4); +gKeyRepeatStartDelay = .; +. += 0x4; +. = ALIGN(4); +gLinkTransferringData = .; +. += 0x4; +. = ALIGN(16); +gMain = .; +. += 0x440; +. = ALIGN(4); +gKeyRepeatContinueDelay = .; +. += 0x4; +. = ALIGN(4); +gSoftResetDisabled = .; +. += 0x4; +. = ALIGN(16); +gIntrTable = .; +. += 0x38; +. = ALIGN(4); +gLinkVSyncDisabled = .; +. += 0x4; +. = ALIGN(16); +IntrMain_Buffer = .; +. += 0x800; +. = ALIGN(4); +gPcmDmaCounter = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(16); +gSpriteOrder = .; +. += 0x40; +. = ALIGN(16); +gSpriteTileAllocBitmap = .; +. += 0x80; +. = ALIGN(4); +gSpriteCoordOffsetX = .; +. += 0x4; +. = ALIGN(4); +gOamLimit = .; +. += 0x4; +. = ALIGN(4); +gReservedSpriteTileCount = .; +. += 0x4; +. = ALIGN(4); +gSpriteCopyRequestCount = .; +. += 0x4; +. = ALIGN(16); +gSpriteCopyRequests = .; +. += 0x300; +. = ALIGN(4); +gSpriteCoordOffsetY = .; +. += 0x4; +. = ALIGN(16); +gOamMatrices = .; +. += 0x100; +. = ALIGN(4); +gShouldProcessSpriteCopyRequests = .; +. += 0x4; +. = ALIGN(4); +gOamMatrixAllocBitmap = .; +. += 0x4; +. = ALIGN(4); +gReservedSpritePaletteCount = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(16); +gUnknownStringVar = .; +. += 0x10; +. = ALIGN(4); +. = ALIGN(8); +word_3002910 = .; +. += 0x8; +. = ALIGN(4); +gLinkDebugValue1 = .; +. += 0x4; +. = ALIGN(16); +localLinkPlayerBlock = .; +. += 0x3C; +. = ALIGN(4); +gLinkErrorOccurred = .; +. += 0x4; +. += 0x4; +. = ALIGN(4); +gLinkDebugValue2 = .; +. += 0x4; +. += 0x4; + +#ifdef GERMAN +. = ALIGN(4); +deUnkValue1 = .; +. += 0x4; +. = ALIGN(4); +deUnkValue2 = .; +. += 0x4; +#endif + +. = ALIGN(4); +gLinkPlayerPending = .; +. += 0x4; +. = ALIGN(16); +gLinkPlayers = .; +. += 0x70; +. = ALIGN(4); +gBlockReceived = .; +. += 0x4; +. += 0x4; +. = ALIGN(4); +gLinkHeldKeys = .; +. += 0x4; +. = ALIGN(4); +gLinkTimeOutCounter = .; +. += 0x4; +. += 0x4; +. = ALIGN(16); +localLinkPlayer = .; +. += 0x1C; +. = ALIGN(16); +gRecvCmds = .; +. += 0x40; +. = ALIGN(4); +gLinkStatus = .; +. += 0x4; +. = ALIGN(4); +gLinkDummyBool = .; +. += 0x4; +. = ALIGN(4); +byte_3002A68 = .; +. += 0x4; +. = ALIGN(16); +gBlockSendBuffer = .; +. += 0x100; +. = ALIGN(4); +u8_array_3002B70 = .; +. += 0x4; +. = ALIGN(4); +gLinkType = .; +. += 0x4; +. = ALIGN(4); +u8_array_3002B78 = .; +. += 0x4; +. = ALIGN(16); +gBlockRecvBuffer = .; +. += 0x400; +. = ALIGN(4); +gSuppressLinkErrorMessage = .; +. += 0x4; +. = ALIGN(4); +gSavedLinkPlayerCount = .; +. += 0x4; +. = ALIGN(16); +gSendCmd = .; +. += 0x10; +. = ALIGN(4); +gSavedMultiplayerId = .; +. += 0x4; +. = ALIGN(4); +gReceivedRemoteLinkPlayers = .; +. += 0x4; +. = ALIGN(16); +gLinkTestBGInfo = .; +. += 0x10; +. = ALIGN(4); +gLinkCallback = .; +. += 0x4; +. = ALIGN(16); +gSavedLinkPlayers = .; +. += 0x70; +. = ALIGN(4); +gShouldAdvanceLinkState = .; +. += 0x4; +. = ALIGN(8); +gLinkTestBlockChecksums = .; +. += 0x8; +. += 0x4; +. = ALIGN(4); +gBlockRequestType = .; +. += 0x4; +. += 0x4; +. += 0x4; +. = ALIGN(4); +gLastSendQueueCount = .; +. += 0x4; +. = ALIGN(16); +gLink = .; +. += 0xFC0; +. = ALIGN(4); +gLastRecvQueueCount = .; +. += 0x4; +. = ALIGN(4); +gLinkSavedIme = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(8); +gLocalTime = .; +. += 0x8; +. = ALIGN(4); +. = ALIGN(16); +gBattleBuffersTransferData = .; +. += 0x170; +. = ALIGN(4); +gBattle_BG3_X = .; +. += 0x4; +gBattle_BG1_Y = .; +. += 0x4; +gBattle_BG3_Y = .; +. += 0x8; +gBattleTextBuff1 = .; +. += 0x10; +gUnknown_030041D0 = .; +. += 0x30; +gBattle_WIN1H = .; +. += 0x10; +gUnknown_03004210 = .; +. += 0x30; +gBattle_WIN0V = .; +. += 0x4; +gBattle_WIN1V = .; +. += 0xC; +gUnknown_03004250 = .; +. += 0x30; +gBattle_BG2_Y = .; +. += 0x4; +gUnknown_03004284 = .; +. += 0x4; +gBattle_BG2_X = .; +. += 0x4; +gBattleTerrain = .; +. += 0x4; +gBattleTextBuff2 = .; +. += 0x10; +gBattle_BG0_Y = .; +. += 0x4; +gBattle_BG0_X = .; +. += 0xC; +gBattleTextBuff3 = .; +. += 0x10; +gBattle_BG1_X = .; +. += 0x4; +gBattle_WIN0H = .; +. += 0xC; +gPreBattleCallback1 = .; +. += 0x4; +gBattleMainFunc = .; +. += 0xC; +gBattleResults = .; +. += 0x1C; +gUnknown_030042FC = .; +. += 0xE; +gUnknown_0300430A = .; +. += 0xC; +gUnknown_03004316 = .; +. += 0xE; +gLeveledUpInBattle = .; +. += 0xC; +gBattleBankFunc = .; +. += 0x10; +gHealthboxIDs = .; +. += 0x4; +gUnknown_03004344 = .; +. += 0x4; +gUnknown_03004348 = .; +. += 0x4; +gUnknown_0300434C = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gPlayerPartyCount = .; +. += 0x4; +. = ALIGN(16); +gPlayerParty = .; +. += 0x258; +. = ALIGN(4); +gEnemyPartyCount = .; +. += 0x4; +. = ALIGN(16); +gEnemyParty = .; +. += 0x258; +. = ALIGN(4); +. = ALIGN(4); +gRngValue = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gEggHatchData = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gFlashMemoryPresent = .; +. += 0x4; +gUnknown_03004824 = .; +. += 0x4; +gUnknown_03004828 = .; +. += 0x8; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03004830 = .; +. += 0x4; +. = ALIGN(4); +gInGameOpponentsNo = .; +. += 0x4; +. = ALIGN(16); +gUnknown_03004840 = .; +. += 0x14; +. = ALIGN(4); +gBerryBlenderData = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +word_3004858 = .; +. += 0x4; +. = ALIGN(4); +gFieldCallback = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03004860 = .; +. += 0x4; +. = ALIGN(4); +gFieldLinkPlayerCount = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(16); +gUnknown_03004870 = .; +. += 0xC; +. = ALIGN(4); +. = ALIGN(16); +gUnknown_03004880 = .; +. += 0x18; +. = ALIGN(4); +gUnknown_03004898 = .; +. += 0x4; +. = ALIGN(4); +gUnknown_0300489C = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(16); +gMapObjects = .; +. += 0x240; +. = ALIGN(4); +. = ALIGN(4); +gSelectedMapObject = .; +. += 0x4; +. = ALIGN(4); +gPokemonItemUseCallback = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gMenuCallback = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gDisableMusic = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gSoundAnimFramesToWait = .; +. += 0x4; +. = ALIGN(16); +gBattleAnimArgs = .; +. += 0x10; +. = ALIGN(16); +gAnimSpriteIndexArray = .; +. += 0x10; +. = ALIGN(4); +. = ALIGN(16); +gTasks = .; +. += 0x280; +. = ALIGN(4); +. = ALIGN(16); +gUnknown_03004DA0 = .; +. += 0x20; +. = ALIGN(4); +. = ALIGN(16); +gScanlineEffect = .; +. += 0x20; +. = ALIGN(16); +gScanlineEffectRegBuffers = .; +. += 0xF00; +. = ALIGN(4); +. = ALIGN(4); +gLastFieldPokeMenuOpened = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005CE4 = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03005CE8 = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005CEC = .; +. += 0x4; +. = ALIGN(16); +gUnknown_03005CF0 = .; +. += 0x10; +. = ALIGN(16); +gFieldItemUseCallback = .; +. += 0x10; +gBagPocketScrollStates = .; +. += 0x14; +gCurrentBagPocketItemSlots = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005D28 = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03005D2C = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03005D30 = .; +. += 0x4; +. = ALIGN(4); +gSoundTestCryNum = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03005D38 = .; +. += 0x4; +. += 0x64; +. = ALIGN(16); +gUnknown_03005DA0 = .; +. += 0x48; +gUnknown_03005DE8 = .; +. += 0x4; +gUnknown_03005DEC = .; +. += 0x4; +gUnknown_03005DF0 = .; +. += 0x4; +gUnknown_03005DF4 = .; +. += 0x4; +gUnknown_03005DF8 = .; +. += 0x4; +gUnknown_03005DFC = .; +. += 0x4; +gUnknown_03005E00 = .; +. += 0x4; +gUnknown_03005E04 = .; +. += 0x4; +gUnknown_03005E08 = .; +. += 0x4; +gUnknown_03005E0C = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gUnknown_03005E10 = .; +. += 0x4; +. = ALIGN(16); +gUnknown_03005E20 = .; +. += 0x20; +. = ALIGN(16); +gUnknown_03005E40 = .; +. += 0x4C; +. = ALIGN(4); +gUnknown_03005E8C = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005E90 = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gCB2_AfterEvolution = .; +. += 0x4; +gUnknown_03005E98 = .; +. += 0x4; +. = ALIGN(4); +. = ALIGN(4); +gFirstSaveSector = .; +. += 0x4; +. = ALIGN(4); +gPrevSaveCounter = .; +. += 0x4; +. = ALIGN(4); +gLastKnownGoodSector = .; +. += 0x4; +. = ALIGN(4); +gDamagedSaveSectors = .; +. += 0x4; +. = ALIGN(4); +gSaveCounter = .; +. += 0x4; +. = ALIGN(4); +gFastSaveSection = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005EB4 = .; +. += 0x4; +. = ALIGN(4); +gSaveFileStatus = .; +. += 0x4; +. = ALIGN(4); +gGameContinueCallback = .; +. += 0x4; +. += 0x10; +. = ALIGN(4); +. = ALIGN(4); +gIntroFrameCounter = .; +. += 0x4; +. = ALIGN(16); +gMultibootProgramStruct = .; +. += 0x2C; +. = ALIGN(4); +gUnknown_03005F0C = .; +. += 0x4; +gUnknown_03005F10 = .; +. += 0x4; +gUnknown_03005F14 = .; +. += 0xC; +. = ALIGN(4); +. = ALIGN(4); +gPokeblockFeedPokeSprite = .; +. += 0x4; +. = ALIGN(4); +gPokeblockFeedMonSpecies = .; +. += 0x4; +. = ALIGN(4); +gPokeblockMonNotFlipped = .; +. += 0x4; +. = ALIGN(4); +gPokeblockFeedMonSpriteID = .; +. += 0x4; +. = ALIGN(4); +gPokeblockFeedMonNature = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005F34 = .; +. += 0x4; +. = ALIGN(4); +gPokeblockFeedUnused0 = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005F3C = .; +. += 0x4; +. = ALIGN(4); +gUnknown_03005F40 = .; +. += 0x4; +. = ALIGN(16); +gPokeblockFeedPokeSpriteCopy = .; +. += 0x44; +. = ALIGN(4); +gUnknown_03005F94 = .; +. += 0x4; +. = ALIGN(16); +gUnknown_03005FA0 = .; +. += 0x30; +. = ALIGN(4); +. = ALIGN(16); +gSoundInfo = .; +. += 0xFB0; +. = ALIGN(16); +gPokemonCrySongs = .; +. += 0x68; +. = ALIGN(16); +gPokemonCryMusicPlayers = .; +. += 0x80; +. = ALIGN(16); +gMPlayJumpTable = .; +. += 0x90; +. = ALIGN(16); +gCgbChans = .; +. += 0x100; +. = ALIGN(16); +gPokemonCryTracks = .; +. += 0x140; +. = ALIGN(16); +gPokemonCrySong = .; +. += 0x34; +. = ALIGN(16); +gMPlay_BGM = .; +. += 0x40; +. = ALIGN(16); +gMPlay_SE1 = .; +. += 0x40; +. = ALIGN(16); +gMPlay_SE2 = .; +. += 0x40; +. = ALIGN(16); +gMPlayMemAccArea = .; +. += 0x10; +. = ALIGN(16); +gMPlay_SE3 = .; +. += 0x40; +. = ALIGN(4); +. = ALIGN(4); +gFlashTimeoutFlag = .; +. += 0x4; +. = ALIGN(4); +PollFlashStatus = .; +. += 0x4; +. = ALIGN(4); +WaitForFlashWrite = .; +. += 0x4; +. = ALIGN(4); +ProgramFlashSector = .; +. += 0x4; +. = ALIGN(4); +gFlash = .; +. += 0x4; +. = ALIGN(4); +ProgramFlashByte = .; +. += 0x4; +. = ALIGN(4); +gFlashNumRemainingBytes = .; +. += 0x4; +. = ALIGN(4); +EraseFlashChip = .; +. += 0x4; +. = ALIGN(4); +EraseFlashSector = .; +. += 0x4; +. = ALIGN(4); +gFlashMaxTime = .; +. += 0x4; -- cgit v1.2.3 From 933d63e1fd865ccca2ef8f75d6273d093a455900 Mon Sep 17 00:00:00 2001 From: yenatch Date: Sat, 20 Jan 2018 18:34:37 -0500 Subject: make special ids global --- data/specials.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/data/specials.inc b/data/specials.inc index 6904a2b6b..73aa3e093 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -1,4 +1,5 @@ .macro def_special ptr +.global SPECIAL_\ptr .set SPECIAL_\ptr, __special__ .set __special__, __special__ + 1 .4byte \ptr -- cgit v1.2.3 From 7a4f92553a41fdd14a29ac038b512cb8603d2a0c Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 20 Jan 2018 22:06:58 -0600 Subject: use C preprocessor to generate common syms file --- common_syms/battle/battle_anim.txt | 3 - common_syms/debug/mori_debug_menu.txt | 1 - common_syms/debug/sound_check_menu.txt | 2 - common_syms/engine/link.txt | 46 -- common_syms/engine/load_save.txt | 1 - common_syms/engine/main.txt | 9 - common_syms/engine/random.txt | 1 - common_syms/engine/record_mixing.txt | 1 - common_syms/engine/rtc.txt | 1 - common_syms/engine/save.txt | 9 - common_syms/engine/sound.txt | 1 - common_syms/engine/sprite.txt | 12 - common_syms/engine/string_util.txt | 1 - common_syms/engine/task.txt | 1 - common_syms/field/field_camera.txt | 3 - common_syms/field/field_control_avatar.txt | 1 - common_syms/field/field_map_obj.txt | 1 - common_syms/field/fieldmap.txt | 1 - common_syms/field/overworld.txt | 4 - common_syms/field/start_menu.txt | 1 - common_syms/field/tv.txt | 1 - common_syms/libs/agb_flash.txt | 10 - common_syms/libs/m4a_2.txt | 12 - common_syms/pokemon/pokeblock_feed.txt | 12 - common_syms/pokemon/pokedex.txt | 2 - common_syms/pokemon/pokemon_1.txt | 4 - common_syms/pokemon/pokemon_menu.txt | 2 - common_syms/rom3.txt | 1 - common_syms/scanline_effect.txt | 2 - common_syms/scene/berry_blender.txt | 4 - common_syms/scene/contest_painting.txt | 5 - common_syms/scene/cute_sketch.txt | 0 common_syms/scene/egg_hatch.txt | 1 - common_syms/scene/evolution_scene.txt | 1 - common_syms/scene/intro.txt | 2 - src/field/tv.c | 2 - sym_common.txt | 799 ++++++++--------------------- 37 files changed, 210 insertions(+), 750 deletions(-) delete mode 100644 common_syms/battle/battle_anim.txt delete mode 100644 common_syms/debug/mori_debug_menu.txt delete mode 100644 common_syms/debug/sound_check_menu.txt delete mode 100644 common_syms/engine/link.txt delete mode 100644 common_syms/engine/load_save.txt delete mode 100644 common_syms/engine/main.txt delete mode 100644 common_syms/engine/random.txt delete mode 100644 common_syms/engine/record_mixing.txt delete mode 100644 common_syms/engine/rtc.txt delete mode 100644 common_syms/engine/save.txt delete mode 100644 common_syms/engine/sound.txt delete mode 100644 common_syms/engine/sprite.txt delete mode 100644 common_syms/engine/string_util.txt delete mode 100644 common_syms/engine/task.txt delete mode 100644 common_syms/field/field_camera.txt delete mode 100644 common_syms/field/field_control_avatar.txt delete mode 100644 common_syms/field/field_map_obj.txt delete mode 100644 common_syms/field/fieldmap.txt delete mode 100644 common_syms/field/overworld.txt delete mode 100644 common_syms/field/start_menu.txt delete mode 100644 common_syms/field/tv.txt delete mode 100644 common_syms/libs/agb_flash.txt delete mode 100644 common_syms/libs/m4a_2.txt delete mode 100644 common_syms/pokemon/pokeblock_feed.txt delete mode 100644 common_syms/pokemon/pokedex.txt delete mode 100644 common_syms/pokemon/pokemon_1.txt delete mode 100644 common_syms/pokemon/pokemon_menu.txt delete mode 100644 common_syms/rom3.txt delete mode 100644 common_syms/scanline_effect.txt delete mode 100644 common_syms/scene/berry_blender.txt delete mode 100644 common_syms/scene/contest_painting.txt delete mode 100644 common_syms/scene/cute_sketch.txt delete mode 100644 common_syms/scene/egg_hatch.txt delete mode 100644 common_syms/scene/evolution_scene.txt delete mode 100644 common_syms/scene/intro.txt diff --git a/common_syms/battle/battle_anim.txt b/common_syms/battle/battle_anim.txt deleted file mode 100644 index a93ac9b5d..000000000 --- a/common_syms/battle/battle_anim.txt +++ /dev/null @@ -1,3 +0,0 @@ -gSoundAnimFramesToWait -gBattleAnimArgs -gAnimSpriteIndexArray diff --git a/common_syms/debug/mori_debug_menu.txt b/common_syms/debug/mori_debug_menu.txt deleted file mode 100644 index 77ab5531c..000000000 --- a/common_syms/debug/mori_debug_menu.txt +++ /dev/null @@ -1 +0,0 @@ -gUnknown_03004DA0 diff --git a/common_syms/debug/sound_check_menu.txt b/common_syms/debug/sound_check_menu.txt deleted file mode 100644 index e9e3032e6..000000000 --- a/common_syms/debug/sound_check_menu.txt +++ /dev/null @@ -1,2 +0,0 @@ -gUnknown_03005D30 -gSoundTestCryNum diff --git a/common_syms/engine/link.txt b/common_syms/engine/link.txt deleted file mode 100644 index faafda4d0..000000000 --- a/common_syms/engine/link.txt +++ /dev/null @@ -1,46 +0,0 @@ -word_3002910 -gLinkDebugValue1 -localLinkPlayerBlock -gLinkErrorOccurred -4 -gLinkDebugValue2 -4 -#begin GERMAN -deUnkValue1 -deUnkValue2 -#end -gLinkPlayerPending -gLinkPlayers -gBlockReceived -4 -gLinkHeldKeys -gLinkTimeOutCounter -4 -localLinkPlayer -gRecvCmds -gLinkStatus -gLinkDummyBool -byte_3002A68 -gBlockSendBuffer -u8_array_3002B70 -gLinkType -u8_array_3002B78 -gBlockRecvBuffer -gSuppressLinkErrorMessage -gSavedLinkPlayerCount -gSendCmd -gSavedMultiplayerId -gReceivedRemoteLinkPlayers -gLinkTestBGInfo -gLinkCallback -gSavedLinkPlayers -gShouldAdvanceLinkState -gLinkTestBlockChecksums -4 -gBlockRequestType -4 -4 -gLastSendQueueCount -gLink -gLastRecvQueueCount -gLinkSavedIme diff --git a/common_syms/engine/load_save.txt b/common_syms/engine/load_save.txt deleted file mode 100644 index 3b969deca..000000000 --- a/common_syms/engine/load_save.txt +++ /dev/null @@ -1 +0,0 @@ -gFlashMemoryPresent diff --git a/common_syms/engine/main.txt b/common_syms/engine/main.txt deleted file mode 100644 index a620083d1..000000000 --- a/common_syms/engine/main.txt +++ /dev/null @@ -1,9 +0,0 @@ -gKeyRepeatStartDelay -gLinkTransferringData -gMain -gKeyRepeatContinueDelay -gSoftResetDisabled -gIntrTable -gLinkVSyncDisabled -IntrMain_Buffer -gPcmDmaCounter diff --git a/common_syms/engine/random.txt b/common_syms/engine/random.txt deleted file mode 100644 index 794439ea5..000000000 --- a/common_syms/engine/random.txt +++ /dev/null @@ -1 +0,0 @@ -gRngValue diff --git a/common_syms/engine/record_mixing.txt b/common_syms/engine/record_mixing.txt deleted file mode 100644 index a6f4f8df3..000000000 --- a/common_syms/engine/record_mixing.txt +++ /dev/null @@ -1 +0,0 @@ -gUnknown_03005D2C diff --git a/common_syms/engine/rtc.txt b/common_syms/engine/rtc.txt deleted file mode 100644 index fa00a34d5..000000000 --- a/common_syms/engine/rtc.txt +++ /dev/null @@ -1 +0,0 @@ -gLocalTime diff --git a/common_syms/engine/save.txt b/common_syms/engine/save.txt deleted file mode 100644 index 4824255bf..000000000 --- a/common_syms/engine/save.txt +++ /dev/null @@ -1,9 +0,0 @@ -gFirstSaveSector -gPrevSaveCounter -gLastKnownGoodSector -gDamagedSaveSectors -gSaveCounter -gFastSaveSection -gUnknown_03005EB4 -gSaveFileStatus -gGameContinueCallback diff --git a/common_syms/engine/sound.txt b/common_syms/engine/sound.txt deleted file mode 100644 index 0f6f2fc75..000000000 --- a/common_syms/engine/sound.txt +++ /dev/null @@ -1 +0,0 @@ -gDisableMusic diff --git a/common_syms/engine/sprite.txt b/common_syms/engine/sprite.txt deleted file mode 100644 index fe38dc61f..000000000 --- a/common_syms/engine/sprite.txt +++ /dev/null @@ -1,12 +0,0 @@ -gSpriteOrder -gSpriteTileAllocBitmap -gSpriteCoordOffsetX -gOamLimit -gReservedSpriteTileCount -gSpriteCopyRequestCount -gSpriteCopyRequests -gSpriteCoordOffsetY -gOamMatrices -gShouldProcessSpriteCopyRequests -gOamMatrixAllocBitmap -gReservedSpritePaletteCount diff --git a/common_syms/engine/string_util.txt b/common_syms/engine/string_util.txt deleted file mode 100644 index 1ee62aaad..000000000 --- a/common_syms/engine/string_util.txt +++ /dev/null @@ -1 +0,0 @@ -gUnknownStringVar diff --git a/common_syms/engine/task.txt b/common_syms/engine/task.txt deleted file mode 100644 index 6601bd11b..000000000 --- a/common_syms/engine/task.txt +++ /dev/null @@ -1 +0,0 @@ -gTasks diff --git a/common_syms/field/field_camera.txt b/common_syms/field/field_camera.txt deleted file mode 100644 index 7aad967f8..000000000 --- a/common_syms/field/field_camera.txt +++ /dev/null @@ -1,3 +0,0 @@ -gUnknown_03004880 -gUnknown_03004898 -gUnknown_0300489C diff --git a/common_syms/field/field_control_avatar.txt b/common_syms/field/field_control_avatar.txt deleted file mode 100644 index 040a9e6c1..000000000 --- a/common_syms/field/field_control_avatar.txt +++ /dev/null @@ -1 +0,0 @@ -gSelectedMapObject diff --git a/common_syms/field/field_map_obj.txt b/common_syms/field/field_map_obj.txt deleted file mode 100644 index 32d8b1915..000000000 --- a/common_syms/field/field_map_obj.txt +++ /dev/null @@ -1 +0,0 @@ -gMapObjects diff --git a/common_syms/field/fieldmap.txt b/common_syms/field/fieldmap.txt deleted file mode 100644 index 7819b3b40..000000000 --- a/common_syms/field/fieldmap.txt +++ /dev/null @@ -1 +0,0 @@ -gUnknown_03004870 diff --git a/common_syms/field/overworld.txt b/common_syms/field/overworld.txt deleted file mode 100644 index ecdb190b2..000000000 --- a/common_syms/field/overworld.txt +++ /dev/null @@ -1,4 +0,0 @@ -word_3004858 -gFieldCallback -gUnknown_03004860 -gFieldLinkPlayerCount diff --git a/common_syms/field/start_menu.txt b/common_syms/field/start_menu.txt deleted file mode 100644 index 05beaf57c..000000000 --- a/common_syms/field/start_menu.txt +++ /dev/null @@ -1 +0,0 @@ -gMenuCallback diff --git a/common_syms/field/tv.txt b/common_syms/field/tv.txt deleted file mode 100644 index 829139f8f..000000000 --- a/common_syms/field/tv.txt +++ /dev/null @@ -1 +0,0 @@ -gUnknown_03005D38 diff --git a/common_syms/libs/agb_flash.txt b/common_syms/libs/agb_flash.txt deleted file mode 100644 index cb421ec80..000000000 --- a/common_syms/libs/agb_flash.txt +++ /dev/null @@ -1,10 +0,0 @@ -gFlashTimeoutFlag -PollFlashStatus -WaitForFlashWrite -ProgramFlashSector -gFlash -ProgramFlashByte -gFlashNumRemainingBytes -EraseFlashChip -EraseFlashSector -gFlashMaxTime diff --git a/common_syms/libs/m4a_2.txt b/common_syms/libs/m4a_2.txt deleted file mode 100644 index a80d8a79d..000000000 --- a/common_syms/libs/m4a_2.txt +++ /dev/null @@ -1,12 +0,0 @@ -gSoundInfo -gPokemonCrySongs -gPokemonCryMusicPlayers -gMPlayJumpTable -gCgbChans -gPokemonCryTracks -gPokemonCrySong -gMPlay_BGM -gMPlay_SE1 -gMPlay_SE2 -gMPlayMemAccArea -gMPlay_SE3 diff --git a/common_syms/pokemon/pokeblock_feed.txt b/common_syms/pokemon/pokeblock_feed.txt deleted file mode 100644 index 827e6526e..000000000 --- a/common_syms/pokemon/pokeblock_feed.txt +++ /dev/null @@ -1,12 +0,0 @@ -gPokeblockFeedPokeSprite -gPokeblockFeedMonSpecies -gPokeblockMonNotFlipped -gPokeblockFeedMonSpriteID -gPokeblockFeedMonNature -gUnknown_03005F34 -gPokeblockFeedUnused0 -gUnknown_03005F3C -gUnknown_03005F40 -gPokeblockFeedPokeSpriteCopy -gUnknown_03005F94 -gUnknown_03005FA0 diff --git a/common_syms/pokemon/pokedex.txt b/common_syms/pokemon/pokedex.txt deleted file mode 100644 index 18b14f3ed..000000000 --- a/common_syms/pokemon/pokedex.txt +++ /dev/null @@ -1,2 +0,0 @@ -gUnknown_03005CE8 -gUnknown_03005CEC diff --git a/common_syms/pokemon/pokemon_1.txt b/common_syms/pokemon/pokemon_1.txt deleted file mode 100644 index c588d53a7..000000000 --- a/common_syms/pokemon/pokemon_1.txt +++ /dev/null @@ -1,4 +0,0 @@ -gPlayerPartyCount -gPlayerParty -gEnemyPartyCount -gEnemyParty diff --git a/common_syms/pokemon/pokemon_menu.txt b/common_syms/pokemon/pokemon_menu.txt deleted file mode 100644 index 98a1bf53b..000000000 --- a/common_syms/pokemon/pokemon_menu.txt +++ /dev/null @@ -1,2 +0,0 @@ -gLastFieldPokeMenuOpened -gUnknown_03005CE4 diff --git a/common_syms/rom3.txt b/common_syms/rom3.txt deleted file mode 100644 index 06a965ff6..000000000 --- a/common_syms/rom3.txt +++ /dev/null @@ -1 +0,0 @@ -gBattleBuffersTransferData diff --git a/common_syms/scanline_effect.txt b/common_syms/scanline_effect.txt deleted file mode 100644 index 280e7f891..000000000 --- a/common_syms/scanline_effect.txt +++ /dev/null @@ -1,2 +0,0 @@ -gScanlineEffect -gScanlineEffectRegBuffers diff --git a/common_syms/scene/berry_blender.txt b/common_syms/scene/berry_blender.txt deleted file mode 100644 index 524a31411..000000000 --- a/common_syms/scene/berry_blender.txt +++ /dev/null @@ -1,4 +0,0 @@ -gUnknown_03004830 -gInGameOpponentsNo -gUnknown_03004840 -gBerryBlenderData diff --git a/common_syms/scene/contest_painting.txt b/common_syms/scene/contest_painting.txt deleted file mode 100644 index 2e8490348..000000000 --- a/common_syms/scene/contest_painting.txt +++ /dev/null @@ -1,5 +0,0 @@ -gUnknown_03005E10 -gUnknown_03005E20 -gUnknown_03005E40 -gUnknown_03005E8C -gUnknown_03005E90 diff --git a/common_syms/scene/cute_sketch.txt b/common_syms/scene/cute_sketch.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/common_syms/scene/egg_hatch.txt b/common_syms/scene/egg_hatch.txt deleted file mode 100644 index 891ccc104..000000000 --- a/common_syms/scene/egg_hatch.txt +++ /dev/null @@ -1 +0,0 @@ -gEggHatchData diff --git a/common_syms/scene/evolution_scene.txt b/common_syms/scene/evolution_scene.txt deleted file mode 100644 index 137cd3e05..000000000 --- a/common_syms/scene/evolution_scene.txt +++ /dev/null @@ -1 +0,0 @@ -gCB2_AfterEvolution diff --git a/common_syms/scene/intro.txt b/common_syms/scene/intro.txt deleted file mode 100644 index d069b1014..000000000 --- a/common_syms/scene/intro.txt +++ /dev/null @@ -1,2 +0,0 @@ -gIntroFrameCounter -gMultibootProgramStruct diff --git a/src/field/tv.c b/src/field/tv.c index efda4b925..8bd36bb9c 100644 --- a/src/field/tv.c +++ b/src/field/tv.c @@ -47,8 +47,6 @@ struct UnkTvStruct s8 var0; }; -extern u8 gUnknown_0300430A[11]; - struct OutbreakPokemon { /*0x00*/ u16 species; diff --git a/sym_common.txt b/sym_common.txt index 1a523e7cb..d8dc14812 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,614 +1,235 @@ -. = ALIGN(4); -. = ALIGN(4); -gKeyRepeatStartDelay = .; -. += 0x4; -. = ALIGN(4); -gLinkTransferringData = .; -. += 0x4; -. = ALIGN(16); -gMain = .; -. += 0x440; -. = ALIGN(4); -gKeyRepeatContinueDelay = .; -. += 0x4; -. = ALIGN(4); -gSoftResetDisabled = .; -. += 0x4; -. = ALIGN(16); -gIntrTable = .; -. += 0x38; -. = ALIGN(4); -gLinkVSyncDisabled = .; -. += 0x4; -. = ALIGN(16); -IntrMain_Buffer = .; -. += 0x800; -. = ALIGN(4); -gPcmDmaCounter = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(16); -gSpriteOrder = .; -. += 0x40; -. = ALIGN(16); -gSpriteTileAllocBitmap = .; -. += 0x80; -. = ALIGN(4); -gSpriteCoordOffsetX = .; -. += 0x4; -. = ALIGN(4); -gOamLimit = .; -. += 0x4; -. = ALIGN(4); -gReservedSpriteTileCount = .; -. += 0x4; -. = ALIGN(4); -gSpriteCopyRequestCount = .; -. += 0x4; -. = ALIGN(16); -gSpriteCopyRequests = .; -. += 0x300; -. = ALIGN(4); -gSpriteCoordOffsetY = .; -. += 0x4; -. = ALIGN(16); -gOamMatrices = .; -. += 0x100; -. = ALIGN(4); -gShouldProcessSpriteCopyRequests = .; -. += 0x4; -. = ALIGN(4); -gOamMatrixAllocBitmap = .; -. += 0x4; -. = ALIGN(4); -gReservedSpritePaletteCount = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(16); -gUnknownStringVar = .; -. += 0x10; -. = ALIGN(4); -. = ALIGN(8); -word_3002910 = .; -. += 0x8; -. = ALIGN(4); -gLinkDebugValue1 = .; -. += 0x4; -. = ALIGN(16); -localLinkPlayerBlock = .; -. += 0x3C; -. = ALIGN(4); -gLinkErrorOccurred = .; -. += 0x4; -. += 0x4; -. = ALIGN(4); -gLinkDebugValue2 = .; -. += 0x4; -. += 0x4; +#define SYMBOL(name, size) \ + . = ALIGN (((size) > 16) ? 16 : (size)); \ + . = ALIGN(4); \ + name = .; \ + . += size; -#ifdef GERMAN -. = ALIGN(4); -deUnkValue1 = .; -. += 0x4; -. = ALIGN(4); -deUnkValue2 = .; +SYMBOL(gKeyRepeatStartDelay, 4) +SYMBOL(gLinkTransferringData, 4) +SYMBOL(gMain, 1088) +SYMBOL(gKeyRepeatContinueDelay, 4) +SYMBOL(gSoftResetDisabled, 4) +SYMBOL(gIntrTable, 56) +SYMBOL(gLinkVSyncDisabled, 4) +SYMBOL(IntrMain_Buffer, 2048) +SYMBOL(gPcmDmaCounter, 4) +SYMBOL(gSpriteOrder, 64) +SYMBOL(gSpriteTileAllocBitmap, 128) +SYMBOL(gSpriteCoordOffsetX, 4) +SYMBOL(gOamLimit, 4) +SYMBOL(gReservedSpriteTileCount, 4) +SYMBOL(gSpriteCopyRequestCount, 4) +SYMBOL(gSpriteCopyRequests, 768) +SYMBOL(gSpriteCoordOffsetY, 4) +SYMBOL(gOamMatrices, 256) +SYMBOL(gShouldProcessSpriteCopyRequests, 4) +SYMBOL(gOamMatrixAllocBitmap, 4) +SYMBOL(gReservedSpritePaletteCount, 4) +SYMBOL(gUnknownStringVar, 16) +SYMBOL(word_3002910, 8) +SYMBOL(gLinkDebugValue1, 4) +SYMBOL(localLinkPlayerBlock, 60) +SYMBOL(gLinkErrorOccurred, 4) +. += 0x4; +SYMBOL(gLinkDebugValue2, 4) . += 0x4; +#ifdef GERMAN +SYMB0L(deUnkValue1, 4) +SYMB0L(deUnkValue2, 4) #endif - -. = ALIGN(4); -gLinkPlayerPending = .; -. += 0x4; -. = ALIGN(16); -gLinkPlayers = .; -. += 0x70; -. = ALIGN(4); -gBlockReceived = .; -. += 0x4; -. += 0x4; -. = ALIGN(4); -gLinkHeldKeys = .; -. += 0x4; -. = ALIGN(4); -gLinkTimeOutCounter = .; -. += 0x4; -. += 0x4; -. = ALIGN(16); -localLinkPlayer = .; -. += 0x1C; -. = ALIGN(16); -gRecvCmds = .; -. += 0x40; -. = ALIGN(4); -gLinkStatus = .; -. += 0x4; -. = ALIGN(4); -gLinkDummyBool = .; -. += 0x4; -. = ALIGN(4); -byte_3002A68 = .; -. += 0x4; -. = ALIGN(16); -gBlockSendBuffer = .; -. += 0x100; -. = ALIGN(4); -u8_array_3002B70 = .; -. += 0x4; -. = ALIGN(4); -gLinkType = .; -. += 0x4; -. = ALIGN(4); -u8_array_3002B78 = .; -. += 0x4; -. = ALIGN(16); -gBlockRecvBuffer = .; -. += 0x400; -. = ALIGN(4); -gSuppressLinkErrorMessage = .; -. += 0x4; -. = ALIGN(4); -gSavedLinkPlayerCount = .; -. += 0x4; -. = ALIGN(16); -gSendCmd = .; -. += 0x10; -. = ALIGN(4); -gSavedMultiplayerId = .; -. += 0x4; -. = ALIGN(4); -gReceivedRemoteLinkPlayers = .; -. += 0x4; -. = ALIGN(16); -gLinkTestBGInfo = .; -. += 0x10; -. = ALIGN(4); -gLinkCallback = .; -. += 0x4; -. = ALIGN(16); -gSavedLinkPlayers = .; -. += 0x70; -. = ALIGN(4); -gShouldAdvanceLinkState = .; -. += 0x4; -. = ALIGN(8); -gLinkTestBlockChecksums = .; -. += 0x8; -. += 0x4; -. = ALIGN(4); -gBlockRequestType = .; -. += 0x4; -. += 0x4; -. += 0x4; -. = ALIGN(4); -gLastSendQueueCount = .; -. += 0x4; -. = ALIGN(16); -gLink = .; -. += 0xFC0; -. = ALIGN(4); -gLastRecvQueueCount = .; -. += 0x4; -. = ALIGN(4); -gLinkSavedIme = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(8); -gLocalTime = .; +SYMBOL(gLinkPlayerPending, 4) +SYMBOL(gLinkPlayers, 112) +SYMBOL(gBlockReceived, 4) +. += 0x4; +SYMBOL(gLinkHeldKeys, 4) +SYMBOL(gLinkTimeOutCounter, 4) +. += 0x4; +SYMBOL(localLinkPlayer, 28) +SYMBOL(gRecvCmds, 64) +SYMBOL(gLinkStatus, 4) +SYMBOL(gLinkDummyBool, 4) +SYMBOL(byte_3002A68, 4) +SYMBOL(gBlockSendBuffer, 256) +SYMBOL(u8_array_3002B70, 4) +SYMBOL(gLinkType, 4) +SYMBOL(u8_array_3002B78, 4) +SYMBOL(gBlockRecvBuffer, 1024) +SYMBOL(gSuppressLinkErrorMessage, 4) +SYMBOL(gSavedLinkPlayerCount, 4) +SYMBOL(gSendCmd, 16) +SYMBOL(gSavedMultiplayerId, 4) +SYMBOL(gReceivedRemoteLinkPlayers, 4) +SYMBOL(gLinkTestBGInfo, 16) +SYMBOL(gLinkCallback, 4) +SYMBOL(gSavedLinkPlayers, 112) +SYMBOL(gShouldAdvanceLinkState, 4) +SYMBOL(gLinkTestBlockChecksums, 8) +. += 0x4; +SYMBOL(gBlockRequestType, 4) . += 0x8; -. = ALIGN(4); -. = ALIGN(16); -gBattleBuffersTransferData = .; -. += 0x170; -. = ALIGN(4); -gBattle_BG3_X = .; -. += 0x4; -gBattle_BG1_Y = .; -. += 0x4; -gBattle_BG3_Y = .; +SYMBOL(gLastSendQueueCount, 4) +SYMBOL(gLink, 4032) +SYMBOL(gLastRecvQueueCount, 4) +SYMBOL(gLinkSavedIme, 4) +SYMBOL(gLocalTime, 8) +SYMBOL(gBattleBuffersTransferData, 368) +SYMBOL(gBattle_BG3_X, 4) +SYMBOL(gBattle_BG1_Y, 4) +SYMBOL(gBattle_BG3_Y, 4) +SYMBOL(gBattleTextBuff1, 16) +SYMBOL(gUnknown_030041D0, 48) +SYMBOL(gBattle_WIN1H, 4) +SYMBOL(gUnknown_03004210, 48) +SYMBOL(gBattle_WIN0V, 4) +SYMBOL(gBattle_WIN1V, 4) +SYMBOL(gUnknown_03004250, 48) +SYMBOL(gBattle_BG2_Y, 4) +SYMBOL(gUnknown_03004284, 4) +SYMBOL(gBattle_BG2_X, 4) +SYMBOL(gBattleTerrain, 4) +SYMBOL(gBattleTextBuff2, 16) +SYMBOL(gBattle_BG0_Y, 4) +SYMBOL(gBattle_BG0_X, 4) +SYMBOL(gBattleTextBuff3, 16) +SYMBOL(gBattle_BG1_X, 4) +SYMBOL(gBattle_WIN0H, 4) . += 0x8; -gBattleTextBuff1 = .; -. += 0x10; -gUnknown_030041D0 = .; -. += 0x30; -gBattle_WIN1H = .; -. += 0x10; -gUnknown_03004210 = .; -. += 0x30; -gBattle_WIN0V = .; -. += 0x4; -gBattle_WIN1V = .; -. += 0xC; -gUnknown_03004250 = .; -. += 0x30; -gBattle_BG2_Y = .; -. += 0x4; -gUnknown_03004284 = .; -. += 0x4; -gBattle_BG2_X = .; -. += 0x4; -gBattleTerrain = .; -. += 0x4; -gBattleTextBuff2 = .; -. += 0x10; -gBattle_BG0_Y = .; -. += 0x4; -gBattle_BG0_X = .; -. += 0xC; -gBattleTextBuff3 = .; -. += 0x10; -gBattle_BG1_X = .; -. += 0x4; -gBattle_WIN0H = .; -. += 0xC; -gPreBattleCallback1 = .; -. += 0x4; +SYMBOL(gPreBattleCallback1, 4) gBattleMainFunc = .; . += 0xC; gBattleResults = .; . += 0x1C; +// Why is this not aligned? gUnknown_030042FC = .; -. += 0xE; -gUnknown_0300430A = .; -. += 0xC; +. += 0x1A; gUnknown_03004316 = .; . += 0xE; gLeveledUpInBattle = .; . += 0xC; -gBattleBankFunc = .; -. += 0x10; -gHealthboxIDs = .; -. += 0x4; -gUnknown_03004344 = .; -. += 0x4; -gUnknown_03004348 = .; -. += 0x4; -gUnknown_0300434C = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gPlayerPartyCount = .; -. += 0x4; -. = ALIGN(16); -gPlayerParty = .; -. += 0x258; -. = ALIGN(4); -gEnemyPartyCount = .; -. += 0x4; -. = ALIGN(16); -gEnemyParty = .; -. += 0x258; -. = ALIGN(4); -. = ALIGN(4); -gRngValue = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gEggHatchData = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gFlashMemoryPresent = .; -. += 0x4; -gUnknown_03004824 = .; -. += 0x4; -gUnknown_03004828 = .; -. += 0x8; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03004830 = .; -. += 0x4; -. = ALIGN(4); -gInGameOpponentsNo = .; -. += 0x4; -. = ALIGN(16); -gUnknown_03004840 = .; -. += 0x14; -. = ALIGN(4); -gBerryBlenderData = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -word_3004858 = .; -. += 0x4; -. = ALIGN(4); -gFieldCallback = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03004860 = .; -. += 0x4; -. = ALIGN(4); -gFieldLinkPlayerCount = .; -. += 0x4; -. = ALIGN(4); +SYMBOL(gBattleBankFunc, 16) +SYMBOL(gHealthboxIDs, 4) +SYMBOL(gUnknown_03004344, 4) +SYMBOL(gUnknown_03004348, 4) +SYMBOL(gUnknown_0300434C, 4) +SYMBOL(gPlayerPartyCount, 4) +SYMBOL(gPlayerParty, 600) +SYMBOL(gEnemyPartyCount, 4) +SYMBOL(gEnemyParty, 600) +SYMBOL(gRngValue, 4) +SYMBOL(gEggHatchData, 4) +SYMBOL(gFlashMemoryPresent, 4) +SYMBOL(gUnknown_03004824, 4) +SYMBOL(gUnknown_03004828, 4) +. += 0x4; +SYMBOL(gUnknown_03004830, 4) +SYMBOL(gInGameOpponentsNo, 4) +SYMBOL(gUnknown_03004840, 20) +SYMBOL(gBerryBlenderData, 4) +SYMBOL(word_3004858, 4) +SYMBOL(gFieldCallback, 4) +SYMBOL(gUnknown_03004860, 4) +SYMBOL(gFieldLinkPlayerCount, 4) . = ALIGN(16); gUnknown_03004870 = .; . += 0xC; -. = ALIGN(4); -. = ALIGN(16); -gUnknown_03004880 = .; -. += 0x18; -. = ALIGN(4); -gUnknown_03004898 = .; -. += 0x4; -. = ALIGN(4); -gUnknown_0300489C = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(16); -gMapObjects = .; -. += 0x240; -. = ALIGN(4); -. = ALIGN(4); -gSelectedMapObject = .; -. += 0x4; -. = ALIGN(4); -gPokemonItemUseCallback = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gMenuCallback = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gDisableMusic = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gSoundAnimFramesToWait = .; -. += 0x4; -. = ALIGN(16); -gBattleAnimArgs = .; -. += 0x10; -. = ALIGN(16); -gAnimSpriteIndexArray = .; -. += 0x10; -. = ALIGN(4); -. = ALIGN(16); -gTasks = .; -. += 0x280; -. = ALIGN(4); -. = ALIGN(16); -gUnknown_03004DA0 = .; -. += 0x20; -. = ALIGN(4); -. = ALIGN(16); -gScanlineEffect = .; -. += 0x20; -. = ALIGN(16); -gScanlineEffectRegBuffers = .; -. += 0xF00; -. = ALIGN(4); -. = ALIGN(4); -gLastFieldPokeMenuOpened = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005CE4 = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03005CE8 = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005CEC = .; -. += 0x4; -. = ALIGN(16); -gUnknown_03005CF0 = .; -. += 0x10; +SYMBOL(gUnknown_03004880, 24) +SYMBOL(gUnknown_03004898, 4) +SYMBOL(gUnknown_0300489C, 4) +SYMBOL(gMapObjects, 576) +SYMBOL(gSelectedMapObject, 4) +SYMBOL(gPokemonItemUseCallback, 4) +SYMBOL(gMenuCallback, 4) +SYMBOL(gDisableMusic, 4) +SYMBOL(gSoundAnimFramesToWait, 4) +SYMBOL(gBattleAnimArgs, 16) +SYMBOL(gAnimSpriteIndexArray, 16) +SYMBOL(gTasks, 640) +SYMBOL(gUnknown_03004DA0, 32) +SYMBOL(gScanlineEffect, 32) +SYMBOL(gScanlineEffectRegBuffers, 3840) +SYMBOL(gLastFieldPokeMenuOpened, 4) +SYMBOL(gUnknown_03005CE4, 4) +SYMBOL(gUnknown_03005CE8, 4) +SYMBOL(gUnknown_03005CEC, 4) +SYMBOL(gUnknown_03005CF0, 4) +// huh? . = ALIGN(16); gFieldItemUseCallback = .; . += 0x10; gBagPocketScrollStates = .; . += 0x14; -gCurrentBagPocketItemSlots = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005D28 = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03005D2C = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03005D30 = .; -. += 0x4; -. = ALIGN(4); -gSoundTestCryNum = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03005D38 = .; -. += 0x4; -. += 0x64; -. = ALIGN(16); -gUnknown_03005DA0 = .; -. += 0x48; -gUnknown_03005DE8 = .; -. += 0x4; -gUnknown_03005DEC = .; -. += 0x4; -gUnknown_03005DF0 = .; -. += 0x4; -gUnknown_03005DF4 = .; -. += 0x4; -gUnknown_03005DF8 = .; -. += 0x4; -gUnknown_03005DFC = .; -. += 0x4; -gUnknown_03005E00 = .; -. += 0x4; -gUnknown_03005E04 = .; -. += 0x4; -gUnknown_03005E08 = .; -. += 0x4; -gUnknown_03005E0C = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gUnknown_03005E10 = .; -. += 0x4; -. = ALIGN(16); -gUnknown_03005E20 = .; -. += 0x20; -. = ALIGN(16); -gUnknown_03005E40 = .; -. += 0x4C; -. = ALIGN(4); -gUnknown_03005E8C = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005E90 = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gCB2_AfterEvolution = .; -. += 0x4; -gUnknown_03005E98 = .; -. += 0x4; -. = ALIGN(4); -. = ALIGN(4); -gFirstSaveSector = .; -. += 0x4; -. = ALIGN(4); -gPrevSaveCounter = .; -. += 0x4; -. = ALIGN(4); -gLastKnownGoodSector = .; -. += 0x4; -. = ALIGN(4); -gDamagedSaveSectors = .; -. += 0x4; -. = ALIGN(4); -gSaveCounter = .; -. += 0x4; -. = ALIGN(4); -gFastSaveSection = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005EB4 = .; -. += 0x4; -. = ALIGN(4); -gSaveFileStatus = .; -. += 0x4; -. = ALIGN(4); -gGameContinueCallback = .; -. += 0x4; +SYMBOL(gCurrentBagPocketItemSlots, 4) +SYMBOL(gUnknown_03005D28, 4) +SYMBOL(gUnknown_03005D2C, 4) +SYMBOL(gUnknown_03005D30, 4) +SYMBOL(gSoundTestCryNum, 4) +SYMBOL(gUnknown_03005D38, 4) +. += 0x64; // huge gap? +SYMBOL(gUnknown_03005DA0, 0x48) +SYMBOL(gUnknown_03005DE8, 4) +SYMBOL(gUnknown_03005DEC, 4) +SYMBOL(gUnknown_03005DF0, 4) +SYMBOL(gUnknown_03005DF4, 4) +SYMBOL(gUnknown_03005DF8, 4) +SYMBOL(gUnknown_03005DFC, 4) +SYMBOL(gUnknown_03005E00, 4) +SYMBOL(gUnknown_03005E04, 4) +SYMBOL(gUnknown_03005E08, 4) +SYMBOL(gUnknown_03005E0C, 4) +SYMBOL(gUnknown_03005E10, 4) +SYMBOL(gUnknown_03005E20, 32) +SYMBOL(gUnknown_03005E40, 76) +SYMBOL(gUnknown_03005E8C, 4) +SYMBOL(gUnknown_03005E90, 4) +SYMBOL(gCB2_AfterEvolution, 4) +SYMBOL(gUnknown_03005E98, 4) +SYMBOL(gFirstSaveSector, 4) +SYMBOL(gPrevSaveCounter, 4) +SYMBOL(gLastKnownGoodSector, 4) +SYMBOL(gDamagedSaveSectors, 4) +SYMBOL(gSaveCounter, 4) +SYMBOL(gFastSaveSection, 4) +SYMBOL(gUnknown_03005EB4, 4) +SYMBOL(gSaveFileStatus, 4) +SYMBOL(gGameContinueCallback, 4) . += 0x10; -. = ALIGN(4); -. = ALIGN(4); -gIntroFrameCounter = .; -. += 0x4; -. = ALIGN(16); -gMultibootProgramStruct = .; -. += 0x2C; -. = ALIGN(4); -gUnknown_03005F0C = .; -. += 0x4; -gUnknown_03005F10 = .; -. += 0x4; +SYMBOL(gIntroFrameCounter, 4) +SYMBOL(gMultibootProgramStruct, 44) +SYMBOL(gUnknown_03005F0C, 4) +SYMBOL(gUnknown_03005F10, 4) gUnknown_03005F14 = .; . += 0xC; -. = ALIGN(4); -. = ALIGN(4); -gPokeblockFeedPokeSprite = .; -. += 0x4; -. = ALIGN(4); -gPokeblockFeedMonSpecies = .; -. += 0x4; -. = ALIGN(4); -gPokeblockMonNotFlipped = .; -. += 0x4; -. = ALIGN(4); -gPokeblockFeedMonSpriteID = .; -. += 0x4; -. = ALIGN(4); -gPokeblockFeedMonNature = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005F34 = .; -. += 0x4; -. = ALIGN(4); -gPokeblockFeedUnused0 = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005F3C = .; -. += 0x4; -. = ALIGN(4); -gUnknown_03005F40 = .; -. += 0x4; -. = ALIGN(16); -gPokeblockFeedPokeSpriteCopy = .; -. += 0x44; -. = ALIGN(4); -gUnknown_03005F94 = .; -. += 0x4; -. = ALIGN(16); -gUnknown_03005FA0 = .; -. += 0x30; -. = ALIGN(4); -. = ALIGN(16); -gSoundInfo = .; -. += 0xFB0; -. = ALIGN(16); -gPokemonCrySongs = .; -. += 0x68; -. = ALIGN(16); -gPokemonCryMusicPlayers = .; -. += 0x80; -. = ALIGN(16); -gMPlayJumpTable = .; -. += 0x90; -. = ALIGN(16); -gCgbChans = .; -. += 0x100; -. = ALIGN(16); -gPokemonCryTracks = .; -. += 0x140; -. = ALIGN(16); -gPokemonCrySong = .; -. += 0x34; -. = ALIGN(16); -gMPlay_BGM = .; -. += 0x40; -. = ALIGN(16); -gMPlay_SE1 = .; -. += 0x40; -. = ALIGN(16); -gMPlay_SE2 = .; -. += 0x40; -. = ALIGN(16); -gMPlayMemAccArea = .; -. += 0x10; -. = ALIGN(16); -gMPlay_SE3 = .; -. += 0x40; -. = ALIGN(4); -. = ALIGN(4); -gFlashTimeoutFlag = .; -. += 0x4; -. = ALIGN(4); -PollFlashStatus = .; -. += 0x4; -. = ALIGN(4); -WaitForFlashWrite = .; -. += 0x4; -. = ALIGN(4); -ProgramFlashSector = .; -. += 0x4; -. = ALIGN(4); -gFlash = .; -. += 0x4; -. = ALIGN(4); -ProgramFlashByte = .; -. += 0x4; -. = ALIGN(4); -gFlashNumRemainingBytes = .; -. += 0x4; -. = ALIGN(4); -EraseFlashChip = .; -. += 0x4; -. = ALIGN(4); -EraseFlashSector = .; -. += 0x4; -. = ALIGN(4); -gFlashMaxTime = .; -. += 0x4; +SYMBOL(gPokeblockFeedPokeSprite, 4) +SYMBOL(gPokeblockFeedMonSpecies, 4) +SYMBOL(gPokeblockMonNotFlipped, 4) +SYMBOL(gPokeblockFeedMonSpriteID, 4) +SYMBOL(gPokeblockFeedMonNature, 4) +SYMBOL(gUnknown_03005F34, 4) +SYMBOL(gPokeblockFeedUnused0, 4) +SYMBOL(gUnknown_03005F3C, 4) +SYMBOL(gUnknown_03005F40, 4) +SYMBOL(gPokeblockFeedPokeSpriteCopy, 68) +SYMBOL(gUnknown_03005F94, 4) +SYMBOL(gUnknown_03005FA0, 48) +SYMBOL(gSoundInfo, 4016) +SYMBOL(gPokemonCrySongs, 104) +SYMBOL(gPokemonCryMusicPlayers, 128) +SYMBOL(gMPlayJumpTable, 144) +SYMBOL(gCgbChans, 256) +SYMBOL(gPokemonCryTracks, 320) +SYMBOL(gPokemonCrySong, 52) +SYMBOL(gMPlay_BGM, 64) +SYMBOL(gMPlay_SE1, 64) +SYMBOL(gMPlay_SE2, 64) +SYMBOL(gMPlayMemAccArea, 16) +SYMBOL(gMPlay_SE3, 64) +SYMBOL(gFlashTimeoutFlag, 4) +SYMBOL(PollFlashStatus, 4) +SYMBOL(WaitForFlashWrite, 4) +SYMBOL(ProgramFlashSector, 4) +SYMBOL(gFlash, 4) +SYMBOL(ProgramFlashByte, 4) +SYMBOL(gFlashNumRemainingBytes, 4) +SYMBOL(EraseFlashChip, 4) +SYMBOL(EraseFlashSector, 4) +SYMBOL(gFlashMaxTime, 4) -- cgit v1.2.3 From 144e48af989692cd4012d9100b748b9cc1627d68 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sat, 20 Jan 2018 23:30:42 -0600 Subject: fix typo --- sym_common.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sym_common.txt b/sym_common.txt index d8dc14812..2c390e214 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -34,8 +34,8 @@ SYMBOL(gLinkErrorOccurred, 4) SYMBOL(gLinkDebugValue2, 4) . += 0x4; #ifdef GERMAN -SYMB0L(deUnkValue1, 4) -SYMB0L(deUnkValue2, 4) +SYMBOL(deUnkValue1, 4) +SYMBOL(deUnkValue2, 4) #endif SYMBOL(gLinkPlayerPending, 4) SYMBOL(gLinkPlayers, 112) -- cgit v1.2.3 From 16f378cb66cbf5c0e4ef144357fe6601db4ac731 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 21 Jan 2018 01:29:33 -0600 Subject: don't generate ld scripts --- Makefile | 10 +- ld_script.sed | 4 - ld_script.txt | 4 +- sym_bss.txt | 84 +++---- sym_ewram.txt | 726 +++++++++++++++++++++++++++++----------------------------- 5 files changed, 410 insertions(+), 418 deletions(-) delete mode 100644 ld_script.sed diff --git a/Makefile b/Makefile index 7718ee523..83f37d8b7 100644 --- a/Makefile +++ b/Makefile @@ -109,16 +109,12 @@ tidy: $(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@ %.elf: $(LD_SCRIPT) $(ALL_OBJECTS) - cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) -o ../../$@ ../../$(LIBGCC) ../../$(LIBC) + cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) ../../$(LIBGCC) ../../$(LIBC) -o ../../$@ -$(LD_SCRIPT): $(BUILD_DIR)/sym_bss.ld $(BUILD_DIR)/sym_common.ld $(BUILD_DIR)/sym_ewram.ld ld_script.txt - cd $(BUILD_DIR) && sed -f ../../ld_script.sed ../../ld_script.txt | sed "s#tools/#../../tools/#g" >ld_script.ld -$(BUILD_DIR)/sym_bss.ld: sym_bss.txt - cd $(BUILD_DIR) && ../../$(RAMSCRGEN) .bss ../../sym_bss.txt $(GAME_LANGUAGE) >sym_bss.ld +$(LD_SCRIPT): $(BUILD_DIR)/sym_common.ld ld_script.txt + cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld $(BUILD_DIR)/sym_common.ld: sym_common.txt $(CPP) -P $(CPPFLAGS) $< > $@ -$(BUILD_DIR)/sym_ewram.ld: sym_ewram.txt - cd $(BUILD_DIR) && ../../$(RAMSCRGEN) ewram_data ../../sym_ewram.txt $(GAME_LANGUAGE) >sym_ewram.ld $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) $(CPP) $(CPPFLAGS) $< -o $(BUILD_DIR)/$*.i diff --git a/ld_script.sed b/ld_script.sed deleted file mode 100644 index 76b18c301..000000000 --- a/ld_script.sed +++ /dev/null @@ -1,4 +0,0 @@ -// { - r sym_bss.ld - d -} diff --git a/ld_script.txt b/ld_script.txt index 18de179bc..6931eb661 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -9,7 +9,7 @@ SECTIONS { ewram (NOLOAD) : ALIGN(4) { - INCLUDE "sym_ewram.ld" + INCLUDE "../../sym_ewram.txt" . = 0x40000; } @@ -20,7 +20,7 @@ SECTIONS { ALIGN(4) { /* .bss starts at 0x3000000 */ - + INCLUDE "../../sym_bss.txt" /* .bss.code starts at 0x3000F60 */ src/libs/m4a_2.o(.bss.code); diff --git a/sym_bss.txt b/sym_bss.txt index 6e95a609f..f36785ce8 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -1,42 +1,42 @@ - .include "src/engine/main.o" - .include "src/engine/sprite.o" - .include "src/engine/text.o" - .include "src/engine/string_util.o" - .include "src/engine/link.o" - .include "src/engine/rtc.o" - .include "src/field/daycare.o" - .include "src/engine/trade.o" - .include "src/scene/berry_blender.o" - .include "src/engine/play_time.o" - .include "src/field/overworld.o" - .include "src/field/field_camera.o" - .include "src/field/field_map_obj.o" - .include "src/field/field_message_box.o" - .include "src/engine/text_window.o" - .include "src/engine/script.o" - .include "src/field/start_menu.o" - .include "src/engine/menu.o" - .include "src/engine/tileset_anim.o" - .include "src/engine/sound.o" - .include "src/field/field_weather.o" - .include "src/field/field_effect.o" - .include "src/field/item_menu.o" - .include "src/field/shop.o" - .include "src/engine/record_mixing.o" - .include "src/field/tv.o" - .include "src/battle/battle_anim_80CA710.o" - .include "src/easy_chat_2.o" - .include "src/pokenav_before.o" - .include "src/field/mauville_man.o" - .include "src/field/menu_helpers.o" - .include "src/scene/contest_painting.o" - .include "src/field/pokeblock.o" - .include "src/field/field_specials.o" - .include "src/pokemon/learn_move.o" - .include "src/field/player_pc.o" - .include "src/libs/m4a_1.o" - .include "src/libs/agb_flash.o" - .include "src/libs/siirtc.o" - .include "tools/agbcc/lib/libgcc.a:dp-bit.o" - .include "tools/agbcc/lib/libgcc.a:fp-bit.o" - .include "tools/agbcc/lib/libc.a:syscalls.o" +. = ALIGN(4); src/engine/main.o(.bss); +. = ALIGN(4); src/engine/sprite.o(.bss); +. = ALIGN(4); src/engine/text.o(.bss); +. = ALIGN(4); src/engine/string_util.o(.bss); +. = ALIGN(4); src/engine/link.o(.bss); +. = ALIGN(4); src/engine/rtc.o(.bss); +. = ALIGN(4); src/field/daycare.o(.bss); +. = ALIGN(4); src/engine/trade.o(.bss); +. = ALIGN(4); src/scene/berry_blender.o(.bss); +. = ALIGN(4); src/engine/play_time.o(.bss); +. = ALIGN(4); src/field/overworld.o(.bss); +. = ALIGN(4); src/field/field_camera.o(.bss); +. = ALIGN(4); src/field/field_map_obj.o(.bss); +. = ALIGN(4); src/field/field_message_box.o(.bss); +. = ALIGN(4); src/engine/text_window.o(.bss); +. = ALIGN(4); src/engine/script.o(.bss); +. = ALIGN(4); src/field/start_menu.o(.bss); +. = ALIGN(4); src/engine/menu.o(.bss); +. = ALIGN(4); src/engine/tileset_anim.o(.bss); +. = ALIGN(4); src/engine/sound.o(.bss); +. = ALIGN(4); src/field/field_weather.o(.bss); +. = ALIGN(4); src/field/field_effect.o(.bss); +. = ALIGN(4); src/field/item_menu.o(.bss); +. = ALIGN(4); src/field/shop.o(.bss); +. = ALIGN(4); src/engine/record_mixing.o(.bss); +. = ALIGN(4); src/field/tv.o(.bss); +. = ALIGN(4); src/battle/battle_anim_80CA710.o(.bss); +. = ALIGN(4); src/easy_chat_2.o(.bss); +. = ALIGN(4); src/pokenav_before.o(.bss); +. = ALIGN(4); src/field/mauville_man.o(.bss); +. = ALIGN(4); src/field/menu_helpers.o(.bss); +. = ALIGN(4); src/scene/contest_painting.o(.bss); +. = ALIGN(4); src/field/pokeblock.o(.bss); +. = ALIGN(4); src/field/field_specials.o(.bss); +. = ALIGN(4); src/pokemon/learn_move.o(.bss); +. = ALIGN(4); src/field/player_pc.o(.bss); +. = ALIGN(4); src/libs/m4a_1.o(.bss); +. = ALIGN(4); src/libs/agb_flash.o(.bss); +. = ALIGN(4); src/libs/siirtc.o(.bss); +. = ALIGN(4); ../../tools/agbcc/lib/libgcc.a:dp-bit.o(.bss); +. = ALIGN(4); ../../tools/agbcc/lib/libgcc.a:fp-bit.o(.bss); +. = ALIGN(4); ../../tools/agbcc/lib/libc.a:syscalls.o(.bss); diff --git a/sym_ewram.txt b/sym_ewram.txt index d2fd0aabe..f6b4852a8 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,471 +1,471 @@ - .include "src/engine/main.o" - .include "src/engine/sprite.o" - .include "src/engine/text.o" - .include "src/engine/string_util.o" +. = ALIGN(4); src/engine/main.o(ewram_data); +. = ALIGN(4); src/engine/sprite.o(ewram_data); +. = ALIGN(4); src/engine/text.o(ewram_data); +. = ALIGN(4); src/engine/string_util.o(ewram_data); - .space 0x2E8 +. += 0x2E8; - .include "src/engine/link.o" - .include "src/rom3.o" +. = ALIGN(4); src/engine/link.o(ewram_data); +. = ALIGN(4); src/rom3.o(ewram_data); -@ battle +/* battle */ - .align 2 -gUnknown_020238C8: @ 20238C8 - .space 0x4 + . = ALIGN(4); +gUnknown_020238C8 = .; /* 20238C8 */ + . += 0x4; -gDisplayedStringBattle: @ 20238CC - .space 0x12C +gDisplayedStringBattle = .; /* 20238CC */ + . += 0x12C; -gBattleTypeFlags: @ 20239F8 - .space 0x4 +gBattleTypeFlags = .; /* 20239F8 */ + . += 0x4; -gUnknown_020239FC: @ 20239FC - .space 0x4 +gUnknown_020239FC = .; /* 20239FC */ + . += 0x4; -gUnknown_02023A00: @ 2023A00 - .space 0x4 +gUnknown_02023A00 = .; /* 2023A00 */ + . += 0x4; -gUnknown_02023A04: @ 2023A04 - .space 0x10 +gUnknown_02023A04 = .; /* 2023A04 */ + . += 0x10; -gUnknown_02023A14: @ 2023A14 - .space 0x4C +gUnknown_02023A14 = .; /* 2023A14 */ + . += 0x4C; -gBattleBufferA: @ 2023A60 - .space 0x2 +gBattleBufferA = .; /* 2023A60 */ + . += 0x2; -gUnknown_02023A62: @ 2023A62 - .space 0x1 +gUnknown_02023A62 = .; /* 2023A62 */ + . += 0x1; -gUnknown_02023A63: @ 2023A63 - .space 0x1 +gUnknown_02023A63 = .; /* 2023A63 */ + . += 0x1; -gUnknown_02023A64: @ 2023A64 - .space 0x7FC +gUnknown_02023A64 = .; /* 2023A64 */ + . += 0x7FC; -gBattleBufferB: @ 2024260 - .space 0x4 +gBattleBufferB = .; /* 2024260 */ + . += 0x4; -gUnknown_02024264: @ 2024264 - .space 0x7FC +gUnknown_02024264 = .; /* 2024264 */ + . += 0x7FC; -gActiveBank: @ 2024A60 - .space 0x4 +gActiveBank = .; /* 2024A60 */ + . += 0x4; -gBattleExecBuffer: @ 2024A64 - .space 0x4 +gBattleExecBuffer = .; /* 2024A64 */ + . += 0x4; -gNoOfAllBanks: @ 2024A68 - .space 0x2 +gNoOfAllBanks = .; /* 2024A68 */ + . += 0x2; -gBattlePartyID: @ 2024A6A - .space 0x8 +gBattlePartyID = .; /* 2024A6A */ + . += 0x8; -gBanksBySide: @ 2024A72 - .space 0x4 +gBanksBySide = .; /* 2024A72 */ + . += 0x4; -gActionsByTurnOrder: @ 2024A76 - .space 0x4 +gActionsByTurnOrder = .; /* 2024A76 */ + . += 0x4; -gBanksByTurnOrder: @ 2024A7A - .space 0x4 +gBanksByTurnOrder = .; /* 2024A7A */ + . += 0x4; -gCurrentTurnActionNumber: @ 2024A7E - .space 0x1 +gCurrentTurnActionNumber = .; /* 2024A7E */ + . += 0x1; -gCurrentActionFuncId: @ 2024A7F - .space 0x1 +gCurrentActionFuncId = .; /* 2024A7F */ + . += 0x1; -gBattleMons: @ 2024A80 - .space 0xC +gBattleMons = .; /* 2024A80 */ + . += 0xC; -gUnknown_02024A8C: @ 2024A8C - .space 0xC +gUnknown_02024A8C = .; /* 2024A8C */ + . += 0xC; -gUnknown_02024A98: @ 2024A98 - .space 0xC +gUnknown_02024A98 = .; /* 2024A98 */ + . += 0xC; -gUnknown_02024AA4: @ 2024AA4 - .space 0x4 +gUnknown_02024AA4 = .; /* 2024AA4 */ + . += 0x4; -gUnknown_02024AA8: @ 2024AA8 - .space 0x24 +gUnknown_02024AA8 = .; /* 2024AA8 */ + . += 0x24; -gUnknown_02024ACC: @ 2024ACC - .space 0x4 +gUnknown_02024ACC = .; /* 2024ACC */ + . += 0x4; -gUnknown_02024AD0: @ 2024AD0 - .space 0x110 +gUnknown_02024AD0 = .; /* 2024AD0 */ + . += 0x110; -gObjectBankIDs: @ 2024BE0 - .space 0x4 +gObjectBankIDs = .; /* 2024BE0 */ + . += 0x4; -gCurrMovePos: @ 2024BE4 - .space 0x1 +gCurrMovePos = .; /* 2024BE4 */ + . += 0x1; -gUnknown_02024BE5: @ 2024BE5 - .space 0x1 +gUnknown_02024BE5 = .; /* 2024BE5 */ + . += 0x1; -gCurrentMove: @ 2024BE6 - .space 0x2 +gCurrentMove = .; /* 2024BE6 */ + . += 0x2; -gChosenMove: @ 2024BE8 - .space 0x2 +gChosenMove = .; /* 2024BE8 */ + . += 0x2; -gRandomMove: @ 2024BEA - .space 0x2 +gRandomMove = .; /* 2024BEA */ + . += 0x2; -gBattleMoveDamage: @ 2024BEC - .space 0x4 +gBattleMoveDamage = .; /* 2024BEC */ + . += 0x4; -gHpDealt: @ 2024BF0 - .space 0x4 +gHpDealt = .; /* 2024BF0 */ + . += 0x4; -gTakenDmg: @ 2024BF4 - .space 0x10 +gTakenDmg = .; /* 2024BF4 */ + . += 0x10; -gLastUsedItem: @ 2024C04 - .space 0x2 +gLastUsedItem = .; /* 2024C04 */ + . += 0x2; -gLastUsedAbility: @ 2024C06 - .space 0x1 +gLastUsedAbility = .; /* 2024C06 */ + . += 0x1; -gBankAttacker: @ 2024C07 - .space 0x1 +gBankAttacker = .; /* 2024C07 */ + . += 0x1; -gBankTarget: @ 2024C08 - .space 0x1 +gBankTarget = .; /* 2024C08 */ + . += 0x1; -gBank1: @ 2024C09 - .space 0x1 +gBank1 = .; /* 2024C09 */ + . += 0x1; -gEffectBank: @ 2024C0A - .space 0x1 +gEffectBank = .; /* 2024C0A */ + . += 0x1; -gStringBank: @ 2024C0B - .space 0x1 +gStringBank = .; /* 2024C0B */ + . += 0x1; -gAbsentBankFlags: @ 2024C0C - .space 0x1 +gAbsentBankFlags = .; /* 2024C0C */ + . += 0x1; -gCritMultiplier: @ 2024C0D - .space 0x1 +gCritMultiplier = .; /* 2024C0D */ + . += 0x1; -gMultiHitCounter: @ 2024C0E - .space 0x2 +gMultiHitCounter = .; /* 2024C0E */ + . += 0x2; -gBattlescriptCurrInstr: @ 2024C10 - .space 0x8 +gBattlescriptCurrInstr = .; /* 2024C10 */ + . += 0x8; -gActionForBanks: @ 2024C18 - .space 0x4 +gActionForBanks = .; /* 2024C18 */ + . += 0x4; -gUnknown_02024C1C: @ 2024C1C - .space 0x10 +gUnknown_02024C1C = .; /* 2024C1C */ + . += 0x10; -gUnknown_02024C2C: @ 2024C2C - .space 0x8 +gUnknown_02024C2C = .; /* 2024C2C */ + . += 0x8; -gLastUsedMove: @ 2024C34 - .space 0x8 +gLastUsedMove = .; /* 2024C34 */ + . += 0x8; -gLastLandedMoves: @ 2024C3C - .space 0x8 +gLastLandedMoves = .; /* 2024C3C */ + . += 0x8; -gLastHitByType: @ 2024C44 - .space 0x8 +gLastHitByType = .; /* 2024C44 */ + . += 0x8; -gUnknown_02024C4C: @ 2024C4C - .space 0x8 +gUnknown_02024C4C = .; /* 2024C4C */ + . += 0x8; -gLockedMoves: @ 2024C54 - .space 0x8 +gLockedMoves = .; /* 2024C54 */ + . += 0x8; -gUnknown_02024C5C: @ 2024C5C - .space 0x4 +gUnknown_02024C5C = .; /* 2024C5C */ + . += 0x4; -gChosenMovesByBanks: @ 2024C60 - .space 0x8 +gChosenMovesByBanks = .; /* 2024C60 */ + . += 0x8; -gBattleMoveFlags: @ 2024C68 - .space 0x4 +gBattleMoveFlags = .; /* 2024C68 */ + . += 0x4; -gHitMarker: @ 2024C6C - .space 0x4 +gHitMarker = .; /* 2024C6C */ + . += 0x4; -gUnknown_02024C70: @ 2024C70 - .space 0x4 +gUnknown_02024C70 = .; /* 2024C70 */ + . += 0x4; -gTakenDmgBanks: @ 2024C74 - .space 0x4 +gTakenDmgBanks = .; /* 2024C74 */ + . += 0x4; -gUnknown_02024C78: @ 2024C78 - .space 0x2 +gUnknown_02024C78 = .; /* 2024C78 */ + . += 0x2; -gSideAffecting: @ 2024C7A - .space 0x6 +gSideAffecting = .; /* 2024C7A */ + . += 0x6; -gSideTimers: @ 2024C80 - .space 0x18 +gSideTimers = .; /* 2024C80 */ + . += 0x18; -gStatuses3: @ 2024C98 - .space 0x10 +gStatuses3 = .; /* 2024C98 */ + . += 0x10; -gDisableStructs: @ 2024CA8 - .space 0x70 +gDisableStructs = .; /* 2024CA8 */ + . += 0x70; -gPauseCounterBattle: @ 2024D18 - .space 0x2 +gPauseCounterBattle = .; /* 2024D18 */ + . += 0x2; -gPaydayMoney: @ 2024D1A - .space 0x2 +gPaydayMoney = .; /* 2024D1A */ + . += 0x2; -gRandomTurnNumber: @ 2024D1C - .space 0x2 +gRandomTurnNumber = .; /* 2024D1C */ + . += 0x2; -gBattleCommunication: @ 2024D1E - .space 0x1 +gBattleCommunication = .; /* 2024D1E */ + . += 0x1; -gUnknown_02024D1F: @ 2024D1F - .space 0x7 +gUnknown_02024D1F = .; /* 2024D1F */ + . += 0x7; -gBattleOutcome: @ 2024D26 - .space 0x2 +gBattleOutcome = .; /* 2024D26 */ + . += 0x2; -gProtectStructs: @ 2024D28 - .space 0x40 +gProtectStructs = .; /* 2024D28 */ + . += 0x40; -gSpecialStatuses: @ 2024D68 - .space 0x50 +gSpecialStatuses = .; /* 2024D68 */ + . += 0x50; -gBattleWeather: @ 2024DB8 - .space 0x4 +gBattleWeather = .; /* 2024DB8 */ + . += 0x4; -gWishFutureKnock: @ 2024DBC - .space 0x20 +gWishFutureKnock = .; /* 2024DBC */ + . += 0x20; -gUnknown_02024DDC: @ 2024DDC - .space 0xC +gUnknown_02024DDC = .; /* 2024DDC */ + . += 0xC; -gUnknown_02024DE8: @ 2024DE8 - .space 0x2 +gUnknown_02024DE8 = .; /* 2024DE8 */ + . += 0x2; -gSentPokesToOpponent: @ 2024DEA - .space 0x2 +gSentPokesToOpponent = .; /* 2024DEA */ + . += 0x2; -gDynamicBasePower: @ 2024DEC - .space 0x2 +gDynamicBasePower = .; /* 2024DEC */ + . += 0x2; -gExpShareExp: @ 2024DEE - .space 0x2 +gExpShareExp = .; /* 2024DEE */ + . += 0x2; -gEnigmaBerries: @ 2024DF0 - .space 0x8 +gEnigmaBerries = .; /* 2024DF0 */ + . += 0x8; -gUnknown_02024DF8: @ 2024DF8 - .space 0x68 +gUnknown_02024DF8 = .; /* 2024DF8 */ + . += 0x68; -gActionSelectionCursor: @ 2024E60 - .space 0x4 +gActionSelectionCursor = .; /* 2024E60 */ + . += 0x4; -gMoveSelectionCursor: @ 2024E64 - .space 0x4 +gMoveSelectionCursor = .; /* 2024E64 */ + . += 0x4; -gUnknown_02024E68: @ 2024E68 - .space 0x4 +gUnknown_02024E68 = .; /* 2024E68 */ + . += 0x4; -gBankInMenu: @ 2024E6C - .space 0x1 +gBankInMenu = .; /* 2024E6C */ + . += 0x1; -gDoingBattleAnim: @ 2024E6D - .space 0x3 +gDoingBattleAnim = .; /* 2024E6D */ + . += 0x3; -gTransformedPersonalities: @ 2024E70 - .space 0x10 +gTransformedPersonalities = .; /* 2024E70 */ + . += 0x10; -gBattleMovePower: @ 2024E80 - .space 0x2 +gBattleMovePower = .; /* 2024E80 */ + . += 0x2; -gMoveToLearn: @ 2024E82 - .space 0x2 +gMoveToLearn = .; /* 2024E82 */ + . += 0x2; -gBattleMonForms: @ 2024E84 - .space 0x4 +gBattleMonForms = .; /* 2024E84 */ + . += 0x4; - .include "src/pokemon/pokemon_1.o" - .include "src/pokemon/pokemon_2.o" - .include "src/engine/load_save.o" - .include "src/engine/trade.o" - .include "src/scene/berry_blender.o" - .include "src/scene/new_game.o" - .include "src/field/overworld.o" - .include "src/field/fieldmap.o" - .include "src/field/field_camera.o" - .include "src/field/field_player_avatar.o" - .include "src/field/field_message_box.o" - .include "src/engine/script.o" - .include "src/field/scrcmd.o" - .include "src/field/field_control_avatar.o" - .include "src/field/event_data.o" - .include "src/field/party_menu.o" - .include "src/field/start_menu.o" - .include "src/engine/menu.o" - .include "src/engine/tileset_anim.o" - .include "src/engine/palette.o" - .include "src/engine/sound.o" - .include "src/battle/battle_anim.o" - .include "src/rom_8077ABC.o" - .include "src/scene/title_screen.o" - .include "src/field/field_weather.o" - .include "src/battle/battle_setup.o" - .include "src/field/wild_encounter.o" - .include "src/field/field_effect.o" - .include "src/scanline_effect.o" - .include "src/pokemon/pokemon_menu.o" - .include "src/pokemon/pokedex.o" - .include "src/engine/trainer_card.o" - .include "src/pokemon/pokemon_storage_system.o" +. = ALIGN(4); src/pokemon/pokemon_1.o(ewram_data); +. = ALIGN(4); src/pokemon/pokemon_2.o(ewram_data); +. = ALIGN(4); src/engine/load_save.o(ewram_data); +. = ALIGN(4); src/engine/trade.o(ewram_data); +. = ALIGN(4); src/scene/berry_blender.o(ewram_data); +. = ALIGN(4); src/scene/new_game.o(ewram_data); +. = ALIGN(4); src/field/overworld.o(ewram_data); +. = ALIGN(4); src/field/fieldmap.o(ewram_data); +. = ALIGN(4); src/field/field_camera.o(ewram_data); +. = ALIGN(4); src/field/field_player_avatar.o(ewram_data); +. = ALIGN(4); src/field/field_message_box.o(ewram_data); +. = ALIGN(4); src/engine/script.o(ewram_data); +. = ALIGN(4); src/field/scrcmd.o(ewram_data); +. = ALIGN(4); src/field/field_control_avatar.o(ewram_data); +. = ALIGN(4); src/field/event_data.o(ewram_data); +. = ALIGN(4); src/field/party_menu.o(ewram_data); +. = ALIGN(4); src/field/start_menu.o(ewram_data); +. = ALIGN(4); src/engine/menu.o(ewram_data); +. = ALIGN(4); src/engine/tileset_anim.o(ewram_data); +. = ALIGN(4); src/engine/palette.o(ewram_data); +. = ALIGN(4); src/engine/sound.o(ewram_data); +. = ALIGN(4); src/battle/battle_anim.o(ewram_data); +. = ALIGN(4); src/rom_8077ABC.o(ewram_data); +. = ALIGN(4); src/scene/title_screen.o(ewram_data); +. = ALIGN(4); src/field/field_weather.o(ewram_data); +. = ALIGN(4); src/battle/battle_setup.o(ewram_data); +. = ALIGN(4); src/field/wild_encounter.o(ewram_data); +. = ALIGN(4); src/field/field_effect.o(ewram_data); +. = ALIGN(4); src/scanline_effect.o(ewram_data); +. = ALIGN(4); src/pokemon/pokemon_menu.o(ewram_data); +. = ALIGN(4); src/pokemon/pokedex.o(ewram_data); +. = ALIGN(4); src/engine/trainer_card.o(ewram_data); +. = ALIGN(4); src/pokemon/pokemon_storage_system.o(ewram_data); -@ still pokemon_storage_system +/* still pokemon_storage_system */ - .align 2 -gUnknown_02038470: @ 2038470 - .space 0x3 + . = ALIGN(4); +gUnknown_02038470 = .; /* 2038470 */ + . += 0x3; -gUnknown_02038473: @ 2038473 - .space 0x1 +gUnknown_02038473 = .; /* 2038473 */ + . += 0x1; -gUnknown_02038474: @ 2038474 - .space 0x4 +gUnknown_02038474 = .; /* 2038474 */ + . += 0x4; -gUnknown_02038478: @ 2038478 - .space 0x4 - -gUnknown_0203847C: @ 203847C - .space 0x1 - -gUnknown_0203847D: @ 203847D - .space 0x1 - -gUnknown_0203847E: @ 203847E - .space 0x1 - -gUnknown_0203847F: @ 203847F - .space 0x1 - -gUnknown_02038480: @ 2038480 - .space 0x64 - -gUnknown_020384E4: @ 20384E4 - .space 0x1 - -gUnknown_020384E5: @ 20384E5 - .space 0x1 - -gUnknown_020384E6: @ 20384E6 - .space 0x1 - -gUnknown_020384E7: @ 20384E7 - .space 0x1 - -gUnknown_020384E8: @ 20384E8 - .space 0x1 - -gUnknown_020384E9: @ 20384E9 - .space 0x1 - -gUnknown_020384EA: @ 20384EA - .space 0x2 - -gUnknown_020384EC: @ 20384EC - .space 0x4 - - .include "src/pokemon/pokemon_summary_screen.o" - .include "src/field/script_movement.o" - .include "src/field/map_name_popup.o" - .include "src/field/item_menu.o" - .include "src/contest.o" - .include "src/field/shop.o" - .include "src/field/fldeff_escalator.o" - .include "src/field/money.o" - .include "src/engine/record_mixing.o" - .include "src/debug/sound_check_menu.o" - .include "src/field/secret_base.o" - .include "src/field/tv.o" - .include "src/field/pc_screen_effect.o" - .include "src/field/rotating_gate.o" - .include "src/field/safari_zone.o" - .include "src/easy_chat_2.o" - -@ pokenav - - .align 2 -gUnknown_020388B0: @ 20388B0 - .space 0x4 - -gUnknown_020388B4: @ 20388B4 - .space 0x4 - - .include "src/pokemon/mon_markings.o" - .include "src/field/mauville_man.o" - .include "src/field/menu_helpers.o" - .include "src/field/region_map.o" - .include "src/field/decoration.o" - .include "src/battle/battle_ai.o" - .include "src/rom6.o" - .include "src/field/pokeblock.o" - .include "src/field/field_specials.o" - -@ pokedex_area_screen - - .align 2 -gUnknown_02039260: @ 2039260 - .space 0x2 +gUnknown_02038478 = .; /* 2038478 */ + . += 0x4; + +gUnknown_0203847C = .; /* 203847C */ + . += 0x1; + +gUnknown_0203847D = .; /* 203847D */ + . += 0x1; + +gUnknown_0203847E = .; /* 203847E */ + . += 0x1; + +gUnknown_0203847F = .; /* 203847F */ + . += 0x1; + +gUnknown_02038480 = .; /* 2038480 */ + . += 0x64; + +gUnknown_020384E4 = .; /* 20384E4 */ + . += 0x1; + +gUnknown_020384E5 = .; /* 20384E5 */ + . += 0x1; + +gUnknown_020384E6 = .; /* 20384E6 */ + . += 0x1; + +gUnknown_020384E7 = .; /* 20384E7 */ + . += 0x1; + +gUnknown_020384E8 = .; /* 20384E8 */ + . += 0x1; + +gUnknown_020384E9 = .; /* 20384E9 */ + . += 0x1; + +gUnknown_020384EA = .; /* 20384EA */ + . += 0x2; + +gUnknown_020384EC = .; /* 20384EC */ + . += 0x4; + +. = ALIGN(4); src/pokemon/pokemon_summary_screen.o(ewram_data); +. = ALIGN(4); src/field/script_movement.o(ewram_data); +. = ALIGN(4); src/field/map_name_popup.o(ewram_data); +. = ALIGN(4); src/field/item_menu.o(ewram_data); +. = ALIGN(4); src/contest.o(ewram_data); +. = ALIGN(4); src/field/shop.o(ewram_data); +. = ALIGN(4); src/field/fldeff_escalator.o(ewram_data); +. = ALIGN(4); src/field/money.o(ewram_data); +. = ALIGN(4); src/engine/record_mixing.o(ewram_data); +. = ALIGN(4); src/debug/sound_check_menu.o(ewram_data); +. = ALIGN(4); src/field/secret_base.o(ewram_data); +. = ALIGN(4); src/field/tv.o(ewram_data); +. = ALIGN(4); src/field/pc_screen_effect.o(ewram_data); +. = ALIGN(4); src/field/rotating_gate.o(ewram_data); +. = ALIGN(4); src/field/safari_zone.o(ewram_data); +. = ALIGN(4); src/easy_chat_2.o(ewram_data); + +/* pokenav */ + + . = ALIGN(4); +gUnknown_020388B0 = .; /* 20388B0 */ + . += 0x4; + +gUnknown_020388B4 = .; /* 20388B4 */ + . += 0x4; + +. = ALIGN(4); src/pokemon/mon_markings.o(ewram_data); +. = ALIGN(4); src/field/mauville_man.o(ewram_data); +. = ALIGN(4); src/field/menu_helpers.o(ewram_data); +. = ALIGN(4); src/field/region_map.o(ewram_data); +. = ALIGN(4); src/field/decoration.o(ewram_data); +. = ALIGN(4); src/battle/battle_ai.o(ewram_data); +. = ALIGN(4); src/rom6.o(ewram_data); +. = ALIGN(4); src/field/pokeblock.o(ewram_data); +. = ALIGN(4); src/field/field_specials.o(ewram_data); + +/* pokedex_area_screen */ + + . = ALIGN(4); +gUnknown_02039260 = .; /* 2039260 */ + . += 0x2; -gUnknown_02039262: @ 2039262 - .space 0x2 +gUnknown_02039262 = .; /* 2039262 */ + . += 0x2; -gUnknown_02039264: @ 2039264 - .space 0x2 +gUnknown_02039264 = .; /* 2039264 */ + . += 0x2; -gUnknown_02039266: @ 2039266 - .space 0x2 +gUnknown_02039266 = .; /* 2039266 */ + . += 0x2; -gUnknown_02039268: @ 2039268 - .space 0x2 +gUnknown_02039268 = .; /* 2039268 */ + . += 0x2; -gUnknown_0203926A: @ 203926A - .space 0x2 - - .include "src/battle/battle_message.o" - .include "src/field/choose_party.o" - .include "src/scene/cable_car.o" - .include "src/engine/save.o" - .include "src/engine/mystery_event_script.o" - .include "src/field/roamer.o" - .include "src/field/use_pokeblock.o" - .include "src/field/player_pc.o" - .include "src/scene/intro.o" - .include "src/scene/hall_of_fame.o" - .include "src/scene/credits.o" - .include "src/field/lottery_corner.o" - .include "src/field/berry_tag_screen.o" - .include "src/engine/mystery_event_menu.o" - .include "src/engine/save_failed_screen.o" - .include "src/pokemon/pokeblock_feed.o" - .include "src/scene/intro_credits_graphics.o" - -@ ??? - - .align 4 -gTileBuffer: @ 2039360 - .space 0x100 - -gUnknown_02039460: @ 2039460 - .space 0x300 - -gUnknown_02039760: @ 2039760 - .space 0xC00 - - .include "src/engine/menu_cursor.o" +gUnknown_0203926A = .; /* 203926A */ + . += 0x2; + +. = ALIGN(4); src/battle/battle_message.o(ewram_data); +. = ALIGN(4); src/field/choose_party.o(ewram_data); +. = ALIGN(4); src/scene/cable_car.o(ewram_data); +. = ALIGN(4); src/engine/save.o(ewram_data); +. = ALIGN(4); src/engine/mystery_event_script.o(ewram_data); +. = ALIGN(4); src/field/roamer.o(ewram_data); +. = ALIGN(4); src/field/use_pokeblock.o(ewram_data); +. = ALIGN(4); src/field/player_pc.o(ewram_data); +. = ALIGN(4); src/scene/intro.o(ewram_data); +. = ALIGN(4); src/scene/hall_of_fame.o(ewram_data); +. = ALIGN(4); src/scene/credits.o(ewram_data); +. = ALIGN(4); src/field/lottery_corner.o(ewram_data); +. = ALIGN(4); src/field/berry_tag_screen.o(ewram_data); +. = ALIGN(4); src/engine/mystery_event_menu.o(ewram_data); +. = ALIGN(4); src/engine/save_failed_screen.o(ewram_data); +. = ALIGN(4); src/pokemon/pokeblock_feed.o(ewram_data); +. = ALIGN(4); src/scene/intro_credits_graphics.o(ewram_data); + +/* ??? */ + + . = ALIGN(16); +gTileBuffer = .; /* 2039360 */ + . += 0x100; + +gUnknown_02039460 = .; /* 2039460 */ + . += 0x300; + +gUnknown_02039760 = .; /* 2039760 */ + . += 0xC00; + +. = ALIGN(4); src/engine/menu_cursor.o(ewram_data); -- cgit v1.2.3 From f52a7bea85cac244b63b50fcf038830450946fb0 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 21 Jan 2018 10:31:03 -0600 Subject: annotate filenames of common symbols --- sym_common.txt | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/sym_common.txt b/sym_common.txt index 2c390e214..64e87c046 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -4,6 +4,8 @@ name = .; \ . += size; + +// main.c SYMBOL(gKeyRepeatStartDelay, 4) SYMBOL(gLinkTransferringData, 4) SYMBOL(gMain, 1088) @@ -13,6 +15,8 @@ SYMBOL(gIntrTable, 56) SYMBOL(gLinkVSyncDisabled, 4) SYMBOL(IntrMain_Buffer, 2048) SYMBOL(gPcmDmaCounter, 4) + +// sprite.c SYMBOL(gSpriteOrder, 64) SYMBOL(gSpriteTileAllocBitmap, 128) SYMBOL(gSpriteCoordOffsetX, 4) @@ -25,7 +29,11 @@ SYMBOL(gOamMatrices, 256) SYMBOL(gShouldProcessSpriteCopyRequests, 4) SYMBOL(gOamMatrixAllocBitmap, 4) SYMBOL(gReservedSpritePaletteCount, 4) + +// string_util.c SYMBOL(gUnknownStringVar, 16) + +// link.c SYMBOL(word_3002910, 8) SYMBOL(gLinkDebugValue1, 4) SYMBOL(localLinkPlayerBlock, 60) @@ -71,7 +79,11 @@ SYMBOL(gLastSendQueueCount, 4) SYMBOL(gLink, 4032) SYMBOL(gLastRecvQueueCount, 4) SYMBOL(gLinkSavedIme, 4) + +// rtc.c SYMBOL(gLocalTime, 8) + +// battle SYMBOL(gBattleBuffersTransferData, 368) SYMBOL(gBattle_BG3_X, 4) SYMBOL(gBattle_BG1_Y, 4) @@ -111,46 +123,88 @@ SYMBOL(gHealthboxIDs, 4) SYMBOL(gUnknown_03004344, 4) SYMBOL(gUnknown_03004348, 4) SYMBOL(gUnknown_0300434C, 4) + +// pokemon_1.c SYMBOL(gPlayerPartyCount, 4) SYMBOL(gPlayerParty, 600) SYMBOL(gEnemyPartyCount, 4) SYMBOL(gEnemyParty, 600) + +// random.c SYMBOL(gRngValue, 4) + +// egg_hatch.c SYMBOL(gEggHatchData, 4) + +// load_save.c SYMBOL(gFlashMemoryPresent, 4) + +// ??? SYMBOL(gUnknown_03004824, 4) SYMBOL(gUnknown_03004828, 4) . += 0x4; + +// berry_blender.c SYMBOL(gUnknown_03004830, 4) SYMBOL(gInGameOpponentsNo, 4) SYMBOL(gUnknown_03004840, 20) SYMBOL(gBerryBlenderData, 4) + +// overworld.c SYMBOL(word_3004858, 4) SYMBOL(gFieldCallback, 4) SYMBOL(gUnknown_03004860, 4) SYMBOL(gFieldLinkPlayerCount, 4) + +// fieldmap.c . = ALIGN(16); gUnknown_03004870 = .; . += 0xC; + +// field_camera.c SYMBOL(gUnknown_03004880, 24) SYMBOL(gUnknown_03004898, 4) SYMBOL(gUnknown_0300489C, 4) + +// field_map_obj.c SYMBOL(gMapObjects, 576) + +// field_control_avatar.c SYMBOL(gSelectedMapObject, 4) + +// ??? SYMBOL(gPokemonItemUseCallback, 4) + +// start_menu.c SYMBOL(gMenuCallback, 4) + +// sound.c SYMBOL(gDisableMusic, 4) + +// battle_anim.c SYMBOL(gSoundAnimFramesToWait, 4) SYMBOL(gBattleAnimArgs, 16) SYMBOL(gAnimSpriteIndexArray, 16) + +// task.c SYMBOL(gTasks, 640) + +// mori_debug_menu.c SYMBOL(gUnknown_03004DA0, 32) + +// scanline_effect.c SYMBOL(gScanlineEffect, 32) SYMBOL(gScanlineEffectRegBuffers, 3840) + +// pokemon_menu.c SYMBOL(gLastFieldPokeMenuOpened, 4) SYMBOL(gUnknown_03005CE4, 4) + +// pokedex.c SYMBOL(gUnknown_03005CE8, 4) SYMBOL(gUnknown_03005CEC, 4) + +// ??? SYMBOL(gUnknown_03005CF0, 4) // huh? . = ALIGN(16); @@ -160,11 +214,19 @@ gBagPocketScrollStates = .; . += 0x14; SYMBOL(gCurrentBagPocketItemSlots, 4) SYMBOL(gUnknown_03005D28, 4) + +// record_mixing.c SYMBOL(gUnknown_03005D2C, 4) + +// sound_check_menu.c SYMBOL(gUnknown_03005D30, 4) SYMBOL(gSoundTestCryNum, 4) + +// tv.c SYMBOL(gUnknown_03005D38, 4) . += 0x64; // huge gap? + +// ??? SYMBOL(gUnknown_03005DA0, 0x48) SYMBOL(gUnknown_03005DE8, 4) SYMBOL(gUnknown_03005DEC, 4) @@ -176,13 +238,21 @@ SYMBOL(gUnknown_03005E00, 4) SYMBOL(gUnknown_03005E04, 4) SYMBOL(gUnknown_03005E08, 4) SYMBOL(gUnknown_03005E0C, 4) + +// contest_painting.c SYMBOL(gUnknown_03005E10, 4) SYMBOL(gUnknown_03005E20, 32) SYMBOL(gUnknown_03005E40, 76) SYMBOL(gUnknown_03005E8C, 4) SYMBOL(gUnknown_03005E90, 4) + +// evolution_scene.c SYMBOL(gCB2_AfterEvolution, 4) + +// ??? SYMBOL(gUnknown_03005E98, 4) + +// save.c SYMBOL(gFirstSaveSector, 4) SYMBOL(gPrevSaveCounter, 4) SYMBOL(gLastKnownGoodSector, 4) @@ -193,12 +263,18 @@ SYMBOL(gUnknown_03005EB4, 4) SYMBOL(gSaveFileStatus, 4) SYMBOL(gGameContinueCallback, 4) . += 0x10; + +// intro.c SYMBOL(gIntroFrameCounter, 4) SYMBOL(gMultibootProgramStruct, 44) + +// ??? SYMBOL(gUnknown_03005F0C, 4) SYMBOL(gUnknown_03005F10, 4) gUnknown_03005F14 = .; . += 0xC; + +// pokeblock_feed.c SYMBOL(gPokeblockFeedPokeSprite, 4) SYMBOL(gPokeblockFeedMonSpecies, 4) SYMBOL(gPokeblockMonNotFlipped, 4) @@ -211,6 +287,8 @@ SYMBOL(gUnknown_03005F40, 4) SYMBOL(gPokeblockFeedPokeSpriteCopy, 68) SYMBOL(gUnknown_03005F94, 4) SYMBOL(gUnknown_03005FA0, 48) + +// m4a_2.c SYMBOL(gSoundInfo, 4016) SYMBOL(gPokemonCrySongs, 104) SYMBOL(gPokemonCryMusicPlayers, 128) @@ -223,6 +301,8 @@ SYMBOL(gMPlay_SE1, 64) SYMBOL(gMPlay_SE2, 64) SYMBOL(gMPlayMemAccArea, 16) SYMBOL(gMPlay_SE3, 64) + +// agb_flash.c SYMBOL(gFlashTimeoutFlag, 4) SYMBOL(PollFlashStatus, 4) SYMBOL(WaitForFlashWrite, 4) -- cgit v1.2.3 From 38c0be840e653454f7a9745ca63ae5f001a70e28 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 21 Jan 2018 11:13:52 -0600 Subject: preprocess and copy ld script files to build directory --- Makefile | 4 ++-- ld_script.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 83f37d8b7..556293b7a 100644 --- a/Makefile +++ b/Makefile @@ -111,9 +111,9 @@ tidy: %.elf: $(LD_SCRIPT) $(ALL_OBJECTS) cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) ../../$(LIBGCC) ../../$(LIBC) -o ../../$@ -$(LD_SCRIPT): $(BUILD_DIR)/sym_common.ld ld_script.txt +$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_common.ld $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_bss.ld cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld -$(BUILD_DIR)/sym_common.ld: sym_common.txt +$(BUILD_DIR)/sym_%.ld: sym_%.txt $(CPP) -P $(CPPFLAGS) $< > $@ $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) diff --git a/ld_script.txt b/ld_script.txt index 6931eb661..5dcdf948d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -9,7 +9,7 @@ SECTIONS { ewram (NOLOAD) : ALIGN(4) { - INCLUDE "../../sym_ewram.txt" + INCLUDE "sym_ewram.ld" . = 0x40000; } @@ -20,7 +20,7 @@ SECTIONS { ALIGN(4) { /* .bss starts at 0x3000000 */ - INCLUDE "../../sym_bss.txt" + INCLUDE "sym_bss.ld" /* .bss.code starts at 0x3000F60 */ src/libs/m4a_2.o(.bss.code); -- cgit v1.2.3 From 7fbce3b89ff5ad8fae138ccf1842cb83cbc86799 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Sun, 21 Jan 2018 12:35:46 -0600 Subject: use sed to convert library paths relative to build dir --- Makefile | 2 +- sym_bss.txt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 556293b7a..eda7fb2c2 100644 --- a/Makefile +++ b/Makefile @@ -114,7 +114,7 @@ tidy: $(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_common.ld $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_bss.ld cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld $(BUILD_DIR)/sym_%.ld: sym_%.txt - $(CPP) -P $(CPPFLAGS) $< > $@ + $(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@ $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) $(CPP) $(CPPFLAGS) $< -o $(BUILD_DIR)/$*.i diff --git a/sym_bss.txt b/sym_bss.txt index f36785ce8..5e22693fd 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -37,6 +37,6 @@ . = ALIGN(4); src/libs/m4a_1.o(.bss); . = ALIGN(4); src/libs/agb_flash.o(.bss); . = ALIGN(4); src/libs/siirtc.o(.bss); -. = ALIGN(4); ../../tools/agbcc/lib/libgcc.a:dp-bit.o(.bss); -. = ALIGN(4); ../../tools/agbcc/lib/libgcc.a:fp-bit.o(.bss); -. = ALIGN(4); ../../tools/agbcc/lib/libc.a:syscalls.o(.bss); +. = ALIGN(4); tools/agbcc/lib/libgcc.a:dp-bit.o(.bss); +. = ALIGN(4); tools/agbcc/lib/libgcc.a:fp-bit.o(.bss); +. = ALIGN(4); tools/agbcc/lib/libc.a:syscalls.o(.bss); -- cgit v1.2.3 From 9f1f9827a8a6057d86b63ccca34d96f5ae080c4f Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 21 Jan 2018 13:51:28 -0500 Subject: fix shell scripts in install instructions --- INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b852dd126..dfd992f2f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,12 +6,12 @@ Make sure that there is an environment variable called DEVKITARM with the path o Then get the compiler from https://github.com/pret/agbcc and run the following commands. - build.sh - install.sh PATH_OF_POKERUBY_DIRECTORY + ./build.sh + ./install.sh PATH_OF_POKERUBY_DIRECTORY Then in the pokeruby directory, build the tools. - build_tools.sh + ./build_tools.sh Finally, build the rom. -- cgit v1.2.3 From 796d331df605f17b3e5d89d494d89ce7a907eaab Mon Sep 17 00:00:00 2001 From: Thomas Winwood Date: Mon, 22 Jan 2018 06:35:10 +0000 Subject: Use BATTLE_TYPE_DOUBLE constant in guard.c --- src/battle/anim/guard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle/anim/guard.c b/src/battle/anim/guard.c index ab093eab1..01cf07e39 100644 --- a/src/battle/anim/guard.c +++ b/src/battle/anim/guard.c @@ -12,7 +12,7 @@ extern u16 gBattleTypeFlags; void sub_80D3014(struct Sprite *sprite) { - if ((gBattleTypeFlags & 1) && IsAnimBankSpriteVisible(gAnimBankAttacker ^ 2)) + if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && IsAnimBankSpriteVisible(gAnimBankAttacker ^ 2)) { sub_807A3FC(gAnimBankAttacker, 0, &sprite->pos1.x, &sprite->pos1.y); sprite->pos1.y += 40; -- cgit v1.2.3 From 4e98ffed3339ca9fd7c4f0915da707aa8b2417ef Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 14:54:37 -0500 Subject: through sub_80C8604 --- asm/contest_link_80C857C.s | 133 -------------------------------------- include/ewram.h | 1 + ld_script.txt | 3 +- src/battle/contest_link_80C857C.c | 46 +++++++++++++ 4 files changed, 49 insertions(+), 134 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 6afcaec6d..c6958462c 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,139 +5,6 @@ .text - thumb_func_start sub_80C857C -sub_80C857C: @ 80C857C - push {r4,r5,lr} - adds r2, r0, 0 - lsls r4, r1, 16 - lsrs r4, 16 - ldr r5, _080C85A8 @ =gSharedMem + 0x1E000 - adds r0, r5, 0 - adds r1, r2, 0 - adds r2, r4, 0 - bl memcpy - bl bitmask_all_link_players_but_self - lsls r0, 24 - lsrs r0, 24 - adds r1, r5, 0 - adds r2, r4, 0 - bl SendBlock - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080C85A8: .4byte gSharedMem + 0x1E000 - thumb_func_end sub_80C857C - - thumb_func_start sub_80C85AC -sub_80C85AC: @ 80C85AC - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x80 - lsls r1, 17 - lsls r1, r0 - lsrs r4, r1, 24 - bl GetBlockReceivedStatus - adds r1, r4, 0 - ands r1, r0 - cmp r1, 0 - beq _080C85D0 - adds r0, r4, 0 - bl ResetBlockReceivedFlag - movs r0, 0x1 - b _080C85D2 -_080C85D0: - movs r0, 0 -_080C85D2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80C85AC - - thumb_func_start sub_80C85D8 -sub_80C85D8: @ 80C85D8 - push {r4,lr} - movs r4, 0 -_080C85DC: - bl GetBlockReceivedStatus - lsls r0, 24 - lsrs r0, 24 - asrs r0, r4 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080C85F2 - movs r0, 0 - b _080C85FE -_080C85F2: - adds r4, 0x1 - cmp r4, 0x3 - ble _080C85DC - bl ResetBlockReceivedFlags - movs r0, 0x1 -_080C85FE: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80C85D8 - -.ifdef ENGLISH - thumb_func_start sub_80C8604 -sub_80C8604: @ 80C8604 - push {r4-r6,lr} - lsls r0, 24 - lsrs r2, r0, 24 - movs r1, 0 - ldr r5, _080C8638 @ =gTasks - ldr r6, _080C863C @ =sub_80C8644 - ldr r4, _080C8640 @ =gBlockRecvBuffer - movs r3, 0xFF -_080C8614: - lsls r0, r1, 8 - adds r0, r4 - strh r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _080C8614 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r0, r5 - movs r1, 0 - strh r1, [r0, 0x8] - str r6, [r0] - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 -_080C8638: .4byte gTasks -_080C863C: .4byte sub_80C8644 -_080C8640: .4byte gBlockRecvBuffer - thumb_func_end sub_80C8604 -.else - thumb_func_start sub_80C8604 -sub_80C8604: @ 80C8604 - lsls r0, 24 - lsrs r0, 24 - ldr r2, _080C861C @ =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0x8] - ldr r0, _080C8620 @ =sub_80C8644 - str r0, [r1] - bx lr - .align 2, 0 -_080C861C: .4byte gTasks -_080C8620: .4byte sub_80C8644 - thumb_func_end sub_80C8604 -.endif - thumb_func_start sub_80C8644 sub_80C8644: @ 80C8644 lsls r0, 24 diff --git a/include/ewram.h b/include/ewram.h index 13e478ff1..2f1c2d1ab 100644 --- a/include/ewram.h +++ b/include/ewram.h @@ -261,6 +261,7 @@ extern u8 gSharedMem[]; #define eHallOfFame (struct HallOfFame *)(gSharedMem + 0x1E000) #define HALL_OF_FAME_SHEET_0 ((u8 *)(gSharedMem + 0x1E000)) #define ewram1E000_2 (const u8 *)(gSharedMem + 0x1E000) +#define eContestLinkSendBuffer gSharedMem + 0x1E000 #define HALL_OF_FAME_SHEET_1 ((u8 *)(gSharedMem + 0x1E800)) #define ewram_1f000 (*(struct DecoPCPointers *)(gSharedMem + 0x1f000)) #define ewramSavedPokeballsPocket ((struct ItemSlot *)(gSharedMem + 0x1F000)) // saved Pokeballs pocket (for Wally battle) diff --git a/ld_script.txt b/ld_script.txt index 5dcdf948d..411d282d1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -169,8 +169,9 @@ SECTIONS { src/field/field_special_scene.o(.text); src/field/rotating_gate.o(.text); src/field/safari_zone.o(.text); - asm/contest_link_80C857C.o(.text); src/battle/contest_link_80C857C.o(.text); + asm/contest_link_80C857C.o(.text); + src/battle/contest_link_80C857C.o(.text_de); src/field/item_use.o(.text); src/battle/anim/powder.o(.text); src/battle/anim/orbs.o(.text); diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 616a72d27..e0b24b9e1 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -1,6 +1,52 @@ #include "global.h" +#include "ewram.h" +#include "task.h" #include "link.h" +void sub_80C8644(u8 taskId); + +void sub_80C857C(const void *data, u16 size) +{ + memcpy(eContestLinkSendBuffer, data, size); + SendBlock(bitmask_all_link_players_but_self(), eContestLinkSendBuffer, size); +} + +bool8 sub_80C85AC(u8 who) +{ + u8 flag = 1 << who; + if (!(GetBlockReceivedStatus() & flag)) + return FALSE; + ResetBlockReceivedFlag(flag); + return TRUE; +} + +bool8 sub_80C85D8(void) +{ + int i; + + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + if (!((GetBlockReceivedStatus() >> i) & 1)) + return FALSE; + } + ResetBlockReceivedFlags(); + return TRUE; +} + +void sub_80C8604(u8 taskId) +{ +#if ENGLISH + u8 i; + + for (i = 0; i < 4; i++) + gBlockRecvBuffer[i][0] = 0xff; +#endif + gTasks[taskId].data[0] = 0; + gTasks[taskId].func = sub_80C8644; +} + +asm(".section .text_de"); + #if GERMAN void de_sub_80C9274(bool32 arg0) -- cgit v1.2.3 From fc504ce61b8698bc4777bbd37a8766b8c35a5814 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 15:51:57 -0500 Subject: through (nonmatching) sub_80C86A0 --- asm/contest_link_80C857C.s | 139 ----------------------------------- include/contest.h | 3 + src/battle/contest_link_80C857C.c | 150 +++++++++++++++++++++++++++++++++++++- 3 files changed, 152 insertions(+), 140 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index c6958462c..1ac60af96 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,145 +5,6 @@ .text - thumb_func_start sub_80C8644 -sub_80C8644: @ 80C8644 - lsls r0, 24 - lsrs r0, 24 - ldr r2, _080C8658 @ =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, _080C865C @ =sub_80C8660 - str r0, [r1] - bx lr - .align 2, 0 -_080C8658: .4byte gTasks -_080C865C: .4byte sub_80C8660 - thumb_func_end sub_80C8644 - - thumb_func_start sub_80C8660 -sub_80C8660: @ 80C8660 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, _080C8694 @ =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0 - beq _080C868E - bl GetMultiplayerId - ldr r1, _080C8698 @ =gContestPlayerMonIndex - strb r0, [r1] - bl GetLinkPlayerCount - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _080C868E - ldr r1, _080C869C @ =gIsLinkContest - movs r0, 0x1 - strb r0, [r1] - adds r0, r4, 0 - bl SwitchTaskToFollowupFunc -_080C868E: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080C8694: .4byte gReceivedRemoteLinkPlayers -_080C8698: .4byte gContestPlayerMonIndex -_080C869C: .4byte gIsLinkContest - thumb_func_end sub_80C8660 - - thumb_func_start sub_80C86A0 -sub_80C86A0: @ 80C86A0 - push {r4,r5,lr} - adds r4, r0, 0 -.ifdef ENGLISH - movs r5, 0x2 -.else - movs r5, 0x5 -.endif - ldrb r0, [r4] - cmp r0, 0xFC - bne _080C86B6 - ldrb r0, [r4, 0x1] - cmp r0, 0x15 - bne _080C86B6 -.ifdef ENGLISH - movs r0, 0x2 -.else - movs r0, 0x5 -.endif - b _080C872C -_080C86B6: - adds r0, r4, 0 - bl StringLength - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x5 - bhi _080C872A - ldrb r0, [r4] - cmp r0, 0xFF - beq _080C872A -_080C86CA: - ldrb r1, [r4] - adds r0, r1, 0 - adds r0, 0x45 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x33 - bls _080C871E - adds r0, r1, 0 - adds r0, 0x5F - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x9 - bls _080C871E - adds r0, r1, 0 - cmp r0, 0 - beq _080C871E - cmp r0, 0xAD - beq _080C871E - cmp r0, 0xB8 - beq _080C871E - cmp r0, 0xAB - beq _080C871E - cmp r0, 0xAC - beq _080C871E - cmp r0, 0xB5 - beq _080C871E - cmp r0, 0xB6 - beq _080C871E - cmp r0, 0xBA - beq _080C871E - cmp r0, 0xAE - beq _080C871E - cmp r0, 0xB0 - beq _080C871E - cmp r0, 0xB1 - beq _080C871E - cmp r0, 0xB2 - beq _080C871E - cmp r0, 0xB3 - beq _080C871E - cmp r0, 0xB1 - bne _080C8728 -_080C871E: - adds r4, 0x1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _080C86CA - b _080C872A -_080C8728: - movs r5, 0x1 -_080C872A: - adds r0, r5, 0 -_080C872C: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80C86A0 - .ifdef ENGLISH thumb_func_start sub_80C8734 sub_80C8734: @ 80C8734 diff --git a/include/contest.h b/include/contest.h index 6b1f1f520..e8e68f0e6 100644 --- a/include/contest.h +++ b/include/contest.h @@ -271,4 +271,7 @@ struct UnknownContestStruct6 #define shared19338 ((struct UnknownContestStruct4 *)(gSharedMem + 0x19338)) #define shared19348 (*(struct UnknownContestStruct8 *)(gSharedMem + 0x19348)) +extern u8 gContestPlayerMonIndex; +extern u8 gIsLinkContest; + #endif // GUARD_CONTEST_H diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index e0b24b9e1..3360ecbb6 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -1,9 +1,13 @@ #include "global.h" #include "ewram.h" #include "task.h" +#include "contest.h" +#include "text.h" +#include "string_util.h" #include "link.h" -void sub_80C8644(u8 taskId); +static void sub_80C8644(u8 taskId); +static void sub_80C8660(u8 taskId); void sub_80C857C(const void *data, u16 size) { @@ -45,6 +49,150 @@ void sub_80C8604(u8 taskId) gTasks[taskId].func = sub_80C8644; } +static void sub_80C8644(u8 taskId) +{ + gTasks[taskId].func = sub_80C8660; +} + +static void sub_80C8660(u8 taskId) +{ + if (gReceivedRemoteLinkPlayers) + { + gContestPlayerMonIndex = GetMultiplayerId(); + if (GetLinkPlayerCount() == MAX_LINK_PLAYERS) + { + gIsLinkContest = TRUE; + SwitchTaskToFollowupFunc(taskId); + } + } +} + +#ifdef NONMATCHING +u8 sub_80C86A0(const u8 *string) +{ + u8 language = GAME_LANGUAGE; + if (string[0] == EXT_CTRL_CODE_BEGIN && string[1] == 0x15) + return language; + if (StringLength(string) > 5) + return language; + for (; *string != EOS; string++) + { + if (!((*string >= CHAR_A && *string <= CHAR_z) || + (*string >= CHAR_0 + 0 && *string <= CHAR_0 + 9) || + *string == CHAR_SPACE || + *string == CHAR_PERIOD || + *string == CHAR_COMMA || + *string == 0xAB || + *string == CHAR_QUESTION_MARK || + *string == CHAR_MALE || + *string == CHAR_FEMALE || + *string == CHAR_SLASH || + *string == CHAR_HYPHEN || + *string == CHAR_ELLIPSIS || + *string == 0xB1 || + *string == 0xB2 || + *string == 0xB3 || + *string == 0xB1 + )) + { + language = LANGUAGE_JAPANESE; + break; + } + } + return language; +} +#else +__attribute__((naked)) u8 sub_80C86A0(const u8 *string) +{ + asm_unified("\tpush {r4,r5,lr}\n" + "\tadds r4, r0, 0\n" + ".ifdef ENGLISH\n" + "\tmovs r5, 0x2\n" + ".else\n" + "\tmovs r5, 0x5\n" + ".endif\n" + "\tldrb r0, [r4]\n" + "\tcmp r0, 0xFC\n" + "\tbne _080C86B6\n" + "\tldrb r0, [r4, 0x1]\n" + "\tcmp r0, 0x15\n" + "\tbne _080C86B6\n" + ".ifdef ENGLISH\n" + "\tmovs r0, 0x2\n" + ".else\n" + "\tmovs r0, 0x5\n" + ".endif\n" + "\tb _080C872C\n" + "_080C86B6:\n" + "\tadds r0, r4, 0\n" + "\tbl StringLength\n" + "\tlsls r0, 16\n" + "\tlsrs r0, 16\n" + "\tcmp r0, 0x5\n" + "\tbhi _080C872A\n" + "\tldrb r0, [r4]\n" + "\tcmp r0, 0xFF\n" + "\tbeq _080C872A\n" + "_080C86CA:\n" + "\tldrb r1, [r4]\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x45\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x33\n" + "\tbls _080C871E\n" + "\tadds r0, r1, 0\n" + "\tadds r0, 0x5F\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tcmp r0, 0x9\n" + "\tbls _080C871E\n" + "\tadds r0, r1, 0\n" + "\tcmp r0, 0\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xAD\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB8\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xAB\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xAC\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB5\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB6\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xBA\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xAE\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB0\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB1\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB2\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB3\n" + "\tbeq _080C871E\n" + "\tcmp r0, 0xB1\n" + "\tbne _080C8728\n" + "_080C871E:\n" + "\tadds r4, 0x1\n" + "\tldrb r0, [r4]\n" + "\tcmp r0, 0xFF\n" + "\tbne _080C86CA\n" + "\tb _080C872A\n" + "_080C8728:\n" + "\tmovs r5, 0x1\n" + "_080C872A:\n" + "\tadds r0, r5, 0\n" + "_080C872C:\n" + "\tpop {r4,r5}\n" + "\tpop {r1}\n" + "\tbx r1"); +} +#endif + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From b2ea9aec023be26a83853ca53134ce78b95ac2e6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 17:33:02 -0500 Subject: sub_80C8734 --- asm/contest_link_80C857C.s | 409 -------------------------------------- src/battle/contest_link_80C857C.c | 104 ++++++++++ 2 files changed, 104 insertions(+), 409 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 1ac60af96..2fdd4bbcd 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,415 +5,6 @@ .text -.ifdef ENGLISH - thumb_func_start sub_80C8734 -sub_80C8734: @ 80C8734 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - ldr r1, _080C8768 @ =gTasks - lsls r5, r0, 2 - adds r0, r5, r0 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C876C - cmp r0, 0x1 - beq _080C87D0 - movs r0, 0 - strh r0, [r4, 0x8] - mov r0, r9 - bl SwitchTaskToFollowupFunc - b _080C8896 - .align 2, 0 -_080C8768: .4byte gTasks -_080C876C: - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C87A8 - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - bne _080C8782 - b _080C8896 -_080C8782: - ldr r0, _080C879C @ =gBlockSendBuffer - ldr r1, _080C87A0 @ =gContestPlayerMonIndex - ldrb r1, [r1] - lsls r1, 6 - ldr r2, _080C87A4 @ =gContestMons - adds r1, r2 - movs r2, 0x40 - bl memcpy - movs r0, 0x2 - bl sub_8007E9C - b _080C87BA - .align 2, 0 -_080C879C: .4byte gBlockSendBuffer -_080C87A0: .4byte gContestPlayerMonIndex -_080C87A4: .4byte gContestMons -_080C87A8: - ldr r0, _080C87C4 @ =gBlockSendBuffer - ldr r1, _080C87C8 @ =gContestPlayerMonIndex - ldrb r1, [r1] - lsls r1, 6 - ldr r2, _080C87CC @ =gContestMons - adds r1, r2 - movs r2, 0x40 - bl memcpy -_080C87BA: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C8896 - .align 2, 0 -_080C87C4: .4byte gBlockSendBuffer -_080C87C8: .4byte gContestPlayerMonIndex -_080C87CC: .4byte gContestMons -_080C87D0: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8896 - movs r7, 0 - str r5, [sp] - ldr r0, _080C8818 @ =gContestMons - ldr r6, _080C881C @ =gLinkPlayers - movs r5, 0 - mov r10, r0 - movs r2, 0xFF - mov r8, r2 -_080C87EA: - lsls r1, r7, 8 - ldr r0, _080C8820 @ =gBlockRecvBuffer - adds r1, r0 - mov r0, r10 - movs r2, 0x40 - bl memcpy - ldr r0, _080C8824 @ =gContestMons + 0x2 - adds r4, r5, r0 - ldrh r0, [r6, 0x1A] - cmp r0, 0x1 - bne _080C8828 - adds r0, r4, 0 - bl sub_80C86A0 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl ConvertInternationalString - b _080C883E - .align 2, 0 -_080C8818: .4byte gContestMons -_080C881C: .4byte gLinkPlayers -_080C8820: .4byte gBlockRecvBuffer -_080C8824: .4byte gContestMons + 0x2 -_080C8828: - ldrb r0, [r4, 0xA] - cmp r0, 0xFC - bne _080C8838 - adds r0, r4, 0 - movs r1, 0x1 - bl ConvertInternationalString - b _080C883E -_080C8838: - strb r0, [r4, 0x5] - mov r1, r8 - strb r1, [r4, 0xA] -_080C883E: - ldr r0, _080C886C @ =gContestMons + 0xD - adds r4, r5, r0 - ldrh r0, [r6, 0x1A] - cmp r0, 0x1 - bne _080C8870 - mov r2, r8 - strb r2, [r4, 0x7] - ldrb r0, [r4, 0x4] - strb r0, [r4, 0x6] - ldrb r0, [r4, 0x3] - strb r0, [r4, 0x5] - ldrb r0, [r4, 0x2] - strb r0, [r4, 0x4] - ldrb r0, [r4, 0x1] - strb r0, [r4, 0x3] - ldrb r0, [r4] - strb r0, [r4, 0x2] - movs r0, 0x15 - strb r0, [r4, 0x1] - movs r0, 0xFC - strb r0, [r4] - b _080C8878 - .align 2, 0 -_080C886C: .4byte gContestMons + 0xD -_080C8870: - ldrb r0, [r4, 0x7] - strb r0, [r4, 0x5] - mov r0, r8 - strb r0, [r4, 0x7] -_080C8878: - adds r6, 0x1C - adds r5, 0x40 - movs r1, 0x40 - add r10, r1 - adds r7, 0x1 - cmp r7, 0x3 - ble _080C87EA - ldr r0, _080C88A8 @ =gTasks - ldr r1, [sp] - add r1, r9 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_080C8896: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080C88A8: .4byte gTasks - thumb_func_end sub_80C8734 -.else - thumb_func_start sub_80C8734 -sub_80C8734: @ 80C8734 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, _080C8760 @ =gTasks - lsls r4, r5, 2 - adds r0, r4, r5 - lsls r0, 3 - adds r2, r0, r1 - movs r3, 0x8 - ldrsh r0, [r2, r3] - cmp r0, 0x1 - beq _080C8800 - cmp r0, 0x1 - bgt _080C8764 - cmp r0, 0 - beq _080C8770 - b _080C88E0 - .align 2, 0 -_080C8760: .4byte gTasks -_080C8764: - cmp r0, 0x2 - bne _080C876A - b _080C88D4_B -_080C876A: - cmp r0, 0x8 - beq _080C8770 - b _080C88E0 -_080C8770: - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C87D4 - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - bne _080C8786 - b _080C88EE -_080C8786: - ldr r0, _080C87A0 @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r4, r1, r0 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080C87A4 - movs r0, 0x3 - strh r0, [r4, 0x8] - b _080C88EE - .align 2, 0 -_080C87A0: .4byte gTasks -_080C87A4: - ldr r0, _080C87C8 @ =gBlockSendBuffer - ldr r1, _080C87CC @ =gContestPlayerMonIndex - ldrb r1, [r1] - lsls r1, 6 - ldr r2, _080C87D0 @ =gContestMons - adds r1, r2 - movs r2, 0x40 - bl memcpy - movs r0, 0 - bl de_sub_80C9274 - movs r0, 0x2 - bl sub_8007E9C - movs r0, 0x1 - strh r0, [r4, 0x8] - b _080C88EE - .align 2, 0 -_080C87C8: .4byte gBlockSendBuffer -_080C87CC: .4byte gContestPlayerMonIndex -_080C87D0: .4byte gContestMons -_080C87D4: - ldr r0, _080C87F0 @ =gBlockSendBuffer - ldr r1, _080C87F4 @ =gContestPlayerMonIndex - ldrb r1, [r1] - lsls r1, 6 - ldr r2, _080C87F8 @ =gContestMons - adds r1, r2 - movs r2, 0x40 - bl memcpy - movs r0, 0 - bl de_sub_80C9294 - ldr r1, _080C87FC @ =gTasks - b _080C88E0 - .align 2, 0 -_080C87F0: .4byte gBlockSendBuffer -_080C87F4: .4byte gContestPlayerMonIndex -_080C87F8: .4byte gContestMons -_080C87FC: .4byte gTasks -_080C8800: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C88EE - movs r2, 0 - mov r8, r2 - str r4, [sp] - ldr r0, _080C884C @ =gContestMons - ldr r7, _080C8850 @ =gLinkPlayers - movs r6, 0 - mov r10, r0 - movs r3, 0xFF - mov r9, r3 -_080C881C: - mov r0, r8 - lsls r1, r0, 8 - ldr r0, _080C8854 @ =gBlockRecvBuffer - adds r1, r0 - mov r0, r10 - movs r2, 0x40 - bl memcpy - ldr r1, _080C8858 @ =gContestMons + 0x2 - adds r4, r6, r1 - ldrh r0, [r7, 0x1A] - cmp r0, 0x1 - bne _080C885C - adds r0, r4, 0 - bl sub_80C86A0 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl ConvertInternationalString - b _080C8872 - .align 2, 0 -_080C884C: .4byte gContestMons -_080C8850: .4byte gLinkPlayers -_080C8854: .4byte gBlockRecvBuffer -_080C8858: .4byte gContestMons + 0x2 -_080C885C: - ldrb r0, [r4, 0xA] - cmp r0, 0xFC - bne _080C886C - adds r0, r4, 0 - movs r1, 0x1 - bl ConvertInternationalString - b _080C8872 -_080C886C: - strb r0, [r4, 0x5] - mov r2, r9 - strb r2, [r4, 0xA] -_080C8872: - ldr r0, _080C88A0 @ =gContestMons + 0xD - adds r4, r6, r0 - ldrh r0, [r7, 0x1A] - cmp r0, 0x1 - bne _080C88A4 - mov r3, r9 - strb r3, [r4, 0x7] - ldrb r0, [r4, 0x4] - strb r0, [r4, 0x6] - ldrb r0, [r4, 0x3] - strb r0, [r4, 0x5] - ldrb r0, [r4, 0x2] - strb r0, [r4, 0x4] - ldrb r0, [r4, 0x1] - strb r0, [r4, 0x3] - ldrb r0, [r4] - strb r0, [r4, 0x2] - movs r0, 0x15 - strb r0, [r4, 0x1] - movs r0, 0xFC - strb r0, [r4] - b _080C88AC - .align 2, 0 -_080C88A0: .4byte gContestMons + 0xD -_080C88A4: - ldrb r0, [r4, 0x7] - strb r0, [r4, 0x5] - mov r0, r9 - strb r0, [r4, 0x7] -_080C88AC: - adds r7, 0x1C - adds r6, 0x40 - movs r1, 0x40 - add r10, r1 - movs r2, 0x1 - add r8, r2 - mov r3, r8 - cmp r3, 0x3 - ble _080C881C - ldr r0, _080C88D0 @ =gTasks - ldr r2, [sp] - adds r1, r2, r5 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _080C88EE - .align 2, 0 -_080C88D0: .4byte gTasks -_080C88D4_B: - movs r0, 0 - strh r0, [r2, 0x8] - adds r0, r5, 0 - bl SwitchTaskToFollowupFunc - b _080C88EE -_080C88E0: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] -_080C88EE: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C8734 -.endif - thumb_func_start sub_80C88AC sub_80C88AC: @ 80C88AC push {r4,r5,lr} diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 3360ecbb6..b86e7bb9c 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -8,6 +8,10 @@ static void sub_80C8644(u8 taskId); static void sub_80C8660(u8 taskId); +#if GERMAN +void de_sub_80C9274(bool32 arg0); +void de_sub_80C9294(bool32 arg0); +#endif void sub_80C857C(const void *data, u16 size) { @@ -193,6 +197,106 @@ __attribute__((naked)) u8 sub_80C86A0(const u8 *string) } #endif +void sub_80C8734(u8 taskId) +{ + int i; + u8 *name; + + switch (gTasks[taskId].data[0]) { +#if ENGLISH + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; +#elif GERMAN + case 8: +#endif + case 0: + if (GetMultiplayerId() == 0) { + if (sub_8007ECC()) { +#if GERMAN + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[0] = 3; + } + else + { +#endif + memcpy(gBlockSendBuffer, gContestMons + gContestPlayerMonIndex, sizeof(struct ContestPokemon)); +#if GERMAN + de_sub_80C9274(FALSE); +#endif + sub_8007E9C(2); +#if GERMAN + gTasks[taskId].data[0] = 1; + } +#else + gTasks[taskId].data[0]++; +#endif + } + } + else + { + memcpy(gBlockSendBuffer, gContestMons + gContestPlayerMonIndex, sizeof(struct ContestPokemon)); +#if GERMAN + de_sub_80C9294(FALSE); +#endif + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + memcpy(gContestMons + i, gBlockRecvBuffer[i], sizeof(struct ContestPokemon)); + name = gContestMons[i].nickname; + if (gLinkPlayers[i].language == LANGUAGE_JAPANESE) + { + ConvertInternationalString(name, sub_80C86A0(name)); + } + else if (name[10] == EXT_CTRL_CODE_BEGIN) + { + ConvertInternationalString(name, LANGUAGE_JAPANESE); + } else + { + name[5] = name[10]; + name[10] = EOS; + } + name = gContestMons[i].trainerName; + if (gLinkPlayers[i].language == LANGUAGE_JAPANESE) + { + name[7] = EOS; + name[6] = name[4]; + name[5] = name[3]; + name[4] = name[2]; + name[3] = name[1]; + name[2] = name[0]; + name[1] = 0x15; + name[0] = EXT_CTRL_CODE_BEGIN; + } + else + { + name[5] = name[7]; + name[7] = EOS; + } + } + gTasks[taskId].data[0]++; + } + break; +#if GERMAN + case 2: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + default: + gTasks[taskId].data[0]++; + break; +#endif + } +} + + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From 84769240d2002281c7bc274f18aab76fbe908483 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 18:04:04 -0500 Subject: sub_80C88AC --- asm/contest_link_80C857C.s | 67 --------------------------------------- include/contest.h | 1 + src/battle/contest_link_80C857C.c | 33 +++++++++++++++++++ src/contest.c | 6 ++-- src/script_pokemon_util_80C4BF0.c | 6 ++-- sym_common.txt | 2 +- 6 files changed, 41 insertions(+), 74 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 2fdd4bbcd..e73efe74d 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,73 +5,6 @@ .text - thumb_func_start sub_80C88AC -sub_80C88AC: @ 80C88AC - push {r4,r5,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, _080C88D4 @ =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r5, r0, r1 - movs r1, 0x8 - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _080C88D8 - cmp r0, 0x1 - beq _080C88FC - movs r0, 0 - strh r0, [r5, 0x8] - adds r0, r2, 0 - bl SwitchTaskToFollowupFunc - b _080C8924 - .align 2, 0 -_080C88D4: .4byte gTasks -_080C88D8: - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C891E - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8924 - ldr r0, _080C88F8 @ =gRngValue - movs r1, 0x4 - bl sub_80C857C - b _080C891E - .align 2, 0 -_080C88F8: .4byte gRngValue -_080C88FC: - movs r0, 0 - bl sub_80C85AC - lsls r0, 24 - cmp r0, 0 - beq _080C8924 - ldr r0, _080C892C @ =gRngValue - ldr r4, _080C8930 @ =gBlockRecvBuffer - adds r1, r4, 0 - movs r2, 0x4 - bl memcpy - ldr r0, _080C8934 @ =gUnknown_03005D28 - adds r1, r4, 0 - movs r2, 0x4 - bl memcpy -_080C891E: - ldrh r0, [r5, 0x8] - adds r0, 0x1 - strh r0, [r5, 0x8] -_080C8924: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080C892C: .4byte gRngValue -_080C8930: .4byte gBlockRecvBuffer -_080C8934: .4byte gUnknown_03005D28 - thumb_func_end sub_80C88AC - .ifdef ENGLISH thumb_func_start sub_80C8938 sub_80C8938: @ 80C8938 diff --git a/include/contest.h b/include/contest.h index e8e68f0e6..dfa0e38da 100644 --- a/include/contest.h +++ b/include/contest.h @@ -273,5 +273,6 @@ struct UnknownContestStruct6 extern u8 gContestPlayerMonIndex; extern u8 gIsLinkContest; +extern u32 gContestRngValue; #endif // GUARD_CONTEST_H diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index b86e7bb9c..937193172 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -1,5 +1,6 @@ #include "global.h" #include "ewram.h" +#include "random.h" #include "task.h" #include "contest.h" #include "text.h" @@ -296,6 +297,38 @@ void sub_80C8734(u8 taskId) } } +void sub_80C88AC(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + case 0: + if (GetMultiplayerId() == 0) + { + if (sub_8007ECC()) + { + sub_80C857C(&gRngValue, sizeof(u32)); + gTasks[taskId].data[0]++; + } + } + else + { + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85AC(0)) + { + memcpy(&gRngValue, gBlockRecvBuffer[0], sizeof(u32)); + memcpy(&gContestRngValue, gBlockRecvBuffer[0], sizeof(u32)); + gTasks[taskId].data[0]++; + } + break; + } +} asm(".section .text_de"); diff --git a/src/contest.c b/src/contest.c index 93d1a8efc..ce29d80b0 100644 --- a/src/contest.c +++ b/src/contest.c @@ -59,7 +59,7 @@ extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_X; extern u16 gBattle_BG1_X; extern u16 gBattle_WIN0H; -extern u32 gUnknown_03005D28; // saved RNG value +extern u32 gContestRngValue; // saved RNG value extern struct SpriteTemplate gUnknown_02024E8C; @@ -495,7 +495,7 @@ void sub_80AB6B4(u8 taskId) GetMultiplayerId(); // unused return value DestroyTask(taskId); gTasks[sContest.mainTaskId].func = sub_80AB960; - gRngValue = gUnknown_03005D28; + gRngValue = gContestRngValue; } } @@ -1812,7 +1812,7 @@ void sub_80ADDA4(u8 taskId) sub_80AF668(); sub_80AF138(); sub_80BE23C(sContestantStatus[gContestPlayerMonIndex].prevMove); - gUnknown_03005D28 = gRngValue; + gContestRngValue = gRngValue; StringExpandPlaceholders(gStringVar4, gUnknown_083CB02C); Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[2] = 0; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index f991297ab..e51bc3522 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -45,7 +45,7 @@ extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; extern u16 gSpecialVar_Result; -extern u32 gUnknown_03005D28; +extern u32 gContestRngValue; extern u8 gUnknown_02038694; extern u8 gUnknown_0203856C; @@ -373,8 +373,8 @@ void ScriptRandom(void) if(gIsLinkContest & 1) { - gUnknown_03005D28 = 1103515245 * gUnknown_03005D28 + 24691; - random = gUnknown_03005D28 >> 16; + gContestRngValue = 1103515245 * gContestRngValue + 24691; + random = gContestRngValue >> 16; scriptPtr = &gSpecialVar_Result; } else diff --git a/sym_common.txt b/sym_common.txt index 64e87c046..0bc9fd80c 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -213,7 +213,7 @@ gFieldItemUseCallback = .; gBagPocketScrollStates = .; . += 0x14; SYMBOL(gCurrentBagPocketItemSlots, 4) -SYMBOL(gUnknown_03005D28, 4) +SYMBOL(gContestRngValue, 4) // record_mixing.c SYMBOL(gUnknown_03005D2C, 4) -- cgit v1.2.3 From 9474c491c070fe38e89f7b3848a5820c763fe045 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 19:03:23 -0500 Subject: sub_80C8938 --- asm/contest_link_80C857C.s | 210 -------------------------------------- src/battle/contest_link_80C857C.c | 68 ++++++++++++ 2 files changed, 68 insertions(+), 210 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index e73efe74d..6dc96e85d 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,216 +5,6 @@ .text -.ifdef ENGLISH - thumb_func_start sub_80C8938 -sub_80C8938: @ 80C8938 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, _080C8968 @ =gTasks - mov r8, r0 - lsls r6, r5, 2 - adds r0, r6, r5 - lsls r7, r0, 3 - mov r1, r8 - adds r4, r7, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C896C - cmp r0, 0x1 - beq _080C8998 - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r5, 0 - bl SwitchTaskToFollowupFunc - b _080C89CE - .align 2, 0 -_080C8968: .4byte gTasks -_080C896C: - ldr r1, _080C8994 @ =gBlockSendBuffer - ldrh r0, [r4, 0x1A] - strb r0, [r1] - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C898C - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C89CE - movs r0, 0x2 - bl sub_8007E9C -_080C898C: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C89CE - .align 2, 0 -_080C8994: .4byte gBlockSendBuffer -_080C8998: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C89CE - movs r3, 0 - mov r12, r8 - adds r1, r6, 0 - ldr r4, _080C89D8 @ =gBlockRecvBuffer - mov r0, r12 - adds r0, 0xA - adds r2, r7, r0 - movs r6, 0x80 - lsls r6, 1 -_080C89B4: - ldrh r0, [r4] - strh r0, [r2] - adds r4, r6 - adds r2, 0x2 - adds r3, 0x1 - cmp r3, 0x3 - ble _080C89B4 - adds r1, r5 - lsls r1, 3 - add r1, r12 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_080C89CE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080C89D8: .4byte gBlockRecvBuffer - thumb_func_end sub_80C8938 -.else - thumb_func_start sub_80C8938 -sub_80C8938: @ 80C8938 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _080C8960 @ =gTasks - lsls r5, r4, 2 - adds r0, r5, r4 - lsls r6, r0, 3 - adds r2, r6, r1 - movs r3, 0x8 - ldrsh r0, [r2, r3] - mov r8, r1 - cmp r0, 0x1 - beq _080C89C4 - cmp r0, 0x1 - bgt _080C8964 - cmp r0, 0 - beq _080C896C - b _080C8A0C - .align 2, 0 -_080C8960: .4byte gTasks -_080C8964: - cmp r0, 0x2 - beq _080C8A00 - cmp r0, 0x8 - bne _080C8A0C -_080C896C: - ldr r1, _080C89A0 @ =gBlockSendBuffer - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - mov r2, r8 - adds r4, r0, r2 - ldrh r0, [r4, 0x1A] - strb r0, [r1] - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C89B6 - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8A1A - movs r3, 0x8 - ldrsh r0, [r4, r3] - cmp r0, 0 - bne _080C89A4 - movs r0, 0x3 - strh r0, [r4, 0x8] - b _080C8A1A - .align 2, 0 -_080C89A0: .4byte gBlockSendBuffer -_080C89A4: - movs r0, 0x1 - bl de_sub_80C9274 - movs r0, 0x2 - bl sub_8007E9C - movs r0, 0x1 - strh r0, [r4, 0x8] - b _080C8A1A -_080C89B6: - movs r0, 0x1 - bl de_sub_80C9294 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C8A1A -_080C89C4: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8A1A - movs r3, 0 - adds r7, r5, 0 - ldr r1, _080C89FC @ =gBlockRecvBuffer - mov r0, r8 - adds r0, 0xA - adds r2, r6, r0 - movs r5, 0x80 - lsls r5, 1 -_080C89DE: - ldrh r0, [r1] - strh r0, [r2] - adds r1, r5 - adds r2, 0x2 - adds r3, 0x1 - cmp r3, 0x3 - ble _080C89DE - adds r1, r7, r4 - lsls r1, 3 - add r1, r8 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _080C8A1A - .align 2, 0 -_080C89FC: .4byte gBlockRecvBuffer -_080C8A00: - movs r0, 0 - strh r0, [r2, 0x8] - adds r0, r4, 0 - bl SwitchTaskToFollowupFunc - b _080C8A1A -_080C8A0C: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - add r0, r8 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] -_080C8A1A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C8938 -.endif - thumb_func_start sub_80C89DC sub_80C89DC: @ 80C89DC push {r4,lr} diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 937193172..17b82388c 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -330,6 +330,74 @@ void sub_80C88AC(u8 taskId) } } +void sub_80C8938(u8 taskId) +{ + int i; + + switch (gTasks[taskId].data[0]) + { +#if ENGLISH + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; +#elif GERMAN + case 8: +#endif + case 0: + gBlockSendBuffer[0] = gTasks[taskId].data[9]; + if (GetMultiplayerId() == 0) + { + if (sub_8007ECC()) + { +#if GERMAN + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[0] = 3; + } + else + { + de_sub_80C9274(TRUE); +#endif + sub_8007E9C(2); +#if ENGLISH + gTasks[taskId].data[0]++; +#elif GERMAN + gTasks[taskId].data[0] = 1; + } +#endif + } + } + else + { +#if GERMAN + de_sub_80C9294(TRUE); +#endif + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + gTasks[taskId].data[i + 1] = gBlockRecvBuffer[i][0]; + } + gTasks[taskId].data[0]++; + } + break; +#if GERMAN + case 2: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + default: + gTasks[taskId].data[0]++; + break; +#endif + } +} + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From 5312cf566196e662aa7edd4ef68f32922eb54180 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 19:20:26 -0500 Subject: through sub_80C8A38 --- asm/contest_link_80C857C.s | 126 -------------------------------------- src/battle/contest_link_80C857C.c | 54 ++++++++++++++++ 2 files changed, 54 insertions(+), 126 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 6dc96e85d..4285531f7 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,132 +5,6 @@ .text - thumb_func_start sub_80C89DC -sub_80C89DC: @ 80C89DC - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, _080C8A04 @ =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C8A08 - cmp r0, 0x1 - beq _080C8A20 - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r2, 0 - bl SwitchTaskToFollowupFunc - b _080C8A30 - .align 2, 0 -_080C8A04: .4byte gTasks -_080C8A08: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8A30 - ldr r0, _080C8A1C @ =gContestPlayerMonIndex - movs r1, 0x1 - bl sub_80C857C - b _080C8A2A - .align 2, 0 -_080C8A1C: .4byte gContestPlayerMonIndex -_080C8A20: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8A30 -_080C8A2A: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_080C8A30: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80C89DC - - thumb_func_start sub_80C8A38 -sub_80C8A38: @ 80C8A38 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r7, _080C8A60 @ =gTasks - lsls r6, r5, 2 - adds r0, r6, r5 - lsls r0, 3 - adds r4, r0, r7 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C8A64 - cmp r0, 0x1 - beq _080C8A94 - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r5, 0 - bl SwitchTaskToFollowupFunc - b _080C8AC2 - .align 2, 0 -_080C8A60: .4byte gTasks -_080C8A64: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8AC2 - ldr r0, _080C8A8C @ =gContestPlayerMonIndex - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - ldr r1, _080C8A90 @ =gSharedMem + 0x19266 - adds r0, r1 - movs r1, 0x2 - bl sub_80C857C - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C8AC2 - .align 2, 0 -_080C8A8C: .4byte gContestPlayerMonIndex -_080C8A90: .4byte gSharedMem + 0x19266 -_080C8A94: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8AC2 - ldr r1, _080C8AC8 @ =gBlockRecvBuffer - ldr r3, _080C8ACC @ =gSharedMem + 0x19266 - movs r4, 0x80 - lsls r4, 1 - movs r2, 0x3 -_080C8AA8: - ldrh r0, [r1] - strh r0, [r3] - adds r1, r4 - adds r3, 0x1C - subs r2, 0x1 - cmp r2, 0 - bge _080C8AA8 - adds r1, r6, r5 - lsls r1, 3 - adds r1, r7 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_080C8AC2: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080C8AC8: .4byte gBlockRecvBuffer -_080C8ACC: .4byte gSharedMem + 0x19266 - thumb_func_end sub_80C8A38 - thumb_func_start sub_80C8AD0 sub_80C8AD0: @ 80C8AD0 push {r4,lr} diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 17b82388c..cef290adf 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -398,6 +398,60 @@ void sub_80C8938(u8 taskId) } } +void sub_80C89DC(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + case 0: + if (sub_8007ECC()) + { + sub_80C857C(&gContestPlayerMonIndex, sizeof(u8)); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + gTasks[taskId].data[0]++; + } + break; + } +} + +void sub_80C8A38(u8 taskId) +{ + int i; + + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + case 0: + if (sub_8007ECC()) + { + sub_80C857C(&sContestantStatus[gContestPlayerMonIndex].currMove, sizeof(u16)); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + *&sContestantStatus[i].currMove = gBlockRecvBuffer[i][0]; + } + gTasks[taskId].data[0]++; + } + break; + } +} + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From cbab0f740349cbeece60f2155537c2a9870d2318 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 20:24:02 -0500 Subject: sub_80C8AD0 --- asm/contest_link_80C857C.s | 198 -------------------------------------- include/contest.h | 5 + src/battle/contest_link_80C857C.c | 77 +++++++++++++++ src/debug/matsuda_debug_menu.c | 8 -- src/script_pokemon_util_80C4BF0.c | 12 --- 5 files changed, 82 insertions(+), 218 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 4285531f7..61117e28c 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,204 +5,6 @@ .text - thumb_func_start sub_80C8AD0 -sub_80C8AD0: @ 80C8AD0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _080C8AF8 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r1 - movs r3, 0x8 - ldrsh r0, [r2, r3] - adds r3, r1, 0 - cmp r0, 0xB - bls _080C8AEC - b _080C8C70 -_080C8AEC: - lsls r0, 2 - ldr r1, _080C8AFC @ =_080C8B00 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080C8AF8: .4byte gTasks -_080C8AFC: .4byte _080C8B00 - .align 2, 0 -_080C8B00: - .4byte _080C8B30 - .4byte _080C8B4C - .4byte _080C8B74 - .4byte _080C8B98 - .4byte _080C8BB0 - .4byte _080C8B74 - .4byte _080C8BD8 - .4byte _080C8BF0 - .4byte _080C8B74 - .4byte _080C8C18 - .4byte _080C8C30 - .4byte _080C8B74 -_080C8B30: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - bne _080C8B3C - b _080C8C7A -_080C8B3C: - ldr r0, _080C8B48 @ =gUnknown_02038678 - movs r1, 0x8 - bl sub_80C857C - b _080C8C4C - .align 2, 0 -_080C8B48: .4byte gUnknown_02038678 -_080C8B4C: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - bne _080C8B58 - b _080C8C7A -_080C8B58: - ldr r0, _080C8B68 @ =gUnknown_02038678 - ldr r1, _080C8B6C @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8B70 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x8 - b _080C8C48 - .align 2, 0 -_080C8B68: .4byte gUnknown_02038678 -_080C8B6C: .4byte gUnknown_0203869B -_080C8B70: .4byte gBlockRecvBuffer -_080C8B74: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r3 - ldrh r0, [r2, 0xA] - adds r1, r0, 0x1 - strh r1, [r2, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bgt _080C8B8C - b _080C8C7A -_080C8B8C: - movs r0, 0 - strh r0, [r2, 0xA] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _080C8C7A -_080C8B98: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8BAC @ =gUnknown_02038680 - movs r1, 0x8 - bl sub_80C857C - b _080C8C4C - .align 2, 0 -_080C8BAC: .4byte gUnknown_02038680 -_080C8BB0: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8BCC @ =gUnknown_02038680 - ldr r1, _080C8BD0 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8BD4 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x8 - b _080C8C48 - .align 2, 0 -_080C8BCC: .4byte gUnknown_02038680 -_080C8BD0: .4byte gUnknown_0203869B -_080C8BD4: .4byte gBlockRecvBuffer -_080C8BD8: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8BEC @ =gUnknown_02038688 - movs r1, 0x8 - bl sub_80C857C - b _080C8C4C - .align 2, 0 -_080C8BEC: .4byte gUnknown_02038688 -_080C8BF0: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8C0C @ =gUnknown_02038688 - ldr r1, _080C8C10 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8C14 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x8 - b _080C8C48 - .align 2, 0 -_080C8C0C: .4byte gUnknown_02038688 -_080C8C10: .4byte gUnknown_0203869B -_080C8C14: .4byte gBlockRecvBuffer -_080C8C18: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8C2C @ =gContestFinalStandings - movs r1, 0x4 - bl sub_80C857C - b _080C8C4C - .align 2, 0 -_080C8C2C: .4byte gContestFinalStandings -_080C8C30: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8C7A - ldr r0, _080C8C60 @ =gContestFinalStandings - ldr r1, _080C8C64 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8C68 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x4 -_080C8C48: - bl memcpy -_080C8C4C: - ldr r1, _080C8C6C @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _080C8C7A - .align 2, 0 -_080C8C60: .4byte gContestFinalStandings -_080C8C64: .4byte gUnknown_0203869B -_080C8C68: .4byte gBlockRecvBuffer -_080C8C6C: .4byte gTasks -_080C8C70: - movs r0, 0 - strh r0, [r2, 0x8] - adds r0, r4, 0 - bl SwitchTaskToFollowupFunc -_080C8C7A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80C8AD0 - thumb_func_start sub_80C8C80 sub_80C8C80: @ 80C8C80 push {r4,lr} diff --git a/include/contest.h b/include/contest.h index dfa0e38da..a15ca67e6 100644 --- a/include/contest.h +++ b/include/contest.h @@ -274,5 +274,10 @@ struct UnknownContestStruct6 extern u8 gContestPlayerMonIndex; extern u8 gIsLinkContest; extern u32 gContestRngValue; +extern s16 gUnknown_02038678[4]; +extern s16 gUnknown_02038680[4]; +extern u16 gUnknown_02038688[4]; +extern u8 gContestFinalStandings[4]; +extern u8 gUnknown_0203869B; #endif // GUARD_CONTEST_H diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index cef290adf..465bb0487 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -452,6 +452,83 @@ void sub_80C8A38(u8 taskId) } } +void sub_80C8AD0(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038678, sizeof gUnknown_02038678); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038678, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038678); + gTasks[taskId].data[0]++; + } + break; + case 2: + case 5: + case 8: + case 11: + if (gTasks[taskId].data[1]++ > 10) + { + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[0]++; + } + break; + case 3: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038680, sizeof gUnknown_02038680); + gTasks[taskId].data[0]++; + } + break; + case 4: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038680, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038680); + gTasks[taskId].data[0]++; + } + break; + case 6: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038688, sizeof gUnknown_02038688); + gTasks[taskId].data[0]++; + } + break; + case 7: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038688, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038688); + gTasks[taskId].data[0]++; + } + break; + case 9: + if (sub_8007ECC()) + { + sub_80C857C(gContestFinalStandings, sizeof gContestFinalStandings); + gTasks[taskId].data[0]++; + } + break; + case 10: + if (sub_80C85D8()) + { + memcpy(gContestFinalStandings, gBlockRecvBuffer[gUnknown_0203869B], sizeof gContestFinalStandings); + gTasks[taskId].data[0]++; + } + break; + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + } +} + asm(".section .text_de"); #if GERMAN diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c index da1937adb..15d28df09 100644 --- a/src/debug/matsuda_debug_menu.c +++ b/src/debug/matsuda_debug_menu.c @@ -19,13 +19,7 @@ extern u8 gUnknown_0203856C; extern s16 gUnknown_02038670[]; -extern s16 gUnknown_02038678[]; -extern s16 gUnknown_02038680[]; -extern u8 gContestFinalStandings[]; extern u8 gUnknown_02038694; -extern u8 gIsLinkContest; -extern u8 gUnknown_0203869B; -extern u8 gContestPlayerMonIndex; extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; @@ -40,8 +34,6 @@ extern u16 gBattle_BG3_Y; extern u8 (*gMenuCallback)(void); -extern bool8 gReceivedRemoteLinkPlayers; - static bool8 sub_80A9B78(void); static void sub_80A9BE4(u8 taskId); static void sub_80A9C98(u8); diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index e51bc3522..513f6ce2a 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -32,26 +32,14 @@ extern void sub_80C4698(u8 *, u8); extern struct SpriteTemplate gUnknown_02024E8C; -extern u8 gContestPlayerMonIndex; -extern u8 gIsLinkContest; -extern u8 gPlayerPartyCount; extern u8 gSelectedOrderFromParty[]; -extern u16 gSpecialVar_0x8004; -extern u16 gSpecialVar_0x8005; -extern u16 gSpecialVar_0x8006; - extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; -extern u16 gSpecialVar_Result; - -extern u32 gContestRngValue; extern u8 gUnknown_02038694; extern u8 gUnknown_0203856C; -extern u8 gContestFinalStandings[]; extern s16 gUnknown_02038670[]; -extern s16 gUnknown_02038678[]; void SetContestTrainerGfxIds(void) { -- cgit v1.2.3 From 399856bc7ead101718891712dd20dd85e138e640 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 20:30:31 -0500 Subject: sub_80C8C80 --- asm/contest_link_80C857C.s | 189 -------------------------------------- include/contest.h | 1 + src/battle/contest_link_80C857C.c | 77 ++++++++++++++++ 3 files changed, 78 insertions(+), 189 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index 61117e28c..a27a96253 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,195 +5,6 @@ .text - thumb_func_start sub_80C8C80 -sub_80C8C80: @ 80C8C80 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, _080C8CA8 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r1 - movs r3, 0x8 - ldrsh r0, [r2, r3] - adds r3, r1, 0 - cmp r0, 0xB - bls _080C8C9C - b _080C8E0C -_080C8C9C: - lsls r0, 2 - ldr r1, _080C8CAC @ =_080C8CB0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_080C8CA8: .4byte gTasks -_080C8CAC: .4byte _080C8CB0 - .align 2, 0 -_080C8CB0: - .4byte _080C8CE0 - .4byte _080C8CFC - .4byte _080C8D24 - .4byte _080C8D46 - .4byte _080C8D60 - .4byte _080C8D24 - .4byte _080C8D88 - .4byte _080C8DA0 - .4byte _080C8D24 - .4byte _080C8DB4 - .4byte _080C8DCC - .4byte _080C8D24 -_080C8CE0: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - bne _080C8CEC - b _080C8E16 -_080C8CEC: - ldr r0, _080C8CF8 @ =gSharedMem + 0x19260 - movs r1, 0x70 - bl sub_80C857C - b _080C8DE8 - .align 2, 0 -_080C8CF8: .4byte gSharedMem + 0x19260 -_080C8CFC: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - bne _080C8D08 - b _080C8E16 -_080C8D08: - ldr r0, _080C8D18 @ =gSharedMem + 0x19260 - ldr r1, _080C8D1C @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8D20 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x70 - b _080C8DE4 - .align 2, 0 -_080C8D18: .4byte gSharedMem + 0x19260 -_080C8D1C: .4byte gUnknown_0203869B -_080C8D20: .4byte gBlockRecvBuffer -_080C8D24: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r2, r0, r3 - ldrh r0, [r2, 0xA] - adds r1, r0, 0x1 - strh r1, [r2, 0xA] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - ble _080C8E16 - movs r0, 0 - strh r0, [r2, 0xA] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] - b _080C8E16 -_080C8D46: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8D5C @ =gSharedMem + 0x192D0 - movs r1, 0x14 - bl sub_80C857C - b _080C8DE8 - .align 2, 0 -_080C8D5C: .4byte gSharedMem + 0x192D0 -_080C8D60: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8D7C @ =gSharedMem + 0x192D0 - ldr r1, _080C8D80 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8D84 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x14 - b _080C8DE4 - .align 2, 0 -_080C8D7C: .4byte gSharedMem + 0x192D0 -_080C8D80: .4byte gUnknown_0203869B -_080C8D84: .4byte gBlockRecvBuffer -_080C8D88: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8D9C @ =gSharedMem + 0x19328 - movs r1, 0x4 - bl sub_80C857C - b _080C8DE8 - .align 2, 0 -_080C8D9C: .4byte gSharedMem + 0x19328 -_080C8DA0: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8DB0 @ =gSharedMem + 0x19328 - b _080C8DD8 - .align 2, 0 -_080C8DB0: .4byte gSharedMem + 0x19328 -_080C8DB4: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8DC8 @ =gUnknown_02038696 - movs r1, 0x4 - bl sub_80C857C - b _080C8DE8 - .align 2, 0 -_080C8DC8: .4byte gUnknown_02038696 -_080C8DCC: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8E16 - ldr r0, _080C8DFC @ =gUnknown_02038696 -_080C8DD8: - ldr r1, _080C8E00 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8E04 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x4 -_080C8DE4: - bl memcpy -_080C8DE8: - ldr r1, _080C8E08 @ =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] - b _080C8E16 - .align 2, 0 -_080C8DFC: .4byte gUnknown_02038696 -_080C8E00: .4byte gUnknown_0203869B -_080C8E04: .4byte gBlockRecvBuffer -_080C8E08: .4byte gTasks -_080C8E0C: - movs r0, 0 - strh r0, [r2, 0x8] - adds r0, r4, 0 - bl SwitchTaskToFollowupFunc -_080C8E16: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80C8C80 - .ifdef ENGLISH thumb_func_start sub_80C8E1C sub_80C8E1C: @ 80C8E1C diff --git a/include/contest.h b/include/contest.h index a15ca67e6..f8fceae79 100644 --- a/include/contest.h +++ b/include/contest.h @@ -278,6 +278,7 @@ extern s16 gUnknown_02038678[4]; extern s16 gUnknown_02038680[4]; extern u16 gUnknown_02038688[4]; extern u8 gContestFinalStandings[4]; +extern u8 gUnknown_02038696[4]; extern u8 gUnknown_0203869B; #endif // GUARD_CONTEST_H diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 465bb0487..84695fb37 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -529,6 +529,83 @@ void sub_80C8AD0(u8 taskId) } } +void sub_80C8C80(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + case 0: + if (sub_8007ECC()) + { + sub_80C857C(sContestantStatus, 4 * sizeof(struct ContestantStatus)); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + memcpy(sContestantStatus, gBlockRecvBuffer[gUnknown_0203869B], 4 * sizeof(struct ContestantStatus)); + gTasks[taskId].data[0]++; + } + break; + case 2: + case 5: + case 8: + case 11: + if (gTasks[taskId].data[1]++ > 10) + { + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[0]++; + } + break; + case 3: + if (sub_8007ECC()) + { + sub_80C857C(&shared192D0, sizeof shared192D0); + gTasks[taskId].data[0]++; + } + break; + case 4: + if (sub_80C85D8()) + { + memcpy(&shared192D0, gBlockRecvBuffer[gUnknown_0203869B], sizeof shared192D0); + gTasks[taskId].data[0]++; + } + break; + case 6: + if (sub_8007ECC()) + { + sub_80C857C(&shared19328, sizeof shared19328); + gTasks[taskId].data[0]++; + } + break; + case 7: + if (sub_80C85D8()) + { + memcpy(&shared19328, gBlockRecvBuffer[gUnknown_0203869B], sizeof shared19328); + gTasks[taskId].data[0]++; + } + break; + case 9: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038696, sizeof gUnknown_02038696); + gTasks[taskId].data[0]++; + } + break; + case 10: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038696, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038696); + gTasks[taskId].data[0]++; + } + break; + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + } +} + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From 765b2ffe3f7f49e49cc416a930a6e60ee265ce14 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 20:38:05 -0500 Subject: sub_80C8E1C --- asm/contest_link_80C857C.s | 210 -------------------------------------- src/battle/contest_link_80C857C.c | 68 ++++++++++++ 2 files changed, 68 insertions(+), 210 deletions(-) diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s index a27a96253..27cdfd2a3 100644 --- a/asm/contest_link_80C857C.s +++ b/asm/contest_link_80C857C.s @@ -5,216 +5,6 @@ .text -.ifdef ENGLISH - thumb_func_start sub_80C8E1C -sub_80C8E1C: @ 80C8E1C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, _080C8E4C @ =gTasks - mov r8, r0 - lsls r6, r5, 2 - adds r0, r6, r5 - lsls r7, r0, 3 - mov r1, r8 - adds r4, r7, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C8E50 - cmp r0, 0x1 - beq _080C8E7C - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r5, 0 - bl SwitchTaskToFollowupFunc - b _080C8EAE - .align 2, 0 -_080C8E4C: .4byte gTasks -_080C8E50: - ldr r1, _080C8E78 @ =gBlockSendBuffer - movs r0, 0x64 - strb r0, [r1] - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C8E70 - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8EAE - movs r0, 0x2 - bl sub_8007E9C -_080C8E70: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - b _080C8EAE - .align 2, 0 -_080C8E78: .4byte gBlockSendBuffer -_080C8E7C: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8EAE - ldr r1, _080C8EB8 @ =gBlockRecvBuffer - mov r0, r8 - adds r0, 0x12 - adds r2, r7, r0 - movs r4, 0x80 - lsls r4, 1 - movs r3, 0x3 -_080C8E94: - ldrh r0, [r1] - strh r0, [r2] - adds r1, r4 - adds r2, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _080C8E94 - adds r1, r6, r5 - lsls r1, 3 - add r1, r8 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_080C8EAE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_080C8EB8: .4byte gBlockRecvBuffer - thumb_func_end sub_80C8E1C -.else - thumb_func_start sub_80C8E1C -sub_80C8E1C: @ 80C8E1C - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r1, _080C8E40 @ =gTasks - lsls r4, r5, 2 - adds r0, r4, r5 - lsls r6, r0, 3 - adds r2, r6, r1 - movs r3, 0x8 - ldrsh r0, [r2, r3] - adds r7, r1, 0 - cmp r0, 0x1 - beq _080C8EB0 - cmp r0, 0x1 - bgt _080C8E44 - cmp r0, 0 - beq _080C8E4C - b _080C8EF8 - .align 2, 0 -_080C8E40: .4byte gTasks -_080C8E44: - cmp r0, 0x2 - beq _080C8EEC - cmp r0, 0x8 - bne _080C8EF8 -_080C8E4C: - ldr r1, _080C8E80 @ =gBlockSendBuffer - movs r0, 0x64 - strb r0, [r1] - bl GetMultiplayerId - lsls r0, 24 - cmp r0, 0 - bne _080C8E9A - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8F06 - ldr r0, _080C8E84 @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r4, r1, r0 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080C8E88 - movs r0, 0x3 - strh r0, [r4, 0x8] - b _080C8F06 - .align 2, 0 -_080C8E80: .4byte gBlockSendBuffer -_080C8E84: .4byte gTasks -_080C8E88: - movs r0, 0 - bl de_sub_80C9274 - movs r0, 0x2 - bl sub_8007E9C - movs r0, 0x1 - strh r0, [r4, 0x8] - b _080C8F06 -_080C8E9A: - movs r0, 0 - bl de_sub_80C9294 - ldr r0, _080C8EAC @ =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - b _080C8EDE - .align 2, 0 -_080C8EAC: .4byte gTasks -_080C8EB0: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8F06 - adds r1, r4, 0 - ldr r4, _080C8EE8 @ =gBlockRecvBuffer - adds r0, r7, 0 - adds r0, 0x12 - adds r2, r6, r0 - movs r6, 0x80 - lsls r6, 1 - movs r3, 0x3 -_080C8ECA: - ldrh r0, [r4] - strh r0, [r2] - adds r4, r6 - adds r2, 0x2 - subs r3, 0x1 - cmp r3, 0 - bge _080C8ECA - adds r1, r5 - lsls r1, 3 - adds r1, r7 -_080C8EDE: - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] - b _080C8F06 - .align 2, 0 -_080C8EE8: .4byte gBlockRecvBuffer -_080C8EEC: - movs r0, 0 - strh r0, [r2, 0x8] - adds r0, r5, 0 - bl SwitchTaskToFollowupFunc - b _080C8F06 -_080C8EF8: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r7 - ldrh r1, [r0, 0x8] - adds r1, 0x1 - strh r1, [r0, 0x8] -_080C8F06: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80C8E1C -.endif - thumb_func_start sub_80C8EBC sub_80C8EBC: @ 80C8EBC push {r4,lr} diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 84695fb37..f505fa658 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -606,6 +606,74 @@ void sub_80C8C80(u8 taskId) } } +void sub_80C8E1C(u8 taskId) +{ + int i; + + switch (gTasks[taskId].data[0]) + { +#if ENGLISH + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; +#elif GERMAN + case 8: +#endif + case 0: + gBlockSendBuffer[0] = 0x64; + if (GetMultiplayerId() == 0) + { + if (sub_8007ECC()) + { +#if GERMAN + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[0] = 3; + } + else + { + de_sub_80C9274(FALSE); +#endif + sub_8007E9C(2); +#if ENGLISH + gTasks[taskId].data[0]++; +#else + gTasks[taskId].data[0] = 1; + } +#endif + } + } + else + { +#if GERMAN + de_sub_80C9294(FALSE); +#endif + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + for (i = 0; i < MAX_LINK_PLAYERS; i++) + { + gTasks[taskId].data[5 + i] = gBlockRecvBuffer[i][0]; + } + gTasks[taskId].data[0]++; + } + break; +#if GERMAN + case 2: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + default: + gTasks[taskId].data[0]++; + break; +#endif + } +} + asm(".section .text_de"); #if GERMAN -- cgit v1.2.3 From c723b341c50df19f8951353a7efd4ab83bf56833 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 20:52:41 -0500 Subject: through sub_80C8F34 --- asm/contest_link_80C857C.s | 130 -------------------------------------- include/contest.h | 2 + ld_script.txt | 2 - src/battle/contest_link_80C857C.c | 60 ++++++++++++++++-- src/contest_ai.c | 1 - src/debug/matsuda_debug_menu.c | 1 - src/script_pokemon_util_80C4BF0.c | 1 - 7 files changed, 56 insertions(+), 141 deletions(-) delete mode 100644 asm/contest_link_80C857C.s diff --git a/asm/contest_link_80C857C.s b/asm/contest_link_80C857C.s deleted file mode 100644 index 27cdfd2a3..000000000 --- a/asm/contest_link_80C857C.s +++ /dev/null @@ -1,130 +0,0 @@ - .include "constants/gba_constants.inc" - .include "include/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_80C8EBC -sub_80C8EBC: @ 80C8EBC - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, _080C8EE4 @ =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C8EE8_B - cmp r0, 0x1 - beq _080C8F00 - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r2, 0 - bl SwitchTaskToFollowupFunc - b _080C8F22 - .align 2, 0 -_080C8EE4: .4byte gTasks -_080C8EE8_B: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8F22 - ldr r0, _080C8EFC @ =gUnknown_02038670 - movs r1, 0x8 - bl sub_80C857C - b _080C8F1C - .align 2, 0 -_080C8EFC: .4byte gUnknown_02038670 -_080C8F00: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8F22 - ldr r0, _080C8F28 @ =gUnknown_02038670 - ldr r1, _080C8F2C @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8F30 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x8 - bl memcpy -_080C8F1C: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_080C8F22: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080C8F28: .4byte gUnknown_02038670 -_080C8F2C: .4byte gUnknown_0203869B -_080C8F30: .4byte gBlockRecvBuffer - thumb_func_end sub_80C8EBC - - thumb_func_start sub_80C8F34 -sub_80C8F34: @ 80C8F34 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r1, _080C8F5C @ =gTasks - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - adds r4, r0, r1 - movs r1, 0x8 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080C8F60 - cmp r0, 0x1 - beq _080C8F78 - movs r0, 0 - strh r0, [r4, 0x8] - adds r0, r2, 0 - bl SwitchTaskToFollowupFunc - b _080C8F9A - .align 2, 0 -_080C8F5C: .4byte gTasks -_080C8F60: - bl sub_8007ECC - lsls r0, 24 - cmp r0, 0 - beq _080C8F9A - ldr r0, _080C8F74 @ =gUnknown_02038696 - movs r1, 0x4 - bl sub_80C857C - b _080C8F94 - .align 2, 0 -_080C8F74: .4byte gUnknown_02038696 -_080C8F78: - bl sub_80C85D8 - lsls r0, 24 - cmp r0, 0 - beq _080C8F9A - ldr r0, _080C8FA0 @ =gUnknown_02038696 - ldr r1, _080C8FA4 @ =gUnknown_0203869B - ldrb r1, [r1] - lsls r1, 8 - ldr r2, _080C8FA8 @ =gBlockRecvBuffer - adds r1, r2 - movs r2, 0x4 - bl memcpy -_080C8F94: - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] -_080C8F9A: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080C8FA0: .4byte gUnknown_02038696 -_080C8FA4: .4byte gUnknown_0203869B -_080C8FA8: .4byte gBlockRecvBuffer - thumb_func_end sub_80C8F34 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/contest.h b/include/contest.h index f8fceae79..b0bdd7f61 100644 --- a/include/contest.h +++ b/include/contest.h @@ -274,6 +274,8 @@ struct UnknownContestStruct6 extern u8 gContestPlayerMonIndex; extern u8 gIsLinkContest; extern u32 gContestRngValue; +extern u8 gUnknown_02038696[4]; +extern s16 gUnknown_02038670[4]; extern s16 gUnknown_02038678[4]; extern s16 gUnknown_02038680[4]; extern u16 gUnknown_02038688[4]; diff --git a/ld_script.txt b/ld_script.txt index 411d282d1..fc13444f1 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -170,8 +170,6 @@ SECTIONS { src/field/rotating_gate.o(.text); src/field/safari_zone.o(.text); src/battle/contest_link_80C857C.o(.text); - asm/contest_link_80C857C.o(.text); - src/battle/contest_link_80C857C.o(.text_de); src/field/item_use.o(.text); src/battle/anim/powder.o(.text); src/battle/anim/orbs.o(.text); diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index f505fa658..e85350aea 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -228,11 +228,11 @@ void sub_80C8734(u8 taskId) de_sub_80C9274(FALSE); #endif sub_8007E9C(2); -#if GERMAN - gTasks[taskId].data[0] = 1; - } -#else +#if ENGLISH gTasks[taskId].data[0]++; +#elif GERMAN + gTasks[taskId].data[0] = 1; + } #endif } } @@ -638,7 +638,7 @@ void sub_80C8E1C(u8 taskId) sub_8007E9C(2); #if ENGLISH gTasks[taskId].data[0]++; -#else +#elif GERMAN gTasks[taskId].data[0] = 1; } #endif @@ -674,7 +674,55 @@ void sub_80C8E1C(u8 taskId) } } -asm(".section .text_de"); +void sub_80C8EBC(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + case 0: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038670, sizeof gUnknown_02038670); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038670, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038670); + gTasks[taskId].data[0]++; + } + break; + } +} + +void sub_80C8F34(u8 taskId) +{ + switch (gTasks[taskId].data[0]) + { + default: + gTasks[taskId].data[0] = 0; + SwitchTaskToFollowupFunc(taskId); + break; + case 0: + if (sub_8007ECC()) + { + sub_80C857C(gUnknown_02038696, sizeof gUnknown_02038696); + gTasks[taskId].data[0]++; + } + break; + case 1: + if (sub_80C85D8()) + { + memcpy(gUnknown_02038696, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038696); + gTasks[taskId].data[0]++; + } + break; + } +} #if GERMAN diff --git a/src/contest_ai.c b/src/contest_ai.c index 66b387270..1e249083b 100644 --- a/src/contest_ai.c +++ b/src/contest_ai.c @@ -8,7 +8,6 @@ extern u8 AreMovesContestCombo(u16, u16); extern bool8 sub_80B214C(u8); extern bool8 Contest_IsMonsTurnDisabled(u8); -extern s16 gUnknown_02038670[]; extern u16 gSpecialVar_ContestCategory; extern u8 *gAIScriptPtr; diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c index 15d28df09..efd952ef7 100644 --- a/src/debug/matsuda_debug_menu.c +++ b/src/debug/matsuda_debug_menu.c @@ -18,7 +18,6 @@ #include "ewram.h" extern u8 gUnknown_0203856C; -extern s16 gUnknown_02038670[]; extern u8 gUnknown_02038694; extern u16 gSpecialVar_ContestCategory; extern u16 gSpecialVar_ContestRank; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index 513f6ce2a..02e66d313 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -39,7 +39,6 @@ extern u16 gSpecialVar_ContestRank; extern u8 gUnknown_02038694; extern u8 gUnknown_0203856C; -extern s16 gUnknown_02038670[]; void SetContestTrainerGfxIds(void) { -- cgit v1.2.3 From cc0d7a675d5fc85adac3bd94387c54e0eb507495 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 22 Jan 2018 21:01:33 -0500 Subject: Rename some static functions --- asm/contest_link_80C2020.s | 4 +- include/link.h | 2 +- src/battle/battle_2.c | 16 +++--- src/battle/contest_link_80C857C.c | 104 +++++++++++++++++++------------------- src/engine/link.c | 9 +--- src/engine/trade.c | 16 +++--- src/field/field_fadetransition.c | 2 +- src/rom3.c | 2 +- src/scene/berry_blender.c | 16 +++--- 9 files changed, 83 insertions(+), 88 deletions(-) diff --git a/asm/contest_link_80C2020.s b/asm/contest_link_80C2020.s index 8a0f096f0..891711bc5 100644 --- a/asm/contest_link_80C2020.s +++ b/asm/contest_link_80C2020.s @@ -657,7 +657,7 @@ sub_80C25C0: @ 80C25C0 push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - bl sub_8007ECC + bl IsLinkTaskFinished lsls r0, 24 cmp r0, 0 beq _080C25EC @@ -5778,7 +5778,7 @@ sub_80C4B5C: @ 80C4B5C ldrh r0, [r0] cmp r0, 0x1 bne _080C4B90 - bl sub_8007ECC + bl IsLinkTaskFinished lsls r0, 24 cmp r0, 0 beq _080C4B9E diff --git a/include/link.h b/include/link.h index 367add625..6581fdbba 100644 --- a/include/link.h +++ b/include/link.h @@ -167,7 +167,7 @@ u8 GetMultiplayerId(void); u8 bitmask_all_link_players_but_self(void); bool8 SendBlock(u8, void *, u16); bool8 sub_8007E9C(u8); -bool8 sub_8007ECC(void); +bool8 IsLinkTaskFinished(void); u8 GetBlockReceivedStatus(void); void ResetBlockReceivedFlags(void); void ResetBlockReceivedFlag(u8); diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index b00c35312..2ad2adb04 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -396,7 +396,7 @@ void sub_800EC9C(void) case 0: if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + if (gReceivedRemoteLinkPlayers != 0 && IsLinkTaskFinished()) { gBattleStruct->unk0 = 1; gBattleStruct->unk1 = 1; @@ -464,7 +464,7 @@ void sub_800EC9C(void) } break; case 2: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { SendBlock(bitmask_all_link_players_but_self(), gPlayerParty, sizeof(*gPlayerParty) * 2); gBattleCommunication[0]++; @@ -479,7 +479,7 @@ void sub_800EC9C(void) } break; case 4: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 2, sizeof(*gPlayerParty) * 2); gBattleCommunication[0]++; @@ -494,7 +494,7 @@ void sub_800EC9C(void) } break; case 6: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { SendBlock(bitmask_all_link_players_but_self(), gPlayerParty + 4, sizeof(*gPlayerParty) * 2); gBattleCommunication[0]++; @@ -579,7 +579,7 @@ void sub_800F104(void) switch (gBattleCommunication[0]) { case 0: - if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + if (gReceivedRemoteLinkPlayers != 0 && IsLinkTaskFinished()) { sub_800F02C(); SendBlock(bitmask_all_link_players_but_self(), gSharedMem, 0x60); @@ -639,7 +639,7 @@ void sub_800F298(void) switch (gBattleCommunication[0]) { case 0: - if (gReceivedRemoteLinkPlayers != 0 && sub_8007ECC()) + if (gReceivedRemoteLinkPlayers != 0 && IsLinkTaskFinished()) { gBattleStruct->unk0 = 1; gBattleStruct->unk1 = 1; @@ -732,7 +732,7 @@ void sub_800F298(void) break; case 2: step_2: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { SendBlock(bitmask_all_link_players_but_self(), ewram1D000, sizeof(struct Pokemon) * 2); gBattleCommunication[0]++; @@ -795,7 +795,7 @@ void sub_800F298(void) } break; case 4: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { SendBlock(bitmask_all_link_players_but_self(), ewram1D000 + 2, sizeof(struct Pokemon)); gBattleCommunication[0]++; diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index e85350aea..01088bf53 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -10,17 +10,17 @@ static void sub_80C8644(u8 taskId); static void sub_80C8660(u8 taskId); #if GERMAN -void de_sub_80C9274(bool32 arg0); -void de_sub_80C9294(bool32 arg0); +static void de_sub_80C9274(bool32 arg0); +static void de_sub_80C9294(bool32 arg0); #endif -void sub_80C857C(const void *data, u16 size) +static void SendBlockToAllOpponents(const void *data, u16 size) { memcpy(eContestLinkSendBuffer, data, size); SendBlock(bitmask_all_link_players_but_self(), eContestLinkSendBuffer, size); } -bool8 sub_80C85AC(u8 who) +static bool8 HasPlayerReceivedBlock(u8 who) { u8 flag = 1 << who; if (!(GetBlockReceivedStatus() & flag)) @@ -29,7 +29,7 @@ bool8 sub_80C85AC(u8 who) return TRUE; } -bool8 sub_80C85D8(void) +static bool8 HaveAllPlayersReceivedBlock(void) { int i; @@ -214,7 +214,7 @@ void sub_80C8734(u8 taskId) #endif case 0: if (GetMultiplayerId() == 0) { - if (sub_8007ECC()) { + if (IsLinkTaskFinished()) { #if GERMAN if (gTasks[taskId].data[0] == 0) { @@ -246,7 +246,7 @@ void sub_80C8734(u8 taskId) } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { for (i = 0; i < MAX_LINK_PLAYERS; i++) { @@ -308,9 +308,9 @@ void sub_80C88AC(u8 taskId) case 0: if (GetMultiplayerId() == 0) { - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(&gRngValue, sizeof(u32)); + SendBlockToAllOpponents(&gRngValue, sizeof(u32)); gTasks[taskId].data[0]++; } } @@ -320,7 +320,7 @@ void sub_80C88AC(u8 taskId) } break; case 1: - if (sub_80C85AC(0)) + if (HasPlayerReceivedBlock(0)) { memcpy(&gRngValue, gBlockRecvBuffer[0], sizeof(u32)); memcpy(&gContestRngValue, gBlockRecvBuffer[0], sizeof(u32)); @@ -348,7 +348,7 @@ void sub_80C8938(u8 taskId) gBlockSendBuffer[0] = gTasks[taskId].data[9]; if (GetMultiplayerId() == 0) { - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { #if GERMAN if (gTasks[taskId].data[0] == 0) @@ -377,7 +377,7 @@ void sub_80C8938(u8 taskId) } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { for (i = 0; i < MAX_LINK_PLAYERS; i++) { @@ -407,14 +407,14 @@ void sub_80C89DC(u8 taskId) SwitchTaskToFollowupFunc(taskId); break; case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(&gContestPlayerMonIndex, sizeof(u8)); + SendBlockToAllOpponents(&gContestPlayerMonIndex, sizeof(u8)); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { gTasks[taskId].data[0]++; } @@ -433,14 +433,14 @@ void sub_80C8A38(u8 taskId) SwitchTaskToFollowupFunc(taskId); break; case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(&sContestantStatus[gContestPlayerMonIndex].currMove, sizeof(u16)); + SendBlockToAllOpponents(&sContestantStatus[gContestPlayerMonIndex].currMove, sizeof(u16)); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { for (i = 0; i < MAX_LINK_PLAYERS; i++) { @@ -457,14 +457,14 @@ void sub_80C8AD0(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038678, sizeof gUnknown_02038678); + SendBlockToAllOpponents(gUnknown_02038678, sizeof gUnknown_02038678); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038678, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038678); gTasks[taskId].data[0]++; @@ -481,42 +481,42 @@ void sub_80C8AD0(u8 taskId) } break; case 3: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038680, sizeof gUnknown_02038680); + SendBlockToAllOpponents(gUnknown_02038680, sizeof gUnknown_02038680); gTasks[taskId].data[0]++; } break; case 4: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038680, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038680); gTasks[taskId].data[0]++; } break; case 6: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038688, sizeof gUnknown_02038688); + SendBlockToAllOpponents(gUnknown_02038688, sizeof gUnknown_02038688); gTasks[taskId].data[0]++; } break; case 7: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038688, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038688); gTasks[taskId].data[0]++; } break; case 9: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gContestFinalStandings, sizeof gContestFinalStandings); + SendBlockToAllOpponents(gContestFinalStandings, sizeof gContestFinalStandings); gTasks[taskId].data[0]++; } break; case 10: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gContestFinalStandings, gBlockRecvBuffer[gUnknown_0203869B], sizeof gContestFinalStandings); gTasks[taskId].data[0]++; @@ -534,14 +534,14 @@ void sub_80C8C80(u8 taskId) switch (gTasks[taskId].data[0]) { case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(sContestantStatus, 4 * sizeof(struct ContestantStatus)); + SendBlockToAllOpponents(sContestantStatus, 4 * sizeof(struct ContestantStatus)); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(sContestantStatus, gBlockRecvBuffer[gUnknown_0203869B], 4 * sizeof(struct ContestantStatus)); gTasks[taskId].data[0]++; @@ -558,42 +558,42 @@ void sub_80C8C80(u8 taskId) } break; case 3: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(&shared192D0, sizeof shared192D0); + SendBlockToAllOpponents(&shared192D0, sizeof shared192D0); gTasks[taskId].data[0]++; } break; case 4: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(&shared192D0, gBlockRecvBuffer[gUnknown_0203869B], sizeof shared192D0); gTasks[taskId].data[0]++; } break; case 6: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(&shared19328, sizeof shared19328); + SendBlockToAllOpponents(&shared19328, sizeof shared19328); gTasks[taskId].data[0]++; } break; case 7: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(&shared19328, gBlockRecvBuffer[gUnknown_0203869B], sizeof shared19328); gTasks[taskId].data[0]++; } break; case 9: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038696, sizeof gUnknown_02038696); + SendBlockToAllOpponents(gUnknown_02038696, sizeof gUnknown_02038696); gTasks[taskId].data[0]++; } break; case 10: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038696, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038696); gTasks[taskId].data[0]++; @@ -624,7 +624,7 @@ void sub_80C8E1C(u8 taskId) gBlockSendBuffer[0] = 0x64; if (GetMultiplayerId() == 0) { - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { #if GERMAN if (gTasks[taskId].data[0] == 0) @@ -653,7 +653,7 @@ void sub_80C8E1C(u8 taskId) } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { for (i = 0; i < MAX_LINK_PLAYERS; i++) { @@ -683,14 +683,14 @@ void sub_80C8EBC(u8 taskId) SwitchTaskToFollowupFunc(taskId); break; case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038670, sizeof gUnknown_02038670); + SendBlockToAllOpponents(gUnknown_02038670, sizeof gUnknown_02038670); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038670, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038670); gTasks[taskId].data[0]++; @@ -708,14 +708,14 @@ void sub_80C8F34(u8 taskId) SwitchTaskToFollowupFunc(taskId); break; case 0: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { - sub_80C857C(gUnknown_02038696, sizeof gUnknown_02038696); + SendBlockToAllOpponents(gUnknown_02038696, sizeof gUnknown_02038696); gTasks[taskId].data[0]++; } break; case 1: - if (sub_80C85D8()) + if (HaveAllPlayersReceivedBlock()) { memcpy(gUnknown_02038696, gBlockRecvBuffer[gUnknown_0203869B], sizeof gUnknown_02038696); gTasks[taskId].data[0]++; @@ -726,7 +726,7 @@ void sub_80C8F34(u8 taskId) #if GERMAN -void de_sub_80C9274(bool32 arg0) +static void de_sub_80C9274(bool32 arg0) { if (deUnkValue2 == 1) { @@ -737,7 +737,7 @@ void de_sub_80C9274(bool32 arg0) } } -void de_sub_80C9294(bool32 arg0) +static void de_sub_80C9294(bool32 arg0) { if (deUnkValue2 == 1) { diff --git a/src/engine/link.c b/src/engine/link.c index ec94295d7..33037b817 100644 --- a/src/engine/link.c +++ b/src/engine/link.c @@ -898,14 +898,9 @@ bool8 sub_8007E9C(u8 a1) } } -bool8 sub_8007ECC(void) +bool8 IsLinkTaskFinished(void) { - u8 retVal = FALSE; - - if (!gLinkCallback) - retVal = TRUE; - - return retVal; + return gLinkCallback == NULL; } u8 GetBlockReceivedStatus(void) diff --git a/src/engine/trade.c b/src/engine/trade.c index 4dc27ea6f..4bd39c4ef 100644 --- a/src/engine/trade.c +++ b/src/engine/trade.c @@ -1711,7 +1711,7 @@ static bool8 sub_8048D44(void) gUnknown_03004824->unk_0075 ++; break; case 1: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { if (GetBlockReceivedStatus() == 0) { @@ -2210,7 +2210,7 @@ static void sub_8049A20(void) { sub_804AADC(3, 1); gUnknown_03004824->linkData[0] = 0xbbbb; - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { Trade_SendData(gUnknown_03004824); } @@ -2239,7 +2239,7 @@ static void sub_8049AC0(void) else { sub_804AADC(3, 1); - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gUnknown_03004824->linkData[0] = 0xbbcc; Trade_SendData(gUnknown_03004824); @@ -4632,7 +4632,7 @@ static void sub_804BB78(void) switch (gUnknown_03004828->unk_00bd) { case 1: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { Trade_SendData(gUnknown_03004828); gUnknown_03004828->unk_00bd ++; @@ -5534,13 +5534,13 @@ static void sub_804DC88(void) gMain.state = 101; gUnknown_03004828->unk_00c0 = 0; } - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gMain.state = 2; } break; case 101: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gMain.state = 2; } @@ -5592,7 +5592,7 @@ static void sub_804DC88(void) gMain.state = 42; break; case 42: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { sub_8125E04(); gSoftResetDisabled = FALSE; @@ -5607,7 +5607,7 @@ static void sub_804DC88(void) } break; case 6: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { BeginNormalPaletteFade(-1, 0, 0, 16, 0); gMain.state ++; diff --git a/src/field/field_fadetransition.c b/src/field/field_fadetransition.c index ad1cd4a59..d68be3b36 100644 --- a/src/field/field_fadetransition.c +++ b/src/field/field_fadetransition.c @@ -146,7 +146,7 @@ void sub_8080A5C(u8 taskId) task->data[0]++; break; case 1: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { pal_fill_for_map_transition(); task->data[0]++; diff --git a/src/rom3.c b/src/rom3.c index 713713162..000de8356 100644 --- a/src/rom3.c +++ b/src/rom3.c @@ -463,7 +463,7 @@ void sub_800C1A8(u8 taskId) } break; case 4: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { var = (ewram14004arr(0, gTasks[taskId].data[15]) | (ewram14004arr(1, gTasks[taskId].data[15]) << 8)); gTasks[taskId].data[13] = 1; diff --git a/src/scene/berry_blender.c b/src/scene/berry_blender.c index 7567899ae..2cb68ccf1 100644 --- a/src/scene/berry_blender.c +++ b/src/scene/berry_blender.c @@ -1163,7 +1163,7 @@ static void sub_804E9F8(void) gBerryBlenderData->framesToWait = 0; break; case 9: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { ResetBlockReceivedFlags(); if (GetMultiplayerId() == 0) @@ -1215,7 +1215,7 @@ static void sub_804E9F8(void) } break; case 13: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gBerryBlenderData->field_0++; sub_8051414(&gBerryBlenderData->field_168); @@ -1257,7 +1257,7 @@ static void sub_804E9F8(void) gBerryBlenderData->field_0++; break; case 20: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { sub_8007E24(); gBerryBlenderData->field_0++; @@ -2506,7 +2506,7 @@ static void sub_8050954(void) case 3: if (/*multiplayerID != 0*/ GetMultiplayerId() != 0) gBerryBlenderData->field_6F++; - else if (sub_8007ECC()) + else if (IsLinkTaskFinished()) { gBerryBlenderData->field_1BC = gBerryBlenderData->gameFrameTime; gBerryBlenderData->field_1C0 = gBerryBlenderData->max_RPM; @@ -2646,7 +2646,7 @@ bool8 sub_8050CE8(void) gBerryBlenderData->framesToWait = 0; break; case 1: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gBerryBlenderData->field_1C4++; gSoftResetDisabled = TRUE; @@ -2665,7 +2665,7 @@ bool8 sub_8050CE8(void) } break; case 4: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { if (sub_8125E6C()) gBerryBlenderData->field_1C4 = 5; @@ -2752,7 +2752,7 @@ static void sub_8050E30(void) gBerryBlenderData->field_6F++; break; case 6: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { gBerryBlenderData->framesToWait = 0; gBerryBlenderData->field_6F++; @@ -2771,7 +2771,7 @@ static void sub_8050E30(void) sub_80084A4(); break; case 9: - if (sub_8007ECC()) + if (IsLinkTaskFinished()) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gBerryBlenderData->field_6F++; -- cgit v1.2.3 From 76c40aac928d139afa725182ab291436f809258d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 23 Jan 2018 08:09:31 -0500 Subject: Clean up English/German blocks (fingers crossed) --- src/battle/contest_link_80C857C.c | 46 ++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/battle/contest_link_80C857C.c b/src/battle/contest_link_80C857C.c index 01088bf53..4fb236294 100644 --- a/src/battle/contest_link_80C857C.c +++ b/src/battle/contest_link_80C857C.c @@ -215,24 +215,22 @@ void sub_80C8734(u8 taskId) case 0: if (GetMultiplayerId() == 0) { if (IsLinkTaskFinished()) { -#if GERMAN +#if ENGLISH + memcpy(gBlockSendBuffer, gContestMons + gContestPlayerMonIndex, sizeof(struct ContestPokemon)); + sub_8007E9C(2); + gTasks[taskId].data[0]++; +#elif GERMAN if (gTasks[taskId].data[0] == 0) { gTasks[taskId].data[0] = 3; } else { -#endif - memcpy(gBlockSendBuffer, gContestMons + gContestPlayerMonIndex, sizeof(struct ContestPokemon)); -#if GERMAN - de_sub_80C9274(FALSE); -#endif - sub_8007E9C(2); -#if ENGLISH - gTasks[taskId].data[0]++; -#elif GERMAN - gTasks[taskId].data[0] = 1; - } + memcpy(gBlockSendBuffer, gContestMons + gContestPlayerMonIndex, sizeof(struct ContestPokemon)); + de_sub_80C9274(FALSE); + sub_8007E9C(2); + gTasks[taskId].data[0] = 1; + } #endif } } @@ -350,7 +348,10 @@ void sub_80C8938(u8 taskId) { if (IsLinkTaskFinished()) { -#if GERMAN +#if ENGLISH + sub_8007E9C(2); + gTasks[taskId].data[0]++; +#elif GERMAN if (gTasks[taskId].data[0] == 0) { gTasks[taskId].data[0] = 3; @@ -358,11 +359,7 @@ void sub_80C8938(u8 taskId) else { de_sub_80C9274(TRUE); -#endif - sub_8007E9C(2); -#if ENGLISH - gTasks[taskId].data[0]++; -#elif GERMAN + sub_8007E9C(2); gTasks[taskId].data[0] = 1; } #endif @@ -626,7 +623,10 @@ void sub_80C8E1C(u8 taskId) { if (IsLinkTaskFinished()) { -#if GERMAN +#if ENGLISH + sub_8007E9C(2); + gTasks[taskId].data[0]++; +#elif GERMAN if (gTasks[taskId].data[0] == 0) { gTasks[taskId].data[0] = 3; @@ -634,12 +634,8 @@ void sub_80C8E1C(u8 taskId) else { de_sub_80C9274(FALSE); -#endif - sub_8007E9C(2); -#if ENGLISH - gTasks[taskId].data[0]++; -#elif GERMAN - gTasks[taskId].data[0] = 1; + sub_8007E9C(2); + gTasks[taskId].data[0] = 1; } #endif } -- cgit v1.2.3 From e8bddb83db39e4352fd2f44d21e761de1174451d Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Fri, 26 Jan 2018 22:10:05 -0800 Subject: fix build --- src/battle/anim/guard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/battle/anim/guard.c b/src/battle/anim/guard.c index 01cf07e39..254160109 100644 --- a/src/battle/anim/guard.c +++ b/src/battle/anim/guard.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle.h" #include "battle_anim.h" #include "rom_8077ABC.h" -- cgit v1.2.3