forked from CorshamTech/xSWTBUG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxswtbug.asm
1736 lines (1652 loc) · 32.4 KB
/
xswtbug.asm
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
title "xSWTBUG v1.2.1"
;***************************************************
;REPLACEMENT FOR MIKBUG ROM
;FOR SWTPC 6800 COMPUTER SYSTEM
;COPYRIGHT 1977
;SOUTHWEST TECHNICAL PROD. CORP.
;AUGUST, 1977
;***************************************************
;
; Enhancements by Bob Applegate, K2UT
; bob@corshamtech.com
; www.corshamtech.com
;
; This was all done for the SWTBUG included with the
; Corsham Tech 6800 CPU board.
;
; I MAKE NO COPYRIGHT CLAIMS! The original code is
; on the Internet and I simply copied and modified it,
; so all my changes are free to use.
;
; Last edit: 05/27/2016
;
; Source was converted to use the AS02 assembler:
;
; http://www.kingswood-consulting.co.uk/assemblers/
;
; I prefer this assembler because it gives me nice
; macros and conditional assembly. It also uses
; traditional pseudo-ops instead of the strange
; Motorola ones.
;
; This includes extensions that can optionally
; be compiled in. Look near ExtCmd for the new
; code. I needed to add more commands without
; disrupting anything in the original SWTBUG, so
; the 'C' command has been replaced by the 'X'
; command which goes into the extended command set.
;
; 1.2 - Includes logic for handling the Corsham Tech
; SD card interface board.
; 1.2.1 - Added a version string at start-up
;
;***************************************************
; Various constants
;
false equ 0
true equ ~false
;
; Version and revision values. Version.Revision
;
VERSION equ 1
REVISION equ 2
;
; So included programs know that they are being
; built as part of SWTBUG and don't need to define
; as much.
;
IN_SWTBUG equ true
;
; If this is true, then add support for S5 records
; in the "L" command. Moves some code into the
; extended area. The original SWTBUG only supported
; S9 for end of file.
;
SUPPORT_S5 equ true
;
;***************************************************
; User options and tuning parameters...
;
; Number of address bits in EPROM. This is used
; to calculate the vector addresses. For Corsham
; Technologies 6800 CPU boards, the value is 13.
;
ADDR_BITS equ 13
;
; Start of ROM and RAM regions
;
RAM_BASE equ $a000
ROM_BASE equ $e000
;
; If NO_WEIRD is set, then don't put out tape reader
; control codes in prompts. Many people are using
; terminal programs running on computers which
; interpret the control codes and display them as
; weird symbols. Turning on this option will stop
; those weird symbols from coming out.
;
NO_WEIRD equ true
;
; If set, add the extended SWTBUG. Else just have
; the standard set of commands.
;
EXTENDED equ true
;
; These are options if EXTENDED is on...
;
SD_SUPPORT equ true ;include SD card funcs
SD_CMDS equ true ;adds SD card commands
SD_BOOT equ true ;boot from SD card
BOOT_ADDR equ $a100 ;where boot sector goes
;
NUMGUESS equ true ;include NumGuess game
MEMTEST equ true ;include Memory tester
OTHELLO equ true ;include Othello game
;
; To support running with either 6800 or 6809
; motherboards, these two options allow you to set
; the base address of the I/O block and also the
; number of addresses for each I/O slot.
;
; For 6800:
; IOBASE is $8000
; IOBYTES is 4
;
; For 6809:
; IOBASE is $e000
; IOBYTES is 16
;
IOBASE equ $8000
IOBYTES equ 4
;
; CONSLOT is the slot that the console port is plugged
; into. SWTPC always uses 1.
;
CONSLOT equ 1
;
;***************************************************
; Common ASCII control codes
;
EOT equ $04
BEL equ $07
BS equ $08
LF equ $0a
CR equ $0d
DEL equ $7f
;
;***************************************************
; This macro is used to verify that the current
; address meets a required value. Used mostly to
; guarantee changes don't cause entry points to
; move. These are used right before documented
; entry points.
;
VERIFY macro expected
if * != expected
fail Not at requested address (expected)
endif
endm
;
;***************************************************
; More constants. You definitely don't want to
; change CTLPOR but the PROM address and stack size
; could be. Beware that changing the stack size
; pushes other things around.
;
CTLPOR equ IOBASE+(IOBYTES*CONSLOT) ;CONTROL PORT ADDRESS
PROM equ $C000 ;JUMP TO PROM ADDRESS
STACK_SIZE equ $2b
page
;***************************************************
; RAM
;
bss
org RAM_BASE
IRQ ds 2 ;IRQ POINTER
BEGA ds 2 ;BEGINNING ADDR PNCH
ENDA ds 2 ;ENDING ADDR PNCH
NMI ds 2 ;NMI INTERRUPT VECTOR
SP ds 1 ;S HIGH
ds 1 ;S LOW
PORADD ds 2 ;PORT ADDRESS
PORECH ds 1 ;ECHO ON/OFF FLAG
XHI ds 1 ;XREG HIGH
XLOW ds 1 ;XREG LOW
CKSM ds 1 ;CHECKSUM
XTEMP ds 2 ;X-REG TEMP STGE
SWIJMP ds 2 ;SWI JUMP VECTOR
BKPT ds 2 ;BREAKPOINT ADDRESS
BKLST ds 1 ;BREAKPOINT DATA
ds STACK_SIZE
STACK ds 1 ;SWTBUG STACK
ds 1
TW ds 2 ;TEMPORARY STORAGE
TEMP ds 1 ;TEMPORARY STORAGE
BYTECT ds 1 ;BYTECT AND MCONT TEMP.
;
; The locations A048 and A049 contain the address where
; the RTI instruction jumps. It's often loaded with the
; address of a program just loaded from tape so the "G"
; command will execute it.
;
VERIFY $a048
RTIVEC ds 2
if SD_CMDS
NAMESIZE equ 12
FnBuffer ds 3 ;formatting area
Filename ds NAMESIZE+1 ;xxxxxxxx.xxx
sdState ds 1
temp ds 1
tempx ds 2
byteCnt ds 1
pointer ds 2
nibCnt ds 1
endif
page
;***************************************************
; Code!
;
; SWTBUG must be first to match up with subroutine
; addresses commonly used. Anything extra goes
; after SWTBUG.
;
code
org ROM_BASE
;
;I/O INTERRUPT SEQUENCE
IRQV ldx IRQ
jmp 0,x
;JUMP TO USER PROGRAM
JUMP bsr BADDR
jmp 0,x
CURSOR db $10,$16,EOT ;CT-1024 cursor control
;ASCII LOADING ROUTINE
VERIFY $e00c
LOAD jsr RDON ;READER ON, DIS ECHO, GET P#
;
; This first loop waits for an 'S' indicating the start
; of a new record. Discards all other characters.
;
LOAD3 bsr INCH
cmpa #'S'
bne LOAD3 ;1ST CHAR NOT S
;
; The next character is the record type. SWTBUG only supported
; 1 (data) and 9 (EOF) but I've added support for 5, which some
; assemblers produce instead of an S9.
;
bsr INCH ;READ CHAR
cmpa #'9'
beq LOAD21
;
; I added code to accept an S5 record as EOF since a lot
; of cross assemblers produce them instead of an S9. To
; make room for the code, some of this function was moved
; into the extended monitor area.
;
if SUPPORT_S5
jsr LOADX
nop ;pad to correct address
else
cmpa #'1'
bne LOAD3 ;2ND CHAR NOT 1
endif
clr CKSM ;ZERO CHECKSUM
bsr BYTE ;READ BYTE
suba #2
staa BYTECT ;BYTE COUNT
;BUILD ADDRESS
bsr BADDR
VERIFY $e02b
;STORE DATA
LOAD11 bsr BYTE
dec BYTECT
beq LOAD15 ;ZERO BYTE COUNT
staa 0,x ;STORE DATA
cmpa 0,x ;DATA STORED?
bne LOAD19
inx
bra LOAD11
LOAD15 inc CKSM
beq LOAD3
VERIFY $e040
LOAD19 ldaa #'?'
bsr OUTCH
LOAD21 jmp RDOFF1
;BUILD ADDRESS
VERIFY $e047
BADDR bsr BYTE ;READ 2 FRAMES
staa XHI
bsr BYTE
staa XLOW
ldx XHI ;LOAD IXR WITH NUMBER
rts
;INPUT BYTE (TWO FRAMES)
VERIFY $e055
BYTE bsr INHEX ;GET HEX CHAR
BYTE1 asla
asla
asla
asla
tab
bsr INHEX
aba
tab
addb CKSM
stab CKSM
rts
VERIFY $e067
OUTHL lsra ;OUT HEX LEFT BCD DIGIT
lsra
lsra
lsra
VERIFY $e06b
OUTHR anda #$F ;OUT HEX RIGHT BCD DIGIT
adda #'0'
cmpa #$39
bls OUTCH
adda #$7
;OUTPUT ONE CHAR
VERIFY $e075
OUTCH jmp OUTEEE
VERIFY $e078
INCH jmp INEEE
;PRINT DATA POINTED TO BY X REG
VERIFY $e07b
PDATA2 bsr OUTCH
inx
VERIFY $e07e
PDATA1 ldaa 0,x
cmpa #EOT
bne PDATA2
rts ;STOP ON HEX 04
C1 jmp SWTCTL
;MEMORY EXAMINE AND CHANGE
VERIFY $e088
CHANGE bsr BADDR
CHA51 ldx #MCL
bsr PDATA1 ;C/R L/F
ldx #XHI
bsr OUT4HS ;PRINT ADDRESS
ldx XHI
bsr OUT2HS ;PRINT OLD DATA
bsr OUTS ;OUTPUT SPACE
ANOTH bsr INCH ;INPUT CHAR
cmpa #' '
beq ANOTH
cmpa #CR
beq C1
cmpa #'^' ;UP ARROW?
bra AL3 ;BRANCH FOR ADJUSTMENT
nop
;INPUT HEX CHARACTER
VERIFY $e0aa
INHEX bsr INCH
INHEX1 suba #'0'
bmi C3
cmpa #$9
ble IN1HG
cmpa #$11
bmi C3 ;NOT HEX
cmpa #$16
bgt C3 ;NOT HEX
suba #7
IN1HG rts
VERIFY $e0bf
OUT2H ldaa 0,x ;OUTPUT 2 HEX CHAR
OUT2HA bsr OUTHL ;OUT LEFT HEX CHAR
ldaa 0,x
inx
bra OUTHR ;OUTPUT RIGHT HEX CHAR
VERIFY $e0c8
OUT4HS bsr OUT2H ;OUTPUT 4 HEX CHAR + SPACE
VERIFY $e0ca
OUT2HS bsr OUT2H ;OUTPUT 2 HEX CHAR + SPACE
VERIFY $e0cc
OUTS ldaa #' ' ;SPACE
bra OUTCH ;(BSR & TRS)
;ENTER POWER ON SEQUENCE
VERIFY $e0d0
START lds #STACK
bra al1
;*******************************************
;PART OF MEMORY EXAMINE AND CHANGE
AL3 bne SK1
dex
dex
stx XHI
bra CHA51
SK1 stx XHI
bra AL4
VERIFY $E0E3
EOE3 bra CONTRL ;BRANCH FOR MIKBUG EQUIV. CONT
AL4 cmpa #$30
bcs CHA51
cmpa #$46
bhi CHA51
bsr INHEX1
jsr BYTE1
dex
staa 0,x ;CHANGE MEMORY
cmpa 0,x
beq CHA51 ;DID CHANGE
jmp LOAD19 ;DIDN'T CHANGE
C3 lds SP
bra SWTCTL
;*************************************************
al1 sts SP ;INIT TARGET STACK PTR.
ldaa #$FF
jsr SWISET
ldx #CTLPOR
jsr PIAINI
ldaa 0,x
cmpa 2,x
bra al2
bra PRINT
al2 bne CONTRL
;INITIALIZE AS ACIA
ldaa #3 ;ACIA MASTER RESET
staa 0,x
ldaa #$11 ;11 = 8N2 /16. 15 = 8N1 /16
staa 0,x;
bra CONTRL
;ENTER FROM SOFTWARE INTERRUPT
SF0 nop
SFE1 sts SP ;SAVE TARGETS STACK POINTER
;DECREMENT P COUNTER
tsx
tst 6,x
bne *+4
dec 5,x
dec 6,x
;PRINT CONTENTS OF STACK.
PRINT ldx #MCL
jsr PDATA1
ldx SP
inx
bsr OUT2HS ;COND CODES
bsr OUT2HS ;ACC B
bsr OUT2HS ;ACC A
bsr OUT4HS ;IXR
bsr OUT4HS ;PGM COUNTER
ldx #SP
jsr OUT4HS ;STACK POINTER
SWTCTL ldx SWIJMP
cpx #SF0
beq CONTR1
CONTRL lds #STACK ;SET CONTRL STACK POINTER
ldx #CTLPOR ;RESET TO CONTROL PORT
stx PORADD
clr PORECH ;TURN ECHO ON
bsr SAVGET ;GET PORT # AND TYPE
beq POF1
jsr PIAECH ;SET PIA ECHO ON IF MP-C INTER
POF1 jsr PNCHOF ;TURN PUNCH OFF
; jsr RDOFF ;TURN READER OFF
jsr PrintVer
CONTR1 ldx #MCLOFF
jsr PDATA1 ;PRINT DATA STRING
bsr INEEE ;READ COMMAND CHARACTER
;COMMAND LOOKUP ROUTINE
LOOK ldx #TABLE
OVER cmpa 0,x
bne SK3
jsr OUTS ;SKIP SPACE
ldx 1,x
jmp 0,x
SK3 inx
inx
inx
cpx #TABEND+3
bne OVER
;
; Bob's change. Branch to a later point.
;
;SWTL1 bra SWTCTL
SWTL1 bra CONTR1
;SOFTWARE INTERRUPT ENTRY POINT
SFE ldx SWIJMP ;JUMP TO VECTORED SOFTWARE INT
jmp 0,x
S9 db 'S','9',EOT ;END OF TAPE
;**************************************************
MTAPE1 db CR,LF,$15,0,0,0,'S','1',EOT ;PUNCH FORMAT
VERIFY $e19c
MCLOFF
if NO_WEIRD
db 0
else
db $13 ;READER OFF
endif
VERIFY $e19d
MCL
if NO_WEIRD
db CR,LF,'$',EOT,0,0,0,0
else
db CR,LF,$15,0,0,0,'$',EOT
endif
EIA5 bra BILD ;BINARY LOADER INPUT
;**************************************************
;NMI SEQUENCE
NMIV ldx NMI ;GET NMI VECTOR
jmp 0,x
VERIFY $e1ac
INEEE bra INEEE1
;BYTE SEARCH ROUTINE
SEARCH jsr BADDR ;GET TOP ADDRESS
stx ENDA
jsr BADDR ;GET BOTTOM ADDRESS
jsr BYTE ;GET BYTE TO SEARCH FOR
tab
OVE ldaa 0,x
stx XHI
cba
beq PNT
bra INCR1
PNT ldx #MCL
jsr PDATA1
ldx #XHI
bra SKP0
;**************************************************
;GO TO USER PROGRAM ROUTINE
GOTO rti
VERIFY $e1d1
OUTEEE bra OUTEE1
;SAVE IXR AND LOAD IXR WITH CORRECT
;PORT NUMBER AND TEST FOR TYPE
SAVGET stx XTEMP ;STORE INDEX REGISTER
GETPT1 ldx PORADD
VERIFY $E1D9
ISACIA pshb
ldab 1,x
cmpb 3,x
pulb
rts
;**************************************************
;CONTINUATION OF SEARCH ROUTINE
SKP0 jsr OUT4HS
ldx XHI
INCR1 cpx ENDA
beq SWTL1
inx
bra OVE
INEEE1 bsr INCH8 ;INPUT 8 BIT CHARACTER
anda #%01111111 ;GET RID OF PARITY BIT
rts
BILD ins ;FIX UP STACK WHEN USING
ins ;BINARY LOADER ON SWTPC TAPES
ins
;INPUT ONE CHAR INTO ACC B
VERIFY $e1f6
INCH8 pshb ;SAVE ACC B
bsr SAVGET ;SAVE IXR, GET PORT# AND TYPE
bne IN1 ;INPUT FROM PIA IF NOT
ldaa #$11 ;RECONFIG FOR 8 BIT, 2 SB
staa 0,x
ACIAIN ldaa 0,x
asra
bcc ACIAIN ;NOT READY
ldaa 1,x ;LOAD CHAR
ldab PORECH
beq ACIOUT ;ECHO
bra RES ;DON'T ECHO
;OUTPUT ONE CHARACTER
OUTEE1 pshb ;SAVE ACC B
bsr SAVGET
bne IOUT
ACIOUT ldab #$15
stab 0,x
ACIOU1 ldab 0,x
asrb
asrb
bcc ACIOU1
staa 1,x ;OUTPUT CHARACTER
RES pulb ;RESTORE ACC B
ldx XTEMP
rts
;PIA INPUT ROUTINE
IN1 ldaa 0,x ;LOOK FOR START BIT
bmi IN1
bsr DDL ;DELAY HALF BIT TIME
ldab #4 ;SET DEL FOR FULL BIT TIME
stab 2,x
aslb ;SET UP CNTR WITH 8
IN3 bsr DEL1 ;WAIT ONE CHAR TIME
sec
rol 0,x
rora
decb
bne IN3
bsr DEL1 ;WAIT FOR STOP BIT
ldab PORECH ;IS ECHO DESIRED?
beq IOUT2 ;ECHO
bra RES ;RESTORE IXR,ACCB
IOUT bsr DDL1 ;DELAY ONE HALF BIT TIME
ldab #$A ;SET UP COUNTER
dec 0,x ;SET START BIT
bsr DE ;START TIMER
OUT1 bsr DEL1 ;DELAY ONE BIT TIME
sta 0,x ;PUT OUT ONE DATA BIT
sec
rora ;SHIFT IN NEXT BIT
decb ;DECREMENT COUNTER
bne OUT1 ;TEST FOR 0
IOUT2 ldab 2,x ;TEST FOR STOP BITS
aslb ;SHIFT BIT TO SIGN
bpl RES ;BRA FOR 1 STOP BIT
bsr DEL1 ;DELAY FOR STOP BITS
bra RES
DEL1 tst 2,x ;IS TIME UP
bpl DEL1
DE inc 2,x ;RESET TIMER
dec 2,x
rts
DDL clr 2,x ;HALF BIT DELAY
DDL1 bsr DE
bra DEL1
;OPTIONAL PORT ROUTINE
OPTL bsr INEEE1
tab
clr PORADD+1 ;SET I/O ADDRESS FOR $8000
ldx PORADD
bsr PIAINI ;INITIALIZE PIA
bsr PIAECH ;SET ECHO
ldx #TABLE1 ;P, L OR E
tba
jmp OVER ;LOOK AT TABLE FOR E, L OR P
PIAECH ldaa #$34 ;SET DDR
staa 3,x
staa 2,x
NOOPT rts
;PIA INITIALIZATION ROUTINE
PIAINI inc 0,x ;SET DDR
ldaa #$7
staa 1,x
inc 0,x
staa 2,x
rts
; MINIFLOPPY DISK BOOT
DISK clr $8014
bsr DELAY
ldab #$0B
bsr RETT2
LOOP1 ldab 4,x
bitb #1
bne LOOP1
clr 6,x
bsr RETURN
ldab #$9C
bsr RETT2
ldx #$2400
LOOP2 bitb #2
beq LOOP3
lda $801B
sta 0,x
inx
LOOP3 ldab $8018
bitb #1
bne LOOP2
jmp $2400
RETT2 stab 4,x
RETURN bsr RETT1
RETT1 rts
;GENERAL PURPOSE DELAY LOOP
VERIFY $E2C2
DELAY ldx #$FFFF
DELAY1 dex
cpx #$8014 ;STOP AT 8014
DUM bne DELAY1
rts
CLEAR ldx #CURSOR
jsr PDATA1
bsr DELAY1
RDOFF1 jsr RDOFF
bra C4
;BREAKPOINT ENTERING ROUTINE
BREAK ldx #SF0
cpx SWIJMP ;BREAKPOINTS ALREADY IN USE?
beq INUSE
inx
BREAK0 bsr STO1
jsr BADDR
stx BKPT
ldaa 0,x
staa BKLST
ldaa #$3F
staa 0,x
ldx #SF0
bsr STO1
jmp CONTR1
INUSE ldx BKPT
ldaa BKLST
staa 0,x
ldx #SFE1
bra BREAK0
SWISET staa STACK+1 ;FIX POWER UP INTERRUPT
ldx SWIJMP
cpx #SF0
beq STORTN
STO ldx #SFE1
STO1 stx SWIJMP
STORTN rts
PUNCH1 bsr PUNCH
bra POFC4
;FORMAT END OF TAPE WITH PGM. CTR. AND S9
PNCHS9 ldx #$A049
stx ENDA
dex
bsr PUNCH2
ldx #S9
PDAT jsr PDATA1
POFC4 bsr PNCHOF
bsr DELAY
C4 jmp CONTRL
RDON
if NO_WEIRD
nop 18
else
com PORECH ;DISABLE ECHO FOR ACIA
ldaa #$11 ;RON CHAR.
ldab #$20 ;STROBE CHAR
bsr STROBE
jsr ISACIA ;CHECK TO SEE IF PIA
beq RTNN
ldaa #$3C ;DISABLE PIA ECHO IF PIA
staa 3,x
endif
RTNN rts
RDOFF
if NO_WEIRD
rts
nop 5
else
ldaa #$13 ;TURN READER OFF
ldab #$10
bra STROBE
endif
PNCHON
if NO_WEIRD
rts
nop 5
else
ldaa #$12
ldab #4
bra STROBE
endif
PNCHOF
if NO_WEIRD
rts
nop 3
else
ldaa #$14
ldab #$8
endif
;PIA STROBING ROUTINE FOR PUNCH/READ ON/OFF
STROBE jsr OUTCH
jsr GETPT1
beq RTN1
ldaa #2
orab #1
bsr STR2
bsr STR1
ldaa #2
ldab #1
stab 0,x
bsr STR2
STR1 ldaa #6
STR2 staa 1,x
stab 0,x
RTN1 rts
;PUNCH FROM BEGINNING ADDRESS (BEGA) THRU
;ENDING ADDRESS (ENDA)
PUNCH ldx BEGA
PUNCH2 stx TW
bsr PNCHON
PUN11 ldaa ENDA+1
suba TW+1
ldab ENDA
sbcb TW
bne PUN22
cmpa #16
bcs PUN23
PUN22 ldaa #15
PUN23 adda #4
staa BYTECT
suba #3
staa TEMP
;PUNCH C/R L/F NULLS S1
ldx #MTAPE1
jsr PDATA1
clrb
;PUNCH FRAME COUNT
ldx #BYTECT
bsr PUNT2 ;PUNCH 2 HEX CHARACTERS
;PUNCH ADDRESS
ldx #TW
bsr PUNT2
bsr PUNT2
;PUNCH DATA
ldx TW
PUN32 bsr PUNT2 ;PUNCH ONE BYTE
dec TEMP
bne PUN32
stx TW
comb
pshb
tsx
bsr PUNT2 ;PUNCH CHECKSUM
pulb ;RESTORE STACK
ldx TW
dex
cpx ENDA
bne PUN11
RTN5 rts
;PUNCH 2 HEX CHAR, UPDATE CHECKSUM
PUNT2 addb 0,x
jmp OUT2H ;OUTPUT 2 HEX CHAR AND RTS
page
;COMMAND TABLE
TABLE db 'G' ;GOTO
dw GOTO
db 'Z' ;GOTO PROM
dw PROM
db 'M' ;MEMORY EXAM AND CHANGE
dw CHANGE
db 'F' ;BYTE SEARCH
dw SEARCH
db 'R' ;REGISTER DUMP
dw PRINT
db 'J' ;JUMP
dw JUMP
if EXTENDED
db 'X'
dw ExtCmd
else
db 'C' ;CLEAR SCREEN
dw CLEAR
endif ;EXTENDED
db 'D' ;boot from disk
dw DISK
db 'B' ;BREAKPOINT
dw BREAK
db 'O' ;OPTIONAL PORT
dw OPTL
TABLE1 db 'P' ;ASCII PUNCH
dw PUNCH1
db 'L' ;ASCII LOAD
dw LOAD
TABEND db 'E' ;END OF TAPE
dw PNCHS9
page
if EXTENDED
;***************************************************
; This is the signature for a piece of code to
; determine if it's running under normal SWTBUG or
; extended xSWTBUG. The signature is always at
; $E400.
;
ds $e400-*
VERIFY $e400
db "XSWTBUG",0
;
; These are the version and revision of this build.
; They are always at $E408 and $E409.
;
VERIFY $e408
db VERSION
db REVISION
;
; These are vectors to internal functions that may
; be useful to user applications. The vectors
; always start at $E40A.
;
VERIFY $e40A
if SD_SUPPORT
jmp SdBoot ;load OS from SD Card
jmp xParInit ;init parallel interface
jmp xParSetWrite ;set for writing
jmp xParSetRead ;set for reading
jmp xParWriteByte ;write one byte
jmp xParReadByte ;read one byte
;
; Higher level disk functions
;
jmp DiskReadSector
jmp DiskWriteSector
jmp DiskStatus
jmp DiskGetDrives
jmp DiskGetMounted
jmp DiskNextMountedDrv
jmp DiskUnmount
jmp DiskMount
jmp DiskDir
jmp DiskDirNext
endif ;SD_SUPPORT
page
;
;***************************************************
; Displaced code from LOAD function in original
; SWTBUG.
;
if SUPPORT_S5
LOADX cmpa #'5'
beq LOADWE ;Wait for EOL
cmpa #'1'
bne LOAD3X ;2ND CHAR NOT 1
rts
LOAD3X jmp LOAD3
;
; Keep eating characters until the end of the line. Note that
; this might not be right, as it fails if the S5 record does
; not have a CR at the end. A better approach would be to
; get the byte count (next two bytes) and read twice that
; number of characters.
;
LOADWE jsr INCH ;get char
cmpa #CR ;end of line?
bne LOADWE ;nope
jmp LOAD21 ;done loading
endif
;
;***************************************************
; If the option is turned on, build in the SD card
; support functions
;
if SD_SUPPORT
include "pario.asm"
include "parproto.inc"
include "diskfunc.asm"
endif ;SD_SUPPORT
;
;***************************************************
; This is the command loop while in extended command
; mode. Same basic concept as the other loop.
;
ExtCmd
if SD_CMDS
jsr xParInit
jsr xParSetWrite
endif