mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th03/th04] Cutscenes: Copying pictures from VRAM page 0→1
And another variation of an EGC-accelerated inter-page copy. At least it's slightly more optimized compared to TH01's horribly slow one. But wait, page *0* to page *1*? That seems kind of backwards… Part of P0223, funded by Blue Bolt and rosenrose.
This commit is contained in:
parent
fb9f18e967
commit
684c149bef
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include "platform.h"
|
||||
#include "x86real.h"
|
||||
#include "pc98.h"
|
||||
#include "planar.h"
|
||||
#include "shiftjis.hpp"
|
||||
|
@ -13,8 +14,18 @@
|
|||
extern "C" {
|
||||
#include "th02/hardware/frmdelay.h"
|
||||
}
|
||||
#include "th03/formats/pi.hpp"
|
||||
#include "th03/cutscene/cutscene.hpp"
|
||||
|
||||
// Constants
|
||||
// ---------
|
||||
|
||||
static const pixel_t PIC_W = PI_QUARTER_W;
|
||||
static const pixel_t PIC_H = PI_QUARTER_H;
|
||||
|
||||
static const vram_byte_amount_t PIC_VRAM_W = (PIC_W / BYTE_DOTS);
|
||||
// ---------
|
||||
|
||||
// State
|
||||
// -----
|
||||
|
||||
|
@ -88,3 +99,39 @@ bool16 pascal near cutscene_script_load(const char* fn)
|
|||
#define egc_start_copy near egc_start_copy
|
||||
#include "th01/hardware/egcstart.cpp"
|
||||
#undef egc_start_copy
|
||||
|
||||
#if (GAME <= 4)
|
||||
void pascal near pic_copy_to_other(screen_x_t left, vram_y_t top)
|
||||
{
|
||||
vram_offset_t vo = vram_offset_shift(left, top);
|
||||
pixel_t y;
|
||||
vram_byte_amount_t vram_x;
|
||||
|
||||
egc_start_copy();
|
||||
|
||||
// Faster than TH01's very slow end_pic_show() version, but still not
|
||||
// as optimal as you can get within the EGC's limited 16-dot tile
|
||||
// register.
|
||||
y = 0;
|
||||
while(y < PIC_H) {
|
||||
vram_x = 0;
|
||||
while(vram_x < PIC_VRAM_W) {
|
||||
egc_temp_t tmp;
|
||||
|
||||
graph_accesspage(0); tmp = egc_chunk(vo);
|
||||
graph_accesspage(1); egc_chunk(vo) = tmp;
|
||||
|
||||
vram_x += EGC_REGISTER_SIZE;
|
||||
vo += EGC_REGISTER_SIZE;
|
||||
}
|
||||
y++;
|
||||
vo += (ROW_SIZE - PIC_VRAM_W);
|
||||
}
|
||||
egc_off();
|
||||
|
||||
// ZUN bloat: All blitting operations in this module access the
|
||||
// intended page before they blit. That's why preliminary state
|
||||
// changes like this one are completely redundant, thankfully.
|
||||
graph_accesspage(0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1200,76 +1200,12 @@ sub_9F8D endp
|
|||
fn:dword
|
||||
@cutscene_script_free$qv procdesc near
|
||||
@egc_start_copy$qv procdesc near
|
||||
@PIC_COPY_TO_OTHER$QII procdesc pascal near \
|
||||
left:word, top:word
|
||||
CUTSCENE_TEXT ends
|
||||
|
||||
mainl_01_TEXT segment byte public 'CODE' use16
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_A1C7 proc near
|
||||
|
||||
var_4 = word ptr -4
|
||||
var_2 = word ptr -2
|
||||
arg_0 = word ptr 4
|
||||
arg_2 = word ptr 6
|
||||
|
||||
enter 4, 0
|
||||
push si
|
||||
push di
|
||||
mov ax, [bp+arg_2]
|
||||
sar ax, 3
|
||||
mov dx, [bp+arg_0]
|
||||
shl dx, 6
|
||||
add ax, dx
|
||||
mov dx, [bp+arg_0]
|
||||
shl dx, 4
|
||||
add ax, dx
|
||||
mov si, ax
|
||||
call @egc_start_copy$qv
|
||||
xor di, di
|
||||
jmp short loc_A225
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_A1EC:
|
||||
mov [bp+var_2], 0
|
||||
jmp short loc_A21B
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_A1F3:
|
||||
graph_accesspage 0
|
||||
les bx, _VRAM_PLANE_B
|
||||
add bx, si
|
||||
mov ax, es:[bx]
|
||||
mov [bp+var_4], ax
|
||||
mov al, 1
|
||||
out dx, al
|
||||
mov bx, word ptr _VRAM_PLANE_B
|
||||
add bx, si
|
||||
mov ax, [bp+var_4]
|
||||
mov es:[bx], ax
|
||||
add [bp+var_2], 2
|
||||
add si, 2
|
||||
|
||||
loc_A21B:
|
||||
cmp [bp+var_2], 28h ; '('
|
||||
jl short loc_A1F3
|
||||
inc di
|
||||
add si, 28h ; '('
|
||||
|
||||
loc_A225:
|
||||
cmp di, 0C8h
|
||||
jl short loc_A1EC
|
||||
call egc_off
|
||||
graph_accesspage 0
|
||||
pop di
|
||||
pop si
|
||||
leave
|
||||
retn 4
|
||||
sub_A1C7 endp
|
||||
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
@ -1281,8 +1217,8 @@ var_4 = word ptr -4
|
|||
var_2 = word ptr -2
|
||||
arg_0 = word ptr 4
|
||||
arg_2 = word ptr 6
|
||||
arg_4 = word ptr 8
|
||||
arg_6 = word ptr 0Ah
|
||||
@@top = word ptr 8
|
||||
@@left = word ptr 0Ah
|
||||
|
||||
enter 8, 0
|
||||
push si
|
||||
|
@ -1318,12 +1254,12 @@ loc_A26F:
|
|||
mov word ptr [bp+var_8+2], ax
|
||||
mov word ptr [bp+var_8], dx
|
||||
graph_showpage 1
|
||||
mov ax, [bp+arg_6]
|
||||
mov ax, [bp+@@left]
|
||||
sar ax, 3
|
||||
mov dx, [bp+arg_4]
|
||||
mov dx, [bp+@@top]
|
||||
shl dx, 6
|
||||
add ax, dx
|
||||
mov dx, [bp+arg_4]
|
||||
mov dx, [bp+@@top]
|
||||
shl dx, 4
|
||||
add ax, dx
|
||||
mov si, ax
|
||||
|
@ -1382,9 +1318,7 @@ loc_A34E:
|
|||
cmp di, 0C8h
|
||||
jl loc_A2B4
|
||||
graph_showpage 0
|
||||
push [bp+arg_6]
|
||||
push [bp+arg_4]
|
||||
call sub_A1C7
|
||||
call @pic_copy_to_other$qii pascal, [bp+@@left], [bp+@@top]
|
||||
pop di
|
||||
pop si
|
||||
leave
|
||||
|
@ -2261,7 +2195,7 @@ loc_AAF8:
|
|||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_AB16:
|
||||
push 0A00040h
|
||||
push (160 shl 16) or 64
|
||||
push [bp+var_2]
|
||||
push si
|
||||
call sub_A23C
|
||||
|
@ -2284,8 +2218,8 @@ loc_AB44:
|
|||
|
||||
loc_AB54:
|
||||
graph_showpage 0
|
||||
push 0A00040h
|
||||
call sub_A1C7
|
||||
push (160 shl 16) or 64
|
||||
call @pic_copy_to_other$qii
|
||||
|
||||
loc_AB63:
|
||||
jmp loc_AC1E ; default
|
||||
|
|
|
@ -337,76 +337,12 @@ _main endp
|
|||
fn:dword
|
||||
@cutscene_script_free$qv procdesc near
|
||||
@egc_start_copy$qv procdesc near
|
||||
@PIC_COPY_TO_OTHER$QII procdesc pascal near \
|
||||
left:word, top:word
|
||||
CUTSCENE_TEXT ends
|
||||
|
||||
maine_01_TEXT segment byte public 'CODE' use16
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_A30A proc near
|
||||
|
||||
var_4 = word ptr -4
|
||||
var_2 = word ptr -2
|
||||
arg_0 = word ptr 4
|
||||
arg_2 = word ptr 6
|
||||
|
||||
enter 4, 0
|
||||
push si
|
||||
push di
|
||||
mov ax, [bp+arg_2]
|
||||
sar ax, 3
|
||||
mov dx, [bp+arg_0]
|
||||
shl dx, 6
|
||||
add ax, dx
|
||||
mov dx, [bp+arg_0]
|
||||
shl dx, 4
|
||||
add ax, dx
|
||||
mov si, ax
|
||||
call @egc_start_copy$qv
|
||||
xor di, di
|
||||
jmp short loc_A368
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_A32F:
|
||||
mov [bp+var_2], 0
|
||||
jmp short loc_A35E
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_A336:
|
||||
graph_accesspage 0
|
||||
les bx, _VRAM_PLANE_B
|
||||
add bx, si
|
||||
mov ax, es:[bx]
|
||||
mov [bp+var_4], ax
|
||||
mov al, 1
|
||||
out dx, al
|
||||
mov bx, word ptr _VRAM_PLANE_B
|
||||
add bx, si
|
||||
mov ax, [bp+var_4]
|
||||
mov es:[bx], ax
|
||||
add [bp+var_2], 2
|
||||
add si, 2
|
||||
|
||||
loc_A35E:
|
||||
cmp [bp+var_2], 28h ; '('
|
||||
jl short loc_A336
|
||||
inc di
|
||||
add si, 28h ; '('
|
||||
|
||||
loc_A368:
|
||||
cmp di, 0C8h
|
||||
jl short loc_A32F
|
||||
call egc_off
|
||||
graph_accesspage 0
|
||||
pop di
|
||||
pop si
|
||||
leave
|
||||
retn 4
|
||||
sub_A30A endp
|
||||
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
@ -418,8 +354,8 @@ var_4 = word ptr -4
|
|||
var_2 = word ptr -2
|
||||
arg_0 = word ptr 4
|
||||
arg_2 = word ptr 6
|
||||
arg_4 = word ptr 8
|
||||
arg_6 = word ptr 0Ah
|
||||
@@top = word ptr 8
|
||||
@@left = word ptr 0Ah
|
||||
|
||||
enter 8, 0
|
||||
push si
|
||||
|
@ -519,9 +455,7 @@ loc_A491:
|
|||
cmp di, 0C8h
|
||||
jl loc_A3F7
|
||||
graph_showpage 0
|
||||
push [bp+arg_6]
|
||||
push [bp+arg_4]
|
||||
call sub_A30A
|
||||
call @pic_copy_to_other$qii pascal, [bp+@@left], [bp+@@top]
|
||||
pop di
|
||||
pop si
|
||||
leave
|
||||
|
@ -1383,8 +1317,8 @@ loc_ACE0:
|
|||
|
||||
loc_ACF0:
|
||||
graph_showpage 0
|
||||
push 0A00040h
|
||||
call sub_A30A
|
||||
push (160 shl 16) or 64
|
||||
call @pic_copy_to_other$qii
|
||||
|
||||
loc_ACFF:
|
||||
jmp loc_ADB5 ; default
|
||||
|
|
Loading…
Reference in New Issue