-
Notifications
You must be signed in to change notification settings - Fork 0
/
BS; DAZZLE 68
2329 lines (2085 loc) · 36.8 KB
/
BS; DAZZLE 68
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 DAZZLE DART
.STITL MACROS
;CONVERT ADDRESS TO DISPLAY PUSHJ
; ARGUMENT IS AC
.MACR MAKEPJ F
.XLIST
SUB #DISREL,F
ASR F
BIS #DPUSHJ,F
.LIST
.ENDM
;CONVERT DISPLAY CONTROLLER ADDRESSES TO REAL WORLD ADDRESSES
; ARG IS AC
.MACR MAKEAD F
.XLIST
ASL F
ADD #DISREL,F
.LIST
.ENDM
.MACR SPUSH AA
.XLIST
MOV AA,-(P)
.LIST
.ENDM
.MACR SPOP AA
.XLIST
MOV (P)+,AA
.LIST
.ENDM
.MACR FPUSH FF
.XLIST
STF FF,-(P)
.LIST
.ENDM
.MACR FPOP FF
.XLIST
LDD (P)+,FF
.LIST
.ENDM
.MACR REPT1 A,B
.XLIST
.REPT A
B
.ENDR
.LIST
.ENDM
.MACR REPT2 A,B,C
.XLIST
.REPT A
B
C
.ENDR
.LIST
.ENDM
.STITL SYSTEM PARAMETERS
CIRC==1
A=%0
B=%1
C=%2
D=%3
E=%4
F=%5
U=%5
M=%5
P=%6
SP=%6
PC=%7
FA==%0
FB==%1
FC==%2
FD==%3
FE==%4
FF==%5
NDISP==0
MNUSRS==2
;PROGRAMMABLE CLOCK
;BREAK LEVEL 6
PCBRV=104 ;PROGRAMMABLE CLOCK BREAK VECTOR
PCS=172540 ;PROGRAMMABLE CLOCK STATUS
PCSTBF=172542 ;PROGRAMMABLE CLOCK SET BUFFER
PCCNT=172544 ;PROGRAMMABLE CLOCK COUNTER
;TK DISPLAY
NGCSR=164040 ;DISPLAY CONTROL AND STATUS REGISTER
NGREL=164042 ;DISPLAY RELOCATION REGISTER
;CONSOLE SWITCHES
SWB=177570
;SWITCH BOX STUFF
DEVADD=160104 ;PLACE NUMBER OF BOX HERE TO SELECT
DEVICE=160106 ;ACTUAL IN/OUT BUFFER
PENUF==1
ADDX=150000
ADDY=144000
ADDXY=ADDX!ADDY
DPUSHJ=100000
DPOP=140200
DPOPJ=140100
DSTOP=140400
DRSTXY=143000 ;RESET X AND Y TO 0
DINC=40000
TLEN==100 ;LENGTH OF TURTLE DISPLAY LIST (IN BYTES)
TURSIZE==6 ;(DO NOT MAKE BIGGER THAN 8)
TKRUN==4000
TKGO==10000
TKSTOP==20000
DPDLL==20.
.=PCBRV
CLKBRK ;PROGRAMMABLE CLOCK
300 ;IS ON BR6
.=400
.=.+200
SPDLP: . ;PDL
.=1000
;DISPLAY DIRECTION CODES
DREC: .BYTE 10
.BYTE 0
.BYTE 20
.BYTE 30
.BYTE 60
.BYTE 70
.BYTE 50
.BYTE 40
.EVEN
TIME: 0
TIMER: 0 ;COUNTS IN SECONDS
;DISPLAY SYSTEM VARIABLES
DFLAGS: .WORD 0
;VARIABLES AND CONSTANTS FOR DISPLAY SYSTEM
;THESE MUST BE IN THIS ORDER
DORBEG==.
CURX: .WORD 0,0 ;CURX = CURRENT X POSITION
; THE FIREST WORD IS THE INTEGER PART
; THE SECOND WORD IS THE FRACTION PART
CURY: .WORD 0,0 ;CURY = CURRENT Y POSITION
CURA: 0 ;CURA = THE CURRENT ANGLE
DOREND==. ;MARKS END OF THESE VARIABLES
;END OF ORDER
STB: 0 ;STATIC AREA BOTTOM
STT: 0 ;STATIC AREA TOP.POINTS TO TOP OF STATIC DISPLAY AREA
DYB: 0 ;DYNAMIC BOTTOM. POINTS TO BOT OF DY AREA
DYR: 0 ;ROVING POINTER USED BY DISPLAY STORAGE ALLOCATIN ROUTINES
DYT: 0 ;POINTER TO DYNAMIC AREA TOP
MIRT: 0 ;POINTER TO TEMP TOP OF MIRROR
TEM1: 0 ;USED BY THE TURTLE DRAWER
TEM2: 0
TEM3: 0
DIREC: 0
PI: 40511
7732
121041
64303
;VARIABLES AND CONSTANTS FOR DAZZLE DART
DAZSTR==.
MAXMRS==10.
MAXBMS==10.
LARGE==77000 ;A LARGE FLOATING POINT NUMBER
RTURNF==1 ;BIT CODE FOR MRBOX
LTURNF==2
RSLIDF==4
LSLIDF==10
BKTRF==20
FDTRF==40
PASSF==100
FIREF==200
R360: .WORD 36066,5542 ;1/360.
;VARIABLES -- ONE COPY
WALLB: .WORD 0,0
WALLT: .WORD 0,0
TEN: .WORD 0,0
TURNSP: .WORD 40440,0
SPEED: .WORD 40440,0
FFBDR: .WORD 0,0 ;RAD OF FBDN ZONE
FFBDR2: .WORD 0,0 ;SQUARE OF ABOVE
FFBDH: .WORD 0,0 ;HT OF FBDN ZONE IN FLOATING POINT
FFBDW: .WORD 0,0 ;WDTH
FFBDB: .WORD 0,0 ;BOUNDARY OF FBDN ZONE
REFSIZ: .WORD 41400,0 ;32.
TARD: .WORD 0,0
SX: .WORD 0,0
SY: .WORD 0,0
BMX: .WORD 0,0
BMY: .WORD 0,0
CNT: .WORD 0,0
TARX: .WORD 0,0
TARY: .WORD 0,0
NUMMRS: 12.
NUMBMS: 3
GOLTIM: 5. ;WAIT THIS MANY SECONDS AFTER HITTING GOAL
DIGIT: <<DIG.0-DISREL>/2>!DPUSHJ ;DISPLAY SUBROUTINES TO DRAW DIGITS
<<DIG.1-DISREL>/2>!DPUSHJ
<<DIG.2-DISREL>/2>!DPUSHJ
<<DIG.3-DISREL>/2>!DPUSHJ
<<DIG.4-DISREL>/2>!DPUSHJ
<<DIG.5-DISREL>/2>!DPUSHJ
<<DIG.6-DISREL>/2>!DPUSHJ
<<DIG.7-DISREL>/2>!DPUSHJ
<<DIG.8-DISREL>/2>!DPUSHJ
<<DIG.9-DISREL>/2>!DPUSHJ
;MIRROR VARIABLES
VARBEG==.
CX: REPT2 MAXMRS+8,0,0
CY: REPT2 MAXMRS+8,0,0
TX: REPT2 MAXMRS+8,0,0
TY: REPT2 MAXMRS+8,0,0
BX: REPT2 MAXMRS+8,0,0
BY: REPT2 MAXMRS+8,0,0
ANGM: REPT2 MAXMRS+8,0,0
COSM: REPT2 MAXMRS+8,0,0
SINM: REPT2 MAXMRS+8,0,0
DBOT: REPT2 MAXMRS,0,0
DIRE: REPT2 MAXMRS,0,0
CONTRO: REPT2 MAXMRS,0,0
BN: 0
BMLOST: 0
SMN: 0
TARN: 0
MRFIRE: 0
VAREND==.
BMR: 0 ;WHO'S GOT THE BEAM?
WALMAX: 200. ;WALLS AT PLUS OR MINUS THIS NUMBER
GOLSIZ: 25. ;GOALS AT PLUS AND MINUS THIS
GOLHT: 10. ;HEIGHT OF GOALS
FBDR: 90. ;RAD OF FBDN ZONE
FBDH: 30. ;HEIGHT OF FORBIDDEN ZONE
FBDW: 100. ;HALF THE WIDTH OF FBDN ZONE
TMOUT: 30. ;MUST SHOOT WITHIN THIS MANY SECONDS
MXPAS: 10. ;MAX NUM OF ALLOWED PASSES
;INITIAL VALUES FOR MIRRORS AS INTEGERS
ICX: 50.
-50.
REPT1 MAXMRS+6,0
ICY: 0
0
100.
-100.
REPT1 MAXMRS+4,0
IANGM: 180.
0.
90.
270.
REPT1 MAXMRS+4,0
HIT: 0 ;A FLAG USED BY FIRE ROUTINES
CPAS: 0
SC1: 0
SC2: 0
PSC1: 0
PSC2: 0
PCPAS: 0
PTIM: 0 ;POINTERS TO DISPLAY LIST
NBDR: 0 ;COUNTER FOR BEAM DRAWER
BMCRP: 0 ;POINTER INTO NEXT AREA
BMCRS: REPT1 4*<MAXBMS+1>,0 ;SAVE BEAM CORS HERE
.STITL CLOCKBREAK
CLKBRK: DEC TIME
BGT CLK1
MOV #60.,TIME
DEC TIMER
BGE CLK1 ;DONT ALLOW IT TO BECOME NEGATIVE
CLR TIMER
CLK1: RTT
.STITLE DAZZLE
START: RESET
MOV SPDLP,P
MOV DISREL,NGREL
CLR BMR
RSTRT: MOV #60.,TIME
MOV TMOUT,TIMER
MOV #115,PCS
CLR SC1
CLR SC2
;DAZZLE DART
DAZZLE: MOV #60.,TIME
MOV TMOUT,TIMER
MOV MXPAS,CPAS
JSR PC,STARTD
LDFPS #0 ;INTEGER,FLOATING
JSR PC,DZCLR ;CLEAR OUT MIRROR VARIABLES
JSR PC,MRALOC ;ALLOCATE BUFFERS
JSR PC,DZINIT ;INITIALIZE VARIABLES
JSR PC,WLINIT ;INITIALIZE WALL VARIABLES
JSR PC,DRWALL ;DRAW THE WALLS
JSR PC,SCINIT ;AREA FOR DRAWING SCORE
JSR PC,MRST ;INITIALZE STATIC (IE BEAM) AREA
;THE MAIN LOOP
DZMAIN: BIT #20000,SWB
BEQ DZM0
BPT
DZM0: TST TIMER ;DID HE FIRE IN TIME?
BGT DZM01
MOV TMOUT,TIMER
MOV #60.,TIME
MOV MXPAS,CPAS
ADD #4,BMR ;GIVE BEAM AWAY
BIC #177763,BMR
INC BMLOST
DZM01: JSR PC,MOVEAL ;MOVE ALL MIRRORS
CLR HIT ;BEAM COMPUTATION
CLR NBDR
TST MRFIRE
BEQ DZM1
JSR PC,FBEAM
BR DZM1
;DELETE PREVIOUS INSTRUCTION TO ALLOW FIRING TO RESET TIME
MOV TMOUT,TIMER
MOV #60.,TIME
DZM1: JSR PC,DWAIT
;YES. SO NOW IT IS OKAY TO MUNGE DISPLAY LISTS.
JSR PC,DRAWAL ;DRAW ALL NEW THINGS
JSR PC,DR.BM
MOV PTIM,D ;PRINT TIME
MOV TIMER,B
JSR PC,NPRNT
MOV PCPAS,D ;PRINT PASSES LEFT
MOV CPAS,B
JSR PC,NPRNT
TST HIT
BEQ DZM2 ;DIDN'T HIT GOAL
JMP GOLWAT ;GO TO WAIT AND RESTART
DZM2: JSR PC,DIGO ;START THE DISPLAY BACK UP
BR DZMAIN
;HAS THE DISPLAY FINISHED YET?
DWAIT: SPUSH A
SPUSH B
MOV #NDISP,A
DWAIT1: MOV A,B
SWAB B
DWAIT2: MOV B,NGCSR
BIT #TKRUN,NGCSR
BNE DWAIT2
DEC A
BGE DWAIT1
SPOP B
SPOP A
RTS PC
;WAIT WHILE RUNNING DISPLAY AND THEN RESTART
GOLWAT: JSR PC,SCCOMP
JSR PC,DWAIT
MOV #60.,TIME
MOV GOLTIM,TIMER
JSR PC,PRSCR ;PRINT THE SCORE
GOLW1: JSR PC,DWAIT
JSR PC,DIGO
TST TIMER
BGT GOLW1
GOLWR: JSR PC,DISTOP
ADD #4,BMR
BIC #177763,BMR
JMP DAZZLE
DIGO: SPUSH C
MOV #TKGO,C
JSR PC,DIMUNG
SPOP C
RTS PC
DISTOP: SPUSH C
MOV #TKSTOP,C
JSR PC,DIMUNG
SPOP C
RTS PC
DIMUNG: SPUSH A
SPUSH B
MOV #NDISP,A
DMUNG1: MOV A,B
SWAB B
BIS C,B
MOV B,NGCSR
DEC A
BGE DMUNG1
SPOP B
SPOP A
RTS PC
SCCOMP: MOV NUMMRS,A
ADD #20.,A
CMP A,HIT ;WAS TOP GOAL HIT?
BNE SCGBOT
SCGTOP: INC SC2
BIT #4,BMR
BNE SCRET
INC SC2 ;TOP GOAL HIT BY DEFENSE?
BR SCRET
SCGBOT: INC SC1
BIT #4,BMR
BEQ SCRET
INC SC1 ;BOTTOM GOAL HIT BY DEFENSE?
SCRET: RTS PC
;PRINT THE SCORE
PRSCR: MOV PSC1,D
MOV SC1,B
JSR PC,NPRNT
MOV PSC2,D
MOV SC2,B
JSR PC,NPRNT
RTS PC
NPRNT: CLR -(D) ;CLEAR OUT OLD NUMBER
CLR -(D)
CLR -(D)
ADD #6,D
CLR A
CMP B,#999.
BLE NPRNT1
BPT
NPRNT1: DIV #10.,A
ASL B
MOV DIGIT(B),-(D)
TST A
BEQ NPRNT2
MOV A,B
CLR A
BR NPRNT1
NPRNT2: RTS PC
;MOVE ALL MIRRORS
MOVEAL: MOV NUMMRS,M
MOVELP: JSR PC,MOVE ;MOVE ONE MIRROR
SUB #4,M
BGE MOVELP
RTS PC
;MOVE ONE MIRROR.
; CALL WITH INDEX IN M
MOVE: JSR PC,MRBOX ;A _ CONTROL BOX
; BITS ARE CODED AS <FIRE, BK, FD, LT, RT>
SPUSH A
MOV A,CONTRO(M)
BIT #<RTURNF!LTURNF>,A
BEQ MVNOTU
BIT #RTURNF,A
BEQ MVLTU ;ITS A LEFT TURN
MVRTU: CLR A ;A FLAG FOR MVTURN
MVLTU: JSR PC,MVTURN ;TURN THIS MIRROR
MVNOTU: MOV (P),A
BIT #<FDTRF!BKTRF>,A
BEQ MVNOTR
BIT #FDTRF,A
BEQ MVBKTR ;BACKWARDS TRANSLATION
MVFDTR: CLR A
MVBKTR: JSR PC,MVTRAN ;TRANSLATE THIS MIRROR
MVNOTR: MOV (P),A ;NOW CHECK FOR SLIDING
BIT #<RSLIDF!LSLIDF>,A
BEQ MVNOTS
BIT #LSLIDF,A
BEQ MLSLD
CLR A
MLSLD: JSR PC,MVSLID
MVNOTS: TST (P)+
RTS PC
;READ THE BOX
MRBOX: MOV M,A
ASH #8,A
MOV A,DEVADD
CLR DEVICE
MRB1: TST DEVICE ;INPUT IS COMPLETE WHEN M.S.B.= 1
BPL MRB1
MOV DEVICE,A
COM A ;DEVICE BITS ARE INVERTED
MRB9: RTS PC
;DRAW ALL THE MIRROS THAT NEED TO BE DRAWN
;
DRAWAL: MOV NUMMRS,M
DRAWLP: JSR PC,DRAW ;DRAW ONE MIRROR
SUB #4,M
BGE DRAWLP
CLR BMLOST
RTS PC
;DRAW ONE MIRROR.
; CALL WITH INDEX IN M
DRAW: SPUSH CONTRO(M) ;CONTROL BOX WORD
BIT #PASSF,(P) ;PASS THE BEAM?
BEQ DRAW0
CMP M,BMR
BNE DRAW0
TST CPAS ;PASSES USED UP?
BEQ DRAW0
DEC CPAS
ADD #8.,BMR
BIC #177763,BMR
INC BMLOST
BIC #PASSF,CONTRO(M) ;TURN OF FLAG SO WE DON'T LOOP
CMP (P)+,(P)+ ;WHEN WE GO TO REDRAW ALL MIRRORS
BR DRAWAL ;WHAT A KLUDGE!
DRAW0: TST BMLOST
BNE DRAW1 ;IF BEAMER CHANGES REDRAW MIRRORS ANYWAY
; BITS ARE CODED AS <FIRE, BK, FD, LT, RT>
BIT #<RTURNF!LTURNF>,(P)
BEQ DRNOTU
DRAW1: JSR PC,DR.MIR ;REDRAW THE MIRROR
DRNOTU: BIT #<FDTRF!BKTRF!LSLIDF!RSLIDF>,(P)
BEQ DRNOTR
JSR PC,DRTRAN ;TRANSLATE THIS MIRROR
DRNOTR: CMP M,BMR ;DOES THIS GUY HAVE THE BEAM?
BNE NOTFIR
CLR MRFIRE
BIT #FIREF,(P) ;IS MIRROR 0 FIRING
BEQ NOTFIR
INC MRFIRE ;YES. SET FLAG
NOTFIR: TST (P)+
RTS PC
;TURN THIS MIRROR.
; CALL WITH A = 0 IFF RIGHT TURN
;UPDATE VARIABLES ONLY
MVTURN: LDF ANGM(M),FA
TST A
BEQ MTURT ;RIGHT TURN
SUBF TURNSP,FA ;LEFT TURN
BR .+6
MTURT: ADDF TURNSP,FA
JSR PC,MOD360 ;MAKE ANGM MOD 360
STF FA,ANGM(M)
MRTUR1: JSR PC,MRANG ;GET SIN, COS, AND DIREC
JSR PC,MRTUUP ;UPDATE REST OF TURNED VARIABLES
RTS PC
;DO ANGLE CRAP
MRANG: STF FA,FE
JSR PC,SINDEG ;FA _ SIN FA
STF FA,SINM(M)
LDF FE,FA
JSR PC,COSDEG
STF FA,COSM(M)
ASH #2,C ;TRIG LEAVES QUADRANT INFO IN C
MOV C,DIRE(M)
RTS PC
;INCREMENATL MOD360 ROUTINE. CLOBBERS FC
MOD360: LDCIF #360.,FC
TSTF FA ;IS ANGLE NEGATIVE?
CFCC
BLT MODNEG ;YES
CMPF FA,FC ;IS ANGLE > 360.
CFCC
BLT MODRTS ;NO. ANGLE IS OKAY
SUBF FC,FA ;ELSE ANGLE = ANGLE - 360
MODRTS: RTS PC
;ANGLE IS NEGATIVE, SO
MODNEG: ADDF FC,FA ;ANGLE = ANGLE + 360
RTS PC
;UPDATE VARIABLES THAT HAVE BEEN TURNED
MRTUUP: LDF COSM(M),FA
MULF REFSIZ,FA
STF FA,FF ;DY
LDF SINM(M),FA
MULF REFSIZ,FA
STF FA,FE ;DX
ADDF CX(M),FA
STF FA,TX(M)
LDF FF,FA ;DY
ADDF CY(M),FA
STF FA,TY(M)
LDF CX(M),FA
SUBF FE,FA
STF FA,BX(M)
LDF CY(M),FA
SUBF FF,FA
STF FA,BY(M)
RTS PC
;SLIDE THIS MIRROR
;A=0 IF SLIDE TO RIGHT
MVSLID: LDCIF #-1,FA ;FOR TURTLE CONTROLS USE---LDF SINM(M),FA
CLRF FB ;FOR TURTLE--LDF COSM(M),FB
NOP ;SPACE FOR TURTLE PATCH
BR MVTRS
;TRANSLATE THIS MIRROR
; A = 0 IFF THE DIRECTION IS FORWARD
MVTRAN: LDCIF #-1,FB ;FOR TURTLE---LDF SINM(M),FB
NEGF FB ;= COS (ANGM+90)
CLRF FA ;FOR TURTLE---LDF COSM(M),FA
NOP
MVTRS: MULF SPEED,FA ;DX
MULF SPEED,FB ;DY
TST A ;FD OR BK ?
BEQ FDMOVE
NEGF FA ;BACKWARD, SO NEGATE DX AND DY
NEGF FB
FDMOVE: STF FA,FE
STF FB,FF
ADDF CX(M),FA ;NEW X
ADDF CY(M),FB
LDF FA,FD
JSR PC,CHKBND ;IN BOUNDS?
BNE NOTBND ;OUT OF BOUNDS. DO NOTHING
YBND: LDF FB,FD
JSR PC,CHKBND ;IN BOUNDS?
BNE NOTBND ;OUT OF BOUNDS. DO NOTHING
JSR PC,FBDCH ;CHECK TO SEE IF IN FORBIDDEN ZONE
BNE NOTBND
MRTR1: JSR PC,MRTRUP ;UPDATE VARIABLES
NOTBND: RTS PC
;CHECK TO SEE IF ENTERING FORBIDDEN ZONE
.IFZ CIRC
FBDCH: FPUSH FA
FPUSH FB
ABSF FA
CMPF FFBDW,FA
CFCC
BLT FBOK
ABSF FB
CMPF FFBDB,FB
CFCC
BGT FBOK
FPOP FB ;INSIDE FORBIDDEN ZONE
FPOP FA
CLZ
RTS PC
FBOK: FPOP FB
FPOP FA
SEZ
RTS PC
.ENDC
.IFZ CIRC-1
FBDCH: FPUSH FA
FPUSH FB
FPUSH FC
STF FB,FC
MULF FA,FA
ADDF WALLT,FC
MULF FC,FC
ADDF FA,FC
CMPF FFBDR2,FC
CFCC
BGT FBNO
SUBF WALLT,FB
MULF FB,FB
ADDF FA,FB
CMPF FFBDR2,FB
CFCC
BGT FBNO
FPOP FC ;OK
FPOP FB
FPOP FA
SEZ
RTS PC
FBNO: FPOP FC
FPOP FB
FPOP FA
CLZ
RTS PC
.ENDC
;UPDATE VARIABLES DUE TO TRANSLATION
MRTRUP: STF FA,CX(M)
STF FB,CY(M)
LDF FE,FC ;DX
ADDF TX(M),FC
STF FC,TX(M)
LDF FF,FC
ADDF TY(M),FC
STF FC,TY(M)
LDF FE,FC
ADDF BX(M),FC
STF FC,BX(M)
LDF FF,FC
ADDF BY(M),FC
STF FC,BY(M)
RTS PC
;MUNGE DISPLAY LIST TO TRANSLATE THIS MIRROR
DRTRAN: LDF CX(M),FA
LDF CY(M),FB
JSR PC,ROUND
STCFI FA,D
STCFI FB,E
MOV DBOT(M),A
JSR PC,MTO.R1 ;ACTUALLY PUT IN THE ADDX AND ADDY COMMANDS
RTS PC
;DRAW A MIRROR
DR.MIR: MOV DBOT(M),A
MOV A,MIRT ;MIRT WILL BE POINTER TO TOP OF TURTLE DLIST SO FAR
CMP -(A),-(A)
MOV #DRSTXY!DPOPJ,-(A)
SPUSH A
MOV DIRE(M),DIREC
LDCIF #TURSIZ,FB
LDF SINM(M),FA
MULF FB,FA ;DX OF 1ST TURTLE SIDE
MULF COSM(M),FB ;DY OF 1ST SIDE
JSR PC,ROUND
STCFI FA,D
STCFI FB,E
MOV M,A
ASR A
JSR PC,@DR.TU(A)
JSR PC,DR.REF ;THE REFLECTOR
MOV #DRSTXY,@(P)+ ;RESTORE THIS WORD
RTS PC
;DISPATCH TABLE FOR POINTERS
;THESE ROUTINES SHOULD BE CALLED WITH D,E AND DIREC SET
;AND LEAVE MIRT POINTING TO WHERE REFLECTOR CODE SHOULD START
DR.TU: DR.TUR
DR.TSQ
DR2TR
DR2SQ
REPT1 MAXMRS-4,DR.TUR
DR.TUL: DR.TUR ;DISPATCH TABLE FOR THE "2 FIGURE "ROUTINES
DR.TS1
;DRAW A TRIANGULAR POINTER
DR.TUR: SPUSH M
SPUSH DIREC
SPUSH D
SPUSH D
SUB E,2(SP) ;NOW SIZE * (SIN - COS) ON STACK
ADD E,(SP) ;NOW SIZE * (SIN + COS) ON STACK
;SIDE 1--WILL BE AN ADDXY
MOV MIRT,A
MOV A,TEM3
CMP (A)+,(A)+
MOV A,MIRT
JSR PC,MTO.R1
;SIDE 2
ADD #30,DIREC ;SIDE 2 IS 3*45 DEGREES RIGHT OF SIDE 1
MOV (SP)+,D ;DX IS SIZE * (COSA + SINA)
MOV (SP)+,E ;DY IS SIZE * (COSA - SINA)
JSR PC,DR.TSD ;DRAW THE SIDE
;SIDE 3 HAS THE SAME INCREMENTS AS SIDE 2.
;JUST THE DIRECTION IS DIFFERENT
MOV DIREC,B
ADD #20,B ;SIDE 3 IS 2*45 DEGREES RIGHT
BIC #177707,B ;LEAVE ONLY THE 3 BITS
SWAB B ;PUT THE DIREC BITS IN TOP BYTE
MOV MIRT,C ;POINTS TO WORD ABOVE LAST ONE OF TURTLE DLIST
MOV C,A
SUB D,C ;SINCE D POINTS TO BOTTOM WORD OF SIDE 2
;C-D IS NUMBER OF BYTES IN SIDE 2'S DLIST
ASR C ;C/2 = NUMBER OF WORDS
DR.TS3: MOV (D)+,E ;NEXT WORD OF SIDE 2'S DLIST
BIC #34000,E ;CLEAR THE DIRECTION BITS THEREIN
BIS B,E ;AND SET THEM FROM THE NEW DIREC IN B
MOV E,(A)+ ;STORE IN DLIST
DEC C ;NUMBER OF WORDS IN SIDE 2'S DLIST
BGT DR.TS3 ;THERE ARE MORE WORDS
;SIDE 4 IS IDENTICAL TO SIDE 1,
SPOP DIREC
SPOP M
MOV TEM3,B ;COPY THE SAME ADDXY
MOV (B)+,(A)+
MOV (B)+,(A)+
MOV #DPOPJ,(A)
MOV A,MIRT
RTS PC
; DRAW ONE SIDE OF THE TURTLE
; DIREC CONTAINS THE DIRECTION
; MIRT POINTS TO TOP OF TURTLE DISPLAY LIST SO FAR
; C,D = + OR - DX OR DY
DR.TSD: BIC #177707,DIREC ;BITS MAY HAVE BEEN SET BY THE SUBTRACTING
JSR PC,DR.STUP
ADD MIRT,D ;D = NEW TOP OF TURTLE
MOV D,MIRT
JSR PC,DR.ASC ;ACTUALLY CREAT THE DISPLAY LIST
RTS PC
;THE 2 FIGURE ROUTINES USE C AS A FLAG TO DECIDE
;BETWEEN TRIANGLE AND SQUARE
DR2TR: CLR C
JSR PC,DR.TU1
RTS PC
DR2SQ: MOV #2,C
ASR D ;SQUARE IS HALF AS BIG AS TRI
ASR E
JSR PC,DR.TU1
RTS PC
;DRAW POINTER AS TWO TRIANGLES
;DLIST IS ADDXY,PUSHJ TO TRIANGLE,ADDXY,PUSHJ,ADDXY,
;PUSHJ TO REFLECTOR,POPJ,TIRANGLE CODE,REFLECTOR CODE
DR.TU1: SPUSH D
SPUSH E
MOV MIRT,A ;POINTER TO START OF CODE
ADD #4,A
MOV A,TEM1 ;FIRST PUSHJ WILL GO HERE
JSR PC,MTO.R1 ;PUT IN ADDXY. D,E ALREADY SET
MOV TEM1,A
ADD #6,A
MOV A,TEM2 ;POINTER TO 2ND PUSHJ
MOV (P),E
MOV 2(P),D
ASL D
ASL E
NEG D
NEG E ;SET UP FOR 2ND ADDXY
JSR PC,MTO.R1
MOV TEM2,A
ADD #10.,A ;LEAVE ROOM FOR ADDXY,PUSH TO REF AND POPJ
MOV A,MIRT ;TRIANGLE CODE WILL START HERE
MOV A,B
MAKEPJ B
MOV B,@TEM1
MOV B,@TEM2 ;PUT IN PUSHJ'S TO TURTLE CODE
MOV #DPOPJ,-(A) ;THE FINAL POPJ
TST -(A)
MOV A,TEM1 ;POINTER TO PUSHJ TO REFLECTOR
MOV (P),E
MOV 2(P),D
JSR PC,MTO.R1 ;THE FINAL ADDXY
SPOP E
SPOP D
JSR PC,@DR.TUL(C) ;DECIDE BETWEEN SQUARE AND TRIANGLE
ADD #2,MIRT ;REFLECTOR CODE WILL START HERE
MOV MIRT,A
MAKEPJ A
MOV A,@TEM1
RTS PC
;DRAW POINTER AS A SQUARE
;MADE UP OF ADDXY (DX,DY)
;SIDES ARE (-2DY,2DX),(-2DX,-2DY),(2DY,-2DX)
;ADDXY (DX,DY)
DR.TSQ: ASR D ;SQUARE IS HALF AS BIG AS TRIANGLE
ASR E
DR.TS1: SPUSH DIREC ;ENTRY FOR "2-SQUARE" WHICH ALREADY ASR'ED D AND E
SPUSH DYB ;THIS WILL FAKE OUT THE
;ERROR CONDITION ON THE LINE DRAWER
MOV #DISEND,DYB
SPUSH STT ;FOR LINE DRAWER WE WILL MUNG STT
SPUSH M
SPUSH D
SPUSH E
MOV MIRT,A ;FIRST WORD OF CODE WILL GO HERE
CMP (A)+,(A)+
MOV A,MIRT
JSR PC,MTO.R1 ;FIRST ADDXY
MOV MIRT,STT ;FOR LINE DRAWER
MOV (P),D ;SET UP DX AND DY FOR SIDE 2
MOV 2(P),E
ASL D
ASL E
NEG E
JSR PC,XYDIR
JSR PC,DR.LIN ;SIDE 2
MOV (P),E
ASL E
NEG E
MOV 2(P),D
ASL D
NEG D
JSR PC,XYDIR
JSR PC,DR.LIN ;SIDE 3
MOV (P),D
MOV 2(P),E
ASL D
ASL E
NEG D
JSR PC,XYDIR
JSR PC,DR.LIN ;SIDE 4
SPOP E
SPOP D
MOV STT,A
CMP (A)+,(A)+
MOV A,MIRT
MOV #DPOPJ,(A) ;LAST WORD OF CODE
JSR PC,MTO.R1 ;FINAL SIDE
SPOP M
SPOP STT
SPOP DYB
SPOP DIREC
RTS PC
;THE REFLECTOR PART OF THE MIRROR
DR.REF: SPUSH M
LDF TX(M),FA ;GET DX,DY TO TOP OF MIRROR
LDF CX(M),FB
JSR PC,ROUND
SUBF FB,FA ;DX
STCFI FA,D
LDF TY(M),FA
LDF CY(M),FB
JSR PC,ROUND
SUBF FB,FA ;DY
STCFI FA,E
MOV MIRT,A ;HACK THE DISPLAY LIST
CMP (A)+,(A)+
MOV #DPOPJ,(A)
MOV A,MIRT
JSR PC,MTO.R1 ;ACTUALLY PUTS IN THE ADDX, ADDY
;GET DX,DY FROM TOP TO BOTTOM OF MIRROR
LDF BX(M),FA
LDF TX(M),FB
JSR PC,ROUND
SUBF FB,FA ;DX
STF FA,FC
STCFI FA,D
LDF BY(M),FA
LDF TY(M),FB
JSR PC,ROUND