-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsbcmon.mac
More file actions
4278 lines (3499 loc) · 92.5 KB
/
sbcmon.mac
File metadata and controls
4278 lines (3499 loc) · 92.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; **** NOTE: Simon uses a few bytes at F000h, and the Votrax
; SPEAK software uses 400 bytes at F100H (outbuf)
; declared in speak.mac), so these should be changed
; when cp/m plus is installed!!
; ---------------------------------------------------------------
.comment\
**************************************************************
* *
* Z80 Control System For Colossus Computer *
* 02/14/87 - Version 2.4 *
* By RCL9 *
* (Rob's Retro Computing Archive) *
* RetroComputingArchive@gmail.com *
* github.com/rcl9 *
* *
**************************************************************
2.4 (03/12/87)
Moved Keyboard NMI to Sio-SyncA line instead.
Added Votrax Speach Synthesizer driver and tables.
Added Lcd driver.
2.3 (02/27/87)
Took bug out of RST$IO$DRIVER, ld a,b/ld b,a instead of push/pop af
Put hooks in for LCD.MAC driver written for pmon.mac.
2.2 (02/14/87)
Added disk I/O and made compatible with Cypher's monitor roms.
Deleted all the RST vectors - use vector table in static ram now.
Added Centronics parallel port driver.
Added RS-232, MIDI and Centronics vector entry point drivers.
2.1 (10/03/86)
Made it compile with Z80ASM.COM & L80.COM
2.0 (01/08/86)
Added real time clock driver
1.9 (12/22/85)
Made simon game an external file
Made keyboard definition tables external
Added Midi and RS-232 Transmit Interrupts
1.8 (11/29/85)
Added Auxiliary board equates
Wrote Simon game for Universal I/O Port
Added Auxiliary board initializations
Wrote Keyboard and Keypad driver
Wrote LED driver
Wrote LCD driver
1.7 (11/14/85)
Added drum pad dispatching software
1.6 (11/06/85)
Added PIO interrupt handler for drum pad inputs
1.5 (10/11/85)
Added Midi sub-menu and xmodem capability
1.4 (09/14/85)
Started work on Keyboard Interrupt driver.
Setup LED display parameters
1.3 (09/09/85)
Added interrupt & buffering routines to SIO (Midi + RS-232)
1.2 (09/01/85)
Got rid of music synthesizer software (dacsynth.mac)
Converted to new hardware memory map.
Coverted SIO I/O to 8253 timer.
Programmed SIO Channel B for Midi (no interrupts yet).
1.1 (04/??/85)
Converted to music synth. (piano using 2 DACS)
1.0 (03/12/85)
Initial version for hardware debugging. \
extrn votrax ; entry point to text to english converter
extrn speak ; entry point to speak a line of text at (SP)
extrn sc01$init ; initialization routines for votrax chip
extrn send$sc01 ; send A to Votrax speech chip
extrn xmodem ; entry point to xmodem send/receive
extrn play$simon ; entry point to simon game
extrn lcd$table ; lcd function address jump table
include A:PUBLICS.MAC
; ------conditional compilation------
true equ 0ffffh
false equ not true
yes equ true
no equ false
eot equ 04h
cr equ 0dh
lf equ 0ah
bs equ 08h
esc equ 01bh
tab equ 09h
.comment\
-----------------------------------
Colossus Memory Map
-----------------------------------
fff0-ffff Special monitor jump table
Midi receive error flag
ffd0-ffef CTC, PIO, NMI, SIO interrupt vectors
ffb0-ffcf Temporary stack for BSWTCH routine
ff00-ffaf Monitor stack area
ff00-ff7f Default DMA disk buffer (dbuf)
fd00-feff Monitor data variables, input buffers etc (top at 0fed0h at last check)
fc00-fcff 256 Byte MIDI Input buffer
f9e0-fbff Common SRAM disk and bank switch routines \
; ---- Flag Equates ----
; the next two are used by the MIDI$RECEIVE$ERROR flag
buffer$overrun$error equ 1 ; Midi input buffer has over-flowed
rec$overrun$error equ 2 ; Midi SIO input has overran
; ---- variables used in the monitor ----
mem$bot equ 0f000h
mem$top equ 0ffffh ; only 4k of static ram
beprom equ 0feh ; eprom bank (its really a bit flag, but this
; value is used for compatibility with Cypher monitor)
dbuf equ mem$top - 0ffh ; default dma buffer
sram equ 0f9e0h ; start of the common sram disk and bank switch routines
; ---- Static memory data variables ----
mwa$length equ 0200h ; 512 bytes long
midi$input$buffer equ mem$top - 03ffh ; 255 byte Midi Input buffer
midi$q$length equ 0ffh ; receive queue length
midi$send$q$length equ 40h ; send queue length
rs232$q$length equ 20 ; 20 bytes for Serial input buffer
rs232$send$q$length equ 20 ; serial output buffer
mwa equ mem$top - 2ffh
spsave equ mwa ; stack pointer save for BSWTCH routine
thl equ spsave + 2 ; register HL save for BSWTCH routine
ta equ thl + 2 ; register A save for BSWTCH routine
density equ ta + 1 ; density of disk
side equ density + 1 ; next disk access side
speed equ side + 1 ; seek speed for disk i/o
secsz equ speed + 1 ; sector size for next disk access
dmadr equ secsz + 2 ; default dma buffer address
trktab equ dmadr + 2 ; table of drive head positions
diskno equ trktab + 2 ; current drive
trackno equ diskno + 1 ; current track
sectno equ trackno + 1 ; current sector
retryno equ sectno + 1 ; retry counter
errorst equ retryno + 1 ; error status
param1 equ errorst + 1 ; monitor command parameters
param2 equ param1 + 2
param3 equ param2 + 2
last equ param3 + 2 ; last address used by mem dump
escflg equ last + 2 ; console escape flag
linbuf equ escflg + 1 ; console input line buffer
rs232$input$buffer equ linbuf + 80h
rs232$q$start equ rs232$input$buffer + rs232$q$length ; word pointer
rs232$q$end equ rs232$q$start + 2 ; queue end pointer
rs232$bytes$in$q equ rs232$q$end + 2 ; how many bytes that are in the queue
midi$q$start equ rs232$bytes$in$q + 1 ; word pointer
midi$q$end equ midi$q$start + 2 ; queue end pointer
midi$bytes$in$q equ midi$q$end + 2 ; how many bytes that are in the queue
midi$receive$error equ midi$bytes$in$q + 1 ; true if buffer overrrun
config$image equ midi$receive$error + 1 ; memory image of configuration port last output byte
; the following are the xmodem memory variables
optsav equ config$image + 1
crcflg equ optsav + 1 ;sets to 'C' if checksum requested
crcval equ crcflg + 1 ;current CRC value
errcde equ crcval + 2 ;receive error code
errct equ errcde + 1 ;error count
frstim equ errct + 1 ;turned on after first 'SOH' received
rcvrno equ frstim + 1 ;record number received
recdno equ rcvrno + 1 ;current record number
recptr equ recdno + 2 ;start of transfer in memory
length equ recptr + 2 ;length of transfer
retaddr equ length + 2 ;return address for calling routine (2 bytes long)
; Lcd Equates for LCD.MAC driver
l1 equ retaddr + 2 ; lcd line 1 memory image
l2 equ l1 + 80 ; lcd line 2 memory image
lcd$column equ l2 + 80 ; last column (0-79) accessed
lcd$line equ lcd$column + 1 ; last lcd row accessed (0-1)
lcd$cr equ lcd$line + 1 ; current lcd control register
lcd$dr equ lcd$cr + 1 ; current lcd data register
split equ lcd$dr + 1 ; lcd split(1)/full-screen(0) mode
lcd$rs232 equ split + 1 ; I/O to lcd/keypad (0) or to RS-232 (1)
; Votrax Speech Synthesizer Variables
port25$image equ lcd$rs232 + 1
inflec equ port25$image + 1
lrflag equ inflec + 1
saveix equ lrflag + 1
ixptr equ saveix + 2
drum$tbl$addr equ ixptr + 2 ; address of drum pads and footswitch voice addresses
rs232$send$buffer equ drum$tbl$addr + 2
rs232$send$q$start equ rs232$send$buffer + rs232$send$q$length ; word pointer
rs232$send$q$end equ rs232$send$q$start + 2 ; queue end pointer
rs232$send$bytes$in$q equ rs232$send$q$end + 2 ; how many bytes that are in the queue
midi$send$buffer equ rs232$send$bytes$in$q + 1
midi$send$q$start equ midi$send$buffer + midi$send$q$length ; word pointer
midi$send$q$end equ midi$send$q$start + 2 ; queue end pointer
midi$send$bytes$in$q equ midi$send$q$end + 2 ; how many bytes that are in the queue
end$of$variables equ midi$send$bytes$in$q + 1
; ------ ctc timers ---------
ctc$a equ 00h ; ctc channel a
ctc$b equ 01h ; ctc channel b
ctc$c equ 02h ; ctc channel c
ctc$d equ 03h ; ctc channel d
; ------ parallel ports -----
pa$data equ 04h ; pio port a data register
pa$ctrl equ 06h ; pio port a control register
pb$data equ 05h ; pio port b data register
pb$ctrl equ 07h ; pio port b control register
; ------ keyboard driver ------
key$data equ 8 ; data register
key$ctrl equ 9 ; control register
keybd$int$enable equ 01000000B ; 8279 interrupt enable
keybd$release equ 00100000B
rom$ram$switch equ 10000000B
; ---- configuration ports -------
config equ 0bh ; output config port.
switches equ 0bh ; dip switch input port
; ----- serial ports -----
sio$a$data equ 0ch ; sio channel a i/o
sio$a$ctrl equ 0eh
sio$b$data equ 0dh ; sio channel b i/o
sio$b$ctrl equ 0fh
; ----- 8253 SIO Baudrate Generators -----
counter$0 equ 10h ; 8253 channel 1 counter
counter$1 equ 11h ; 8253 channel 2 counter
counter$2 equ 12h ; 8253 channel 3 counter
counter$ctrl equ 13h ; 8253 Control register
; ----- 8255 Parallel Ports -----
pio$a$8255 equ 020h ; port a data i/o
pio$b$8255 equ 021h ; port b data i/o
pio$c$8255 equ 022h ; port c data i/o
pio$ctrl$8255 equ 023h ; control register
; Centronics port equates (uses port A and C of 8255)
auto$ff equ 1 ; = 1 if dont want auto-ff on Epson printer
; = 0 if want auto-ff after cr
cen$init$val equ 136 ; 8255 initialization constant
; A, B, C lower = output, C upper = input
; ----- Votrax Speech Synthesizer -----
sc01_base equ 024h ; base of SC01 chip ports
; ----- Lcd Interface -----
; See LCD.MAC for Lcd Equates
; ----- Real Time Clock -----
clock$base equ 030h ; 24 I/O port addresses
; ----- 2797 Floppy Disk Controller -----
wd2797 equ 048H ; 2797 base port address
stsreg equ wd2797+0 ; status register
cmdreg equ wd2797+0 ; command register
trkreg equ wd2797+1 ; track register
secreg equ wd2797+2 ; sector register
datreg equ wd2797+3 ; data register
; =-=-=-=-=-=-=-=-= start of main program =-=-=-=-=-=-=-=-=-=
start: org 0000
; -- MONITOR ENTRY POINT TABLE --
cold: jp init ; 1 Monitor cold entry point
warm: jp prompt ; 2 Monitor warm entry point
jp rst$io$driver ; 3 Centronics, LCD and LED dispatcher
jp rst$rs232$driver ; 4 I/O to the Sio, channels A - Console I/O, Keyboard input
jp rst$midi$driver ; 5 I/O to Sio channel B - Midi I/O
jp rst$system$driver ; 6 Odd system functions
; the following 5 vectors are disk related. They reside in SRAM, so dont use
; this table to call them.
jp prompt ; 7 (Select) SELECT DISK DRIVE <c>
jp prompt ; 8 (Home) HOME R/W HEAD
jp prompt ; 9 (Seek) SEEK TO TRACK <c>, speed <b>
jp prompt ; 10 (Read) READ SECTOR <c>, <hl> = dma
jp prompt ; 11 (Write) WRITE SECTOR <c>, <hl> = dma
jp setdens ; 12 set disk type (postponed until select)
; <hl> = sector size (128, 256, 512, 1024)
; <d> = disk type (5 or 8)
; <e> = density (1 or 2)
jp getsad ; 13 Return <c> = sector size code,
; <d> = track, <e> = side from sector
; address header
jp setside ; 14 set side <c> (0 or 1)
jp swbank ; 15 switch memory bank to <A>, 0-15 (ram) or 0fe (eprom)
; ** interrupts will be re-enabled !!!
; ## the relocated vector table for the static ram is located near the
; ## end of this program.
; ------ No NMI Interrtupt Currently Used -----
; NMI Interrupt can't be used because it would crash if a normal
; interrupt had changed the bank number!
org 66h
nmi: retn
;nmi: jp keynmi + mem$top - vec$length + 1
; ------- interrupt vector table moved to top of ram --------
vec$start equ $
.phase 0 ; all references relative to 'vec$abs$mem$loc' now
; --> ctcvec0 must start at ffd0h - No vectors defined yet
ctcvec0: defw return
ctcvec1: defw return ; return from interrupt
ctcvec2: defw return ; send out sample address
ctcvec3: defw return
; --> piovec1 must start at ffd8h - No vectors defined yet
pio$vectors equ 0ffd8h
piovec1: defw return
piovec2: defw return
; Some empty space in the table
empty: defs 4
; --> Siovec1 must start at ffe0h
sio$vectors equ 0ffe0h
siovec1: defw midi$int$send ; Ch B Transmit Buffer empty
siovec2: defw return ; CH B Ext/Status change
siovec3: defw midi$handler ; Ch B Recieve character available
siovec4: defw midi$error ; Ch B Parity, Rx overrrun, framing errors
siovec5: defw rs232$int$send ; Ch A Transmit Buffer empty
siovec6: defw rs232$ext$stat ; CH A Ext/Status change
siovec7: defw rs232$handler ; Ch A Recieve character available
siovec8: defw rs232$error ; Ch A Parity, Rx overrrun, framing errors
; --> These are the Specialized monitor routine vectors
return equ 0fff0h ; address of next 2 byte instruction
reti ; dummy service routine
; when the footswitch is hit, the Pio interrupt routine
; recognizes it and calls this vector. Registers a,bc,de,hl
; can be killed, and you must do a return (this is dispatched
; in the middle if the interrupt routine).
footswitch$vector equ 0fff2h
ret
defs 2
; this is the same as the footswitch$vector except that the
; Pio interrupt routine jumps here if one of the 8 pads are
; hit.
drumpad$vector equ 0fff5h
ret
defs 2
mon$vec3 equ 0fff8h
ret
defs 2
mon$vec4 equ 0fffbh
ret
defs 2
db 00 ; fffeh (### empty space ###)
bank equ 0ffffh ; this is the current bank number
db 00
.dephase
vec$length equ $ - vec$start
vec$tbl$abs$loc equ mem$top - vec$length + 1
; ---------------- Define stack locations --------------------
lstack equ mem$top - vec$length ; BSWTCH stack under the vector table
mstack equ mem$top - vec$length-20h
; ----------------- Initialize computer ----------------------
init: di
ld a,0ffh ; set up interrupt vector
ld i,a
im 2 ; set z80 to interrupt mode 2
; clear MWA RAM memory to zero.
xor a
ld (mwa),a
ld hl,mwa
ld de,mwa+1
ld bc,mwa$length -1
ldir
; move bank switch jump table to static ram (this has to go before any other code)
ld hl,s$code ; point to jump vector table
ld de,sram ; move it to jump vector location
ld bc,veclen
ldir ; go move it
; setup configuration output port status
ld a,0 ; default to 0
ld (config$image),a
out (config),a
ld a,beprom ; make sure the system knows we are in
call swbank ; the eprom bank for now...
; move interrupt vector table to top of memory
ld hl,vec$start
ld de,vec$tbl$abs$loc
ld bc,vec$length
ldir
; make monitor's stack
ld sp,mstack
; initialize the RS-232 buffer & midi buffer pointers
call clear$rs232$buffers
call clear$midi$buffers
; ----- initialize keyboard and video driver -------
ld a,02ah ; set chip clock to 100khz
out (key$ctrl),a
ld a,00000010B ; N-key rollover, encoded scan
; 8 8-bit right left character display
out (key$ctrl),a
ld a,(config$image) ; get last byte output to configuration port
or keybd$int$enable
ld (config$image),a
out (config),a ; and enable 8270 NMI interrupts
ld a,11011111B ; clear display & fifo & interrupt line
out (key$ctrl),a
; --> must not send out another byte to key$ctrl
; --> for 160 usec after the clear display command
; ----- Initialize the LCD display
ld c,8 ; Lcd initialization routines
call rst$io$driver
ld a,0ffh
ld (lcd$rs232),a ; default to RS232 output first
; ------ initialize CTC Timers for Serial Port A -----
; --> no initialization at present. The timers can be
; used for interruptable utility timers.
; ------ Initialize 8253 SIO Baudrates for Channels A & B
in a,(switches) ; get power-on baudrate
and 0fh
call setbd1
; now program SIO Channel B for 31.25kbaud MIDI
ld a,77h ; select channel 1
out (counter$ctrl),a
ld a,04 ; program for 31.25 kbaud
out (counter$1),a
ld a,0
out (counter$1),a
; ----- initialize z-sio serial --------
; initialize SIO A registers
ld c,sio$a$ctrl
ld b,tbl$a$length
ld hl,sio$a$tbl
otir ; send to SIO A control register
; initialize SIO B, and the interrupt vector
ld c,sio$b$ctrl
ld b,tbl$b$length
ld hl,sio$b$tbl
otir ; send to SIO A control register
ei
jp inipio ; go init z80 pio
sio$a$tbl: defb 18H ; channel reset
defb 00010000B ; reset EXT/Status interrupts
defb 4 ; select Write register 4
defb 4CH ; 16x clock, 2 stop bits, no parity
defb 3 ; Select write register 3
defb 0C1H ; 8 data bits, Rx Enable only
defb 5 ; Select write register 5
defb 01101000B ; enable Tx, Tx 8 bits
defb 00010000B ; reset EXT/Status interrupts
defb 1
defb 00011111B ; status affects vector
; Tx INT enable, EXT INT enable
; INT on all received characters
tbl$a$length equ $ - sio$a$tbl
sio$b$tbl: defb 18H ; channel reset
defb 2 ; program the interrupt vector
defb sio$vectors - ((sio$vectors / 256) * 256) ; send LSB of vector address
defb 00010000B ; reset EXT/Status interrupts
defb 4 ; select Write register 4
defb 4CH ; 16x clock, 2 stop bits, no parity
defb 3 ; Select write register 3
defb 0C1H ; 8 data bits, Rx Enable only
defb 5 ; Select write register 5
defb 01101000B ; enable Tx, Tx 8 bits
defb 00010000B ; reset EXT/Status interrupts
defb 1
defb 00011110B ; status affects vector,
; Tx INT enable, EXT INT disable
; INT on all received characters
tbl$b$length equ $ - sio$b$tbl
; ----- initialize parallel z80pio -------
inipio: ld a,11001111b ; select input mode 3
out (pa$ctrl),a
ld a,0ffh ; set bits to input
out (pa$ctrl),a
ld a,00000111b ; disable bit interrupt
out (pa$ctrl),a
ld a,11001111b ; select input mode 3
out (pb$ctrl),a
ld a,0ffh ; set bits to input
out (pb$ctrl),a
ld a,00000111b ; disable bit interrupt
out (pb$ctrl),a
; ----- initialize 8255 I/O Ports -----
ld a,137 ; set A & B to output
out (pio$ctrl$8255),a ; and Port C to input
ld a,0ffh
out (pio$a$8255),a ; send 255 to turn off simon game
; ----- initialize disk drive characteristics -----
ld a,0c3h ; make drive selects in-active & motor off,
; Sasi reset* and select* in-active
out (pio$b$8255),a
ld hl,dbuf
ld (dmadr),hl ; setup default dma address
ld a,1 ; (0=3ms, 1=6ms, 2=10ms or 3=15ms)
ld (speed),a ; set default speed
ld hl,200h ; boot up on 5" double density
ld e,2
call setdens ;set sector size,disk type,density
xor a
ld (side),a ; default to side 0
ld c,a ;select side 0
call setside ;ensure side zero
; ----- Initialize Votrax Speech Synthesizer -----
call sc01$init ; call routine in speak.mac
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; Resident Z80 Monitor
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
zmon: ei
gopr: call print$string
defm cr,lf,'Colossus Z-80 Monitor. Version 2.4. Copyright (c) April 12, 1987 by RCL9',cr,lf,eot
ld a,(lcd$rs232)
or a
jr z,sayit ; don't print time and date if LCD display
call snd$timdat ; print time and date
sayit: call speak
defm 'READY',eot
prompt: call print$string
defm 'Z80> ',eot
ld hl,linbuf
ld c,78 ;allow 78 characters input
call getlin ;input a bufered console line
jr c,prompt ;goto prompt if control codes
xor a
ld (escflg),a
call crlf
ld a,(linbuf) ;get first character in line
cp cr
jr z,prompt ;jump if a null line
cp ' '
jr nz,not$spc
ld a,(linbuf+1)
not$spc:ld hl,cmdtab ;search for a matching character
ld bc,cmdsiz/3 ; in command search table
call search
jr nz,error ;try again if search fails
push bc
ld iy,linbuf+1
call params ;input numeric parameters from
pop ix ; line buffer and test if error
jr c,error
ld hl,(param1)
ld de,(param2)
ld bc,(param3)
call callx ;call subroutine @ ix
jr c,error
jr prompt ;go back to prompt
error: call print$string
defm cr,lf,'Parameter error.',cr,lf,eot
jp prompt
help: call print$string
defm cr,lf,'Command set:',cr,lf
defm cr,lf,'1 print time & date'
defm cr,lf,'2 set clock'
defm cr,lf,'a(djust) adjust baudrate'
defm cr,lf,'b(oot) b<dram bank#>,d<isk #> - default 0,0'
defm cr,lf,'c(opy) c<start>,<end>,<dest>'
defm cr,lf,'d(ump) d<start>,<end>'
defm cr,lf,'e(memory) e<addr>'
defm cr,lf,'f(ill) f<start>,<end>,<byte>'
defm cr,lf,'g(oto) g<addr>'
defm cr,lf,'i(nput) i<port>'
defm cr,lf,'g(oto) g<addr>'
defm cr,lf,'j switch between LCD and RS-232 Output'
defm cr,lf,'o(utput) o<port#>,<data>'
defm cr,lf,'p(lay) p<lays> game of Simon'
defm cr,lf,'r(eceive) r<destination> <-- Xmodem protocol'
defm cr,lf,'s(end) s<start>,<end> <-- Xmodem protocol'
defm cr,lf,'t(est) t<memory_start>,<end>'
defm cr,lf,'u(read) u<unit>,<track>,<sector>'
defm cr,lf,'v(otrax) Speech converter'
defm cr,lf,'w(rite) w<unit>,<track>,<sector>'
defm cr,lf,'x(select) x<8-8" 5-5">,<0,1 -side>,<1-s 2-d density>'
defm cr,lf,'y(dma) y<dma r/w address>'
defm cr,lf,'z(sector) z<size> 80 hex default'
defm cr,lf,'? print help'
defm cr,lf,lf,'Terminate commands with RETURN.'
defm cr,lf
defb eot
jp prompt
callx: jp (ix) ;call subroutine @ ix
cmdtab:
defb 'W'
defb 'U'
defb 'O'
defb 'I'
defb 'G'
defb 'T'
defb 'F'
defb 'E'
defb 'C'
defb 'B'
defb 'D'
defb 'Z'
defb 'Y'
defb 'X'
defb 'A'
defb '?'
defb 'M'
defb 'S'
defb 'R'
defb 'P'
defb '1'
defb '2'
defb 'J'
defb 'V'
defw votrax ;speech synthesizer text input test
defw toggle$display ;toggle between Lcd and Rs-232 output
defw setclock ;set the clock
defw snd$timdat ;print time and date to output
defw play$simon ;plays game of simon
defw rec$xmodem ;xmodem receive
defw send$xmodem ;xmodem send
defw midi$prompt ;midi sub menu
defw help ;print help menu
defw setbaud ;select new baudrate
defw diskx ;select 5 or 8 side and density
defw disky ;select dma address for disk i/o
defw diskz ;select sector size
defw memdmp ;dump memory in hex/ascii
defw boot ;boot up cp/m
defw block ;memory block move
defw view ;memory examine/change
defw fill ;fill memory
defw test ;ram diagnostic
defw goto ;jump to memory location
defw incmd ;read from input port
defw outcmd ;write to output port
defw dskcmd ;display disk sector data
defw dskwrt ;write disk sector
cmdsiz equ $-cmdtab
; ---------------- MIDI SUB MENU -------------------
midi$prompt:
call print$string
defb cr,lf
defm 'Midi> '
defb eot
ld hl,linbuf
ld c,78 ; allow 78 characters input
call getlin ;input a bufered console line
jr c,midi$prompt ;goto prompt if control codes
xor a
ld (escflg),a
call crlf
ld a,(linbuf) ;get first character in line
cp cr
jr z,midi$prompt ;jump if a null line
cp ' '
jr nz,notspc
ld a,(linbuf+1)
notspc: ld hl,midi$cmdtab ;search for a matching character
ld bc,midi$cmdsiz/3; in command search table
call search
jr nz,param$error ;try again if search fails
push bc
ld iy,linbuf+1
call params ;input numeric parameters from
pop ix ; line buffer and test if error
jr c,param$error
ld hl,(param1)
ld de,(param2)
ld bc,(param3)
call callx ;call subroutine @ ix
jr c,param$error
jr midi$prompt ;go back to prompt
param$error:
call print$string
defm cr,lf,'Parameter error.',cr,lf,eot
jp midi$prompt
midi$help:
call print$string
defm cr,lf,'MIDI Commands:',cr,lf
defm cr,lf,'- Return to main menu'
defm cr,lf,'a Arpeggiator'
defm cr,lf,'e Enable drum pad & Footswitch interrupts'
defm cr,lf,'d Disable drum pad & Footswitch interrupts'
defm cr,lf,'m Map drum pads'
defm cr,lf,'c Copy MIDI in to MIDI out'
defm cr,lf,'p Play Speech Synth From JX8P'
defm cr,lf,'? Help'
defm cr,lf,lf,'Terminate commands with RETURN'
defm cr,lf
defb eot
jp midi$prompt
midi$cmdtab:
defb '-'
defb 'E'
defb 'D'
defb 'M'
defb 'A'
defb 'C'
defb '?'
defb 'P'
defw play$votrax ; play speech synthesizer from Jx8p
defw midi$help ; print midi help menu
defw midi$copy ; loop Midi In to Midi Out
defw arpeggiator ; emulate Jupitor 6 arpeggiator
defw drum$map ; map drum pad inputs to key-on codes
defw disable$drum ; disable drum and footswitch interrupts
defw enable$drum ; enable drum and footswitch interrupts
defw prompt ; return to main menu
midi$cmdsiz equ $-midi$cmdtab
; ------->>> Emulate Jupitor 6 Arpeggiator
arpeggiator:
call print$string
defm cr,lf,'Not implemented',eot
jp midi$prompt
; ------->>> Copy Midi In to Midi Out
midi$copy: call clear$midi$buffers
keybd$wait: call kbdst ; stop if keyboard pressed
ret nz
call midi$status
jr z,keybd$wait
ld a,(midi$receive$error)
cp false
jr z,midi$ok
cp buffer$overrun$error
jr nz,sio$err
call print$string
db 'Receive buffer overflow error.',cr,lf,eot
jr reset$stat
sio$err: call print$string
db 'Midi SIO error indicated (overrun?)',cr,lf,eot
reset$stat: ld a,false
ld (midi$receive$error),a
midi$ok: call midi$in ; get Midi data
call midi$out ; send back out to Midi
jr keybd$wait
; ------->>> Play Votrax Speech Synthesizer from JX8P
play$votrax: call print$string
defm cr,lf,'Put JX8P into LOCAL OFF mode. TONE buttons select 64 voice types.',cr,lf,eot
call clear$midi$buffers
vo$loop: call kbdst ; stop if keyboard pressed
ret nz
call get$data ; look for data
and 0f0h ; mask off midi channel
cp 090h ; note on/off?
jr z,note
cp 0c0h ; program change?
jr z,pgm$change
cp 0b0h ; all notes off?
jr z,noteoff
jr vo$loop ; no, not recognized, loop
; a tone button was pressed on the synth
pgm$change: call get$data ; get the program key number (0-127)
cp 64
jr c,vo$loop
sub 64 ; two preset banks select voices
ld b,a ; save it as new voice number
jr vo$loop ; and continue monitoring
note: call get$data ; get note number
ld c,a ; save it
call get$data ; get velocity (useless)
cp 00
jr z,vo$loop ; note off, ignore
; turn on the note
ld a,c ; get note number
cp 36 ; no notes less than 36
jr c,vo$loop
sub 36
cp 25 ; only 26 frequency divisions!
jr c,notbelow
ld a,25 ; truncate upper keyboard to one frequency
notbelow: add 90h ; offset to frequency command
push bc ; save voice type
call send$sc01 ; set frequency
pop bc ; get voice type
ld a,b
call send$sc01 ; turn on voice
jr vo$loop ; and continue loop
noteoff: call get$data
cp 07bh ; second byte of ALL NOTES OFF?
jr nz,vo$loop ; no, not all notes off command
call get$data ; kill third byte
ld a,03fh ; no noise command for chip
call send$sc01
jr vo$loop ; and continue monitoring
get$data: call midi$status
jr z,get$data
call midi$in ; get Midi data
ret
; ------->>> Map drum pad inputs to Midi key-on codes
drum$map:call print$string
defb cr,lf,'Drum Pad/Footswitch Code Mapper.',cr,lf,eot
mod$pad:call print$string
defb cr,lf,'Option? (? for help) ',eot
mod$1: call kbdin
cp cr
jp z,midi$prompt ; exit if return hit
cp 'A'
jr c,a$num
cp 'a'
jr c,upp$case
sub 20h
upp$case:cp 'I' ; initialize the cartridge
jp z,init$cart
cp 'M' ; print midi map
jp z,prt$midi$map
cp 'P' ; print pad mappings
jp z,prt$pads$map
cp 'T' ; toggle rom/ram mapping
jp z,toggle$maps
cp 'D' ; print TR-707 drum map
jp z,prt$map
cp 'F' ; modify footswitch map
jp z,mod$swt
a$num: cp '?' ; print help menu
jp z,mod$hlp
cp '1'
jr c,mod$1 ; modify pads 1-9
cp '9'+1
jr nc,mod$1
call crlf