Skip to content

Commit

Permalink
Dump and rebuild lists, closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
VariantXYZ committed Jun 22, 2024
1 parent 51e80b8 commit b688a9f
Show file tree
Hide file tree
Showing 36 changed files with 4,409 additions and 70 deletions.
33 changes: 30 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ TILEMAP_GFX := $(GFX)/tilemaps
TILEMAP_PREBUILT := $(GFX)/prebuilt/tilemaps
ATTRIBMAP_GFX := $(GFX)/attribmaps
ATTRIBMAP_PREBUILT := $(GFX)/prebuilt/attribmaps
PTRLISTS_TEXT := $(TEXT)/ptrlists

# Build Directories
VERSION_OUT := $(BUILD)/version
Expand All @@ -57,6 +58,8 @@ DIALOG_OUT := $(BUILD)/dialog
TILESET_OUT := $(BUILD)/tilesets
TILEMAP_OUT := $(BUILD)/tilemaps
ATTRIBMAP_OUT := $(BUILD)/attribmaps
PTRLISTS_INT := $(BUILD)/intermediate/ptrlists
PTRLISTS_OUT := $(BUILD)/ptrlists

# Source Modules (directories in SRC), version directories (kuwagata/kabuto) are implied
# We explicitly separate this with newlines to avoid silly conflicts with tr_EN
Expand Down Expand Up @@ -109,6 +112,7 @@ TILEMAPS_VERSIONED := $(call FILTER,_,$(TILEMAPS))
ATTRIBMAPS := $(notdir $(basename $(wildcard $(ATTRIBMAP_GFX)/*.$(TEXT_TYPE))))
ATTRIBMAPS_COMMON := $(call FILTER_OUT,_,$(ATTRIBMAPS))
ATTRIBMAPS_VERSIONED := $(call FILTER,_,$(ATTRIBMAPS))
PTRLISTS := $(notdir $(basename $(wildcard $(PTRLISTS_TEXT)/*.$(TEXT_TYPE))))

# Intermediates for common sources (not in version folder)
## We explicitly rely on second expansion to handle version-specific files in the version specific objects
Expand All @@ -129,6 +133,7 @@ version_text_tables_ADDITIONAL := $(DIALOG_OUT)/text_table_constants_PLACEHOLDER
version_tileset_table_ADDITIONAL := $(COMPRESSED_TILESET_FILES_COMMON) $(VERSION_SRC)/tileset_table.asm $(COMPRESSED_TILESET_FILES_GAMEVERSION) $(TILESET_OUT)/PLACEHOLDER_VERSION.stamp
version_tilemap_table_ADDITIONAL := $(TILEMAP_FILES_COMMON) $(VERSION_SRC)/tilemap_table.asm $(TILEMAP_OUT)/PLACEHOLDER_VERSION.stamp
version_attribmap_table_ADDITIONAL := $(ATTRIBMAP_FILES_COMMON) $(VERSION_SRC)/attribmap_table.asm $(ATTRIBMAP_OUT)/PLACEHOLDER_VERSION.stamp
version_ptrlist_data_ADDITIONAL := $(PTRLISTS_OUT)/ptrlist_data_constants_PLACEHOLDER_VERSION.asm

.PHONY: $(VERSIONS) all clean default
default: kabuto
Expand Down Expand Up @@ -166,6 +171,11 @@ $(BUILD)/%.$(INT_TYPE): $(SRC)/$$(firstword $$(subst ., ,$$*))/$$(lastword $$(su
$(DIALOG_INT)/%.$(DIALOG_TYPE): $(DIALOG_TEXT)/$$(word 1, $$(subst _, ,$$*)).$(CSV_TYPE) $(SCRIPT_RES)/ptrs.tbl | $(DIALOG_INT)
$(PYTHON) $(SCRIPT)/dialog2bin.py $@ $^ "Original" $(subst $(subst .$(CSV_TYPE),,$(<F))_,,$*)

# build/intermediate/ptrlists/*.bin from ptrlists csv files
.SECONDEXPANSION:
$(PTRLISTS_INT)/%.$(PTRLIST_TYPE): $(PTRLISTS_TEXT)/$$(word 1, $$(subst _, ,$$*)).$(TEXT_TYPE) | $(PTRLISTS_INT)
$(PYTHON) $(SCRIPT)/ptrlist2bin.py $@ $< $(subst $(subst .$(TEXT_TYPE),,$(<F))_,,$*)

# build/pointer_constants.asm from scripts/res/ptrs.tbl
$(BUILD)/pointer_constants.asm: $(SCRIPT_RES)/ptrs.tbl | $(BUILD)
awk -F "=0x" '{ print "DEF c"$$1 " EQU " "$$"$$2 > "$@" }' $<
Expand All @@ -190,6 +200,10 @@ $(TILESET_OUT)/%.stamp: $$(call FILTER,%,$(COMPRESSED_TILESET_FILES_VERSIONED))
$(DIALOG_OUT)/text_table_constants_%.asm: $(SRC)/version/text_tables.asm $(SRC)/version/%/text_tables.asm $$(foreach FILE,$(DIALOG),$(DIALOG_INT)/$$(FILE)_$$*.$(DIALOG_TYPE)) | $(DIALOG_OUT)
$(PYTHON) $(SCRIPT)/dialogbin2asm.py $@ $(DIALOG_OUT) $* $^

.SECONDEXPANSION:
$(PTRLISTS_OUT)/ptrlist_data_constants_%.asm: $(SRC)/version/ptrlist_data.asm $(SRC)/version/%/ptrlist_data.asm $$(foreach FILE,$(PTRLISTS),$(PTRLISTS_INT)/$$(FILE)_$$*.$(PTRLIST_TYPE)) | $(PTRLISTS_OUT)
$(PYTHON) $(SCRIPT)/ptrlistbin2asm.py $@ $(PTRLISTS_OUT) $* $^

# build/tilemaps/*.map from tilemaps txt
$(TILEMAP_OUT)/%.$(TMAP_TYPE): $(TILEMAP_GFX)/%.$(TEXT_TYPE) | $(TILEMAP_OUT)
$(PYTHON) $(SCRIPT)/txt2map.py $@ $^ $(TILEMAP_PREBUILT)
Expand All @@ -209,8 +223,8 @@ $(ATTRIBMAP_OUT)/%.stamp: $$(call FILTER,%,$(ATTRIBMAP_FILES_VERSIONED))
touch $@

# Dump scripts
.PHONY: dump dump_text dump_tilesets dump_tilemaps dump_attribmaps
dump: dump_text dump_tilesets dump_tilemaps dump_attribmaps
.PHONY: dump dump_text dump_tilesets dump_tilemaps dump_attribmaps dump_ptrlists
dump: dump_text dump_tilesets dump_tilemaps dump_attribmaps dump_ptrlists

dump_text: | $(DIALOG_TEXT) $(SCRIPT_RES)
rm $(DIALOG_TEXT)/*.$(CSV_TYPE) || echo ""
Expand All @@ -231,6 +245,10 @@ dump_attribmaps: | $(ATTRIBMAP_GFX) $(ATTRIBMAP_PREBUILT) $(SCRIPT_RES)
rm $(ATTRIBMAP_GFX)/*.$(TEXT_TYPE) || echo ""
$(PYTHON) $(SCRIPT)/dump_maps.py attribmap "$(ATTRIBMAP_GFX)" "$(ATTRIBMAP_PREBUILT)" "$(ATTRIBMAP_OUT)" "$(SCRIPT_RES)" "$(VERSION_SRC)" a02 a0b 9

dump_ptrlists: | $(PTRLISTS_TEXT)
rm $(PTRLISTS_TEXT)/*.$(TEXT_TYPE) || echo ""
$(PYTHON) $(SCRIPT)/dump_ptrlists.py "$(VERSION_SRC)" "$(PTRLISTS_TEXT)" "$(PTRLISTS_OUT)"

# Tests
.PHONY: test_tilemaps test_attribmaps

Expand Down Expand Up @@ -284,4 +302,13 @@ $(ATTRIBMAP_GFX):
mkdir -p $(ATTRIBMAP_GFX)

$(ATTRIBMAP_OUT):
mkdir -p $(ATTRIBMAP_OUT)
mkdir -p $(ATTRIBMAP_OUT)

$(PTRLISTS_TEXT):
mkdir -p $(PTRLISTS_TEXT)

$(PTRLISTS_INT):
mkdir -p $(PTRLISTS_INT)

$(PTRLISTS_OUT):
mkdir -p $(PTRLISTS_OUT)
31 changes: 30 additions & 1 deletion game/src/text/buffer_text.asm
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,33 @@ BufferTextFromList::
jr nz, .copyLoop
ret

; Look in version folders for ListPointerTable
SECTION "List Pointer Table", ROM0[$29C6]
ListPointerTable::
dbw BANK(PtrListUnknown00), PtrListUnknown00
dbw BANK(PtrListPartsHead), PtrListPartsHead
dbw BANK(PtrListPartsRArm), PtrListPartsRArm
dbw BANK(PtrListPartsLArm), PtrListPartsLArm
dbw BANK(PtrListPartsLegs), PtrListPartsLegs
dbw BANK(PtrListAttributes), PtrListAttributes
dbw BANK(PtrListSkills), PtrListSkills
dbw BANK(PtrListMovement), PtrListMovement
dbw BANK(PtrListUnknown08),PtrListUnknown08
dbw BANK(PtrListPersonalities), PtrListPersonalities
dbw BANK(PtrListMedaforce), PtrListMedaforce
dbw BANK(PtrListMedals), PtrListMedals
dbw BANK(PtrListUnknown0C), PtrListUnknown0C
dbw BANK(PtrListItems), PtrListItems
dbw BANK(PtrListUnknown0E), PtrListUnknown0E
dbw $00, $0000
dbw $00, $0000
dbw BANK(PtrListMedarotters), PtrListMedarotters
dbw BANK(PtrListUnknown10), PtrListUnknown10
dbw BANK(PtrListTerrain), PtrListTerrain
dbw BANK(PtrListUnknown12), PtrListUnknown12
dbw BANK(PtrListAttacks), PtrListAttacks
dbw BANK(PtrListCharacterNames), PtrListCharacterNames
dbw BANK(PtrListMedarots), PtrListMedarots
dbw BANK(PtrListUnknown16), PtrListUnknown16
dbw BANK(PtrListUnknown17), PtrListUnknown17
dbw BANK(PtrListUnknown18), PtrListUnknown18
dbw BANK(PtrListMusicTitles), PtrListMusicTitles
33 changes: 0 additions & 33 deletions game/src/version/kabuto/buffer_text.asm

This file was deleted.

3 changes: 3 additions & 0 deletions game/src/version/kabuto/ptrlist_data.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEF cAddressMusicTitles EQU $737e
DEF cBankMusicTitles EQU $03
INCLUDE "./game/src/version/ptrlist_data.asm"
33 changes: 0 additions & 33 deletions game/src/version/kuwagata/buffer_text.asm

This file was deleted.

3 changes: 3 additions & 0 deletions game/src/version/kuwagata/ptrlist_data.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEF cAddressMusicTitles EQU $7383
DEF cBankMusicTitles EQU $03
INCLUDE "./game/src/version/ptrlist_data.asm"
106 changes: 106 additions & 0 deletions game/src/version/ptrlist_data.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
INCLUDE "./build/ptrlists/ptrlist_data_constants_{GAMEVERSION}.asm"

SECTION "Pointer List - Unknown00", ROMX[$5379], BANK[$7f]
PtrListUnknown00::
INCBIN cUnknown00

SECTION "Pointer List - PartsHead", ROMX[$51b5], BANK[$49]
PtrListPartsHead::
INCBIN cPartsHead

SECTION "Pointer List - PartsRArm", ROMX[$46c0], BANK[$4e]
PtrListPartsRArm::
INCBIN cPartsRArm

SECTION "Pointer List - PartsLArm", ROMX[$597c], BANK[$4e]
PtrListPartsLArm::
INCBIN cPartsLArm

SECTION "Pointer List - PartsLegs", ROMX[$6471], BANK[$49]
PtrListPartsLegs::
INCBIN cPartsLegs

SECTION "Pointer List - Attributes", ROMX[$7ec0], BANK[$27]
PtrListAttributes::
INCBIN cAttributes

SECTION "Pointer List - Skills", ROMX[$7f4c], BANK[$27]
PtrListSkills::
INCBIN cSkills

SECTION "Pointer List - Movement", ROMX[$7f9a], BANK[$27]
PtrListMovement::
INCBIN cMovement

SECTION "Pointer List - Unknown08", ROMX[$5edd], BANK[$26]
PtrListUnknown08::
INCBIN cUnknown08

SECTION "Pointer List - Personalities", ROMX[$6141], BANK[$26]
PtrListPersonalities::
INCBIN cPersonalities

SECTION "Pointer List - Medaforce", ROMX[$5800], BANK[$26]
PtrListMedaforce::
INCBIN cMedaforce

SECTION "Pointer List - Medals", ROMX[$4b89], BANK[$49]
PtrListMedals::
INCBIN cMedals

SECTION "Pointer List - Unknown0C", ROMX[$6186], BANK[$26]
PtrListUnknown0C::
INCBIN cUnknown0C

SECTION "Pointer List - Items", ROMX[$4939], BANK[$49]
PtrListItems::
INCBIN cItems

SECTION "Pointer List - Unknown0E", ROMX[$4000], BANK[$29]
PtrListUnknown0E::
INCBIN cUnknown0E

SECTION "Pointer List - Medarotters", ROMX[$4dd7], BANK[$49]
PtrListMedarotters::
INCBIN cMedarotters

SECTION "Pointer List - Unknown10", ROMX[$4e56], BANK[$49]
PtrListUnknown10::
INCBIN cUnknown10

SECTION "Pointer List - Terrain", ROMX[$4000], BANK[$2a]
PtrListTerrain::
INCBIN cTerrain

SECTION "Pointer List - Unknown12", ROMX[$4364], BANK[$2a]
PtrListUnknown12::
INCBIN cUnknown12

SECTION "Pointer List - Attacks", ROMX[$4000], BANK[$49]
PtrListAttacks::
INCBIN cAttacks

SECTION "Pointer List - CharacterNames", ROMX[$44d0], BANK[$29]
PtrListCharacterNames::
INCBIN cCharacterNames

SECTION "Pointer List - Medarots", ROMX[$4630], BANK[$2b]
PtrListMedarots::
INCBIN cMedarots

SECTION "Pointer List - Unknown16", ROMX[$4f42], BANK[$29]
PtrListUnknown16::
INCBIN cUnknown16

SECTION "Pointer List - Unknown17", ROMX[$5290], BANK[$2b]
PtrListUnknown17::
INCBIN cUnknown17

SECTION "Pointer List - Unknown18", ROMX[$4c78], BANK[$49]
PtrListUnknown18::
INCBIN cUnknown18

SECTION "Pointer List - MusicTitles", ROMX[cAddressMusicTitles], BANK[cBankMusicTitles]
PtrListMusicTitles::
INCBIN cMusicTitles

Loading

0 comments on commit b688a9f

Please sign in to comment.