From 5a6ac29f504c2f9a3240cf6c2d2d95272a2f6c3e Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 6 Sep 2020 01:40:03 +0200 Subject: [PATCH] [Separate translation units] [th03] CDG: Non-alpha display (undecompilable) Reason: Self-modifying. -.- Part of P0114, funded by Lmocinemod. --- Makefile.mak | 4 +-- Tupfile | 2 ++ Tupfile.bat | 1 + .../cdg_put_noalpha.asm => cdg_p_na.asm} | 34 +++++++++++++------ th03/formats/cdg.h | 7 ++++ th03_mainl.asm | 2 +- th03_op.asm | 2 +- 7 files changed, 37 insertions(+), 15 deletions(-) rename th03/{formats/cdg_put_noalpha.asm => cdg_p_na.asm} (64%) diff --git a/Makefile.mak b/Makefile.mak index 1477bf23..c824cbf5 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -83,7 +83,7 @@ bin\th03\res_yume.com: th03\res_yume.cpp $** | masters.lib -bin\th03\op.exe: bin\th03\op.obj bin\hfliplut.obj bin\frmdely2.obj +bin\th03\op.exe: bin\th03\op.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj bin\frmdely2.obj $(CC) $(CFLAGS) -ml -DGAME=3 -nbin\th03\ -eOP.EXE @&&| $** | @@ -93,7 +93,7 @@ bin\th03\main.exe: bin\th03\main.obj th03\main_01.cpp th03\sprite16.cpp $** | -bin\th03\mainl.exe: bin\th03\mainl.obj bin\hfliplut.obj +bin\th03\mainl.exe: bin\th03\mainl.obj bin\th03\cdg_p_na.obj bin\hfliplut.obj $(CC) $(CFLAGS) -ml -DGAME=3 -nbin\th03\ -eMAINL.EXE @&&| $** | diff --git a/Tupfile b/Tupfile index c06c1520..9302d0f5 100644 --- a/Tupfile +++ b/Tupfile @@ -36,6 +36,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe : 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 |> bin\\%B.obj +!as3 = |> $(AS) /dGAME=3 th03\%b %o |> bin\\th03\\%B.obj !as4 = |> $(AS) /dGAME=4 th04\%b %o |> bin\\th04\\%B.obj !as5 = |> $(AS) /dGAME=5 th05\%b %o |> bin\\th05\\%B.obj @@ -63,6 +64,7 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe : th02_maine.asm |> !as |> bin\\th02\\maine.obj : libs/sprite16/sprite16.asm |> $(AS) /DTHIEF libs\sprite16\sprite16.asm %o |> bin\\th03\\zunsp.obj +: th03\\cdg_p_na.asm |> !as3 |> : th03_op.asm |> !as |> bin\\th03\\op.obj : th03_main.asm | \ th03/sprites/score.asp \ diff --git a/Tupfile.bat b/Tupfile.bat index 1cd7be24..0620ac2b 100644 --- a/Tupfile.bat +++ b/Tupfile.bat @@ -25,6 +25,7 @@ tasm32 /m /mx /kh32768 /t th02_op.asm bin\th02\op.obj tasm32 /m /mx /kh32768 /t th02_main.asm bin\th02\main.obj tasm32 /m /mx /kh32768 /t th02_maine.asm bin\th02\maine.obj tasm32 /m /mx /kh32768 /t /DTHIEF libs\sprite16\sprite16.asm bin\th03\zunsp.obj +tasm32 /m /mx /kh32768 /t /dGAME=3 th03\cdg_p_na.asm bin\th03\cdg_p_na.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 diff --git a/th03/formats/cdg_put_noalpha.asm b/th03/cdg_p_na.asm similarity index 64% rename from th03/formats/cdg_put_noalpha.asm rename to th03/cdg_p_na.asm index 8ca5f7ea..d8df4829 100644 --- a/th03/formats/cdg_put_noalpha.asm +++ b/th03/cdg_p_na.asm @@ -1,7 +1,14 @@ -; Displays the CDG image in the given [slot] at (⌊left/8⌋*8, top), -; disregarding its alpha plane. + .386 + locals + +include pc98.inc +include th03/formats/cdg.inc + + extrn _cdg_slots:cdg_t:CDG_SLOT_COUNT + +SEG2 segment word public 'CODE' use16 + assume cs:SEG2 -; void pascal cdg_put_noalpha(screen_x_t left, vram_y_t top, int slot); public CDG_PUT_NOALPHA cdg_put_noalpha proc far @@ -9,39 +16,41 @@ cdg_put_noalpha proc far @@top = word ptr 8 @@left = word ptr 10 +@@vram_offset_at_bottom_left equ + push bp mov bp, sp push si push di mov si, [bp+@@slot] - shl si, 4 + shl si, 4 ; *= size cdg_t add si, offset _cdg_slots mov ax, [bp+@@left] sar ax, 3 add ax, [si+cdg_t.offset_at_bottom_left] mov di, ax mov ax, [si+cdg_t.vram_dword_w] - mov word ptr cs:@@width+1, ax + mov word ptr cs:@@width, ax jmp short $+2 shl ax, 2 - add ax, (640 / 8) + add ax, ROW_SIZE mov dx, ax mov ax, [bp+@@top] mov bx, ax shl ax, 2 add ax, bx - add ax, 0A800h + add ax, SEG_PLANE_B mov es, ax push ds mov ax, [si+cdg_t.seg_colors] mov ds, ax xor si, si - mov bx, di + mov @@vram_offset_at_bottom_left, di cld - nop + even @@row_loop: -@@width: +@@width = word ptr $+1 mov cx, 1234h rep movsd sub di, dx @@ -56,4 +65,7 @@ cdg_put_noalpha proc far pop bp retf 6 cdg_put_noalpha endp - align 2 + even +SEG2 ends + + end diff --git a/th03/formats/cdg.h b/th03/formats/cdg.h index 9c6eae07..f00d6ab8 100644 --- a/th03/formats/cdg.h +++ b/th03/formats/cdg.h @@ -70,4 +70,11 @@ void pascal cdg_free(int slot); // Frees the CDG images in all slots. void pascal cdg_free_all(void); // ------------------- + +// Blitting +// -------- +// Displays the CDG image in the given [slot] at (⌊left/8⌋*8, top), +// disregarding its alpha plane. +void pascal cdg_put_noalpha(screen_x_t left, vram_y_t top, int slot); +// -------- /// --------------------------------------------------------------------------- diff --git a/th03_mainl.asm b/th03_mainl.asm index 3d4cc53f..de279d61 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -5587,7 +5587,7 @@ include th03/formats/pi_slot_put_quarter.asm include th03/hardware/input_modes.asm include th03/hardware/input_wait.asm db 0 -include th03/formats/cdg_put_noalpha.asm + extern CDG_PUT_NOALPHA:proc extern _hflip_lut_generate:proc seg2 ends diff --git a/th03_op.asm b/th03_op.asm index 5b81b91c..1f310620 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -3641,7 +3641,7 @@ include th02/formats/pi_slot_load.asm include th03/hardware/input_modes.asm include th03/hardware/input_wait.asm db 0 -include th03/formats/cdg_put_noalpha.asm + extern CDG_PUT_NOALPHA:proc extern _hflip_lut_generate:proc extern FRAME_DELAY_2:proc seg2 ends