mirror of
https://github.com/pret/pokegold-spaceworld.git
synced 2026-04-25 15:39:32 -05:00
Add text compilation to makefile; polish various bits
This commit is contained in:
parent
0132b9cf18
commit
db5fd2083b
15
Makefile
15
Makefile
|
|
@ -23,6 +23,8 @@ DIRS := home engine data audio
|
|||
ASMFILES := $(call rwildcard, $(DIRS), *.asm) gfx.asm vram.asm sram.asm wram.asm hram.asm hack/hack.asm
|
||||
OBJS := $(patsubst %.asm, $(BUILD)/%.o, $(ASMFILES))
|
||||
OBJS += $(BUILD)/shim.o
|
||||
OBJS += $(BUILD)/hack/relocated_text.o
|
||||
TEXTCSVS := $(wildcard hack/text/*.csv)
|
||||
|
||||
.SECONDEXPANSION:
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ clean:
|
|||
# Remove files except for graphics.
|
||||
.PHONY: mostlyclean
|
||||
mostlyclean:
|
||||
rm -rf $(ROM) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) *.d
|
||||
rm -rf $(ROM) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) $(BUILD)/shim.asm $(BUILD)/hack/relocated_text.asm $(BUILD)/hack/text/* *.d
|
||||
|
||||
# Utilities
|
||||
.PHONY: coverage
|
||||
|
|
@ -106,6 +108,17 @@ $(BUILD)/%.1bpp: %.1bpp.png tools/gfx | $$(dir $$@)
|
|||
$(BUILD)/%.tilemap: %.png | $$(dir $$@)
|
||||
$(RGBGFX) -t $@ $<
|
||||
|
||||
.PRECIOUS: $(BUILD)/hack/text.inc $(BUILD)/hack/text/%.asm
|
||||
$(BUILD)/hack/text/%.inc $(BUILD)/hack/text/%.asm: hack/text/%.csv
|
||||
$(PYTHON3) tools/compile_text.py $<
|
||||
|
||||
# Switch out this approach if more text banks are needed.
|
||||
.PRECIOUS: $(BUILD)/hack/relocated_text.asm
|
||||
$(BUILD)/hack/relocated_text.asm: hack/text_bank_start.asm $(TEXTCSVS:%.csv=$(BUILD)/%.asm)
|
||||
cat $^ > $@
|
||||
# For posterity! Since relocated_text.asm isn't scanned automatically.
|
||||
$(BUILD)/hack/relocated_text.o: constants.asm
|
||||
|
||||
.PRECIOUS: %/
|
||||
%/:
|
||||
mkdir -p $@
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
charmap "<PLAY_G>", $14 ; "<PLAYER>くん" or "<PLAYER>ちゃん"
|
||||
|
||||
charmap "<15>", $15 ; nothing
|
||||
charmap "<FAR_TEXT>", $15 ; Far text pointer (patch)
|
||||
charmap "<16>", $16 ; nothing
|
||||
|
||||
charmap "ネ゛", $17
|
||||
|
|
|
|||
|
|
@ -5,32 +5,43 @@ INCLUDE "constants.asm"
|
|||
; Move elsewhere if $DA00 turns out to be used.
|
||||
SECTION "Patch WRAM", WRAM0[$DA00]
|
||||
wPatchWRAM:
|
||||
wHackOldBank: db
|
||||
|
||||
; RAM values here...
|
||||
|
||||
wPatchWRAMEnd:
|
||||
|
||||
SECTION "Hack interrupt vector", ROM0[HackInterrupt]
|
||||
push af
|
||||
; Save A for RunHack.
|
||||
ld [wPredefID], a
|
||||
|
||||
di
|
||||
; Save bank to be able to switch back.
|
||||
ldh a, [hROMBank]
|
||||
ld [wHackOldBank], a
|
||||
push af
|
||||
|
||||
ld a, BANK(RunHack)
|
||||
call Bankswitch
|
||||
ei
|
||||
|
||||
pop af
|
||||
call RunHack
|
||||
|
||||
di
|
||||
; Juggly way to both pop the previous bank off the stack and preserve AF.
|
||||
push af
|
||||
ld a, [wHackOldBank]
|
||||
add sp, 1 * 2
|
||||
pop af
|
||||
add sp, -2 * 2
|
||||
call Bankswitch
|
||||
pop af
|
||||
inc sp
|
||||
inc sp
|
||||
|
||||
ret
|
||||
reti
|
||||
|
||||
SECTION "Patch ROM", ROMX[$4000], BANK[$28]
|
||||
; A: Index of hack function to run.
|
||||
; [wPredefID]: Index of hack function to run.
|
||||
RunHack:
|
||||
; Save A and HL for later.
|
||||
ld [wPredefID], a
|
||||
; Save HL for later.
|
||||
ld a, h
|
||||
ld [wPredefHL], a
|
||||
ld a, l
|
||||
|
|
|
|||
10
hack/text_bank_start.asm
Normal file
10
hack/text_bank_start.asm
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
INCLUDE "constants.asm"
|
||||
|
||||
SECTION "Patch text bank", ROMX[$4000], BANK[$29]
|
||||
|
||||
; The actual text data goes in CSVs in hack/text.
|
||||
; At build time, this file is concatenated with the code files built from the CSVs.
|
||||
; If more banks are needed, this approach should be switched out - likely for
|
||||
; including bank numbers in the compiled text .asms, or putting the text .asms
|
||||
; in a linkerscript or similar.
|
||||
|
||||
|
|
@ -164,7 +164,11 @@ ENDM
|
|||
dict "<TARGET>", PlaceMoveTargetsName
|
||||
dict "<USER>", PlaceMoveUsersName
|
||||
|
||||
cp "゚"
|
||||
; Skip over all the diacritic code for the patch. If more space
|
||||
; is needed, all the diacritic code below could be removed.
|
||||
jr .place
|
||||
|
||||
; cp "゚"
|
||||
jr z, .diacritic
|
||||
cp "゙"
|
||||
jr nz, .not_diacritic
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import csv
|
|||
import os
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from separatetext import *
|
||||
from separate_text import *
|
||||
|
||||
String = namedtuple('String', ('label', 'lines', 'space'))
|
||||
|
||||
|
|
@ -47,12 +47,16 @@ def shallow_dependencies_of(asm_file_path, build_dirs=[]):
|
|||
# so leading slashes should be stripped.
|
||||
path = line[line.index('"') + 1:line.rindex('"')].lstrip('/')
|
||||
if keyword == 'INCLUDE':
|
||||
asm_dependencies.add(path)
|
||||
dependency_category = asm_dependencies
|
||||
else:
|
||||
if os.path.isfile(path) or not build_dirs:
|
||||
bin_dependencies.add(path)
|
||||
else:
|
||||
bin_dependencies.update(os.path.join(d, path) for d in build_dirs)
|
||||
dependency_category = bin_dependencies
|
||||
|
||||
if os.path.isfile(path) or not build_dirs:
|
||||
dependency_category.add(path)
|
||||
else:
|
||||
# Always add .inc and .asm files in the build directory to
|
||||
# bin_dependencies, as they shouldn't be scanned for includes.
|
||||
bin_dependencies.update(os.path.join(d, path) for d in build_dirs)
|
||||
|
||||
return asm_dependencies, bin_dependencies
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user