/
SHADE.S
989 lines (912 loc) · 24.7 KB
/
SHADE.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
; *************************************************************************
; ***** *****
; ***** Routine which draws a 4-planes shaded polygon. *****
; ***** By Alain BROBECKER. *****
; ***** Coded between 22nd and 23rd of june 1994. *****
; ***** Rewritten & Optimised on 25th of june 1994. *****
; ***** *****
; *************************************************************************
; Parameters: a0.l = ramvideo adress.
; a1.l = adress of brows coords and intensities.
; d0.w = nb of brows.
;
; The brows coords and intensities are organised like this:
; 1 word: x.
; 1 word: y.
; 1 word: intensity. (Integer part of it in the 4 most significant bits.)
; The brows must be placed anticlockwise. Also, the min intensity must be
; 2 and the max one must be 14 as there sometimes is an imprecision of
; one color during the interpolation.
; *************************************************************************
movem.l d0-a6,-(sp)
; *************************************************************************
; * First copy the brows once just after their first appearance in a1.l, so
; * the "tracking" of the min & max lines will be easier. At the same time
; * search ymin & ymax of the poly.
.copy_and_search:
move.l a1,a2
move.l a2,a3
move.w d0,d1 ; 6 words per brow.
add.w d1,d1
add.w d0,d1
add.w d1,d1
add.w d1,a3 ; a3 points just after the brows.
move.w #800,d6 ; d6=ymin.
move.w #-600,d7 ; d7=ymax.
subq.w #$1,d0 ; Beware the dbra.
.copy_one_brow:
move.l (a2)+,d1 ; Load x and y in d1.
move.l d1,(a3)+ ; Copy them.
cmp.w d1,d6 ; This y lower than ymin?
blt.s .not_ymin
move.w d1,d6 ; Yes, then it's the new ymin.
.not_ymin:
cmp.w d1,d7 ; This y bigger than ymax?
bgt.s .not_ymax
move.w d1,d7 ; Yes, then it' s the new ymax.
.not_ymax:
move.w (a2)+,(a3)+ ; Copy intensity.
dbra d0,.copy_one_brow ; Next brow.
; *************************************************************************
; * When ymin and ymax are found, we can see if the poly is in the screen,
; * if it' s partly hidden (y_clipping only) or if it' s invisible.
.poly_visibility:
cmp.w d6,d7 ; ymin=ymax?
beq.s .poly_invisible
tst.w d7 ; ymax=<0?
ble.s .poly_invisible
cmp.w #198,d6 ; ymin>=199?
ble.s .poly_clipping
.poly_invisible: ; Poly out of the screen, so...
movem.l (sp)+,d0-a6
rts
.poly_clipping: ; The poly is (partly?) visible.
moveq.l #$0,d0 ; d0=nb h_lines to pass at the beginning.
move.w d7,d1
sub.w d6,d1 ; d1=ymax-ymin=nb h_lines to draw-1.
tst.w d6 ; ymin<0?
bge.s .no_clip_up
.clip_up: ; Yes, so cut the first -ymin h_lines.
move.w d6,d0 ; Pass -ymin h_lines at the beginning.
neg.w d0
move.w d7,d1 ; Nb lines to draw=ymax-0.
bra.s .no_clip_down ; I assume the poly is not that big.
.no_clip_up:
cmp.w #199,d7 ; ymax>199.
ble.s .no_clip_down
.clip_down:
move.w #199,d1 ; Yes, so reduce the nb of h_lines.
sub.w d6,d1
.no_clip_down:
move.w d0,.nb_lines_2_pass
addq.w #$1,d1
move.w d1,.nb_lines_2_draw
; *************************************************************************
; * Not very hard or important, but we must do it, so....
move.l #.y_table,a2 ; The faster way to multiply by 160???
move.w d6,d5
add.w d0,d5 ; d5=first seen y.
add.w d5,d5 ; One word per y.
add.w (a2,d5.w),a0 ; a0 points on first line.
; *************************************************************************
; * Now, the first important part. We "track" the max_lines, which are on
; * the right of the poly and calculate xmax and intensity_max for each
; * y between ymin-ymax by using linear interpolations.
.xmax_tracking: ; First, search the upper right brow.
subq.w #$6,a3 ; Next point in clockwise cycle.
cmp.w $2(a3),d6 ; y=ymin?
bne.s .xmax_tracking
.xmax_ymin_found: ; If the next brow=ymin, then it' s more
cmp.w -$4(a3),d6 ; on the right...
bne.s .xmax_ymin_ok
subq.w #$6,a3 ; It is the upper right brow.
.xmax_ymin_ok: ; a3 points on the good brow.
move.l #.xmax_buffer,a2 ; Store int_maxs and xmaxs here.
move.l #.inverses,a4 ; Inverse table.
move.l #.xmax_ad,a5 ; The adresses for the jump.
.xmax_one_line: ; Interpolate on one line.
move.w (a3),d0 ; d0=x1.
move.w $2(a3),d1 ; d1=y1.
cmp.w d1,d7 ; y1=ymax?
beq .xmax_end ; Yes, then it' s finished.
move.w $4(a3),d2 ; d2=intensity1.
subq.l #$6,a3 ; Next brow.
move.w (a3),d3 ; d3=x2.
move.w $2(a3),d4 ; d4=y2.
move.w $4(a3),d5 ; d5=intensity2.
sub.w d1,d4 ; d4=y2-y1, always <>0.
add.w d4,d4 ; One word per inverse.
move.w (a4,d4.w),d1 ; d1=16384/(y2-y1).
add.w d4,d4 ; Two words per jump adress.
move.l (a5,d4.w),a6 ; a6=adress where to jump.
sub.w d2,d5 ; d5=int2-int1.
muls.w d1,d5
lsl.l #$2,d5 ; d5=65536*(int2-int1)/dy.
sub.w d0,d3 ; d3=x2-x1.
muls.w d1,d3
lsl.l #$2,d3 ; d3=65536*(dx/dy).
swap.w d3
move.w d3,d5 ; up(d5)=dint/dy ; low(d5)=int(dx/dy).
swap.w d3 ; low(d3)=reg(dx/dy).
swap.w d2
move.w d0,d2 ; up(d2)=intensity ; low(d2)=x.
moveq.l #$0,d0 ; d0=error.
jmp (a6)
rept 300
move.l d2,(a2)+ ; Save intensity and x.
add.w d3,d0 ; error=error+reg(dx/dy).
addx.l d5,d2 ; int=int+inc ; x=x+int(dy/dx)+eXtend.
endr
.xmax_line_end:
subq.w #$4,a2 ; Erase last point.
bra .xmax_one_line
.xmax_end:
; *************************************************************************
; * Do the same with the min_lines, which are on the right of the poly
; * and calculate xmin and intensity_min for each y between ymin-ymax by
; * using linear interpolations.
subq.w #$6,a1
.xmin_tracking: ; First, search the upper left brow.
addq.w #$6,a1 ; Next point in anticlockwise cycle.
cmp.w $2(a1),d6 ; y=ymin?
bne.s .xmin_tracking
.xmin_ymin_found: ; If the next brow=ymin, then it' s more
cmp.w $a(a1),d6 ; on the left...
bne.s .xmin_ymin_ok
addq.w #$6,a3 ; It is the upper left brow.
.xmin_ymin_ok: ; a1 points on the good brow.
move.l #.xmin_buffer,a2 ; Store int_mins and xmins here.
move.l #.inverses,a4 ; Inverse table.
move.l #.xmin_ad,a5 ; The adresses for the jump.
.xmin_one_line: ; Interpolate on one line.
move.w (a1)+,d0 ; d0=x1.
move.w (a1)+,d1 ; d1=y1.
cmp.w d1,d7 ; y1=ymax?
beq .xmin_end ; Yes, then it' s finished.
move.w (a1)+,d2 ; d2=intensity1.
move.w (a1),d3 ; d3=x2.
move.w $2(a1),d4 ; d4=y2.
move.w $4(a1),d5 ; d5=intensity2.
sub.w d1,d4 ; d4=y2-y1, always <>0.
add.w d4,d4 ; One word per inverse.
move.w (a4,d4.w),d1 ; d1=16384/(y2-y1).
add.w d4,d4 ; Two words per jump adress.
move.l (a5,d4.w),a6 ; a6=adress where to jump.
sub.w d2,d5 ; d5=int2-int1.
muls.w d1,d5
lsl.l #$2,d5 ; d5=65536*(int2-int1)/dy.
sub.w d0,d3 ; d3=x2-x1.
muls.w d1,d3
lsl.l #$2,d3 ; d3=65536*(dx/dy).
swap.w d3
move.w d3,d5 ; up(d5)=dint/dy ; low(d5)=int(dx/dy).
swap.w d3 ; low(d3)=reg(dx/dy).
swap.w d2
move.w d0,d2 ; up(d2)=intensity ; low(d2)=x.
moveq.l #$0,d0 ; d0=error.
jmp (a6)
rept 300
move.l d2,(a2)+ ; Save intensity and x.
add.w d3,d0 ; error=error+reg(dx/dy).
addx.l d5,d2 ; int=int+inc ; x=x+int(dy/dx)+eXtend.
endr
.xmin_line_end:
subq.w #$4,a2 ; Erase last point.
bra .xmin_one_line
.xmin_end:
; *************************************************************************
; * Ok, now we have all we want, it' s now time to draw the poly on the
; * screen. I proceed by drawing each h_line one after another, and as
; * intensity_min and intensity_max are different, I have to do an
; * interpolation between them.
.draw_shaded:
move.l #.xmin_buffer,a1
move.w .nb_lines_2_pass,d0
add.w d0,d0 ; 4 bytes per int+x.
add.w d0,d0
add.w d0,a1 ; Pass the invisible lines.
move.l #.points_ad,-(sp) ; Store the table x->adress.
move.l #.endrouts_ad,-(sp) ; Table xmax mod(16)->endrout adress.
move.w .nb_lines_2_draw,d0 ; The counter.
subq.w #$1,d0 ; Beware dbra..
move.w d0,-(sp) ; Store the counter.
move.l #.inverses,a2
.draw_one_hline:
move.w d0,(sp) ; Store the counter.
move.w (a1)+,d5 ; d5=int_min.
move.w 1198(a1),d6 ; d6=int_max.
move.w (a1)+,d0 ; d0=xmin.
move.w 1198(a1),d1 ; d1=xmax.
move.w d1,d2
sub.w d0,d2 ; d2=xmax-xmin=dx.
ble.s .next_line ; Don' t draw if xmin>=xmax.
add.w d2,d2
move.w (a2,d2.w),d2 ; d2=16384/dx.
sub.w d5,d6 ; d6=int_max-int_min=dint.
add.w d5,d5 ; The intensity in the 4 Msbits...
muls.w d2,d6
lsl.l #$3,d6 ; d6=2*65536*(dint/dx). No more sign bit.
swap.w d6 ; In the lowerword please.
move.w d6,d7
add.w #$800,d6 ; d6=inc1=0.5+(dint/dx).
sub.w #$800,d7 ; d7=inc2=-0.5+(dint/dx).
move.l $2(sp),a4 ; a4=endrouts_ad table.
move.w d1,d2
moveq.l #$f,d3
and.w d3,d2 ; d2=xmax mod(16).
add.w d2,d2 ; One long per adress.
add.w d2,d2
move.l (a4,d2.w),a4 ; a4 points on the endrout to use.
move.l $6(sp),a5 ; points_ad table.
and.w d0,d3 ; d3=xmin mod(16).
sub.w d3,d0 ; d0=xmin-xmin mod(16).
add.w d3,d3
add.w d3,d3
move.l (a5,d3.w),a3 ; a3 points on first point.
sub.w d0,d1 ; d1=xmax-(xmin-xmin mod(16)).
add.w d1,d1
add.w d1,d1
move.l (a5,d1.w),a5 ; a5 points on last point-1.
move.w #$4ed4,(a5) ; Put the "jump (a4)".
lsr.w #$1,d0 ; d0=offset to xmin.
move.l a0,a6
add.w d0,a6 ; a6 points on first word.
add.w #$a0,a0 ; Next line.
moveq.l #$0,d1 ; Clear bitplanes.
moveq.l #$0,d2
moveq.l #$0,d3
moveq.l #$0,d4
jmp (a3) ; Go on first point.
.next_line:
move.w (sp),d0 ; Load the counter.
dbra d0,.draw_one_hline
add.w #$a,sp ; Fuck the stored tiddies.
.the_end:
movem.l (sp)+,d0-a6
rts
.draw_one_hline2:
move.w d0,(sp) ; Store the counter.
move.w (a1)+,d5 ; d5=int_min.
move.w 1198(a1),d6 ; d6=int_max.
move.w (a1)+,d0 ; d0=xmin.
move.w 1198(a1),d1 ; d1=xmax.
move.w d1,d2
sub.w d0,d2 ; d2=xmax-xmin=dx.
ble.s .next_line2 ; Don' t draw if xmin>=xmax.
add.w d2,d2
move.w (a2,d2.w),d2 ; d2=16384/dx.
sub.w d5,d6 ; d6=int_max-int_min=dint.
add.w d5,d5 ; The intensity in the 4 Msbits...
muls.w d2,d6
lsl.l #$3,d6 ; d6=2*65536*(dint/dx). No more sign bit.
swap.w d6 ; In the lowerword please.
move.w d6,d7
sub.w #$800,d6 ; d6=inc1=0.5+(dint/dx).
add.w #$800,d7 ; d7=inc2=-0.5+(dint/dx).
move.l $2(sp),a4 ; a4=endrouts_ad table.
move.w d1,d2
moveq.l #$f,d3
and.w d3,d2 ; d2=xmax mod(16).
add.w d2,d2 ; One long per adress.
add.w d2,d2
move.l 16*4(a4,d2.w),a4 ; a4 points on the endrout to use.
move.l $6(sp),a5 ; points_ad table.
and.w d0,d3 ; d3=xmin mod(16).
sub.w d3,d0 ; d0=xmin-xmin mod(16).
add.w d3,d3
add.w d3,d3
move.l (a5,d3.w),a3 ; a3 points on first point.
sub.w d0,d1 ; d1=xmax-(xmin-xmin mod(16)).
add.w d1,d1
add.w d1,d1
move.l (a5,d1.w),a5 ; a5 points on last point-1.
move.w #$4ed4,(a5) ; Put the "jump (a4)".
lsr.w #$1,d0 ; d0=offset to xmin.
move.l a0,a6
add.w d0,a6 ; a6 points on first word.
add.w #$a0,a0 ; Next line.
moveq.l #$0,d1 ; Clear bitplanes.
moveq.l #$0,d2
moveq.l #$0,d3
moveq.l #$0,d4
jmp (a3) ; Go on first point.
.next_line2:
move.w (sp),d0 ; Load the counter.
dbra d0,.draw_one_hline
add.w #$a,sp ; Fuck the stored tiddies.
.the_end2:
movem.l (sp)+,d0-a6
rts
; *************************************************************************
; * We have to use different endroutines in order to gain speed, cos the
; * ending bitplanes must be rotated and they must be "or.w".
shademac1: MACRO
add.w d5,d5
addx.w d4,d4
add.w d5,d5
addx.w d3,d3
add.w d5,d5
addx.w d2,d2
add.w d5,d5
addx.w d1,d1
ENDM
shademac2: MACRO
and.w d0,d1
and.w d0,d2
and.w d0,d3
and.w d0,d4
ENDM
shademac3: MACRO
or.w d1,(a6)+
or.w d2,(a6)+
or.w d3,(a6)+
or.w d4,(a6)+
ENDM
shademac4: MACRO
move.w #$3005,(a5) ; Restore initial code.
move.w (sp),d0 ; Load counter.
dbra d0,.draw_one_hline2
add.w #$a,sp ; Fuck the stored tiddies.
movem.l (sp)+,d0-a6 ; The end.
rts
ENDM
.endrout_0:
shademac1 ; Convert last point.
ror.w #$1,d1 ; Rotate the bitplanes.
ror.w #$1,d2
ror.w #$1,d3
ror.w #$1,d4
move.w #$8000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_1:
shademac1 ; Convert last point.
ror.w #$2,d1 ; Rotate the bitplanes.
ror.w #$2,d2
ror.w #$2,d3
ror.w #$2,d4
move.w #$c000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_2:
shademac1 ; Convert last point.
ror.w #$3,d1 ; Rotate the bitplanes.
ror.w #$3,d2
ror.w #$3,d3
ror.w #$3,d4
move.w #$e000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_3:
shademac1 ; Convert last point.
ror.w #$4,d1 ; Rotate the bitplanes.
ror.w #$4,d2
ror.w #$4,d3
ror.w #$4,d4
move.w #$f000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_4:
shademac1 ; Convert last point.
ror.w #$5,d1 ; Rotate the bitplanes.
ror.w #$5,d2
ror.w #$5,d3
ror.w #$5,d4
move.w #$f800,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_5:
shademac1 ; Convert last point.
ror.w #$6,d1 ; Rotate the bitplanes.
ror.w #$6,d2
ror.w #$6,d3
ror.w #$6,d4
move.w #$fc00,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_6:
shademac1 ; Convert last point.
ror.w #$7,d1 ; Rotate the bitplanes.
ror.w #$7,d2
ror.w #$7,d3
ror.w #$7,d4
move.w #$fe00,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac4
.endrout_7:
shademac1 ; Convert last point.
lsl.w #$8,d1 ; Rotate the bitplanes.
lsl.w #$8,d2
lsl.w #$8,d3
lsl.w #$8,d4
shademac3 ; Print last word.
shademac4
.endrout_8:
shademac1 ; Convert last point.
lsl.w #$7,d1 ; Rotate the bitplanes.
lsl.w #$7,d2
lsl.w #$7,d3
lsl.w #$7,d4
shademac3 ; Print last word.
shademac4
.endrout_9:
shademac1 ; Convert last point.
lsl.w #$6,d1 ; Rotate the bitplanes.
lsl.w #$6,d2
lsl.w #$6,d3
lsl.w #$6,d4
shademac3 ; Print last word.
shademac4
.endrout_a:
shademac1 ; Convert last point.
lsl.w #$5,d1 ; Rotate the bitplanes.
lsl.w #$5,d2
lsl.w #$5,d3
lsl.w #$5,d4
shademac3 ; Print last word.
shademac4
.endrout_b:
shademac1 ; Convert last point.
lsl.w #$4,d1 ; Rotate the bitplanes.
lsl.w #$4,d2
lsl.w #$4,d3
lsl.w #$4,d4
shademac3 ; Print last word.
shademac4
.endrout_c:
shademac1 ; Convert last point.
lsl.w #$3,d1 ; Rotate the bitplanes.
lsl.w #$3,d2
lsl.w #$3,d3
lsl.w #$3,d4
shademac3 ; Print last word.
shademac4
.endrout_d:
shademac1 ; Convert last point.
lsl.w #$2,d1 ; Rotate the bitplanes.
lsl.w #$2,d2
lsl.w #$2,d3
lsl.w #$2,d4
shademac3 ; Print last word.
shademac4
.endrout_e:
shademac1 ; Convert last point.
add.w d1,d1 ; Rotate the bitplanes.
add.w d2,d2
add.w d3,d3
add.w d4,d4
shademac3 ; Print last word.
shademac4
.endrout_f:
shademac1 ; Convert last point.
shademac3
shademac4
shademac42: MACRO
move.w #$3005,(a5) ; Restore initial code.
move.w (sp),d0 ; Load counter.
dbra d0,.draw_one_hline
add.w #$a,sp ; Fuck the stored tiddies.
movem.l (sp)+,d0-a6 ; The end.
rts
ENDM
.endrout_10:
shademac1 ; Convert last point.
ror.w #$1,d1 ; Rotate the bitplanes.
ror.w #$1,d2
ror.w #$1,d3
ror.w #$1,d4
move.w #$8000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_11:
shademac1 ; Convert last point.
ror.w #$2,d1 ; Rotate the bitplanes.
ror.w #$2,d2
ror.w #$2,d3
ror.w #$2,d4
move.w #$c000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_12:
shademac1 ; Convert last point.
ror.w #$3,d1 ; Rotate the bitplanes.
ror.w #$3,d2
ror.w #$3,d3
ror.w #$3,d4
move.w #$e000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_13:
shademac1 ; Convert last point.
ror.w #$4,d1 ; Rotate the bitplanes.
ror.w #$4,d2
ror.w #$4,d3
ror.w #$4,d4
move.w #$f000,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_14:
shademac1 ; Convert last point.
ror.w #$5,d1 ; Rotate the bitplanes.
ror.w #$5,d2
ror.w #$5,d3
ror.w #$5,d4
move.w #$f800,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_15:
shademac1 ; Convert last point.
ror.w #$6,d1 ; Rotate the bitplanes.
ror.w #$6,d2
ror.w #$6,d3
ror.w #$6,d4
move.w #$fc00,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_16:
shademac1 ; Convert last point.
ror.w #$7,d1 ; Rotate the bitplanes.
ror.w #$7,d2
ror.w #$7,d3
ror.w #$7,d4
move.w #$fe00,d0 ; For destroying unusefull bits.
shademac2 ; Fuck them.
shademac3 ; Print last word.
shademac42
.endrout_17:
shademac1 ; Convert last point.
lsl.w #$8,d1 ; Rotate the bitplanes.
lsl.w #$8,d2
lsl.w #$8,d3
lsl.w #$8,d4
shademac3 ; Print last word.
shademac42
.endrout_18:
shademac1 ; Convert last point.
lsl.w #$7,d1 ; Rotate the bitplanes.
lsl.w #$7,d2
lsl.w #$7,d3
lsl.w #$7,d4
shademac3 ; Print last word.
shademac42
.endrout_19:
shademac1 ; Convert last point.
lsl.w #$6,d1 ; Rotate the bitplanes.
lsl.w #$6,d2
lsl.w #$6,d3
lsl.w #$6,d4
shademac3 ; Print last word.
shademac42
.endrout_1a:
shademac1 ; Convert last point.
lsl.w #$5,d1 ; Rotate the bitplanes.
lsl.w #$5,d2
lsl.w #$5,d3
lsl.w #$5,d4
shademac3 ; Print last word.
shademac42
.endrout_1b:
shademac1 ; Convert last point.
lsl.w #$4,d1 ; Rotate the bitplanes.
lsl.w #$4,d2
lsl.w #$4,d3
lsl.w #$4,d4
shademac3 ; Print last word.
shademac42
.endrout_1c:
shademac1 ; Convert last point.
lsl.w #$3,d1 ; Rotate the bitplanes.
lsl.w #$3,d2
lsl.w #$3,d3
lsl.w #$3,d4
shademac3 ; Print last word.
shademac42
.endrout_1d:
shademac1 ; Convert last point.
lsl.w #$2,d1 ; Rotate the bitplanes.
lsl.w #$2,d2
lsl.w #$2,d3
lsl.w #$2,d4
shademac3 ; Print last word.
shademac42
.endrout_1e:
shademac1 ; Convert last point.
add.w d1,d1 ; Rotate the bitplanes.
add.w d2,d2
add.w d3,d3
add.w d4,d4
shademac3 ; Print last word.
shademac42
.endrout_1f:
shademac1 ; Convert last point.
shademac3
shademac42
; *************************************************************************
; * The core of the shading poly routine... Very repetitive, cos I don' t
; * like the dbra and I LOOOOooove Speed....
shademac5: MACRO
move.w d5,d0 ; Convert first point.
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0 ; Convert second point.
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; intensity=intensity+increment2.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; intensity=intensity+increment2.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; Intensity=intensity+increment2.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; intensity=intensity+increment2.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; intensity=intensity+increment2.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d6,d5 ; intensity=intensity+increment1.
move.w d5,d0
add.w d0,d0
addx.w d4,d4
add.w d0,d0
addx.w d3,d3
add.w d0,d0
addx.w d2,d2
add.w d0,d0
addx.w d1,d1
add.w d7,d5 ; Intensity=intensity+increment2.
ENDM
.core:
shademac5 ; 16 pixies.
or.w d1,(a6)+ ; Print first bitlanes.
or.w d2,(a6)+
or.w d3,(a6)+
or.w d4,(a6)+
.core_2:
shademac5 ; Do 16 pixies.
movem.w d1-d4,(a6) ; Store planes.
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
shademac5
movem.w d1-d4,(a6)
addq.w #$8,a6
; *************************************************************************
Section DATA
.y_table: ; Table for y->y*160 conversions.
N set 0
rept 200
dc.w N
N set N+160
endr
.inverses: ; Table n->16384/n.
incbin 'e:\demos\positivi.ty\passion\shading\inverses.xxx'
.xmax_ad: ; Table of adresses for the jump.
N set 6
rept 300
dc.l .xmax_line_end-N
N set N+6
endr
.xmin_ad: ; The same for the xmin tracking.
N set 6
rept 300
dc.l .xmin_line_end-N
N set N+6
endr
.points_ad: ; Convert x->adress in the "core".
N set 0 ; For the first 16 pixies.
rept 16
dc.l .core+N
N set N+20
endr
N set 0 ; For the next ones.
rept 15 ; 240 points.
dc.l .core_2+000+N,.core_2+020+N
dc.l .core_2+040+N,.core_2+060+N
dc.l .core_2+080+N,.core_2+100+N
dc.l .core_2+120+N,.core_2+140+N
dc.l .core_2+160+N,.core_2+180+N
dc.l .core_2+200+N,.core_2+220+N
dc.l .core_2+240+N,.core_2+260+N
dc.l .core_2+280+N,.core_2+300+N
N set N+320+6
endr
.endrouts_ad: ; Table for the endrouts adresses.
dc.l .endrout_0,.endrout_1,.endrout_2,.endrout_3
dc.l .endrout_4,.endrout_5,.endrout_6,.endrout_7
dc.l .endrout_8,.endrout_9,.endrout_a,.endrout_b
dc.l .endrout_c,.endrout_d,.endrout_e,.endrout_f
dc.l .endrout_10,.endrout_11,.endrout_12,.endrout_13
dc.l .endrout_14,.endrout_15,.endrout_16,.endrout_17
dc.l .endrout_18,.endrout_19,.endrout_1a,.endrout_1b
dc.l .endrout_1c,.endrout_1d,.endrout_1e,.endrout_1f
; *************************************************************************
Section BSS
.nb_lines_2_pass: ; This two vars are used for the clipping.
ds.w 1
.nb_lines_2_draw:
ds.w 1
.xmin_buffer:
ds.l 300
.xmax_buffer:
ds.l 300