From fa39c23fad07747cfbc753c06de8072d0e3f6584 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 12 Jan 2017 19:54:26 +0100 Subject: [PATCH] [Reverse-engineering] [th03] CDG loading --- ReC98.inc | 1 + th03/formats/cdg.inc | 33 +++ th03/formats/cdg[bss].asm | 7 + th03/formats/cdg[data].asm | 3 + th03/formats/cdg_load.asm | 292 +++++++++++++++++++ th03_mainl.asm | 562 +++---------------------------------- th03_op.asm | 477 ++----------------------------- 7 files changed, 387 insertions(+), 988 deletions(-) create mode 100644 th03/formats/cdg.inc create mode 100644 th03/formats/cdg[bss].asm create mode 100644 th03/formats/cdg[data].asm create mode 100644 th03/formats/cdg_load.asm diff --git a/ReC98.inc b/ReC98.inc index c2c423e2..da5072f1 100644 --- a/ReC98.inc +++ b/ReC98.inc @@ -26,6 +26,7 @@ include libs/master.lib/clip.inc include libs/master.lib/macros.inc include libs/kaja/kaja.inc include th02/formats/pi_slots.inc +include th03/formats/cdg.inc nopcall macro func if LDATA diff --git a/th03/formats/cdg.inc b/th03/formats/cdg.inc new file mode 100644 index 00000000..b3459750 --- /dev/null +++ b/th03/formats/cdg.inc @@ -0,0 +1,33 @@ +; CDG slot structure. + +CDGSlot struc + ; Size of a single bitplane. + bitplane_size dw ? + + ; Only used by custom functions that apply effects on the image. The core + ; CDG functions mainly use the two pre-calculated values + ; [vram_byte_at_bottom_left] and [width_divided_by_32] instead. + pixel_width dw ? + pixel_height dw ? + + ; (640 / 8) * (pixel_height - 1) + vram_byte_at_bottom_left dw ? + + ; Divided by 8 because of 1bpp planar, divided by 4 because ZUN tends to + ; blit 4 bytes at a time, using the REP MOVSD instruction with this value. + width_divided_by_32 dw ? + + ; Number of images in this file. + num_images db ? + + ; Alpha flag for all images in this file. Unused in TH03, where all files + ; are assumed to have an alpha plane. + ; • 0 = no alpha (4 planes per image) + ; • 1 = separate 1bpp alpha plane (5 planes per image) + ; • 2 = alpha-only (1 plane per image) + alpha db ? + + ; Memory segments of the loaded data. + sgm_alpha dw ? + sgm_colors dw ? +CDGSlot ends diff --git a/th03/formats/cdg[bss].asm b/th03/formats/cdg[bss].asm new file mode 100644 index 00000000..9cb25a59 --- /dev/null +++ b/th03/formats/cdg[bss].asm @@ -0,0 +1,7 @@ +; Global CDG data. + +CDG_SLOT_COUNT = 32 + +; CDGHeader cdg_slots[CDG_SLOT_COUNT] +public _cdg_slots +_cdg_slots CDGSlot CDG_SLOT_COUNT dup() diff --git a/th03/formats/cdg[data].asm b/th03/formats/cdg[data].asm new file mode 100644 index 00000000..4269fd67 --- /dev/null +++ b/th03/formats/cdg[data].asm @@ -0,0 +1,3 @@ +; Won't load the alpha plane of the next CDG file if nonzero. +cdg_noalpha db ? + align 2 diff --git a/th03/formats/cdg_load.asm b/th03/formats/cdg_load.asm new file mode 100644 index 00000000..218ec582 --- /dev/null +++ b/th03/formats/cdg_load.asm @@ -0,0 +1,292 @@ +; TH03-specific note: All CDG images loaded by this game are assumed to have +; an alpha plane. + +; Loads the [n]th image of the CDG file [fn] into [slot]. + +; void pascal cdg_load_single_forcealpha(int slot, const char *fn, int n) +_cdg_load_single_forcealpha proc far + +@@image_size = dword ptr -4 +@@n = word ptr 6 +@@fn = dword ptr 8 +@@slot = word ptr 12 + + enter 4, 0 + push si + push di + mov di, [bp+@@slot] + push di + nopcall _cdg_free + mov ax, di + shl ax, 4 + add ax, offset _cdg_slots + mov si, ax + pushd [bp+@@fn] + call file_ropen + push ds + push si + push size CDGSlot + call file_read + mov ax, [si+CDGSlot.bitplane_size] + imul ax, 5 + movzx eax, ax + mov [bp+@@image_size], eax + movsx eax, [bp+@@n] + imul eax, [bp+@@image_size] + push eax + push 1 + call file_seek + push [si+CDGSlot.bitplane_size] + call hmem_allocbyte + mov [si+CDGSlot.sgm_alpha], ax + push [si+CDGSlot.sgm_alpha] + push 0 + push [si+CDGSlot.bitplane_size] + call file_read + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call hmem_allocbyte + mov [si+CDGSlot.sgm_colors], ax + push [si+CDGSlot.sgm_colors] + push 0 + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call file_read + call file_close + pop di + pop si + leave + retf 8 +_cdg_load_single_forcealpha endp + + +; Loads the [n]th image of the CDG file [fn] into [slot], skipping the alpha +; plane. + +; void pascal cdg_load_single_noalpha(int slot, const char *fn, int n) +_cdg_load_single_noalpha proc far + +@@image_size = dword ptr -4 +@@n = word ptr 6 +@@fn = dword ptr 8 +@@slot = word ptr 12 + + enter 4, 0 + push si + push di + mov di, [bp+@@slot] + push di + nopcall _cdg_free + mov ax, di + shl ax, 4 + add ax, offset _cdg_slots + mov si, ax + pushd [bp+@@fn] + call file_ropen + push ds + push si + push size CDGSlot + call file_read + mov ax, [si+CDGSlot.bitplane_size] + imul ax, 5 + movzx eax, ax + mov [bp+@@image_size], eax + movsx eax, [bp+@@n] + imul eax, [bp+@@image_size] + push eax + push 1 + call file_seek + movzx eax, [si+CDGSlot.bitplane_size] + push eax + push 1 + call file_seek + mov [si+CDGSlot.sgm_alpha], 0 + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call hmem_allocbyte + mov [si+CDGSlot.sgm_colors], ax + push [si+CDGSlot.sgm_colors] + push 0 + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call file_read + call file_close + pop di + pop si + leave + retf 8 +_cdg_load_single_noalpha endp + + +; Loads all images of the CDG file [fn], starting at [slot_first] and +; incrementing the slot number for every further image. + +; void pascal cdg_load_all(int slot_first, const char *fn); +_cdg_load_all proc far + +@@i = word ptr -2 +@@fn = dword ptr 6 +@@slot_first = word ptr 10 + + enter 2, 0 + push si + push di + pushd [bp+@@fn] + call file_ropen + push [bp+@@slot_first] + nopcall _cdg_free + mov ax, [bp+@@slot_first] + shl ax, 4 + add ax, offset _cdg_slots + mov si, ax + push ds + push ax + push size CDGSlot + call file_read + mov di, si + mov [bp+@@i], 1 + jmp short @@free_loop + +@@free: + mov ax, [bp+@@slot_first] + add ax, [bp+@@i] + push ax + nopcall _cdg_free + inc [bp+@@i] + +@@free_loop: + mov al, [di+CDGSlot.num_images] + mov ah, 0 + cmp ax, [bp+@@i] + jg short @@free + mov [bp+@@i], 0 + jmp short @@load_loop + +@@copy_header: + mov ax, [di+CDGSlot.bitplane_size] + mov [si+CDGSlot.bitplane_size], ax + mov ax, [di+CDGSlot.pixel_width] + mov [si+CDGSlot.pixel_width], ax + mov ax, [di+CDGSlot.pixel_height] + mov [si+CDGSlot.pixel_height], ax + mov ax, [di+CDGSlot.vram_byte_at_bottom_left] + mov [si+CDGSlot.vram_byte_at_bottom_left], ax + mov ax, [di+CDGSlot.width_divided_by_32] + mov [si+CDGSlot.width_divided_by_32], ax + mov al, [di+CDGSlot.num_images] + mov [si+CDGSlot.num_images], al + mov [si+CDGSlot.alpha], 0 + cmp cdg_noalpha, 0 + jnz short @@noalpha + push [si+CDGSlot.bitplane_size] + call hmem_allocbyte + mov [si+CDGSlot.sgm_alpha], ax + push [si+CDGSlot.sgm_alpha] + push 0 + push [si+CDGSlot.bitplane_size] + call file_read + jmp short @@alpha + +@@noalpha: + mov [si+CDGSlot.sgm_alpha], 0 + movzx eax, [si+CDGSlot.bitplane_size] + push eax + push 1 + call file_seek + +@@alpha: + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call hmem_allocbyte + mov [si+CDGSlot.sgm_colors], ax + push [si+CDGSlot.sgm_colors] + push 0 + mov ax, [si+CDGSlot.bitplane_size] + shl ax, 2 + push ax + call file_read + inc [bp+@@i] + add si, size CDGSlot + +@@load_loop: + mov al, [di+CDGSlot.num_images] + mov ah, 0 + cmp ax, [bp+@@i] + jg @@copy_header + call file_close + pop di + pop si + leave + retf 6 +_cdg_load_all endp + + +; Loads all images of the CDG file [fn], disregarding their alpha planes, +; starting at [slot_first] and incrementing the slot number for every further +; image. + +; void pascal cdg_load_all_noalpha(int slot_first, const char *fn); +_cdg_load_all_noalpha proc far + +@@fn = dword ptr 6 +@@slot_first = word ptr 10 + + push bp + mov bp, sp + mov cdg_noalpha, 1 + push [bp+@@slot_first] + pushd [bp+@@fn] + call _cdg_load_all + mov cdg_noalpha, 0 + pop bp + retf 6 +_cdg_load_all_noalpha endp + + +; Frees the CDG image in the given [slot]. + +; void cdg_free(int slot); +_cdg_free proc far + +@@slot = word ptr 6 + + push bp + mov bp, sp + push si + push di + mov ax, [bp+@@slot] + shl ax, 4 + add ax, offset _cdg_slots + mov di, ax + xor si, si + jmp short @@sgm_loop + +@@free: + mov bx, si + add bx, bx + cmp word ptr [bx+di+0Ch], 0 + jz short @@next_sgm + mov bx, si + add bx, bx + push word ptr [bx+di+0Ch] + call hmem_free + mov bx, si + add bx, bx + mov word ptr [bx+di+0Ch], 0 + +@@next_sgm: + inc si + +@@sgm_loop: + cmp si, 2 + jl short @@free + pop di + pop si + pop bp + retf 2 +_cdg_free endp diff --git a/th03_mainl.asm b/th03_mainl.asm index 82650548..a146a2f5 100644 --- a/th03_mainl.asm +++ b/th03_mainl.asm @@ -180,15 +180,8 @@ var_1 = byte ptr -1 push offset aLogo0_rgb ; "logo0.rgb" call palette_entry_rgb call far ptr palette_show - push 0 - push ds - push offset aLogo_cd2 ; "logo.cd2" - call sub_D114 - push 5 - push ds - push offset aLogo5_cdg ; "logo5.cdg" - push 0 - call sub_CF1E + call _cdg_load_all_noalpha pascal, 0, ds, offset aLogo_cd2 + call _cdg_load_single_forcealpha pascal, 5, ds, offset aLogo5_cdg, 0 les bx, dword_105DA cmp byte ptr es:[bx+17h], 0 jnz short loc_965E @@ -260,7 +253,7 @@ loc_96B7: mov ah, 0 and ax, 1 push ax - call sub_CFA8 + call _cdg_load_single_noalpha mov al, [bp+var_1] mov ah, 0 cwd @@ -338,12 +331,11 @@ sub_9776 proc near ; --------------------------------------------------------------------------- loc_977E: - push si - call sub_D130 + call _cdg_free pascal, si inc si loc_9785: - cmp si, 20h ; ' ' + cmp si, CDG_SLOT_COUNT jl short loc_977E pop si pop bp @@ -546,7 +538,7 @@ var_1 = byte ptr -1 mov ah, 0 and ax, 1 push ax - call sub_CF1E + call _cdg_load_single_forcealpha les bx, dword_105DA mov al, es:[bx+0Dh] add al, 0FFh @@ -564,7 +556,7 @@ var_1 = byte ptr -1 mov ah, 0 and ax, 1 push ax - call sub_CF1E + call _cdg_load_single_forcealpha mov al, [bp+var_1] mov ah, 0 cwd @@ -621,7 +613,7 @@ loc_99D4: mov ah, 0 inc ax push ax - call sub_CF1E + call _cdg_load_single_forcealpha mov byte_F7E5, 0 loc_99F1: @@ -667,12 +659,9 @@ var_2 = word ptr -2 call sub_C9D4 loc_9A8E: - push 0 - call sub_D130 - push 1 - call sub_D130 - push 2 - call sub_D130 + call _cdg_free pascal, 0 + call _cdg_free pascal, 1 + call _cdg_free pascal, 2 les bx, dword_105DA mov al, es:[bx+0Ch] mov ah, 0 @@ -3151,16 +3140,11 @@ sub_AFAC proc near mov al, es:[bx+0Bh] mov bx, word_ED68 add [bx+3], al - push 0 - push ds - push bx - push 0 - call sub_CF1E + call _cdg_load_single_forcealpha pascal, 0, ds, bx, 0 push 1400138h push 0 call sub_C9D4 - push 0 - call sub_D130 + call _cdg_free pascal, 0 push ds push offset aRegi2_bft ; "regi2.bft" call super_entry_bfnt @@ -4352,10 +4336,7 @@ loc_B879: call pi_slot_palette_apply pascal, 0 call pi_slot_put pascal, large 0, 0 freePISlotLarge 0 - push 0 - push ds - push offset aConti_cd2 ; "conti.cd2" - call sub_D02E + call _cdg_load_all pascal, 0, ds, offset aConti_cd2 pop bp retn ; --------------------------------------------------------------------------- @@ -4404,12 +4385,9 @@ sub_B972 proc near var_1 = byte ptr -1 enter 2, 0 - push 0 - call sub_D130 - push 1 - call sub_D130 - push 2 - call sub_D130 + call _cdg_free pascal, 0 + call _cdg_free pascal, 1 + call _cdg_free pascal, 2 freePISlotLarge 0 les bx, dword_105DA mov al, es:[bx+0Ch] @@ -5841,66 +5819,18 @@ loc_C4D8: mov dx, 0A4h mov al, 1 out dx, al - push 0 - push ds - push offset aStf1_cdg ; "stf1.cdg" - push 0 - call sub_CFA8 - push 1 - push ds - push offset aStf11_cdg ; "stf11.cdg" - push 0 - call sub_CFA8 - push 2 - push ds - push offset aStf3_cdg ; "stf3.cdg" - push 0 - call sub_CF1E - push 3 - push ds - push offset aStf4_cdg ; "stf4.cdg" - push 0 - call sub_CF1E - push 4 - push ds - push offset aStf5_cdg ; "stf5.cdg" - push 0 - call sub_CFA8 - push 5 - push ds - push offset aStf6_cdg ; "stf6.cdg" - push 0 - call sub_CFA8 - push 6 - push ds - push offset aStf7_cdg ; "stf7.cdg" - push 0 - call sub_CFA8 - push 7 - push ds - push offset aStf8_cdg ; "stf8.cdg" - push 0 - call sub_CFA8 - push 8 - push ds - push offset aStf9_cdg ; "stf9.cdg" - push 0 - call sub_CFA8 - push 9 - push ds - push offset aStf10_cdg ; "stf10.cdg" - push 0 - call sub_CFA8 - push 0Ah - push ds - push offset aStf2_cdg ; "stf2.cdg" - push 0 - call sub_CFA8 - push 0Bh - push ds - push offset aStf12_cdg ; "stf12.cdg" - push 0 - call sub_CFA8 + call _cdg_load_single_noalpha pascal, 0, ds, offset aStf1_cdg, 0 + call _cdg_load_single_noalpha pascal, 1, ds, offset aStf11_cdg, 0 + call _cdg_load_single_forcealpha pascal, 2, ds, offset aStf3_cdg, 0 + call _cdg_load_single_forcealpha pascal, 3, ds, offset aStf4_cdg, 0 + call _cdg_load_single_noalpha pascal, 4, ds, offset aStf5_cdg, 0 + call _cdg_load_single_noalpha pascal, 5, ds, offset aStf6_cdg, 0 + call _cdg_load_single_noalpha pascal, 6, ds, offset aStf7_cdg, 0 + call _cdg_load_single_noalpha pascal, 7, ds, offset aStf8_cdg, 0 + call _cdg_load_single_noalpha pascal, 8, ds, offset aStf9_cdg, 0 + call _cdg_load_single_noalpha pascal, 9, ds, offset aStf10_cdg, 0 + call _cdg_load_single_noalpha pascal, 10, ds, offset aStf2_cdg, 0 + call _cdg_load_single_noalpha pascal, 11, ds, offset aStf12_cdg, 0 call sub_BB66 mov word_10BB2, 0 les bx, dword_105DA @@ -6030,12 +5960,11 @@ loc_C7CD: ; --------------------------------------------------------------------------- loc_C7D1: - push si - call sub_D130 + call _cdg_free pascal, si inc si loc_C7D8: - cmp si, 20h ; ' ' + cmp si, CDG_SLOT_COUNT jl short loc_C7D1 pop di pop si @@ -6355,302 +6284,7 @@ loc_CEF6: retf 4 sub_CEE0 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CF1E proc far - -var_4 = dword ptr -4 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 -arg_6 = word ptr 0Ch - - enter 4, 0 - push si - push di - mov di, [bp+arg_6] - push di - nopcall sub_D130 - mov ax, di - shl ax, 4 - add ax, 1D0Eh - mov si, ax - pushd [bp+arg_2] - call file_ropen - push ds - push si - push 10h - call file_read - mov ax, [si] - imul ax, 5 - movzx eax, ax - mov [bp+var_4], eax - movsx eax, [bp+arg_0] - imul eax, [bp+var_4] - push eax - push 1 - call file_seek - push word ptr [si] - call hmem_allocbyte - mov [si+0Ch], ax - push word ptr [si+0Ch] - push 0 - push word ptr [si] - call file_read - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - call file_close - pop di - pop si - leave - retf 8 -sub_CF1E endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_CFA8 proc far - -var_4 = dword ptr -4 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 -arg_6 = word ptr 0Ch - - enter 4, 0 - push si - push di - mov di, [bp+arg_6] - push di - nopcall sub_D130 - mov ax, di - shl ax, 4 - add ax, 1D0Eh - mov si, ax - pushd [bp+arg_2] - call file_ropen - push ds - push si - push 10h - call file_read - mov ax, [si] - imul ax, 5 - movzx eax, ax - mov [bp+var_4], eax - movsx eax, [bp+arg_0] - imul eax, [bp+var_4] - push eax - push 1 - call file_seek - movzx eax, word ptr [si] - push eax - push 1 - call file_seek - mov word ptr [si+0Ch], 0 - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - call file_close - pop di - pop si - leave - retf 8 -sub_CFA8 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_D02E proc far - -var_2 = word ptr -2 -arg_0 = dword ptr 6 -arg_4 = word ptr 0Ah - - enter 2, 0 - push si - push di - pushd [bp+arg_0] - call file_ropen - push [bp+arg_4] - nopcall sub_D130 - mov ax, [bp+arg_4] - shl ax, 4 - add ax, 1D0Eh - mov si, ax - push ds - push ax - push 10h - call file_read - mov di, si - mov [bp+var_2], 1 - jmp short loc_D071 -; --------------------------------------------------------------------------- - -loc_D062: - mov ax, [bp+arg_4] - add ax, [bp+var_2] - push ax - nopcall sub_D130 - inc [bp+var_2] - -loc_D071: - mov al, [di+0Ah] - mov ah, 0 - cmp ax, [bp+var_2] - jg short loc_D062 - mov [bp+var_2], 0 - jmp short loc_D0FD -; --------------------------------------------------------------------------- - -loc_D082: - mov ax, [di] - mov [si], ax - mov ax, [di+2] - mov [si+2], ax - mov ax, [di+4] - mov [si+4], ax - mov ax, [di+6] - mov [si+6], ax - mov ax, [di+8] - mov [si+8], ax - mov al, [di+0Ah] - mov [si+0Ah], al - mov byte ptr [si+0Bh], 0 - cmp byte_EC84, 0 - jnz short loc_D0C7 - push word ptr [si] - call hmem_allocbyte - mov [si+0Ch], ax - push word ptr [si+0Ch] - push 0 - push word ptr [si] - call file_read - jmp short loc_D0D9 -; --------------------------------------------------------------------------- - -loc_D0C7: - mov word ptr [si+0Ch], 0 - movzx eax, word ptr [si] - push eax - push 1 - call file_seek - -loc_D0D9: - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - inc [bp+var_2] - add si, 10h - -loc_D0FD: - mov al, [di+0Ah] - mov ah, 0 - cmp ax, [bp+var_2] - jg loc_D082 - call file_close - pop di - pop si - leave - retf 6 -sub_D02E endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_D114 proc far - -arg_0 = dword ptr 6 -arg_4 = word ptr 0Ah - - push bp - mov bp, sp - mov byte_EC84, 1 - push [bp+arg_4] - pushd [bp+arg_0] - call sub_D02E - mov byte_EC84, 0 - pop bp - retf 6 -sub_D114 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_D130 proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - mov ax, [bp+arg_0] - shl ax, 4 - add ax, 1D0Eh - mov di, ax - xor si, si - jmp short loc_D164 -; --------------------------------------------------------------------------- - -loc_D144: - mov bx, si - add bx, bx - cmp word ptr [bx+di+0Ch], 0 - jz short loc_D163 - mov bx, si - add bx, bx - push word ptr [bx+di+0Ch] - call hmem_free - mov bx, si - add bx, bx - mov word ptr [bx+di+0Ch], 0 - -loc_D163: - inc si - -loc_D164: - cmp si, 2 - jl short loc_D144 - pop di - pop si - pop bp - retf 2 -sub_D130 endp - +include th03/formats/cdg_load.asm ; =============== S U B R O U T I N E ======================================= @@ -7328,8 +6962,7 @@ _snd_active db 0 include libs/master.lib/respal_exist[data].asm include th03/snd/se_state[data].asm include th02/formats/pfopen[data].asm -byte_EC84 db 0 - db 0 +include th03/formats/cdg[data].asm include th03/snd/se_priority[data].asm db 30h ; 0 db 0 @@ -7758,134 +7391,7 @@ include th02/snd/snd[bss].asm include th02/snd/load[bss].asm include libs/master.lib/pfint21[bss].asm include th03/hardware/input[bss].asm - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; +include th03/formats/cdg[bss].asm include th02/formats/pi_slots[bss].asm include th03/formats/hfliplut[bss].asm dword_105C6 dd ? diff --git a/th03_op.asm b/th03_op.asm index 7383e034..d92e50f1 100644 --- a/th03_op.asm +++ b/th03_op.asm @@ -2170,12 +2170,11 @@ sub_AC06 proc far ; --------------------------------------------------------------------------- loc_AC0E: - push si - call sub_C69C + call _cdg_free pascal, si inc si loc_AC15: - cmp si, 20h ; ' ' + cmp si, CDG_SLOT_COUNT jl short loc_AC0E call super_free call text_clear @@ -3075,16 +3074,13 @@ loc_B39A: shl bx, 2 pushd dword ptr [bx+0A0Eh] push 0 - call sub_C48A + call _cdg_load_single_forcealpha inc si loc_B3B0: cmp si, 3 jl short loc_B39A - push 0Dh - push ds - push offset aSlex_cd2 ; "slex.cd2" - call sub_C680 + call _cdg_load_all_noalpha pascal, 13, ds, offset aSlex_cd2 pop si pop bp retn @@ -3098,21 +3094,9 @@ sub_B38D endp sub_B3C3 proc near push bp mov bp, sp - push 1 - push ds - push offset a99sl_cdg ; "99sl.cdg" - push 0 - call sub_C48A - push 0Bh - push ds - push offset aSlwin_cdg ; "slwin.cdg" - push 0 - call sub_C514 - push 0Ch - push ds - push offset aSlex_cdg ; "slex.cdg" - push 0 - call sub_C514 + call _cdg_load_single_forcealpha pascal, 1, ds, offset a99sl_cdg, 0 + call _cdg_load_single_noalpha pascal, 11, ds, offset aSlwin_cdg , 0 + call _cdg_load_single_noalpha pascal, 12, ds, offset aSlex_cdg, 0 pop bp retn sub_B3C3 endp @@ -3126,10 +3110,7 @@ sub_B3EF proc near push bp mov bp, sp push si - push 0 - pushd [off_E1FE] - push 0 - call sub_C48A + call _cdg_load_single_forcealpha pascal, 0, [off_E1FE], 0 mov si, 3 jmp short loc_B41C ; --------------------------------------------------------------------------- @@ -3141,7 +3122,7 @@ loc_B406: shl bx, 2 pushd dword ptr [bx+0A0Eh] push 0 - call sub_C48A + call _cdg_load_single_forcealpha inc si loc_B41C: @@ -3202,7 +3183,7 @@ loc_B4A6: shl bx, 2 pushd dword ptr [bx+0A0Eh] push 0 - call sub_C48A + call _cdg_load_single_forcealpha inc si loc_B4BC: @@ -3234,12 +3215,11 @@ sub_B4D7 proc near ; --------------------------------------------------------------------------- loc_B4DF: - push si - call sub_C69C + call _cdg_free pascal, si inc si loc_B4E6: - cmp si, 16h + cmp si, 22 jl short loc_B4DF call super_free pop si @@ -3895,7 +3875,7 @@ loc_B9CC: push 0 loc_B9DA: - call sub_C48A + call _cdg_load_single_forcealpha mov bx, 1 sub bx, si cmp byte ptr [bx+246Ah], 0 @@ -3950,7 +3930,7 @@ loc_BA53: push 1 loc_BA61: - call sub_C48A + call _cdg_load_single_forcealpha mov bx, 1 sub bx, si cmp byte ptr [bx+246Ah], 0 @@ -4744,302 +4724,7 @@ loc_C435: retf sub_C421 endp - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C48A proc far - -var_4 = dword ptr -4 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 -arg_6 = word ptr 0Ch - - enter 4, 0 - push si - push di - mov di, [bp+arg_6] - push di - nopcall sub_C69C - mov ax, di - shl ax, 4 - add ax, 1AA8h - mov si, ax - pushd [bp+arg_2] - call file_ropen - push ds - push si - push 10h - call file_read - mov ax, [si] - imul ax, 5 - movzx eax, ax - mov [bp+var_4], eax - movsx eax, [bp+arg_0] - imul eax, [bp+var_4] - push eax - push 1 - call file_seek - push word ptr [si] - call hmem_allocbyte - mov [si+0Ch], ax - push word ptr [si+0Ch] - push 0 - push word ptr [si] - call file_read - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - call file_close - pop di - pop si - leave - retf 8 -sub_C48A endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C514 proc far - -var_4 = dword ptr -4 -arg_0 = word ptr 6 -arg_2 = dword ptr 8 -arg_6 = word ptr 0Ch - - enter 4, 0 - push si - push di - mov di, [bp+arg_6] - push di - nopcall sub_C69C - mov ax, di - shl ax, 4 - add ax, 1AA8h - mov si, ax - pushd [bp+arg_2] - call file_ropen - push ds - push si - push 10h - call file_read - mov ax, [si] - imul ax, 5 - movzx eax, ax - mov [bp+var_4], eax - movsx eax, [bp+arg_0] - imul eax, [bp+var_4] - push eax - push 1 - call file_seek - movzx eax, word ptr [si] - push eax - push 1 - call file_seek - mov word ptr [si+0Ch], 0 - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - call file_close - pop di - pop si - leave - retf 8 -sub_C514 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C59A proc far - -var_2 = word ptr -2 -arg_0 = dword ptr 6 -arg_4 = word ptr 0Ah - - enter 2, 0 - push si - push di - pushd [bp+arg_0] - call file_ropen - push [bp+arg_4] - nopcall sub_C69C - mov ax, [bp+arg_4] - shl ax, 4 - add ax, 1AA8h - mov si, ax - push ds - push ax - push 10h - call file_read - mov di, si - mov [bp+var_2], 1 - jmp short loc_C5DD -; --------------------------------------------------------------------------- - -loc_C5CE: - mov ax, [bp+arg_4] - add ax, [bp+var_2] - push ax - nopcall sub_C69C - inc [bp+var_2] - -loc_C5DD: - mov al, [di+0Ah] - mov ah, 0 - cmp ax, [bp+var_2] - jg short loc_C5CE - mov [bp+var_2], 0 - jmp short loc_C669 -; --------------------------------------------------------------------------- - -loc_C5EE: - mov ax, [di] - mov [si], ax - mov ax, [di+2] - mov [si+2], ax - mov ax, [di+4] - mov [si+4], ax - mov ax, [di+6] - mov [si+6], ax - mov ax, [di+8] - mov [si+8], ax - mov al, [di+0Ah] - mov [si+0Ah], al - mov byte ptr [si+0Bh], 0 - cmp byte_DDE0, 0 - jnz short loc_C633 - push word ptr [si] - call hmem_allocbyte - mov [si+0Ch], ax - push word ptr [si+0Ch] - push 0 - push word ptr [si] - call file_read - jmp short loc_C645 -; --------------------------------------------------------------------------- - -loc_C633: - mov word ptr [si+0Ch], 0 - movzx eax, word ptr [si] - push eax - push 1 - call file_seek - -loc_C645: - mov ax, [si] - shl ax, 2 - push ax - call hmem_allocbyte - mov [si+0Eh], ax - push word ptr [si+0Eh] - push 0 - mov ax, [si] - shl ax, 2 - push ax - call file_read - inc [bp+var_2] - add si, 10h - -loc_C669: - mov al, [di+0Ah] - mov ah, 0 - cmp ax, [bp+var_2] - jg loc_C5EE - call file_close - pop di - pop si - leave - retf 6 -sub_C59A endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C680 proc far - -arg_0 = dword ptr 6 -arg_4 = word ptr 0Ah - - push bp - mov bp, sp - mov byte_DDE0, 1 - push [bp+arg_4] - pushd [bp+arg_0] - call sub_C59A - mov byte_DDE0, 0 - pop bp - retf 6 -sub_C680 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_C69C proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - mov ax, [bp+arg_0] - shl ax, 4 - add ax, 1AA8h - mov di, ax - xor si, si - jmp short loc_C6D0 -; --------------------------------------------------------------------------- - -loc_C6B0: - mov bx, si - add bx, bx - cmp word ptr [bx+di+0Ch], 0 - jz short loc_C6CF - mov bx, si - add bx, bx - push word ptr [bx+di+0Ch] - call hmem_free - mov bx, si - add bx, bx - mov word ptr [bx+di+0Ch], 0 - -loc_C6CF: - inc si - -loc_C6D0: - cmp si, 2 - jl short loc_C6B0 - pop di - pop si - pop bp - retf 2 -sub_C69C endp - +include th03/formats/cdg_load.asm ; =============== S U B R O U T I N E ======================================= @@ -5548,8 +5233,7 @@ _snd_active db 0 include libs/master.lib/respal_exist[data].asm include libs/master.lib/draw_trapezoid[data].asm include th02/formats/pfopen[data].asm -byte_DDE0 db 0 - db 0 +include th03/formats/cdg[data].asm dd aNo_1B@cVOul ; "NO.1 @͎z " dd aNo_2B@B@Select ; "NO.2 @ @ Selection " dd aNo_3Umx ; "NO.3 dk " @@ -5730,134 +5414,7 @@ include th02/snd/snd[bss].asm include th02/snd/load[bss].asm include libs/master.lib/pfint21[bss].asm include th03/hardware/input[bss].asm - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; - dd ? ; +include th03/formats/cdg[bss].asm include th02/formats/pi_slots[bss].asm include th03/formats/hfliplut[bss].asm include th02/music/polygons[bss].asm