From 22bf71d17099678f0f9e7cd01719afbd90a76185 Mon Sep 17 00:00:00 2001 From: wintiger0222 <0xodbs02@naver.com> Date: Wed, 20 Nov 2019 04:08:50 +0000 Subject: [PATCH] [Reduction] [th03/th04/th05] game_init_main --- th02/initexit.h | 2 ++ th02/initmain.asm | 49 +++++++++++++++++++++++++++++++++++++++++++++++ th03_main.asm | 37 ++--------------------------------- th03_mainl.asm | 37 ++--------------------------------- th04_main.asm | 41 ++------------------------------------- th04_maine.asm | 41 ++------------------------------------- th05_main.asm | 39 ++----------------------------------- th05_maine.asm | 41 ++------------------------------------- 8 files changed, 63 insertions(+), 224 deletions(-) create mode 100644 th02/initmain.asm diff --git a/th02/initexit.h b/th02/initexit.h index ffeedee9..69efb312 100644 --- a/th02/initexit.h +++ b/th02/initexit.h @@ -1,7 +1,9 @@ #if GAME >= 3 int game_init_op(const unsigned char *pf_fn); +int pascal game_init_main(const unsigned char *pf_fn); #else int game_init_op(void); +int pascal game_init_main(void); #endif void game_exit(void); diff --git a/th02/initmain.asm b/th02/initmain.asm new file mode 100644 index 00000000..5ffaf043 --- /dev/null +++ b/th02/initmain.asm @@ -0,0 +1,49 @@ +; (only covering TH03 and above) +public GAME_INIT_MAIN +game_init_main proc far + +@@pf_fn = dword ptr 6 + +if GAME ge 4 +PARAS equ <_mem_assign_paras> +else +PARAS = MEM_ASSIGN_PARAS_MAIN +endif + + push bp + mov bp, sp + call mem_assign_dos pascal, PARAS + or ax, ax + jz short @@assign_success + mov ax, 1 + pop bp +if GAME ge 3 + retf 4 +else + retf +endif +; --------------------------------------------------------------------------- + +@@assign_success: +if GAME ge 4 + mov bbufsiz, 1000h +endif +if GAME le 4 + nopcall vram_planes_set +endif + call vsync_start + call egc_start + call graph_400line + call js_start + call pfstart pascal, large [bp+@@pf_fn] +if GAME ge 4 + call bgm_init pascal, 2048 +endif + xor ax, ax + pop bp +if GAME ge 3 + retf 4 +else + retf +endif +game_init_main endp diff --git a/th03_main.asm b/th03_main.asm index cf4e532f..95b364d5 100644 --- a/th03_main.asm +++ b/th03_main.asm @@ -204,9 +204,7 @@ _envp = dword ptr 0Ch push bp mov bp, sp push si - push ds - push offset aCOul ; "–²Žž‹ó2.dat" - call sub_ECD0 + call game_init_main pascal, ds, offset aCOul call sub_A346 or ax, ax jz short loc_9775 @@ -9247,38 +9245,7 @@ include th03/hardware/input_sense.asm nop include th02/snd/se.asm include th02/snd/kajaint.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_ECD0 proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, MEM_ASSIGN_PARAS_MAIN - or ax, ax - jz short loc_ECE6 - mov ax, 1 - pop bp - retf 4 -; --------------------------------------------------------------------------- - -loc_ECE6: - nopcall vram_planes_set - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - xor ax, ax - pop bp - retf 4 -sub_ECD0 endp - +include th02/initmain.asm include th02/formats/pi_slot_load.asm include th03/hardware/input_modes.asm include th03/hardware/input_wait.asm diff --git a/th03_mainl.asm b/th03_mainl.asm index a151ac95..f3545adf 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -932,9 +932,7 @@ _envp = dword ptr 0Ch call sub_95F3 or ax, ax jz locret_9F8B - push ds - push offset aCOul ; "–²Žž‹ó1.dat" - call sub_CEE0 + call game_init_main pascal, ds, offset aCOul call respal_exist mov _snd_midi_active, 0 les bx, _yumeconfig @@ -5632,38 +5630,7 @@ include th02/formats/pi_slot_put.asm include th03/formats/pi_slot_put_interlace.asm include th02/snd/se.asm include th02/snd/kajaint.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CEE0 proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, MEM_ASSIGN_PARAS_MAINL - or ax, ax - jz short loc_CEF6 - mov ax, 1 - pop bp - retf 4 -; --------------------------------------------------------------------------- - -loc_CEF6: - nopcall vram_planes_set - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - xor ax, ax - pop bp - retf 4 -sub_CEE0 endp - +include th02/initmain.asm include th03/formats/cdg_load.asm ; =============== S U B R O U T I N E ======================================= diff --git a/th04_main.asm b/th04_main.asm index a77d9cd0..86ec1ca3 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -293,9 +293,7 @@ _envp = dword ptr 0Ch or ax, ax jz short loc_AB86 mov _mem_assign_paras, MEM_ASSIGN_PARAS_MAIN - push ds - push offset aUmx ; "“Œ•ûŒ¶‘z.‹½" - call sub_13666 + call game_init_main pascal, ds, offset aUmx les bx, _humaconfig mov eax, es:[bx+14h] mov random_seed, eax @@ -15246,42 +15244,7 @@ include th04/snd/detmodes.asm include th04/snd/load.asm include th04/formats/cdg_put.asm include th02/exit.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_13666 proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, _mem_assign_paras - or ax, ax - jz short loc_1367D - mov ax, 1 - pop bp - retf 4 -; --------------------------------------------------------------------------- - -loc_1367D: - mov bbufsiz, 1000h - nopcall vram_planes_set - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - push 800h - call bgm_init - xor ax, ax - pop bp - retf 4 -sub_13666 endp - -; --------------------------------------------------------------------------- +include th02/initmain.asm db 0 include th04/formats/cdg_put_noalpha.asm diff --git a/th04_maine.asm b/th04_maine.asm index db72c1f3..4f51241f 100644 --- a/th04_maine.asm +++ b/th04_maine.asm @@ -260,9 +260,7 @@ _envp = dword ptr 0Ch les bx, [bp+var_4] mov es:[bx+4], al mov _mem_assign_paras, MEM_ASSIGN_PARAS_MAINE - push ds - push offset aMSzlEd_dat ; "Œ¶‘z‹½ed.dat" - call sub_D43C + call game_init_main pascal, ds, offset aMSzlEd_dat call gaiji_backup push ds push offset aGameft_bft ; "GAMEFT.bft" @@ -5349,42 +5347,7 @@ loc_D350: include th04/formats/cdg_put.asm include th02/exit.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_D43C proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, _mem_assign_paras - or ax, ax - jz short loc_D453 - mov ax, 1 - pop bp - retf 4 -; --------------------------------------------------------------------------- - -loc_D453: - mov bbufsiz, 1000h - nopcall vram_planes_set - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - push 800h - call bgm_init - xor ax, ax - pop bp - retf 4 -sub_D43C endp - -; --------------------------------------------------------------------------- +include th02/initmain.asm db 0 include th04/hardware/input_sense.asm include th04/snd/se.asm diff --git a/th05_main.asm b/th05_main.asm index b0b95a2e..7a72c563 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -339,9 +339,7 @@ _envp = dword ptr 0Ch or ax, ax jz short loc_AEA4 mov _mem_assign_paras, MEM_ASSIGN_PARAS_MAIN - push ds - push offset aKAIKIDAN2_DAT - call sub_14F86 + call game_init_main pascal, ds, offset aKAIKIDAN2_DAT les bx, _ksoconfig mov eax, es:[bx+28h] mov random_seed, eax @@ -14148,40 +14146,7 @@ include th04/math/vector1_at.asm include th04/math/vector2_at.asm include th05/snd/load.asm include th05/snd/kajaint.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_14F86 proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, _mem_assign_paras - or ax, ax - jz short loc_14F9D - mov ax, 1 - pop bp - retf 4 -; --------------------------------------------------------------------------- - -loc_14F9D: - mov bbufsiz, 1000h - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - push 800h - call bgm_init - xor ax, ax - pop bp - retf 4 -sub_14F86 endp - +include th02/initmain.asm include th04/hardware/input_sense.asm include th05/hardware/input_held.asm include th05/hardware/input_wait.asm diff --git a/th05_maine.asm b/th05_maine.asm index d480a390..7efe8946 100644 --- a/th05_maine.asm +++ b/th05_maine.asm @@ -345,9 +345,7 @@ _envp = dword ptr 0Ch or ax, ax jz loc_A693 mov _mem_assign_paras, MEM_ASSIGN_PARAS_MAINE - push ds - push offset aKaikidan1_dat - call sub_F0B4 + call game_init_main pascal, ds, offset aKaikidan1_dat les bx, _ksoconfig mov al, es:[bx+12h] mov ah, 0 @@ -8680,42 +8678,7 @@ include th05/formats/pi_slot_load.asm include th05/formats/pi_slot_put.asm include th05/formats/pi_slot_palette_apply.asm include th05/formats/pi_slot_free.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F0B4 proc far - -arg_0 = dword ptr 6 - - push bp - mov bp, sp - call mem_assign_dos pascal, _mem_assign_paras - or ax, ax - jz short loc_F0CB - mov ax, 1 - pop bp - -locret_F0C8: - retf 4 -; --------------------------------------------------------------------------- - -loc_F0CB: - mov bbufsiz, 1000h - call vsync_start - call egc_start - call graph_400line - call js_start - pushd [bp+arg_0] - call pfstart - push 800h - call bgm_init - xor ax, ax - pop bp - retf 4 -sub_F0B4 endp - +include th02/initmain.asm include th04/hardware/input_sense.asm include th05/hardware/input_held.asm include th05/hardware/input_wait.asm