home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 3
/
FREEWARE.BIN
/
fb386
/
metal
/
y_sbios.asm
< prev
next >
Wrap
Assembly Source File
|
1980-01-02
|
13KB
|
790 lines
.386p
include tbios.inc
param struc
dd ? ;return address
p dd 16 dup(?) ;paramater
param ends
;
; for y_s bios
;
pattern struc ; 4 bytes 2 article
pno dw ? ;pattern no.(for tbios)
pmxy dw ? ;size of x and y(DH:x DL:y)
pattern ends
sp_chr struc ; 16 byte 8 article
cno dw ? ;sprite charactor no.(for tbios)
cmxy dw ? ;size of x and y(DH:x DL:y)
aix dw ? ;animation pointer
x dw ? ;x_point(dot)
y dw ? ;y_point(dot)
si_b dw ? ;offset, direction flag
di_b dw ? ;color table no.
resev dw ? ;reserve
sp_chr ends
;
; エントリー
;
code segment dword public ER use32 'CODE'
assume cs:code,ds:data,es:data,ss:sseg
jmp i_o ;0
jmp gbios ;5
jmp dummy ;mbios ;10
jmp spbios ;15
jmp sdbios ;20
jmp dummy ;fbios ;25
jmp y_sbios ;30
;
;
;
data segment dword public RW use32 'DATA'
;
; for graphics bios
;
gsize equ 1024
gwork db gsize dup(?)
;
; for sound bios
;
;sdsize equ 1024*16
;sdwork db sdsize dup(?)
;
; for y_s bios
;
x_ofs dw 0
y_ofs dw 0
pt pattern <128>
pattern 512-128-1 dup(<>)
at dw 256 dup(16 dup(?))
sp_chr <1024>
ct sp_chr 256 dup(<>)
prt dw 256 dup(?)
data ends
dummy proc near
ret
dummy endp
;
; I/O
;
i_o proc near
mov edx,[esp].p[0]
mov eax,[esp].p[4]
out dx,al
ret
i_o endp
;
; TBIOS マクロ
;
;
; グラフィックス
;
gbios proc near
mov ebp,esp
push tbios
pop fs
mov edi,offset gwork
mov eax,[ebp].p[0]
call dword ptr cs:g_jtbl[eax*4]
ret
gbios endp
;
g_jtbl dd offset init
dd offset scrn_md
dd offset scrn_at
dd offset view
dd offset palette
dd offset w_page
dd offset d_page
;
;
;
init proc near
ginit
ret
init endp
;
scrn_md proc near
mov eax,[ebp].p[4]
mov edx,[ebp].p[8]
graph 01h
ret
scrn_md endp
;
scrn_at proc near
mov eax,[ebp].p[4]
graph 05h
mov al,0
mov edx,[ebp].p[8]
mov ebx,[ebp].p[12]
graph 02h
mov al,2
mov edx,[ebp].p[16]
mov ebx,[ebp].p[20]
graph 02h
mov al,3
mov edx,[ebp].p[24]
mov ebx,[ebp].p[28]
graph 02h
ret
scrn_at endp
;
view proc near
mov esi,[ebp].p[4]
graph 03h
ret
view endp
;
palette proc near
mov eax,[ebp].p[4]
mov esi,[ebp].p[8]
graph 04h
ret
palette endp
;
w_page proc near
mov eax,[ebp].p[4]
graph 05h
ret
w_page endp
;
d_page proc near
mov eax,[ebp].p[4]
mov edx,[ebp].p[8]
graph 06h
ret
d_page endp
;
; サウンド
;
sdbios proc near
; mov ebp,esp
; push tbios
; pop fs
; mov edi,offset sdwork
; mov eax,[ebp].p[0]
; call dword ptr cs:sd_jtbl[eax*4]
ret
sdbios endp
sd_jtbl dd offset sd_init ;00h
dd offset keyon ;01h
dd offset keyoff ;02h
dd offset output ;03h
dd offset c_stype ;04h
dd offset w_sdata ;05h
; dd offset pad
; dd offset LED
;
sd_init proc near
sound 00h
ret
sd_init endp
;
keyon proc near
mov bl,byte ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
mov dl,byte ptr[ebp].p[12]
sound 01h
ret
keyon endp
;
keyoff proc near
mov bl,byte ptr[ebp].p[4]
sound 02h
ret
keyoff endp
;
output proc near
mov bl,byte ptr[ebp].p[4]
mov dl,byte ptr[ebp].p[8]
sound 03h
ret
output endp
;
c_stype proc near
mov bl,byte ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
sound 04h
ret
c_stype endp
;
w_sdata proc near
mov bl,byte ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
mov esi,[ebp].p[12]
sound 05h
ret
w_sdata endp
;
; スプライト
;
spbios proc near
push tbios
pop fs
mov ebp,esp
mov eax,[ebp].p[0]
call dword ptr cs:sp_jtbl[eax*4]
ret
spbios endp
;
sp_jtbl dd offset spinit ;00h
dd offset sp_dsp ;01h
dd offset sp_def ;02h
dd offset sp_spal ;03h
dd offset sp_spos ;04h
dd offset sp_satr ;05h
dd offset sp_xy ;06h
dd offset sp_ofs ;07h
dd offset sp_gatr ;08h
;
spinit proc near
sprite 00h
ret
spinit endp
;
sp_dsp proc near
mov al,byte ptr[ebp].p[4]
mov cx,word ptr[ebp].p[8]
sprite 01h
ret
sp_dsp endp
;
sp_def proc near
mov al,byte ptr[ebp].p[4]
mov cx,word ptr[ebp].p[8]
mov dh,byte ptr[ebp].p[12]
mov dl,byte ptr[ebp].p[16]
mov esi,[ebp].p[20]
sprite 02h
ret
sp_def endp
;
sp_spal proc near
mov cx,word ptr[ebp].p[4]
mov dx,word ptr[ebp].p[8]
mov esi,[ebp].p[12]
sprite 03h
ret
sp_spal endp
;
sp_spos proc near
mov al,byte ptr[ebp].p[4]
mov cx,word ptr[ebp].p[8]
mov dh,byte ptr[ebp].p[12]
mov dl,byte ptr[ebp].p[16]
mov si,word ptr[ebp].p[20]
mov di,word ptr[ebp].p[24]
sprite 04h
ret
sp_spos endp
;
sp_satr proc near
mov cx,word ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
mov dl,byte ptr[ebp].p[12]
mov si,word ptr[ebp].p[16]
mov di,word ptr[ebp].p[20]
sprite 05h
ret
sp_satr endp
;
sp_xy proc near
mov cx,word ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
mov dl,byte ptr[ebp].p[12]
mov si,word ptr[ebp].p[16]
mov di,word ptr[ebp].p[20]
sprite 06h
ret
sp_xy endp
;
sp_ofs proc near
mov si,word ptr[ebp].p[4]
mov di,word ptr[ebp].p[8]
sprite 07h
ret
sp_ofs endp
;
sp_gatr proc near
mov cx,word ptr[ebp].p[4]
mov dh,byte ptr[ebp].p[8]
mov dl,byte ptr[ebp].p[12]
mov edi,[ebp].p[16]
sprite 08h
ret
sp_gatr endp
;
; Y_S BIOS
;
y_sbios proc near
push tbios
pop fs
mov ebp,esp
mov eax,[ebp].p[0]
call dword ptr cs:ys_jtbl[eax*4]
ret
y_sbios endp
;
ys_jtbl dd offset y_sinit ;00h
dd offset def_cell ;01h
dd offset def_anime ;02h
dd offset def_schr ;03h
dd offset dsp_anm ;04h
dd offset chg_atr ;05h
dd offset chg_prt ;06h
; initialize Y_S BIOS
; p[4]=view x point p[8]=view y point
y_sinit proc near
sprite 00h
xor cx,cx
mov dx,1010h ;x=16 y=16 (256 count)
mov si,0000h
mov di,2000h ;no display
yi_lp1: sprite 05h
add cx,256
cmp cx,1024
jne short yi_lp1
mov word ptr pt[0].pno,128 ;initialize pattern no.
mov word ptr ct[0].cno,1024 ;initialize sp_chr no.
mov ax,word ptr[ebp].p[4]
mov x_ofs,ax
mov ax,word ptr[ebp].p[8]
mov y_ofs,ax
ret
y_sinit endp
; define cell (function 01h)
; p[4]=cell top no. p[8]=cell number p[12]=max_x(char) p[16]=max_y(char)
; p[20]=pattern top address
; <return> eax=next cell top no.
def_cell proc near
mov eax,[ebp].p[8]
push eax ;[esp][8]
mov ah,byte ptr[ebp].p[12]
mov al,byte ptr[ebp].p[16]
mul ah
push eax ;[esp][4]=max_x*max_y
shl ax,7
push eax ;[esp][0]=max_x*max_y*128(offset)
mov ebx,[ebp].p[4]
mov esi,[ebp].p[20]
mov dh,byte ptr[ebp].p[12]
mov dl,byte ptr[ebp].p[16]
dfc_lp1: mov ax,pt[ebx*4].pno
mov cx,ax
add ax,[esp][4]
mov pt[ebx*4][4],ax ;next .pno
mov pt[ebx*4].pmxy,dx
mov ax,0200h
call pword ptr fs:[60h]
inc ebx
add esi,[esp][0]
dec dword ptr[esp][8]
jne short dfc_lp1
add esp,12
mov eax,ebx
ret
def_cell endp
; define animation (function 02h)
; p[4]=top anime no. p[8]=anime number p[12]=top cell no.
; p[16]=top anime address
; <return> eax=next top anime no.
def_anime proc near
mov ecx,[ebp].p[8]
mov edi,[ebp].p[4]
shl edi,5
mov esi,[ebp].p[16]
dfa_lp1: xor edx,edx
dfa_lp2: mov ax,[esi+edx*2]
or ax,ax
js short dfa_ed1
add ax,word ptr[ebp].p[12]
mov at[edi+edx*2],ax
inc edx
jmp short dfa_lp2
dfa_ed1: mov at[edi+edx*2],ax
add esi,16*2
add edi,16*2
loop dfa_lp1
mov eax,[ebp].p[4]
add eax,[ebp].p[8]
ret
def_anime endp
; difine sprite_charactor (function 03h)
; p[4]=char no. p[8]=anime no. p[12]=max_x(char) p[16]=max_y(char)
; p[20]=point_x(dot) p[24]=point_y(dot) p[28]=color_tbl no
; p[32]=offset flag p[36]=direction flag
; <return> eax=used sprite count
def_schr proc near
mov ebx,[ebp].p[4]
shl ebx,4
mov ah,byte ptr[ebp].p[12] ;sp_chr no.
mov al,byte ptr[ebp].p[16]
mul ah
mov cx,ct[ebx][-16] ;before .cno
sub cx,ax
mov ct[ebx].cno,cx
mov eax,[ebp].p[4] ;priority
mov prt[eax*2],ax
mov dh,byte ptr[ebp].p[12] ;max x,y
mov dl,byte ptr[ebp].p[16]
mov ct[ebx].cmxy,dx
mov eax,[ebp].p[8] ;anime no=>cell no.
shl eax,5
mov ct[ebx].aix,ax
mov ax,at[eax] ;cell no.=>pattern no
mov si,pt[eax*4]
xor ah,ah
mov al,byte ptr[ebp].p[32] ;offset flag
or al,al
je short dfc_skp1
or ah,80h
dfc_skp1: mov al,byte ptr[ebp].p[36] ;direction flag
shl al,4
or ah,al
xor al,al
mov ct[ebx].si_b,ax
or si,ax
mov di,word ptr[ebp].p[28] ;color table
or di,8100h
mov ct[ebx].di_b,di
sprite 05h
mov si,word ptr[ebp].p[20] ;point x,y
mov ct[ebx].x,si
mov di,word ptr[ebp].p[24]
mov ct[ebx].y,di
call ca_xy1
mov ax,1024
sub ax,cx
movsx eax,ax
ret
def_schr endp
; display animation (function 04h)
; p[4]=sp_chr no.
; <return> eax -1:anime ended
dsp_anm proc near
mov ebx,[ebp].p[4]
shl ebx,4
mov ax,ct[ebx].aix ;anime no.
movzx eax,ax
mov ax,at[eax] ;cell no.=>pattern no
movzx eax,ax
mov si,pt[eax*4]
or si,ct[ebx].si_b
mov di,ct[ebx].di_b
mov cx,ct[ebx].cno
mov dx,ct[ebx].cmxy
sprite 05h
mov dx,ct[ebx].aix
add dx,2
movzx edx,dx
mov ax,at[edx]
or ax,ax
jns short dpa_skp1
and dx,0FFE0h
dpa_skp1: mov ct[ebx].aix,dx
movsx eax,ax
ret
dsp_anm endp
; change attribute (function 05h)
; p[4]=chr no. p[8]=change no.
; p[8]=0 : p[12]=x point(dot) p[16]=y point(dot)
; 1 : p[12]=anime no.
; 2 : p[12]=palette no.
; 3 : p[12]=direction flag
chg_atr proc near
mov ebx,[ebp].p[4]
shl ebx,4
mov cx,ct[ebx].cno
mov dx,ct[ebx].cmxy
mov eax,[ebp].p[8]
call dword ptr cs:ca_jtbl[eax*4]
ret
chg_atr endp
;
ca_jtbl dd offset ca_xy ;00h
dd offset ca_ano ;01h
dd offset ca_cpal ;02h
dd offset ca_cdir ;03h
ca_xy proc near
mov si,word ptr[ebp].p[12] ;point x,y
mov ct[ebx].x,si
mov di,word ptr[ebp].p[16]
mov ct[ebx].y,di
ca_xy1: sub si,x_ofs
and si,1FFh
sub di,y_ofs
and di,1FFh
test byte ptr ct[ebx].si_b+1,70h
je short ca_nml
push ecx
push edx ;[esp][8]
push edx ;[esp][4]
mov al,16
dec dh
mul dh
add si,ax
push esi ;[esp][0]
mov dx,0101h
ca_lp1: mov al,[esp][9]
mov [esp][5],al
mov si,[esp][0]
ca_lp2: mov ax,0400h
call pword ptr fs:[60h]
inc cx
sub si,16
dec byte ptr[esp][5]
jne short ca_lp2
add di,16
dec byte ptr[esp][4]
jne short ca_lp1
add esp,8
pop edx
pop ecx
ret
ca_nml: mov ax,0400h
call pword ptr fs:[60h]
ret
ca_xy endp
ca_ano proc near
mov eax,[ebp].p[12] ;anime no=>cell no.
shl eax,5
mov ct[ebx].aix,ax
mov ax,at[eax] ;cell no.=>pattern no
mov si,pt[eax*4]
or si,ct[ebx].si_b
mov di,ct[ebx].di_b
sprite 05h
ret
ca_ano endp
ca_cpal proc near
xor eax,eax
mov ax,ct[ebx].aix ;anime no=>cell no.
mov ax,at[eax] ;cell no.=>pattern no
mov si,pt[eax*4]
or si,ct[ebx].si_b
mov di,ct[ebx].di_b
and di,0FF00h
add di,word ptr[ebp].p[12]
mov ct[ebx].di_b,di
sprite 05h
ret
ca_cpal endp
ca_cdir proc near
mov eax,[ebp].p[12]
shl eax,12
mov si,ct[ebx].si_b
and si,7000h
cmp ax,si
je cacd_end
mov si,ct[ebx].si_b
and si,8FFFh
or si,ax
mov ct[ebx].si_b,si
mov ax,ct[ebx].aix
mov ax,at[eax] ;cell no.=>pattern no
mov ax,pt[eax*4]
or si,ax
mov di,ct[ebx].di_b
sprite 05h
mov si,ct[ebx].x
mov di,ct[ebx].y
call ca_xy1
cacd_end: ret
ca_cdir endp
; change prioritys (function 06h)
; p[4]=chr count p[8]=prioryty table address
; p[12]=sort type (0:normal 1:reverse)
chg_prt proc near
mov ebx,[ebp].p[8]
xor edx,edx
push edx ;[esp][4]
xor esi,esi ;value C
mov edx,[ebp].p[4] ;CMAX
push edx ;[esp][0]
cp_lp1: xor edi,edi ;value I
mov ecx,[ebp].p[4] ;CMAX
xor edx,edx
cp_lp2: mov ax,[ebx][esi*2]
cmp ax,[ebx][edi*2]
jne short cp_sk1
cmp esi,edi
ja short cp_ed1
jmp short cp_ed2
cp_sk1: seta al
xor al,byte ptr[ebp].p[12]
je short cp_ed2
cp_ed1: inc edx
cp_ed2: inc edi
loop short cp_lp2
cmp si,prt[edx*2]
je short cp_sk2
mov prt[edx*2],si
mov byte ptr[esp][4],255
cp_sk2: inc esi
dec byte ptr[esp][0]
jne short cp_lp1
add esp,4
pop eax
test al,255
je cp_end
mov si,prt[0]
shl si,4
mov word ptr ct[esi].cno,1024
xor ebx,ebx ;PR=0
mov ecx,[ebp].p[4] ;CMAX
dec ecx
cp_lp3: mov si,prt[ebx*2]
shl si,4
mov di,prt[ebx*2+2]
shl di,4
mov ax,ct[esi].cmxy ;sp_chr no.
mul ah
mov dx,ct[esi].cno
sub dx,ax
mov ct[esi].cno,dx
mov ct[edi].cno,dx
inc ebx
loop short cp_lp3
mov ax,ct[edi].cmxy ;sp_chr no.
mul ah
mov dx,ct[edi].cno
sub dx,ax
mov ct[edi].cno,dx
xor ebx,ebx
mov edx,[ebp].p[4] ;CMAX
push edx ;[esp][0]
cp_lp4: mov cx,ct[ebx].cno
mov dx,ct[ebx].cmxy
mov ax,ct[ebx].aix
mov ax,at[eax] ;cell no.=>pattern no
mov si,pt[eax*4]
mov ax,ct[ebx].si_b
or si,ax
mov di,ct[ebx].di_b
sprite 05h
mov si,ct[ebx].x
mov di,ct[ebx].y
call ca_xy1
add ebx,16
dec byte ptr[esp][0]
jne short cp_lp4
add esp,4
cp_end: ret
chg_prt endp
code ends
;
;
;
sseg segment dword stack RW use32 'STACK'
db 1000h dup(?)
sseg ends
end