From 03048c318d724366f89245c4966b05caa12cf613 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 12 Sep 2020 01:11:39 +0200 Subject: [PATCH] [Decompilation] [th04/th05] Cutscenes: Text blending Completes P0116, funded by [Anonymous] and Lmocinemod. --- Makefile.mak | 8 +-- th04/end/box.cpp | 50 +++++++++++++++++ th04/end/box[data].asm | 7 +++ th04/maine011.cpp | 10 ++++ th04_maine.asm | 124 ++++------------------------------------ th05/maine011.cpp | 9 ++- th05_maine.asm | 125 ++++------------------------------------- 7 files changed, 99 insertions(+), 234 deletions(-) create mode 100644 th04/end/box.cpp create mode 100644 th04/end/box[data].asm create mode 100644 th04/maine011.cpp diff --git a/Makefile.mak b/Makefile.mak index 4c4448bc..cec8d17d 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -124,8 +124,8 @@ bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp bin\ $** | -bin\th04\maine.exe: bin\th04\maine.obj bin\hfliplut.obj - $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='E' -nbin\th04\ -eMAINE.EXE @&&| +bin\th04\maine.exe: bin\th04\maine.obj th04\maine011.cpp bin\hfliplut.obj + $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='E' -Z -nbin\th04\ -eMAINE.EXE @&&| $** | @@ -144,8 +144,8 @@ bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_co $** | -bin\th05\maine.exe: bin\th05\maine.obj th05\staff.cpp bin\hfliplut.obj - $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='E' -nbin\th05\ -eMAINE.EXE @&&| +bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\hfliplut.obj + $(CC) $(CFLAGS) -ml -DGAME=5 -DBINARY='E' -Z -nbin\th05\ -eMAINE.EXE @&&| $** | diff --git a/th04/end/box.cpp b/th04/end/box.cpp new file mode 100644 index 00000000..c0a25434 --- /dev/null +++ b/th04/end/box.cpp @@ -0,0 +1,50 @@ +#include "ReC98.h" +#include "decomp.h" + +// Note that this does not correspond to the tiled area painted into TH05's +// EDBK?.PI images. +static const screen_x_t BOX_LEFT = 80; +static const screen_y_t BOX_TOP = 320; +static const pixel_t BOX_W = 480; +static const pixel_t BOX_H = (GLYPH_H * 4); + +static const screen_y_t BOX_RIGHT = (BOX_LEFT + BOX_W); +static const screen_y_t BOX_BOTTOM = (BOX_TOP + BOX_H); + +typedef enum { + BOX_MASK_0, + BOX_MASK_1, + BOX_MASK_2, + BOX_MASK_3, + BOX_MASK_COPY, + BOX_MASK_COUNT, + + _box_mask_t_FORCE_UINT16 = 0xFFFF +} box_mask_t; + +// Copies the text box area from VRAM page 1 to VRAM page 0, applying the +// given [mask]. Assumes that the EGC is active, and initialized for a copy. +void pascal near box_1_to_0_mask(box_mask_t mask) +{ + extern dots16_t BOX_MASKS[BOX_MASK_COUNT][4]; + dots16_t dots; + #define CHUNK_W static_cast(sizeof(dots) * BYTE_DOTS) + + for(screen_y_t y = BOX_TOP; y < BOX_BOTTOM; y++) { + OUTW2(EGC_READPLANEREG, 0x00ff); + // EGC_COMPAREREAD | EGC_WS_PATREG | EGC_RL_MEMREAD + OUTW2(EGC_MODE_ROP_REG, 0x3100); + OUTW2(EGC_BITLENGTHREG, 0xF); + OUTW(EGC_MASKREG, BOX_MASKS[mask][y & 3]); + + vram_offset_t vram_offset = vram_offset_shift(BOX_LEFT, y); + pixel_t x = 0; + while(x < BOX_W) { + graph_accesspage(1); VRAM_SNAP(dots, B, vram_offset, 16); + graph_accesspage(0); VRAM_PUT(B, vram_offset, dots, 16); + x += CHUNK_W; + vram_offset += (CHUNK_W / BYTE_DOTS); + } + } + #undef CHUNK_W +} diff --git a/th04/end/box[data].asm b/th04/end/box[data].asm new file mode 100644 index 00000000..ac49a3ed --- /dev/null +++ b/th04/end/box[data].asm @@ -0,0 +1,7 @@ +public _BOX_MASKS +_BOX_MASKS label word + dw 8888h, 0h, 2222h, 0h + dw 8888h, 4444h, 2222h, 1111h + dw 0AAAAh, 4444h, 0AAAAh, 1111h + dw 0AAAAh, 4444h, 0AAAAh, 5555h + dw 0FFFFh, 0FFFFh, 0FFFFh, 0FFFFh diff --git a/th04/maine011.cpp b/th04/maine011.cpp new file mode 100644 index 00000000..5ee2287e --- /dev/null +++ b/th04/maine011.cpp @@ -0,0 +1,10 @@ +/* ReC98 + * ----- + * 2nd part of code segment #1 of TH04's MAINE.EXE + */ + +#pragma codeseg maine_01_TEXT + +extern "C" { +#include "th04/end/box.cpp" +} diff --git a/th04_maine.asm b/th04_maine.asm index 970a48d4..1756299d 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -28,6 +28,7 @@ include th04/th04.inc extern _tolower:proc extern __ctype:byte +maine_01 group maine_01_TEXT, maine_01__TEXT g_seg2 group seg2, seg2_ ; =========================================================================== @@ -150,7 +151,7 @@ _TEXT ends ; Segment type: Pure code maine_01_TEXT segment byte public 'CODE' use16 - assume cs:maine_01_TEXT + assume cs:maine_01 ;org 9 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing @@ -928,75 +929,11 @@ loc_A78D: pop bp retn sub_A73B endp +maine_01_TEXT ends - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_A78F proc near - -var_2 = word ptr -2 -arg_0 = word ptr 4 - - enter 2, 0 - push si - push di - mov cx, 140h - jmp short loc_A809 -; --------------------------------------------------------------------------- - -loc_A79A: - egc_selectpat - egc_setrop EGC_COMPAREREAD or EGC_WS_PATREG or EGC_RL_MEMREAD - outw2 EGC_BITLENGTHREG, 0Fh - mov bx, [bp+arg_0] - shl bx, 3 - mov ax, cx - and ax, 3 - add ax, ax - add bx, ax - outw2 EGC_MASKREG, [bx+62Ch] - mov ax, cx - shl ax, 6 - mov dx, cx - shl dx, 4 - add ax, dx - add ax, 0Ah - mov si, ax - xor di, di - jmp short loc_A802 -; --------------------------------------------------------------------------- - -loc_A7DB: - graph_accesspage 1 - les bx, _VRAM_PLANE_B - add bx, si - mov ax, es:[bx] - mov [bp+var_2], ax - mov al, 0 - out dx, al - mov bx, word ptr _VRAM_PLANE_B - add bx, si - mov ax, [bp+var_2] - mov es:[bx], ax - add di, 10h - add si, 2 - -loc_A802: - cmp di, 1E0h - jl short loc_A7DB - inc cx - -loc_A809: - cmp cx, 180h - jl short loc_A79A - pop di - pop si - leave - retn 2 -sub_A78F endp - +maine_01__TEXT segment byte public 'CODE' use16 + BOX_1_TO_0_MASK procdesc pascal near \ + mask:word ; =============== S U B R O U T I N E ======================================= @@ -1014,8 +951,7 @@ sub_A815 proc near ; --------------------------------------------------------------------------- loc_A827: - push si - call sub_A78F + call box_1_to_0_mask pascal, si push word_124C0 call frame_delay inc si @@ -1025,8 +961,7 @@ loc_A835: jl short loc_A827 loc_A83A: - push 4 - call sub_A78F + call box_1_to_0_mask pascal, 4 call egc_off pop si pop bp @@ -4692,7 +4627,7 @@ loc_CC66: sub_CBF3 endp db 0 -maine_01_TEXT ends +maine_01__TEXT ends ; =========================================================================== @@ -4781,46 +4716,7 @@ include th03/snd/se_state[data].asm include th04/bgimage[data].asm include th03/formats/cdg[data].asm include th03/formats/pi_put_mask[data].asm - db 88h - db 88h - db 0 - db 0 - db 22h ; " - db 22h ; " - db 0 - db 0 - db 88h - db 88h - db 44h ; D - db 44h ; D - db 22h ; " - db 22h ; " - db 11h - db 11h - db 0AAh ; ª - db 0AAh ; ª - db 44h ; D - db 44h ; D - db 0AAh ; ª - db 0AAh ; ª - db 11h - db 11h - db 0AAh ; ª - db 0AAh ; ª - db 44h ; D - db 44h ; D - db 0AAh ; ª - db 0AAh ; ª - db 55h ; U - db 55h ; U - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh +include th04/end/box[data].asm asc_EB84 db ' ', 0 even aSff1_pi db 'sff1.pi',0 diff --git a/th05/maine011.cpp b/th05/maine011.cpp index 515f7408..1825b4ea 100644 --- a/th05/maine011.cpp +++ b/th05/maine011.cpp @@ -1,5 +1,12 @@ +/* ReC98 + * ----- + * 2nd part of code segment #1 of TH05's MAINE.EXE + */ + +#pragma codeseg maine_01_TEXT + extern "C" { -#include "ReC98.h" +#include "th04/end/box.cpp" /// String-to-color map /// ------------------- diff --git a/th05_maine.asm b/th05_maine.asm index 3fb64bda..bf420747 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -28,7 +28,7 @@ include th01/math/subpixel.inc extern _tolower:proc extern __ctype:byte -maine_01 group maine_01__TEXT, maine_01___TEXT +maine_01 group maine_01_TEXT, maine_01__TEXT, maine_01___TEXT g_seg2 group seg2, seg2_ ; =========================================================================== @@ -156,7 +156,7 @@ _TEXT ends ; =========================================================================== ; Segment type: Pure code -maine_01__TEXT segment byte public 'CODE' use16 +maine_01_TEXT segment byte public 'CODE' use16 assume cs:maine_01 ;org 5 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing @@ -520,75 +520,11 @@ loc_A864: pop bp retn sub_A826 endp +maine_01_TEXT ends - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_A866 proc near - -var_2 = word ptr -2 -arg_0 = word ptr 4 - - enter 2, 0 - push si - push di - mov cx, 140h - jmp short loc_A8E0 -; --------------------------------------------------------------------------- - -loc_A871: - egc_selectpat - egc_setrop EGC_COMPAREREAD or EGC_WS_PATREG or EGC_RL_MEMREAD - outw2 EGC_BITLENGTHREG, 0Fh - mov bx, [bp+arg_0] - shl bx, 3 - mov ax, cx - and ax, 3 - add ax, ax - add bx, ax - outw2 EGC_MASKREG, [bx+732h] - mov ax, cx - shl ax, 6 - mov dx, cx - shl dx, 4 - add ax, dx - add ax, 0Ah - mov si, ax - xor di, di - jmp short loc_A8D9 -; --------------------------------------------------------------------------- - -loc_A8B2: - graph_accesspage 1 - les bx, _VRAM_PLANE_B - add bx, si - mov ax, es:[bx] - mov [bp+var_2], ax - mov al, 0 - out dx, al - mov bx, word ptr _VRAM_PLANE_B - add bx, si - mov ax, [bp+var_2] - mov es:[bx], ax - add di, 10h - add si, 2 - -loc_A8D9: - cmp di, 1E0h - jl short loc_A8B2 - inc cx - -loc_A8E0: - cmp cx, 180h - jl short loc_A871 - pop di - pop si - leave - retn 2 -sub_A866 endp - +maine_01__TEXT segment byte public 'CODE' use16 + BOX_1_TO_0_MASK procdesc pascal near \ + mask:word ; =============== S U B R O U T I N E ======================================= @@ -607,8 +543,7 @@ sub_A8EC proc near ; --------------------------------------------------------------------------- loc_A904: - push si - call sub_A866 + call box_1_to_0_mask pascal, si push word_15008 call frame_delay inc si @@ -618,8 +553,7 @@ loc_A912: jl short loc_A904 loc_A917: - push 4 - call sub_A866 + call box_1_to_0_mask pascal, 4 call egc_off push 1 call frame_delay @@ -7719,47 +7653,8 @@ include th05/hardware/vram_planes[data].asm include th03/formats/cdg[data].asm public _colmap_count _colmap_count db 0 - db 0 - db 88h - db 88h - db 0 - db 0 - db 22h ; " - db 22h ; " - db 0 - db 0 - db 88h - db 88h - db 44h ; D - db 44h ; D - db 22h ; " - db 22h ; " - db 11h - db 11h - db 0AAh ; ª - db 0AAh ; ª - db 44h ; D - db 44h ; D - db 0AAh ; ª - db 0AAh ; ª - db 11h - db 11h - db 0AAh ; ª - db 0AAh ; ª - db 44h ; D - db 44h ; D - db 0AAh ; ª - db 0AAh ; ª - db 55h ; U - db 55h ; U - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh - db 0FFh + evendata +include th04/end/box[data].asm asc_1085A db ' ', 0 even byte_1085E db 0