Home » Archimedes archive » Archimedes World » AW-1991-02.adf » !AWFeb91/Goodies/ArtOfNoise/MIDIdump

!AWFeb91/Goodies/ArtOfNoise/MIDIdump

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » AW-1991-02.adf
Filename: !AWFeb91/Goodies/ArtOfNoise/MIDIdump
Read OK:
File size: 1023 bytes
Load address: FFFFFB42
Exec address: C3D6F6FC
File contents
   10REM > MIDIdump
   20
   30MODE12
   40ON ERROR PROCerror:END
   50OSCLI"RMREINIT MIDI"
   60PROCassemble
   70
   80OSCLI"FX21,0"
   90PRINT"1. From MIDI instrument"
  100PRINT"2. To   MIDI instrument"
  110PRINT"3. OS Command"
  120REPEAT:K$=GET$:UNTIL INSTR("123",K$)<>0
  130CASE VAL(K$) OF
  140WHEN 1 :PROCreceivedata
  150WHEN 2 :PROCtransmitdata
  160WHEN 3 :PROCoscliscreen
  170ENDCASE
  180
  190RUN
  200END
  210
  220DEFPROCreceivedata
  230REPEAT
  240CLS:PRINT'"Awaiting MIDI data..."
  250checksum%=USR receive_data
  260IF checksum%=0 THEN intact%=TRUE ELSE intact%=FALSE
  270IF (NOT intact%) CLS:VDU7:PRINT"MIDI DATA ERROR !!!":REPEAT UNTIL GET=32
  280UNTIL intact%
  290VDU7:PRINT'"MIDI data intact - jolly good !!!"''
  300INPUT"Enter full path/filename for save - "filename$
  310endaddress%=!data_end
  320OSCLI"SAVE "+filename$+" "+STR$~(buffer)+" "+STR$~(endaddress%)+" 0 0"
  330ENDPROC
  340
  350DEFPROCtransmitdata
  360INPUT"Enter full path/filename - "filename$
  370OSCLI"LOAD "+filename$+" "+STR$~(buffer)
  380CLS:PRINT'"Sending MIDI data..."
  390CALL transmit_data
  400PRINT'"Finished !!!"
  410ENDPROC
  420
  430DEFPROCoscliscreen
  440CLS
  450INPUT"*"oscommand$
  460OSCLI oscommand$
  470PRINT'"Press SPACE to continue..."
  480OSCLI"FX21,0"
  490REPEAT UNTIL GET=32
  500ENDPROC
  510
  520DEFPROCassemble
  530end=11:buff=12:sp=13:link=14
  540length%=50*1024
  550DIM code% length%
  560FOR pass%= 8 TO 10 STEP 2
  570P%=code%
  580L%=P% + length%
  590[OPT pass%
  600.receive_data
  610STMFD (sp)!,{link}              ;push return address onto stack
  620ADR buff,buffer                 ;get buffer address into R12
  630.start_reception
  640MOV R0,#0                       ;set MIDI port 0
  650SWI "MIDI_RxByte"               ;test port 0 receive buffer
  660AND R0,R0,#&FF                  ;mask out unwanted bytes
  670CMP R0,#&F0                     ;check if start of SYSEX
  680BNE start_reception             ;...and loop back if not true
  690STRB R0,[buff],#1               ;store &F0 at start of buffer, buffer+=1
  700.receive_loop
  710MOV R0,#0                       ;set MIDI port 0
  720SWI "MIDI_RxByte"               ;test port 0 buffer
  730CMP R0,#0                       ;test if buffer empty...
  740BEQ receive_loop                ;...and loop back if true
  750AND R0,R0,#&FF                  ;mask out unwanted bytes...
  760STRB R0,[buff],#1               ;...and store byte in buffer, buffer+=1
  770CMP R0,#&F7                     ;check if end of SYSEX
  780BNE receive_loop                ;...if not continue reception
  790ADR end,data_end                ;get address of data_end store into R11
  800STR buff,[end]                  ;store data end address in .data_end
  810.count_data
  820ADR buff,buffer                 ;get data buffer address in R12
  830ADD buff,buff,#6                ;add offset to start count from (Yamaha)
  840MOV R0,#0                       ;set counter to zero
  850.count_loop
  860LDRB R1,[buff],#1               ;get next byte from buffer, buffer+=1
  870LDRB R2,[buff]                  ;check the next byte...
  880CMP R2,#&F7                     ;...to see if end of exclusive
  890ADDNE R0,R0,R1                  ;if not EOX add previous to counter...
  900BNE count_loop                  ;...and loop back and continue count
  910AND R0,R0,#&FF                  ;get bottom byte of accumulated count
  920ADD R0,R0,R1                    ;add count and packet checksum
  930AND R0,R0,#&7F                  ;delete top bit to finish checksum
  940LDMFD (sp)!,{PC}                ;return from routine
  950
  960.transmit_data
  970STMFD (sp)!,{link}              ;store return address on stack
  980ADR buff,buffer                 ;get buffer address into R12
  990.transmit_loop
 1000MOV R0,#1                       ;1 = transmit buffer
 1010SWI "MIDI_InqBufferSize"        ;inquire size of transmit buffer
 1020CMP R0,#0                       ;check if no space available in buffer...
 1030BEQ transmit_loop               ;...and loop back if true
 1040LDRB R0,[buff],#1               ;get next byte to transmit, buffer+=1
 1050SWI "MIDI_TxByte"               ;...and transmit
 1060CMP R0,#&F7                     ;check if end of exclusive data...
 1070BNE transmit_loop               ;...and loop back if not
 1080LDMFD (sp)!,{PC}                ;return from routine
 1090
 1100.data_end
 1110EQUD 0
 1120.buffer
 1130FNspace(40*1024)
 1140]
 1150NEXT pass%
 1160ENDPROC
 1170
 1180REM reserve space in code
 1190DEFFNspace(bytes%)
 1200P%+=bytes%
 1210[OPT pass%
 1220ALIGN
 1230]
 1240=""
 1250
 1260DEFPROCerror
 1270MODE12
 1280REPORT:PRINT" at line ";ERL
 1290ENDPROC

� > MIDIdump

�12
(� � �error:�
2�"RMREINIT MIDI"
<
�assemble
F
P
�"FX21,0"
Z�"1. From MIDI instrument"
d�"2. To   MIDI instrument"
n�"3. OS Command"
x�:K$=�:� �"123",K$)<>0
�Ȏ �(K$) �
�� 1 :�receivedata
�� 2 :�transmitdata
�� 3 :�oscliscreen
��
�
��
��
�
���receivedata
��
��:�'"Awaiting MIDI data..."
�checksum%=� receive_data
)� checksum%=0 � intact%=� � intact%=�
6� (� intact%) �:�7:�"MIDI DATA ERROR !!!":� � �=32

� intact%
".�7:�'"MIDI data intact - jolly good !!!"''
,4�"Enter full path/filename for save - "filename$
6endaddress%=!data_end
@@�"SAVE "+filename$+" "+�~(buffer)+" "+�~(endaddress%)+" 0 0"
J�
T
^��transmitdata
h+�"Enter full path/filename - "filename$
r%�"LOAD "+filename$+" "+�~(buffer)
|�:�'"Sending MIDI data..."
�� transmit_data
��'"Finished !!!"
��
�
���oscliscreen
��
��"*"oscommand$
�� oscommand$
�"�'"Press SPACE to continue..."
�
�"FX21,0"
�� � �=32
��
�
��assemble
 end=11:buff=12:sp=13:link=14
length%=50*1024
&� code% length%
0� pass%= 8 � 10 � 2
:P%=code%
DL%=P% + length%
N[OPT pass%
X.receive_data
bCSTMFD (sp)!,{link}              ;push return address onto stack
l@ADR buff,buffer                 ;get buffer address into R12
v.start_reception
�4MOV R0,#0                       ;set MIDI port 0
�?SWI "MIDI_RxByte"               ;test port 0 receive buffer
�:� R0,R0,#&FF                  ;mask out unwanted bytes
�;CMP R0,#&F0                     ;check if start of șEX
�ABNE start_reception             ;...and loop back if not true
�LSTRB R0,[buff],#1               ;store &F0 at start of buffer, buffer+=1
�.receive_loop
�4MOV R0,#0                       ;set MIDI port 0
�7SWI "MIDI_RxByte"               ;test port 0 buffer
�<CMP R0,#0                       ;test if buffer empty...
�=BEQ receive_loop                ;...and loop back if true
�=� R0,R0,#&FF                  ;mask out unwanted bytes...
�KSTRB R0,[buff],#1               ;...and store byte in buffer, buffer+=1
9CMP R0,#&F7                     ;check if end of șEX
ABNE receive_loop                ;...if not continue reception
KADR end,data_end                ;get address of data_end store into R11
 HSTR buff,[end]                  ;store data end address in .data_end
*.count_data
4CADR buff,buffer                 ;get data buffer address in R12
>LADD buff,buff,#6                ;add offset to start count from (Yamaha)
H8MOV R0,#0                       ;set counter to zero
R.count_loop
\ILDRB R1,[buff],#1               ;get next byte from buffer, buffer+=1
f;LDRB R2,[buff]                  ;check the next byte...
pBCMP R2,#&F7                     ;...to see if end of exclusive
zJADDNE R0,R0,R1                  ;if not EOX add previous to counter...
�HBNE count_loop                  ;...and loop back and continue count
�G� R0,R0,#&FF                  ;get bottom byte of accumulated count
�BADD R0,R0,R1                    ;add count and packet checksum
�D� R0,R0,#&7F                  ;delete top bit to finish checksum
�8LDMFD (sp)!,{PC}                ;return from routine
�
�.transmit_data
�BSTMFD (sp)!,{link}              ;store return address on stack
�@ADR buff,buffer                 ;get buffer address into R12
�.transmit_loop
�8MOV R0,#1                       ;1 = transmit buffer
�DSWI "MIDI_InqBufferSize"        ;inquire size of transmit buffer
�MCMP R0,#0                       ;check if no space available in buffer...
=BEQ transmit_loop               ;...and loop back if true
ILDRB R0,[buff],#1               ;get next byte to transmit, buffer+=1
4SWI "MIDI_TxByte"               ;...and transmit
$FCMP R0,#&F7                     ;check if end of exclusive data...
.<BNE transmit_loop               ;...and loop back if not
88LDMFD (sp)!,{PC}                ;return from routine
B
L
.data_end
V
EQUD 0
`.buffer
j�space(40*1024)
t]
~� pass%
��
�
�� reserve space in code
�ݤspace(bytes%)
�P%+=bytes%
�[OPT pass%
�	ALIGN
�]
�=""
�
���error
��12
�:�" at line ";�

�
�
00000000  0d 00 0a 10 f4 20 3e 20  4d 49 44 49 64 75 6d 70  |..... > MIDIdump|
00000010  0d 00 14 04 0d 00 1e 07  eb 31 32 0d 00 28 10 ee  |.........12..(..|
00000020  20 85 20 f2 65 72 72 6f  72 3a e0 0d 00 32 14 ff  | . .error:...2..|
00000030  22 52 4d 52 45 49 4e 49  54 20 4d 49 44 49 22 0d  |"RMREINIT MIDI".|
00000040  00 3c 0d f2 61 73 73 65  6d 62 6c 65 0d 00 46 04  |.<..assemble..F.|
00000050  0d 00 50 0d ff 22 46 58  32 31 2c 30 22 0d 00 5a  |..P.."FX21,0"..Z|
00000060  1e f1 22 31 2e 20 46 72  6f 6d 20 4d 49 44 49 20  |.."1. From MIDI |
00000070  69 6e 73 74 72 75 6d 65  6e 74 22 0d 00 64 1e f1  |instrument"..d..|
00000080  22 32 2e 20 54 6f 20 20  20 4d 49 44 49 20 69 6e  |"2. To   MIDI in|
00000090  73 74 72 75 6d 65 6e 74  22 0d 00 6e 14 f1 22 33  |strument"..n.."3|
000000a0  2e 20 4f 53 20 43 6f 6d  6d 61 6e 64 22 0d 00 78  |. OS Command"..x|
000000b0  1a f5 3a 4b 24 3d be 3a  fd 20 a7 22 31 32 33 22  |..:K$=.:. ."123"|
000000c0  2c 4b 24 29 3c 3e 30 0d  00 82 0e c8 8e 20 bb 28  |,K$)<>0...... .(|
000000d0  4b 24 29 20 ca 0d 00 8c  15 c9 20 31 20 3a f2 72  |K$) ...... 1 :.r|
000000e0  65 63 65 69 76 65 64 61  74 61 0d 00 96 16 c9 20  |eceivedata..... |
000000f0  32 20 3a f2 74 72 61 6e  73 6d 69 74 64 61 74 61  |2 :.transmitdata|
00000100  0d 00 a0 15 c9 20 33 20  3a f2 6f 73 63 6c 69 73  |..... 3 :.osclis|
00000110  63 72 65 65 6e 0d 00 aa  05 cb 0d 00 b4 04 0d 00  |creen...........|
00000120  be 05 f9 0d 00 c8 05 e0  0d 00 d2 04 0d 00 dc 11  |................|
00000130  dd f2 72 65 63 65 69 76  65 64 61 74 61 0d 00 e6  |..receivedata...|
00000140  05 f5 0d 00 f0 1f db 3a  f1 27 22 41 77 61 69 74  |.......:.'"Await|
00000150  69 6e 67 20 4d 49 44 49  20 64 61 74 61 2e 2e 2e  |ing MIDI data...|
00000160  22 0d 00 fa 1c 63 68 65  63 6b 73 75 6d 25 3d ba  |"....checksum%=.|
00000170  20 72 65 63 65 69 76 65  5f 64 61 74 61 0d 01 04  | receive_data...|
00000180  29 e7 20 63 68 65 63 6b  73 75 6d 25 3d 30 20 8c  |). checksum%=0 .|
00000190  20 69 6e 74 61 63 74 25  3d b9 20 8b 20 69 6e 74  | intact%=. . int|
000001a0  61 63 74 25 3d a3 0d 01  0e 36 e7 20 28 ac 20 69  |act%=....6. (. i|
000001b0  6e 74 61 63 74 25 29 20  db 3a ef 37 3a f1 22 4d  |ntact%) .:.7:."M|
000001c0  49 44 49 20 44 41 54 41  20 45 52 52 4f 52 20 21  |IDI DATA ERROR !|
000001d0  21 21 22 3a f5 20 fd 20  a5 3d 33 32 0d 01 18 0d  |!!":. . .=32....|
000001e0  fd 20 69 6e 74 61 63 74  25 0d 01 22 2e ef 37 3a  |. intact%.."..7:|
000001f0  f1 27 22 4d 49 44 49 20  64 61 74 61 20 69 6e 74  |.'"MIDI data int|
00000200  61 63 74 20 2d 20 6a 6f  6c 6c 79 20 67 6f 6f 64  |act - jolly good|
00000210  20 21 21 21 22 27 27 0d  01 2c 34 e8 22 45 6e 74  | !!!"''..,4."Ent|
00000220  65 72 20 66 75 6c 6c 20  70 61 74 68 2f 66 69 6c  |er full path/fil|
00000230  65 6e 61 6d 65 20 66 6f  72 20 73 61 76 65 20 2d  |ename for save -|
00000240  20 22 66 69 6c 65 6e 61  6d 65 24 0d 01 36 19 65  | "filename$..6.e|
00000250  6e 64 61 64 64 72 65 73  73 25 3d 21 64 61 74 61  |ndaddress%=!data|
00000260  5f 65 6e 64 0d 01 40 40  ff 22 53 41 56 45 20 22  |_end..@@."SAVE "|
00000270  2b 66 69 6c 65 6e 61 6d  65 24 2b 22 20 22 2b c3  |+filename$+" "+.|
00000280  7e 28 62 75 66 66 65 72  29 2b 22 20 22 2b c3 7e  |~(buffer)+" "+.~|
00000290  28 65 6e 64 61 64 64 72  65 73 73 25 29 2b 22 20  |(endaddress%)+" |
000002a0  30 20 30 22 0d 01 4a 05  e1 0d 01 54 04 0d 01 5e  |0 0"..J....T...^|
000002b0  12 dd f2 74 72 61 6e 73  6d 69 74 64 61 74 61 0d  |...transmitdata.|
000002c0  01 68 2b e8 22 45 6e 74  65 72 20 66 75 6c 6c 20  |.h+."Enter full |
000002d0  70 61 74 68 2f 66 69 6c  65 6e 61 6d 65 20 2d 20  |path/filename - |
000002e0  22 66 69 6c 65 6e 61 6d  65 24 0d 01 72 25 ff 22  |"filename$..r%."|
000002f0  4c 4f 41 44 20 22 2b 66  69 6c 65 6e 61 6d 65 24  |LOAD "+filename$|
00000300  2b 22 20 22 2b c3 7e 28  62 75 66 66 65 72 29 0d  |+" "+.~(buffer).|
00000310  01 7c 1e db 3a f1 27 22  53 65 6e 64 69 6e 67 20  |.|..:.'"Sending |
00000320  4d 49 44 49 20 64 61 74  61 2e 2e 2e 22 0d 01 86  |MIDI data..."...|
00000330  13 d6 20 74 72 61 6e 73  6d 69 74 5f 64 61 74 61  |.. transmit_data|
00000340  0d 01 90 14 f1 27 22 46  69 6e 69 73 68 65 64 20  |.....'"Finished |
00000350  21 21 21 22 0d 01 9a 05  e1 0d 01 a4 04 0d 01 ae  |!!!"............|
00000360  11 dd f2 6f 73 63 6c 69  73 63 72 65 65 6e 0d 01  |...oscliscreen..|
00000370  b8 05 db 0d 01 c2 12 e8  22 2a 22 6f 73 63 6f 6d  |........"*"oscom|
00000380  6d 61 6e 64 24 0d 01 cc  10 ff 20 6f 73 63 6f 6d  |mand$..... oscom|
00000390  6d 61 6e 64 24 0d 01 d6  22 f1 27 22 50 72 65 73  |mand$...".'"Pres|
000003a0  73 20 53 50 41 43 45 20  74 6f 20 63 6f 6e 74 69  |s SPACE to conti|
000003b0  6e 75 65 2e 2e 2e 22 0d  01 e0 0d ff 22 46 58 32  |nue..."....."FX2|
000003c0  31 2c 30 22 0d 01 ea 0c  f5 20 fd 20 a5 3d 33 32  |1,0"..... . .=32|
000003d0  0d 01 f4 05 e1 0d 01 fe  04 0d 02 08 0e dd f2 61  |...............a|
000003e0  73 73 65 6d 62 6c 65 0d  02 12 20 65 6e 64 3d 31  |ssemble... end=1|
000003f0  31 3a 62 75 66 66 3d 31  32 3a 73 70 3d 31 33 3a  |1:buff=12:sp=13:|
00000400  6c 69 6e 6b 3d 31 34 0d  02 1c 13 6c 65 6e 67 74  |link=14....lengt|
00000410  68 25 3d 35 30 2a 31 30  32 34 0d 02 26 13 de 20  |h%=50*1024..&.. |
00000420  63 6f 64 65 25 20 6c 65  6e 67 74 68 25 0d 02 30  |code% length%..0|
00000430  17 e3 20 70 61 73 73 25  3d 20 38 20 b8 20 31 30  |.. pass%= 8 . 10|
00000440  20 88 20 32 0d 02 3a 0c  50 25 3d 63 6f 64 65 25  | . 2..:.P%=code%|
00000450  0d 02 44 13 4c 25 3d 50  25 20 2b 20 6c 65 6e 67  |..D.L%=P% + leng|
00000460  74 68 25 0d 02 4e 0e 5b  4f 50 54 20 70 61 73 73  |th%..N.[OPT pass|
00000470  25 0d 02 58 11 2e 72 65  63 65 69 76 65 5f 64 61  |%..X..receive_da|
00000480  74 61 0d 02 62 43 53 54  4d 46 44 20 28 73 70 29  |ta..bCSTMFD (sp)|
00000490  21 2c 7b 6c 69 6e 6b 7d  20 20 20 20 20 20 20 20  |!,{link}        |
000004a0  20 20 20 20 20 20 3b 70  75 73 68 20 72 65 74 75  |      ;push retu|
000004b0  72 6e 20 61 64 64 72 65  73 73 20 6f 6e 74 6f 20  |rn address onto |
000004c0  73 74 61 63 6b 0d 02 6c  40 41 44 52 20 62 75 66  |stack..l@ADR buf|
000004d0  66 2c 62 75 66 66 65 72  20 20 20 20 20 20 20 20  |f,buffer        |
000004e0  20 20 20 20 20 20 20 20  20 3b 67 65 74 20 62 75  |         ;get bu|
000004f0  66 66 65 72 20 61 64 64  72 65 73 73 20 69 6e 74  |ffer address int|
00000500  6f 20 52 31 32 0d 02 76  14 2e 73 74 61 72 74 5f  |o R12..v..start_|
00000510  72 65 63 65 70 74 69 6f  6e 0d 02 80 34 4d 4f 56  |reception...4MOV|
00000520  20 52 30 2c 23 30 20 20  20 20 20 20 20 20 20 20  | R0,#0          |
00000530  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 73 65  |             ;se|
00000540  74 20 4d 49 44 49 20 70  6f 72 74 20 30 0d 02 8a  |t MIDI port 0...|
00000550  3f 53 57 49 20 22 4d 49  44 49 5f 52 78 42 79 74  |?SWI "MIDI_RxByt|
00000560  65 22 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |e"              |
00000570  20 3b 74 65 73 74 20 70  6f 72 74 20 30 20 72 65  | ;test port 0 re|
00000580  63 65 69 76 65 20 62 75  66 66 65 72 0d 02 94 3a  |ceive buffer...:|
00000590  80 20 52 30 2c 52 30 2c  23 26 46 46 20 20 20 20  |. R0,R0,#&FF    |
000005a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 6d  |              ;m|
000005b0  61 73 6b 20 6f 75 74 20  75 6e 77 61 6e 74 65 64  |ask out unwanted|
000005c0  20 62 79 74 65 73 0d 02  9e 3b 43 4d 50 20 52 30  | bytes...;CMP R0|
000005d0  2c 23 26 46 30 20 20 20  20 20 20 20 20 20 20 20  |,#&F0           |
000005e0  20 20 20 20 20 20 20 20  20 20 3b 63 68 65 63 6b  |          ;check|
000005f0  20 69 66 20 73 74 61 72  74 20 6f 66 20 c8 99 45  | if start of ..E|
00000600  58 0d 02 a8 41 42 4e 45  20 73 74 61 72 74 5f 72  |X...ABNE start_r|
00000610  65 63 65 70 74 69 6f 6e  20 20 20 20 20 20 20 20  |eception        |
00000620  20 20 20 20 20 3b 2e 2e  2e 61 6e 64 20 6c 6f 6f  |     ;...and loo|
00000630  70 20 62 61 63 6b 20 69  66 20 6e 6f 74 20 74 72  |p back if not tr|
00000640  75 65 0d 02 b2 4c 53 54  52 42 20 52 30 2c 5b 62  |ue...LSTRB R0,[b|
00000650  75 66 66 5d 2c 23 31 20  20 20 20 20 20 20 20 20  |uff],#1         |
00000660  20 20 20 20 20 20 3b 73  74 6f 72 65 20 26 46 30  |      ;store &F0|
00000670  20 61 74 20 73 74 61 72  74 20 6f 66 20 62 75 66  | at start of buf|
00000680  66 65 72 2c 20 62 75 66  66 65 72 2b 3d 31 0d 02  |fer, buffer+=1..|
00000690  bc 11 2e 72 65 63 65 69  76 65 5f 6c 6f 6f 70 0d  |...receive_loop.|
000006a0  02 c6 34 4d 4f 56 20 52  30 2c 23 30 20 20 20 20  |..4MOV R0,#0    |
000006b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000006c0  20 20 20 3b 73 65 74 20  4d 49 44 49 20 70 6f 72  |   ;set MIDI por|
000006d0  74 20 30 0d 02 d0 37 53  57 49 20 22 4d 49 44 49  |t 0...7SWI "MIDI|
000006e0  5f 52 78 42 79 74 65 22  20 20 20 20 20 20 20 20  |_RxByte"        |
000006f0  20 20 20 20 20 20 20 3b  74 65 73 74 20 70 6f 72  |       ;test por|
00000700  74 20 30 20 62 75 66 66  65 72 0d 02 da 3c 43 4d  |t 0 buffer...<CM|
00000710  50 20 52 30 2c 23 30 20  20 20 20 20 20 20 20 20  |P R0,#0         |
00000720  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 74  |              ;t|
00000730  65 73 74 20 69 66 20 62  75 66 66 65 72 20 65 6d  |est if buffer em|
00000740  70 74 79 2e 2e 2e 0d 02  e4 3d 42 45 51 20 72 65  |pty......=BEQ re|
00000750  63 65 69 76 65 5f 6c 6f  6f 70 20 20 20 20 20 20  |ceive_loop      |
00000760  20 20 20 20 20 20 20 20  20 20 3b 2e 2e 2e 61 6e  |          ;...an|
00000770  64 20 6c 6f 6f 70 20 62  61 63 6b 20 69 66 20 74  |d loop back if t|
00000780  72 75 65 0d 02 ee 3d 80  20 52 30 2c 52 30 2c 23  |rue...=. R0,R0,#|
00000790  26 46 46 20 20 20 20 20  20 20 20 20 20 20 20 20  |&FF             |
000007a0  20 20 20 20 20 3b 6d 61  73 6b 20 6f 75 74 20 75  |     ;mask out u|
000007b0  6e 77 61 6e 74 65 64 20  62 79 74 65 73 2e 2e 2e  |nwanted bytes...|
000007c0  0d 02 f8 4b 53 54 52 42  20 52 30 2c 5b 62 75 66  |...KSTRB R0,[buf|
000007d0  66 5d 2c 23 31 20 20 20  20 20 20 20 20 20 20 20  |f],#1           |
000007e0  20 20 20 20 3b 2e 2e 2e  61 6e 64 20 73 74 6f 72  |    ;...and stor|
000007f0  65 20 62 79 74 65 20 69  6e 20 62 75 66 66 65 72  |e byte in buffer|
00000800  2c 20 62 75 66 66 65 72  2b 3d 31 0d 03 02 39 43  |, buffer+=1...9C|
00000810  4d 50 20 52 30 2c 23 26  46 37 20 20 20 20 20 20  |MP R0,#&F7      |
00000820  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00000830  63 68 65 63 6b 20 69 66  20 65 6e 64 20 6f 66 20  |check if end of |
00000840  c8 99 45 58 0d 03 0c 41  42 4e 45 20 72 65 63 65  |..EX...ABNE rece|
00000850  69 76 65 5f 6c 6f 6f 70  20 20 20 20 20 20 20 20  |ive_loop        |
00000860  20 20 20 20 20 20 20 20  3b 2e 2e 2e 69 66 20 6e  |        ;...if n|
00000870  6f 74 20 63 6f 6e 74 69  6e 75 65 20 72 65 63 65  |ot continue rece|
00000880  70 74 69 6f 6e 0d 03 16  4b 41 44 52 20 65 6e 64  |ption...KADR end|
00000890  2c 64 61 74 61 5f 65 6e  64 20 20 20 20 20 20 20  |,data_end       |
000008a0  20 20 20 20 20 20 20 20  20 3b 67 65 74 20 61 64  |         ;get ad|
000008b0  64 72 65 73 73 20 6f 66  20 64 61 74 61 5f 65 6e  |dress of data_en|
000008c0  64 20 73 74 6f 72 65 20  69 6e 74 6f 20 52 31 31  |d store into R11|
000008d0  0d 03 20 48 53 54 52 20  62 75 66 66 2c 5b 65 6e  |.. HSTR buff,[en|
000008e0  64 5d 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |d]              |
000008f0  20 20 20 20 3b 73 74 6f  72 65 20 64 61 74 61 20  |    ;store data |
00000900  65 6e 64 20 61 64 64 72  65 73 73 20 69 6e 20 2e  |end address in .|
00000910  64 61 74 61 5f 65 6e 64  0d 03 2a 0f 2e 63 6f 75  |data_end..*..cou|
00000920  6e 74 5f 64 61 74 61 0d  03 34 43 41 44 52 20 62  |nt_data..4CADR b|
00000930  75 66 66 2c 62 75 66 66  65 72 20 20 20 20 20 20  |uff,buffer      |
00000940  20 20 20 20 20 20 20 20  20 20 20 3b 67 65 74 20  |           ;get |
00000950  64 61 74 61 20 62 75 66  66 65 72 20 61 64 64 72  |data buffer addr|
00000960  65 73 73 20 69 6e 20 52  31 32 0d 03 3e 4c 41 44  |ess in R12..>LAD|
00000970  44 20 62 75 66 66 2c 62  75 66 66 2c 23 36 20 20  |D buff,buff,#6  |
00000980  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 61  |              ;a|
00000990  64 64 20 6f 66 66 73 65  74 20 74 6f 20 73 74 61  |dd offset to sta|
000009a0  72 74 20 63 6f 75 6e 74  20 66 72 6f 6d 20 28 59  |rt count from (Y|
000009b0  61 6d 61 68 61 29 0d 03  48 38 4d 4f 56 20 52 30  |amaha)..H8MOV R0|
000009c0  2c 23 30 20 20 20 20 20  20 20 20 20 20 20 20 20  |,#0             |
000009d0  20 20 20 20 20 20 20 20  20 20 3b 73 65 74 20 63  |          ;set c|
000009e0  6f 75 6e 74 65 72 20 74  6f 20 7a 65 72 6f 0d 03  |ounter to zero..|
000009f0  52 0f 2e 63 6f 75 6e 74  5f 6c 6f 6f 70 0d 03 5c  |R..count_loop..\|
00000a00  49 4c 44 52 42 20 52 31  2c 5b 62 75 66 66 5d 2c  |ILDRB R1,[buff],|
00000a10  23 31 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |#1              |
00000a20  20 3b 67 65 74 20 6e 65  78 74 20 62 79 74 65 20  | ;get next byte |
00000a30  66 72 6f 6d 20 62 75 66  66 65 72 2c 20 62 75 66  |from buffer, buf|
00000a40  66 65 72 2b 3d 31 0d 03  66 3b 4c 44 52 42 20 52  |fer+=1..f;LDRB R|
00000a50  32 2c 5b 62 75 66 66 5d  20 20 20 20 20 20 20 20  |2,[buff]        |
00000a60  20 20 20 20 20 20 20 20  20 20 3b 63 68 65 63 6b  |          ;check|
00000a70  20 74 68 65 20 6e 65 78  74 20 62 79 74 65 2e 2e  | the next byte..|
00000a80  2e 0d 03 70 42 43 4d 50  20 52 32 2c 23 26 46 37  |...pBCMP R2,#&F7|
00000a90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000aa0  20 20 20 20 20 3b 2e 2e  2e 74 6f 20 73 65 65 20  |     ;...to see |
00000ab0  69 66 20 65 6e 64 20 6f  66 20 65 78 63 6c 75 73  |if end of exclus|
00000ac0  69 76 65 0d 03 7a 4a 41  44 44 4e 45 20 52 30 2c  |ive..zJADDNE R0,|
00000ad0  52 30 2c 52 31 20 20 20  20 20 20 20 20 20 20 20  |R0,R1           |
00000ae0  20 20 20 20 20 20 20 3b  69 66 20 6e 6f 74 20 45  |       ;if not E|
00000af0  4f 58 20 61 64 64 20 70  72 65 76 69 6f 75 73 20  |OX add previous |
00000b00  74 6f 20 63 6f 75 6e 74  65 72 2e 2e 2e 0d 03 84  |to counter......|
00000b10  48 42 4e 45 20 63 6f 75  6e 74 5f 6c 6f 6f 70 20  |HBNE count_loop |
00000b20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000b30  20 3b 2e 2e 2e 61 6e 64  20 6c 6f 6f 70 20 62 61  | ;...and loop ba|
00000b40  63 6b 20 61 6e 64 20 63  6f 6e 74 69 6e 75 65 20  |ck and continue |
00000b50  63 6f 75 6e 74 0d 03 8e  47 80 20 52 30 2c 52 30  |count...G. R0,R0|
00000b60  2c 23 26 46 46 20 20 20  20 20 20 20 20 20 20 20  |,#&FF           |
00000b70  20 20 20 20 20 20 20 3b  67 65 74 20 62 6f 74 74  |       ;get bott|
00000b80  6f 6d 20 62 79 74 65 20  6f 66 20 61 63 63 75 6d  |om byte of accum|
00000b90  75 6c 61 74 65 64 20 63  6f 75 6e 74 0d 03 98 42  |ulated count...B|
00000ba0  41 44 44 20 52 30 2c 52  30 2c 52 31 20 20 20 20  |ADD R0,R0,R1    |
00000bb0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000bc0  3b 61 64 64 20 63 6f 75  6e 74 20 61 6e 64 20 70  |;add count and p|
00000bd0  61 63 6b 65 74 20 63 68  65 63 6b 73 75 6d 0d 03  |acket checksum..|
00000be0  a2 44 80 20 52 30 2c 52  30 2c 23 26 37 46 20 20  |.D. R0,R0,#&7F  |
00000bf0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000c00  3b 64 65 6c 65 74 65 20  74 6f 70 20 62 69 74 20  |;delete top bit |
00000c10  74 6f 20 66 69 6e 69 73  68 20 63 68 65 63 6b 73  |to finish checks|
00000c20  75 6d 0d 03 ac 38 4c 44  4d 46 44 20 28 73 70 29  |um...8LDMFD (sp)|
00000c30  21 2c 7b 50 43 7d 20 20  20 20 20 20 20 20 20 20  |!,{PC}          |
00000c40  20 20 20 20 20 20 3b 72  65 74 75 72 6e 20 66 72  |      ;return fr|
00000c50  6f 6d 20 72 6f 75 74 69  6e 65 0d 03 b6 04 0d 03  |om routine......|
00000c60  c0 12 2e 74 72 61 6e 73  6d 69 74 5f 64 61 74 61  |...transmit_data|
00000c70  0d 03 ca 42 53 54 4d 46  44 20 28 73 70 29 21 2c  |...BSTMFD (sp)!,|
00000c80  7b 6c 69 6e 6b 7d 20 20  20 20 20 20 20 20 20 20  |{link}          |
00000c90  20 20 20 20 3b 73 74 6f  72 65 20 72 65 74 75 72  |    ;store retur|
00000ca0  6e 20 61 64 64 72 65 73  73 20 6f 6e 20 73 74 61  |n address on sta|
00000cb0  63 6b 0d 03 d4 40 41 44  52 20 62 75 66 66 2c 62  |ck...@ADR buff,b|
00000cc0  75 66 66 65 72 20 20 20  20 20 20 20 20 20 20 20  |uffer           |
00000cd0  20 20 20 20 20 20 3b 67  65 74 20 62 75 66 66 65  |      ;get buffe|
00000ce0  72 20 61 64 64 72 65 73  73 20 69 6e 74 6f 20 52  |r address into R|
00000cf0  31 32 0d 03 de 12 2e 74  72 61 6e 73 6d 69 74 5f  |12.....transmit_|
00000d00  6c 6f 6f 70 0d 03 e8 38  4d 4f 56 20 52 30 2c 23  |loop...8MOV R0,#|
00000d10  31 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |1               |
00000d20  20 20 20 20 20 20 20 20  3b 31 20 3d 20 74 72 61  |        ;1 = tra|
00000d30  6e 73 6d 69 74 20 62 75  66 66 65 72 0d 03 f2 44  |nsmit buffer...D|
00000d40  53 57 49 20 22 4d 49 44  49 5f 49 6e 71 42 75 66  |SWI "MIDI_InqBuf|
00000d50  66 65 72 53 69 7a 65 22  20 20 20 20 20 20 20 20  |ferSize"        |
00000d60  3b 69 6e 71 75 69 72 65  20 73 69 7a 65 20 6f 66  |;inquire size of|
00000d70  20 74 72 61 6e 73 6d 69  74 20 62 75 66 66 65 72  | transmit buffer|
00000d80  0d 03 fc 4d 43 4d 50 20  52 30 2c 23 30 20 20 20  |...MCMP R0,#0   |
00000d90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000da0  20 20 20 20 3b 63 68 65  63 6b 20 69 66 20 6e 6f  |    ;check if no|
00000db0  20 73 70 61 63 65 20 61  76 61 69 6c 61 62 6c 65  | space available|
00000dc0  20 69 6e 20 62 75 66 66  65 72 2e 2e 2e 0d 04 06  | in buffer......|
00000dd0  3d 42 45 51 20 74 72 61  6e 73 6d 69 74 5f 6c 6f  |=BEQ transmit_lo|
00000de0  6f 70 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |op              |
00000df0  20 3b 2e 2e 2e 61 6e 64  20 6c 6f 6f 70 20 62 61  | ;...and loop ba|
00000e00  63 6b 20 69 66 20 74 72  75 65 0d 04 10 49 4c 44  |ck if true...ILD|
00000e10  52 42 20 52 30 2c 5b 62  75 66 66 5d 2c 23 31 20  |RB R0,[buff],#1 |
00000e20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 67  |              ;g|
00000e30  65 74 20 6e 65 78 74 20  62 79 74 65 20 74 6f 20  |et next byte to |
00000e40  74 72 61 6e 73 6d 69 74  2c 20 62 75 66 66 65 72  |transmit, buffer|
00000e50  2b 3d 31 0d 04 1a 34 53  57 49 20 22 4d 49 44 49  |+=1...4SWI "MIDI|
00000e60  5f 54 78 42 79 74 65 22  20 20 20 20 20 20 20 20  |_TxByte"        |
00000e70  20 20 20 20 20 20 20 3b  2e 2e 2e 61 6e 64 20 74  |       ;...and t|
00000e80  72 61 6e 73 6d 69 74 0d  04 24 46 43 4d 50 20 52  |ransmit..$FCMP R|
00000e90  30 2c 23 26 46 37 20 20  20 20 20 20 20 20 20 20  |0,#&F7          |
00000ea0  20 20 20 20 20 20 20 20  20 20 20 3b 63 68 65 63  |           ;chec|
00000eb0  6b 20 69 66 20 65 6e 64  20 6f 66 20 65 78 63 6c  |k if end of excl|
00000ec0  75 73 69 76 65 20 64 61  74 61 2e 2e 2e 0d 04 2e  |usive data......|
00000ed0  3c 42 4e 45 20 74 72 61  6e 73 6d 69 74 5f 6c 6f  |<BNE transmit_lo|
00000ee0  6f 70 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |op              |
00000ef0  20 3b 2e 2e 2e 61 6e 64  20 6c 6f 6f 70 20 62 61  | ;...and loop ba|
00000f00  63 6b 20 69 66 20 6e 6f  74 0d 04 38 38 4c 44 4d  |ck if not..88LDM|
00000f10  46 44 20 28 73 70 29 21  2c 7b 50 43 7d 20 20 20  |FD (sp)!,{PC}   |
00000f20  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 72 65  |             ;re|
00000f30  74 75 72 6e 20 66 72 6f  6d 20 72 6f 75 74 69 6e  |turn from routin|
00000f40  65 0d 04 42 04 0d 04 4c  0d 2e 64 61 74 61 5f 65  |e..B...L..data_e|
00000f50  6e 64 0d 04 56 0a 45 51  55 44 20 30 0d 04 60 0b  |nd..V.EQUD 0..`.|
00000f60  2e 62 75 66 66 65 72 0d  04 6a 13 a4 73 70 61 63  |.buffer..j..spac|
00000f70  65 28 34 30 2a 31 30 32  34 29 0d 04 74 05 5d 0d  |e(40*1024)..t.].|
00000f80  04 7e 0b ed 20 70 61 73  73 25 0d 04 88 05 e1 0d  |.~.. pass%......|
00000f90  04 92 04 0d 04 9c 1b f4  20 72 65 73 65 72 76 65  |........ reserve|
00000fa0  20 73 70 61 63 65 20 69  6e 20 63 6f 64 65 0d 04  | space in code..|
00000fb0  a6 13 dd a4 73 70 61 63  65 28 62 79 74 65 73 25  |....space(bytes%|
00000fc0  29 0d 04 b0 0e 50 25 2b  3d 62 79 74 65 73 25 0d  |)....P%+=bytes%.|
00000fd0  04 ba 0e 5b 4f 50 54 20  70 61 73 73 25 0d 04 c4  |...[OPT pass%...|
00000fe0  09 41 4c 49 47 4e 0d 04  ce 05 5d 0d 04 d8 07 3d  |.ALIGN....]....=|
00000ff0  22 22 0d 04 e2 04 0d 04  ec 0b dd f2 65 72 72 6f  |""..........erro|
00001000  72 0d 04 f6 07 eb 31 32  0d 05 00 14 f6 3a f1 22  |r.....12.....:."|
00001010  20 61 74 20 6c 69 6e 65  20 22 3b 9e 0d 05 0a 05  | at line ";.....|
00001020  e1 0d ff                                          |...|
00001023