2017-01-19 20:14:22 +00:00
|
|
|
; Loads the [n]th image of the CDG file [fn] into [slot].
|
|
|
|
|
|
|
|
; void pascal cdg_load_single_noalpha(int slot, const char *fn, int n);
|
|
|
|
; void pascal cdg_load_single(int slot, const char *fn, int n);
|
2019-09-15 16:23:33 +00:00
|
|
|
public CDG_LOAD_SINGLE_NOALPHA
|
|
|
|
public CDG_LOAD_SINGLE
|
2017-01-19 20:14:22 +00:00
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_single_noalpha label proc
|
2017-01-19 20:14:22 +00:00
|
|
|
mov cdg_noalpha, 1
|
|
|
|
align 2
|
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_single proc far
|
2017-01-19 20:14:22 +00:00
|
|
|
|
|
|
|
@@n = word ptr 6
|
|
|
|
@@fn = dword ptr 8
|
|
|
|
@@slot = word ptr 12
|
|
|
|
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
mov di, [bp+@@slot]
|
|
|
|
push di
|
2019-09-15 14:22:36 +00:00
|
|
|
nopcall cdg_free
|
2017-01-19 20:14:22 +00:00
|
|
|
shl di, 4
|
|
|
|
add di, offset _cdg_slots
|
|
|
|
pushd [bp+@@fn]
|
|
|
|
call file_ropen
|
|
|
|
push ds
|
|
|
|
push di
|
|
|
|
push size CDGSlot
|
|
|
|
call file_read
|
|
|
|
mov ax, [di+CDGSlot.bitplane_size]
|
|
|
|
mov dx, ax
|
|
|
|
cmp [di+CDGSlot.alpha], 0
|
|
|
|
jz short @@read
|
|
|
|
shl ax, 2
|
|
|
|
cmp [di+CDGSlot.alpha], 2
|
|
|
|
jz short @@read
|
|
|
|
add ax, dx
|
|
|
|
|
|
|
|
@@read:
|
|
|
|
mul [bp+@@n]
|
|
|
|
movzx eax, ax
|
|
|
|
push eax
|
|
|
|
push 1
|
|
|
|
call file_seek
|
2019-09-15 14:22:36 +00:00
|
|
|
call cdg_read_single
|
2017-01-19 20:14:22 +00:00
|
|
|
call file_close
|
|
|
|
mov cdg_noalpha, 0
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
|
|
|
retf 8
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_single endp
|
2017-01-19 20:14:22 +00:00
|
|
|
align 2
|
|
|
|
|
|
|
|
; Reads a single CDG image from the master.lib file, which previously has been
|
|
|
|
; positioned at the beginning of the image data, into the slot in DI.
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_read_single proc near
|
2017-01-19 20:14:22 +00:00
|
|
|
mov al, [di+CDGSlot.alpha]
|
|
|
|
or al, al
|
|
|
|
jz short @@colors
|
|
|
|
cmp al, 2
|
|
|
|
jz short @@alpha
|
|
|
|
cmp cdg_noalpha, 0
|
|
|
|
jnz short @@skip_alpha
|
|
|
|
|
|
|
|
@@alpha:
|
|
|
|
push [di+CDGSlot.bitplane_size]
|
|
|
|
call hmem_allocbyte
|
|
|
|
mov [di+CDGSlot.sgm_alpha], ax
|
|
|
|
push ax
|
|
|
|
push 0
|
|
|
|
push [di+CDGSlot.bitplane_size]
|
|
|
|
call file_read
|
|
|
|
jmp short @@colors
|
|
|
|
|
|
|
|
@@skip_alpha:
|
|
|
|
movzx eax, [di+CDGSlot.bitplane_size]
|
|
|
|
push eax
|
|
|
|
push 1
|
|
|
|
call file_seek
|
|
|
|
|
|
|
|
@@colors:
|
|
|
|
cmp [di+CDGSlot.alpha], 2
|
|
|
|
jz short @@ret
|
|
|
|
mov ax, [di+CDGSlot.bitplane_size]
|
|
|
|
shl ax, 2
|
|
|
|
push ax
|
|
|
|
call hmem_allocbyte
|
|
|
|
mov [di+CDGSlot.sgm_colors], ax
|
|
|
|
push ax
|
|
|
|
push 0
|
|
|
|
mov ax, [di+CDGSlot.bitplane_size]
|
|
|
|
shl ax, 2
|
|
|
|
push ax
|
|
|
|
call file_read
|
|
|
|
|
|
|
|
@@ret:
|
|
|
|
retn
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_read_single endp
|
2017-01-19 20:14:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Loads all images of the CDG file [fn], starting at [slot_first] and
|
|
|
|
; incrementing the slot number for every further image.
|
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
; void pascal cdg_load_all_noalpha(int slot, const char *fn);
|
|
|
|
; void pascal cdg_load_all(int slot, const char *fn);
|
2019-09-15 16:23:33 +00:00
|
|
|
public CDG_LOAD_ALL_NOALPHA
|
|
|
|
public CDG_LOAD_ALL
|
2017-01-19 20:14:22 +00:00
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_all_noalpha label proc
|
2017-01-19 20:14:22 +00:00
|
|
|
mov cdg_noalpha, 1
|
|
|
|
align 2
|
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_all proc far
|
2017-01-19 20:14:22 +00:00
|
|
|
|
|
|
|
@@fn = dword ptr 6
|
|
|
|
@@slot_first = word ptr 10
|
|
|
|
|
|
|
|
push bp
|
|
|
|
mov bp, sp
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
pushd [bp+@@fn]
|
|
|
|
call file_ropen
|
|
|
|
mov di, [bp+@@slot_first]
|
|
|
|
shl di, 4
|
|
|
|
add di, offset _cdg_slots
|
|
|
|
push ds
|
|
|
|
push di
|
|
|
|
push size CDGSlot
|
|
|
|
call file_read
|
|
|
|
mov si, di
|
|
|
|
mov bp, [bp+@@slot_first]
|
|
|
|
mov al, CDGSlot.num_images[si]
|
|
|
|
mov cdg_images_to_load, al
|
|
|
|
push ds
|
|
|
|
pop es
|
|
|
|
assume es:_DATA
|
|
|
|
|
|
|
|
@@loop:
|
|
|
|
push bp
|
2019-09-15 14:22:36 +00:00
|
|
|
call cdg_free
|
2017-01-19 20:14:22 +00:00
|
|
|
mov cx, 3
|
|
|
|
rep movsd
|
|
|
|
sub si, CDGSlot.sgm_alpha
|
|
|
|
sub di, CDGSlot.sgm_alpha
|
2019-09-15 14:22:36 +00:00
|
|
|
call cdg_read_single
|
2017-01-19 20:14:22 +00:00
|
|
|
inc bp
|
|
|
|
add di, size CDGSlot
|
|
|
|
dec cdg_images_to_load
|
|
|
|
jnz short @@loop
|
|
|
|
call file_close
|
|
|
|
mov cdg_noalpha, 0
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop bp
|
|
|
|
retf 6
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_load_all endp
|
2017-01-19 20:14:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Frees the CDG image in the given [slot].
|
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
; void cdg_free(int slot);
|
2019-09-15 16:23:33 +00:00
|
|
|
public CDG_FREE
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_free proc far
|
2017-01-19 20:14:22 +00:00
|
|
|
mov bx, sp
|
|
|
|
push di
|
|
|
|
mov di, ss:[bx+4]
|
|
|
|
shl di, 4
|
|
|
|
add di, offset _cdg_slots.sgm_alpha
|
|
|
|
cmp word ptr [di], 0
|
|
|
|
jz short @@colors
|
|
|
|
push word ptr [di]
|
|
|
|
call hmem_free
|
|
|
|
mov word ptr [di], 0
|
|
|
|
|
|
|
|
@@colors:
|
|
|
|
add di, 2
|
|
|
|
cmp word ptr [di], 0
|
|
|
|
jz short @@ret
|
|
|
|
push word ptr [di]
|
|
|
|
call hmem_free
|
|
|
|
mov word ptr [di], 0
|
|
|
|
|
|
|
|
@@ret:
|
|
|
|
pop di
|
|
|
|
retf 2
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_free endp
|
2017-01-19 20:14:22 +00:00
|
|
|
align 2
|
|
|
|
|
|
|
|
|
|
|
|
; Frees the CDG images in all slots.
|
|
|
|
|
2019-09-15 14:22:36 +00:00
|
|
|
; void cdg_freeall();
|
2019-09-15 16:23:33 +00:00
|
|
|
public CDG_FREEALL
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_freeall proc far
|
2017-01-19 20:14:22 +00:00
|
|
|
push si
|
|
|
|
mov si, CDG_SLOT_COUNT - 1
|
|
|
|
|
|
|
|
@@loop:
|
2019-09-15 14:22:36 +00:00
|
|
|
call cdg_free pascal, si
|
2017-01-19 20:14:22 +00:00
|
|
|
dec si
|
|
|
|
jge short @@loop
|
|
|
|
pop si
|
|
|
|
retf
|
2019-09-15 14:22:36 +00:00
|
|
|
cdg_freeall endp
|