Skip to content

Commit

Permalink
[Decompilation] [th04/th05] Cutscenes: Text blending
Browse files Browse the repository at this point in the history
Completes P0116, funded by [Anonymous] and Lmocinemod.
  • Loading branch information
nmlgc committed Sep 12, 2020
1 parent 84baa1d commit 03048c3
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 234 deletions.
8 changes: 4 additions & 4 deletions Makefile.mak
Expand Up @@ -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 @&&|
$**
|

Expand All @@ -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 @&&|
$**
|

Expand Down
50 changes: 50 additions & 0 deletions 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<int>(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
}
7 changes: 7 additions & 0 deletions 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
10 changes: 10 additions & 0 deletions 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"
}
124 changes: 10 additions & 114 deletions th04_maine.asm
Expand Up @@ -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_

; ===========================================================================
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 =======================================

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -4692,7 +4627,7 @@ loc_CC66:
sub_CBF3 endp
db 0

maine_01_TEXT ends
maine_01__TEXT ends

; ===========================================================================

Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion 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
/// -------------------
Expand Down

0 comments on commit 03048c3

Please sign in to comment.