-
Notifications
You must be signed in to change notification settings - Fork 2
/
d_polyset68k.s
1910 lines (1744 loc) · 53 KB
/
d_polyset68k.s
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
**
** Quake for AMIGA
** d_polyset.c assembler implementations by Frank Wille <[email protected]>
**
INCLUDE "quakedef68k.i"
XREF _acolormap
XREF _d_aspancount
XREF _errorterm
XREF _erroradjustup
XREF _erroradjustdown
XREF _d_countextrastep
XREF _ubasestep
XREF _r_affinetridesc
XREF _a_ststepxwhole
XREF _a_sstepxfrac
XREF _a_tstepxfrac
XREF _r_lstepx
XREF _r_lstepy
XREF _r_sstepx
XREF _r_sstepy
XREF _r_tstepx
XREF _r_tstepy
XREF _r_zistepx
XREF _r_zistepy
XREF _zspantable
XREF _skintable
XREF _r_p0
XREF _r_p1
XREF _r_p2
XREF _d_xdenom
XREF _d_pcolormap
XREF _d_scantable
XREF _d_viewbuffer
XREF _d_pedgespanpackage
XREF _d_pdest
XREF _d_pz
XREF _d_aspancount
XREF _d_ptex
XREF _d_sfrac
XREF _d_tfrac
XREF _d_light
XREF _d_zi
XREF _d_pdestextrastep
XREF _d_pzextrastep
XREF _d_countextrastep
XREF _d_ptexextrastep
XREF _d_sfracextrastep
XREF _d_tfracextrastep
XREF _d_lightextrastep
XREF _d_ziextrastep
XREF _d_pdestbasestep
XREF _d_pzbasestep
XREF _d_ptexbasestep
XREF _d_sfracbasestep
XREF _d_tfracbasestep
XREF _d_lightbasestep
XREF _d_zibasestep
XREF _d_zwidth
XREF _d_pzbuffer
XREF _a_spans
XREF _pedgetable
XREF _edgetables
XREF _screenwidth
XREF _FloorDivMod
XDEF _D_DrawNonSubdiv
XDEF _D_PolysetRecursiveTriangle
XDEF _D_RasterizeAliasPolySmooth
ALIAS_ONSEAM = $20 ;must match the def. in r_shared.h
******************************************************************************
*
* void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage)
*
* standard scan drawing function for alias models
*
******************************************************************************
cnop 0,4
_D_PolysetDrawSpans8
***** stackframe
rsreset
.intregs rs.l 11
rs.l 1
.pspan rs.l 1
****** prologue
movem.l d2-d7/a2-a6,-(sp)
move.l .pspan(sp),a0
move.l _d_aspancount,d0
move.l _errorterm,d1
move.l _erroradjustup,d2
move.l _erroradjustdown,d3
move.l _d_countextrastep,a1
move.l _ubasestep,d5
move.l _acolormap,a3
move.l _r_zistepx,d4
move.l _a_ststepxwhole,a5
move.l _a_sstepxfrac,a4
move.l _a_tstepxfrac,d6
swap d6
move.l _r_lstepx,a6
move.l _r_affinetridesc+R_SKINWIDTH,d7
move d7,d6
.loop
* lcount = d_aspancount - pspanpackage->count;
*
* errorterm += erroradjustup;
* if (errorterm >= 0)
* {
* d_aspancount += d_countextrastep;
* errorterm -= erroradjustdown;
* }
* else
* {
* d_aspancount += ubasestep;
* }
move.l d0,d7
sub.l PSPANP_COUNT(a0),d7 ;lcount = d_aspancount-pspa...
add.l d2,d1 ;errorterm += erroradjustup
blt.b .else ;if (errorterm >= 0)
add.l a1,d0 ;d_aspancount += d_countextrastep
sub.l d3,d1 ;errorterm -= error adjustdown
bra.b .next
.else
add.l d5,d0 ;d_aspancount += ubasestep
.next
subq.l #1,d7
blt.b .loopend
* lpdest = pspanpackage->pdest;
* lptex = pspanpackage->ptex;
* lpz = pspanpackage->pz;
* lsfrac = pspanpackage->sfrac;
* ltfrac = pspanpackage->tfrac;
* llight = pspanpackage->light;
* lzi = pspanpackage->zi;
movem.l d0-d3/d5/a0/a1,-(sp)
move.l (a0)+,d2 ;lpdest = pspanpackage->dest
move.l (a0)+,a1 ;lpz = pspanpackage->pz
addq.l #4,a0
move.l (a0)+,a2 ;lptex = pspanpackage->ptex
move.l (a0)+,d3 ;lsfrac = pspanpackage->sfrac
move.l (a0)+,d5 ;tsfrac = pspanpackage->tfrac
swap d5
move.l (a0)+,d1 ;llight = pspanpackage->light
move.l (a0)+,d0 ;lzi = pspanpackage->zi
move.l d2,a0
moveq #0,d2
****** main drawing loop
****** d0 = lzi
****** d1 = llight
****** d3 = lsfrac
****** d4 = r_zistepx
****** d5 = ltfrac
****** d6 = a_tstepxfrac [high] and r_affinetridesc.skinwidth [low]
****** d7 = lcount-1
****** a0 -> lpdest
****** a1 -> lpz
****** a2 -> lptex
****** a3 -> acolormap
****** a4 = a_sstepxfrac
****** a5 = a_ststepxwhole
****** a6 = r_lstepx
* do
* {
* if ((lzi >> 16) >= *lpz)
* {
* *lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
* *lpz = lzi >> 16;
* }
* lpdest++;
* lzi += r_zistepx;
* lpz++;
* llight += r_lstepx;
* lptex += a_ststepxwhole;
* lsfrac += a_sstepxfrac;
* lptex += lsfrac >> 16;
* lsfrac &= 0xFFFF;
* ltfrac += a_tstepxfrac;
* if (ltfrac & 0x10000)
* {
* lptex += r_affinetridesc.skinwidth;
* ltfrac &= 0xFFFF;
* }
* } while (--lcount);
.loop2
swap d0
cmp (a1)+,d0 ;if ((lzi >> 16) >= *lpz)
blt.b .cont
move d1,d2
move.b (a2),d2 ;d3 = *lptex + (llight & $ff00)
move.b 0(a3,d2.l),(a0) ;*lpdest = ((byte *)acolormap[d2]
move d0,-2(a1) ;*lpz = lzi >> 16
.cont
addq.l #1,a0 ;lpdest++
swap d0
add.l d4,d0 ;lzi += r_zistepx
add.l a6,d1 ;llight += r_lstepx
add.l a5,a2 ;lptex += a_ststepxwhole
add.l a4,d3 ;lsfrac += a_sstepxfrac
swap d3
add d3,a2 ;lptex += lsfrac >> 16
clr d3
swap d3 ;lsfrac &= $ffff
add.l d6,d5 ;ltfrac += a_tstepxfrac
bcc.b .cont2 ;if (ltfrac & $10000)
add d6,a2 ;lptex += r_affine...
.cont2
dbra d7,.loop2 ;while (--lcount)
movem.l (sp)+,d0-d3/d5/a0/a1
.loopend
* pspanpackage++;
* } while (pspanpackage->count != -999999);
lea PSPANP_SIZEOF(a0),a0 ;pspanpackage++
cmp.l #-999999,PSPANP_COUNT(a0) ; while (pspanpackage->count...)
bne.b .loop
movem.l (sp)+,d2-d7/a2-a6
rts
******************************************************************************
*
* void D_PolysetRecursiveTriangle (int *lp1, int *lp2, int *lp3)
*
******************************************************************************
cnop 0,4
_D_PolysetRecursiveTriangle
***** stackframe
rsreset
.new rs.l 6
.intregs rs.l 11
rs.l 1
.lp1 rs.l 1
.lp2 rs.l 1
.lp3 rs.l 1
movem.l d2-d7/a2-a6,-(sp)
sub.l #.intregs,sp
move.l .lp1(sp),a0
move.l .lp2(sp),a1
move.l .lp3(sp),a2
lea _zspantable,a5
move.l _d_viewbuffer,a6
bsr DoRecursion
add.l #.intregs,sp
movem.l (sp)+,d2-d7/a2-a6
rts
****** a0 -> lp1
****** a1 -> lp2
****** a2 -> lp3
DoRecursion
lea -6*4(sp),sp
move.l sp,a4
* d = lp2[0] - lp1[0];
* if (d < -1 || d > 1)
* goto split;
* d = lp2[1] - lp1[1];
* if (d < -1 || d > 1)
* goto split;
*
* d = lp3[0] - lp2[0];
* if (d < -1 || d > 1)
* goto split2;
* d = lp3[1] - lp2[1];
* if (d < -1 || d > 1)
* goto split2;
*
* d = lp1[0] - lp3[0];
* if (d < -1 || d > 1)
* goto split3;
* d = lp1[1] - lp3[1];
* if (d < -1 || d > 1)
move.l (a1),d0
move.l (a0),d1
move.l 1*4(a1),d2
move.l 1*4(a0),d3
move.l d0,d4
sub.l d1,d4 ;d = lp2[0] - lp1[0]
addq.l #1,d4
cmp.l #2,d4 ;if (d < -1 || d > 1)
bhi.b .split ;goto split
move.l d2,d5
sub.l d3,d5 ;d = lp2[1] - lp1[1]
addq.l #1,d5
cmp.l #2,d5 ;if (d < -1 || d > 1)
bhi.b .split ;goto split
move.l (a2),d4
move.l d4,d5
sub.l d0,d4 ;d = lp3[0] - lp2[0]
addq.l #1,d4
cmp.l #2,d4 ;if (d < -1 || d > 1)
bhi.b .split2 ;goto split2
move.l 1*4(a2),d4
move.l d4,d6
sub.l d2,d4 ;d = lp3[1] - lp2[1]
addq.l #1,d4
cmp.l #2,d4 ;if (d < -1 || d > 1)
bhi.b .split2 ;goto split2
sub.l d1,d5 ;d = lp1[0] - lp3[0]
addq.l #1,d5
cmp.l #2,d5 ;if (d < -1 || d > 1)
bhi.b .split3 ;goto split3
sub.l d3,d6 ;d = lp1[1] - lp3[1]
addq.l #1,d6
cmp.l #2,d6 ;if (d < -1 || d > 1)
bls.b .exit
*split3:
* temp = lp1;
* lp1 = lp3;
* lp3 = lp2;
* lp2 = temp;
*
* goto split;
*
*split2:
* temp = lp1;
* lp1 = lp2;
* lp2 = lp3;
* lp3 = temp;
.split3
exg a1,a2 ;rotate forward
exg a1,a0
move.l (a1),d0
move.l (a0),d1
move.l 1*4(a1),d2
move.l 1*4(a0),d3
bra.b .split
.split2
exg a1,a0 ;rotate backward
exg a1,a2
move.l (a1),d0
move.l (a0),d1
move.l 1*4(a1),d2
move.l 1*4(a0),d3
.split
* new[0] = (lp1[0] + lp2[0]) >> 1;
* new[1] = (lp1[1] + lp2[1]) >> 1;
* new[2] = (lp1[2] + lp2[2]) >> 1;
* new[3] = (lp1[3] + lp2[3]) >> 1;
* new[5] = (lp1[5] + lp2[5]) >> 1;
move.l d0,d4
move.l d0,a3
add.l d1,d4
asr.l #1,d4 ;d4 = new[0]
move.l d2,d5
add.l d3,d5
asr.l #1,d5 ;d5 = new[1]
move.l 2*4(a0),d6
add.l 2*4(a1),d6
asr.l #1,d6 ;d6 = new[2]
move.l 3*4(a0),d7
add.l 3*4(a1),d7
asr.l #1,d7 ;d7 = new[3]
move.l 5*4(a0),d0
add.l 5*4(a1),d0
asr.l #1,d0 ;d0 = new[5]
* if (lp2[1] > lp1[1])
* goto nodraw;
* if ((lp2[1] == lp1[1]) && (lp2[0] < lp1[0]))
* goto nodraw;
move.l d4,(a4)+ ;store new[]
move.l d5,(a4)+
move.l d6,(a4)+
move.l d7,(a4)+
move.l d0,4(a4)
lea -16(a4),a4
swap d0 ;z = new[5]>>16
cmp.l d3,d2 ;if (lp2[1] > lp1[1])
bgt.b .nodraw ;goto nodraw
cmp.l d2,d3 ;if (lp2[1] == lp1[1)
bne.b .draw
cmp.l d1,a3 ;&& (lp2[0] < lp1[0])
blt.b .nodraw ;goto nodraw
.draw
* z = new[5]>>16;
* zbuf = zspantable[new[1]] + new[0];
* if (z >= *zbuf)
* {
* int pix;
*
* *zbuf = z;
* pix = d_pcolormap[skintable[new[3]>>16][new[2]>>16]];
* d_viewbuffer[d_scantable[new[1]] + new[0]] = pix;
* }
move.l 0(a5,d5.l*4),a3
cmp 0(a3,d4.l*2),d0 ;if (z >= *zbuf)
blt.b .nodraw
move d0,0(a3,d4.l*2) ;*zbuf = z
swap d6
swap d7
lea _skintable,a3
move.l 0(a3,d7.w*4),a3 ;skintable[new[3]]
move.b 0(a3,d6.w),d2 ;d2 = skintable[new[3]][new[2]>>16]
and #$ff,d2
move.l _d_pcolormap,a3
move.b 0(a3,d2.w),d2 ;pix = d_pcolormap[d2]
lea _d_scantable,a3
move.l 0(a3,d5.l*4),d1 ;d_scantable[new[1]]
add.l d4,d1 ;+new[0]
move.b d2,0(a6,d1.l) ;d_viewbuffer[d1] = pix
.nodraw
*// recursively continue
* D_PolysetRecursiveTriangle (lp3, lp1, new);
* D_PolysetRecursiveTriangle (lp3, new, lp2);
movem.l a1/a2/a4,-(sp)
move.l a0,a1
move.l a2,a0
move.l a4,a2
bsr DoRecursion ;DRT (lp3, lp1, new)
movem.l (sp)+,a1/a2/a4
move.l a2,a0
move.l a1,a2
move.l a4,a1
bsr DoRecursion ;DRT (lp3, new, lp2)
.exit
lea 6*4(sp),sp
rts
******************************************************************************
*
* void D_PolysetSetUpForLineScan (fixed8_t startvertu,
* fixed8_t startvertv, fixed8_t endvertu, fixed8_t endvertv)
*
* Parameters are transferred in registers d0-d3
******************************************************************************
cnop 0,4
_D_PolysetSetUpForLineScan
***** stackframe
rsreset
.intregs rs.l 2
rs.l 1
.startvertu rs.l 1
.startvertv rs.l 1
.endvertu rs.l 1
.endvertv rs.l 1
* errorterm = -1;
*
* tm = endvertu - startvertu;
* tn = endvertv - startvertv;
move.l #-1,_errorterm
sub.l d0,d2
sub.l d1,d3
add.l #15,d2
add.l #15,d3
* if (((tm <= 16) && (tm >= -15)) &&
* ((tn <= 16) && (tn >= -15)))
* {
* ptemp = &adivtab[((tm+15) << 5) + (tn+15)];
* ubasestep = ptemp->quotient;
* erroradjustup = ptemp->remainder;
* erroradjustdown = tn;
* }
cmp.l #31,d2
bhi.b .else
cmp.l #31,d3
bhi.b .else
lea _adivtab,a0
lsl.l #5,d2
add.l d3,d2
lea 0(a0,d2.l*8),a0
move.l PTEMP_QUOTIENT(a0),_ubasestep
move.l PTEMP_REMAINDER(a0),_erroradjustup
sub.l #15,d3
move.l d3,_erroradjustdown
bra.b .exit
* {
* dm = (double)tm;
* dn = (double)tn;
*
* FloorDivMod (dm, dn, &ubasestep, &erroradjustup);
*
* erroradjustdown = dn;
* }
.else
sub.l #15,d2
sub.l #15,d3
fmove.l d2,fp0
fmove.l d3,fp1
move.l #_erroradjustup,-(sp)
move.l #_ubasestep,-(sp)
fmove.d fp1,-(sp)
fmove.d fp0,-(sp)
jsr _FloorDivMod
add #24,sp
move.l d3,_erroradjustdown
.exit
rts
*****************************************************************************
*
* void D_PolysetCalcGradients (int skinwidth)
*
******************************************************************************
cnop 0,4
_D_PolysetCalcGradients
***** stackframe
rsreset
.fpuregs rs.x 6
.intregs rs.l 3
rs.l 1
.skinwidth rs.l 1
***** prologue
movem.l d2/d3/a2,-(sp)
fmovem.x fp2-fp7,-(sp)
* p00_minus_p20 = r_p0[0] - r_p2[0];
* p01_minus_p21 = r_p0[1] - r_p2[1];
* p10_minus_p20 = r_p1[0] - r_p2[0];
* p11_minus_p21 = r_p1[1] - r_p2[1];
*
* xstepdenominv = 1.0 / (float)d_xdenom;
*
* ystepdenominv = -xstepdenominv;
lea _r_p2,a0
lea _r_p1,a1
lea _r_p0,a2
move.l (a2),d0
move.l 1*4(a2),d1
move.l (a0),d2
sub.l d2,d0
fmove.l d0,fp0 ;fp0 = p00_minus_p20
move.l 1*4(a0),d3
sub.l d3,d1
fmove.l d1,fp1 ;fp1 = p01_minus_p21
sub.l (a1),d2
neg.l d2
fmove.l d2,fp2 ;fp2 = p10_minus_p20
sub.l 4(a1),d3
neg.l d3
fmove.l d3,fp3 ;fp3 = p11_minus_p21
fmove.l _d_xdenom,fp4
fmove.s #1,fp5
fdiv fp4,fp5 ;fp5 = 1.0 / (float)d_xdenom
fneg fp5,fp6 ;fp6 = ystepdenominv
fmul fp5,fp1
fmul fp5,fp3
fmul fp6,fp0
fmul fp6,fp2
* t0 = r_p0[4] - r_p2[4];
* t1 = r_p1[4] - r_p2[4];
* r_lstepx = (int)
* ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
* r_lstepy = (int)
* ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
fmove.l fpcr,d2
fmove.l #$000000b0,fpcr
move.l 4*4(a0),d0
move.l d0,d1
sub.l 4*4(a2),d0
neg.l d0
fmove.l d0,fp4 ;fp4 = t0
sub.l 4*4(a1),d1
neg.l d1
fmove.l d1,fp5 ;fp5 = t1
fmove fp4,fp6
fmul fp3,fp6
fmove fp5,fp7
fmul fp1,fp7
fsub fp6,fp7
fmove.l fp7,_r_lstepx
fmul fp2,fp4
fmul fp0,fp5
fsub fp4,fp5
fmove.l fp5,_r_lstepy
fmove.l d2,fpcr
* t0 = r_p0[2] - r_p2[2];
* t1 = r_p1[2] - r_p2[2];
* r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
* xstepdenominv);
* r_sstepy = (int)((t1 * p00_minus_p20 - t0* p10_minus_p20) *
* ystepdenominv);
move.l 2*4(a0),d0
move.l d0,d1
sub.l 2*4(a2),d0
neg.l d0
fmove.l d0,fp4 ;fp4 = t0
sub.l 2*4(a1),d1
neg.l d1
fmove.l d1,fp5 ;fp5 = t1
fmove fp4,fp6
fmul fp3,fp6
fmove fp5,fp7
fmul fp1,fp7
fsub fp6,fp7
fmove.l fp7,d2
move.l d2,_r_sstepx
fmul fp2,fp4
fmul fp0,fp5
fsub fp4,fp5
fmove.l fp5,_r_sstepy
* t0 = r_p0[3] - r_p2[3];
* t1 = r_p1[3] - r_p2[3];
* r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
* xstepdenominv);
* r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
* ystepdenominv);
move.l 3*4(a0),d0
move.l d0,d1
sub.l 3*4(a2),d0
neg.l d0
fmove.l d0,fp4 ;fp4 = t0
sub.l 3*4(a1),d1
neg.l d1
fmove.l d1,fp5 ;fp5 = t1
fmove fp4,fp6
fmul fp3,fp6
fmove fp5,fp7
fmul fp1,fp7
fsub fp6,fp7
fmove.l fp7,d3
move.l d3,_r_tstepx
fmul fp2,fp4
fmul fp0,fp5
fsub fp4,fp5
fmove.l fp5,_r_tstepy
* t0 = r_p0[5] - r_p2[5];
* t1 = r_p1[5] - r_p2[5];
* r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
* xstepdenominv);
* r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
* ystepdenominv);
move.l 5*4(a0),d0
move.l d0,d1
sub.l 5*4(a2),d0
neg.l d0
fmove.l d0,fp4 ;fp4 = t0
sub.l 5*4(a1),d1
neg.l d1
fmove.l d1,fp5 ;fp5 = t1
fmove fp4,fp6
fmul fp3,fp6
fmove fp5,fp7
fmul fp1,fp7
fsub fp6,fp7
fmove.l fp7,_r_zistepx
fmul fp2,fp4
fmul fp0,fp5
fsub fp4,fp5
fmove.l fp5,_r_zistepy
* a_sstepxfrac = r_sstepx & 0xFFFF;
* a_tstepxfrac = r_tstepx & 0xFFFF;
* a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
move.l .skinwidth(sp),d0
swap d3
muls d3,d0
clr d3
swap d3
move.l d2,d1
swap d1
ext.l d1
add.l d1,d0
and.l #$ffff,d2
move.l d2,_a_sstepxfrac
move.l d3,_a_tstepxfrac
move.l d0,_a_ststepxwhole
fmovem.x (sp)+,fp2-fp7
movem.l (sp)+,d2/d3/a2
rts
******************************************************************************
*
* void D_RasterizeAliasPolySmooth (void)
*
******************************************************************************
cnop 0,4
_D_RasterizeAliasPolySmooth
***** stackframe
rsreset
.pdestx rs.l 1
.pzx rs.l 1
.aspanx rs.l 1
.ptexx rs.l 1
.sfracx rs.l 1
.tfracx rs.l 1
.lightx rs.l 1
.zix rs.l 1
.pdestb rs.l 1
.pzb rs.l 1
.aspanb rs.l 1
.ptexb rs.l 1
.sfracb rs.l 1
.tfracb rs.l 1
.lightb rs.l 1
.zib rs.l 1
.r_affine rs.l 1
.height rs.l 1
.initLH rs.l 1
.initRH rs.l 1
.savearea rs.l 11
.intregs rs.l 11
rs.l 1
movem.l d2-d7/a2-a6,-(sp)
sub #.intregs,sp
* plefttop = pedgetable->pleftedgevert0;
* prighttop = pedgetable->prightedgevert0;
*
* pleftbottom = pedgetable->pleftedgevert1;
* prightbottom = pedgetable->prightedgevert1;
*
* initialleftheight = pleftbottom[1] - plefttop[1];
* initialrightheight = prightbottom[1] - prighttop[1];
move.l _pedgetable,a0
move.l ETAB_PLEV0(a0),a6 ;a6 = plefttop
move.l ETAB_PREV0(a0),a2 ;a2 = prighttop
move.l ETAB_PLEV1(a0),a3 ;a3 = pleftbottom
move.l ETAB_PREV1(a0),a4 ;a4 = prightbottom
lea _r_affinetridesc,a5
move.l 4(a3),d6
move.l 4(a6),d7 ;d7 = plefttop[1]
move.l d6,d2
sub.l d7,d2
move.l d2,.initLH(sp) ;initialleftheight
move.l 4(a4),d3
move.l 4(a2),d4
move.l d3,d5
sub.l d4,d5
move.l d5,.initRH(sp) ;initialrightheight
move.l R_SKINWIDTH(a5),d4
move.l d4,.r_affine(sp)
move.l d4,-(sp)
bsr _D_PolysetCalcGradients
addq #4,sp
move.l d6,d3
move.l (a3),d2
move.l d7,d1
move.l (a6),d0
bsr _D_PolysetSetUpForLineScan
* d_pedgespanpackage = a_spans;
*
* ystart = plefttop[1];
* d_aspancount = plefttop[0] - prighttop[0];
*
* d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
* (plefttop[3] >> 16) * r_affinetridesc.skinwidth;
* d_sfrac = plefttop[2] & 0xFFFF;
* d_tfrac = plefttop[3] & 0xFFFF;
* d_pzbasestep = d_zwidth + ubasestep;
* d_pzextrastep = d_pzbasestep + 1;
* d_light = plefttop[4];
* d_zi = plefttop[5];
*
* d_pdestbasestep = screenwidth + ubasestep;
* d_pdestextrastep = d_pdestbasestep + 1;
* d_pdest = (byte *)d_viewbuffer +
* ystart * screenwidth + plefttop[0];
* d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
move.l _a_spans,_d_pedgespanpackage
move.l (a6),d2
sub.l (a2),d2
move.l d2,_d_aspancount ;d_aspancount = plefttop[0] - ...
move.l 2*4(a6),d0
move.l 3*4(a6),d1
move.l d0,d3 ;d3 = plefttop[2]
move.l d1,d6 ;d6 = plefttop[3]
swap d0
swap d1
and.l #$ffff,d0
and.l #$ffff,d1
mulu d4,d1
add.l d0,d1
add.l R_PSKIN(a5),d1
move.l d1,_d_ptex ;d_ptex = ...
and.l #$ffff,d3
and.l #$ffff,d6
move.l d3,_d_sfrac ;d_sfrac = plefttop[2]&$ffff
move.l d6,_d_tfrac ;d_tfrac = plefttop[3]&$ffff
move.l _d_zwidth,d0
move.l d0,d3 ;d3 = d_zwidth
move.l _ubasestep,d1
move.l d1,.aspanb(sp)
move.l d1,d5 ;d5 = ubasestep
add.l d1,d0
addq.l #1,d1
move.l d1,_d_countextrastep
move.l d1,.aspanx(sp)
add.l d0,d0
move.l d0,.pzb(sp) ;d_pzbasestep = d_zwidth + ubasestep
addq.l #2,d0
move.l d0,.pzx(sp) ;d_pzextrastep = d_pzbasestep + 1
move.l 4*4(a6),_d_light ;d_light = plefttop[4]
move.l 5*4(a6),_d_zi ;d_zi = plefttop[5]
move.l _screenwidth,d0
add.l d0,d1
move.l d1,.pdestx(sp) ;d_pdestextrastep = ...
subq.l #1,d1
move.l d1,.pdestb(sp) ;d_pdestbasestep = screenwidth + ..
mulu d7,d0 ;screenwidth * ystart
move.l (a6),d6
add.l d6,d0 ;+ plefttop[0]
add.l _d_viewbuffer,d0
move.l d0,_d_pdest ;d_pdest + d_viewbuffer + ...
mulu d7,d3 ;d_zwidth * ystart
add.l d6,d3 ;+ plefttop[0]
add.l d3,d3
add.l _d_pzbuffer,d3
move.l d3,_d_pz ;d_pz = d_pzbuffer + ...
* if (ubasestep < 0)
* working_lstepx = r_lstepx - 1;
* else
* working_lstepx = r_lstepx;
*
* d_countextrastep = ubasestep + 1;
* d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
* ((r_tstepy + r_tstepx * ubasestep) >> 16) *
* r_affinetridesc.skinwidth;
* d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
* d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
* d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
* d_zibasestep = r_zistepy + r_zistepx * ubasestep;
*
* d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
* ((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
* r_affinetridesc.skinwidth;
* d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF;
* d_tfracextrastep = (r_tstepy + r_tstepx*d_countextrastep) & 0xFFFF;
* d_lightextrastep = d_lightbasestep + working_lstepx;
* d_ziextrastep = d_zibasestep + r_zistepx;
*
move.l _r_sstepy,a0
move.l _r_sstepx,d1
move.l _r_tstepy,a1
move.l _r_tstepx,d6
move.l d1,d2
muls.l d5,d2
move.l d6,d7
muls.l d5,d7
add.l a0,d2
add.l a1,d7
move.l d2,d0
move.l d7,d3
and.l #$ffff,d0
move.l d0,.sfracb(sp)
and.l #$ffff,d3
swap d3
move.l d3,.tfracb(sp)
swap d3
add.l d1,d0
add.l d6,d3
and.l #$ffff,d0
move.l d0,.sfracx(sp)
and.l #$ffff,d3
swap d3
move.l d3,.tfracx(sp)
swap d3
move.l d2,d0
move.l d7,d3
swap d2
ext.l d2
swap d7
muls d4,d7
add.l d2,d7
move.l d7,.ptexb(sp)
add.l d1,d0
add.l d6,d3
swap d0
ext.l d0
swap d3
muls d4,d3
add.l d0,d3
move.l d3,.ptexx(sp)
move.l _r_lstepy,d0
move.l _r_lstepx,d1
tst.l d5 ;(if ubasestep < 0)
bge.b .ge
subq.l #1,d1 ;working_lstepx = r_lstepx - 1
.ge
move.l d1,d2
muls.l d5,d1
add.l d0,d1
move.l d1,.lightb(sp)
add.l d2,d1
move.l d1,.lightx(sp)
move.l _r_zistepy,d0
move.l _r_zistepx,d1
move.l d1,d2
muls.l d5,d1
add.l d0,d1
move.l d1,.zib(sp)
add.l d2,d1
move.l d1,.zix(sp)
***** D_PolysetScanLeftEdge (inlined)
movem.l d2-d7/a2-a6,.savearea(sp)
move.l _d_pedgespanpackage,a0
move.l _d_pdest,a1
move.l _d_pz,a2
move.l _d_aspancount,d6
move.l _d_ptex,a3
move.l _d_sfrac,d4
move.l _d_tfrac,d5
swap d5
move.l _d_light,a5
move.l _d_zi,a4
move.l _errorterm,d2
move.l _erroradjustup,d1
move.l _erroradjustdown,d0
move.l .initLH(sp),d7
subq #1,d7
.loopA