[Reverse-engineering] [th04] cdg_put_plane_roll

Used for the falling blue stars in TH04 Stage 5 --Nmlgc
This commit is contained in:
wintiger0222 2019-12-08 23:02:07 +09:00 committed by nmlgc
parent 417ba80c00
commit 6e741bb1e1
3 changed files with 87 additions and 69 deletions

5
th04/formats/cdg.h Normal file
View File

@ -0,0 +1,5 @@
// ORs a single plane of the CDG image in the given [slot] into the given
// VRAM destination plane at (⌊x/8⌋*8, y), wrapped vertically.
void pascal cdg_put_plane_roll(
int x, int y, int slot, vram_plane_t plane_src, void __seg *plane_dst
);

View File

@ -0,0 +1,80 @@
public CDG_PUT_PLANE_ROLL
cdg_put_plane_roll proc far
@@plane_dst = word ptr [bp+6]
@@plane_src = word ptr [bp+8]
@@slot = word ptr [bp+10]
@@y = word ptr [bp+12]
@@x = word ptr [bp+14]
@@stride_backwards equ dx
@@h equ bx
push bp
mov bp, sp
push si
push di
mov ax, @@plane_dst
mov es, ax
mov si, @@slot
shl si, 4
add si, offset _cdg_slots
mov di, @@x
sar di, 3
mov @@h, [si+CDGSlot.pixel_height]
mov ax, @@y
add ax, @@h
dec ax
shl ax, 6
add di, ax
shr ax, 2
add di, ax
mov ax, [si+CDGSlot.width_divided_by_32]
mov word ptr cs:@@width_dwords, ax
jmp short $+2
shl ax, 2
add ax, ROW_SIZE
mov @@stride_backwards, ax
push ds
mov ax, [si+CDGSlot.sgm_colors]
mov si, [si+CDGSlot.bitplane_size]
mov ds, ax
mov cx, @@plane_src
inc cx
mov ax, si
neg si
@@plane_src_num_to_offset:
add si, ax
loop @@plane_src_num_to_offset
cmp di, (ROW_SIZE * RES_Y)
jb short @@start_blitting
sub di, (ROW_SIZE * RES_Y)
@@start_blitting:
cld
nop
@@next_row:
@@width_dwords equ $+1
mov cx, 1234h
@@blit_dword:
mov eax, [si]
or es:[di], eax
add si, 4
add di, 4
loop @@blit_dword
sub di, @@stride_backwards
jge short @@more_rows?
add di, (ROW_SIZE * RES_Y)
@@more_rows?:
dec @@h
jnz short @@next_row
pop ds
pop di
pop si
pop bp
retf 0Ah
cdg_put_plane_roll endp

View File

@ -7245,7 +7245,7 @@ loc_EC24:
push [bp+var_2]
push 110000h
push 0E000h
call far ptr loc_1371A
call cdg_put_plane_roll
inc si
loc_EC51:
@ -15149,74 +15149,7 @@ include th02/initmain.asm
db 0
include th04/formats/cdg_put_noalpha.asm
loc_1371A:
push bp
mov bp, sp
push si
push di
mov ax, [bp+6]
mov es, ax
mov si, [bp+0Ah]
shl si, 4
add si, offset _cdg_slots
mov di, [bp+0Eh]
sar di, 3
mov bx, [si+4]
mov ax, [bp+0Ch]
add ax, bx
dec ax
shl ax, 6
add di, ax
shr ax, 2
add di, ax
mov ax, [si+8]
mov word ptr cs:loc_13778+1, ax
jmp short $+2
shl ax, 2
add ax, 50h ; 'P'
mov dx, ax
push ds
mov ax, [si+0Eh]
mov si, [si]
mov ds, ax
mov cx, [bp+8]
inc cx
mov ax, si
neg si
loc_13768:
add si, ax
loop loc_13768
cmp di, 7D00h
jb short loc_13776
sub di, 7D00h
loc_13776:
cld
nop
loc_13778:
mov cx, 1234h
loc_1377B:
mov eax, [si]
or es:[di], eax
add si, 4
add di, 4
loop loc_1377B
sub di, dx
jge short loc_13792
add di, 7D00h
loc_13792:
dec bx
jnz short loc_13778
pop ds
pop di
pop si
pop bp
retf 0Ah
include th04/formats/cdg_put_plane_roll.asm
include th04/hardware/input_sense.asm
include th04/snd/se.asm
include th04/formats/cdg_load.asm