diff options
author | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2018-01-24 23:38:36 -0500 |
---|---|---|
committer | ProjectRevoTPP <projectrevotpp@hotmail.com> | 2018-01-24 23:38:36 -0500 |
commit | 4ba3b9f592e2a23bb57e59ca41acd0cfb27a0d84 (patch) | |
tree | 4009791ef38c7f47f8ba14a1ba17ea3e75058544 | |
parent | 4327bee485510b424cbf28e450d90ff50e6fe78b (diff) | |
parent | 4e54b9f65e93e84887ef81b726a187bbf3197530 (diff) |
merge
74 files changed, 1325 insertions, 1374 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. @@ -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) - -$(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 -$(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_ewram.ld: sym_ewram.txt - cd $(BUILD_DIR) && ../../$(RAMSCRGEN) ewram_data ../../sym_ewram.txt $(GAME_LANGUAGE) >sym_ewram.ld + cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) ../../$(LIBGCC) ../../$(LIBC) -o ../../$@ + +$(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) $< | sed -e "s#tools/#../../tools/#g" > $@ $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) $(CPP) $(CPPFLAGS) $< -o $(BUILD_DIR)/$*.i 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/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/evobjmv.txt b/common_syms/field/evobjmv.txt deleted file mode 100644 index 32d8b1915..000000000 --- a/common_syms/field/evobjmv.txt +++ /dev/null @@ -1 +0,0 @@ -gMapObjects 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/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 --- a/common_syms/scene/cute_sketch.txt +++ /dev/null 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/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 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/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/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 267650a2a..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 { @@ -23,21 +31,17 @@ 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]; - s8 unknown_6C0; - s8 unknown_6C1; - u8 unknown_6C2; - u8 unknown_6C3; - u16 unknown_6C4; - u8 unknown_6C6; - u8 unknown_6C7; - u8 unknown_6C8; - u8 unknown_6C9; + u8 gammaShifts[19][32]; + u8 altGammaShifts[19][32]; + s8 gammaIndex; + s8 gammaTargetIndex; + u8 gammaStepDelay; + u8 gammaStepFrameCounter; + u16 fadeDestColor; + u8 palProcessingState; + u8 fadeScreenCounter; + bool8 readyForInit; + u8 taskId; u8 unknown_6CA; u8 unknown_6CB; u16 initStep; @@ -45,9 +49,9 @@ struct Weather u8 currWeather; u8 nextWeather; u8 weatherGfxLoaded; - u8 unknown_6D3; - u8 unknown_6D4; - u8 unknown_6D5; + bool8 weatherChangeComplete; + u8 weatherPicSpritePalIndex; + u8 altGammaSpritePalIndex; u16 unknown_6D6; u8 unknown_6D8; u8 unknown_6D9; @@ -70,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; @@ -104,8 +108,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,42 +117,35 @@ 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 sub_807CDC4(void); -u8 sub_807CE24(void); -u8 sub_807CE7C(void); -void nullsub_39(void); +void SetWeatherScreenFadeOut(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 fade_screen(u8, u8); +enum +{ + FADE_FROM_BLACK, + FADE_TO_BLACK, + FADE_FROM_WHITE, + FADE_TO_WHITE, +}; + +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); // ... -void sub_807DE68(void); -// ... void PlayRainSoundEffect(void); // ... void SetSav1Weather(u32); @@ -158,10 +155,18 @@ 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); +void ResetPreservedPalettesInWeather(void); +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/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/ld_script.sed b/ld_script.sed deleted file mode 100644 index b91542b6f..000000000 --- a/ld_script.sed +++ /dev/null @@ -1,14 +0,0 @@ -/<EWRAM>/ { - r sym_ewram.ld - d -} - -/<BSS>/ { - r sym_bss.ld - d -} - -/<COMMON>/ { - r sym_common.ld - d -} diff --git a/ld_script.txt b/ld_script.txt index b7b825362..e6624de0a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -9,7 +9,7 @@ SECTIONS { ewram (NOLOAD) : ALIGN(4) { -<EWRAM> + INCLUDE "sym_ewram.ld" . = 0x40000; } @@ -20,13 +20,13 @@ SECTIONS { ALIGN(4) { /* .bss starts at 0x3000000 */ -<BSS> + INCLUDE "sym_bss.ld" /* .bss.code starts at 0x3000F60 */ src/libs/m4a_2.o(.bss.code); /* COMMON starts at 0x3001760 */ -<COMMON> + INCLUDE "sym_common.ld" tools/agbcc/lib/libc.a:sbrkr.o(COMMON); end = .; . = 0x8000; 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/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/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/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/decoration.c b/src/field/decoration.c index e1604cfa1..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() == 1) + 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() == 1) + 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() == 1) + 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_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 384da4bd2..deddf790e 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -405,7 +405,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; } @@ -541,7 +541,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); } @@ -554,13 +554,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) { @@ -1089,7 +1089,7 @@ void task00_8084310(u8 taskId) task = &gTasks[taskId]; if (!task->data[0]) { - if (!sub_807D770()) + if (!IsWeatherNotFadingIn()) { return; } @@ -1189,7 +1189,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]++; } @@ -1811,7 +1811,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; @@ -2044,7 +2044,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(); @@ -2197,7 +2197,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 3e1fb1c13..2889ee954 100644 --- a/src/field/field_effect_helpers.c +++ b/src/field/field_effect_helpers.c @@ -93,7 +93,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); } } @@ -105,7 +105,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 4350f7960..17d47aecf 100644 --- a/src/field/field_fadetransition.c +++ b/src/field/field_fadetransition.c @@ -43,18 +43,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(); } @@ -64,10 +64,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); } } @@ -365,7 +365,7 @@ bool32 sub_8080E64(void) bool32 sub_8080E70(void) { - if (sub_807D770() == TRUE) + if (IsWeatherNotFadingIn() == TRUE) return TRUE; else return FALSE; @@ -482,7 +482,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 3053c58cb..ceb23b629 100644 --- a/src/field/field_weather.c +++ b/src/field/field_weather.c @@ -13,7 +13,13 @@ #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)) + +enum { + GAMMA_NONE, + GAMMA_NORMAL, + GAMMA_ALT, +}; struct RGBColor { @@ -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,18 @@ static const u8 *const sCompressedDroughtPalettes[] = // this file produces the same result as accessing gWeather directly. struct Weather *const gWeatherPtr = &gWeather; +static bool8 LightenSpritePaletteInFog(u8); +static void BuildGammaShiftTables(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); @@ -108,10 +126,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); @@ -130,7 +148,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}, @@ -138,54 +156,58 @@ 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}, }; -void (*const gUnknown_083970B8[])(void) = +void (*const gWeatherPalStateFuncs[])(void) = { - sub_807CC24, - 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 }; -const u8 gUnknown_083970C8[] = +// 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"); @@ -193,13 +215,14 @@ const u16 gUnknown_083970E8[] = INCBIN_U16("graphics/weather/0.gbapal"); void StartWeather(void) { u8 index; + if (!FuncIsActiveTask(Task_WeatherMain)) { index = AllocSpritePalette(0x1200); CpuCopy32(gUnknown_083970E8, &gPlttBufferUnfaded[0x100 + index * 16], 32); - sub_807CB10(); - gWeatherPtr->unknown_6D5 = index; - gWeatherPtr->unknown_6D4 = AllocSpritePalette(0x1201); + BuildGammaShiftTables(); + gWeatherPtr->altGammaSpritePalIndex = index; + gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(0x1201); gWeatherPtr->rainSpriteCount = 0; gWeatherPtr->unknown_6D8 = 0; gWeatherPtr->cloudSpritesCreated = 0; @@ -210,49 +233,53 @@ 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); } } -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->weatherChangeComplete = FALSE; + 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->unknown_6C8 = 1; + gWeatherPtr->currWeather = weather; + gWeatherPtr->nextWeather = weather; + 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; @@ -265,24 +292,26 @@ 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->unknown_6C3 = 0; - gWeatherPtr->unknown_6C6 = 0; + gWeatherPtr->gammaStepFrameCounter = 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) { - gWeatherPtr->unknown_6C1 = 0; - gWeatherPtr->unknown_6C2 = 0; + gWeatherPtr->gammaTargetIndex = 0; + gWeatherPtr->gammaStepDelay = 0; } void None_Main(void) @@ -294,7 +323,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]; @@ -307,15 +339,15 @@ 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; (u16)v2 <= 0x1f; v2++) + for (v2 = 0; v2 < 32; v2++) { v4 = v2 << 8; if (v0 == 0) @@ -334,88 +366,86 @@ 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; - } } } } } } -void sub_807CC24(void) +// When the weather is changing, it gradually updates the palettes +// towards the desired gamma shift. +static void UpdateWeatherGammaShift(void) { - if (gWeatherPtr->unknown_6C0 == gWeatherPtr->unknown_6C1) + if (gWeatherPtr->gammaIndex == gWeatherPtr->gammaTargetIndex) { - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } 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--; + + 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: case WEATHER_RAIN_MED: case WEATHER_RAIN_HEAVY: case WEATHER_SNOW: - case WEATHER_DARK: - if (sub_807CDC4() == 0) + case WEATHER_SHADE: + if (FadeInScreen_RainShowShade() == FALSE) { - gWeatherPtr->unknown_6C0 = 3; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->gammaIndex = 3; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_DROUGHT: - if (sub_807CE24() == 0) + if (FadeInScreen_Drought() == FALSE) { - gWeatherPtr->unknown_6C0 = -6; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->gammaIndex = -6; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_FOG_1: - if (sub_807CE7C() == 0) + if (FadeInScreen_Fog1() == FALSE) { - gWeatherPtr->unknown_6C0 = 0; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->gammaIndex = 0; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; case WEATHER_ASH: @@ -425,71 +455,78 @@ void sub_807CCAC(void) default: if (!gPaletteFade.active) { - gWeatherPtr->unknown_6C0 = gWeatherPtr->unknown_6C1; - gWeatherPtr->unknown_6C6 = 3; + gWeatherPtr->gammaIndex = gWeatherPtr->gammaTargetIndex; + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_IDLE; } break; } } -u8 sub_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) { - sub_807CEBC(0, 0x20, 3); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, 3); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - sub_807D1BC(0, 0x20, 3, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); - return 1; + + ApplyGammaShiftWithBlend(0, 32, 3, 16 - gWeatherPtr->fadeScreenCounter, gWeatherPtr->fadeDestColor); + return TRUE; } -u8 sub_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) { - sub_807CEBC(0, 0x20, -6); - gWeatherPtr->unknown_6C7 = 0x10; - return 0; + ApplyGammaShift(0, 32, -6); + gWeatherPtr->fadeScreenCounter = 16; + return FALSE; } - sub_807D304(-6, 0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); - return 1; -} -u8 sub_807CE7C(void) -{ - if (gWeatherPtr->unknown_6C7 == 0x10) - return 0; - ++gWeatherPtr->unknown_6C7; - sub_807D424(0x10 - gWeatherPtr->unknown_6C7, gWeatherPtr->unknown_6C4); - 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 sub_807CEBC(u8 a, u8 b, s8 c) +static void DoNothing(void) +{ } + +static void ApplyGammaShift(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; } @@ -497,25 +534,27 @@ void sub_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; } } @@ -524,39 +563,45 @@ void sub_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++; } } @@ -564,93 +609,100 @@ void sub_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 sub_807D1BC(u8 a1, u8 a2, s8 c, u8 d, u16 e) +static void ApplyGammaShiftWithBlend(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 sub_807D304(s8 a, u8 coeff, u16 c) +void ApplyDroughtGammaShiftWithBlend(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; @@ -664,14 +716,14 @@ void sub_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; } @@ -679,33 +731,30 @@ void sub_807D304(s8 a, u8 coeff, u16 c) } } -bool8 sub_807D574(u8); - -void sub_807D424(u8 a, u16 b) +void ApplyFogBlend(u8 blendCoeff, 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 rBlend; + u8 gBlend; + u8 bBlend; + u16 curPalIndex; + + BlendPalette(0, 0x100, blendCoeff, blendColor); + color = *(struct RGBColor *)&blendColor; + rBlend = color.r; + gBlend = color.g; + bBlend = color.b; + + for (curPalIndex = 16; curPalIndex < 32; curPalIndex++) { - if (sub_807D574(r4)) + if (LightenSpritePaletteInFog(curPalIndex)) { - u16 r12 = (r4 + 1) * 16; - u16 r6 = r4 * 16; + u16 palEnd = (curPalIndex + 1) * 16; + u16 palOffset = curPalIndex * 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,88 +763,88 @@ 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 += ((rBlend - r) * blendCoeff) >> 4; + g += ((gBlend - g) * blendCoeff) >> 4; + b += ((bBlend - b) * blendCoeff) >> 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(curPalIndex * 16, 16, blendCoeff, blendColor); } - r4++; } } -void sub_807D540(u8 a) +static void MarkFogSpritePalToLighten(u8 paletteIndex) { - if (gWeatherPtr->unknown_6FA < 6) + if (gWeatherPtr->lightenedFogSpritePalsCount < 6) { - gWeatherPtr->unknown_6F4[gWeatherPtr->unknown_6FA] = a; - gWeatherPtr->unknown_6FA++; + gWeatherPtr->lightenedFogSpritePals[gWeatherPtr->lightenedFogSpritePalsCount] = paletteIndex; + gWeatherPtr->lightenedFogSpritePalsCount++; } } -bool8 sub_807D574(u8 a) +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] == a) + if (gWeatherPtr->lightenedFogSpritePals[i] == paletteIndex) return TRUE; } + return FALSE; } -void sub_807D5BC(s8 a) +void sub_807D5BC(s8 gammaIndex) { - if (gWeatherPtr->unknown_6C6 == 3) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - sub_807CEBC(0, 32, a); - gWeatherPtr->unknown_6C0 = a; + ApplyGammaShift(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) + if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { - gWeatherPtr->unknown_6C6 = 0; - gWeatherPtr->unknown_6C0 = a; - gWeatherPtr->unknown_6C1 = b; - gWeatherPtr->unknown_6C3 = 0; - gWeatherPtr->unknown_6C2 = c; - sub_807D5BC(a); + gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_CHANGING_WEATHER; + gWeatherPtr->gammaIndex = gammaIndex; + gWeatherPtr->gammaTargetIndex = gammaTargetIndex; + gWeatherPtr->gammaStepFrameCounter = 0; + gWeatherPtr->gammaStepDelay = gammaStepDelay; + sub_807D5BC(gammaIndex); } } -void fade_screen(u8 a, u8 delay) +void FadeScreen(u8 mode, u8 delay) { u32 fadeColor; - u32 r1; - u32 r2; + bool8 fadeOut; + bool8 useWeatherPal; - switch (a) + switch (mode) { - case 0: + case FADE_FROM_BLACK: fadeColor = 0; - r1 = 0; + fadeOut = FALSE; break; - case 2: + case FADE_FROM_WHITE: fadeColor = 0xFFFF; - r1 = 0; + fadeOut = FALSE; break; - case 1: + case FADE_TO_BLACK: fadeColor = 0; - r1 = 1; + fadeOut = TRUE; break; - case 3: + case FADE_TO_WHITE: fadeColor = 0xFFFF; - r1 = 1; + fadeOut = TRUE; break; default: return; @@ -808,145 +857,149 @@ 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 (fadeOut) { - if (r2 != 0) + 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->unknown_6C4 = fadeColor; - if (r2 != 0) - gWeatherPtr->unknown_6C7 = 0; + gWeatherPtr->fadeDestColor = fadeColor; + if (useWeatherPal) + 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 a) +void UpdateSpritePaletteWithWeather(u8 spritePaletteIndex) { - u16 r4 = 16 + a; + 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(r4); - r4 *= 16; + MarkFogSpritePalToLighten(paletteIndex); + paletteIndex *= 16; for (i = 0; i < 16; i++) - gPlttBufferFaded[r4 + i] = gWeatherPtr->unknown_6C4; + gPlttBufferFaded[paletteIndex + i] = gWeatherPtr->fadeDestColor; } break; - case 2: - r4 *= 16; - CpuFastCopy(gPlttBufferFaded + r4, gPlttBufferUnfaded + r4, 32); - BlendPalette(r4, 16, gPaletteFade.y, gPaletteFade.blendColor); + 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) { - sub_807CEBC(r4, 1, gWeatherPtr->unknown_6C0); + ApplyGammaShift(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 ApplyWeatherGammaShiftToPal(u8 paletteIndex) { - sub_807CEBC(a, 1, gWeatherPtr->unknown_6C0); + 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); } -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) @@ -1008,8 +1061,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) @@ -1018,13 +1071,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++; @@ -1054,48 +1107,48 @@ 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; } } -u8 weather_get_current(void) +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; @@ -1109,7 +1162,8 @@ void SetRainStrengthFromSoundEffect(u16 sndEff) default: return; } - PlaySE(sndEff); + + PlaySE(soundEffect); } } @@ -1133,29 +1187,29 @@ 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 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 b7b5d85c7..09d98b7b1 100644 --- a/src/field/field_weather_effects.c +++ b/src/field/field_weather_effects.c @@ -74,10 +74,7 @@ static const struct SpriteTemplate sCloudSpriteTemplate = .callback = sub_807E0F4, }; -extern void sub_807D5BC(s8 a); -extern void sub_807D8C0(const u16 *palette); -extern void sub_807D9A8(void); -extern bool8 sub_807D9C8(void); +extern void sub_807D5BC(s8 gammaIndex); extern void sub_807DA14(void); extern void sub_807DA4C(void); extern void Weather_SetTargetBlendCoeffs(u8 a, u8 b, int c); @@ -91,8 +88,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 +156,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) @@ -184,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); @@ -236,8 +233,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); @@ -254,15 +251,15 @@ 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: - sub_807D9A8(); + ResetDroughtWeatherPaletteLoading(); gWeatherPtr->initStep++; break; case 2: - if (sub_807D9C8() == FALSE) + if (LoadDroughtWeatherPalettes() == FALSE) gWeatherPtr->initStep++; break; case 3: @@ -368,8 +365,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 +882,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 +1071,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 +1099,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); } @@ -1139,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; @@ -1213,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; @@ -1296,8 +1293,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 +1443,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 +1631,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 +1832,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; @@ -2015,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); @@ -2113,26 +2110,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; } @@ -2322,7 +2319,7 @@ void SetSav1WeatherFromCurrMapHeader(void) void SetWeather(u32 weather) { SetSav1Weather(weather); - DoWeatherEffect(GetSav1Weather()); + ChangeWeather(GetSav1Weather()); } void SetWeather_Unused(u32 weather) @@ -2333,7 +2330,7 @@ void SetWeather_Unused(u32 weather) void DoCurrentWeather(void) { - DoWeatherEffect(GetSav1Weather()); + ChangeWeather(GetSav1Weather()); } void sub_8080750(void) diff --git a/src/field/item_menu.c b/src/field/item_menu.c index 28b360e78..d0c3f598b 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 a5b091f0a..a0fbb13b2 100644 --- a/src/field/item_use.c +++ b/src/field/item_use.c @@ -99,7 +99,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 cff67d02e..dcfa72cbb 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -588,7 +588,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(); @@ -609,8 +609,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++) + 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 fd5620a76..44863edb2 100644 --- a/src/field/scrcmd.c +++ b/src/field/scrcmd.c @@ -625,7 +625,7 @@ bool8 IsPaletteNotActive(void) bool8 ScrCmd_fadescreen(struct ScriptContext *ctx) { - fade_screen(ScriptReadByte(ctx), 0); + FadeScreen(ScriptReadByte(ctx), 0); SetupNativeScript(ctx, IsPaletteNotActive); return TRUE; } @@ -635,7 +635,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 65be76b81..a87c859b7 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 43b0c29c2..161b5d6a0 100644 --- a/src/field/start_menu.c +++ b/src/field/start_menu.c @@ -328,7 +328,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/field/tv.c b/src/field/tv.c index 79c4716cb..786320eba 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/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 2e596883f..2f2a03a2f 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; @@ -357,7 +358,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; @@ -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++) diff --git a/sym_bss.txt b/sym_bss.txt index a5beb2df4..4eef91a5f 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/evobjmv.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/evobjmv.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_common.txt b/sym_common.txt index 99b6c7674..25fe0e6bc 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -1,240 +1,315 @@ - .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/evobjmv.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" +#define SYMBOL(name, size) \ + . = ALIGN (((size) > 16) ? 16 : (size)); \ + . = ALIGN(4); \ + name = .; \ + . += size; + + +// main.c +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) + +// sprite.c +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) + +// string_util.c +SYMBOL(gUnknownStringVar, 16) + +// link.c +SYMBOL(word_3002910, 8) +SYMBOL(gLinkDebugValue1, 4) +SYMBOL(localLinkPlayerBlock, 60) +SYMBOL(gLinkErrorOccurred, 4) +. += 0x4; +SYMBOL(gLinkDebugValue2, 4) +. += 0x4; +#ifdef GERMAN +SYMBOL(deUnkValue1, 4) +SYMBOL(deUnkValue2, 4) +#endif +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; +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) +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; +SYMBOL(gPreBattleCallback1, 4) +gBattleMainFunc = .; +. += 0xC; +gBattleResults = .; +. += 0x1C; +// Why is this not aligned? +gUnknown_030042FC = .; +. += 0x1A; +gUnknown_03004316 = .; +. += 0xE; +gLeveledUpInBattle = .; +. += 0xC; +SYMBOL(gBattleBankFunc, 16) +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) + +// evobjmv.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); +gFieldItemUseCallback = .; +. += 0x10; +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) +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) + +// 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) +SYMBOL(gDamagedSaveSectors, 4) +SYMBOL(gSaveCounter, 4) +SYMBOL(gFastSaveSection, 4) +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) +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) + +// m4a_2.c +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) + +// agb_flash.c +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) 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); |