From 1f1847de48b770dc07be92af17a7a99c2d97d7d5 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 6 Sep 2020 01:12:42 +0200 Subject: [PATCH] [Build] Assemble all .ASM files in the 32-bit build part MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Yeah, why *were* we assembling them in the 16-bit part before?! Possible reasons: • In a time before Tup, it made no actual difference whether these little files were assembled in the 32-bit or 16-bit part. Now it sort of does, since we've temporarily given up on minimal rebuilds in the 16-bit part. • Emphasizing the temporary nature of the 32-bit part by deliberately moving everything to the 16-bit part as early as possible? • It all started with the ZUN.COM ASM code, which doesn't include any other files, and can therefore be perfectly tracked by a Makefile. Which *was* superior than the exclusive dumb batch file we had in the past. And then I've simply cargo-culted all new .ASM translation units into the 16-bit part well. Oh, and another positive side effect of temporarily not using 16-bit TASM: The build process now also runs on Windows 95. Part of P0113, funded by Lmocinemod. --- CONTRIBUTING.md | 7 ++----- Makefile.mak | 40 +++------------------------------------- README.md | 4 ++-- Tupfile | 16 +++++++++++++++- Tupfile.bat | 8 ++++++++ build32b.bat | 1 + libs/piloadc/piloadc.asm | 7 ++++++- 7 files changed, 37 insertions(+), 46 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71ec7b83..a069c07a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,11 +55,8 @@ C++, Open Watcom, and Visual C++, which will ease future third-party ports. ## Build system -* Whenever you edit the `Tupfile`: - * Make sure that the `B32_OBJS` list in `build32b.bat` still matches the - list of `.obj` files generated from the `Tupfile` - * Run `tup generate Tupfile.bat` to update the dumb batch fallback script, - for systems that can't run Tup. +* Whenever you edit the `Tupfile`, run `tup generate Tupfile.bat` to update + the dumb batch fallback script, for systems that can't run Tup. ## Code organization diff --git a/Makefile.mak b/Makefile.mak index fcc92208..20d9e02b 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -22,25 +22,6 @@ th03:: $(TH03:\=bin\th03\) th04:: $(TH04:\=bin\th04\) th05:: $(TH05:\=bin\th05\) -# Third-party libraries -# --------------------- -bin\piloadc.obj: libs\piloadc\piloadc.asm - $(AS) $(AFLAGS) $**, $* -# --------------------- - -{th05}.asm{bin\th05}.obj: - $(AS) $(AFLAGS) /dGAME=5 $**, $(@R) - -# 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) $(AFLAGS) /dGAME=4 $**, $(@R) -{th04}.asm{bin\th05}.obj: - $(AS) $(AFLAGS) /dGAME=5 $**, $(@R) -# ------------------------------- - .obj.exe: $(CC) $(CFLAGS) -ml $** @@ -113,17 +94,11 @@ bin\th04\op.exe: bin\th04\op.obj th04\op_01.cpp th04\op_02.c $** | -bin\th04\scoreupd.obj: th04\scoreupd.asm bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp th04\main032.cpp $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&| $** | -bin\th05\bullet.obj: th05\bullet.asm -bin\th05\player.obj: th05\player.asm -bin\th05\hud_bar.obj: th05\hud_bar.asm -bin\th05\scoreupd.obj: th04\scoreupd.asm - bin\th05\res_kso.com: th05\res_kso.cpp $(CC) $(CFLAGS) -mt -lt -Z -DGAME=5 -nbin\th05\ -eRES_KSO.COM @&&| $** @@ -141,24 +116,15 @@ $** # ZUN.COM packing +{bin\zuncom}.obj{bin\zuncom}.bin: + tlink -t $**, $@ + bin\zuncom\zungen.com: zuncom\zungen.c - mkdir bin\zuncom $(CC) $(CFLAGS) -mt -lt -nbin\zuncom\ -eZUNGEN.COM $** -bin\zuncom\zun_stub.bin: zuncom\zun_stub.asm - mkdir bin\zuncom - tasm zuncom\zun_stub.asm,bin\zuncom\zun_stub - tlink -t bin\zuncom\zun_stub.obj,bin\zuncom\zun_stub.bin - 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 - ZUNCOM_PREREQ = bin\zuncom\zungen.com bin\zuncom\zun_stub.bin bin\th02\zun.com : $(ZUNCOM_PREREQ) libs\kaja\ongchk.com bin\th02\zuninit.com bin\th02\zun_res.com bin\th01\zunsoft.com diff --git a/README.md b/README.md index bca7af85..830d53ef 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ You will need: ---- -* **Borland Turbo Assembler (TASM), version 4.1 or later, for 16-bit DOS (`TASM.EXE`)** +* **Borland Turbo Assembler (TASM), version 4.1 or later, for 16-bit DOS (`TASM.EXE`)** (currently not needed) Towards TH05, the games increasingly used raw ASM code that [can't be decompiled]. Thus, even the final 16-bit-only build will need some sort of assembler. @@ -146,7 +146,7 @@ You will need: ---- -The most performant OS for building ReC98 is therefore a 32-bit Windows ≥Vista, where both the 32-bit and 16-bit build parts can run natively from a single shell. The build process should work reliably on pretty much every system though: Windows 98 SE (which you might use on actual PC-98 hardware) is the oldest one to be known to work, and modern 64-bit Windows and Linux of course work as well. +The most performant OS for building ReC98 is therefore a 32-bit Windows ≥Vista, where both the 32-bit and 16-bit build parts can run natively from a single shell. The build process was tested and should work reliably on pretty much every system though – from modern 64-bit Windows and Linux, down to Windows 95, which you might use on actual PC-98 hardware. To build, simply run `build.bat` and follow any instructions. The final executables will be put into `bin\th0?`, using the same names as the originals. diff --git a/Tupfile b/Tupfile index 87c2b704..cf27a342 100644 --- a/Tupfile +++ b/Tupfile @@ -35,7 +35,16 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe : th05/sprites/gaiji.bmp |> !bmp2arr -sym _sGAIJI -of asm -sw 16 -sh 16 |> th05/sprites/gaiji.asp : th05/sprites/piano_l.bmp |> !bmp2arr -sym _sPIANO_LABEL_FONT -of asm -sw 8 -sh 8 |> th05/sprites/piano_l.asp -!as = |> $(AS) %f %o |> %o +!as = |> $(AS) %f %o |> bin\\%B.obj +!as4 = |> $(AS) /dGAME=4 th04\%b %o |> bin\\th04\\%B.obj +!as5 = |> $(AS) /dGAME=5 th05\%b %o |> bin\\th05\\%B.obj + +# Third-party libraries +: libs\\piloadc\\piloadc.asm |> $(AS) /ml libs\piloadc\%b %o |> bin\\%B.obj + +# ZUN.COM +: zuncom\\zun_stub.asm |> $(AS) zuncom\%b %o |> bin\\zuncom\\%B.obj +: zuncom\\cstmstub.asm |> $(AS) zuncom\%b %o |> bin\\zuncom\\%B.obj : th01_op.asm |> !as |> bin\\th01\\op.obj : th01_reiiden.asm | \ @@ -60,6 +69,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe |> !as |> bin\\th03\\main.obj : th03_mainl.asm |> !as |> bin\\th03\\mainl.obj +: th04\\scoreupd.asm |> !as4 |> : th04_op.asm |> !as |> bin\\th04\\op.obj : th04_main.asm | \ th02/sprites/pellet.asp \ @@ -69,6 +79,10 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe |> !as |> bin\\th04\\main.obj : th04_maine.asm |> !as |> bin\\th04\\maine.obj +: th04\\scoreupd.asm |> $(AS) /dGAME=5 th04\%b %o |> bin\\th05\\%B.obj +: th05\\player.asm |> !as5 |> +: th05\\hud_bar.asm |> !as5 |> +: th05\\bullet.asm |> !as5 |> : th05_op.asm | \ th05/sprites/piano_l.asp \ |> !as |> bin\\th05\\op.obj diff --git a/Tupfile.bat b/Tupfile.bat index fd558f6b..8bc7c84a 100644 --- a/Tupfile.bat +++ b/Tupfile.bat @@ -14,6 +14,9 @@ bin\\Pipeline\\bmp2arr.exe -i th04/sprites/pelletbt.bmp -o th04/sprites/pelletbt bin\\Pipeline\\bmp2arr.exe -i th04/sprites/pointnum.bmp -o th04/sprites/pointnum.asp -sym _sPOINTNUMS -of asm -sw 8 -sh 8 -pshf inner bin\\Pipeline\\bmp2arr.exe -i th05/sprites/gaiji.bmp -o th05/sprites/gaiji.asp -sym _sGAIJI -of asm -sw 16 -sh 16 bin\\Pipeline\\bmp2arr.exe -i th05/sprites/piano_l.bmp -o th05/sprites/piano_l.asp -sym _sPIANO_LABEL_FONT -of asm -sw 8 -sh 8 +tasm32 /m /mx /kh32768 /t /ml libs\piloadc\piloadc.asm bin\piloadc.obj +tasm32 /m /mx /kh32768 /t zuncom\zun_stub.asm bin\zuncom\zun_stub.obj +tasm32 /m /mx /kh32768 /t zuncom\cstmstub.asm bin\zuncom\cstmstub.obj tasm32 /m /mx /kh32768 /t th01_op.asm bin\th01\op.obj tasm32 /m /mx /kh32768 /t th01_reiiden.asm bin\th01\reiiden.obj tasm32 /m /mx /kh32768 /t th01_fuuin.asm bin\th01\fuuin.obj @@ -25,9 +28,14 @@ tasm32 /m /mx /kh32768 /t /DTHIEF libs\sprite16\sprite16.asm bin\th03\zunsp.obj tasm32 /m /mx /kh32768 /t th03_op.asm bin\th03\op.obj tasm32 /m /mx /kh32768 /t th03_main.asm bin\th03\main.obj tasm32 /m /mx /kh32768 /t th03_mainl.asm bin\th03\mainl.obj +tasm32 /m /mx /kh32768 /t /dGAME=4 th04\scoreupd.asm bin\th04\scoreupd.obj tasm32 /m /mx /kh32768 /t th04_op.asm bin\th04\op.obj tasm32 /m /mx /kh32768 /t th04_main.asm bin\th04\main.obj tasm32 /m /mx /kh32768 /t th04_maine.asm bin\th04\maine.obj +tasm32 /m /mx /kh32768 /t /dGAME=5 th04\scoreupd.asm bin\th05\scoreupd.obj +tasm32 /m /mx /kh32768 /t /dGAME=5 th05\player.asm bin\th05\player.obj +tasm32 /m /mx /kh32768 /t /dGAME=5 th05\hud_bar.asm bin\th05\hud_bar.obj +tasm32 /m /mx /kh32768 /t /dGAME=5 th05\bullet.asm bin\th05\bullet.obj tasm32 /m /mx /kh32768 /t th05_op.asm bin\th05\op.obj tasm32 /m /mx /kh32768 /t th05_main.asm bin\th05\main.obj tasm32 /m /mx /kh32768 /t th05_maine.asm bin\th05\maine.obj diff --git a/build32b.bat b/build32b.bat index 3da2cfac..1abb9be0 100755 --- a/build32b.bat +++ b/build32b.bat @@ -28,6 +28,7 @@ if errorlevel 1 goto no_bcc32 : Neither BCC32 nor TASM32 automatically create nonexisting output : directories. Tup would, but not everybody can use it. +mkdir bin\zuncom %STDERR_IGNORE% mkdir bin\Pipeline %STDERR_IGNORE% for %%i in (1 2 3 4 5) do mkdir bin\th0%%i %STDERR_IGNORE% diff --git a/libs/piloadc/piloadc.asm b/libs/piloadc/piloadc.asm index e748cb98..de58c891 100644 --- a/libs/piloadc/piloadc.asm +++ b/libs/piloadc/piloadc.asm @@ -1,5 +1,10 @@ ; The only change in ZUN's fork: The format ID is 'NZ', rather than 'iP'. Lol. +; For compatibility with later TASM versions, "segcs movsw" has also been +; spelled out to what it's actually supposed to mean. +; (movs word ptr es:[di], word ptr cs:[si]) +; ---------------------------------------------------------------------------- + ;////////////////////////////////////////////////////////////////////////////// ; ; Pi 16色 グラフィック・ローダ 1990 やなぎさわ @@ -489,7 +494,7 @@ nopalet: mov si,offset dftpal mov di,PaletteBuff mov cx,12 -rep segcs movsw +rep movs word ptr es:[di], word ptr cs:[si] palend: test option,1 jz @@skip