Skip to content

Commit

Permalink
Merge pull request #41 from andwhyisit/master-to-patch
Browse files Browse the repository at this point in the history
Save Me, Variant!
  • Loading branch information
andwhyisit authored Jun 23, 2024
2 parents 827a703 + 87b2112 commit f314b97
Show file tree
Hide file tree
Showing 59 changed files with 5,495 additions and 231 deletions.
36 changes: 32 additions & 4 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

# Patch Specific
VWF_TSET_SRC_TYPE := 1bpp
Expand All @@ -74,6 +77,7 @@ link \
titlemenu \
saveclock \
nameentry \
pausemenu \
text

# Toolchain
Expand Down Expand Up @@ -115,6 +119,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 Down Expand Up @@ -142,6 +147,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

# Patch Specific, including any tilesets we move into the patch tileset
patch_tilesets_ADDITIONAL := $(PATCH_TILESET_FILES) $(PATCH_TEXT_TILESET_FILES)
Expand Down Expand Up @@ -182,9 +188,14 @@ $(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 $@ $^ "Translated" $(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 "c"$$1 " EQU " "$$"$$2 > "$@" }' $<
awk -F "=0x" '{ print "DEF c"$$1 " EQU " "$$"$$2 > "$@" }' $<

# build/tilesets/*.2bpp from source png
$(TILESET_OUT)/%.$(TSET_SRC_TYPE): $(TILESET_GFX)/%.$(RAW_TSET_SRC_TYPE) | $(TILESET_OUT)
Expand All @@ -206,6 +217,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 Down Expand Up @@ -244,8 +259,8 @@ csv_from_xlsx:
$(PYTHON) $(SCRIPT)/xlsx2csv.py $(TRANSLATION_SHEET) $(DIALOG_TEXT) $(DIALOG)

# 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 @@ -266,6 +281,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 @@ -324,4 +343,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)
4 changes: 2 additions & 2 deletions game/src/common/constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ INCLUDE "game/src/common/joypad.inc"
; H = FF00 to FFFF (HRAM and I/O, basically any address ldh works with)
; M = for symbolising values

H_PushOAM EQU $ff80
H_VBlankCompleted EQU $ff92
DEF H_PushOAM EQU $ff80
DEF H_VBlankCompleted EQU $ff92
118 changes: 59 additions & 59 deletions game/src/common/hardware.inc
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
H_RegJoyp EQU $ff00
H_RegSB EQU $ff01
H_RegSC EQU $ff02
H_RegDIV EQU $ff04
H_RegTIMA EQU $ff05
H_RegTMA EQU $ff06
H_RegTAC EQU $ff07
H_RegIF EQU $ff0f
H_RegNR10 EQU $ff10
H_RegNR11 EQU $ff11
H_RegNR12 EQU $ff12
H_RegNR13 EQU $ff13
H_RegNR14 EQU $ff14
H_RegNR21 EQU $ff16
H_RegNR22 EQU $ff17
H_RegNR23 EQU $ff18
H_RegNR24 EQU $ff19
H_RegNR30 EQU $ff1a
H_RegNR31 EQU $ff1b
H_RegNR32 EQU $ff1c
H_RegNR33 EQU $ff1d
H_RegNR34 EQU $ff1e
H_RegNR41 EQU $ff20
H_RegNR42 EQU $ff21
H_RegNR43 EQU $ff22
H_RegNR44 EQU $ff23
H_RegNR50 EQU $ff24
H_RegNR51 EQU $ff25
H_RegNR52 EQU $ff26
H_RegLCDC EQU $ff40
H_LCDStat EQU $ff41
H_RegSCY EQU $ff42
H_RegSCX EQU $ff43
H_RegLY EQU $ff44
H_RegLYC EQU $ff45
H_RegDMA EQU $ff46
H_RegBGP EQU $ff47
H_RegOBP0 EQU $ff48
H_RegOBP1 EQU $ff49
H_RegWY EQU $ff4a
H_RegWX EQU $ff4b
H_RegKEY1 EQU $ff4d
H_RegVBK EQU $ff4f
H_RegHDMA1 EQU $ff51
H_RegHDMA2 EQU $ff52
H_RegHDMA3 EQU $ff53
H_RegHDMA4 EQU $ff54
H_RegHDMA5 EQU $ff55
H_RegRP EQU $ff56
H_RegBGPI EQU $ff68
H_RegBGPD EQU $ff69
H_RegOBPI EQU $ff6a
H_RegOBPD EQU $ff6b
H_RegSVBK EQU $ff70
H_RegIE EQU $ffff
DEF H_RegJoyp EQU $ff00
DEF H_RegSB EQU $ff01
DEF H_RegSC EQU $ff02
DEF H_RegDIV EQU $ff04
DEF H_RegTIMA EQU $ff05
DEF H_RegTMA EQU $ff06
DEF H_RegTAC EQU $ff07
DEF H_RegIF EQU $ff0f
DEF H_RegNR10 EQU $ff10
DEF H_RegNR11 EQU $ff11
DEF H_RegNR12 EQU $ff12
DEF H_RegNR13 EQU $ff13
DEF H_RegNR14 EQU $ff14
DEF H_RegNR21 EQU $ff16
DEF H_RegNR22 EQU $ff17
DEF H_RegNR23 EQU $ff18
DEF H_RegNR24 EQU $ff19
DEF H_RegNR30 EQU $ff1a
DEF H_RegNR31 EQU $ff1b
DEF H_RegNR32 EQU $ff1c
DEF H_RegNR33 EQU $ff1d
DEF H_RegNR34 EQU $ff1e
DEF H_RegNR41 EQU $ff20
DEF H_RegNR42 EQU $ff21
DEF H_RegNR43 EQU $ff22
DEF H_RegNR44 EQU $ff23
DEF H_RegNR50 EQU $ff24
DEF H_RegNR51 EQU $ff25
DEF H_RegNR52 EQU $ff26
DEF H_RegLCDC EQU $ff40
DEF H_LCDStat EQU $ff41
DEF H_RegSCY EQU $ff42
DEF H_RegSCX EQU $ff43
DEF H_RegLY EQU $ff44
DEF H_RegLYC EQU $ff45
DEF H_RegDMA EQU $ff46
DEF H_RegBGP EQU $ff47
DEF H_RegOBP0 EQU $ff48
DEF H_RegOBP1 EQU $ff49
DEF H_RegWY EQU $ff4a
DEF H_RegWX EQU $ff4b
DEF H_RegKEY1 EQU $ff4d
DEF H_RegVBK EQU $ff4f
DEF H_RegHDMA1 EQU $ff51
DEF H_RegHDMA2 EQU $ff52
DEF H_RegHDMA3 EQU $ff53
DEF H_RegHDMA4 EQU $ff54
DEF H_RegHDMA5 EQU $ff55
DEF H_RegRP EQU $ff56
DEF H_RegBGPI EQU $ff68
DEF H_RegBGPD EQU $ff69
DEF H_RegOBPI EQU $ff6a
DEF H_RegOBPD EQU $ff6b
DEF H_RegSVBK EQU $ff70
DEF H_RegIE EQU $ffff

X_MBC5SRAMEnable EQU $0000
X_MBC5ROMBankLow EQU $2000
X_MBC5ROMBankHigh EQU $3000
X_MBC5SRAMBank EQU $4000
DEF X_MBC5SRAMEnable EQU $0000
DEF X_MBC5ROMBankLow EQU $2000
DEF X_MBC5ROMBankHigh EQU $3000
DEF X_MBC5SRAMBank EQU $4000
20 changes: 10 additions & 10 deletions game/src/common/joypad.inc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
H_JPInputHeldDown EQU $ff8c
H_JPInputChanged EQU $ff8d
DEF H_JPInputHeldDown EQU $ff8c
DEF H_JPInputChanged EQU $ff8d

M_JPInputA EQU $1
M_JPInputB EQU $2
M_JPInputSelect EQU $4
M_JPInputStart EQU $8
M_JPInputRight EQU $10
M_JPInputLeft EQU $20
M_JPInputUp EQU $40
M_JPInputDown EQU $80
DEF M_JPInputA EQU $1
DEF M_JPInputB EQU $2
DEF M_JPInputSelect EQU $4
DEF M_JPInputStart EQU $8
DEF M_JPInputRight EQU $10
DEF M_JPInputLeft EQU $20
DEF M_JPInputUp EQU $40
DEF M_JPInputDown EQU $80
40 changes: 38 additions & 2 deletions game/src/gfx/attribmap.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
INCLUDE "game/src/common/constants.asm"

W_AttribmapWritingBaseLocationIndex EQU $C4E0 ; 0 for $9800, 1 for $9C00, I suck at naming things.
W_AttribmapPointerTableIndex EQU $C4E1
DEF W_AttribmapWritingBaseLocationIndex EQU $C4E0 ; 0 for $9800, 1 for $9C00, I suck at naming things.
DEF W_AttribmapPointerTableIndex EQU $C4E1

SECTION "Attribmap Loading Variables 1", WRAM0[$C499]
W_DecompressAttribmapCurrentValue:: ds 1
Expand Down Expand Up @@ -306,3 +306,39 @@ DecompressAttribmap0ScrollAdjusted::
call GetOverworldScrollTileOffset
pop af
jp DecompressAttribmap0

SECTION "Map Attribute Rect", ROM0[$2950]
MapAttributeRect::
; Maps attribute index A to a rectangle mapped at HL (top-left corner) that is B tiles wide and C tiles high.

ld [$C4EF], a
ld a, 1
ld [W_CurrentVRAMBank], a
ldh [H_RegVBK], a
ld a, b
ld [$C4EE], a

.rowLoop
push hl
ld a, [$C4EE]
ld b, a

.colLoop
di
rst $20
ld a, [$C4EF]
ld [hli], a
ei
dec b
jr nz, .colLoop

pop hl
ld de, $20
add hl, de
dec c
jr nz, .rowLoop

ld a, 0
ld [W_CurrentVRAMBank], a
ldh [H_RegVBK], a
ret
2 changes: 1 addition & 1 deletion game/src/gfx/fades.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SECTION "Fade Variables 2", WRAM0[$C47B]
W_PaletteAnimStepController:: ds 1
W_PaletteAnimRunning:: ds 1

W_FadePaletteForUnpacking EQU $C4EE ; This address is overutilised, so EQU is better.
DEF W_FadePaletteForUnpacking EQU $C4EE ; This address is overutilised, so EQU is better.

SECTION "CGB Fade Palette Staging", WRAMX[$DB40], BANK[$3]
W_FadeStagingOldBGPaletteIndexes:: ds $10
Expand Down
4 changes: 2 additions & 2 deletions game/src/gfx/tilemap.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
INCLUDE "game/src/common/constants.asm"

W_TilemapWritingBaseLocationIndex EQU $C4E0 ; 0 for $9800, 1 for $9C00, I suck at naming things.
W_TilemapPointerTableIndex EQU $C4E1
DEF W_TilemapWritingBaseLocationIndex EQU $C4E0 ; 0 for $9800, 1 for $9C00, I suck at naming things.
DEF W_TilemapPointerTableIndex EQU $C4E1

SECTION "Load Tilemaps", ROM0[$072B]
DecompressTilemapWTF::
Expand Down
8 changes: 4 additions & 4 deletions game/src/gfx/tilesets.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ W_TilesetScript_NumTiles:: ds 1
SECTION "Tileset Variables 4", WRAM0[$C4DD]
W_TilesetScript_Bank:: ds 1

W_TilesetScript_PointerIndex EQU $C4E0 ; This address is overutilised, so EQU is better.
W_MaliasSourceBank EQU $C4EE ; This address is overutilised, so EQU is better.
W_TilesetScript_TilesetPointerIndex EQU $C4EE ; This address is overutilised, so EQU is better.
W_MaliasDestinationAddress EQU $C4F0 ; This address is overutilised, so EQU is better.
DEF W_TilesetScript_PointerIndex EQU $C4E0 ; This address is overutilised, so EQU is better.
DEF W_MaliasSourceBank EQU $C4EE ; This address is overutilised, so EQU is better.
DEF W_TilesetScript_TilesetPointerIndex EQU $C4EE ; This address is overutilised, so EQU is better.
DEF W_MaliasDestinationAddress EQU $C4F0 ; This address is overutilised, so EQU is better.

SECTION "Load Malias-Compressed Tilesets", ROM0[$0A85]
LoadMaliasGraphics::
Expand Down
1 change: 1 addition & 0 deletions game/src/nameentry/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ W_NamingScreenExitIndicator:: ds 1
SECTION "Naming Screen Variables 4", WRAM0[$C760]
W_NamingScreenSubSubSubStateIndex:: ds 1
W_NamingScreenTypeIndex:: ds 1

; Look in version folders for the actual code.
3 changes: 3 additions & 0 deletions game/src/nameentry/medal_naming_core.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
INCLUDE "game/src/common/constants.asm"

SECTION "Medal Name Entry Variables", WRAM0[$C762]
W_NamingEntryMedalIndex:: ds 1

; Look in version folders for the actual code.
Loading

0 comments on commit f314b97

Please sign in to comment.