diff --git a/Makefile b/Makefile index 73e94205f..edb1a67d5 100644 --- a/Makefile +++ b/Makefile @@ -150,12 +150,20 @@ ifneq (,$(MAKECMDGOALS)) endif endif +.SHELLSTATUS ?= 0 + ifeq ($(SETUP_PREREQS),1) # If set on: Default target or a rule requiring a scan # Forcibly execute `make tools` since we need them for what we are doing. - $(call infoshell, $(MAKE) -f make_tools.mk) + $(foreach line, $(shell $(MAKE) -f make_tools.mk | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) + ifneq ($(.SHELLSTATUS),0) + $(error Errors occurred while building tools. See error messages above for more details) + endif # Oh and also generate mapjson sources before we use `SCANINC`. - $(call infoshell, $(MAKE) generated) + $(foreach line, $(shell $(MAKE) generated | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) + ifneq ($(.SHELLSTATUS),0) + $(error Errors occurred while generating map-related sources. See error messages above for more details) + endif endif # Collect sources @@ -237,7 +245,10 @@ include spritesheet_rules.mk include json_data_rules.mk include audio_rules.mk +# NOTE: Tools must have been built prior (FIXME) +# so you can't really call this rule directly generated: $(AUTO_GEN_TARGETS) + @: # Silence the "Nothing to be done for `generated'" message, which some people were confusing for an error. %.s: ; %.png: ; @@ -252,8 +263,6 @@ generated: $(AUTO_GEN_TARGETS) %.lz: % ; $(GFX) $< $@ %.rl: % ; $(GFX) $< $@ -# NOTE: Tools must have been built prior (FIXME) -generated: tools $(AUTO_GEN_TARGETS) clean-generated: @rm -f $(AUTO_GEN_TARGETS) @echo "rm -f " @@ -288,71 +297,52 @@ endif # As a side effect, they're evaluated immediately instead of when the rule is invoked. # It doesn't look like $(shell) can be deferred so there might not be a better way (Icedude_907: there is soon). -# For C dependencies. -# Args: $1 = Output file without extension (build/assets/src/data), $2 = Input file (src/data.c) -define C_DEP -$(call C_DEP_IMPL,$1,$2,$1) -endef -# Internal implementation details. -# $1: Output file without extension, $2 input file, $3 temp path (if keeping) -define C_DEP_IMPL -$1.o: $2 +$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c ifneq ($(KEEP_TEMPS),1) - @echo "$$(CC1) -o $$@ $$<" - @$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) -i $$< charmap.txt | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ - + @echo "$(CC1) -o $@ $<" + @$(CPP) $(CPPFLAGS) $< | $(PREPROC) -i $< charmap.txt | $(CC1) $(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $(AS) $(ASFLAGS) -o $@ - else - @$$(CPP) $$(CPPFLAGS) $$< -o $3.i - @$$(PREPROC) $3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $3.s - @echo -e ".text\n\t.align\t2, 0 @ Don't pad with nop\n" >> $3.s - $$(AS) $$(ASFLAGS) -o $$@ $3.s + @$(CPP) $(CPPFLAGS) $< -o $*.i + @$(PREPROC) $*.i charmap.txt | $(CC1) $(CFLAGS) -o $*.s + @echo -e ".text\n\t.align\t2, 0\n" >> $*.s + $(AS) $(ASFLAGS) -o $@ $*.s endif -$1.d: $2 - $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $2 + +$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.c + $(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I tools/agbcc/include $< + ifneq ($(NODEP),1) -$1.o: $1.d --include $1.d -endif -endef - -# Create generic rules if no dependency scanning, else create the real rules -ifeq ($(NODEP),1) -$(eval $(call C_DEP,$(C_BUILDDIR)/%,$(C_SUBDIR)/%.c)) -else -$(foreach src,$(C_SRCS),$(eval $(call C_DEP,$(OBJ_DIR)/$(basename $(src)),$(src)))) +-include $(addprefix $(OBJ_DIR)/,$(C_SRCS:.c=.d)) endif -# Similar methodology for Assembly files -# $1: Output path without extension, $2: Input file (`*.s`) -define ASM_DEP -$1.o: $2 - $$(AS) $$(ASFLAGS) -o $$@ $$< -$(call ASM_SCANINC,$1,$2) -endef -# As above but first doing a preprocessor pass -define ASM_DEP_PREPROC -$1.o: $2 - $$(PREPROC) $$< charmap.txt | $$(CPP) $(INCLUDE_SCANINC_ARGS) - | $$(PREPROC) -ie $$< charmap.txt | $$(AS) $$(ASFLAGS) -o $$@ -$(call ASM_SCANINC,$1,$2) -endef +$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s + $(AS) $(ASFLAGS) -o $@ $< + +$(ASM_BUILDDIR)/%.d: $(ASM_SUBDIR)/%.s + $(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $< -define ASM_SCANINC ifneq ($(NODEP),1) -$1.o: $1.d -$1.d: $2 - $(SCANINC) -M $1.d $(INCLUDE_SCANINC_ARGS) -I "" $2 --include $1.d +-include $(addprefix $(OBJ_DIR)/,$(ASM_SRCS:.s=.d)) endif -endef -# Dummy rules or real rules -ifeq ($(NODEP),1) -$(eval $(call ASM_DEP,$(ASM_BUILDDIR)/%,$(ASM_SUBDIR)/%.s)) -$(eval $(call ASM_DEP_PREPROC,$(C_BUILDDIR)/%,$(C_SUBDIR)/%.s)) -$(eval $(call ASM_DEP_PREPROC,$(DATA_ASM_BUILDDIR)/%,$(DATA_ASM_SUBDIR)/%.s)) -else -$(foreach src, $(ASM_SRCS), $(eval $(call ASM_DEP,$(src:%.s=$(OBJ_DIR)/%),$(src)))) -$(foreach src, $(C_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)/%),$(src)))) -$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call ASM_DEP_PREPROC,$(src:%.s=$(OBJ_DIR)/%),$(src)))) +$(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s + $(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@ + +$(C_BUILDDIR)/%.d: $(C_SUBDIR)/%.s + $(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $< + +ifneq ($(NODEP),1) +-include $(addprefix $(OBJ_DIR)/,$(C_ASM_SRCS:.s=.d)) +endif + +$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s + $(PREPROC) $< charmap.txt | $(CPP) $(INCLUDE_SCANINC_ARGS) - | $(PREPROC) -ie $< charmap.txt | $(AS) $(ASFLAGS) -o $@ + +$(DATA_ASM_BUILDDIR)/%.d: $(DATA_ASM_SUBDIR)/%.s + $(SCANINC) -M $@ $(INCLUDE_SCANINC_ARGS) -I "" $< + +ifneq ($(NODEP),1) +-include $(addprefix $(OBJ_DIR)/,$(REGULAR_DATA_ASM_SRCS:.s=.d)) endif $(OBJ_DIR)/sym_bss.ld: sym_bss.txt @@ -376,8 +366,10 @@ endif # Final rules # Elf from object files +LDFLAGS = -Map ../../$(MAP) $(ELF): $(LD_SCRIPT) $(LD_SCRIPT_DEPS) $(OBJS) @cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat + @echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../../$< --print-memory-usage -o ../../$@ | cat" $(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent # Builds the rom from the elf file diff --git a/common_syms/AgbRfu_LinkManager.txt b/common_syms/AgbRfu_LinkManager.txt deleted file mode 100644 index 7ff8cd53d..000000000 --- a/common_syms/AgbRfu_LinkManager.txt +++ /dev/null @@ -1 +0,0 @@ -lman diff --git a/common_syms/agb_flash.txt b/common_syms/agb_flash.txt deleted file mode 100644 index cb421ec80..000000000 --- a/common_syms/agb_flash.txt +++ /dev/null @@ -1,10 +0,0 @@ -gFlashTimeoutFlag -PollFlashStatus -WaitForFlashWrite -ProgramFlashSector -gFlash -ProgramFlashByte -gFlashNumRemainingBytes -EraseFlashChip -EraseFlashSector -gFlashMaxTime diff --git a/common_syms/battle_anim_special.txt b/common_syms/battle_anim_special.txt deleted file mode 100644 index 5e2e8b3ff..000000000 --- a/common_syms/battle_anim_special.txt +++ /dev/null @@ -1,3 +0,0 @@ -gMonShrinkDuration -gMonShrinkDelta -gMonShrinkDistance diff --git a/common_syms/battle_controller_pokedude.txt b/common_syms/battle_controller_pokedude.txt deleted file mode 100644 index c96cab771..000000000 --- a/common_syms/battle_controller_pokedude.txt +++ /dev/null @@ -1 +0,0 @@ -gPokedudeBattlerStates diff --git a/common_syms/battle_main.txt b/common_syms/battle_main.txt deleted file mode 100644 index f6f02c48d..000000000 --- a/common_syms/battle_main.txt +++ /dev/null @@ -1,9 +0,0 @@ -gPreBattleCallback1 -gBattleMainFunc -gBattleResults -gLeveledUpInBattle -gBattlerControllerFuncs -gHealthboxSpriteIds -gMultiUsePlayerCursor -gNumberOfMovesToChoose -gBattleControllerData diff --git a/common_syms/berry_fix_program.txt b/common_syms/berry_fix_program.txt deleted file mode 100644 index f04247492..000000000 --- a/common_syms/berry_fix_program.txt +++ /dev/null @@ -1,4 +0,0 @@ -gMultibootStart -gMultibootStatus -gMultibootSize -gMultibootParam diff --git a/common_syms/bg.txt b/common_syms/bg.txt deleted file mode 100644 index 0a3c3aecc..000000000 --- a/common_syms/bg.txt +++ /dev/null @@ -1 +0,0 @@ -gWindowTileAutoAllocEnabled diff --git a/common_syms/cable_club.txt b/common_syms/cable_club.txt deleted file mode 100644 index 9cdf633b5..000000000 --- a/common_syms/cable_club.txt +++ /dev/null @@ -1 +0,0 @@ -UnusedVarNeededToMatch diff --git a/common_syms/ereader_screen.txt b/common_syms/ereader_screen.txt deleted file mode 100644 index 2189eedbc..000000000 --- a/common_syms/ereader_screen.txt +++ /dev/null @@ -1 +0,0 @@ -gEReaderData diff --git a/common_syms/event_data.txt b/common_syms/event_data.txt deleted file mode 100644 index 6d9f585d7..000000000 --- a/common_syms/event_data.txt +++ /dev/null @@ -1 +0,0 @@ -gLastQuestLogStoredFlagOrVarIdx diff --git a/common_syms/evolution_scene.txt b/common_syms/evolution_scene.txt deleted file mode 100644 index 137cd3e05..000000000 --- a/common_syms/evolution_scene.txt +++ /dev/null @@ -1 +0,0 @@ -gCB2_AfterEvolution diff --git a/common_syms/fame_checker.txt b/common_syms/fame_checker.txt deleted file mode 100644 index c23bd9a2a..000000000 --- a/common_syms/fame_checker.txt +++ /dev/null @@ -1,2 +0,0 @@ -gFameChecker_ListMenuTemplate -gIconDescriptionBoxIsOpen diff --git a/common_syms/field_camera.txt b/common_syms/field_camera.txt deleted file mode 100644 index 02301ce23..000000000 --- a/common_syms/field_camera.txt +++ /dev/null @@ -1,3 +0,0 @@ -gFieldCamera -gTotalCameraPixelOffsetY -gTotalCameraPixelOffsetX diff --git a/common_syms/field_control_avatar.txt b/common_syms/field_control_avatar.txt deleted file mode 100644 index c243b56ec..000000000 --- a/common_syms/field_control_avatar.txt +++ /dev/null @@ -1 +0,0 @@ -gFieldInputRecord diff --git a/common_syms/field_specials.txt b/common_syms/field_specials.txt deleted file mode 100644 index 04599f921..000000000 --- a/common_syms/field_specials.txt +++ /dev/null @@ -1,2 +0,0 @@ -sFieldSpecialsListMenuTemplate -sFieldSpecialsListMenuScrollBuffer diff --git a/common_syms/fieldmap.txt b/common_syms/fieldmap.txt deleted file mode 100644 index dedf055bd..000000000 --- a/common_syms/fieldmap.txt +++ /dev/null @@ -1 +0,0 @@ -VMap diff --git a/common_syms/help_system.txt b/common_syms/help_system.txt deleted file mode 100644 index 20475eeb9..000000000 --- a/common_syms/help_system.txt +++ /dev/null @@ -1,2 +0,0 @@ -gHelpSystemState -gHelpContextIdBackup diff --git a/common_syms/help_system_util.txt b/common_syms/help_system_util.txt deleted file mode 100644 index af59733d4..000000000 --- a/common_syms/help_system_util.txt +++ /dev/null @@ -1 +0,0 @@ -gHelpSystemEnabled diff --git a/common_syms/image_processing_effects.txt b/common_syms/image_processing_effects.txt deleted file mode 100644 index 134f7e88b..000000000 --- a/common_syms/image_processing_effects.txt +++ /dev/null @@ -1,10 +0,0 @@ -gCanvasColumnStart -gCanvasPixels -gCanvasRowEnd -gCanvasHeight -gCanvasColumnEnd -gCanvasRowStart -gCanvasMonPersonality -gCanvasWidth -gCanvasPalette -gCanvasPaletteStart diff --git a/common_syms/librfu_rfu.txt b/common_syms/librfu_rfu.txt deleted file mode 100644 index 4b742dcd2..000000000 --- a/common_syms/librfu_rfu.txt +++ /dev/null @@ -1,5 +0,0 @@ -gRfuSlotStatusUNI -gRfuSlotStatusNI -gRfuLinkStatus -gRfuStatic -gRfuFixed diff --git a/common_syms/librfu_sio32id.txt b/common_syms/librfu_sio32id.txt deleted file mode 100644 index 97395e84b..000000000 --- a/common_syms/librfu_sio32id.txt +++ /dev/null @@ -1 +0,0 @@ -gRfuSIO32Id diff --git a/common_syms/librfu_stwi.txt b/common_syms/librfu_stwi.txt deleted file mode 100644 index a1f773553..000000000 --- a/common_syms/librfu_stwi.txt +++ /dev/null @@ -1 +0,0 @@ -gSTWIStatus diff --git a/common_syms/link.txt b/common_syms/link.txt deleted file mode 100644 index 4118d1eb4..000000000 --- a/common_syms/link.txt +++ /dev/null @@ -1,35 +0,0 @@ -gLinkPartnersHeldKeys -gLinkDebugSeed -gLocalLinkPlayerBlock -gLinkErrorOccurred -gLinkDebugFlags -gLinkFiller1 -gRemoteLinkPlayersNotReceived -gBlockReceivedStatus -gLinkFiller2 -gLinkHeldKeys -gRecvCmds -gLinkStatus -gLinkDummy1 -gLinkDummy2 -gReadyToExitStandby -gReadyToCloseLink -gReadyCloseLinkType -gSuppressLinkErrorMessage -gWirelessCommType -gSavedLinkPlayerCount -gSendCmd -gSavedMultiplayerId -gReceivedRemoteLinkPlayers -gLinkTestBGInfo -gLinkCallback -gShouldAdvanceLinkState -gLinkTestBlockChecksums -gBlockRequestType -gLinkFiller3 -gLinkFiller4 -gLinkFiller5 -gLastSendQueueCount -gLink -gLastRecvQueueCount -gLinkSavedIme diff --git a/common_syms/link_rfu_2.txt b/common_syms/link_rfu_2.txt deleted file mode 100644 index 3a84c23bf..000000000 --- a/common_syms/link_rfu_2.txt +++ /dev/null @@ -1,3 +0,0 @@ -gHostRfuGameData -gRfu -gHostRfuUsername diff --git a/common_syms/list_menu.txt b/common_syms/list_menu.txt deleted file mode 100644 index ed5343618..000000000 --- a/common_syms/list_menu.txt +++ /dev/null @@ -1,2 +0,0 @@ -gListMenuOverride -gMultiuseListMenuTemplate diff --git a/common_syms/load_save.txt b/common_syms/load_save.txt deleted file mode 100644 index 2d3d9b802..000000000 --- a/common_syms/load_save.txt +++ /dev/null @@ -1,4 +0,0 @@ -gFlashMemoryPresent -gSaveBlock1Ptr -gSaveBlock2Ptr -gPokemonStoragePtr diff --git a/common_syms/m4a.txt b/common_syms/m4a.txt deleted file mode 100644 index 6e7b3c93e..000000000 --- a/common_syms/m4a.txt +++ /dev/null @@ -1,12 +0,0 @@ -gSoundInfo -gPokemonCrySongs -gPokemonCryMusicPlayers -gMPlayJumpTable -gCgbChans -gPokemonCryTracks -gPokemonCrySong -gMPlayInfo_BGM -gMPlayInfo_SE1 -gMPlayInfo_SE2 -gMPlayMemAccArea -gMPlayInfo_SE3 diff --git a/common_syms/main.txt b/common_syms/main.txt deleted file mode 100644 index b1f274b58..000000000 --- a/common_syms/main.txt +++ /dev/null @@ -1,12 +0,0 @@ -gKeyRepeatStartDelay -gLinkTransferringData -gMain -gKeyRepeatContinueDelay -gSoftResetDisabled -gIntrTable -sVcountAfterSound -gLinkVSyncDisabled -IntrMain_Buffer -sVcountAtIntr -sVcountBeforeSound -gPcmDmaCounter diff --git a/common_syms/overworld.txt b/common_syms/overworld.txt deleted file mode 100644 index e2aec44b1..000000000 --- a/common_syms/overworld.txt +++ /dev/null @@ -1,8 +0,0 @@ -gBGTilemapBuffers1 -gBGTilemapBuffers2 -gBGTilemapBuffers3 -gFieldCallback -gFieldCallback2 -gHeldKeyCodeToSend -gLocalLinkPlayerId -gFieldLinkPlayerCount diff --git a/common_syms/party_menu.txt b/common_syms/party_menu.txt deleted file mode 100644 index 6ed37392c..000000000 --- a/common_syms/party_menu.txt +++ /dev/null @@ -1 +0,0 @@ -gItemUseCB diff --git a/common_syms/quest_log.txt b/common_syms/quest_log.txt deleted file mode 100644 index e5e3ec49c..000000000 --- a/common_syms/quest_log.txt +++ /dev/null @@ -1,4 +0,0 @@ -gQuestLogPlaybackState -sMaxActionsInScene -gQuestLogFieldInput -sCurSceneActions diff --git a/common_syms/random.txt b/common_syms/random.txt deleted file mode 100644 index 794439ea5..000000000 --- a/common_syms/random.txt +++ /dev/null @@ -1 +0,0 @@ -gRngValue diff --git a/common_syms/save.txt b/common_syms/save.txt deleted file mode 100644 index 8b2ecc95a..000000000 --- a/common_syms/save.txt +++ /dev/null @@ -1,12 +0,0 @@ -gLastWrittenSector -gLastSaveCounter -gLastKnownGoodSector -gDamagedSaveSectors -gSaveCounter -gSaveDataBufferPtr -gIncrementalSectorId -gSaveUnusedVar -gSaveFileStatus -gGameContinueCallback -gRamSaveSectorLocations -gSaveAttemptStatus diff --git a/common_syms/save_failed_screen.txt b/common_syms/save_failed_screen.txt deleted file mode 100644 index caab09b26..000000000 --- a/common_syms/save_failed_screen.txt +++ /dev/null @@ -1 +0,0 @@ -sIsInSaveFailedScreen diff --git a/common_syms/scrcmd.txt b/common_syms/scrcmd.txt deleted file mode 100644 index bfc21e41f..000000000 --- a/common_syms/scrcmd.txt +++ /dev/null @@ -1,2 +0,0 @@ -sQuestLogScriptContextPtr -gSelectedObjectEvent diff --git a/common_syms/sound.txt b/common_syms/sound.txt deleted file mode 100644 index 0f6f2fc75..000000000 --- a/common_syms/sound.txt +++ /dev/null @@ -1 +0,0 @@ -gDisableMusic diff --git a/common_syms/sprite.txt b/common_syms/sprite.txt deleted file mode 100644 index 627c01c0d..000000000 --- a/common_syms/sprite.txt +++ /dev/null @@ -1,2 +0,0 @@ -gOamMatrixAllocBitmap -gReservedSpritePaletteCount diff --git a/common_syms/task.txt b/common_syms/task.txt deleted file mode 100644 index 6601bd11b..000000000 --- a/common_syms/task.txt +++ /dev/null @@ -1 +0,0 @@ -gTasks diff --git a/common_syms/text.txt b/common_syms/text.txt deleted file mode 100644 index dbaaa0b49..000000000 --- a/common_syms/text.txt +++ /dev/null @@ -1 +0,0 @@ -gTextFlags diff --git a/common_syms/text_printer.txt b/common_syms/text_printer.txt deleted file mode 100644 index 38452e46d..000000000 --- a/common_syms/text_printer.txt +++ /dev/null @@ -1,2 +0,0 @@ -gFonts -gGlyphInfo diff --git a/common_syms/window.txt b/common_syms/window.txt deleted file mode 100644 index 0371083ce..000000000 --- a/common_syms/window.txt +++ /dev/null @@ -1,2 +0,0 @@ -gWindowClearTile -gWindowBgTilemapBuffers diff --git a/include/constants/.gitignore b/include/constants/.gitignore index 87f4babc6..ff77d833c 100644 --- a/include/constants/.gitignore +++ b/include/constants/.gitignore @@ -1,4 +1,5 @@ # Will be moved to build/ eventually map_groups.h layouts.h +region_map_sections.h map_event_ids.h diff --git a/include/constants/region_map_sections.h b/include/constants/region_map_sections.h deleted file mode 100644 index 4fa9378f5..000000000 --- a/include/constants/region_map_sections.h +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef GUARD_CONSTANTS_REGION_MAP_SECTIONS_H -#define GUARD_CONSTANTS_REGION_MAP_SECTIONS_H - -#define MAPSEC_LITTLEROOT_TOWN 0x00 -#define MAPSEC_OLDALE_TOWN 0x01 -#define MAPSEC_DEWFORD_TOWN 0x02 -#define MAPSEC_LAVARIDGE_TOWN 0x03 -#define MAPSEC_FALLARBOR_TOWN 0x04 -#define MAPSEC_VERDANTURF_TOWN 0x05 -#define MAPSEC_PACIFIDLOG_TOWN 0x06 -#define MAPSEC_PETALBURG_CITY 0x07 -#define MAPSEC_SLATEPORT_CITY 0x08 -#define MAPSEC_MAUVILLE_CITY 0x09 -#define MAPSEC_RUSTBORO_CITY 0x0A -#define MAPSEC_FORTREE_CITY 0x0B -#define MAPSEC_LILYCOVE_CITY 0x0C -#define MAPSEC_MOSSDEEP_CITY 0x0D -#define MAPSEC_SOOTOPOLIS_CITY 0x0E -#define MAPSEC_EVER_GRANDE_CITY 0x0F -#define MAPSEC_ROUTE_101 0x10 -#define MAPSEC_ROUTE_102 0x11 -#define MAPSEC_ROUTE_103 0x12 -#define MAPSEC_ROUTE_104 0x13 -#define MAPSEC_ROUTE_105 0x14 -#define MAPSEC_ROUTE_106 0x15 -#define MAPSEC_ROUTE_107 0x16 -#define MAPSEC_ROUTE_108 0x17 -#define MAPSEC_ROUTE_109 0x18 -#define MAPSEC_ROUTE_110 0x19 -#define MAPSEC_ROUTE_111 0x1A -#define MAPSEC_ROUTE_112 0x1B -#define MAPSEC_ROUTE_113 0x1C -#define MAPSEC_ROUTE_114 0x1D -#define MAPSEC_ROUTE_115 0x1E -#define MAPSEC_ROUTE_116 0x1F -#define MAPSEC_ROUTE_117 0x20 -#define MAPSEC_ROUTE_118 0x21 -#define MAPSEC_ROUTE_119 0x22 -#define MAPSEC_ROUTE_120 0x23 -#define MAPSEC_ROUTE_121 0x24 -#define MAPSEC_ROUTE_122 0x25 -#define MAPSEC_ROUTE_123 0x26 -#define MAPSEC_ROUTE_124 0x27 -#define MAPSEC_ROUTE_125 0x28 -#define MAPSEC_ROUTE_126 0x29 -#define MAPSEC_ROUTE_127 0x2A -#define MAPSEC_ROUTE_128 0x2B -#define MAPSEC_ROUTE_129 0x2C -#define MAPSEC_ROUTE_130 0x2D -#define MAPSEC_ROUTE_131 0x2E -#define MAPSEC_ROUTE_132 0x2F -#define MAPSEC_ROUTE_133 0x30 -#define MAPSEC_ROUTE_134 0x31 -#define MAPSEC_UNDERWATER_124 0x32 -#define MAPSEC_UNDERWATER_125 0x33 -#define MAPSEC_UNDERWATER_126 0x34 -#define MAPSEC_UNDERWATER_127 0x35 -#define MAPSEC_UNDERWATER_SOOTOPOLIS 0x36 -#define MAPSEC_GRANITE_CAVE 0x37 -#define MAPSEC_MT_CHIMNEY 0x38 -#define MAPSEC_SAFARI_ZONE 0x39 -#define MAPSEC_BATTLE_FRONTIER 0x3A -#define MAPSEC_PETALBURG_WOODS 0x3B -#define MAPSEC_RUSTURF_TUNNEL 0x3C -#define MAPSEC_ABANDONED_SHIP 0x3D -#define MAPSEC_NEW_MAUVILLE 0x3E -#define MAPSEC_METEOR_FALLS 0x3F -#define MAPSEC_METEOR_FALLS2 0x40 -#define MAPSEC_MT_PYRE 0x41 -#define MAPSEC_AQUA_HIDEOUT_OLD 0x42 -#define MAPSEC_SHOAL_CAVE 0x43 -#define MAPSEC_SEAFLOOR_CAVERN 0x44 -#define MAPSEC_UNDERWATER_128 0x45 -#define MAPSEC_VICTORY_ROAD 0x46 -#define MAPSEC_MIRAGE_ISLAND 0x47 -#define MAPSEC_CAVE_OF_ORIGIN 0x48 -#define MAPSEC_SOUTHERN_ISLAND 0x49 -#define MAPSEC_FIERY_PATH 0x4A -#define MAPSEC_FIERY_PATH2 0x4B -#define MAPSEC_JAGGED_PASS 0x4C -#define MAPSEC_JAGGED_PASS2 0x4D -#define MAPSEC_SEALED_CHAMBER 0x4E -#define MAPSEC_UNDERWATER_SEALED_CHAMBER 0x4F -#define MAPSEC_SCORCHED_SLAB 0x50 -#define MAPSEC_ISLAND_CAVE 0x51 -#define MAPSEC_DESERT_RUINS 0x52 -#define MAPSEC_ANCIENT_TOMB 0x53 -#define MAPSEC_INSIDE_OF_TRUCK 0x54 -#define MAPSEC_SKY_PILLAR 0x55 -#define MAPSEC_SECRET_BASE 0x56 -#define MAPSEC_DYNAMIC 0x57 - -#define MAPSECS_KANTO 0x58 - -#define MAPSEC_PALLET_TOWN 0x58 -#define MAPSEC_VIRIDIAN_CITY 0x59 -#define MAPSEC_PEWTER_CITY 0x5A -#define MAPSEC_CERULEAN_CITY 0x5B -#define MAPSEC_LAVENDER_TOWN 0x5C -#define MAPSEC_VERMILION_CITY 0x5D -#define MAPSEC_CELADON_CITY 0x5E -#define MAPSEC_FUCHSIA_CITY 0x5F -#define MAPSEC_CINNABAR_ISLAND 0x60 -#define MAPSEC_INDIGO_PLATEAU 0x61 -#define MAPSEC_SAFFRON_CITY 0x62 -#define MAPSEC_ROUTE_4_POKECENTER 0x63 -#define MAPSEC_ROUTE_10_POKECENTER 0x64 -#define MAPSEC_ROUTE_1 0x65 -#define MAPSEC_ROUTE_2 0x66 -#define MAPSEC_ROUTE_3 0x67 -#define MAPSEC_ROUTE_4 0x68 -#define MAPSEC_ROUTE_5 0x69 -#define MAPSEC_ROUTE_6 0x6A -#define MAPSEC_ROUTE_7 0x6B -#define MAPSEC_ROUTE_8 0x6C -#define MAPSEC_ROUTE_9 0x6D -#define MAPSEC_ROUTE_10 0x6E -#define MAPSEC_ROUTE_11 0x6F -#define MAPSEC_ROUTE_12 0x70 -#define MAPSEC_ROUTE_13 0x71 -#define MAPSEC_ROUTE_14 0x72 -#define MAPSEC_ROUTE_15 0x73 -#define MAPSEC_ROUTE_16 0x74 -#define MAPSEC_ROUTE_17 0x75 -#define MAPSEC_ROUTE_18 0x76 -#define MAPSEC_ROUTE_19 0x77 -#define MAPSEC_ROUTE_20 0x78 -#define MAPSEC_ROUTE_21 0x79 -#define MAPSEC_ROUTE_22 0x7A -#define MAPSEC_ROUTE_23 0x7B -#define MAPSEC_ROUTE_24 0x7C -#define MAPSEC_ROUTE_25 0x7D -#define MAPSEC_VIRIDIAN_FOREST 0x7E -#define MAPSEC_MT_MOON 0x7F -#define MAPSEC_S_S_ANNE 0x80 -#define MAPSEC_UNDERGROUND_PATH 0x81 -#define MAPSEC_UNDERGROUND_PATH_2 0x82 -#define MAPSEC_DIGLETTS_CAVE 0x83 -#define MAPSEC_KANTO_VICTORY_ROAD 0x84 -#define MAPSEC_ROCKET_HIDEOUT 0x85 -#define MAPSEC_SILPH_CO 0x86 -#define MAPSEC_POKEMON_MANSION 0x87 -#define MAPSEC_KANTO_SAFARI_ZONE 0x88 -#define MAPSEC_POKEMON_LEAGUE 0x89 -#define MAPSEC_ROCK_TUNNEL 0x8A -#define MAPSEC_SEAFOAM_ISLANDS 0x8B -#define MAPSEC_POKEMON_TOWER 0x8C -#define MAPSEC_CERULEAN_CAVE 0x8D -#define MAPSEC_POWER_PLANT 0x8E - -#define MAPSECS_SEVII_123 0x8F - -#define MAPSEC_ONE_ISLAND 0x8F -#define MAPSEC_TWO_ISLAND 0x90 -#define MAPSEC_THREE_ISLAND 0x91 -#define MAPSEC_FOUR_ISLAND 0x92 -#define MAPSEC_FIVE_ISLAND 0x93 -#define MAPSEC_SEVEN_ISLAND 0x94 -#define MAPSEC_SIX_ISLAND 0x95 -#define MAPSEC_KINDLE_ROAD 0x96 -#define MAPSEC_TREASURE_BEACH 0x97 -#define MAPSEC_CAPE_BRINK 0x98 -#define MAPSEC_BOND_BRIDGE 0x99 -#define MAPSEC_THREE_ISLE_PORT 0x9A -#define MAPSEC_SEVII_ISLE_6 0x9B -#define MAPSEC_SEVII_ISLE_7 0x9C -#define MAPSEC_SEVII_ISLE_8 0x9D -#define MAPSEC_SEVII_ISLE_9 0x9E -#define MAPSEC_RESORT_GORGEOUS 0x9F -#define MAPSEC_WATER_LABYRINTH 0xA0 -#define MAPSEC_FIVE_ISLE_MEADOW 0xA1 -#define MAPSEC_MEMORIAL_PILLAR 0xA2 -#define MAPSEC_OUTCAST_ISLAND 0xA3 -#define MAPSEC_GREEN_PATH 0xA4 -#define MAPSEC_WATER_PATH 0xA5 -#define MAPSEC_RUIN_VALLEY 0xA6 -#define MAPSEC_TRAINER_TOWER 0xA7 -#define MAPSEC_CANYON_ENTRANCE 0xA8 -#define MAPSEC_SEVAULT_CANYON 0xA9 -#define MAPSEC_TANOBY_RUINS 0xAA -#define MAPSEC_SEVII_ISLE_22 0xAB -#define MAPSEC_SEVII_ISLE_23 0xAC -#define MAPSEC_SEVII_ISLE_24 0xAD -#define MAPSEC_NAVEL_ROCK 0xAE -#define MAPSEC_MT_EMBER 0xAF -#define MAPSEC_BERRY_FOREST 0xB0 -#define MAPSEC_ICEFALL_CAVE 0xB1 -#define MAPSEC_ROCKET_WAREHOUSE 0xB2 -#define MAPSEC_TRAINER_TOWER_2 0xB3 -#define MAPSEC_DOTTED_HOLE 0xB4 -#define MAPSEC_LOST_CAVE 0xB5 -#define MAPSEC_PATTERN_BUSH 0xB6 -#define MAPSEC_ALTERING_CAVE 0xB7 -#define MAPSEC_TANOBY_CHAMBERS 0xB8 -#define MAPSEC_THREE_ISLE_PATH 0xB9 -#define MAPSEC_TANOBY_KEY 0xBA -#define MAPSEC_BIRTH_ISLAND 0xBB -#define MAPSEC_MONEAN_CHAMBER 0xBC -#define MAPSEC_LIPTOO_CHAMBER 0xBD -#define MAPSEC_WEEPTH_CHAMBER 0xBE -#define MAPSEC_DILFORD_CHAMBER 0xBF -#define MAPSEC_SCUFIB_CHAMBER 0xC0 -#define MAPSEC_RIXY_CHAMBER 0xC1 -#define MAPSEC_VIAPOIS_CHAMBER 0xC2 -#define MAPSEC_EMBER_SPA 0xC3 -#define MAPSEC_SPECIAL_AREA 0xC4 -#define MAPSEC_NONE 0xC5 -#define MAPSEC_COUNT 0xC6 - -#define METLOC_SPECIAL_EGG 0xFD -#define METLOC_IN_GAME_TRADE 0xFE -#define METLOC_FATEFUL_ENCOUNTER 0xFF - -#endif //GUARD_CONSTANTS_REGION_MAP_SECTIONS_H diff --git a/include/gba/defines.h b/include/gba/defines.h index 46c722a1a..5521e942c 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -13,6 +13,7 @@ #define IWRAM_DATA __attribute__((section("iwram_data"))) #define EWRAM_DATA __attribute__((section("ewram_data"))) #endif +#define COMMON_DATA __attribute__((section("common_data"))) #if MODERN #define NOINLINE __attribute__((noinline)) diff --git a/json_data_rules.mk b/json_data_rules.mk index f3a04660c..65c4ee44e 100644 --- a/json_data_rules.mk +++ b/json_data_rules.mk @@ -19,6 +19,10 @@ $(DATA_SRC_SUBDIR)/region_map/region_map_entry_strings.h: $(DATA_SRC_SUBDIR)/reg $(C_BUILDDIR)/region_map.o: c_dep += $(DATA_SRC_SUBDIR)/region_map/region_map_entry_strings.h +AUTO_GEN_TARGETS += include/constants/region_map_sections.h +include/constants/region_map_sections.h: $(DATA_SRC_SUBDIR)/region_map/region_map_sections.json $(DATA_SRC_SUBDIR)/region_map/region_map_sections.constants.json.txt + $(JSONPROC) $^ $@ + AUTO_GEN_TARGETS += $(DATA_SRC_SUBDIR)/items.h $(DATA_SRC_SUBDIR)/items.h: $(DATA_SRC_SUBDIR)/items.json $(DATA_SRC_SUBDIR)/items.json.txt $(JSONPROC) $^ $@ diff --git a/ld_script.ld b/ld_script.ld index 1d2bbf29d..3bbcfc8fa 100644 --- a/ld_script.ld +++ b/ld_script.ld @@ -38,6 +38,7 @@ SECTIONS { /* COMMON starts at 0x30030E0 */ INCLUDE "sym_common.ld" + src/*.o(COMMON); *libc.a:sbrkr.o(COMMON); end = .; diff --git a/ld_script_modern.ld b/ld_script_modern.ld index 76f4536fb..2b5eb546d 100644 --- a/ld_script_modern.ld +++ b/ld_script_modern.ld @@ -30,6 +30,7 @@ SECTIONS { /* COMMON starts at 0x30022A8 */ *(COMMON); + *(common_data); end = .; __end__ = .; } > IWRAM diff --git a/src/AgbRfu_LinkManager.c b/src/AgbRfu_LinkManager.c index 558b19514..0f0501393 100644 --- a/src/AgbRfu_LinkManager.c +++ b/src/AgbRfu_LinkManager.c @@ -14,7 +14,7 @@ #define FSP_ON 0x01 #define FSP_START 0x02 -LINK_MANAGER lman; +COMMON_DATA LINK_MANAGER lman = {0}; static void rfu_LMAN_clearVariables(void); static void rfu_LMAN_settingPCSWITCH(u32 rand); diff --git a/src/agb_flash.c b/src/agb_flash.c index 0b454a41a..08aeed163 100644 --- a/src/agb_flash.c +++ b/src/agb_flash.c @@ -6,16 +6,16 @@ static u16 sTimerCount; static vu16 *sTimerReg; static u16 sSavedIme; -u8 gFlashTimeoutFlag; -u8 (*PollFlashStatus)(u8 *); -u16 (*WaitForFlashWrite)(u8 phase, u8 *addr, u8 lastData); -u16 (*ProgramFlashSector)(u16 sectorNum, void *src); -const struct FlashType *gFlash; -u16 (*ProgramFlashByte)(u16 sectorNum, u32 offset, u8 data); -u16 gFlashNumRemainingBytes; -u16 (*EraseFlashChip)(); -u16 (*EraseFlashSector)(u16 sectorNum); -const u16 *gFlashMaxTime; +COMMON_DATA u8 gFlashTimeoutFlag = 0; +COMMON_DATA u8 (*PollFlashStatus)(u8 *) = NULL; +COMMON_DATA u16 (*WaitForFlashWrite)(u8 phase, u8 *addr, u8 lastData) = NULL; +COMMON_DATA u16 (*ProgramFlashSector)(u16 sectorNum, void *src) = NULL; +COMMON_DATA const struct FlashType *gFlash = NULL; +COMMON_DATA u16 (*ProgramFlashByte)(u16 sectorNum, u32 offset, u8 data) = NULL; +COMMON_DATA u16 gFlashNumRemainingBytes = 0; +COMMON_DATA u16 (*EraseFlashChip)() = NULL; +COMMON_DATA u16 (*EraseFlashSector)(u16 sectorNum) = NULL; +COMMON_DATA const u16 *gFlashMaxTime = NULL; void SetReadFlash1(u16 *dest); diff --git a/src/battle_anim_special.c b/src/battle_anim_special.c index 183f86196..23eb9ebe4 100644 --- a/src/battle_anim_special.c +++ b/src/battle_anim_special.c @@ -30,9 +30,9 @@ #define TAG_PARTICLES_LUXURYBALL 55030 #define TAG_PARTICLES_PREMIERBALL 55031 -u32 gMonShrinkDuration; -u16 gMonShrinkDelta; -u16 gMonShrinkDistance; +COMMON_DATA u32 gMonShrinkDuration = 0; +COMMON_DATA u16 gMonShrinkDelta = 0; +COMMON_DATA u16 gMonShrinkDistance = 0; static void AnimTask_UnusedLevelUpHealthBox_Step(u8); static void AnimTask_FlashHealthboxOnLevelUp_Step(u8); diff --git a/src/battle_controller_pokedude.c b/src/battle_controller_pokedude.c index 62c259c04..f6307236c 100644 --- a/src/battle_controller_pokedude.c +++ b/src/battle_controller_pokedude.c @@ -2424,7 +2424,7 @@ static const struct PokedudeBattlePartyInfo *const sPokedudeBattlePartyPointers[ [TTVSCR_CATCHING] = sParties_Catching, }; -struct PokedudeBattlerState *gPokedudeBattlerStates[MAX_BATTLERS_COUNT]; +COMMON_DATA struct PokedudeBattlerState *gPokedudeBattlerStates[MAX_BATTLERS_COUNT] = {0}; static void PokedudeSimulateInputChooseAction(void) { diff --git a/src/battle_main.c b/src/battle_main.c index dc52024d2..4c3e927a0 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -220,15 +220,15 @@ EWRAM_DATA u16 gBattleMovePower = 0; EWRAM_DATA u16 gMoveToLearn = 0; EWRAM_DATA u8 gBattleMonForms[MAX_BATTLERS_COUNT] = {0}; -void (*gPreBattleCallback1)(void); -void (*gBattleMainFunc)(void); -struct BattleResults gBattleResults; -u8 gLeveledUpInBattle; -void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void); -u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT]; -u8 gMultiUsePlayerCursor; -u8 gNumberOfMovesToChoose; -u8 gBattleControllerData[MAX_BATTLERS_COUNT]; +COMMON_DATA void (*gPreBattleCallback1)(void) = NULL; +COMMON_DATA void (*gBattleMainFunc)(void) = NULL; +COMMON_DATA struct BattleResults gBattleResults = {0}; +COMMON_DATA u8 gLeveledUpInBattle = 0; +COMMON_DATA void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void) = {0}; +COMMON_DATA u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT] = {0}; +COMMON_DATA u8 gMultiUsePlayerCursor = 0; +COMMON_DATA u8 gNumberOfMovesToChoose = 0; +COMMON_DATA u8 gBattleControllerData[MAX_BATTLERS_COUNT] = {0}; static const struct ScanlineEffectParams sIntroScanlineParams16Bit = { diff --git a/src/battle_message.c b/src/battle_message.c index 9e6789c9c..07c136029 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -237,7 +237,7 @@ static const u8 sText_PkmnAnchoredItself[] = _("{B_DEF_NAME_WITH_PREFIX} anchore static const u8 sText_PkmnWasMadeDrowsy[] = _("{B_ATK_NAME_WITH_PREFIX} made\n{B_DEF_NAME_WITH_PREFIX} drowsy!"); static const u8 sText_PkmnKnockedOff[] = _("{B_ATK_NAME_WITH_PREFIX} knocked off\n{B_DEF_NAME_WITH_PREFIX}'s {B_LAST_ITEM}!"); static const u8 sText_PkmnSwappedAbilities[] = _("{B_ATK_NAME_WITH_PREFIX} swapped abilities\nwith its opponent!"); -static const u8 sText_PkmnSealedOpponentMove[] = _("{B_ATK_NAME_WITH_PREFIX} sealed the\nopponent's moveシsス!"); +static const u8 sText_PkmnSealedOpponentMove[] = _("{B_ATK_NAME_WITH_PREFIX} sealed the\nopponent's move(s)!"); static const u8 sText_PkmnWantsGrudge[] = _("{B_ATK_NAME_WITH_PREFIX} wants the\nopponent to bear a GRUDGE!"); static const u8 sText_PkmnLostPPGrudge[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_BUFF1} lost\nall its PP due to the GRUDGE!"); static const u8 sText_PkmnShroudedItself[] = _("{B_ATK_NAME_WITH_PREFIX} shrouded\nitself in {B_CURRENT_MOVE}!"); diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index 67aece9a1..4ef103aec 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -32,10 +32,10 @@ enum { STATE_RETRY, }; -const void *gMultibootStart; -int gMultibootStatus; -size_t gMultibootSize; -struct MultiBootParam gMultibootParam; +COMMON_DATA const void *gMultibootStart = NULL; +COMMON_DATA int gMultibootStatus = 0; +COMMON_DATA size_t gMultibootSize = 0; +COMMON_DATA struct MultiBootParam gMultibootParam = {0}; static void CB2_BerryFix(void); static void Task_BerryFixMain(u8 taskId); diff --git a/src/bg.c b/src/bg.c index 251f42616..aa11ae01f 100644 --- a/src/bg.c +++ b/src/bg.c @@ -43,7 +43,7 @@ static struct BgConfig2 sGpuBgConfigs2[4]; static u32 sDmaBusyBitfield[4]; static u8 gpu_tile_allocation_map_bg[0x100]; -bool32 gWindowTileAutoAllocEnabled; +COMMON_DATA bool32 gWindowTileAutoAllocEnabled = 0; static const struct BgConfig sZeroedBgControlStruct = { 0 }; diff --git a/src/cable_club.c b/src/cable_club.c index f1869b83f..23c9b940a 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -27,7 +27,7 @@ #include "constants/field_weather.h" #include "constants/maps.h" -u32 UnusedVarNeededToMatch[8]; +COMMON_DATA u32 UnusedVarNeededToMatch[8] = {0}; static void Task_LinkupStart(u8 taskId); static void Task_LinkupAwaitConnection(u8 taskId); diff --git a/src/data/region_map/region_map_sections.constants.json.txt b/src/data/region_map/region_map_sections.constants.json.txt new file mode 100644 index 000000000..eeddea6ae --- /dev/null +++ b/src/data/region_map/region_map_sections.constants.json.txt @@ -0,0 +1,24 @@ +{{ doNotModifyHeader }} +#ifndef GUARD_CONSTANTS_REGION_MAP_SECTIONS_H +#define GUARD_CONSTANTS_REGION_MAP_SECTIONS_H + +enum { +## for map_section in map_sections + {{ map_section.id }}, +## endfor + MAPSEC_NONE, + MAPSEC_COUNT +}; + +// Values before KANTO_MAPSEC_START are assumed to have no data. +#define KANTO_MAPSEC_START MAPSEC_PALLET_TOWN + +// Values starting from SEVII_MAPSEC_START are assumed to have data in sSeviiMapsecs. +#define SEVII_MAPSEC_START MAPSEC_ONE_ISLAND + +// Special location IDs that use the same value space as MAPSECs. +#define METLOC_SPECIAL_EGG 0xFD +#define METLOC_IN_GAME_TRADE 0xFE +#define METLOC_FATEFUL_ENCOUNTER 0xFF + +#endif // GUARD_CONSTANTS_REGION_MAP_SECTIONS_H diff --git a/src/data/region_map/region_map_sections.entries.json.txt b/src/data/region_map/region_map_sections.entries.json.txt index 7cce3705c..fc5fee915 100644 --- a/src/data/region_map/region_map_sections.entries.json.txt +++ b/src/data/region_map/region_map_sections.entries.json.txt @@ -3,24 +3,30 @@ #define GUARD_DATA_REGION_MAP_REGION_MAP_ENTRIES_H ## for map_section in map_sections -{% if isEmptyString(getVar(map_section.name)) and not existsIn(map_section, "name_clone") %}{{ setVar(map_section.name, map_section.map_section) }}{% endif %} +{% if existsIn(map_section, "name") and isEmptyString(getVar(map_section.name)) and not existsIn(map_section, "name_clone") %}{{ setVar(map_section.name, map_section.id) }}{% endif %} ## endfor static const u8 *const sMapNames[] = { ## for map_section in map_sections - [{{ map_section.map_section }} - MAPSECS_KANTO] = sMapsecName_{{ cleanString(map_section.name) }}{% if existsIn(map_section, "name_clone") %}_Clone{% endif %}, +{% if existsIn(map_section, "name") %} + [{{ map_section.id }} - KANTO_MAPSEC_START] = sMapsecName_{{ cleanString(map_section.name) }}{% if existsIn(map_section, "name_clone") %}_Clone{% endif %}, +{% endif %} ## endfor }; static const u16 sMapSectionTopLeftCorners[MAPSEC_COUNT][2] = { ## for map_section in map_sections - [{{ map_section.map_section }} - MAPSECS_KANTO] = { {{ map_section.x }}, {{ map_section.y }} }, +{% if existsIn(map_section, "x") and existsIn(map_section, "y") %} + [{{ map_section.id }} - KANTO_MAPSEC_START] = { {{ map_section.x }}, {{ map_section.y }} }, +{% endif %} ## endfor }; static const u16 sMapSectionDimensions[MAPSEC_COUNT][2] = { ## for map_section in map_sections - [{{ map_section.map_section }} - MAPSECS_KANTO] = { {{ map_section.width }}, {{ map_section.height }} }, +{% if existsIn(map_section, "width") and existsIn(map_section, "height") %} + [{{ map_section.id }} - KANTO_MAPSEC_START] = { {{ map_section.width }}, {{ map_section.height }} }, +{% endif %} ## endfor }; diff --git a/src/data/region_map/region_map_sections.json b/src/data/region_map/region_map_sections.json index 63947d4f0..601bff65d 100644 --- a/src/data/region_map/region_map_sections.json +++ b/src/data/region_map/region_map_sections.json @@ -1,7 +1,271 @@ { "map_sections": [ { - "map_section": "MAPSEC_PALLET_TOWN", + "id": "MAPSEC_LITTLEROOT_TOWN" + }, + { + "id": "MAPSEC_OLDALE_TOWN" + }, + { + "id": "MAPSEC_DEWFORD_TOWN" + }, + { + "id": "MAPSEC_LAVARIDGE_TOWN" + }, + { + "id": "MAPSEC_FALLARBOR_TOWN" + }, + { + "id": "MAPSEC_VERDANTURF_TOWN" + }, + { + "id": "MAPSEC_PACIFIDLOG_TOWN" + }, + { + "id": "MAPSEC_PETALBURG_CITY" + }, + { + "id": "MAPSEC_SLATEPORT_CITY" + }, + { + "id": "MAPSEC_MAUVILLE_CITY" + }, + { + "id": "MAPSEC_RUSTBORO_CITY" + }, + { + "id": "MAPSEC_FORTREE_CITY" + }, + { + "id": "MAPSEC_LILYCOVE_CITY" + }, + { + "id": "MAPSEC_MOSSDEEP_CITY" + }, + { + "id": "MAPSEC_SOOTOPOLIS_CITY" + }, + { + "id": "MAPSEC_EVER_GRANDE_CITY" + }, + { + "id": "MAPSEC_ROUTE_101" + }, + { + "id": "MAPSEC_ROUTE_102" + }, + { + "id": "MAPSEC_ROUTE_103" + }, + { + "id": "MAPSEC_ROUTE_104" + }, + { + "id": "MAPSEC_ROUTE_105" + }, + { + "id": "MAPSEC_ROUTE_106" + }, + { + "id": "MAPSEC_ROUTE_107" + }, + { + "id": "MAPSEC_ROUTE_108" + }, + { + "id": "MAPSEC_ROUTE_109" + }, + { + "id": "MAPSEC_ROUTE_110" + }, + { + "id": "MAPSEC_ROUTE_111" + }, + { + "id": "MAPSEC_ROUTE_112" + }, + { + "id": "MAPSEC_ROUTE_113" + }, + { + "id": "MAPSEC_ROUTE_114" + }, + { + "id": "MAPSEC_ROUTE_115" + }, + { + "id": "MAPSEC_ROUTE_116" + }, + { + "id": "MAPSEC_ROUTE_117" + }, + { + "id": "MAPSEC_ROUTE_118" + }, + { + "id": "MAPSEC_ROUTE_119" + }, + { + "id": "MAPSEC_ROUTE_120" + }, + { + "id": "MAPSEC_ROUTE_121" + }, + { + "id": "MAPSEC_ROUTE_122" + }, + { + "id": "MAPSEC_ROUTE_123" + }, + { + "id": "MAPSEC_ROUTE_124" + }, + { + "id": "MAPSEC_ROUTE_125" + }, + { + "id": "MAPSEC_ROUTE_126" + }, + { + "id": "MAPSEC_ROUTE_127" + }, + { + "id": "MAPSEC_ROUTE_128" + }, + { + "id": "MAPSEC_ROUTE_129" + }, + { + "id": "MAPSEC_ROUTE_130" + }, + { + "id": "MAPSEC_ROUTE_131" + }, + { + "id": "MAPSEC_ROUTE_132" + }, + { + "id": "MAPSEC_ROUTE_133" + }, + { + "id": "MAPSEC_ROUTE_134" + }, + { + "id": "MAPSEC_UNDERWATER_124" + }, + { + "id": "MAPSEC_UNDERWATER_125" + }, + { + "id": "MAPSEC_UNDERWATER_126" + }, + { + "id": "MAPSEC_UNDERWATER_127" + }, + { + "id": "MAPSEC_UNDERWATER_SOOTOPOLIS" + }, + { + "id": "MAPSEC_GRANITE_CAVE" + }, + { + "id": "MAPSEC_MT_CHIMNEY" + }, + { + "id": "MAPSEC_SAFARI_ZONE" + }, + { + "id": "MAPSEC_BATTLE_FRONTIER" + }, + { + "id": "MAPSEC_PETALBURG_WOODS" + }, + { + "id": "MAPSEC_RUSTURF_TUNNEL" + }, + { + "id": "MAPSEC_ABANDONED_SHIP" + }, + { + "id": "MAPSEC_NEW_MAUVILLE" + }, + { + "id": "MAPSEC_METEOR_FALLS" + }, + { + "id": "MAPSEC_METEOR_FALLS2" + }, + { + "id": "MAPSEC_MT_PYRE" + }, + { + "id": "MAPSEC_AQUA_HIDEOUT_OLD" + }, + { + "id": "MAPSEC_SHOAL_CAVE" + }, + { + "id": "MAPSEC_SEAFLOOR_CAVERN" + }, + { + "id": "MAPSEC_UNDERWATER_128" + }, + { + "id": "MAPSEC_VICTORY_ROAD" + }, + { + "id": "MAPSEC_MIRAGE_ISLAND" + }, + { + "id": "MAPSEC_CAVE_OF_ORIGIN" + }, + { + "id": "MAPSEC_SOUTHERN_ISLAND" + }, + { + "id": "MAPSEC_FIERY_PATH" + }, + { + "id": "MAPSEC_FIERY_PATH2" + }, + { + "id": "MAPSEC_JAGGED_PASS" + }, + { + "id": "MAPSEC_JAGGED_PASS2" + }, + { + "id": "MAPSEC_SEALED_CHAMBER" + }, + { + "id": "MAPSEC_UNDERWATER_SEALED_CHAMBER" + }, + { + "id": "MAPSEC_SCORCHED_SLAB" + }, + { + "id": "MAPSEC_ISLAND_CAVE" + }, + { + "id": "MAPSEC_DESERT_RUINS" + }, + { + "id": "MAPSEC_ANCIENT_TOMB" + }, + { + "id": "MAPSEC_INSIDE_OF_TRUCK" + }, + { + "id": "MAPSEC_SKY_PILLAR" + }, + { + "id": "MAPSEC_SECRET_BASE" + }, + { + "id": "MAPSEC_DYNAMIC" + }, + { + "id": "MAPSEC_PALLET_TOWN", "name": "PALLET TOWN", "x": 4, "y": 11, @@ -9,7 +273,7 @@ "height": 1 }, { - "map_section": "MAPSEC_VIRIDIAN_CITY", + "id": "MAPSEC_VIRIDIAN_CITY", "name": "VIRIDIAN CITY", "x": 4, "y": 8, @@ -17,7 +281,7 @@ "height": 1 }, { - "map_section": "MAPSEC_PEWTER_CITY", + "id": "MAPSEC_PEWTER_CITY", "name": "PEWTER CITY", "x": 4, "y": 4, @@ -25,7 +289,7 @@ "height": 1 }, { - "map_section": "MAPSEC_CERULEAN_CITY", + "id": "MAPSEC_CERULEAN_CITY", "name": "CERULEAN CITY", "x": 14, "y": 3, @@ -33,7 +297,7 @@ "height": 1 }, { - "map_section": "MAPSEC_LAVENDER_TOWN", + "id": "MAPSEC_LAVENDER_TOWN", "name": "LAVENDER TOWN", "x": 18, "y": 6, @@ -41,7 +305,7 @@ "height": 1 }, { - "map_section": "MAPSEC_VERMILION_CITY", + "id": "MAPSEC_VERMILION_CITY", "name": "VERMILION CITY", "x": 14, "y": 9, @@ -49,7 +313,7 @@ "height": 1 }, { - "map_section": "MAPSEC_CELADON_CITY", + "id": "MAPSEC_CELADON_CITY", "name": "CELADON CITY", "x": 11, "y": 6, @@ -57,7 +321,7 @@ "height": 1 }, { - "map_section": "MAPSEC_FUCHSIA_CITY", + "id": "MAPSEC_FUCHSIA_CITY", "name": "FUCHSIA CITY", "x": 12, "y": 12, @@ -65,7 +329,7 @@ "height": 1 }, { - "map_section": "MAPSEC_CINNABAR_ISLAND", + "id": "MAPSEC_CINNABAR_ISLAND", "name": "CINNABAR ISLAND", "x": 4, "y": 14, @@ -73,7 +337,7 @@ "height": 1 }, { - "map_section": "MAPSEC_INDIGO_PLATEAU", + "id": "MAPSEC_INDIGO_PLATEAU", "name": "INDIGO PLATEAU", "x": 2, "y": 3, @@ -81,7 +345,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SAFFRON_CITY", + "id": "MAPSEC_SAFFRON_CITY", "name": "SAFFRON CITY", "x": 14, "y": 6, @@ -89,7 +353,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_4_POKECENTER", + "id": "MAPSEC_ROUTE_4_POKECENTER", "name": "ROUTE 4", "name_clone": true, "x": 8, @@ -98,7 +362,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_10_POKECENTER", + "id": "MAPSEC_ROUTE_10_POKECENTER", "name": "ROUTE 10", "name_clone": true, "x": 18, @@ -107,7 +371,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_1", + "id": "MAPSEC_ROUTE_1", "name": "ROUTE 1", "x": 4, "y": 9, @@ -115,7 +379,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_2", + "id": "MAPSEC_ROUTE_2", "name": "ROUTE 2", "x": 4, "y": 5, @@ -123,7 +387,7 @@ "height": 3 }, { - "map_section": "MAPSEC_ROUTE_3", + "id": "MAPSEC_ROUTE_3", "name": "ROUTE 3", "x": 5, "y": 4, @@ -131,7 +395,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_4", + "id": "MAPSEC_ROUTE_4", "name": "ROUTE 4", "x": 8, "y": 3, @@ -139,7 +403,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_5", + "id": "MAPSEC_ROUTE_5", "name": "ROUTE 5", "x": 14, "y": 4, @@ -147,7 +411,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_6", + "id": "MAPSEC_ROUTE_6", "name": "ROUTE 6", "x": 14, "y": 7, @@ -155,7 +419,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_7", + "id": "MAPSEC_ROUTE_7", "name": "ROUTE 7", "x": 12, "y": 6, @@ -163,7 +427,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_8", + "id": "MAPSEC_ROUTE_8", "name": "ROUTE 8", "x": 15, "y": 6, @@ -171,7 +435,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_9", + "id": "MAPSEC_ROUTE_9", "name": "ROUTE 9", "x": 15, "y": 3, @@ -179,7 +443,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_10", + "id": "MAPSEC_ROUTE_10", "name": "ROUTE 10", "x": 18, "y": 3, @@ -187,7 +451,7 @@ "height": 3 }, { - "map_section": "MAPSEC_ROUTE_11", + "id": "MAPSEC_ROUTE_11", "name": "ROUTE 11", "x": 15, "y": 9, @@ -195,7 +459,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_12", + "id": "MAPSEC_ROUTE_12", "name": "ROUTE 12", "x": 18, "y": 7, @@ -203,7 +467,7 @@ "height": 5 }, { - "map_section": "MAPSEC_ROUTE_13", + "id": "MAPSEC_ROUTE_13", "name": "ROUTE 13", "x": 16, "y": 11, @@ -211,7 +475,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_14", + "id": "MAPSEC_ROUTE_14", "name": "ROUTE 14", "x": 15, "y": 11, @@ -219,7 +483,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_15", + "id": "MAPSEC_ROUTE_15", "name": "ROUTE 15", "x": 13, "y": 12, @@ -227,7 +491,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_16", + "id": "MAPSEC_ROUTE_16", "name": "ROUTE 16", "x": 7, "y": 6, @@ -235,7 +499,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_17", + "id": "MAPSEC_ROUTE_17", "name": "ROUTE 17", "x": 7, "y": 7, @@ -243,7 +507,7 @@ "height": 5 }, { - "map_section": "MAPSEC_ROUTE_18", + "id": "MAPSEC_ROUTE_18", "name": "ROUTE 18", "x": 7, "y": 12, @@ -251,7 +515,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_19", + "id": "MAPSEC_ROUTE_19", "name": "ROUTE 19", "x": 12, "y": 13, @@ -259,7 +523,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_20", + "id": "MAPSEC_ROUTE_20", "name": "ROUTE 20", "x": 5, "y": 14, @@ -267,7 +531,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_21", + "id": "MAPSEC_ROUTE_21", "name": "ROUTE 21", "x": 4, "y": 12, @@ -275,7 +539,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_22", + "id": "MAPSEC_ROUTE_22", "name": "ROUTE 22", "x": 2, "y": 8, @@ -283,7 +547,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROUTE_23", + "id": "MAPSEC_ROUTE_23", "name": "ROUTE 23", "x": 2, "y": 4, @@ -291,7 +555,7 @@ "height": 4 }, { - "map_section": "MAPSEC_ROUTE_24", + "id": "MAPSEC_ROUTE_24", "name": "ROUTE 24", "x": 14, "y": 1, @@ -299,7 +563,7 @@ "height": 2 }, { - "map_section": "MAPSEC_ROUTE_25", + "id": "MAPSEC_ROUTE_25", "name": "ROUTE 25", "x": 15, "y": 1, @@ -307,7 +571,7 @@ "height": 1 }, { - "map_section": "MAPSEC_VIRIDIAN_FOREST", + "id": "MAPSEC_VIRIDIAN_FOREST", "name": "VIRIDIAN FOREST", "x": 0, "y": 0, @@ -315,7 +579,7 @@ "height": 1 }, { - "map_section": "MAPSEC_MT_MOON", + "id": "MAPSEC_MT_MOON", "name": "MT. MOON", "x": 0, "y": 0, @@ -323,7 +587,7 @@ "height": 1 }, { - "map_section": "MAPSEC_S_S_ANNE", + "id": "MAPSEC_S_S_ANNE", "name": "S.S. ANNE", "x": 0, "y": 0, @@ -331,7 +595,7 @@ "height": 1 }, { - "map_section": "MAPSEC_UNDERGROUND_PATH", + "id": "MAPSEC_UNDERGROUND_PATH", "name": "UNDERGROUND PATH", "x": 0, "y": 0, @@ -339,7 +603,7 @@ "height": 1 }, { - "map_section": "MAPSEC_UNDERGROUND_PATH_2", + "id": "MAPSEC_UNDERGROUND_PATH_2", "name": "UNDERGROUND PATH", "name_clone": true, "x": 0, @@ -348,7 +612,7 @@ "height": 1 }, { - "map_section": "MAPSEC_DIGLETTS_CAVE", + "id": "MAPSEC_DIGLETTS_CAVE", "name": "DIGLETT'S CAVE", "x": 0, "y": 0, @@ -356,7 +620,7 @@ "height": 1 }, { - "map_section": "MAPSEC_KANTO_VICTORY_ROAD", + "id": "MAPSEC_KANTO_VICTORY_ROAD", "name": "VICTORY ROAD", "x": 0, "y": 0, @@ -364,7 +628,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROCKET_HIDEOUT", + "id": "MAPSEC_ROCKET_HIDEOUT", "name": "ROCKET HIDEOUT", "x": 0, "y": 0, @@ -372,7 +636,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SILPH_CO", + "id": "MAPSEC_SILPH_CO", "name": "SILPH CO.", "x": 0, "y": 0, @@ -380,7 +644,7 @@ "height": 1 }, { - "map_section": "MAPSEC_POKEMON_MANSION", + "id": "MAPSEC_POKEMON_MANSION", "name": "POKéMON MANSION", "x": 0, "y": 0, @@ -388,7 +652,7 @@ "height": 1 }, { - "map_section": "MAPSEC_KANTO_SAFARI_ZONE", + "id": "MAPSEC_KANTO_SAFARI_ZONE", "name": "SAFARI ZONE", "x": 0, "y": 0, @@ -396,7 +660,7 @@ "height": 1 }, { - "map_section": "MAPSEC_POKEMON_LEAGUE", + "id": "MAPSEC_POKEMON_LEAGUE", "name": "POKéMON LEAGUE", "x": 0, "y": 0, @@ -404,7 +668,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROCK_TUNNEL", + "id": "MAPSEC_ROCK_TUNNEL", "name": "ROCK TUNNEL", "x": 0, "y": 0, @@ -412,7 +676,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEAFOAM_ISLANDS", + "id": "MAPSEC_SEAFOAM_ISLANDS", "name": "SEAFOAM ISLANDS", "x": 0, "y": 0, @@ -420,7 +684,7 @@ "height": 1 }, { - "map_section": "MAPSEC_POKEMON_TOWER", + "id": "MAPSEC_POKEMON_TOWER", "name": "POKéMON TOWER", "x": 0, "y": 0, @@ -428,7 +692,7 @@ "height": 1 }, { - "map_section": "MAPSEC_CERULEAN_CAVE", + "id": "MAPSEC_CERULEAN_CAVE", "name": "CERULEAN CAVE", "x": 0, "y": 0, @@ -436,7 +700,7 @@ "height": 1 }, { - "map_section": "MAPSEC_POWER_PLANT", + "id": "MAPSEC_POWER_PLANT", "name": "POWER PLANT", "x": 0, "y": 0, @@ -444,7 +708,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ONE_ISLAND", + "id": "MAPSEC_ONE_ISLAND", "name": "ONE ISLAND", "x": 1, "y": 8, @@ -452,7 +716,7 @@ "height": 1 }, { - "map_section": "MAPSEC_TWO_ISLAND", + "id": "MAPSEC_TWO_ISLAND", "name": "TWO ISLAND", "x": 9, "y": 9, @@ -460,7 +724,7 @@ "height": 1 }, { - "map_section": "MAPSEC_THREE_ISLAND", + "id": "MAPSEC_THREE_ISLAND", "name": "THREE ISLAND", "x": 18, "y": 12, @@ -468,7 +732,7 @@ "height": 1 }, { - "map_section": "MAPSEC_FOUR_ISLAND", + "id": "MAPSEC_FOUR_ISLAND", "name": "FOUR ISLAND", "x": 3, "y": 4, @@ -476,7 +740,7 @@ "height": 1 }, { - "map_section": "MAPSEC_FIVE_ISLAND", + "id": "MAPSEC_FIVE_ISLAND", "name": "FIVE ISLAND", "x": 16, "y": 11, @@ -484,7 +748,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVEN_ISLAND", + "id": "MAPSEC_SEVEN_ISLAND", "name": "SEVEN ISLAND", "x": 5, "y": 8, @@ -492,7 +756,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SIX_ISLAND", + "id": "MAPSEC_SIX_ISLAND", "name": "SIX ISLAND", "x": 17, "y": 5, @@ -500,7 +764,7 @@ "height": 1 }, { - "map_section": "MAPSEC_KINDLE_ROAD", + "id": "MAPSEC_KINDLE_ROAD", "name": "KINDLE ROAD", "x": 2, "y": 3, @@ -508,7 +772,7 @@ "height": 6 }, { - "map_section": "MAPSEC_TREASURE_BEACH", + "id": "MAPSEC_TREASURE_BEACH", "name": "TREASURE BEACH", "x": 1, "y": 9, @@ -516,7 +780,7 @@ "height": 2 }, { - "map_section": "MAPSEC_CAPE_BRINK", + "id": "MAPSEC_CAPE_BRINK", "name": "CAPE BRINK", "x": 9, "y": 7, @@ -524,7 +788,7 @@ "height": 2 }, { - "map_section": "MAPSEC_BOND_BRIDGE", + "id": "MAPSEC_BOND_BRIDGE", "name": "BOND BRIDGE", "x": 13, "y": 12, @@ -532,7 +796,7 @@ "height": 1 }, { - "map_section": "MAPSEC_THREE_ISLE_PORT", + "id": "MAPSEC_THREE_ISLE_PORT", "name": "THREE ISLE PORT", "x": 18, "y": 13, @@ -540,7 +804,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_6", + "id": "MAPSEC_SEVII_ISLE_6", "name": "SEVII ISLE 6", "x": 4, "y": 3, @@ -548,7 +812,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_7", + "id": "MAPSEC_SEVII_ISLE_7", "name": "SEVII ISLE 7", "x": 5, "y": 4, @@ -556,7 +820,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_8", + "id": "MAPSEC_SEVII_ISLE_8", "name": "SEVII ISLE 8", "x": 1, "y": 4, @@ -564,7 +828,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_9", + "id": "MAPSEC_SEVII_ISLE_9", "name": "SEVII ISLE 9", "x": 4, "y": 5, @@ -572,7 +836,7 @@ "height": 2 }, { - "map_section": "MAPSEC_RESORT_GORGEOUS", + "id": "MAPSEC_RESORT_GORGEOUS", "name": "RESORT GORGEOUS", "x": 16, "y": 9, @@ -580,7 +844,7 @@ "height": 1 }, { - "map_section": "MAPSEC_WATER_LABYRINTH", + "id": "MAPSEC_WATER_LABYRINTH", "name": "WATER LABYRINTH", "x": 14, "y": 10, @@ -588,7 +852,7 @@ "height": 1 }, { - "map_section": "MAPSEC_FIVE_ISLE_MEADOW", + "id": "MAPSEC_FIVE_ISLE_MEADOW", "name": "FIVE ISLE MEADOW", "x": 17, "y": 10, @@ -596,7 +860,7 @@ "height": 3 }, { - "map_section": "MAPSEC_MEMORIAL_PILLAR", + "id": "MAPSEC_MEMORIAL_PILLAR", "name": "MEMORIAL PILLAR", "x": 18, "y": 12, @@ -604,7 +868,7 @@ "height": 3 }, { - "map_section": "MAPSEC_OUTCAST_ISLAND", + "id": "MAPSEC_OUTCAST_ISLAND", "name": "OUTCAST ISLAND", "x": 15, "y": 0, @@ -612,7 +876,7 @@ "height": 3 }, { - "map_section": "MAPSEC_GREEN_PATH", + "id": "MAPSEC_GREEN_PATH", "name": "GREEN PATH", "x": 15, "y": 3, @@ -620,7 +884,7 @@ "height": 1 }, { - "map_section": "MAPSEC_WATER_PATH", + "id": "MAPSEC_WATER_PATH", "name": "WATER PATH", "x": 18, "y": 3, @@ -628,7 +892,7 @@ "height": 5 }, { - "map_section": "MAPSEC_RUIN_VALLEY", + "id": "MAPSEC_RUIN_VALLEY", "name": "RUIN VALLEY", "x": 16, "y": 7, @@ -636,7 +900,7 @@ "height": 2 }, { - "map_section": "MAPSEC_TRAINER_TOWER", + "id": "MAPSEC_TRAINER_TOWER", "name": "TRAINER TOWER", "x": 5, "y": 6, @@ -644,7 +908,7 @@ "height": 2 }, { - "map_section": "MAPSEC_CANYON_ENTRANCE", + "id": "MAPSEC_CANYON_ENTRANCE", "name": "CANYON ENTRANCE", "x": 5, "y": 9, @@ -652,7 +916,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVAULT_CANYON", + "id": "MAPSEC_SEVAULT_CANYON", "name": "SEVAULT CANYON", "x": 6, "y": 9, @@ -660,7 +924,7 @@ "height": 3 }, { - "map_section": "MAPSEC_TANOBY_RUINS", + "id": "MAPSEC_TANOBY_RUINS", "name": "TANOBY RUINS", "x": 3, "y": 12, @@ -668,7 +932,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_22", + "id": "MAPSEC_SEVII_ISLE_22", "name": "SEVII ISLE 22", "x": 9, "y": 12, @@ -676,7 +940,7 @@ "height": 3 }, { - "map_section": "MAPSEC_SEVII_ISLE_23", + "id": "MAPSEC_SEVII_ISLE_23", "name": "SEVII ISLE 23", "x": 3, "y": 14, @@ -684,7 +948,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SEVII_ISLE_24", + "id": "MAPSEC_SEVII_ISLE_24", "name": "SEVII ISLE 24", "x": 2, "y": 12, @@ -692,7 +956,7 @@ "height": 3 }, { - "map_section": "MAPSEC_NAVEL_ROCK", + "id": "MAPSEC_NAVEL_ROCK", "name": "NAVEL ROCK", "x": 10, "y": 8, @@ -700,7 +964,7 @@ "height": 1 }, { - "map_section": "MAPSEC_MT_EMBER", + "id": "MAPSEC_MT_EMBER", "name": "MT. EMBER", "x": 0, "y": 0, @@ -708,7 +972,7 @@ "height": 1 }, { - "map_section": "MAPSEC_BERRY_FOREST", + "id": "MAPSEC_BERRY_FOREST", "name": "BERRY FOREST", "x": 0, "y": 0, @@ -716,7 +980,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ICEFALL_CAVE", + "id": "MAPSEC_ICEFALL_CAVE", "name": "ICEFALL CAVE", "x": 0, "y": 0, @@ -724,7 +988,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ROCKET_WAREHOUSE", + "id": "MAPSEC_ROCKET_WAREHOUSE", "name": "ROCKET WAREHOUSE", "x": 0, "y": 0, @@ -732,7 +996,7 @@ "height": 1 }, { - "map_section": "MAPSEC_TRAINER_TOWER_2", + "id": "MAPSEC_TRAINER_TOWER_2", "name": "TRAINER TOWER", "name_clone": true, "x": 0, @@ -741,7 +1005,7 @@ "height": 1 }, { - "map_section": "MAPSEC_DOTTED_HOLE", + "id": "MAPSEC_DOTTED_HOLE", "name": "DOTTED HOLE", "x": 0, "y": 0, @@ -749,7 +1013,7 @@ "height": 1 }, { - "map_section": "MAPSEC_LOST_CAVE", + "id": "MAPSEC_LOST_CAVE", "name": "LOST CAVE", "x": 0, "y": 0, @@ -757,7 +1021,7 @@ "height": 1 }, { - "map_section": "MAPSEC_PATTERN_BUSH", + "id": "MAPSEC_PATTERN_BUSH", "name": "PATTERN BUSH", "x": 0, "y": 0, @@ -765,7 +1029,7 @@ "height": 1 }, { - "map_section": "MAPSEC_ALTERING_CAVE", + "id": "MAPSEC_ALTERING_CAVE", "name": "ALTERING CAVE", "x": 0, "y": 0, @@ -773,7 +1037,7 @@ "height": 1 }, { - "map_section": "MAPSEC_TANOBY_CHAMBERS", + "id": "MAPSEC_TANOBY_CHAMBERS", "name": "TANOBY CHAMBERS", "x": 0, "y": 0, @@ -781,7 +1045,7 @@ "height": 1 }, { - "map_section": "MAPSEC_THREE_ISLE_PATH", + "id": "MAPSEC_THREE_ISLE_PATH", "name": "THREE ISLE PATH", "x": 0, "y": 0, @@ -789,7 +1053,7 @@ "height": 1 }, { - "map_section": "MAPSEC_TANOBY_KEY", + "id": "MAPSEC_TANOBY_KEY", "name": "TANOBY KEY", "x": 0, "y": 0, @@ -797,7 +1061,7 @@ "height": 1 }, { - "map_section": "MAPSEC_BIRTH_ISLAND", + "id": "MAPSEC_BIRTH_ISLAND", "name": "BIRTH ISLAND", "x": 18, "y": 13, @@ -805,7 +1069,7 @@ "height": 1 }, { - "map_section": "MAPSEC_MONEAN_CHAMBER", + "id": "MAPSEC_MONEAN_CHAMBER", "name": "MONEAN CHAMBER", "x": 0, "y": 0, @@ -813,7 +1077,7 @@ "height": 1 }, { - "map_section": "MAPSEC_LIPTOO_CHAMBER", + "id": "MAPSEC_LIPTOO_CHAMBER", "name": "LIPTOO CHAMBER", "x": 0, "y": 0, @@ -821,7 +1085,7 @@ "height": 1 }, { - "map_section": "MAPSEC_WEEPTH_CHAMBER", + "id": "MAPSEC_WEEPTH_CHAMBER", "name": "WEEPTH CHAMBER", "x": 0, "y": 0, @@ -829,7 +1093,7 @@ "height": 1 }, { - "map_section": "MAPSEC_DILFORD_CHAMBER", + "id": "MAPSEC_DILFORD_CHAMBER", "name": "DILFORD CHAMBER", "x": 0, "y": 0, @@ -837,7 +1101,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SCUFIB_CHAMBER", + "id": "MAPSEC_SCUFIB_CHAMBER", "name": "SCUFIB CHAMBER", "x": 0, "y": 0, @@ -845,7 +1109,7 @@ "height": 1 }, { - "map_section": "MAPSEC_RIXY_CHAMBER", + "id": "MAPSEC_RIXY_CHAMBER", "name": "RIXY CHAMBER", "x": 0, "y": 0, @@ -853,7 +1117,7 @@ "height": 1 }, { - "map_section": "MAPSEC_VIAPOIS_CHAMBER", + "id": "MAPSEC_VIAPOIS_CHAMBER", "name": "VIAPOIS CHAMBER", "x": 0, "y": 0, @@ -861,7 +1125,7 @@ "height": 1 }, { - "map_section": "MAPSEC_EMBER_SPA", + "id": "MAPSEC_EMBER_SPA", "name": "EMBER SPA", "x": 0, "y": 0, @@ -869,7 +1133,7 @@ "height": 1 }, { - "map_section": "MAPSEC_SPECIAL_AREA", + "id": "MAPSEC_SPECIAL_AREA", "name": "CELADON DEPT.", "x": 0, "y": 0, diff --git a/src/data/region_map/region_map_sections.strings.json.txt b/src/data/region_map/region_map_sections.strings.json.txt index c81a10419..31a28c8f6 100644 --- a/src/data/region_map/region_map_sections.strings.json.txt +++ b/src/data/region_map/region_map_sections.strings.json.txt @@ -3,16 +3,18 @@ #define GUARD_DATA_REGION_MAP_REGION_MAP_ENTRY_STRINGS_H ## for map_section in map_sections -{% if isEmptyString(getVar(map_section.name)) and not existsIn(map_section, "name_clone") %}{{ setVar(map_section.name, map_section.map_section) }}{% endif %} +{% if existsIn(map_section, "name") and isEmptyString(getVar(map_section.name)) and not existsIn(map_section, "name_clone") %}{{ setVar(map_section.name, map_section.id) }}{% endif %} ## endfor ## for map_section in map_sections -{% if getVar(map_section.name) == map_section.map_section %} +{% if existsIn(map_section, "name") %} +{% if getVar(map_section.name) == map_section.id %} static const u8 sMapsecName_{{ cleanString(map_section.name) }}[] = _("{{ map_section.name }}"); {% endif %} {% if existsIn(map_section, "name_clone") %} static const u8 sMapsecName_{{ cleanString(map_section.name) }}_Clone[] = _("{{ map_section.name }}"); {% endif %} +{% endif %} ## endfor #endif // GUARD_DATA_REGION_MAP_REGION_MAP_ENTRY_STRINGS_H diff --git a/src/ereader_screen.c b/src/ereader_screen.c index 060150cbf..20ec25d01 100644 --- a/src/ereader_screen.c +++ b/src/ereader_screen.c @@ -41,7 +41,7 @@ struct EReaderData static void Task_EReader(u8); -struct EReaderData gEReaderData; +COMMON_DATA struct EReaderData gEReaderData = {0}; extern const u8 gMultiBootProgram_EReader_Start[]; extern const u8 gMultiBootProgram_EReader_End[]; diff --git a/src/event_data.c b/src/event_data.c index fa393a47c..da9391cf0 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -35,7 +35,7 @@ EWRAM_DATA u16 gSpecialVar_PrevTextColor = 0; EWRAM_DATA u16 gSpecialVar_0x8014 = 0; EWRAM_DATA u8 sSpecialFlags[SPECIAL_FLAGS_SIZE] = {}; -u16 gLastQuestLogStoredFlagOrVarIdx; +COMMON_DATA u16 gLastQuestLogStoredFlagOrVarIdx = 0; extern u16 *const gSpecialVars[]; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 5e505e336..442aa15ff 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -43,7 +43,7 @@ static EWRAM_DATA struct EvoInfo *sEvoStructPtr = NULL; static EWRAM_DATA u16 *sBgAnimPal = NULL; // IWRAM common -void (*gCB2_AfterEvolution)(void); +COMMON_DATA void (*gCB2_AfterEvolution)(void) = NULL; #define sEvoCursorPos gBattleCommunication[1] // when learning a new move #define sEvoGraphicsTaskId gBattleCommunication[2] diff --git a/src/fame_checker.c b/src/fame_checker.c index 3c0c76963..ea1724922 100644 --- a/src/fame_checker.c +++ b/src/fame_checker.c @@ -57,8 +57,8 @@ static EWRAM_DATA struct FameCheckerData * sFameCheckerData = NULL; static EWRAM_DATA struct ListMenuItem * sListMenuItems = NULL; static EWRAM_DATA s32 sLastMenuIdx = 0; -struct ListMenuTemplate gFameChecker_ListMenuTemplate; -u8 gIconDescriptionBoxIsOpen; +COMMON_DATA struct ListMenuTemplate gFameChecker_ListMenuTemplate = {0}; +COMMON_DATA u8 gIconDescriptionBoxIsOpen = 0; static void MainCB2_LoadFameChecker(void); static void LoadUISpriteSheetsAndPalettes(void); diff --git a/src/field_camera.c b/src/field_camera.c index e2839d76e..e8d401907 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -37,9 +37,9 @@ static s16 sVerticalCameraPan; static u8 sBikeCameraPanFlag; static void (*sFieldCameraPanningCallback)(void); -struct CameraObject gFieldCamera; -u16 gTotalCameraPixelOffsetY; -u16 gTotalCameraPixelOffsetX; +COMMON_DATA struct CameraObject gFieldCamera = {0}; +COMMON_DATA u16 gTotalCameraPixelOffsetY = 0; +COMMON_DATA u16 gTotalCameraPixelOffsetX = 0; // text static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraOffset *cameraOffset) diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 5a6927861..b1b646594 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -71,7 +71,7 @@ static bool8 TryDoorWarp(struct MapPosition * position, u16 metatileBehavior, u8 static s8 GetWarpEventAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z); static const u8 *GetCoordEventScriptAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z); -struct FieldInput gFieldInputRecord; +COMMON_DATA struct FieldInput gFieldInputRecord = {0}; void FieldClearPlayerInput(struct FieldInput *input) { diff --git a/src/field_specials.c b/src/field_specials.c index 3c279395e..08b7ced2d 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -50,8 +50,8 @@ static EWRAM_DATA u16 sListMenuLastScrollPosition = 0; static EWRAM_DATA u8 sPCBoxToSendMon = 0; static EWRAM_DATA u8 sBrailleTextCursorSpriteID = 0; -struct ListMenuTemplate sFieldSpecialsListMenuTemplate; -u16 sFieldSpecialsListMenuScrollBuffer; +COMMON_DATA struct ListMenuTemplate sFieldSpecialsListMenuTemplate = {0}; +COMMON_DATA u16 sFieldSpecialsListMenuScrollBuffer = 0; static void Task_AnimatePcTurnOn(u8 taskId); static void PcTurnOnUpdateMetatileId(bool16 flag); diff --git a/src/fieldmap.c b/src/fieldmap.c index bd69c0533..415677722 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -14,7 +14,7 @@ struct ConnectionFlags u8 east:1; }; -struct BackupMapLayout VMap; +COMMON_DATA struct BackupMapLayout VMap = {0}; EWRAM_DATA u16 gBackupMapData[VIRTUAL_MAP_SIZE] = {}; EWRAM_DATA struct MapHeader gMapHeader = {}; EWRAM_DATA struct Camera gCamera = {}; diff --git a/src/help_system.c b/src/help_system.c index 86c749bd4..00756538e 100644 --- a/src/help_system.c +++ b/src/help_system.c @@ -51,8 +51,8 @@ struct HelpSystemState u8 scrollSub; }; -struct HelpSystemState gHelpSystemState; -u16 gHelpContextIdBackup; +COMMON_DATA struct HelpSystemState gHelpSystemState = {0}; +COMMON_DATA u16 gHelpContextIdBackup = 0; static bool32 IsCurrentMapInArray(const u16 * mapIdxs); static void BuildMainTopicsListAndMoveToH00(struct HelpSystemListMenu * a0, struct ListMenuItem * a1); diff --git a/src/help_system_util.c b/src/help_system_util.c index 546fda934..d07881e00 100644 --- a/src/help_system_util.c +++ b/src/help_system_util.c @@ -10,7 +10,7 @@ #define ZERO 0 -bool8 gHelpSystemEnabled; +COMMON_DATA bool8 gHelpSystemEnabled = 0; struct HelpSystemVideoState { diff --git a/src/image_processing_effects.c b/src/image_processing_effects.c index 01364c354..d0213527e 100644 --- a/src/image_processing_effects.c +++ b/src/image_processing_effects.c @@ -2,16 +2,16 @@ #include "image_processing_effects.h" // IWRAM common -u8 gCanvasColumnStart; -u16 (*gCanvasPixels)[][32]; -u8 gCanvasRowEnd; -u8 gCanvasHeight; -u8 gCanvasColumnEnd; -u8 gCanvasRowStart; -u8 gCanvasMonPersonality; -u8 gCanvasWidth; -u16 *gCanvasPalette; -u16 gCanvasPaletteStart; +COMMON_DATA u8 gCanvasColumnStart = 0; +COMMON_DATA u16 (*gCanvasPixels)[][32] = {0}; +COMMON_DATA u8 gCanvasRowEnd = 0; +COMMON_DATA u8 gCanvasHeight = 0; +COMMON_DATA u8 gCanvasColumnEnd = 0; +COMMON_DATA u8 gCanvasRowStart = 0; +COMMON_DATA u8 gCanvasMonPersonality = 0; +COMMON_DATA u8 gCanvasWidth = 0; +COMMON_DATA u16 *gCanvasPalette = NULL; +COMMON_DATA u16 gCanvasPaletteStart = 0; static void ApplyImageEffect_Pointillism(void); static void ApplyImageEffect_Blur(void); diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index 69fbbd13f..0bfa13abb 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -68,11 +68,11 @@ static void rfu_STC_NI_receive_Sender(u8, u8, const struct RfuLocalStruct *, con static void rfu_STC_NI_initSlot_asRecvDataEntity(u8, struct NIComm *); static void rfu_STC_NI_initSlot_asRecvControllData(u8, struct NIComm *); -struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX]; -struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX]; -struct RfuLinkStatus *gRfuLinkStatus; -struct RfuStatic *gRfuStatic; -struct RfuFixed *gRfuFixed; +COMMON_DATA struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX] = {0}; +COMMON_DATA struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX] = {0}; +COMMON_DATA struct RfuLinkStatus *gRfuLinkStatus = NULL; +COMMON_DATA struct RfuStatic *gRfuStatic = NULL; +COMMON_DATA struct RfuFixed *gRfuFixed = NULL; static const struct LLSFStruct llsf_struct[2] = { [MODE_CHILD] = { diff --git a/src/librfu_sio32id.c b/src/librfu_sio32id.c index d726bca7b..56a18d293 100644 --- a/src/librfu_sio32id.c +++ b/src/librfu_sio32id.c @@ -15,7 +15,7 @@ struct RfuSIO32Id u16 lastId; }; -struct RfuSIO32Id gRfuSIO32Id; +COMMON_DATA struct RfuSIO32Id gRfuSIO32Id = {0}; static const u16 Sio32ConnectionData[] = { 0x494e, 0x544e, 0x4e45, 0x4f44 }; // NINTENDO static const char Sio32IDLib_Var[] = "Sio32ID_030820"; diff --git a/src/librfu_stwi.c b/src/librfu_stwi.c index fb90cb452..7b3b486ca 100644 --- a/src/librfu_stwi.c +++ b/src/librfu_stwi.c @@ -8,7 +8,7 @@ static void STWI_stop_timer(void); static s32 STWI_restart_Command(void); static s32 STWI_reset_ClockCounter(void); -struct STWIStatus *gSTWIStatus; +COMMON_DATA struct STWIStatus *gSTWIStatus = NULL; void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam) { diff --git a/src/link.c b/src/link.c index f883db482..959264a40 100644 --- a/src/link.c +++ b/src/link.c @@ -62,41 +62,41 @@ static u16 sRecvNonzeroCheck; static u8 sChecksumAvailable; static u8 sHandshakePlayerCount; -u16 gLinkPartnersHeldKeys[6]; -u32 gLinkDebugSeed; -struct LinkPlayerBlock gLocalLinkPlayerBlock; -bool8 gLinkErrorOccurred; -u32 gLinkDebugFlags; -u32 gLinkFiller1; -bool8 gRemoteLinkPlayersNotReceived[MAX_LINK_PLAYERS]; -u8 gBlockReceivedStatus[MAX_LINK_PLAYERS]; -u32 gLinkFiller2; -u16 gLinkHeldKeys; -u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH]; -u32 gLinkStatus; -bool8 gLinkDummy1; // Never read -bool8 gLinkDummy2; // Never read -bool8 gReadyToExitStandby[MAX_LINK_PLAYERS]; -bool8 gReadyToCloseLink[MAX_LINK_PLAYERS]; -u16 gReadyCloseLinkType; -u8 gSuppressLinkErrorMessage; -u8 gWirelessCommType; -u8 gSavedLinkPlayerCount; -u16 gSendCmd[CMD_LENGTH]; -u8 gSavedMultiplayerId; -bool8 gReceivedRemoteLinkPlayers; -struct LinkTestBGInfo gLinkTestBGInfo; -void (*gLinkCallback)(void); -u8 gShouldAdvanceLinkState; -u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS]; -u8 gBlockRequestType; -u32 gLinkFiller3; // file -u32 gLinkFiller4; // boundary -u32 gLinkFiller5; // here? -u8 gLastSendQueueCount; -struct Link gLink; -u8 gLastRecvQueueCount; -u16 gLinkSavedIme; +COMMON_DATA u16 gLinkPartnersHeldKeys[6] = {0}; +COMMON_DATA u32 gLinkDebugSeed = 0; +COMMON_DATA struct LinkPlayerBlock gLocalLinkPlayerBlock = {0}; +COMMON_DATA bool8 gLinkErrorOccurred = 0; +COMMON_DATA u32 gLinkDebugFlags = 0; +COMMON_DATA u32 gLinkFiller1 = 0; +COMMON_DATA bool8 gRemoteLinkPlayersNotReceived[MAX_LINK_PLAYERS] = {0}; +COMMON_DATA u8 gBlockReceivedStatus[MAX_LINK_PLAYERS] = {0}; +COMMON_DATA u32 gLinkFiller2 = 0; +COMMON_DATA u16 gLinkHeldKeys = 0; +COMMON_DATA u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH] = {0}; +COMMON_DATA u32 gLinkStatus = 0; +COMMON_DATA bool8 gLinkDummy1 = 0; // Never read +COMMON_DATA bool8 gLinkDummy2 = 0; // Never read +COMMON_DATA bool8 gReadyToExitStandby[MAX_LINK_PLAYERS] = {0}; +COMMON_DATA bool8 gReadyToCloseLink[MAX_LINK_PLAYERS] = {0}; +COMMON_DATA u16 gReadyCloseLinkType = 0; +COMMON_DATA u8 gSuppressLinkErrorMessage = 0; +COMMON_DATA u8 gWirelessCommType = 0; +COMMON_DATA u8 gSavedLinkPlayerCount = 0; +COMMON_DATA u16 gSendCmd[CMD_LENGTH] = {0}; +COMMON_DATA u8 gSavedMultiplayerId = 0; +COMMON_DATA bool8 gReceivedRemoteLinkPlayers = 0; +COMMON_DATA struct LinkTestBGInfo gLinkTestBGInfo = {0}; +COMMON_DATA void (*gLinkCallback)(void) = NULL; +COMMON_DATA u8 gShouldAdvanceLinkState = 0; +COMMON_DATA u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS] = {0}; +COMMON_DATA u8 gBlockRequestType = 0; +COMMON_DATA u32 gLinkFiller3 = 0; // file +COMMON_DATA u32 gLinkFiller4 = 0; // boundary +COMMON_DATA u32 gLinkFiller5 = 0; // here? +COMMON_DATA u8 gLastSendQueueCount = 0; +COMMON_DATA struct Link gLink = {0}; +COMMON_DATA u8 gLastRecvQueueCount = 0; +COMMON_DATA u16 gLinkSavedIme = 0; static EWRAM_DATA bool8 sLinkTestDebugValuesEnabled = FALSE; static EWRAM_DATA bool8 sDummyFlag = FALSE; diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 43614712d..2a58279c0 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -75,9 +75,9 @@ static u32 sRfuAPIBuffer[RFU_API_BUFF_SIZE_RAM / 4]; static u8 sResendBlock8[CMD_LENGTH * 2]; static u16 sResendBlock16[CMD_LENGTH]; -struct RfuGameData gHostRfuGameData; -struct RfuManager gRfu; -u8 gHostRfuUsername[PLAYER_NAME_LENGTH + 1]; +COMMON_DATA struct RfuGameData gHostRfuGameData = {0}; +COMMON_DATA struct RfuManager gRfu = {0}; +COMMON_DATA u8 gHostRfuUsername[PLAYER_NAME_LENGTH + 1] = {0}; static void InitChildRecvBuffers(void); static void InitParentSendData(void); diff --git a/src/list_menu.c b/src/list_menu.c index d759f6d79..36b81faec 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -39,8 +39,8 @@ struct MoveMenuInfoIcon static EWRAM_DATA struct MysteryGiftLinkMenuStruct sMysteryGiftLinkMenu = {0}; -struct ListMenuOverride gListMenuOverride; -struct ListMenuTemplate gMultiuseListMenuTemplate; +COMMON_DATA struct ListMenuOverride gListMenuOverride = {0}; +COMMON_DATA struct ListMenuTemplate gMultiuseListMenuTemplate = {0}; static u8 ListMenuInitInternal(const struct ListMenuTemplate *listMenuTemplate, u16 cursorPos, u16 itemsAbove); static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAndCallCallback, u8 count, bool8 movingDown); diff --git a/src/load_save.c b/src/load_save.c index b81e78acc..d71130507 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -37,10 +37,10 @@ EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0}; EWRAM_DATA u32 gLastEncryptionKey = 0; // IWRAM common -bool32 gFlashMemoryPresent; -struct SaveBlock1 *gSaveBlock1Ptr; -struct SaveBlock2 *gSaveBlock2Ptr; -struct PokemonStorage *gPokemonStoragePtr; +COMMON_DATA bool32 gFlashMemoryPresent = 0; +COMMON_DATA struct SaveBlock1 *gSaveBlock1Ptr = NULL; +COMMON_DATA struct SaveBlock2 *gSaveBlock2Ptr = NULL; +COMMON_DATA struct PokemonStorage *gPokemonStoragePtr = NULL; void CheckForFlashMemory(void) { diff --git a/src/m4a.c b/src/m4a.c index 365e7f6aa..31d519d7b 100644 --- a/src/m4a.c +++ b/src/m4a.c @@ -7,18 +7,18 @@ extern const u8 gCgb3Vol[]; BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0}; -struct SoundInfo gSoundInfo; -struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES]; -struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES]; -MPlayFunc gMPlayJumpTable[36]; -struct CgbChannel gCgbChans[4]; -struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2]; -struct PokemonCrySong gPokemonCrySong; -struct MusicPlayerInfo gMPlayInfo_BGM; -struct MusicPlayerInfo gMPlayInfo_SE1; -struct MusicPlayerInfo gMPlayInfo_SE2; -struct MusicPlayerInfo gMPlayInfo_SE3; -u8 gMPlayMemAccArea[0x10]; +COMMON_DATA struct SoundInfo gSoundInfo = {0}; +COMMON_DATA struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES] = {0}; +COMMON_DATA struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES] = {0}; +COMMON_DATA MPlayFunc gMPlayJumpTable[36] = {0}; +COMMON_DATA struct CgbChannel gCgbChans[4] = {0}; +COMMON_DATA struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2] = {0}; +COMMON_DATA struct PokemonCrySong gPokemonCrySong = {0}; +COMMON_DATA struct MusicPlayerInfo gMPlayInfo_BGM = {0}; +COMMON_DATA struct MusicPlayerInfo gMPlayInfo_SE1 = {0}; +COMMON_DATA struct MusicPlayerInfo gMPlayInfo_SE2 = {0}; +COMMON_DATA u8 gMPlayMemAccArea[0x10] = {0}; +COMMON_DATA struct MusicPlayerInfo gMPlayInfo_SE3 = {0}; u32 MidiKeyToFreq(struct WaveData *wav, u8 key, u8 fineAdjust) { diff --git a/src/main.c b/src/main.c index 8ee89c994..f2d77a8c2 100644 --- a/src/main.c +++ b/src/main.c @@ -58,21 +58,18 @@ const IntrFunc gIntrTableTemplate[] = #define INTR_COUNT ((int)(sizeof(gIntrTableTemplate)/sizeof(IntrFunc))) -u16 gKeyRepeatStartDelay; -u8 gLinkTransferringData; -struct Main gMain; -u16 gKeyRepeatContinueDelay; -u8 gSoftResetDisabled; -IntrFunc gIntrTable[INTR_COUNT]; -bool8 gLinkVSyncDisabled; -u32 IntrMain_Buffer[0x200]; -u8 gPcmDmaCounter; - -// These variables are not defined in RS or Emerald, and are never read. -// They were likely used to debug the audio engine and VCount interrupt. -u8 sVcountAfterSound; -u8 sVcountAtIntr; -u8 sVcountBeforeSound; +COMMON_DATA u16 gKeyRepeatStartDelay = 0; +COMMON_DATA u8 gLinkTransferringData = 0; +COMMON_DATA struct Main gMain = {0}; +COMMON_DATA u16 gKeyRepeatContinueDelay = 0; +COMMON_DATA u8 gSoftResetDisabled = 0; +COMMON_DATA IntrFunc gIntrTable[INTR_COUNT] = {0}; +COMMON_DATA u8 sVcountAfterSound = 0; +COMMON_DATA bool8 gLinkVSyncDisabled = 0; +COMMON_DATA u32 IntrMain_Buffer[0x200] = {0}; +COMMON_DATA u8 sVcountAtIntr = 0; +COMMON_DATA u8 sVcountBeforeSound = 0; +COMMON_DATA u8 gPcmDmaCounter = 0; static IntrFunc * const sTimerIntrFunc = gIntrTable + 0x7; diff --git a/src/overworld.c b/src/overworld.c index 830146cfe..1b81b360c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -106,14 +106,14 @@ static EWRAM_DATA s16 sCreditsOverworld_CmdIndex = 0; EWRAM_DATA struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4] = {}; -u16 *gBGTilemapBuffers1; -u16 *gBGTilemapBuffers2; -u16 *gBGTilemapBuffers3; -void (*gFieldCallback)(void); -bool8 (*gFieldCallback2)(void); -u16 gHeldKeyCodeToSend; -u8 gLocalLinkPlayerId; -u8 gFieldLinkPlayerCount; +COMMON_DATA u16 *gBGTilemapBuffers1 = NULL; +COMMON_DATA u16 *gBGTilemapBuffers2 = NULL; +COMMON_DATA u16 *gBGTilemapBuffers3 = NULL; +COMMON_DATA void (*gFieldCallback)(void) = NULL; +COMMON_DATA bool8 (*gFieldCallback2)(void) = NULL; +COMMON_DATA u16 gHeldKeyCodeToSend = 0; +COMMON_DATA u8 gLocalLinkPlayerId = 0; +COMMON_DATA u8 gFieldLinkPlayerCount = 0; static u8 sPlayerLinkStates[MAX_LINK_PLAYERS]; static KeyInterCB sPlayerKeyInterceptCallback; diff --git a/src/party_menu.c b/src/party_menu.c index 62377341d..7f3a881e6 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -414,7 +414,7 @@ EWRAM_DATA u8 gSelectedOrderFromParty[3] = {0}; static EWRAM_DATA u16 sPartyMenuItemId = ITEM_NONE; ALIGNED(4) EWRAM_DATA u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2] = {0}; // bits 0-3 are the current pos of Slot 1, 4-7 are Slot 2, and so on -void (*gItemUseCB)(u8, TaskFunc); +COMMON_DATA void (*gItemUseCB)(u8, TaskFunc) = NULL; #include "data/pokemon/tutor_learnsets.h" #include "data/party_menu.h" diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 2ff2483b1..b3e3c7763 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -5212,7 +5212,7 @@ static bool32 CurrentMonIsFromGBA(void) static bool32 MapSecIsInKantoOrSevii(u8 mapSec) { - if (mapSec >= MAPSECS_KANTO && mapSec < MAPSEC_NONE) + if (mapSec >= KANTO_MAPSEC_START && mapSec < MAPSEC_NONE) return TRUE; return FALSE; } diff --git a/src/quest_log.c b/src/quest_log.c index 168a57af3..0a2f76f2c 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -67,10 +67,10 @@ struct FlagOrVarRecord u16 value; }; -u8 gQuestLogPlaybackState; -u16 sMaxActionsInScene; -struct FieldInput gQuestLogFieldInput; -struct QuestLogAction * sCurSceneActions; +COMMON_DATA u8 gQuestLogPlaybackState = 0; +COMMON_DATA u16 sMaxActionsInScene = 0; +COMMON_DATA struct FieldInput gQuestLogFieldInput = {0}; +COMMON_DATA struct QuestLogAction * sCurSceneActions = NULL; static struct FlagOrVarRecord * sFlagOrVarRecords; static u16 sNumFlagsOrVars; diff --git a/src/random.c b/src/random.c index 413a3e60d..635a1df5a 100644 --- a/src/random.c +++ b/src/random.c @@ -4,7 +4,7 @@ // The number 1103515245 comes from the example implementation // of rand and srand in the ISO C standard. -u32 gRngValue; +COMMON_DATA u32 gRngValue = 0; u16 Random(void) { diff --git a/src/region_map.c b/src/region_map.c index 270327875..baa0d45a3 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -826,114 +826,114 @@ static const u8 sTextColors[] = {TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_CO #include "data/region_map/region_map_layout_sevii_67.h" static const u8 sMapFlyDestinations[][3] = { - [MAPSEC_PALLET_TOWN - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_PALLET_TOWN}, - [MAPSEC_VIRIDIAN_CITY - MAPSECS_KANTO] = {MAP(MAP_VIRIDIAN_CITY), HEAL_LOCATION_VIRIDIAN_CITY}, - [MAPSEC_PEWTER_CITY - MAPSECS_KANTO] = {MAP(MAP_PEWTER_CITY), HEAL_LOCATION_PEWTER_CITY}, - [MAPSEC_CERULEAN_CITY - MAPSECS_KANTO] = {MAP(MAP_CERULEAN_CITY), HEAL_LOCATION_CERULEAN_CITY}, - [MAPSEC_LAVENDER_TOWN - MAPSECS_KANTO] = {MAP(MAP_LAVENDER_TOWN), HEAL_LOCATION_LAVENDER_TOWN}, - [MAPSEC_VERMILION_CITY - MAPSECS_KANTO] = {MAP(MAP_VERMILION_CITY), HEAL_LOCATION_VERMILION_CITY}, - [MAPSEC_CELADON_CITY - MAPSECS_KANTO] = {MAP(MAP_CELADON_CITY), HEAL_LOCATION_CELADON_CITY}, - [MAPSEC_FUCHSIA_CITY - MAPSECS_KANTO] = {MAP(MAP_FUCHSIA_CITY), HEAL_LOCATION_FUCHSIA_CITY}, - [MAPSEC_CINNABAR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_CINNABAR_ISLAND), HEAL_LOCATION_CINNABAR_ISLAND}, - [MAPSEC_INDIGO_PLATEAU - MAPSECS_KANTO] = {MAP(MAP_INDIGO_PLATEAU_EXTERIOR), HEAL_LOCATION_INDIGO_PLATEAU}, - [MAPSEC_SAFFRON_CITY - MAPSECS_KANTO] = {MAP(MAP_SAFFRON_CITY), HEAL_LOCATION_SAFFRON_CITY}, - [MAPSEC_ROUTE_4_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), HEAL_LOCATION_ROUTE4}, - [MAPSEC_ROUTE_10_POKECENTER - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), HEAL_LOCATION_ROUTE10}, - [MAPSEC_ROUTE_1 - MAPSECS_KANTO] = {MAP(MAP_ROUTE1), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_2 - MAPSECS_KANTO] = {MAP(MAP_ROUTE2), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_3 - MAPSECS_KANTO] = {MAP(MAP_ROUTE3), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_4 - MAPSECS_KANTO] = {MAP(MAP_ROUTE4), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_5 - MAPSECS_KANTO] = {MAP(MAP_ROUTE5), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_6 - MAPSECS_KANTO] = {MAP(MAP_ROUTE6), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_7 - MAPSECS_KANTO] = {MAP(MAP_ROUTE7), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_8 - MAPSECS_KANTO] = {MAP(MAP_ROUTE8), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_9 - MAPSECS_KANTO] = {MAP(MAP_ROUTE9), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_10 - MAPSECS_KANTO] = {MAP(MAP_ROUTE10), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_11 - MAPSECS_KANTO] = {MAP(MAP_ROUTE11), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_12 - MAPSECS_KANTO] = {MAP(MAP_ROUTE12), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_13 - MAPSECS_KANTO] = {MAP(MAP_ROUTE13), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_14 - MAPSECS_KANTO] = {MAP(MAP_ROUTE14), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_15 - MAPSECS_KANTO] = {MAP(MAP_ROUTE15), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_16 - MAPSECS_KANTO] = {MAP(MAP_ROUTE16), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_17 - MAPSECS_KANTO] = {MAP(MAP_ROUTE17), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_18 - MAPSECS_KANTO] = {MAP(MAP_ROUTE18), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_19 - MAPSECS_KANTO] = {MAP(MAP_ROUTE19), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_20 - MAPSECS_KANTO] = {MAP(MAP_ROUTE20), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_21 - MAPSECS_KANTO] = {MAP(MAP_ROUTE21_NORTH), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_22 - MAPSECS_KANTO] = {MAP(MAP_ROUTE22), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_23 - MAPSECS_KANTO] = {MAP(MAP_ROUTE23), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_24 - MAPSECS_KANTO] = {MAP(MAP_ROUTE24), HEAL_LOCATION_NONE}, - [MAPSEC_ROUTE_25 - MAPSECS_KANTO] = {MAP(MAP_ROUTE25), HEAL_LOCATION_NONE}, - [MAPSEC_VIRIDIAN_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_MT_MOON - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_S_S_ANNE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_UNDERGROUND_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_UNDERGROUND_PATH_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_DIGLETTS_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_KANTO_VICTORY_ROAD - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ROCKET_HIDEOUT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_SILPH_CO - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_POKEMON_MANSION - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_KANTO_SAFARI_ZONE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_POKEMON_LEAGUE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ROCK_TUNNEL - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_SEAFOAM_ISLANDS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_POKEMON_TOWER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_CERULEAN_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_POWER_PLANT - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ONE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND), HEAL_LOCATION_ONE_ISLAND}, - [MAPSEC_TWO_ISLAND - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND), HEAL_LOCATION_TWO_ISLAND}, - [MAPSEC_THREE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND), HEAL_LOCATION_THREE_ISLAND}, - [MAPSEC_FOUR_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FOUR_ISLAND), HEAL_LOCATION_FOUR_ISLAND}, - [MAPSEC_FIVE_ISLAND - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND), HEAL_LOCATION_FIVE_ISLAND}, - [MAPSEC_SEVEN_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND), HEAL_LOCATION_SEVEN_ISLAND}, - [MAPSEC_SIX_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND), HEAL_LOCATION_SIX_ISLAND}, - [MAPSEC_KINDLE_ROAD - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_KINDLE_ROAD), HEAL_LOCATION_NONE}, - [MAPSEC_TREASURE_BEACH - MAPSECS_KANTO] = {MAP(MAP_ONE_ISLAND_TREASURE_BEACH), HEAL_LOCATION_NONE}, - [MAPSEC_CAPE_BRINK - MAPSECS_KANTO] = {MAP(MAP_TWO_ISLAND_CAPE_BRINK), HEAL_LOCATION_NONE}, - [MAPSEC_BOND_BRIDGE - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_BOND_BRIDGE), HEAL_LOCATION_NONE}, - [MAPSEC_THREE_ISLE_PORT - MAPSECS_KANTO] = {MAP(MAP_THREE_ISLAND_PORT), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_6 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_6), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_7 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_7), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_8 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_8), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_9 - MAPSECS_KANTO] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_9), HEAL_LOCATION_NONE}, - [MAPSEC_RESORT_GORGEOUS - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_RESORT_GORGEOUS), HEAL_LOCATION_NONE}, - [MAPSEC_WATER_LABYRINTH - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_WATER_LABYRINTH), HEAL_LOCATION_NONE}, - [MAPSEC_FIVE_ISLE_MEADOW - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEADOW), HEAL_LOCATION_NONE}, - [MAPSEC_MEMORIAL_PILLAR - MAPSECS_KANTO] = {MAP(MAP_FIVE_ISLAND_MEMORIAL_PILLAR), HEAL_LOCATION_NONE}, - [MAPSEC_OUTCAST_ISLAND - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_OUTCAST_ISLAND), HEAL_LOCATION_NONE}, - [MAPSEC_GREEN_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_GREEN_PATH), HEAL_LOCATION_NONE}, - [MAPSEC_WATER_PATH - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_WATER_PATH), HEAL_LOCATION_NONE}, - [MAPSEC_RUIN_VALLEY - MAPSECS_KANTO] = {MAP(MAP_SIX_ISLAND_RUIN_VALLEY), HEAL_LOCATION_NONE}, - [MAPSEC_TRAINER_TOWER - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TRAINER_TOWER), HEAL_LOCATION_NONE}, - [MAPSEC_CANYON_ENTRANCE - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON_ENTRANCE), HEAL_LOCATION_NONE}, - [MAPSEC_SEVAULT_CANYON - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON), HEAL_LOCATION_NONE}, - [MAPSEC_TANOBY_RUINS - MAPSECS_KANTO] = {MAP(MAP_SEVEN_ISLAND_TANOBY_RUINS), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_22 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_23 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_SEVII_ISLE_24 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_NAVEL_ROCK - MAPSECS_KANTO] = {MAP(MAP_NAVEL_ROCK_EXTERIOR), HEAL_LOCATION_NONE}, - [MAPSEC_MT_EMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_BERRY_FOREST - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ICEFALL_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ROCKET_WAREHOUSE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_TRAINER_TOWER_2 - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_DOTTED_HOLE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_LOST_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_PATTERN_BUSH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_ALTERING_CAVE - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_TANOBY_CHAMBERS - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_THREE_ISLE_PATH - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_TANOBY_KEY - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_BIRTH_ISLAND - MAPSECS_KANTO] = {MAP(MAP_BIRTH_ISLAND_EXTERIOR), HEAL_LOCATION_NONE}, - [MAPSEC_MONEAN_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_LIPTOO_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_WEEPTH_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_DILFORD_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_SCUFIB_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_RIXY_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_VIAPOIS_CHAMBER - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, - [MAPSEC_EMBER_SPA - MAPSECS_KANTO] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_PALLET_TOWN - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_PALLET_TOWN}, + [MAPSEC_VIRIDIAN_CITY - KANTO_MAPSEC_START] = {MAP(MAP_VIRIDIAN_CITY), HEAL_LOCATION_VIRIDIAN_CITY}, + [MAPSEC_PEWTER_CITY - KANTO_MAPSEC_START] = {MAP(MAP_PEWTER_CITY), HEAL_LOCATION_PEWTER_CITY}, + [MAPSEC_CERULEAN_CITY - KANTO_MAPSEC_START] = {MAP(MAP_CERULEAN_CITY), HEAL_LOCATION_CERULEAN_CITY}, + [MAPSEC_LAVENDER_TOWN - KANTO_MAPSEC_START] = {MAP(MAP_LAVENDER_TOWN), HEAL_LOCATION_LAVENDER_TOWN}, + [MAPSEC_VERMILION_CITY - KANTO_MAPSEC_START] = {MAP(MAP_VERMILION_CITY), HEAL_LOCATION_VERMILION_CITY}, + [MAPSEC_CELADON_CITY - KANTO_MAPSEC_START] = {MAP(MAP_CELADON_CITY), HEAL_LOCATION_CELADON_CITY}, + [MAPSEC_FUCHSIA_CITY - KANTO_MAPSEC_START] = {MAP(MAP_FUCHSIA_CITY), HEAL_LOCATION_FUCHSIA_CITY}, + [MAPSEC_CINNABAR_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_CINNABAR_ISLAND), HEAL_LOCATION_CINNABAR_ISLAND}, + [MAPSEC_INDIGO_PLATEAU - KANTO_MAPSEC_START] = {MAP(MAP_INDIGO_PLATEAU_EXTERIOR), HEAL_LOCATION_INDIGO_PLATEAU}, + [MAPSEC_SAFFRON_CITY - KANTO_MAPSEC_START] = {MAP(MAP_SAFFRON_CITY), HEAL_LOCATION_SAFFRON_CITY}, + [MAPSEC_ROUTE_4_POKECENTER - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE4), HEAL_LOCATION_ROUTE4}, + [MAPSEC_ROUTE_10_POKECENTER - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE10), HEAL_LOCATION_ROUTE10}, + [MAPSEC_ROUTE_1 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE1), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_2 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE2), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_3 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE3), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_4 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE4), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_5 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE5), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_6 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE6), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_7 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE7), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_8 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE8), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_9 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE9), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_10 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE10), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_11 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE11), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_12 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE12), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_13 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE13), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_14 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE14), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_15 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE15), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_16 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE16), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_17 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE17), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_18 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE18), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_19 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE19), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_20 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE20), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_21 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE21_NORTH), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_22 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE22), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_23 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE23), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_24 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE24), HEAL_LOCATION_NONE}, + [MAPSEC_ROUTE_25 - KANTO_MAPSEC_START] = {MAP(MAP_ROUTE25), HEAL_LOCATION_NONE}, + [MAPSEC_VIRIDIAN_FOREST - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_MT_MOON - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_S_S_ANNE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_UNDERGROUND_PATH - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_UNDERGROUND_PATH_2 - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DIGLETTS_CAVE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_KANTO_VICTORY_ROAD - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCKET_HIDEOUT - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SILPH_CO - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_MANSION - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_KANTO_SAFARI_ZONE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_LEAGUE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCK_TUNNEL - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEAFOAM_ISLANDS - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POKEMON_TOWER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_CERULEAN_CAVE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_POWER_PLANT - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ONE_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_ONE_ISLAND), HEAL_LOCATION_ONE_ISLAND}, + [MAPSEC_TWO_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_TWO_ISLAND), HEAL_LOCATION_TWO_ISLAND}, + [MAPSEC_THREE_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_THREE_ISLAND), HEAL_LOCATION_THREE_ISLAND}, + [MAPSEC_FOUR_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_FOUR_ISLAND), HEAL_LOCATION_FOUR_ISLAND}, + [MAPSEC_FIVE_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_FIVE_ISLAND), HEAL_LOCATION_FIVE_ISLAND}, + [MAPSEC_SEVEN_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_SEVEN_ISLAND), HEAL_LOCATION_SEVEN_ISLAND}, + [MAPSEC_SIX_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_SIX_ISLAND), HEAL_LOCATION_SIX_ISLAND}, + [MAPSEC_KINDLE_ROAD - KANTO_MAPSEC_START] = {MAP(MAP_ONE_ISLAND_KINDLE_ROAD), HEAL_LOCATION_NONE}, + [MAPSEC_TREASURE_BEACH - KANTO_MAPSEC_START] = {MAP(MAP_ONE_ISLAND_TREASURE_BEACH), HEAL_LOCATION_NONE}, + [MAPSEC_CAPE_BRINK - KANTO_MAPSEC_START] = {MAP(MAP_TWO_ISLAND_CAPE_BRINK), HEAL_LOCATION_NONE}, + [MAPSEC_BOND_BRIDGE - KANTO_MAPSEC_START] = {MAP(MAP_THREE_ISLAND_BOND_BRIDGE), HEAL_LOCATION_NONE}, + [MAPSEC_THREE_ISLE_PORT - KANTO_MAPSEC_START] = {MAP(MAP_THREE_ISLAND_PORT), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_6 - KANTO_MAPSEC_START] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_6), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_7 - KANTO_MAPSEC_START] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_7), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_8 - KANTO_MAPSEC_START] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_8), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_9 - KANTO_MAPSEC_START] = {MAP(MAP_PROTOTYPE_SEVII_ISLE_9), HEAL_LOCATION_NONE}, + [MAPSEC_RESORT_GORGEOUS - KANTO_MAPSEC_START] = {MAP(MAP_FIVE_ISLAND_RESORT_GORGEOUS), HEAL_LOCATION_NONE}, + [MAPSEC_WATER_LABYRINTH - KANTO_MAPSEC_START] = {MAP(MAP_FIVE_ISLAND_WATER_LABYRINTH), HEAL_LOCATION_NONE}, + [MAPSEC_FIVE_ISLE_MEADOW - KANTO_MAPSEC_START] = {MAP(MAP_FIVE_ISLAND_MEADOW), HEAL_LOCATION_NONE}, + [MAPSEC_MEMORIAL_PILLAR - KANTO_MAPSEC_START] = {MAP(MAP_FIVE_ISLAND_MEMORIAL_PILLAR), HEAL_LOCATION_NONE}, + [MAPSEC_OUTCAST_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_SIX_ISLAND_OUTCAST_ISLAND), HEAL_LOCATION_NONE}, + [MAPSEC_GREEN_PATH - KANTO_MAPSEC_START] = {MAP(MAP_SIX_ISLAND_GREEN_PATH), HEAL_LOCATION_NONE}, + [MAPSEC_WATER_PATH - KANTO_MAPSEC_START] = {MAP(MAP_SIX_ISLAND_WATER_PATH), HEAL_LOCATION_NONE}, + [MAPSEC_RUIN_VALLEY - KANTO_MAPSEC_START] = {MAP(MAP_SIX_ISLAND_RUIN_VALLEY), HEAL_LOCATION_NONE}, + [MAPSEC_TRAINER_TOWER - KANTO_MAPSEC_START] = {MAP(MAP_SEVEN_ISLAND_TRAINER_TOWER), HEAL_LOCATION_NONE}, + [MAPSEC_CANYON_ENTRANCE - KANTO_MAPSEC_START] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON_ENTRANCE), HEAL_LOCATION_NONE}, + [MAPSEC_SEVAULT_CANYON - KANTO_MAPSEC_START] = {MAP(MAP_SEVEN_ISLAND_SEVAULT_CANYON), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_RUINS - KANTO_MAPSEC_START] = {MAP(MAP_SEVEN_ISLAND_TANOBY_RUINS), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_22 - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_23 - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SEVII_ISLE_24 - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_NAVEL_ROCK - KANTO_MAPSEC_START] = {MAP(MAP_NAVEL_ROCK_EXTERIOR), HEAL_LOCATION_NONE}, + [MAPSEC_MT_EMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_BERRY_FOREST - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ICEFALL_CAVE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ROCKET_WAREHOUSE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TRAINER_TOWER_2 - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DOTTED_HOLE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_LOST_CAVE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_PATTERN_BUSH - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_ALTERING_CAVE - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_CHAMBERS - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_THREE_ISLE_PATH - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_TANOBY_KEY - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_BIRTH_ISLAND - KANTO_MAPSEC_START] = {MAP(MAP_BIRTH_ISLAND_EXTERIOR), HEAL_LOCATION_NONE}, + [MAPSEC_MONEAN_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_LIPTOO_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_WEEPTH_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_DILFORD_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_SCUFIB_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_RIXY_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_VIAPOIS_CHAMBER - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, + [MAPSEC_EMBER_SPA - KANTO_MAPSEC_START] = {MAP(MAP_PALLET_TOWN), HEAL_LOCATION_NONE}, }; static void RegionMap_DarkenPalette(u16 *pal, u16 size, u16 tint) @@ -1029,7 +1029,7 @@ static void InitRegionMapType(void) sRegionMap->permissions[MAPPERM_HAS_SWITCH_BUTTON] = FALSE; region = REGIONMAP_KANTO; j = REGIONMAP_KANTO; - if (gMapHeader.regionMapSectionId >= MAPSECS_SEVII_123) + if (gMapHeader.regionMapSectionId >= SEVII_MAPSEC_START) { // Mapsec is in Sevii Islands, determine which map to use while (region == REGIONMAP_KANTO) @@ -1470,7 +1470,7 @@ static void DisplayCurrentDungeonName(void) mapsecId = GetDungeonMapsecUnderCursor(); if (mapsecId != MAPSEC_NONE) { - descOffset = mapsecId - MAPSECS_KANTO; + descOffset = mapsecId - KANTO_MAPSEC_START; SetDispCnt(1, FALSE); sRegionMap->dungeonWinTop = TRUE; sRegionMap->dungeonWinLeft = StringLength(sMapNames[descOffset]); @@ -3154,7 +3154,7 @@ static void GetPlayerPositionOnRegionMap(void) break; } - sMapCursor->selectedMapsec -= MAPSECS_KANTO; + sMapCursor->selectedMapsec -= KANTO_MAPSEC_START; divisor = width / sMapSectionDimensions[sMapCursor->selectedMapsec][0]; if (divisor == 0) divisor = 1; @@ -3803,7 +3803,7 @@ u8 *GetMapName(u8 *dst0, u16 mapsec, u16 fill) u8 *dst; u16 i; u16 idx; - if ((idx = mapsec - MAPSECS_KANTO) <= MAPSEC_SPECIAL_AREA - MAPSECS_KANTO) + if ((idx = mapsec - KANTO_MAPSEC_START) <= MAPSEC_SPECIAL_AREA - KANTO_MAPSEC_START) { if (IsCeladonDeptStoreMapsec(mapsec) == TRUE) dst = StringCopy(dst0, sMapsecName_CELADON_DEPT_); @@ -4022,7 +4022,7 @@ static void FreeFlyMap(u8 taskId) static void SetFlyWarpDestination(u16 mapsec) { - u16 idx = mapsec - MAPSECS_KANTO; + u16 idx = mapsec - KANTO_MAPSEC_START; if (sMapFlyDestinations[idx][2]) { SetWarpDestinationToHealLocation(sMapFlyDestinations[idx][2]); diff --git a/src/save.c b/src/save.c index 07def36e4..7a4808924 100644 --- a/src/save.c +++ b/src/save.c @@ -77,18 +77,18 @@ STATIC_ASSERT(sizeof(struct SaveBlock1) <= SECTOR_DATA_SIZE * (SECTOR_ID_SAVEBLO STATIC_ASSERT(sizeof(struct PokemonStorage) <= SECTOR_DATA_SIZE * (SECTOR_ID_PKMN_STORAGE_END - SECTOR_ID_PKMN_STORAGE_START + 1), PokemonStorageFreeSpace); // Sector num to begin writing save data. Sectors are rotated each time the game is saved. (possibly to avoid wear on flash memory?) -u16 gLastWrittenSector; -u32 gLastSaveCounter; -u16 gLastKnownGoodSector; -u32 gDamagedSaveSectors; -u32 gSaveCounter; -struct SaveSector *gSaveDataBufferPtr; // the pointer is in fast IWRAM but points to the slower EWRAM. -u16 gIncrementalSectorId; -u16 gSaveUnusedVar; -u16 gSaveFileStatus; -void (*gGameContinueCallback)(void); -struct SaveSectorLocation gRamSaveSectorLocations[NUM_SECTORS_PER_SLOT]; -u16 gSaveAttemptStatus; +COMMON_DATA u16 gLastWrittenSector = 0; +COMMON_DATA u32 gLastSaveCounter = 0; +COMMON_DATA u16 gLastKnownGoodSector = 0; +COMMON_DATA u32 gDamagedSaveSectors = 0; +COMMON_DATA u32 gSaveCounter = 0; +COMMON_DATA struct SaveSector *gSaveDataBufferPtr = NULL; // the pointer is in fast IWRAM but points to the slower EWRAM. +COMMON_DATA u16 gIncrementalSectorId = 0; +COMMON_DATA u16 gSaveUnusedVar = 0; +COMMON_DATA u16 gSaveFileStatus = 0; +COMMON_DATA void (*gGameContinueCallback)(void) = NULL; +COMMON_DATA struct SaveSectorLocation gRamSaveSectorLocations[NUM_SECTORS_PER_SLOT] = {0}; +COMMON_DATA u16 gSaveAttemptStatus = 0; EWRAM_DATA struct SaveSector gSaveDataBuffer = {0}; EWRAM_DATA u32 gSaveUnusedVar2 = 0; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index ddb45171a..e88e30918 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -7,7 +7,7 @@ #include "save.h" #include "strings.h" -bool32 sIsInSaveFailedScreen; +COMMON_DATA bool32 sIsInSaveFailedScreen = 0; static EWRAM_DATA u16 sSaveType = SAVE_NORMAL; static EWRAM_DATA u16 sUnused = 0; diff --git a/src/scrcmd.c b/src/scrcmd.c index 497155eff..f7481f862 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -54,8 +54,8 @@ static EWRAM_DATA u16 sMovingNpcMapGroup = 0; static EWRAM_DATA u16 sMovingNpcMapNum = 0; static EWRAM_DATA u16 sFieldEffectScriptId = 0; -struct ScriptContext * sQuestLogScriptContextPtr; -u8 gSelectedObjectEvent; +COMMON_DATA struct ScriptContext * sQuestLogScriptContextPtr = NULL; +COMMON_DATA u8 gSelectedObjectEvent = 0; // This is defined in here so the optimizer can't see its value when compiling // script.c. diff --git a/src/sound.c b/src/sound.c index 636f88bb3..9060aa513 100644 --- a/src/sound.c +++ b/src/sound.c @@ -30,7 +30,7 @@ static u8 sMapMusicFadeInSpeed; static u16 sFanfareCounter; // iwram common -bool8 gDisableMusic; +COMMON_DATA bool8 gDisableMusic = 0; extern u32 gBattleTypeFlags; extern struct MusicPlayerInfo gMPlayInfo_BGM; diff --git a/src/sprite.c b/src/sprite.c index afaa8e08d..ae7a055ac 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -270,8 +270,8 @@ static u16 sSpriteTileRanges[MAX_SPRITES * 2]; static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT]; static u16 sSpritePaletteTags[16]; -u32 gOamMatrixAllocBitmap; -u8 gReservedSpritePaletteCount; +COMMON_DATA u32 gOamMatrixAllocBitmap = 0; +COMMON_DATA u8 gReservedSpritePaletteCount = 0; EWRAM_DATA struct Sprite gSprites[MAX_SPRITES + 1] = {0}; EWRAM_DATA u16 gSpritePriorities[MAX_SPRITES] = {0}; diff --git a/src/task.c b/src/task.c index 672d200fe..cd9841d06 100644 --- a/src/task.c +++ b/src/task.c @@ -4,7 +4,7 @@ #define HEAD_SENTINEL 0xFE #define TAIL_SENTINEL 0xFF -struct Task gTasks[NUM_TASKS]; +COMMON_DATA struct Task gTasks[NUM_TASKS] = {0}; static void InsertTask(u8 newTaskId); static u8 FindFirstActiveTask(); diff --git a/src/text.c b/src/text.c index 76739f8c6..b2dcff3b5 100644 --- a/src/text.c +++ b/src/text.c @@ -24,7 +24,7 @@ static s32 GetGlyphWidth_Male(u16 glyphId, bool32 isJapanese); static s32 GetGlyphWidth_Female(u16 glyphId, bool32 isJapanese); static void SpriteCB_TextCursor(struct Sprite *sprite); -TextFlags gTextFlags; +COMMON_DATA TextFlags gTextFlags = {0}; static const u8 sDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp"); static const u8 sDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_RS.4bpp"); diff --git a/src/text_printer.c b/src/text_printer.c index 6710ebfd0..e425ccb18 100644 --- a/src/text_printer.c +++ b/src/text_printer.c @@ -10,8 +10,8 @@ static u16 sLastTextBgColor; static u16 sLastTextFgColor; static u16 sLastTextShadowColor; -const struct FontInfo *gFonts; -struct GlyphInfo gGlyphInfo; +COMMON_DATA const struct FontInfo *gFonts = NULL; +COMMON_DATA struct GlyphInfo gGlyphInfo = {0}; static const u8 sFontHalfRowOffsets[] = { diff --git a/src/window.c b/src/window.c index 1b1d347a0..834f13a8c 100644 --- a/src/window.c +++ b/src/window.c @@ -1,8 +1,8 @@ #include "global.h" #include "gflib.h" -u8 gWindowClearTile; -void *gWindowBgTilemapBuffers[4]; +COMMON_DATA u8 gWindowClearTile = {0}; +COMMON_DATA void *gWindowBgTilemapBuffers[4] = {0}; EWRAM_DATA struct Window gWindows[WINDOWS_MAX] = {0}; diff --git a/tools/ramscrgen/elf.cpp b/tools/ramscrgen/elf.cpp index 7e78704b8..077fcc82a 100644 --- a/tools/ramscrgen/elf.cpp +++ b/tools/ramscrgen/elf.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include "ramscrgen.h" @@ -22,6 +21,7 @@ static int s_shstrtabIndex; static std::uint32_t s_symtabOffset; static std::uint32_t s_strtabOffset; +static std::uint32_t s_pseudoCommonSectionIndex; static std::uint32_t s_symbolCount; static std::uint32_t s_elfFileOffset; @@ -101,18 +101,6 @@ static void VerifyElfIdent() FATAL_ERROR("error: \"%s\" not little-endian ELF\n", s_elfPath.c_str()); } -static void VerifyAr() -{ - char expectedMagic[8] = {'!', '<', 'a', 'r', 'c', 'h', '>', '\n'}; - char magic[8]; - - if (std::fread(magic, 8, 1, s_file) != 1) - FATAL_ERROR("error: failed to read AR magic from \"%s\"\n", s_archiveFilePath.c_str()); - - if (std::memcmp(magic, expectedMagic, 8) != 0) - FATAL_ERROR("error: AR magic did not match in \"%s\"\n", s_archiveFilePath.c_str()); -} - static void ReadElfHeader() { Seek(0x20); @@ -123,40 +111,6 @@ static void ReadElfHeader() s_shstrtabIndex = ReadInt16(); } -static void FindArObj() -{ - char file_ident[17] = {0}; - char filesize_s[11] = {0}; - char expectedEndMagic[2] = { 0x60, 0x0a }; - char end_magic[2]; - std::size_t filesize; - - Seek(8); - while (!std::feof(s_file)) { - if (std::fread(file_ident, 16, 1, s_file) != 1) - FATAL_ERROR("error: failed to read file ident in \"%s\"\n", s_archiveFilePath.c_str()); - Skip(32); - if (std::fread(filesize_s, 10, 1, s_file) != 1) - FATAL_ERROR("error: failed to read filesize in \"%s\"\n", s_archiveFilePath.c_str()); - if (std::fread(end_magic, 2, 1, s_file) != 1) - FATAL_ERROR("error: failed to read end sentinel in \"%s\"\n", s_archiveFilePath.c_str()); - if (std::memcmp(end_magic, expectedEndMagic, 2) != 0) - FATAL_ERROR("error: corrupted archive header in \"%s\" at \"%s\"\n", s_archiveFilePath.c_str(), file_ident); - - char * ptr = std::strchr(file_ident, '/'); - if (ptr != nullptr) - *ptr = 0; - filesize = std::strtoul(filesize_s, nullptr, 10); - if (std::strncmp(s_archiveObjectPath.c_str(), file_ident, 16) == 0) { - s_elfFileOffset = std::ftell(s_file); - return; - } - Skip(filesize); - } - - FATAL_ERROR("error: could not find object \"%s\" in archive \"%s\"\n", s_archiveObjectPath.c_str(), s_archiveFilePath.c_str()); -} - static std::string GetSectionName(std::uint32_t shstrtabOffset, int index) { Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * index); @@ -169,6 +123,7 @@ static void FindTableOffsets() { s_symtabOffset = 0; s_strtabOffset = 0; + s_pseudoCommonSectionIndex = 0; Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * s_shstrtabIndex + 0x10); std::uint32_t shstrtabOffset = ReadInt32(); @@ -192,6 +147,11 @@ static void FindTableOffsets() FATAL_ERROR("error: mutiple .strtab sections found in \"%s\"\n", s_elfPath.c_str()); Seek(s_sectionHeaderOffset + s_sectionHeaderEntrySize * i + 0x10); s_strtabOffset = ReadInt32(); + } else if (name == "common_data") { + if (s_pseudoCommonSectionIndex) { + FATAL_ERROR("error: mutiple common_data sections found in \"%s\"\n", s_elfPath.c_str()); + } + s_pseudoCommonSectionIndex = i; } } @@ -202,65 +162,50 @@ static void FindTableOffsets() FATAL_ERROR("error: couldn't find .strtab section in \"%s\"\n", s_elfPath.c_str()); } -static std::map GetCommonSymbols_Shared() +static std::vector> GetCommonSymbols_Shared() { VerifyElfIdent(); ReadElfHeader(); FindTableOffsets(); - std::map commonSymbols; + std::vector> commonSymbols; - std::vector commonSymbolVec; - - Seek(s_symtabOffset); - - for (std::uint32_t i = 0; i < s_symbolCount; i++) - { - Symbol sym; - sym.nameOffset = ReadInt32(); - Skip(4); - sym.size = ReadInt32(); - Skip(2); - std::uint16_t sectionIndex = ReadInt16(); - if (sectionIndex == SHN_COMMON) - commonSymbolVec.push_back(sym); - } - - for (const Symbol& sym : commonSymbolVec) - { - Seek(s_strtabOffset + sym.nameOffset); - std::string name = ReadString(); - commonSymbols[name] = sym.size; + if (s_pseudoCommonSectionIndex) { + std::vector commonSymbolVec; + + Seek(s_symtabOffset); + + for (std::uint32_t i = 0; i < s_symbolCount; i++) + { + Symbol sym; + sym.nameOffset = ReadInt32(); + Skip(4); + sym.size = ReadInt32(); + Skip(2); + std::uint16_t sectionIndex = ReadInt16(); + if (sectionIndex == s_pseudoCommonSectionIndex) + commonSymbolVec.push_back(sym); + } + + for (const Symbol& sym : commonSymbolVec) + { + Seek(s_strtabOffset + sym.nameOffset); + std::string name = ReadString(); + if (name == "$d" || name == "") { + continue; + } + commonSymbols.emplace_back(name, sym.size); + } } return commonSymbols; } -std::map GetCommonSymbolsFromLib(std::string sourcePath, std::string libpath) -{ - std::size_t colonPos = libpath.find(':'); - if (colonPos == std::string::npos) - FATAL_ERROR("error: missing colon separator in libfile \"%s\"\n", s_elfPath.c_str()); - - s_archiveObjectPath = libpath.substr(colonPos + 1); - s_archiveFilePath = sourcePath + "/" + libpath.substr(1, colonPos - 1); - s_elfPath = sourcePath + "/" + libpath.substr(1); - - s_file = std::fopen(s_archiveFilePath.c_str(), "rb"); - - if (s_file == NULL) - FATAL_ERROR("error: failed to open \"%s\" for reading\n", s_archiveFilePath.c_str()); - - VerifyAr(); - FindArObj(); - return GetCommonSymbols_Shared(); -} - -std::map GetCommonSymbols(std::string sourcePath, std::string path) +std::vector> GetCommonSymbols(std::string sourcePath, std::string path) { s_elfFileOffset = 0; if (path[0] == '*') - return GetCommonSymbolsFromLib(sourcePath, path); + FATAL_ERROR("error: library common syms are unsupported (filename: \"%s\")\n", path.c_str()); s_elfPath = sourcePath + "/" + path; s_file = std::fopen(s_elfPath.c_str(), "rb"); diff --git a/tools/ramscrgen/elf.h b/tools/ramscrgen/elf.h index 3704860c0..bf79a954e 100644 --- a/tools/ramscrgen/elf.h +++ b/tools/ramscrgen/elf.h @@ -22,9 +22,9 @@ #define ELF_H #include -#include +#include #include -std::map GetCommonSymbols(std::string sourcePath, std::string path); +std::vector> GetCommonSymbols(std::string sourcePath, std::string path); #endif // ELF_H diff --git a/tools/ramscrgen/main.cpp b/tools/ramscrgen/main.cpp index 5e5894f47..e99cf9fa3 100644 --- a/tools/ramscrgen/main.cpp +++ b/tools/ramscrgen/main.cpp @@ -28,54 +28,19 @@ void HandleCommonInclude(std::string filename, std::string sourcePath, std::string symOrderPath, std::string lang) { auto commonSymbols = GetCommonSymbols(sourcePath, filename); - std::size_t dotIndex; - if (filename[0] == '*') { - dotIndex = filename.find_last_of(':'); - filename = filename.substr(dotIndex + 1); - } - - dotIndex = filename.find_last_of('.'); - - if (dotIndex == std::string::npos) - FATAL_ERROR("error: \"%s\" doesn't have a file extension\n", filename.c_str()); - - std::string symOrderFilename = filename.substr(0, dotIndex + 1) + "txt"; - - SymFile symFile(symOrderPath + "/" + symOrderFilename); - - while (!symFile.IsAtEnd()) + for (const auto& commonSym : commonSymbols) { - symFile.HandleLangConditional(lang); + unsigned long size = commonSym.second; - std::string label = symFile.GetLabel(false); - - if (label.length() == 0) - { - unsigned long length; - if (symFile.ReadInteger(length)) - { - if (length & 3) - symFile.RaiseWarning("gap length %d is not multiple of 4", length); - printf(". += 0x%lX;\n", length); - } - } - else - { - if (commonSymbols.count(label) == 0) - symFile.RaiseError("no common symbol named \"%s\"", label.c_str()); - unsigned long size = commonSymbols[label]; - int alignment = 4; - if (size > 4) - alignment = 8; - if (size > 8) - alignment = 16; - printf(". = ALIGN(%d);\n", alignment); - printf("%s = .;\n", label.c_str()); - printf(". += 0x%lX;\n", size); - } - - symFile.ExpectEmptyRestOfLine(); + int alignment = 4; + if (size > 4) + alignment = 8; + if (size > 8) + alignment = 16; + printf(". = ALIGN(%d);\n", alignment); + printf("%s = .;\n", commonSym.first.c_str()); + printf(". += 0x%lX;\n", size); } } diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp index 595f366cb..c1fe10d37 100644 --- a/tools/scaninc/c_file.cpp +++ b/tools/scaninc/c_file.cpp @@ -33,6 +33,11 @@ CFile::CFile(std::string path) m_size = std::ftell(fp); + if (m_size < 0) + FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str()); + else if (m_size == 0) + return; // Empty file + m_buffer = new char[m_size + 1]; m_buffer[m_size] = 0; @@ -49,7 +54,7 @@ CFile::CFile(std::string path) CFile::~CFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } void CFile::FindIncbins() diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp index c1b7987a5..d470a3f16 100644 --- a/tools/scaninc/scaninc.cpp +++ b/tools/scaninc/scaninc.cpp @@ -157,19 +157,29 @@ int main(int argc, char **argv) // Print a make rule for the object file size_t ext_pos = make_outfile.find_last_of("."); auto object_file = make_outfile.substr(0, ext_pos + 1) + "o"; - output << object_file.c_str() << ": "; + output << object_file.c_str() << ":"; for (const std::string &path : dependencies) { - output << path << " "; + output << " " << path; } + output << '\n'; // Dependency list rule. // Although these rules are identical, they need to be separate, else make will trigger the rule again after the file is created for the first time. - output << "\n" << make_outfile.c_str() << ": "; + output << make_outfile.c_str() << ":"; for (const std::string &path : dependencies_includes) { - output << path << " "; + output << " " << path; } + output << '\n'; + + // Dummy rules + // If a dependency is deleted, make will try to make it, instead of rescanning the dependencies before trying to do that. + for (const std::string &path : dependencies) + { + output << path << ":\n"; + } + output.flush(); output.close(); }