[Decompilation] [th01] PTN-sized page 0→1 copies

Final shared function in TH01's OP.EXE.

Part of P0084, funded by Yanga.
This commit is contained in:
nmlgc 2020-03-19 14:12:13 +01:00
parent dfac2f2fd4
commit 1cc9cefa26
10 changed files with 35 additions and 170 deletions

10
ReC98.h
View File

@ -86,10 +86,6 @@ typedef int8_t sdots8_t;
typedef int16_t sdots16_t;
typedef int32_t sdots32_t;
// Abstracted dot types, with their width defined by a macro.
#define dots_t_(x) dots##x##_t
#define dots_t(x) dots_t_(x)
typedef enum {
PL_B, PL_R, PL_G, PL_E, PL_COUNT
} vram_plane_t;
@ -106,6 +102,12 @@ typedef struct {
dots32_t B, R, G, E;
} planar32_t;
// Abstracted dot and planar types, with their width defined by a macro.
#define dots_t_(x) dots##x##_t
#define dots_t(x) dots_t_(x)
#define planar_t_(x) planar##x##_t
#define planar_t(x) planar_t_(x)
// Since array subscripts create slightly different assembly in places, we
// offer both variants.
extern dots8_t *VRAM_PLANE[PL_COUNT];

View File

@ -81,6 +81,10 @@ void ptn_put_noalpha_8(int left, int top, int ptn_id);
// Overwrites the 4 color planes of [ptn_id] with the current VRAM content of
// the 32×32 pixels starting at (⌊left/8⌋*8, top).
void ptn_snap_8(int left, int top, int ptn_id);
// Copies the 32×32 pixels starting at (⌊left/8⌋*8, top) from VRAM page 0 to
// VRAM page 1.
void ptn_copy_8_0_to_1(int left, int top);
// ------------
// 16×16 access

13
th01/formats/ptn_0to1.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "th01/formats/ptn.hpp"
void ptn_copy_8_0_to_1(int left, int top)
{
planar_t(PTN_W) row;
unsigned int vram_offset = vram_offset_shift(left, top);
for(int y = 0; y < PTN_H; y++) {
graph_accesspage_func(0); VRAM_SNAP_PLANAR(row, vram_offset, PTN_W);
graph_accesspage_func(1); VRAM_PUT_PLANAR(vram_offset, row, PTN_W);
vram_offset += ROW_SIZE;
}
graph_accesspage_func(0);
}

View File

@ -1,7 +1,5 @@
extern "C" {
#include "th01/formats/ptn.hpp"
void ptn_snap_8(int left, int top, int ptn_id)
{
unsigned int vram_offset = vram_offset_muldiv(left, top);

View File

@ -1,7 +1,7 @@
void pascal vram_planes_set(void)
{
VRAM_PLANE_B = MK_FP(0xA800, 0);
VRAM_PLANE_R = MK_FP(0xB000, 0);
VRAM_PLANE_G = MK_FP(0xB800, 0);
VRAM_PLANE_E = MK_FP(0xE000, 0);
VRAM_PLANE_B = (dots8_t *)MK_FP(0xA800, 0);
VRAM_PLANE_R = (dots8_t *)MK_FP(0xB000, 0);
VRAM_PLANE_G = (dots8_t *)MK_FP(0xB800, 0);
VRAM_PLANE_E = (dots8_t *)MK_FP(0xE000, 0);
}

View File

@ -9,6 +9,8 @@ extern "C" {
#include "ReC98.h"
#include "th01/hardware/graph.h"
#include "th01/formats/ptn_0to1.cpp"
#include "th01/hardware/vplanset.c"
#include "th01/hardware/egccopyr.c"
#include "th01/formats/ptn_snap.cpp"
}

View File

@ -9,6 +9,8 @@ extern "C" {
#include "ReC98.h"
#include "th01/hardware/graph.h"
#include "th01/formats/ptn_0to1.cpp"
#include "th01/hardware/vplanset.c"
#include "th01/hardware/egccopyr.c"
#include "th01/formats/ptn_snap.cpp"
}

View File

@ -2107,77 +2107,6 @@ op_06_TEXT ends
; Segment type: Pure code
op_07_TEXT segment byte public 'CODE' use16
assume cs:op_07_TEXT
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
enter 10h, 0
push si
push di
mov ax, [bp+6]
sar ax, 3
mov dx, [bp+8]
shl dx, 6
add ax, dx
mov dx, [bp+8]
shl dx, 4
add ax, dx
mov si, ax
xor di, di
jmp loc_D2C8
; ---------------------------------------------------------------------------
loc_D243:
push 0
call _graph_accesspage_func
les bx, _VRAM_PLANE_B
add bx, si
mov eax, es:[bx]
mov [bp-10h], eax
les bx, _VRAM_PLANE_R
add bx, si
mov eax, es:[bx]
mov [bp-0Ch], eax
les bx, _VRAM_PLANE_G
add bx, si
mov eax, es:[bx]
mov [bp-8], eax
les bx, _VRAM_PLANE_E
add bx, si
mov eax, es:[bx]
mov [bp-4], eax
push 1
call _graph_accesspage_func
add sp, 4
les bx, _VRAM_PLANE_B
add bx, si
mov eax, [bp-10h]
mov es:[bx], eax
les bx, _VRAM_PLANE_R
add bx, si
mov eax, [bp-0Ch]
mov es:[bx], eax
les bx, _VRAM_PLANE_G
add bx, si
mov eax, [bp-8]
mov es:[bx], eax
les bx, _VRAM_PLANE_E
add bx, si
mov eax, [bp-4]
mov es:[bx], eax
add si, 50h ; 'P'
inc di
loc_D2C8:
cmp di, 20h ; ' '
jl loc_D243
push 0
call _graph_accesspage_func
pop cx
pop di
pop si
leave
retf
include th01/hardware/vram_planes_set.asm
extern _egc_copy_rect_1_to_0:proc
op_07_TEXT ends

View File

@ -5272,93 +5272,8 @@ main_06_TEXT ends
; Segment type: Pure code
main_07_TEXT segment byte public 'CODE' use16
assume cs:main_07_TEXT
;org 0Bh
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1031B proc far
var_10 = dword ptr -10h
var_C = dword ptr -0Ch
var_8 = dword ptr -8
var_4 = dword ptr -4
arg_0 = word ptr 6
arg_2 = word ptr 8
enter 10h, 0
push si
push di
mov ax, [bp+arg_0]
sar ax, 3
mov dx, [bp+arg_2]
shl dx, 6
add ax, dx
mov dx, [bp+arg_2]
shl dx, 4
add ax, dx
mov si, ax
xor di, di
jmp loc_103C3
; ---------------------------------------------------------------------------
loc_1033E:
push 0
call _graph_accesspage_func
les bx, _VRAM_PLANE_B
add bx, si
mov eax, es:[bx]
mov [bp+var_10], eax
les bx, _VRAM_PLANE_R
add bx, si
mov eax, es:[bx]
mov [bp+var_C], eax
les bx, _VRAM_PLANE_G
add bx, si
mov eax, es:[bx]
mov [bp+var_8], eax
les bx, _VRAM_PLANE_E
add bx, si
mov eax, es:[bx]
mov [bp+var_4], eax
push 1
call _graph_accesspage_func
add sp, 4
les bx, _VRAM_PLANE_B
add bx, si
mov eax, [bp+var_10]
mov es:[bx], eax
les bx, _VRAM_PLANE_R
add bx, si
mov eax, [bp+var_C]
mov es:[bx], eax
les bx, _VRAM_PLANE_G
add bx, si
mov eax, [bp+var_8]
mov es:[bx], eax
les bx, _VRAM_PLANE_E
add bx, si
mov eax, [bp+var_4]
mov es:[bx], eax
add si, 50h ; 'P'
inc di
loc_103C3:
cmp di, 20h ; ' '
jl loc_1033E
push 0
call _graph_accesspage_func
pop cx
pop di
pop si
leave
retf
sub_1031B endp
include th01/hardware/vram_planes_set.asm
extern _ptn_copy_8_0_to_1:proc
extern VRAM_PLANES_SET:proc
extern _egc_copy_rect_1_to_0:proc
extern _ptn_snap_8:proc
extern _ptn_snap_quarter_8:proc

View File

@ -9421,7 +9421,7 @@ loc_2089A:
les bx, off_39E9A
add bx, ax
push word ptr es:[bx]
call sub_1031B
call _ptn_copy_8_0_to_1
add sp, 4
loc_208BC:
@ -9445,7 +9445,7 @@ loc_208C7:
les bx, font
add bx, ax
push word ptr es:[bx]
call sub_1031B
call _ptn_copy_8_0_to_1
add sp, 4
inc si