-
Notifications
You must be signed in to change notification settings - Fork 3
/
p_sight.gas
1209 lines (1044 loc) · 19 KB
/
p_sight.gas
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
.long
.dc.l codeend-_p_sight_start
_p_sight_start::
.gpu
.org $f1b140
DIVCONTROL .equ $f1a11c
S_LE .ccdef $14 ; PL
U_LE .ccdef $04 ; CC
S_GT .ccdef $18 ; MI
U_GT .ccdef $08 ; CS
S_LT .ccdef $15 ; PL+NE
U_LT .ccdef $05 ; CC+NE
FP .equr r14
scratch .equr r10
scratch2 .equr r11
RETURNVALUE .equr r29
RETURNPOINT .equr r28
MATH_A .equr r27
MATH_B .equr r26
MATH_C .equr r25
MATH_RTS .equr r24
MATH_SIGN .equr r23
movei #codestart,scratch
jump T,(scratch)
nop
GPU_IMUL:
move MATH_A,MATH_SIGN
xor MATH_B,MATH_SIGN
abs MATH_A
abs MATH_B
move MATH_A,MATH_C
mult MATH_B,MATH_C
move MATH_B,scratch2
shrq #16,scratch2
mult MATH_A,scratch2
shlq #16,scratch2
add scratch2,MATH_C
move MATH_A,scratch2
shrq #16,scratch2
mult MATH_B,scratch2
shlq #16,scratch2
add scratch2, MATH_C
btst #31,MATH_SIGN
jump EQ,(MATH_RTS)
nop
jump T,(MATH_RTS)
neg MATH_C
;========================
_PS_SightCrossLine:
;fixed_t PS_SightCrossLine (line_t *line)
;========================
sc_p1x .equr r0
sc_p1y .equr r1
sc_p2x .equr r2
sc_p2y .equr r3
sc_p3x .equr r4
sc_p3y .equr r5
sc_p4x .equr r6
sc_p4y .equr r7
sc_dx .equr r8
sc_dy .equr r9
sc_ndx .equr r10
sc_ndy .equr r11
sc_s1 .equr r12
sc_s2 .equr r13
sc_line .equr r15
sc_temp1 .equr r16
sc_temp2 .equr r17
load (FP),sc_line
load (sc_line),sc_line ; line->v1
load (sc_line),sc_p1x
sharq #16,sc_p1x
load (sc_line+1),sc_p1y
sharq #16,sc_p1y
load (FP),sc_line
load (sc_line+1),sc_line ; line->v2
load (sc_line),sc_p2x
sharq #16,sc_p2x
load (sc_line+1),sc_p2y
sharq #16,sc_p2y
movei #_t1xs,sc_p3x
load (sc_p3x),sc_p3x
movei #_t1ys,sc_p3y
load (sc_p3y),sc_p3y
movei #_t2xs,sc_p4x
load (sc_p4x),sc_p4x
movei #_t2ys,sc_p4y
load (sc_p4y),sc_p4y
move sc_p2x,sc_dx
sub sc_p3x,sc_dx
move sc_p2y,sc_dy
sub sc_p3y,sc_dy
move sc_p4x,sc_ndx
sub sc_p3x,sc_ndx
move sc_p4y,sc_ndy
sub sc_p3y,sc_ndy
move sc_ndy,sc_temp1
imult sc_dx,sc_temp1
move sc_dy,sc_temp2
imult sc_ndx,sc_temp2
cmp sc_temp1,sc_temp2
jr S_LT,gots1
moveq #1,sc_s1 ; delay slot
moveq #0,sc_s1
gots1:
move sc_p1x,sc_dx
sub sc_p3x,sc_dx
move sc_p1y,sc_dy
sub sc_p3y,sc_dy
move sc_ndy,sc_temp1
imult sc_dx,sc_temp1
move sc_dy,sc_temp2
imult sc_ndx,sc_temp2
cmp sc_temp1,sc_temp2
jr S_LT,gots2
moveq #1,sc_s2 ; delay slot
moveq #0,sc_s2
gots2:
cmp sc_s1,sc_s2
moveq #0,RETURNVALUE
jump EQ,(RETURNPOINT)
subq #1,RETURNVALUE ; delay slot (return -1)
move sc_p1y,sc_ndx
sub sc_p2y,sc_ndx
move sc_p2x,sc_ndy
sub sc_p1x,sc_ndy
move sc_ndx,sc_temp1
imult sc_dx,sc_temp1
move sc_ndy,sc_s1
imult sc_dy,sc_s1
add sc_temp1,sc_s1
move sc_p4x,sc_dx
sub sc_p1x,sc_dx
move sc_p4y,sc_dy
sub sc_p1y,sc_dy
move sc_ndx,sc_temp1
imult sc_dx,sc_temp1
move sc_ndy,sc_s2
imult sc_dy,sc_s2
add sc_temp1,sc_s2
add sc_s1,sc_s2
;
; fixeddiv
;
movei #DIVCONTROL,sc_temp1 ; divide unit control
moveq #1,sc_temp2
store sc_temp2,(sc_temp1) ; turn on frac div
move sc_s1,MATH_SIGN
xor sc_s2,MATH_SIGN
abs sc_s1
abs sc_s2
move sc_s1,RETURNVALUE
div sc_s2,RETURNVALUE
or RETURNVALUE,RETURNVALUE
btst #31,MATH_SIGN
moveq #0,sc_temp2
jump EQ,(RETURNPOINT)
store sc_temp2,(sc_temp1) ; turn off frac div
jump T,(RETURNPOINT)
neg RETURNVALUE
;=============================================================================
_PS_CrossBSPNode:
;boolean PS_CrossBSPNode (int bspnum)
; FP+3 parm bspnum / saved cb_node
; FP+2 saved returnpoint
; FP+1 saved side2 (<0 if not crossed over to)
; FP arg 1
;=============================================================================
cb_node .equr r15
.extern _subsectors, _nodes
subq #12,FP
nop
store RETURNPOINT,(FP+2)
load (FP+3),cb_node
;if (bspnum & NF_SUBSECTOR)
; return PS_CrossSubsector (&subsectors[bspnum&(~NF_SUBSECTOR)]);
btst #15,cb_node
movei #notsubsec,scratch
jump EQ,(scratch)
bclr #15,cb_node ; delay slot
moveq #12,scratch ; sizeof subsector_t
mult scratch,cb_node
movei #_subsectors,scratch
load (scratch),scratch
add scratch,cb_node
; unthread this stack frame to directly return to caller
addq #12,FP
store cb_node,(FP)
movei #_PS_CrossSubsector,scratch
jump T,(scratch)
nop
notsubsec:
; bsp = &nodes[bspnum];
movei #56,scratch ; sizeof node_t
mult scratch,cb_node
movei #_nodes,scratch
load (scratch),scratch
add scratch,cb_node
store cb_node,(FP+3) ; save off over parameter
ds_node .equr r15
ds_x1 .equr r16
ds_y1 .equr r17
ds_nodex .equr r18
ds_nodey .equr r19
ds_nodedx .equr r20
ds_nodedy .equr r21
ds_x2 .equr r22
ds_y2 .equr r23
ds_side1 .equr r24
ds_side2 .equr r25
;
; load node points
;
load (ds_node),ds_nodex
load (ds_node+1),ds_nodey
load (ds_node+2),ds_nodedx
load (ds_node+3),ds_nodedy
sharq #16,ds_nodex
sharq #16,ds_nodey
sharq #16,ds_nodedx
sharq #16,ds_nodedy
;
; load preshifted sight endpoints
;
movei #_t1xs,ds_x1
load (ds_x1),ds_x1
movei #_t1ys,ds_y1
load (ds_y1),ds_y1
movei #_t2xs,ds_x2
load (ds_x2),ds_x2
movei #_t2ys,ds_y2
load (ds_y2),ds_y2
;
; calc side 1
;
move ds_x1,scratch
sub ds_nodex,scratch
move ds_y1,scratch2
sub ds_nodey,scratch2
imult ds_nodedy,scratch
imult ds_nodedx,scratch2
cmp scratch2,scratch
jr S_GT,gotds1
moveq #1,ds_side1 ; 1 = back side
moveq #0,ds_side1 ; 0 = front side
gotds1:
;
; calc side 2
;
move ds_x2,scratch
sub ds_nodex,scratch
move ds_y2,scratch2
sub ds_nodey,scratch2
imult ds_nodedy,scratch
imult ds_nodedx,scratch2
cmp scratch2,scratch
jr S_GT,gotds2
moveq #1,ds_side2 ; 1 = back side
moveq #0,ds_side2 ; 0 = front side
gotds2:
;
; if side 2 == side 1, set it < 0
;
cmp ds_side2,ds_side1
jr NE,crosses
nop
subq #31,ds_side2
crosses:
store ds_side2,(FP+1) ; save for processing after first cross
; if (!PS_CrossBSPNode (bsp->children[side]) )
; return false;
shlq #2,ds_side1
addq #24,ds_side1
addq #24,ds_side1
add ds_side1,ds_node
load (ds_node),ds_node ; bsp->children[side]
store ds_node,(FP)
movei #_PS_CrossBSPNode,scratch
move PC,RETURNPOINT
jump T,(scratch)
addq #6,RETURNPOINT
load (FP+2),RETURNPOINT
load (FP+1),ds_side1
addq #12,FP ; unthread stack frame
or RETURNVALUE,RETURNVALUE
jump EQ,(RETURNPOINT)
load (FP),ds_node ; harmless delay slot
; if side2 < 0, the back side doesn't need to be checked
or ds_side1,ds_side1
moveq #1,RETURNVALUE
jump MI,(RETURNPOINT)
nop
; return PS_CrossBSPNode (bsp->children[side^1]);
shlq #2,ds_side1
addq #24,ds_side1
addq #24,ds_side1
add ds_side1,ds_node
load (ds_node),ds_node ; bsp->children[side]
store ds_node,(FP)
movei #_PS_CrossBSPNode,scratch
jump T,(scratch)
nop
codestart:
; unfuckdsp output -- add loads before external dsp stores
;====================
_P_CheckSights2::
;3 dag registers 1 register variables
;localoffset:0 regoffset:0 argoffset:20
;====================
subq #20,FP
movei #_mobjhead+4,r0
load (r0),r0
move r0,r15 ;(mo)
movei #L75,r0
jump T,(r0)
nop
L72:
movei #100,r0
move r15,r1 ;(mo)
add r0,r1
load (r1),r0
movei #4194304,r1
and r1,r0
moveq #0,r1
cmp r0,r1
movei #L77,scratch
jump NE,(scratch)
nop
movei #L73,r0
jump T,(r0)
nop
L77:
movei #92,r0
move r15,r1 ;(mo)
add r0,r1
load (r1),r0
moveq #1,r1
cmp r0,r1
movei #L79,scratch
jump EQ,(scratch)
nop
movei #L73,r0
jump T,(r0)
nop
L79:
movei #100,r0
move r15,r1 ;(mo)
add r0,r1
load (r1),r0
movei #-67108865,r2
and r2,r0
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r0,(r1)
movei #116,r0
move r15,r1 ;(mo)
add r0,r1
load (r1),r0
moveq #0,r1
cmp r0,r1
movei #L81,scratch
jump NE,(scratch)
nop
movei #L73,r0
jump T,(r0)
nop
L81:
movei #_sight1,r0
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r15,(r0) ;(mo)
movei #_sight2,r0
movei #116,r1
move r15,r2 ;(mo)
add r1,r2
load (r2),r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_P_CheckSight2,r0
store r28,(FP) ; psuh ;(RETURNPOINT)
movei #L85,RETURNPOINT
jump T,(r0)
store r15,(FP+1) ; delay slot push ;(mo)
L85:
load (FP+1),r15 ; pop ;(mo)
load (FP),RETURNPOINT ; pop
movei #_sightreturn,r0
load (r0),r0
moveq #0,r1
cmp r0,r1
movei #L83,scratch
jump EQ,(scratch)
nop
movei #100,r0
move r15,r1 ;(mo)
add r0,r1
load (r1),r0
movei #67108864,r2
or r2,r0
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r0,(r1)
L83:
L73:
move r15,r0 ;(mo)
addq #4,r0
load (r0),r0
move r0,r15 ;(mo)
L75:
move r15,r0 ;(mo)
movei #_mobjhead,r1
cmp r0,r1
movei #L72,scratch
jump NE,(scratch)
nop
L71:
jump T,(RETURNPOINT)
addq #20,FP ; delay slot
;====================
_P_CheckSight2::
;6 dag registers 3 register variables
;localoffset:4 regoffset:20 argoffset:60
;====================
movei #60,scratch
sub scratch,FP
movei #_sight1,r0
load (r0),r0
move r0,r16 ;(t1)
movei #_sight2,r1
load (r1),r1
move r1,r15 ;(t2)
move FP,r1
addq #4,r1 ; &s1
movei #52,r2
add r2,r0
load (r0),r0
load (r0),r0
movei #_sectors,r3
load (r3),r3
sub r3,r0
movei #96,r4
move r4,MATH_SIGN
move r4,MATH_B
xor r0,MATH_SIGN
abs MATH_B
abs r0
div MATH_B,r0
btst #31, MATH_SIGN
jr EQ,L94
nop
neg r0
L94:
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r0,(r1)
move FP,r0
addq #8,r0 ; &s2
move r15,r5 ;(t2)
add r2,r5
load (r5),r2
load (r2),r2
sub r3,r2
move r4,MATH_SIGN
move r4,MATH_B
xor r2,MATH_SIGN
abs MATH_B
abs r2
div MATH_B,r2
btst #31, MATH_SIGN
jr EQ,L95
nop
neg r2
L95:
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r0)
load (r1),r1
movei #_numsectors,r2
load (r2),r2
move r1,MATH_A
movei #L96,MATH_RTS
movei #GPU_IMUL,scratch
jump T,(scratch)
move r2,MATH_B ; delay slot
L96:
move MATH_C,r1
load (r0),r0
add r0,r1
move r1,r17 ;(pnum)
move FP,r0
addq #12,r0 ; &bytenum
move r17,r1 ;(pnum)
sharq #3,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
move FP,r1
addq #16,r1 ; &bitnum
moveq #1,r2
move r17,r3 ;(pnum)
moveq #7,r4
and r4,r3
neg r3
sha r3,r2
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r1)
load (r0),r0
movei #_rejectmatrix,r2
load (r2),r2
add r2,r0
loadb (r0),r0
load (r1),r1
and r1,r0
moveq #0,r1
cmp r0,r1
movei #L87,scratch
jump EQ,(scratch)
nop
movei #_sightreturn,r0
moveq #0,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #L86,r0
jump T,(r0)
nop
L87:
movei #_validcount,r0
load (r0),r1
addq #1,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_strace,r0
move r16,r1 ;(t1)
addq #12,r1
load (r1),r1
movei #-131072,r2
and r2,r1
movei #65536,r3
or r3,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_strace+4,r0
move r16,r1 ;(t1)
addq #16,r1
load (r1),r1
and r2,r1
or r3,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t2x,r0
move r15,r1 ;(t2)
addq #12,r1
load (r1),r1
movei #-131072,r2
and r2,r1
movei #65536,r3
or r3,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t2y,r1
move r15,r4 ;(t2)
addq #16,r4
load (r4),r4
and r2,r4
move r4,r2
or r3,r2
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r1)
movei #_strace+8,r1
load (r0),r0
movei #_strace,r2
load (r2),r2
sub r2,r0
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r0,(r1)
movei #_strace+12,r0
movei #_t2y,r1
load (r1),r1
movei #_strace+4,r2
load (r2),r2
sub r2,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t1xs,r0
movei #_strace,r1
load (r1),r1
moveq #16,r2
sha r2,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t1ys,r0
movei #_strace+4,r1
load (r1),r1
sha r2,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t2xs,r0
movei #_t2x,r1
load (r1),r1
sha r2,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_t2ys,r0
movei #_t2y,r1
load (r1),r1
sha r2,r1
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r0)
movei #_sightzstart,r0
moveq #20,r1
move r16,r2 ;(t1)
add r1,r2
load (r2),r2
movei #68,r3
move r16,r4 ;(t1)
add r3,r4
load (r4),r4
add r4,r2
sharq #2,r4
sub r4,r2
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r0)
movei #_topslope,r2
move r15,r4 ;(t2)
add r1,r4
load (r4),r1
move r15,r5 ;(t2)
add r3,r5
load (r5),r3
add r3,r1
load (r0),r0
sub r0,r1
load (r2),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r1,(r2)
movei #_bottomslope,r1
load (r4),r2
sub r0,r2
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r1)
movei #_numnodes,r0
load (r0),r0
subq #1,r0
store r0,(FP) ; arg[]
movei #_PS_CrossBSPNode,r0
store r28,(FP+5) ; push ;(RETURNPOINT)
store r17,(FP+6) ; push ;(pnum)
store r16,(FP+7) ; push ;(t1)
movei #L97,RETURNPOINT
jump T,(r0)
store r15,(FP+8) ; delay slot push ;(t2)
L97:
load (FP+6),r17 ; pop ;(pnum)
load (FP+7),r16 ; pop ;(t1)
load (FP+8),r15 ; pop ;(t2)
load (FP+5), RETURNPOINT ; pop
movei #_sightreturn,r0
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r29,(r0) ;(RETURNVALUE)
L86:
movei #60,scratch
jump T,(RETURNPOINT)
add scratch,FP ; delay slot
;====================
_PS_CrossSubsector::
;3 dag registers 8 register variables
;localoffset:4 regoffset:8 argoffset:56
;====================
movei #56,scratch
sub scratch,FP
move FP,r0
addq #4,r0 ; &count
load (FP+14),r1 ; local sub
move r1,r2
addq #4,r2
load (r2),r2
load (r0),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r2,(r0)
move r1,r0
addq #8,r0
load (r0),r0
shlq #5,r0
movei #_segs,r1
load (r1),r1
add r1,r0
move r0,r22 ;(seg)
movei #L102,r0
jump T,(r0)
nop
L99:
move r22,r0 ;(seg)
addq #20,r0
load (r0),r0
move r0,r17 ;(line)
movei #64,r0
move r17,r1 ;(line)
add r0,r1
load (r1),r0
movei #_validcount,r1
load (r1),r1
cmp r0,r1
movei #L103,scratch
jump NE,(scratch)
nop
movei #L100,r0
jump T,(r0)
nop
L103:
movei #64,r0
move r17,r1 ;(line)
add r0,r1
movei #_validcount,r0
load (r0),r0
load (r1),r30 ; FUCKING dsp!
or r30,r30 ; FUCKING dsp!
store r0,(r1)
store r17,(FP) ; arg[] ;(line)
movei #_PS_SightCrossLine,r0
store r28,(FP+2) ; push ;(RETURNPOINT)
store r22,(FP+3) ; push ;(seg)
store r21,(FP+4) ; push ;(slope)
store r20,(FP+5) ; push ;(openbottom)
store r19,(FP+6) ; push ;(opentop)
store r18,(FP+7) ; push ;(frac)
store r17,(FP+8) ; push ;(line)
store r16,(FP+9) ; push ;(front)
movei #L128,RETURNPOINT
jump T,(r0)
store r15,(FP+10) ; delay slot push ;(back)
L128:
load (FP+3),r22 ; pop ;(seg)
load (FP+4),r21 ; pop ;(slope)
load (FP+5),r20 ; pop ;(openbottom)
load (FP+6),r19 ; pop ;(opentop)
load (FP+7),r18 ; pop ;(frac)
load (FP+8),r17 ; pop ;(line)
load (FP+9),r16 ; pop ;(front)
load (FP+10),r15 ; pop ;(back)
load (FP+2), RETURNPOINT ; pop
move r29,r18 ;(RETURNVALUE)(frac)
moveq #4,r0
cmp r18,r0 ;(frac)
movei #L107,scratch
jump S_LT,(scratch)
nop
movei #65536,r0
cmp r18,r0 ;(frac)
movei #L105,scratch
jump PL,(scratch)
nop
L107:
movei #L100,r0
jump T,(r0)
nop
L105:
movei #60,r0
move r17,r1 ;(line)
add r0,r1
load (r1),r0
move r0,r15 ;(back)
move r15,r0 ;(back)
moveq #0,r1
cmp r0,r1
movei #L108,scratch
jump NE,(scratch)
nop
moveq #0,r0
move r0,RETURNVALUE
movei #L98,r0
jump T,(r0)
nop
L108:
movei #56,r0
move r17,r1 ;(line)
add r0,r1
load (r1),r0
move r0,r16 ;(front)
load (r16),r0 ;(front)
load (r15),r1 ;(back)
cmp r0,r1
movei #L110,scratch
jump NE,(scratch)
nop
moveq #4,r0
move r16,r1 ;(front)
add r0,r1
load (r1),r1
move r15,r2 ;(back)
add r0,r2
load (r2),r0
cmp r1,r0
movei #L110,scratch
jump NE,(scratch)
nop
movei #L100,r0
jump T,(r0)
nop
L110:
moveq #4,r0
move r16,r1 ;(front)
add r0,r1
load (r1),r1
move r15,r2 ;(back)
add r0,r2
load (r2),r0
cmp r1,r0
movei #L112,scratch
jump EQ,(scratch)
nop
jump MI,(scratch)
nop
move r16,r0 ;(front)
addq #4,r0
load (r0),r0
move r0,r19 ;(opentop)
movei #L113,r0
jump T,(r0)
nop
L112:
move r15,r0 ;(back)
addq #4,r0
load (r0),r0
move r0,r19 ;(opentop)
L113:
load (r16),r0 ;(front)
load (r15),r1 ;(back)
cmp r0,r1
movei #L114,scratch
jump PL,(scratch)
nop
load (r16),r0 ;(front)
move r0,r20 ;(openbottom)
movei #L115,r0
jump T,(r0)
nop
L114:
load (r15),r0 ;(back)
move r0,r20 ;(openbottom)
L115:
cmp r20,r19 ;(openbottom)(opentop)
movei #L116,scratch
jump S_LT,(scratch)
nop