[Decompilation] [th01] Graphics BIOS initialization and activation functions

Just like with the z_text_*() functions, master.lib doesn't already
have graph_init() and graph_exit() either, and once again, ZUN's code
here doesn't fully correspond to any master.lib function. Unlike the
z_text_*() functions though, those names aren't really the best
descriptions for these rather random combinations of BIOS calls and I/O
port writes…

Anyway, that's the entire segment!

Part of P0080, funded by Ember2528 and Splashman.
This commit is contained in:
nmlgc 2020-03-01 22:47:46 +01:00
parent ee682ce2e1
commit de3f9ec31b
5 changed files with 103 additions and 453 deletions

View File

@ -82,6 +82,82 @@ extern page_t page_back;
clip_max(top, bottom, (RES_Y - 1));
/// --------
/// BIOS
/// ----
inline void graph_access_and_show_0()
{
graph_accesspage_func(0);
graph_showpage_func(0);
}
inline void cgrom_code_and_grcg_off()
{
outportb(0x68, 0xA); // CG ROM code access
grcg_off();
}
inline void z_graph_400line()
{
REGS regs;
z_graph_hide();
// 640x400
regs.h.ah = 0x42;
regs.h.ch = 0xC0;
int86(0x18, &regs, &regs);
// 16-color, analog mode
outportb(0x6A, 1);
}
inline void z_graph_access_and_show_0()
{
graph_access_and_show_0();
cgrom_code_and_grcg_off();
z_graph_show();
}
void z_graph_init()
{
z_graph_400line();
z_palette_set_all_show(z_Palettes);
graph_access_and_show_0();
z_graph_clear_0();
cgrom_code_and_grcg_off();
z_graph_show();
}
void graph_400line_access_and_show_0()
{
z_graph_400line();
z_graph_access_and_show_0();
}
void z_graph_exit()
{
z_palette_black();
z_graph_clear_0();
graph_access_and_show_0();
z_graph_show();
cgrom_code_and_grcg_off();
}
void z_graph_show()
{
REGS regs;
regs.h.ah = 0x40;
int86(0x18, &regs, &regs);
}
void z_graph_hide()
{
REGS regs;
regs.h.ah = 0x41;
int86(0x18, &regs, &regs);
}
/// ----
/// Page flipping
/// -------------
void graph_showpage_func(page_t page)

View File

@ -1,3 +1,15 @@
/// BIOS
/// ----
// Enables the graphics layer in 640x400 mode, applies z_Palettes, and clears
// page 0.
void z_graph_init(void);
// Resets all hardware colors to black and clears page 0.
void z_graph_exit(void);
void z_graph_show(void);
void z_graph_hide(void);
/// ----
/// Pages
/// -----
void graph_showpage_func(page_t page);

View File

@ -5808,7 +5808,7 @@ game_exit_inner proc far
call _vsync_exit
call _z_text_clear
call _z_palette_black_out
call sub_D094
call _z_graph_exit
call egc_start
pushd [_int06_old] ; isr
push 6 ; interruptno
@ -5897,159 +5897,7 @@ fuuin_07_TEXT ends
; Segment type: Pure code
fuuin_08_TEXT segment byte public 'CODE' use16
assume cs:fuuin_08_TEXT
;org 4
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_CFF4 proc far
inregs = REGS ptr -10h
enter 10h, 0
nopcall sub_D0E0
mov byte ptr [bp+inregs+1], 42h ; 'B'
mov byte ptr [bp+inregs+5], 0C0h ; 'À'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push ds
push offset _z_Palettes
nopcall _z_palette_set_all_show
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 12h
nopcall _z_graph_clear_0
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_D0C5
leave
retf
sub_CFF4 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D04B proc far
inregs = REGS ptr -10h
enter 10h, 0
nopcall sub_D0E0
mov byte ptr [bp+inregs+1], 42h ; 'B'
mov byte ptr [bp+inregs+5], 0C0h ; 'À'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 0Eh
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_D0C5
leave
retf
sub_D04B endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D094 proc far
push bp
mov bp, sp
nopcall _z_palette_black
nopcall _z_graph_clear_0
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 4
nopcall sub_D0C5
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
pop bp
retf
sub_D094 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D0C5 proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 40h
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_D0C5 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D0E0 proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 41h ; 'A'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_D0E0 endp
extern _z_graph_exit:proc
extern _graph_showpage_func:proc
extern _graph_accesspage_func:proc
extern _z_palette_set_all_show:proc

View File

@ -2239,7 +2239,7 @@ game_exit_inner proc far
call _vsync_exit
call _z_text_clear
call _z_palette_black_out
call sub_B8D0
call _z_graph_exit
call egc_start
pushd [dword ptr _int06_old] ; isr
push 6 ; interruptno
@ -2329,137 +2329,7 @@ op_05_TEXT ends
; Segment type: Pure code
op_06_TEXT segment byte public 'CODE' use16
assume cs:op_06_TEXT
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
enter 10h, 0
nopcall sub_B91C
mov byte ptr [bp-0Fh], 42h ; 'B'
mov byte ptr [bp-0Bh], 0C0h
push ss
lea ax, [bp-10h]
push ax
push ss
push ax
push 18h
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push ds
push offset _z_Palettes
nopcall _z_palette_set_all_show
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 12h
nopcall _z_graph_clear_0
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_B901
leave
retf
; ---------------------------------------------------------------------------
enter 10h, 0
nopcall sub_B91C
mov byte ptr [bp-0Fh], 42h ; 'B'
mov byte ptr [bp-0Bh], 0C0h
push ss
lea ax, [bp-10h]
push ax
push ss
push ax
push 18h
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 0Eh
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_B901
leave
retf
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_B8D0 proc far
push bp
mov bp, sp
nopcall _z_palette_black
nopcall _z_graph_clear_0
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 4
nopcall sub_B901
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
pop bp
retf
sub_B8D0 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_B901 proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 40h
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_B901 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_B91C proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 41h ; 'A'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_B91C endp
extern _z_graph_exit:proc
extern _graph_showpage_func:proc
extern _graph_accesspage_func:proc
extern _grcg_setcolor_rmw:proc

View File

@ -3365,7 +3365,7 @@ loc_D118:
mov [bp+var_4], 0
cmp _mode_test, 1
jnz loc_D317
call sub_EA17
call _z_graph_hide
push ds
push offset format ; "\x1B*"
call _printf
@ -3579,7 +3579,7 @@ sub_D323 proc far
mov bp, sp
cmp _mode_test, 1
jnz short loc_D33E
call sub_E9FC
call _z_graph_show
push ds
push offset format ; "\x1B*"
call _printf
@ -4158,7 +4158,7 @@ loc_D795:
mov word ptr dword_36C1A+2, dx
mov word ptr dword_36C1A, ax
call sub_BC87
call sub_E92B
call _z_graph_init
push 0
call _graph_accesspage_func
pop cx
@ -5403,7 +5403,7 @@ game_exit_inner proc far
call _vsync_exit
call _z_text_clear
call _z_palette_black_out
call sub_E9CB
call _z_graph_exit
call egc_start
pushd [_int06_old] ; isr
push 6 ; interruptno
@ -5480,6 +5480,9 @@ arglist = byte ptr 0Ah
call _z_text_print
push 1 ; status
call _exit
add sp, 12h
leave
retf
game_exit_print_error endp
main_05_TEXT ends
@ -5488,169 +5491,10 @@ main_05_TEXT ends
; Segment type: Pure code
main_06_TEXT segment byte public 'CODE' use16
assume cs:main_06_TEXT
;org 6
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== S U B R O U T I N E =======================================
sub_E926 proc far
add sp, 12h
leave
retf
sub_E926 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_E92B proc far
inregs = REGS ptr -10h
enter 10h, 0
nopcall sub_EA17
mov byte ptr [bp+inregs+1], 42h ; 'B'
mov byte ptr [bp+inregs+5], 0C0h ; 'À'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push ds
push offset _z_Palettes
nopcall _z_palette_set_all_show
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 12h
nopcall _z_graph_clear_0
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_E9FC
leave
retf
sub_E92B endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_E982 proc far
inregs = REGS ptr -10h
enter 10h, 0
nopcall sub_EA17
mov byte ptr [bp+inregs+1], 42h ; 'B'
mov byte ptr [bp+inregs+5], 0C0h ; 'À'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
mov dx, 6Ah ; 'j'
mov al, 1
out dx, al ; PC-98 GDC (6a):
;
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 0Eh
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
nopcall sub_E9FC
leave
retf
sub_E982 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_E9CB proc far
push bp
mov bp, sp
nopcall _z_palette_black
nopcall _z_graph_clear_0
push 0
nopcall _graph_accesspage_func
push 0
nopcall _graph_showpage_func
add sp, 4
nopcall sub_E9FC
mov dx, 68h ; 'h'
mov al, 0Ah
out dx, al
GRCG_OFF_CLOBBERING dx
pop bp
retf
sub_E9CB endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_E9FC proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 40h
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_E9FC endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_EA17 proc far
inregs = REGS ptr -10h
enter 10h, 0
mov byte ptr [bp+inregs+1], 41h ; 'A'
push ss
lea ax, [bp+inregs]
push ax ; outregs
push ss
push ax ; inregs
push 18h ; intno
call _int86
add sp, 0Ah
leave
retf
sub_EA17 endp
extern _z_graph_init:proc
extern _z_graph_exit:proc
extern _z_graph_show:proc
extern _z_graph_hide:proc
extern _graph_showpage_func:proc
extern _graph_accesspage_func:proc
extern _grcg_setcolor_rmw:proc