1068 ;============================================================== ; SYSEX Transmits and receives SysEx using Soundblaster MIDI ;============================================================== INCLUDELIB MIDI INCLUDELIB INOUT INCLUDELIB FILE INCLUDE MIDI.INC INCLUDE INOUT.INC INCLUDE FILE.INC INCLUDE DOS.INC DOSSEG .MODEL SMALL .386 .STACK .DATA exbufseg dw ? exdatalen dd 0 handle dw ? menutxt db '(1) Transmit SysEx (2) Receive SysEx (ESC) Quit$' xmitprompt db 'Enter name of SysEx file to transmit: $' xmittxt db 'Transmitting SysEx data...',13,10,'$' xmitoktxt db 'Transmission completed. Press any key...',13,10,'$' errtxt db 'Could not load that file! Press any key...',13,10,'$' max db 128 actual db ? string db 128 dup(?) .CODE .STARTUP @ModBlock 65536/16 call sbmidi_init call draw_screen mainlp: mov ah,1 int 16h jz midithru mov ah,0 int 16h cmp al,'1' jz upload cmp al,'2' jz download cmp al,27 jz quit jmp mainlp midithru: call sbmidi_get jnc mainlp mov bl,al call sbmidi_put jmp mainlp upload: call exul call draw_screen jmp mainlp download: call exdl call draw_screen jmp mainlp quit: call sbmidi_exit call clrscr call showcur .EXIT draw_screen PROC call clrscr call hidecur mov ah,9 mov dx,offset menutxt int 21h ret draw_screen ENDP exul PROC call clrscr call hidecur mov ah,9 mov dx,offset xmitprompt int 21h call showcur mov ah,0ah mov dx,offset max int 21h call crlf call hidecur xor bh,bh mov bl,actual mov string[bx],0 mov dx,offset string call heap_load cmp ax,0 jnz loaded_ok mov ah,9 mov dx,offset errtxt int 21h jmp ul_abort loaded_ok: mov exbufseg,ax mov ah,9 mov dx,offset xmittxt int 21h mov es,exbufseg mov di,0 xmit_lp: mov bl,byte ptr es:[di] call sbmidi_put mov cx,0ffh ; A little delay to be sure... dly: loop dly inc di jnz no_newseg mov dx,es add dx,1000h mov es,dx no_newseg: cmp bl,EOX jnz xmit_lp mov ah,9 mov dx,offset xmitoktxt int 21h ul_abort: mov ah,0 int 16h mov es,exbufseg @FreeBlock ret exul ENDP ;--------------------------------- ;EXDL Receives SysEx data ;--------------------------------- .DATA rcvstarttxt db 'Waiting for SysEx from transmitting device...',13,10,'$' rcvtxt db 'Receiving SysEx data...',13,10,'$' rcvoktxt db 'Reception completed.',13,10,13,10 db 'Enter name of file to save to: $' aborttxt db 'Aborted! Press any key...',13,10,'$' .CODE exdl PROC @GetBlock 0ffffh @GetBlock bx mov exbufseg,ax call clrscr call hidecur mov ah,9 mov dx,offset rcvstarttxt int 21h mov exdatalen,0 waitforsysexstart: call sbmidi_get jc byte_rcvd1 mov ah,1 int 16h jnz dl_abort jmp waitforsysexstart byte_rcvd1: cmp al,SysEx jnz waitforsysexstart mov es,exbufseg mov di,word ptr[exdatalen] mov byte ptr es:[di],al inc exdatalen mov ah,9 mov dx,offset rcvtxt int 21h mov es,exbufseg rcv_lp: call sbmidi_get jc byte_rcvd2 mov ah,1 int 16h jnz dl_abort jmp rcv_lp byte_rcvd2: mov di,word ptr[exdatalen] mov byte ptr es:[di],al inc exdatalen cmp word ptr[exdatalen],0 jnz no_newseg mov dx,es add dx,1000h mov es,dx no_newseg: cmp al,EOX jnz rcv_lp mov ah,9 mov dx,offset rcvoktxt int 21h call showcur mov ah,0ah mov dx,offset max int 21h call hidecur xor bh,bh mov bl,actual mov string[bx],0 mov dx,offset string @MakeFile dx mov dx,offset string @OpenFile dx,1 mov handle,ax mov si,exbufseg writelp: cmp exdatalen,00008000h jb lastchunk push ds @Write 0,8000h,handle,si pop ds sub exdatalen,00008000h add si,0800h jmp writelp lastchunk: push ds @Write 0,word ptr[exdatalen],handle,si pop ds @CloseFile handle jmp ul_end dl_abort: mov ah,0 int 16h mov ah,9 mov dx,offset aborttxt int 21h mov ah,0 int 16h ul_end: mov es,exbufseg @FreeBlock ret exdl ENDP END . 0