mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-09-16 10:23:34 +12:00
handle preprocessing in one python procress; export asm labels
instead of running a process for each file, one process handles all files rgbasm requires label EXPORT definitions for cross-object compiling. this is handled by globals.asm
This commit is contained in:
parent
bacc4594c0
commit
120ba96649
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
||||||
|
# global label defs are generated
|
||||||
|
globals.asm
|
||||||
|
|
||||||
# precompiled python
|
# precompiled python
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
|
31
Makefile
31
Makefile
|
@ -4,6 +4,8 @@ PYTHON := python
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
|
|
||||||
|
TEXTQUEUE :=
|
||||||
|
|
||||||
RED_OBJS := pokered.o
|
RED_OBJS := pokered.o
|
||||||
BLUE_OBJS := pokeblue.o
|
BLUE_OBJS := pokeblue.o
|
||||||
|
|
||||||
|
@ -13,9 +15,11 @@ ROMS := pokered.gbc pokeblue.gbc
|
||||||
|
|
||||||
# generate dependencies for each object
|
# generate dependencies for each object
|
||||||
$(shell $(foreach obj, $(OBJS), \
|
$(shell $(foreach obj, $(OBJS), \
|
||||||
$(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm))) \
|
$(eval $(obj:.o=)_DEPENDENCIES := $(shell $(PYTHON) extras/pokemontools/scan_includes.py $(obj:.o=.asm) | sed s/globals.asm//g)) \
|
||||||
|
))
|
||||||
|
$(shell $(foreach obj, $(OBJS), \
|
||||||
|
$(eval ALL_DEPENDENCIES := $(ALL_DEPENDENCIES) $($(obj:.o=)_DEPENDENCIES)) \
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
all: $(ROMS)
|
all: $(ROMS)
|
||||||
red: pokered.gbc
|
red: pokered.gbc
|
||||||
|
@ -27,6 +31,7 @@ redrle: extras/redtools/redrle.c
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ROMS)
|
rm -f $(ROMS)
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
|
rm -f globals.asm
|
||||||
find -iname '*.tx' -delete
|
find -iname '*.tx' -delete
|
||||||
rm -f redrle
|
rm -f redrle
|
||||||
|
|
||||||
|
@ -35,20 +40,26 @@ baserom.gbc: ;
|
||||||
@echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false
|
@echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false
|
||||||
|
|
||||||
%.asm: ;
|
%.asm: ;
|
||||||
|
|
||||||
.asm.tx:
|
.asm.tx:
|
||||||
$(PYTHON) preprocessor.py < $< > $@
|
$(eval TEXTQUEUE := $(TEXTQUEUE) $<)
|
||||||
|
@rm -f $@
|
||||||
|
|
||||||
$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES))
|
globals.asm: $(ALL_DEPENDENCIES:.asm=.tx) $(OBJS:.o=.tx)
|
||||||
rgbasm -o $@ $(@:.o=.tx)
|
@touch $@
|
||||||
|
@$(PYTHON) prequeue.py $(TEXTQUEUE)
|
||||||
|
globals.tx: globals.asm
|
||||||
|
@cp $< $@
|
||||||
|
|
||||||
pokered.gbc: $(RED_OBJS)
|
$(OBJS): $$*.tx $$($$*_DEPENDENCIES$:.asm=.tx)
|
||||||
rgblink -n $*.sym -m $*.map -o $@ $^
|
rgbasm -o $@ $*.tx
|
||||||
|
|
||||||
|
pokered.gbc: globals.tx $(RED_OBJS)
|
||||||
|
rgblink -n $*.sym -m $*.map -o $@ $(RED_OBJS)
|
||||||
rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" $@
|
rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" $@
|
||||||
cmp baserom.gbc $@
|
cmp baserom.gbc $@
|
||||||
|
|
||||||
pokeblue.gbc: $(BLUE_OBJS)
|
pokeblue.gbc: globals.tx $(BLUE_OBJS)
|
||||||
rgblink -n $*.sym -m $*.map -o $@ $^
|
rgblink -n $*.sym -m $*.map -o $@ $(BLUE_OBJS)
|
||||||
rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" $@
|
rgbfix -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" $@
|
||||||
cmp blue.gbc $@
|
cmp blue.gbc $@
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import extras.pokemontools.preprocessor as preprocessor
|
import extras.pokemontools.preprocessor as preprocessor
|
||||||
|
|
||||||
import extras.pokemontools.configuration as configuration
|
import extras.pokemontools.configuration as configuration
|
||||||
|
config = configuration.Config()
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from extras.pokemontools.crystal import (
|
||||||
|
callchannel,
|
||||||
|
loopchannel,
|
||||||
|
)
|
||||||
|
|
||||||
chars = {
|
chars = {
|
||||||
"ガ": 0x05,
|
"ガ": 0x05,
|
||||||
"ギ": 0x06,
|
"ギ": 0x06,
|
||||||
|
@ -260,14 +267,19 @@ chars = {
|
||||||
"9": 0xFF,
|
"9": 0xFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocessor.chars = chars
|
def load_pokered_macros():
|
||||||
|
macros = [callchannel, loopchannel]
|
||||||
|
return macros
|
||||||
|
|
||||||
from extras.pokemontools.crystal import (
|
def setup_processor():
|
||||||
callchannel,
|
preprocessor.chars = chars
|
||||||
loopchannel,
|
macros = load_pokered_macros()
|
||||||
)
|
processor = preprocessor.Preprocessor(config, macros)
|
||||||
|
return processor
|
||||||
|
|
||||||
config = configuration.Config()
|
def main():
|
||||||
macros = [callchannel, loopchannel]
|
processor = setup_processor()
|
||||||
processor = preprocessor.Preprocessor(config, macros)
|
processor.preprocess()
|
||||||
processor.preprocess()
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
29
prequeue.py
Normal file
29
prequeue.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# coding: utf-8
|
||||||
|
"""
|
||||||
|
Starting a new python process to preprocess each source file creates too much
|
||||||
|
overhead. Instead, a list of files to preprocess is fed into a script run from
|
||||||
|
a single process.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import preprocessor
|
||||||
|
|
||||||
|
def main():
|
||||||
|
processor = preprocessor.setup_processor()
|
||||||
|
|
||||||
|
for source in sys.argv[1:]:
|
||||||
|
dest = os.path.splitext(source)[0] + '.tx'
|
||||||
|
|
||||||
|
stdout = sys.stdout
|
||||||
|
|
||||||
|
sys.stdin = open(source, 'r')
|
||||||
|
sys.stdout = open(dest, 'w')
|
||||||
|
|
||||||
|
processor.preprocess()
|
||||||
|
|
||||||
|
sys.stdout = stdout
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in a new issue