[Reduction] #408: gaiji_backup and gaiji_restore

This commit is contained in:
nmlgc 2014-08-31 10:23:41 +02:00
parent bd2ef210c0
commit e9e6d14ab6
11 changed files with 133 additions and 466 deletions

View File

@ -0,0 +1,83 @@
; master library - PC98
;
; Description:
; 外字データをメインメモリに退避,復元する
;
; Function/Procedures:
; int gaiji_backup( void ) ; (退避)
; int gaiji_restore( void ) ; (復元)
;
;
; Parameters:
; none
;
; Returns:
; int 1 = 成功
; 0 = 失敗( 退避・復元回数不一致, メインメモリが足りないなど )
;
; Binding Target:
; Microsoft-C / Turbo-C / Turbo Pascal
;
; Running Target:
; PC-9801
;
; Requiring Resources:
; CPU: 8086
;
; Notes:
; 既に退避してあるのにもう一度退避しようとするとエラーになります。
; 同じ様に、開放も連続2回実行はできません。
; 退避、開放と交互ならば何回でも実行できます。
;
; テキスト画面が表示されていると画面の漢字がちらつきます。
;
; Compiler/Assembler:
; TASM 3.0
; OPTASM 1.6
;
; Author:
; 恋塚昭彦
;
; Revision History:
; 93/ 2/ 4 Initial
; 93/ 3/23 メモリマネージャ使用
GAIJISIZE equ 256*2*16
func GAIJI_BACKUP ; {
xor AX,AX
cmp backup_mseg,AX
jne short @@B_END ; すでに退避してるならエラー
mov AX,GAIJISIZE/16
push AX
nopcall HMEM_ALLOC
or AX,AX
jz short @@B_END
mov backup_mseg,AX
push AX
xor AX,AX
push AX
call GAIJI_READ_ALL
mov AX,1
@@B_END:
ret
endfunc ; }
func GAIJI_RESTORE ; {
mov AX,backup_mseg
test AX,AX
jz short @@R_FAULT
push AX ; このpushのみ、HMEM_FREEの引数だよん
push AX
xor AX,AX
mov backup_mseg,AX
push AX
call GAIJI_WRITE_ALL
nopcall HMEM_FREE
mov AX,1
@@R_FAULT:
ret
endfunc ; }

View File

@ -0,0 +1 @@
backup_mseg dw 0 ; Main Memory Segment

View File

@ -394,53 +394,7 @@ include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/grcg_vline.asm
include libs/master.lib/gdc_outpw.asm
db 0
; =============== S U B R O U T I N E =======================================
sub_1340 proc far
xor ax, ax
cmp word_1DF84, ax
jnz short locret_1363
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_1363
mov word_1DF84, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_1363:
retf
sub_1340 endp
; =============== S U B R O U T I N E =======================================
sub_1364 proc far
mov ax, word_1DF84
test ax, ax
jz short locret_137F
push ax
push ax
xor ax, ax
mov word_1DF84, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_137F:
retf
sub_1364 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -11673,7 +11627,7 @@ sub_DAF0 endp
sub_DC38 proc near
push bp
mov bp, sp
call sub_1340
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
@ -11689,7 +11643,7 @@ sub_DC38 endp
sub_DC4B proc near
push bp
mov bp, sp
call sub_1364
call gaiji_restore
pop bp
retn
sub_DC4B endp
@ -41302,7 +41256,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_1DF84 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -321,53 +321,7 @@ loc_F66:
sub_DD4 endp ; sp-analysis failed
include libs/master.lib/grcg_setcolor.asm
; =============== S U B R O U T I N E =======================================
sub_FA2 proc far
xor ax, ax
cmp word_D39A, ax
jnz short locret_FC5
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_FC5
mov word_D39A, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_FC5:
retf
sub_FA2 endp
; =============== S U B R O U T I N E =======================================
sub_FC6 proc far
mov ax, word_D39A
test ax, ax
jz short locret_FE1
push ax
push ax
xor ax, ax
mov word_D39A, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_FE1:
retf
sub_FC6 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -7321,7 +7275,7 @@ _envp = dword ptr 0Ch
cmp byte ptr es:[bx+0Bh], 7Fh ; ''
jnz loc_B1FE
call sub_B756
call sub_FA2
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
@ -7390,7 +7344,7 @@ loc_B1C6:
call sub_BC9E
mov PaletteTone, 0
call far ptr palette_show
call sub_FC6
call gaiji_restore
call sub_B616
push large 0
push ds
@ -9935,7 +9889,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_D39A dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -537,53 +537,7 @@ loc_F81:
sub_EAA endp
include libs/master.lib/grcg_setcolor.asm
; =============== S U B R O U T I N E =======================================
sub_FBC proc far
xor ax, ax
cmp word_D860, ax
jnz short locret_FDF
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_FDF
mov word_D860, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_FDF:
retf
sub_FBC endp
; =============== S U B R O U T I N E =======================================
sub_FE0 proc far
mov ax, word_D860
test ax, ax
jz short locret_FFB
push ax
push ax
xor ax, ax
mov word_D860, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_FFB:
retf
sub_FE0 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -4532,7 +4486,7 @@ sub_9FAF proc far
push 20Fh
call sub_B203
add sp, 8
call sub_FE0
call gaiji_restore
call super_free
call sub_B019
les bx, dword_F3DC
@ -4601,7 +4555,7 @@ sub_A027 proc far
push word_F186
push word_F184
call graph_pi_free
call sub_FE0
call gaiji_restore
call super_free
call sub_B019
push 0
@ -4643,7 +4597,7 @@ sub_A0C6 proc far
push 20Fh
call sub_B203
add sp, 8
call sub_FE0
call gaiji_restore
call super_free
call sub_B019
les bx, dword_F3DC
@ -5787,7 +5741,7 @@ loc_A9EE:
; ---------------------------------------------------------------------------
loc_A9F3:
call sub_FBC
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
@ -5893,7 +5847,7 @@ loc_AAF0:
call text_clear
call graph_clear
call sub_AB28
call sub_FE0
call gaiji_restore
_main endp ; sp-analysis failed
mov al, [bp-1]
@ -10216,7 +10170,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_D860 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -625,55 +625,7 @@ loc_11AF:
retf 0Ch
sub_1120 endp
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
sub_11B6 proc far
xor ax, ax
cmp word_1D816, ax
jnz short locret_11D9
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_11D9
mov word_1D816, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_11D9:
retf
sub_11B6 endp
; =============== S U B R O U T I N E =======================================
sub_11DA proc far
mov ax, word_1D816
test ax, ax
jz short locret_11F5
push ax
push ax
xor ax, ax
mov word_1D816, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_11F5:
retf
sub_11DA endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -4283,7 +4235,7 @@ _envp = dword ptr 0Ch
call sub_E922
loc_970F:
call sub_11B6
call gaiji_backup
push ds
push offset aGameft_bft ; "GAMEFT.bft"
call gaiji_entry_bfnt
@ -7000,7 +6952,7 @@ _arg0 = dword ptr 6
call super_free
call graph_hide
call text_clear
call sub_11DA
call gaiji_restore
push 0
call sub_EF1C
push 1
@ -42579,7 +42531,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_1D816 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -62,53 +62,7 @@ include libs/master.lib/grcg_byteboxfill_x.asm
include libs/master.lib/grcg_setcolor.asm
include libs/master.lib/gdc_outpw.asm
db 0
; =============== S U B R O U T I N E =======================================
sub_C72 proc far
xor ax, ax
cmp word_E94A, ax
jnz short locret_C95
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_C95
mov word_E94A, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_C95:
retf
sub_C72 endp
; =============== S U B R O U T I N E =======================================
sub_C96 proc far
mov ax, word_E94A
test ax, ax
jz short locret_CB1
push ax
push ax
xor ax, ax
mov word_E94A, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_CB1:
retf
sub_C96 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_read.asm
include libs/master.lib/gaiji_write.asm
@ -4743,7 +4697,7 @@ _envp = dword ptr 0Ch
call sub_C80C
loc_9DAD:
call sub_C72
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
@ -4759,7 +4713,7 @@ loc_9DAD:
jz short loc_9E04
call sub_B7D2
call text_clear
call sub_C96
call gaiji_restore
call sub_C990
push large 0
push ds
@ -4874,7 +4828,7 @@ loc_9EF1:
call sub_A174
call sub_990C
call sub_9A2C
call sub_C96
call gaiji_restore
loc_9F1E:
call sub_D16F
@ -4914,7 +4868,7 @@ loc_9F58:
loc_9F69:
call text_clear
call sub_C96
call gaiji_restore
call sub_C990
push large 0
push ds
@ -8345,7 +8299,7 @@ loc_B9DD:
loc_BA66:
call text_clear
call sub_C96
call gaiji_restore
call sub_C990
push large 0
push ds
@ -12182,7 +12136,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_E94A dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -331,54 +331,7 @@ sub_C6A endp
include libs/master.lib/grcg_pset.asm
include libs/master.lib/grcg_setcolor.asm
; =============== S U B R O U T I N E =======================================
sub_EF6 proc far
xor ax, ax
cmp word_DAA6, ax
jnz short locret_F19
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_F19
mov word_DAA6, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_F19:
retf
sub_EF6 endp
; =============== S U B R O U T I N E =======================================
sub_F1A proc far
; sub_9BDF+143P ...
mov ax, word_DAA6
test ax, ax
jz short locret_F35
push ax
push ax
xor ax, ax
mov word_DAA6, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_F35:
retf
sub_F1A endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putsa.asm
include libs/master.lib/gaiji_read.asm
@ -4515,7 +4468,7 @@ loc_9B4E:
add al, 46h ; 'F'
mov es:[bx+38h], al
call sub_9980
call sub_F1A
call gaiji_restore
push 100h
call sub_C403
call sub_BFC2
@ -4729,7 +4682,7 @@ loc_9D19:
cmp [bp+var_2], 10h
jl short loc_9D0A
call sub_9980
call sub_F1A
call gaiji_restore
push 100h
call sub_C403
call sub_BFC2
@ -4811,7 +4764,7 @@ loc_9DDF:
push 1
call palette_black_out
call sub_9980
call sub_F1A
call gaiji_restore
push 100h
call sub_C403
call sub_BFC2
@ -4910,7 +4863,7 @@ loc_9EA6:
cmp si, 10h
jl short loc_9E9A
call sub_9980
call sub_F1A
call gaiji_restore
push 100h
call sub_C403
call super_free
@ -5652,7 +5605,7 @@ loc_A452:
; ---------------------------------------------------------------------------
loc_A468:
call sub_EF6
call gaiji_backup
push ds
push offset aMikoft_bft ; "MIKOFT.bft"
call gaiji_entry_bfnt
@ -5720,7 +5673,7 @@ loc_A4FE:
cmp byte_D952, 0
jz short loc_A4D2
call sub_99C3
call sub_F1A
call gaiji_restore
call text_clear
call sub_BEB8
call sub_2B3C
@ -10834,7 +10787,7 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/edges[data].asm
include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
word_DAA6 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -342,53 +342,7 @@ include libs/master.lib/get_machine_at.asm
include libs/master.lib/get_machine_dosbox.asm
include libs/master.lib/check_machine_fmr.asm
include libs/master.lib/get_machine.asm
; =============== S U B R O U T I N E =======================================
sub_1A36 proc far
xor ax, ax
cmp word_216C4, ax
jnz short locret_1A59
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_1A59
mov word_216C4, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_1A59:
retf
sub_1A36 endp
; =============== S U B R O U T I N E =======================================
sub_1A5A proc far
mov ax, word_216C4
test ax, ax
jz short locret_1A75
push ax
push ax
xor ax, ax
mov word_216C4, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_1A75:
retf
sub_1A5A endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -4922,7 +4876,7 @@ _envp = dword ptr 0Ch
mov random_seed, eax
call sub_B488
call text_clear
call sub_1A36
call gaiji_backup
push ds
push offset aGameft_bft ; "GAMEFT.bft"
call gaiji_entry_bfnt
@ -13174,7 +13128,7 @@ loc_E813:
call super_free
call graph_hide
call text_clear
call sub_1A5A
call gaiji_restore
call sub_1361E
push large 0
push large [bp+_arg0] ; arg0
@ -24043,7 +23997,7 @@ include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
include libs/master.lib/get_machine_98[data].asm
include libs/master.lib/get_machine_at[data].asm
word_216C4 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -68,53 +68,7 @@ include libs/master.lib/get_machine_at.asm
include libs/master.lib/get_machine_dosbox.asm
include libs/master.lib/check_machine_fmr.asm
include libs/master.lib/get_machine.asm
; =============== S U B R O U T I N E =======================================
sub_EEE proc far
xor ax, ax
cmp word_E642, ax
jnz short locret_F11
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_F11
mov word_E642, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_F11:
retf
sub_EEE endp
; =============== S U B R O U T I N E =======================================
sub_F12 proc far
mov ax, word_E642
test ax, ax
jz short locret_F2D
push ax
push ax
xor ax, ax
mov word_E642, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_F2D:
retf
sub_F12 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_putca.asm
include libs/master.lib/gaiji_putsa.asm
@ -3866,7 +3820,7 @@ _arg0 = dword ptr 4
call sub_D8CE
call graph_hide
call text_clear
call sub_F12
call gaiji_restore
call sub_D3F4
push large 0
push large [bp+_arg0] ; arg0
@ -3934,7 +3888,7 @@ _envp = dword ptr 0Ch
push ds
push offset aMSzlEd_dat ; "Œ¶z½ed.dat"
call sub_D43C
call sub_EEE
call gaiji_backup
push ds
push offset aGameft_bft ; "GAMEFT.bft"
call gaiji_entry_bfnt
@ -10865,7 +10819,7 @@ include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
include libs/master.lib/get_machine_98[data].asm
include libs/master.lib/get_machine_at[data].asm
word_E642 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0

View File

@ -485,53 +485,7 @@ include libs/master.lib/get_machine_at.asm
include libs/master.lib/get_machine_dosbox.asm
include libs/master.lib/check_machine_fmr.asm
include libs/master.lib/get_machine.asm
; =============== S U B R O U T I N E =======================================
sub_1332 proc far
xor ax, ax
cmp word_F8A6, ax
jnz short locret_1355
mov ax, 200h
push ax
nop
call hmem_alloc
or ax, ax
jz short locret_1355
mov word_F8A6, ax
push ax
xor ax, ax
push ax
call gaiji_read_all
mov ax, 1
locret_1355:
retf
sub_1332 endp
; =============== S U B R O U T I N E =======================================
sub_1356 proc far
mov ax, word_F8A6
test ax, ax
jz short locret_1371
push ax
push ax
xor ax, ax
mov word_F8A6, ax
push ax
call gaiji_write_all
nop
call hmem_free
mov ax, 1
locret_1371:
retf
sub_1356 endp
include libs/master.lib/gaiji_backup.asm
include libs/master.lib/gaiji_entry_bfnt.asm
include libs/master.lib/gaiji_read.asm
include libs/master.lib/gaiji_write.asm
@ -4412,7 +4366,7 @@ sub_A8F1 proc near
mov byte ptr es:[bx+3Eh], 0
call sub_CCC8
call sub_A7F0
call sub_1356
call gaiji_restore
push 20Ah
call sub_DC74
call sub_E0AC
@ -4464,7 +4418,7 @@ sub_A96C proc near
mov byte ptr es:[bx+3Eh], 0
call sub_CCC8
call sub_A7F0
call sub_1356
call gaiji_restore
push 20Ah
call sub_DC74
call sub_E0AC
@ -4553,7 +4507,7 @@ loc_AA6E:
call graph_pi_free
call sub_CCC8
call sub_A7F0
call sub_1356
call gaiji_restore
call sub_E0AC
push large 0
push ds
@ -5578,7 +5532,7 @@ _envp = dword ptr 0Ch
call sub_A3B2
loc_B3AB:
call sub_1332
call gaiji_backup
push ds
push offset aGameft_bft ; "GAMEFT.bft"
call gaiji_entry_bfnt
@ -5670,7 +5624,7 @@ loc_B47B:
jz short loc_B43A
call sub_CCC8
call sub_A873
call sub_1356
call gaiji_restore
call text_clear
call sub_DDB1
call sub_2FBE
@ -12334,7 +12288,7 @@ include libs/master.lib/fil[data].asm
include libs/master.lib/dos_ropen[data].asm
include libs/master.lib/get_machine_98[data].asm
include libs/master.lib/get_machine_at[data].asm
word_F8A6 dw 0
include libs/master.lib/gaiji_backup[data].asm
include libs/master.lib/gaiji_entry_bfnt[data].asm
include libs/master.lib/grp[data].asm
db 0