blob: abc4cd18d3786c4bb301a8dbfaf9ccba1240bcfd [file] [log] [blame] [raw]
.387
.386p
PUBLIC cmsWrite_
PUBLIC cmsNull_
PUBLIC cmsReset_
PUBLIC cmsDisableVoice_
PUBLIC cmsSetVolume_
PUBLIC cmsSound_
PUBLIC cmsNoteOff_
PUBLIC cmsTick_
PUBLIC cmsNoteOn_
PUBLIC cmsController_
PUBLIC _ChanEnableReg
PUBLIC _cms_synth
PUBLIC _CmsOctaveStore
PUBLIC _cmsPort
EXTRN _small_code_:BYTE
DGROUP GROUP CONST,CONST2,_DATA,_BSS
_TEXT SEGMENT BYTE PUBLIC USE16 'CODE'
ASSUME CS:_TEXT, DS:DGROUP, SS:DGROUP
cmsWrite_:
inc dx
xchg al,ah
out dx,al
dec dx
xchg al,ah
out dx,al
ret
cmsNull_:
add dx,word ptr _cmsPort
mov cx,20H
xor ax,ax
L$1:
call near ptr cmsWrite_
inc ah
loop L$1
mov ax,1c02H
call near ptr cmsWrite_
mov ax,1c01H
call near ptr cmsWrite_
ret
cmsReset_:
push bx
push cx
push dx
push si
push di
mov word ptr _cmsPort,ax
mov dx,0
call near ptr cmsNull_
mov dx,2
call near ptr cmsNull_
xor al,al
L$2:
xor bx,bx
mov bl,al
xor ah,ah
mov byte ptr _CmsOctaveStore[bx],ah
inc al
cmp al,0bH
jb L$2
mov byte ptr _ChanEnableReg,ah
mov byte ptr _ChanEnableReg+1,ah
xor al,al
L$3:
xor bx,bx
mov bl,al
add bx,bx
xor cl,cl
mov byte ptr _cms_synth[bx],cl
mov byte ptr _cms_synth+1[bx],cl
inc al
cmp al,0cH
jb L$3
L$4:
pop di
pop si
pop dx
pop cx
pop bx
ret
cmsDisableVoice_:
push bx
push cx
push dx
push si
push di
push bp
mov bp,sp
sub sp,2
mov byte ptr -2[bp],al
xor bh,bh
mov bl,byte ptr -2[bp]
mov dx,word ptr _cmsPort
mov bl,byte ptr _ChanReg[bx]
xor di,di
mov cl,byte ptr -2[bp]
cmp cl,6
jl L$5
inc di
add dx,2
L$5:
mov al,14H
inc dx
out dx,al
dec dx
mov al,byte ptr _ChanEnableReg[di]
mov ah,1
mov cl,bl
shl ah,cl
not ah
and al,ah
out dx,al
mov byte ptr _ChanEnableReg[di],al
mov sp,bp
pop bp
jmp L$4
cmsSetVolume_:
push cx
push si
push di
push bp
mov bp,sp
sub sp,6
mov byte ptr -6[bp],al
mov byte ptr -4[bp],dl
mov byte ptr -2[bp],bl
xor bh,bh
mov bl,byte ptr -6[bp]
mov dx,word ptr _cmsPort
cmp bl,6
add dx,2
mov bl,byte ptr _ChanReg[bx]
mov al,byte ptr -4[bp]
mov ah,byte ptr -2[bp]
mov cl,4
shl ah,cl
or al,ah
mov ah,bl
call near ptr cmsWrite_
L$6:
mov sp,bp
pop bp
pop di
L$7:
pop si
pop cx
ret
cmsSound_:
push si
push di
push bp
mov bp,sp
sub sp,8
mov byte ptr -6[bp],al
mov byte ptr -8[bp],dl
mov byte ptr -2[bp],bl
mov byte ptr -4[bp],cl
xor bh,bh
mov bl,byte ptr -6[bp]
mov dx,word ptr _cmsPort
cmp bl,6
add dx,2
mov bl,byte ptr _ChanReg[bx]
mov ah,byte ptr _OctavReg[bx]
mov al,ah
xor ah,ah
mov di,ax
sub di,10H
mov cl,byte ptr -6[bp]
cmp cl,6
jl L$8
add di,3
L$8:
mov ah,al
mov al,byte ptr _CmsOctaveStore[di]
mov bh,byte ptr -2[bp]
test bl,1
jne L$9
and al,0f0H
jmp near ptr L$10
L$9:
and al,0fH
mov cl,4
shl bh,cl
L$10:
or al,bh
mov byte ptr _CmsOctaveStore[di],al
call near ptr cmsWrite_
mov al,byte ptr -4[bp]
mov ah,byte ptr 8[bp]
mov cl,4
shl ah,cl
or al,ah
mov ah,bl
call near ptr cmsWrite_
mov al,byte ptr -8[bp]
or ah,8
call near ptr cmsWrite_
mov al,14H
inc dx
out dx,al
dec dx
xor di,di
mov cl,byte ptr -6[bp]
cmp cl,6
jl L$11
inc di
L$11:
mov al,byte ptr _ChanEnableReg[di]
mov ah,1
mov cl,bl
shl ah,cl
or al,ah
out dx,al
mov byte ptr _ChanEnableReg[di],al
mov sp,bp
pop bp
pop di
pop si
ret 2
cmsNoteOff_:
push bx
mov ah,0cH
xor al,al
jmp L$13
L$12:
inc al
cmp al,0cH
jae L$14
L$13:
xor bx,bx
mov bl,al
add bx,bx
cmp dl,byte ptr _cms_synth[bx]
jne L$12
mov ah,al
L$14:
cmp ah,0cH
je L$15
xor bx,bx
mov bl,ah
mov ax,bx
call near ptr cmsDisableVoice_
add bx,bx
mov byte ptr _cms_synth[bx],0
L$15:
pop bx
cmsTick_:
ret
cmsNoteOn_:
push cx
push si
push di
push bp
mov bp,sp
sub sp,6
mov byte ptr -2[bp],dl
mov byte ptr -4[bp],bl
test bl,bl
je L$19
mov bl,dl
inc bl
xor ax,ax
mov al,bl
mov cx,0cH
cwd
idiv cx
dec ax
mov dl,al
inc al
mov ah,0cH
mul ah
sub bl,al
mov byte ptr -6[bp],bl
mov ah,0cH
xor al,al
jmp L$17
L$16:
inc al
cmp al,0cH
jae L$18
L$17:
xor bx,bx
mov bl,al
add bx,bx
cmp byte ptr _cms_synth[bx],0
jne L$16
mov ah,al
L$18:
cmp ah,0cH
je L$6
xor bx,bx
mov bl,byte ptr -4[bp]
xor cx,cx
mov cl,byte ptr _atten[bx]
push cx
xor dh,dh
xor bx,bx
mov bl,byte ptr -6[bp]
movzx di,byte ptr _noteAdr[bx]
movzx si,ah
mov bx,dx
mov dx,di
mov ax,si
call near ptr cmsSound_
mov bx,si
add bx,si
mov al,byte ptr -2[bp]
mov byte ptr _cms_synth[bx],al
mov al,byte ptr -4[bp]
mov byte ptr _cms_synth+1[bx],al
jmp near ptr L$6
L$19:
xor dx,dx
mov dl,byte ptr -2[bp]
xor ah,ah
call near ptr cmsNoteOff_
jmp near ptr L$6
cmsController_:
push cx
push si
mov ch,bl
cmp dl,7
jne L$7
xor cl,cl
jmp L$21
L$20:
inc cl
cmp cl,0cH
jae L$7
L$21:
xor ax,ax
mov al,cl
mov si,ax
add si,ax
cmp byte ptr _cms_synth[si],0
je L$20
xor bx,bx
mov bl,ch
xor dx,dx
mov dl,byte ptr _atten[bx]
mov bx,dx
call near ptr cmsSetVolume_
mov byte ptr _cms_synth+1[si],ch
jmp L$20
_TEXT ENDS
CONST SEGMENT WORD PUBLIC USE16 'DATA'
CONST ENDS
CONST2 SEGMENT WORD PUBLIC USE16 'DATA'
CONST2 ENDS
_DATA SEGMENT WORD PUBLIC USE16 'DATA'
_noteAdr:
DB 5, 20H, 3cH, 55H, 6eH, 84H, 99H, 0adH
DB 0c0H, 0d2H, 0e3H, 0f3H
_atten:
DB 0, 1, 1, 1, 1, 1, 1, 1
DB 2, 2, 2, 2, 2, 2, 2, 2
DB 3, 3, 3, 3, 3, 3, 3, 3
DB 4, 4, 4, 4, 4, 4, 4, 4
DB 5, 5, 5, 5, 5, 5, 5, 5
DB 6, 6, 6, 6, 6, 6, 6, 6
DB 7, 7, 7, 7, 7, 7, 7, 7
DB 8, 8, 8, 8, 8, 8, 8, 8
DB 9, 9, 9, 9, 9, 9, 9, 9
DB 0aH, 0aH, 0aH, 0aH, 0aH, 0aH, 0aH, 0aH
DB 0bH, 0bH, 0bH, 0bH, 0bH, 0bH, 0bH, 0bH
DB 0cH, 0cH, 0cH, 0cH, 0cH, 0cH, 0cH, 0cH
DB 0dH, 0dH, 0dH, 0dH, 0dH, 0dH, 0dH, 0dH
DB 0eH, 0eH, 0eH, 0eH, 0eH, 0eH, 0eH, 0eH
DB 0fH, 0fH, 0fH, 0fH, 0fH, 0fH, 0fH, 0fH
DB 0fH, 0fH, 0fH, 0fH, 0fH, 0fH, 0fH, 0fH
_ChanReg:
DB 0, 1, 2, 3, 4, 5, 0, 1
DB 2, 3, 4, 5
_OctavReg:
DB 10H, 10H, 11H, 11H, 12H, 12H, 10H, 10H
DB 11H, 11H, 12H, 12H
_ChanEnableReg:
DB 0, 0
_DATA ENDS
_BSS SEGMENT WORD PUBLIC USE16 'BSS'
ORG 0
_cms_synth LABEL BYTE
ORG 18H
_CmsOctaveStore LABEL BYTE
ORG 24H
_cmsPort LABEL BYTE
ORG 26H
_BSS ENDS
END