2015-02-21 10:23:03 +00:00
|
|
|
# ReC98
|
|
|
|
# -----
|
|
|
|
# Makefile for the 16-bit part of the build process
|
|
|
|
|
2015-02-21 13:13:58 +00:00
|
|
|
CFLAGS = -ls -Ilibs\master.lib\ -I. -Lbin\ -O -a2
|
2015-02-21 10:23:03 +00:00
|
|
|
|
|
|
|
TH01 = \zunsoft.com \op.exe \reiiden.exe \fuuin.exe
|
2018-04-14 17:08:22 +00:00
|
|
|
TH02 = \zuninit.com \zun_res.com \op.exe \main.exe \maine.exe \zun.com
|
|
|
|
TH03 = \zunsp.com \res_yume.com \op.exe \main.exe \mainl.exe \zun.com
|
2015-02-21 10:23:03 +00:00
|
|
|
TH04 = \res_huma.com \op.exe \main.exe \maine.exe
|
|
|
|
TH05 = \res_kso.com \op.exe \main.exe \maine.exe
|
|
|
|
|
|
|
|
all: th01 th02 th03 th04 th05
|
|
|
|
@echo Done. Find the executables in the bin\ subdirectory.
|
|
|
|
|
|
|
|
th01:: $(TH01:\=bin\th01\)
|
|
|
|
th02:: $(TH02:\=bin\th02\)
|
|
|
|
th03:: $(TH03:\=bin\th03\)
|
|
|
|
th04:: $(TH04:\=bin\th04\)
|
|
|
|
th05:: $(TH05:\=bin\th05\)
|
|
|
|
|
2019-09-20 18:36:19 +00:00
|
|
|
{th05}.asm{bin\th05}.obj:
|
|
|
|
$(AS) /dGAME=5 $**, $@
|
|
|
|
|
2019-09-18 16:33:38 +00:00
|
|
|
# Shared TH04/TH05 assembly units
|
|
|
|
# -------------------------------
|
|
|
|
# Need to go into separate .obj directories since they will have different
|
|
|
|
# AFLAGS per game.
|
|
|
|
{th04}.asm{bin\th04}.obj:
|
|
|
|
$(AS) /dGAME=4 $**, $@
|
|
|
|
{th04}.asm{bin\th05}.obj:
|
|
|
|
$(AS) /dGAME=5 $**, $@
|
|
|
|
# -------------------------------
|
|
|
|
|
2015-02-21 10:23:03 +00:00
|
|
|
.obj.exe:
|
|
|
|
$(CC) $(CFLAGS) -ml $**
|
|
|
|
|
|
|
|
.obj.com:
|
|
|
|
tlink /t /3 $**
|
|
|
|
|
|
|
|
bin\th01\zunsoft.com: th01\zunsoft.c
|
2015-02-21 13:13:58 +00:00
|
|
|
$(CC) $(CFLAGS) -mt -lt -nbin\th01\ $** masters.lib
|
|
|
|
|
2019-11-18 07:28:39 +00:00
|
|
|
bin\th01\op.exe: bin\th01\op.obj th01\op_02.c th01\op_03.c th01\op_04.c th01\op_10.c th01\op_11.c th01\op_12.cpp
|
2015-03-07 16:35:30 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eOP.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2015-02-21 19:45:02 +00:00
|
|
|
|
2019-11-18 07:28:39 +00:00
|
|
|
bin\th01\reiiden.exe: bin\th01\reiiden.obj th01\main_02.c th01\main_03.c th01\main_04.c th01\main_12.c th01\main_13.c th01\main_14.c th01\main_16.c
|
2015-03-07 16:35:30 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eREIIDEN.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2015-02-21 19:45:02 +00:00
|
|
|
|
2015-09-05 20:06:46 +00:00
|
|
|
bin\th01\fuuin.exe: bin\th01\fuuin.obj th01\fuuin_05.c th01\fuuin_06.c th01\fuuin_11.c th01\fuuin_12.c th01\fuuin_13.c
|
2015-02-27 22:11:47 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -3 -nbin\th01\ -eFUUIN.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2015-02-21 19:45:02 +00:00
|
|
|
|
2015-09-16 03:02:29 +00:00
|
|
|
bin\th02\zun_res.com: th02\zun_res1.c th02\zun_res2.c
|
|
|
|
$(CC) $(CFLAGS) -mt -lt -Z -nbin\th02\ -eZUN_RES.COM @&&|
|
|
|
|
$**
|
|
|
|
| masters.lib
|
|
|
|
|
2015-03-16 21:35:52 +00:00
|
|
|
bin\th02\op.exe: th02\op_01.c bin\th02\op.obj th02\op_02_1.c th02\op_02_2.c th02\op_03.c th02\op_04.c th02\op_05.c th02\op_06.c
|
2015-02-25 22:05:20 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eOP.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2015-02-28 21:37:40 +00:00
|
|
|
|
2015-03-14 22:25:50 +00:00
|
|
|
bin\th02\main.exe: bin\th02\main.obj th02\main02_1.c th02\main02_2.c
|
2015-03-04 03:28:16 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -Z -DGAME=2 -nbin\th02\ -eMAIN.EXE @&&|
|
2015-03-04 01:39:36 +00:00
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
2015-03-14 22:25:50 +00:00
|
|
|
bin\th02\maine.exe: bin\th02\maine.obj th02\maine021.c th02\maine022.c th02\maine_03.c th02\maine_04.c th02\maine_05.c
|
2015-02-28 21:37:40 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=2 -nbin\th02\ -eMAINE.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2015-03-03 09:20:20 +00:00
|
|
|
|
|
|
|
bin\th03\op.exe: bin\th03\op.obj th03\op_02.c
|
|
|
|
$(CC) $(CFLAGS) -ml -DGAME=3 -nbin\th03\ -eOP.EXE @&&|
|
[Decompilation] [th03] Sprite display calls
Yes, decompilation, of something that was so obviously originally
written in ASM. We're still left with two un-decompilable instructions
here, but I'm amazed at how nicely I was able to abstract away all of
the gory register details, leading to pretty clear, readable, and dare
I say *portable* code?! Turbo C++ was once again pretty helpful here:
• `static_cast<char>(_BX) = _AL` actually compiles into `MOV BL, AL`,
as you would have intended,
• and no-op assignments like _DI = _DI are optimized away, allowing
us to leave them in for clarity, so that we can have all parameter
assignments for the SPRITE16 display call in a single place.
I love this compiler.
Part of P0060, funded by Touhou Patch Center.
2019-11-22 21:25:41 +00:00
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
2019-12-03 21:45:08 +00:00
|
|
|
bin\th03\main.exe: bin\th03\main.obj th03\main_01.cpp th03\sprite16.cpp
|
|
|
|
$(CC) $(CFLAGS) -ml -Z -DGAME=3 -nbin\th03\ -eMAIN.EXE @&&|
|
2015-03-03 09:20:20 +00:00
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
|
|
|
bin\th04\op.exe: bin\th04\op.obj th04\op_02.c
|
|
|
|
$(CC) $(CFLAGS) -ml -DGAME=4 -nbin\th04\ -eOP.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
2018-04-14 17:08:22 +00:00
|
|
|
|
2019-09-18 16:33:38 +00:00
|
|
|
bin\th04\scoreupd.obj: th04\scoreupd.asm
|
|
|
|
bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj
|
|
|
|
$(CC) $(CFLAGS) -ml -DGAME=4 -nbin\th04\ -eMAIN.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
[Reverse-engineering] [th04/th05] Player sprite area invalidation
And once again, the TH05 version is un-decompilable. :/ It was pretty
close this time, though, as the entire block between PUSH DI and POP DI
kind of resembles a separate inlined function, in accordance with Turbo
C++'s automatic backup of the DI register, as researched in 7f971a0.
Except that it contains a loop, and Turbo C++ refuses to inline any
function with `do`, `while`, `for`, or `goto`. If it didn't, it would
have totally worked.
Also, yes, C++ class methods are treated identically in this regard.
Oh well. Shot type control functions next, finally!
Completes P0035, funded by zorg.
2019-09-24 18:54:32 +00:00
|
|
|
bin\th05\player.obj: th05\player.asm
|
2019-09-20 18:36:19 +00:00
|
|
|
bin\th05\hud_bar.obj: th05\hud_bar.asm
|
2019-09-18 16:33:38 +00:00
|
|
|
bin\th05\scoreupd.obj: th04\scoreupd.asm
|
2019-12-07 10:37:53 +00:00
|
|
|
|
|
|
|
bin\th05\op.exe: bin\th05\op.obj th05\op_01.cpp
|
|
|
|
$(CC) $(CFLAGS) -ml -DGAME=5 -nbin\th05\ -eOP.EXE @&&|
|
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
2019-12-21 13:18:38 +00:00
|
|
|
bin\th05\main.exe: bin\th05\main.obj th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp
|
[Decompilation] [th05] Stage setup
"Yeah, let's do this real quick, how can this possibly be hard, it's
just MOVs and a few function calls"…
…except that these MOVs access quite a lot of data, which we now all
have to declare in the C world, hooray.
Once it came to midbosses and bosses, I just turned them into C structs
after all. Despite what I said in 260edd8… after all, the ASM world
doesn't care about the representation in the C world, so they don't
necessarily have to be the same.
Since these structs can't contain everything related to midbosses and
bosses (really, why did all those variables have to be spread out like
this, ZUN?), it also made for a nice occasion to continue the "stuff"
naming scheme, describing "an obviously incomplete collection of
variables related to a thing", first seen in 160d4eb.
Also, PROCDESC apparently is the only syntactically correct option to
declare an extern near proc?
Also, that `boss_phase_timed_out` variable only needs to be here
already because TCC enforces word alignment for the .data segment…
yeah, it's technically not related to this commit, but why waste time
working around it if we can just include that one variable.
Completes P0030, funded by zorg.
2019-09-15 18:14:00 +00:00
|
|
|
$(CC) $(CFLAGS) -ml -3 -Z -DGAME=5 -nbin\th05\ -eMAIN.EXE @&&|
|
2019-09-14 14:41:16 +00:00
|
|
|
$**
|
|
|
|
|
|
|
|
|
|
2018-04-14 17:08:22 +00:00
|
|
|
# ZUN.COM packing
|
|
|
|
|
2018-04-15 17:07:40 +00:00
|
|
|
bin\zuncom\zungen.com: zuncom\zungen.c
|
2018-04-14 17:08:22 +00:00
|
|
|
mkdir bin\zuncom
|
2018-04-15 17:07:40 +00:00
|
|
|
$(CC) $(CFLAGS) -mt -lt -nbin\zuncom\ -eZUNGEN.COM $**
|
2018-04-14 17:08:22 +00:00
|
|
|
|
2018-04-15 17:07:40 +00:00
|
|
|
bin\zuncom\zun_stub.bin: zuncom\zun_stub.asm
|
2018-04-14 17:08:22 +00:00
|
|
|
mkdir bin\zuncom
|
2018-04-15 17:07:40 +00:00
|
|
|
tasm zuncom\zun_stub.asm,bin\zuncom\zun_stub
|
|
|
|
tlink -t bin\zuncom\zun_stub.obj,bin\zuncom\zun_stub.bin
|
2018-04-14 17:08:22 +00:00
|
|
|
|
2018-04-15 14:37:06 +00:00
|
|
|
bin\zuncom\comcstm.com: zuncom\comcstm.c
|
|
|
|
mkdir bin\zuncom
|
|
|
|
$(CC) $(CFLAGS) -mt -lt -nbin\zuncom\ -eCOMCSTM.com $**
|
|
|
|
|
|
|
|
bin\zuncom\cstmstub.bin: zuncom\cstmstub.asm
|
|
|
|
mkdir bin\zuncom
|
|
|
|
tasm zuncom\cstmstub.asm,bin\zuncom\cstmstub
|
|
|
|
tlink -t bin\zuncom\cstmstub.obj,bin\zuncom\cstmstub.bin
|
|
|
|
|
2018-04-15 17:22:41 +00:00
|
|
|
ZUNCOM_PREREQ = bin\zuncom\zungen.com bin\zuncom\zun_stub.bin
|
2018-04-14 17:08:22 +00:00
|
|
|
|
|
|
|
bin\th02\zun.com : $(ZUNCOM_PREREQ) libs\kaja\ongchk.com bin\th02\zuninit.com bin\th02\zun_res.com bin\th01\zunsoft.com
|
2018-04-15 17:22:41 +00:00
|
|
|
bin\zuncom\zungen bin\zuncom\zun_stub.bin &&|
|
2018-04-15 17:07:40 +00:00
|
|
|
4
|
|
|
|
ONGCHK
|
|
|
|
ZUNINIT
|
|
|
|
ZUN_RES
|
|
|
|
ZUNSOFT
|
2018-04-14 17:08:22 +00:00
|
|
|
libs\kaja\ongchk.com
|
|
|
|
bin\th02\zuninit.com
|
|
|
|
bin\th02\zun_res.com
|
|
|
|
bin\th01\zunsoft.com
|
|
|
|
| bin\th02\zun.com
|
|
|
|
|
|
|
|
bin\th03\zun.com : $(ZUNCOM_PREREQ) libs\kaja\ongchk.com bin\th02\zuninit.com bin\th01\zunsoft.com bin\th03\zunsp.com bin\th03\res_yume.com
|
2018-04-15 17:22:41 +00:00
|
|
|
bin\zuncom\zungen bin\zuncom\zun_stub.bin &&|
|
2018-04-15 17:07:40 +00:00
|
|
|
5
|
|
|
|
-1
|
|
|
|
-2
|
|
|
|
-3
|
|
|
|
-4
|
|
|
|
-5
|
2018-04-14 17:08:22 +00:00
|
|
|
libs\kaja\ongchk.com
|
|
|
|
bin\th02\zuninit.com
|
|
|
|
bin\th01\zunsoft.com
|
|
|
|
bin\th03\zunsp.com
|
|
|
|
bin\th03\res_yume.com
|
|
|
|
| bin\th03\zun.com
|
2018-04-15 14:37:06 +00:00
|
|
|
|
|
|
|
bin\th04\zuncom.bin : $(ZUNCOM_PREREQ) libs\kaja\ongchk.com bin\th04\zuninit.com bin\th04\res_huma.com bin\th04\memchk.com
|
2018-04-15 17:22:41 +00:00
|
|
|
bin\zuncom\zungen bin\zuncom\zun_stub.bin &&|
|
2018-04-15 17:07:40 +00:00
|
|
|
4
|
|
|
|
-O
|
|
|
|
-I
|
|
|
|
-S
|
|
|
|
-M
|
2018-04-15 14:37:06 +00:00
|
|
|
libs\kaja\ongchk.com
|
|
|
|
bin\th04\zuninit.com
|
|
|
|
bin\th04\res_huma.com
|
|
|
|
bin\th04\memchk.com
|
|
|
|
| bin\th04\zuncom.bin
|
|
|
|
|
|
|
|
bin\th05\zuncom.bin : $(ZUNCOM_PREREQ) libs\kaja\ongchk.com bin\th05\zuninit.com bin\th05\res_kso.com bin\th05\gjinit.com bin\th05\memchk.com
|
2018-04-15 17:22:41 +00:00
|
|
|
bin\zuncom\zungen bin\zuncom\zun_stub.bin &&|
|
2018-04-15 17:07:40 +00:00
|
|
|
5
|
|
|
|
-O
|
|
|
|
-I
|
|
|
|
-S
|
|
|
|
-G
|
|
|
|
-M
|
2018-04-15 14:37:06 +00:00
|
|
|
libs\kaja\ongchk.com
|
|
|
|
bin\th05\zuninit.com
|
|
|
|
bin\th05\res_kso.com
|
|
|
|
bin\th05\gjinit.com
|
|
|
|
bin\th05\memchk.com
|
|
|
|
| bin\th05\zuncom.bin
|
|
|
|
|
|
|
|
bin\th04\zun.com : bin\zuncom\comcstm.com zuncom\zun4.txt bin\th04\zuncom.bin bin\zuncom\cstmstub.bin
|
2018-04-15 17:07:40 +00:00
|
|
|
bin\zuncom\comcstm zuncom\zun4.txt bin\th04\zuncom.bin bin\zuncom\cstmstub.bin 621381155 bin\th04\zun.com
|
2018-04-15 14:37:06 +00:00
|
|
|
|
|
|
|
bin\th05\zun.com : bin\zuncom\comcstm.com zuncom\zun5.txt bin\th05\zuncom.bin bin\zuncom\cstmstub.bin
|
2018-04-15 17:07:40 +00:00
|
|
|
bin\zuncom\comcstm zuncom\zun5.txt bin\th05\zuncom.bin bin\zuncom\cstmstub.bin 628731748 bin\th05\zun.com
|