home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Special Sound & MIDI
/
Chip-Special_Sound-und-Midi-auf-dem-PC.bin
/
midiprog
/
smsg.asm
< prev
next >
Wrap
Assembly Source File
|
1993-11-28
|
6KB
|
347 lines
title Send MIDI Message HEX
page 64,132
MIDI_CLOCK equ 0f8h
ACTIVE_SENSE equ 0feh
code segment 'code'
assume cs:code,ds:code,es:code
org 100h
start : jmp anfang
msg_help db 'Aufruf: SMSG [-f Datei] | MIDI Message (hexadezimal)'
db 13,10,0
msg_fnf db 'SMSG: Datei nicht gefunden'
db 13,10,0
msg_fatal db 13,10
db 'SMSG: FATAL loop in put_cmd()'
db 13,10,0
; ---------
; Variablen
ALIGN 4
faddr dw 0
smsg_flag db 0
; ---------
; Utilities
wstring: push ax
push si
wstr100: lodsb
or al,al
jz wstr200
call wchar
jmp short wstr100
wstr200: pop si
pop ax
ret
wchar : push ax
push dx
mov dl,al
mov ah,2
int 21h
pop dx
pop ax
ret
toupper: cmp al,'a'
jb tou_ex
cmp al,'z'
ja tou_ex
and al,not 32
tou_ex : ret
tolower: cmp al,'A'
jb tol_ex
cmp al,'Z'
ja tol_ex
or al,32
tol_ex : ret
wsecond: push cx
mov ah,18
mul ah
mov cx,ax
wsec10 : call wtick
loop wsec10
pop cx
ret
; -----
; wtick - Wartet für einen Timertick ...
wtick : push ax
push bx
push cx
push dx
sti
xor ax,ax
int 1ah
mov bx,dx
wtick10: xor ax,ax
int 1ah
cmp dx,bx
jz wtick10
pop dx
pop cx
pop bx
pop ax
ret
; -------
; waitrcv - Wait For MPU Receive Ready
waitrcv: push ax
push dx
mov dx,0331h
waitr10: in al,dx
test al,40h
jnz waitr10
pop dx
pop ax
ret
; --------
; put_midi - Ausgabe eines MidiBytes
put_midi:push ax
push dx
call waitrcv
mov dx,0330h
out dx,al
pop dx
pop ax
ret
; -------
; resetmpu - Reset MPU
resetmpu:push ax
push dx
call waitrcv
pushf
cli
mov dx,0331h
mov al,0ffh
out dx,al
call waitrcv
dec dx
in al,dx
popf
pop dx
pop ax
ret
; -------
; put_cmd - Ausgabe eines MPU-Kommandos
put_cmd: push ax
push cx
push dx
call waitrcv
pushf
cli
mov dx,0331h
out dx,al
mov cx,4000h
put_c20: in al,dx
test al,80h
jz put_c30
loop put_c20
mov al,20h
out 20h,al
sti
lea si,msg_fatal
call wstring
jmp ende
put_c30: dec dx
in al,dx
inc dx
cmp al,0feh
jnz put_c20
put_c90: popf
pop dx
pop cx
pop ax
ret
; -----
; rmain
rmain : call resetmpu
mov al,3fh
call put_cmd
lea si,message
rmain100:lodsb
cmp al,MIDI_CLOCK
jnz rmain110
mov al,1
call wsecond
jmp short rmain112
rmain110:call put_midi
rmain112:loop rmain100
rmain120:cmp smsg_flag,0
jz rmain130
rmain130:call resetmpu
ret
; -------
; parscmd - Die Kommandozeile untersuchen
parscmd: mov si,80h
lodsw
or al,al
jnz pars100
helpexit:lea si,msg_help
err_exit:call wstring
mov al,1
jmp ende
pars100: call pars500
jb helpexit
cmp word ptr [si],'f-'
jnz pars110
jmp pars600
pars110: lea di,message
xor cx,cx
pars120: lodsb
call pars200
mov ah,al
shl ah,1
shl ah,1
shl ah,1
shl ah,1
lodsb
call pars200
or ah,al
mov al,ah
stosb
inc cx
call pars500
jnb pars120
ret
pars200: call toupper
cmp al,'0'
jb helpexit
cmp al,'F'
ja helpexit
cmp al,'9'
jbe pars220
cmp al,'A'
jb helpexit
sub al,7
pars220: sub al,'0'
ret
pars_ex: ret
pars500: cmp byte ptr [si],' '
jz pars540
cmp byte ptr [si],9
jz pars540
cmp byte ptr [si],13
jnz pars520
stc
ret
pars520: clc
ret
pars540: inc si
jmp short pars500
pars600: lodsw
call pars500
jnb pars620
jmp helpexit
pars620: mov faddr,si
mov di,si
pars640: lodsb
cmp al,13
jz pars660
call toupper
stosb
jmp short pars640
pars660: mov al,0
stosb
mov ax,3d00h
mov dx,faddr
int 21h
jnb pars700
lea si,msg_fnf
jmp err_exit
pars700: mov bx,ax
mov ax,3f00h
mov cx,0e000h
lea dx,message
int 21h
mov cx,ax
mov ax,3e00h
int 21h
mov smsg_flag,1
ret
; ------
; Anfang
anfang : cld
call parscmd
call rmain
ende : mov ah,4ch
int 21h
ALIGN 16
message label byte
code ends
end start