|
|
1.1 root 1: .long
2: .dc.l codeend - _ref7_start
3: _ref7_start::
4: .gpu
5: .org $f03100
6:
7: DIVCONTROL .equ $f0211c
8:
9: S_LE .ccdef $14 ; PL
10: U_LE .ccdef $04 ; CC
11: S_GT .ccdef $18 ; MI
12: U_GT .ccdef $08 ; CS
13:
14: S_LT .ccdef $15 ; PL+NE
15: U_LT .ccdef $05 ; CC+NE
16:
17: FP .equr r14
18: scratch .equr r10
19: scratch2 .equr r11
20: RETURNVALUE .equr r29
21: RETURNPOINT .equr r28
22: MATH_A .equr r27
23: MATH_B .equr r26
24: MATH_C .equr r25
25: MATH_RTS .equr r24
26: MATH_SIGN .equr r23
27:
28: alt_plane_lightmax .equr r4
29: alt_plane_lightmin .equr r5
30: alt_plane_lightcoef .equr r6
31: alt_plane_lightsub .equr r7
32: alt_baseyscale .equr r8
33: alt_basexscale .equr r9
34: alt_planeheight .equr r10
35: alt_planesource .equr r11
36: alt_planeangle .equr r12
37: alt_planey .equr r13
38: alt_planex .equr r14
39: alt_400000 .equr r15
40:
41: ;===========================================================================
42: _R_DrawPlanes::
43: ;4 dag registers 3 register variables
44: ;localoffset:4 regoffset:4 argoffset:36
45: ;===========================================================================
46: movei #36,scratch
47: sub scratch,FP
48:
49: nop
50: store RETURNPOINT,(FP+1)
51:
52: ;================
53: ; load constants into alternate register bank
54: ;================
55: movei #$400000,r0
56: moveta r0,alt_400000
57:
58: movei #_viewx,r0
59: load (r0),r0
60: moveta r0,alt_planex
61:
62: movei #_viewy,r0
63: load (r0),r0
64: neg r0
65: moveta r0,alt_planey
66:
67: movei #_viewangle,r0
68: load (r0),r0
69: moveta r0,alt_planeangle
70:
71: movei #1073741824,r1
72: sub r1,r0
73: shrq #19,r0
74: move r0,r17 ;(angle)
75:
76: move r17,r1 ;(angle)
77: shlq #2,r1
78: movei #_finecosine,r2
79: load (r2),r2
80: move r1,r3
81: add r2,r3
82: load (r3),r2
83: movei #80,r3
84: move r3,MATH_SIGN
85: move r3,MATH_B
86: xor r2,MATH_SIGN
87: abs MATH_B
88: abs r2
89: div MATH_B,r2
90: btst #31, MATH_SIGN
91: jr EQ,L71
92: nop
93: neg r2
94: L71:
95: moveta r2,alt_basexscale
96:
97: movei #_finesine,r2
98: add r2,r1
99: load (r1),r1
100: move r3,MATH_SIGN
101: move r3,MATH_B
102: xor r1,MATH_SIGN
103: abs MATH_B
104: abs r1
105: div MATH_B,r1
106: btst #31, MATH_SIGN
107: jr EQ,L72
108: nop
109: neg r1
110: L72:
111: neg r1
112: moveta r1,alt_baseyscale
113:
114: L53:
115: movei #_junk,r0
116: movei #15737400,r1
117: load (r1),r1
118: store r1,(r0)
119: move r1,r0
120: moveq #1,r1
121: and r1,r0
122: moveq #0,r1
123: cmp r0,r1
124: movei #L53,scratch
125: jump EQ,(scratch)
126: nop
127:
128: movei #15737348,r0
129: movei #208928,r1
130: store r1,(r0)
131:
132: movei #15737384,r0
133: movei #80416,r1
134: store r1,(r0)
135:
136: movei #_visplanes+348,r0
137: move r0,r15 ;(pl)
138:
139: movei #L59,r0
140: jump T,(r0)
141: nop
142:
143: L56:
144:
145: move r15,r0 ;(pl)
146: addq #12,r0
147: load (r0),r0
148: move r15,r1 ;(pl)
149: addq #16,r1
150: load (r1),r1
151: cmp r0,r1
152: movei #L61,scratch
153: jump PL,(scratch)
154: nop
155:
156: movei #L57,r0
157: jump T,(r0)
158: nop
159:
160: L61:
161:
162: L63:
163: movei #_junk,r0
164: movei #15737400,r1
165: load (r1),r1
166: store r1,(r0)
167: move r1,r0
168: moveq #1,r1
169: and r1,r0
170: moveq #0,r1
171: cmp r0,r1
172: movei #L63,scratch
173: jump EQ,(scratch)
174: nop
175:
176: load (r15+1),r1 ; (pl)
177: movei #$f02200,r0 ; plane source
178: store r1,(r0)
179:
180: load (r15),r0 ;(pl)
181: abs r0
182: moveta r0,alt_planeheight
183:
184: L66:
185:
186: move r15,r0 ;(pl)
187: addq #8,r0
188: load (r0),r0
189: move r0,r16 ;(light)
190: movei #255,r1
191: sub r16,r1 ;(light)
192: shlq #1,r1
193: move r16,r2 ;(light)
194: sub r1,r2
195: moveta r2,alt_plane_lightmin
196: moveq #0,r1
197: cmp r2,r1
198: movei #L68,scratch
199: jump EQ,(scratch)
200: nop
201: jump MI,(scratch)
202: nop
203:
204: moveq #0,r1
205: moveta r1,alt_plane_lightmin
206:
207: L68:
208:
209: moveta r16,alt_plane_lightmax
210:
211: movei #160,r1
212: movefa alt_plane_lightmin,r2
213: move r16,r3 ;(light)
214: sub r2,r3
215: move r3,r4
216: imult r1,r3
217: movei #640,r2
218: div r2,r3
219: moveta r3,alt_plane_lightsub
220:
221: shlq #11,r4
222: moveta r4,alt_plane_lightcoef
223:
224: move r15,r0 ;(pl)
225: addq #16,r0
226: load (r0),r0
227: shlq #1,r0
228: move r15,r1 ;(pl)
229: addq #26,r1
230: add r1,r0
231: movei #65280,r1
232: storew r1,(r0)
233:
234: move r15,r0 ;(pl)
235: addq #12,r0
236: load (r0),r0
237: shlq #1,r0
238: subq #2,r0
239: move r15,r1 ;(pl)
240: addq #24,r1
241: add r1,r0
242: movei #65280,r1
243: storew r1,(r0)
244:
245: store r15,(FP) ; arg[] ;(pl)
246: movei #_R_PlaneLoop,r0
247: move PC,RETURNPOINT
248: jump T,(r0)
249: addq #6,RETURNPOINT
250: load (FP),r15
251:
252: L57:
253:
254: movei #348,r0
255: move r15,r1 ;(pl)
256: add r0,r1
257: move r1,r15 ;(pl)
258:
259: L59:
260:
261: move r15,r0 ;(pl)
262: movei #_lastvisplane,r1
263: load (r1),r1
264: cmp r0,r1
265: movei #L56,scratch
266: jump U_LT,(scratch)
267: nop
268:
269: movei #_phasetime+28,r0
270: movei #_samplecount,r1
271: load (r1),r1
272: store r1,(r0)
273:
274: movei #_gpucodestart,r0
275: movei #_ref8_start,r1
276: store r1,(r0)
277:
278:
279: L52:
280: load (FP+1),RETURNPOINT
281: movei #36,scratch
282: jump T,(RETURNPOINT)
283: add scratch,FP ; delay slot
284:
285: ;=======================
286:
287: .extern _lastvisplane
288: .extern _visplanes
289: .extern _phasetime
290: .extern _viewangle
291: .extern _viewy
292: .extern _viewx
293: .extern _gpucodestart
294: .extern _samplecount
295: .extern _junk
296: .extern _finecosine
297: .extern _finesine
298: .extern _ref8_start
299:
300:
301: .extern _yslope,_distscale,_xtoviewangle
302:
303: ;==============================================================================
304: _R_PlaneLoop::
305: ;==============================================================================
306:
307: pl_L_topstarts .equr r0
308: pl_L_checkbottomdif .equr r1
309: pl_L_topdif .equr r2
310: pl_L_next .equr r3
311: pl_L_bottomstarts .equr r4
312: pl_L_xloop .equr r5
313: pl_L_bottomdif .equr r6
314:
315: pl_spanstart .equr r15
316: pl_pl .equr r15
317:
318: pl_x .equr r16
319: pl_stopx .equr r17
320: pl_t1 .equr r18
321: pl_t2 .equr r19
322: pl_b1 .equr r20
323: pl_b2 .equr r21
324: pl_oldtop .equr r22
325: pl_oldbottom .equr r23
326: pl_openptr .equr r24
327: pl_ff .equr r25
328: pl_cmdhigh .equr r26
329:
330: pl_stopfp .equr r13 ; must stay constant across R_MapPlane
331:
332: ;scratch .equr r10
333: ;scratch2 .equr r11
334: ;FP .equr r14
335: ;RETURNPOINT .equr r28
336:
337: load (FP),pl_pl ; get plane
338:
339: move pl_pl,pl_openptr
340: load (pl_pl+3),pl_x ; pl_x = pl->minx
341: addq #6*4,pl_openptr ; pl_openptr = pl->open
342: load (pl_pl+4),pl_stopx ; pl_stopx = pl->maxx
343:
344: cmp pl_x,pl_stopx ; see if there is any open space
345: jump U_GT,(RETURNPOINT) ; nothing to map
346: addq #2,pl_stopx ; pl_stopx = pl->maxx+2 (harmless delay slot)
347:
348: subq #4,FP ; space for returnpoint
349: store RETURNPOINT,(FP) ; save returnpoint before pushing cmds
350: move FP,pl_stopfp ; when command que is back here, stop
351:
352: move pl_x,scratch
353: shlq #1,scratch
354: add scratch,pl_openptr ; pl_openptr = &pl->open[x-1]
355: subq #2,pl_openptr
356:
357: movei #_spanstart,pl_spanstart ; allow indexed loads on spanstart[]
358: movei #$ff,pl_ff
359:
360: movei #pl_topstarts,pl_L_topstarts
361: movei #pl_checkbottmdif,pl_L_checkbottomdif
362: movei #pl_topdif,pl_L_topdif
363: movei #pl_next,pl_L_next
364: movei #pl_bottomstarts,pl_L_bottomstarts
365: movei #pl_xloop,pl_L_xloop
366: movei #pl_bottomdif,pl_L_bottomdif
367:
368: ; oldtop = open[x-1];
369: ; oldbottom = oldtop&0xff;
370: ; oldtop >>= 8;
371: loadw (pl_openptr),pl_t1
372: addq #2,pl_openptr
373: move pl_t1,pl_b1
374: and pl_ff,pl_b1
375: shrq #8,pl_t1
376:
377: loadw (pl_openptr),pl_t2 ; delay sloted
378: ;----------------------
379: ;
380: pl_xloop:
381: ;
382: ;-----------------------
383: ; t1 = oldtop;
384: ; b1 = oldbottom;
385: ; t2 = open[x];
386: ; b2 = t2&0xff;
387: ; t2 >>= 8;
388: ; oldtop = t2;
389: ; oldbottom = b2;
390:
391: move pl_t2,pl_b2
392: and pl_ff,pl_b2
393: shrq #8,pl_t2
394: move pl_x,pl_cmdhigh
395: subq #1,pl_cmdhigh
396: shlq #16,pl_cmdhigh
397:
398: ;------------------------
399: ;
400: ; top diffs
401: ;
402: ;------------------------
403: ; if (t1 != t2)
404: move pl_t2,pl_oldtop
405: cmp pl_t1,pl_oldtop
406: move pl_b2,pl_oldbottom
407: jump EQ,(pl_L_checkbottomdif)
408: addq #2,pl_openptr ; reordered delay slot
409:
410: pl_topdif:
411: cmp pl_t1,pl_t2
412: jump U_GT,(pl_L_topstarts)
413: nop
414: jump EQ,(pl_L_topstarts)
415: cmp pl_t1,pl_b1 ; harmless delay slot
416: jump U_GT,(pl_L_topstarts)
417:
418: ;
419: ; R_MapPlane ( ((x-1)<<16) + (t1<<8) + spanstart[t1]);
420: ;
421: move pl_t1,scratch ; harmless delay slot
422: move pl_t1,scratch2
423: shlq #8,scratch
424: shlq #2,scratch2
425: or pl_cmdhigh,scratch
426: load (pl_spanstart+scratch2),scratch2
427: subq #4,FP
428: or scratch2,scratch
429: addqt #1,pl_t1 ; t1++
430: jump T,(pl_L_topdif)
431: store scratch,(FP) ; delay slot
432:
433: ;
434: ; top dif spanstarts
435: ;
436: pl_topstarts:
437: cmp pl_t2,pl_t1
438: jump U_GT,(pl_L_checkbottomdif)
439: move pl_t2,scratch2 ; harmless delay slot
440: jump EQ,(pl_L_checkbottomdif)
441: shlq #2,scratch2 ; harmless delay slot
442: cmp pl_t2,pl_b2
443: jump U_GT,(pl_L_checkbottomdif)
444: nop
445:
446: ; spanstart[t2] = x
447: addqt #1,pl_t2
448: jr T,pl_topstarts
449: store pl_x,(pl_spanstart+scratch2) ; delay slot
450:
451:
452: ;------------------------
453: ;
454: ; bottom diffs
455: ;
456: ;------------------------
457: pl_checkbottmdif:
458: ; if (b1 != b2)
459: cmp pl_b1,pl_b2
460: jump EQ,(pl_L_next)
461:
462: pl_bottomdif:
463: cmp pl_b1,pl_b2 ; harmless delay slot
464: jump U_LE,(pl_L_bottomstarts)
465: cmp pl_b1,pl_t1 ; harmless delay slot
466: jr EQ,pl_bottomplane
467: move pl_b1,scratch ; harmless delay slot
468: jump U_LE,(pl_L_bottomstarts)
469: pl_bottomplane:
470: ;
471: ;R_MapPlane ( ((x-1)<<16) + (b1<<8) + spanstart[b1]);
472: ;
473: shlq #8,scratch ; harmless delay slot
474: move pl_b1,scratch2
475: or pl_cmdhigh,scratch
476: shlq #2,scratch2
477: load (pl_spanstart+scratch2),scratch2
478: subq #4,FP
479: or scratch2,scratch
480: subqt #1,pl_b1 ; b1--
481: jump T,(pl_L_bottomdif)
482: store scratch,(FP) ; delay slot
483:
484: ;
485: ; bottom dif spanstarts
486: ;
487: pl_bottomstarts:
488: cmp pl_b2,pl_b1
489: jump U_LE,(pl_L_next)
490: cmp pl_b2,pl_t2 ; harmless delay slot
491: jr EQ,pl_bottommark
492: move pl_b2,scratch2 ; harmless delay slot
493: jump U_LT,(pl_L_next)
494: pl_bottommark:
495: shlq #2,scratch2 ; harmless delay slot
496: ; spanstart[b2] = x
497: ; b2--
498: subqt #1,pl_b2
499: jump T,(pl_L_bottomstarts)
500: store pl_x,(pl_spanstart+scratch2) ; delay slot
501:
502:
503: ;------------------------
504: ;
505: ; next
506: ;
507: ;------------------------
508: pl_next:
509: addq #1,pl_x
510: move pl_oldbottom,pl_b1
511: cmp pl_x,pl_stopx
512: move pl_oldtop,pl_t1
513: jump NE,(pl_L_xloop)
514: loadw (pl_openptr),pl_t2 ; delay slot
515:
516: ;------------------------
517: ;
518: ; all done calculating, so execute the plane commands
519: ;
520: ;------------------------
521: cmp FP,pl_stopfp
522: jr NE,pl_isadraw
523: nop
524:
525: ; nothing to draw
526: load (FP),RETURNPOINT
527: jump T,(RETURNPOINT)
528: addq #4,FP ; delay slot
529:
530: pl_isadraw:
531:
532: ;
533: ; fall through into R_MapPlane
534: ;
535:
536:
537:
538: ;==============================================================================
539: _R_MapPlane::
540: ; (FP) is the munged up coordinates
541: ;==============================================================================
542:
543: mp_ystep .equr r0
544: mp_axstep .equr r1
545: mp_aystep .equr r2
546: mp_count .equr r3
547: mp_a1pixel .equr r4
548: mp_FREE .equr r5
549: mp_remaining .equr r6
550: mp_xremain .equr r7
551: mp_yremain .equr r8
552: mp_ffff .equr r9
553: mp_ffff0000 .equr r12
554:
555: ;scratch .equr r10
556: ;scratch2 .equr r11
557: ;pl_stopfp .equr r13 ; must stay constant across R_MapPlane
558: ;FP .equr r14
559:
560: mp_blitter .equr r15
561: mp_y .equr r16
562: mp_3fffff .equr r17
563: mp_x2 .equr r18
564: mp_angle .equr r19
565: mp_distance .equr r20
566: mp_length .equr r21
567: mp_x .equr r22
568: mp_light .equr r23
569: mp_xfrac .equr r24
570: mp_yfrac .equr r25
571: mp_xstep .equr r26
572: mp_blitcommand .equr r27
573:
574: ;RETURNPOINT .equr r28
575:
576: ;
577: ; set up for multiple R_MapPlanes
578: ;
579: movei #$f02200,mp_blitter
580: movei #$ffff,mp_ffff
581: movei #$ffff0000,mp_ffff0000
582: movei #$3fffff,mp_3fffff
583: movei #1+(1<<11)+(1<<13)+(1<<30)+(12<<21),mp_blitcommand
584:
585:
586: ; x2 = parm>>16;
587: ; y = (parm>>8)&0xff;
588: ; x1 = parm&0xff;
589: ; x = x1;
590: ; count = x2 - x+1;
591: mp_entry:
592: load (FP),mp_x2
593: move mp_x2,mp_y
594: move mp_y,mp_x
595: shlq #24,mp_x
596: shrq #24,mp_x
597: shrq #16,mp_x2
598: shlq #16,mp_y
599: shrq #24,mp_y
600: move mp_x2,mp_remaining
601: sub mp_x,mp_remaining
602: addq #1,mp_remaining
603:
604: or mp_remaining,mp_remaining
605: movei #mp_linedone,scratch
606: jump EQ,(scratch) ; nothing to draw (sholdn't happen)
607: nop
608:
609:
610: ; distance = (planeheight*yslope[y])>>12;
611:
612: movei #_yslope,scratch
613: add mp_y,scratch
614: add mp_y,scratch
615: loadw (scratch),scratch ; yslope[y]
616: movefa alt_planeheight,mp_distance
617: mult scratch,mp_distance
618: shrq #12,mp_distance
619:
620: ; length = (distance*distscale[x1])>>14;
621: move mp_x,scratch2
622: shlq #1,scratch2
623: movei #_distscale,mp_length
624: add scratch2,mp_length
625: loadw (mp_length),mp_length
626: mult mp_distance,mp_length
627: shrq #14,mp_length
628:
629: ; angle = (planeangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
630:
631: movefa alt_planeangle,scratch
632: shlq #1,scratch2
633: movei #_xtoviewangle,mp_angle
634: add scratch2,mp_angle ; + x1*4
635: load (mp_angle),mp_angle
636: add scratch,mp_angle
637: shrq #19,mp_angle
638:
639: shlq #2,mp_angle ; used to index int tables
640: movei #_finesine,scratch
641: add scratch,mp_angle
642: movei #8192,scratch
643: load (mp_angle),scratch2 ; finesine[angle]
644: add scratch,mp_angle
645: load (mp_angle),mp_xfrac ; finecosine[angle]
646:
647: ; xfrac = planex + (((finecosine[angle]>>1)*length)>>4);
648:
649: movefa alt_planex,scratch
650: sharq #1,mp_xfrac
651: imult mp_length,mp_xfrac
652: sharq #4,mp_xfrac
653: add scratch,mp_xfrac
654:
655: ; yfrac = planey - (((finesine[angle]>>1)*length)>>4);
656:
657: movefa alt_planey,mp_yfrac
658: sharq #1,scratch2
659: imult mp_length,scratch2
660: sharq #4,scratch2
661: sub scratch2,mp_yfrac
662:
663:
664:
665: ; xstep = (distance*basexscale)>>4;
666: ; if (!xstep)
667: ; axstep = 1;
668: ; else if (xstep < 0)
669: ; axstep = -xstep;
670: ; else
671: ; axstep = xstep;
672: movefa alt_basexscale,mp_xstep
673: imult mp_distance,mp_xstep
674: sharq #4,mp_xstep
675: jr NE,mp_xnotzero
676: move mp_xstep,mp_axstep ; delay slot
677: moveq #1,mp_axstep
678: moveq #1,mp_xstep
679: mp_xnotzero:
680: abs mp_axstep
681:
682: ; light = planelight; // - ((planelightscale*distance)>>16);
683: ; if (light < 0)
684: ; light = 0;
685: ; light = -((255-light)<<14); // should be from 0 to -0x800000
686: ; light &= 0xffffff;
687:
688: movefa alt_plane_lightcoef,mp_light
689: div mp_distance,mp_light
690: ; do something else while dividing
691:
692:
693: ; ystep = (distance*baseyscale)>>4;
694: ; if (!ystep)
695: ; aystep = 1;
696: ; else if (ystep < 0)
697: ; aystep = -ystep;
698: ; else
699: ; aystep = ystep;
700: movefa alt_baseyscale,mp_ystep
701: imult mp_distance,mp_ystep
702: sharq #4,mp_ystep
703: jr NE,mp_ynotzero
704: move mp_ystep,mp_aystep ; delay slot
705: moveq #1,mp_aystep
706: moveq #1,mp_ystep
707: mp_ynotzero:
708: abs mp_aystep
709:
710: ; finish light calculations
711:
712: movefa alt_plane_lightsub,scratch
713: sub scratch,mp_light
714:
715: movefa alt_plane_lightmax,scratch
716: cmp scratch,mp_light
717: jr S_GT,mp_lightless
718: nop
719: move scratch,mp_light
720: mp_lightless:
721: movefa alt_plane_lightmin,scratch
722: cmp scratch,mp_light
723: jr S_LT,mp_lightmore
724: nop
725: move scratch,mp_light
726: mp_lightmore:
727:
728: movei #255,scratch
729: sub mp_light,scratch
730: shlq #14,scratch
731: neg scratch
732: movei #$ffffff,mp_light
733: and scratch,mp_light
734:
735:
736:
737: ;-----------------
738: ;
739: ; setup blitter
740: ;
741: ;-----------------
742:
743: mp_wait1:
744: load (mp_blitter+14),scratch
745: btst #0,scratch
746: jr EQ,mp_wait1
747: nop
748:
749: ; *(int *)0xf0221c = (ystep&0xffff0000)+((xstep>>16)&0xffff); // a1 increment
750: move mp_ystep,scratch
751: and mp_ffff0000,scratch
752: move mp_xstep,scratch2
753: shrq #16,scratch2
754: or scratch2,scratch
755: store scratch,(mp_blitter+7)
756:
757: ; *(int *)0xf02220 = (xstep&0xffff) + (ystep<<16); // a1 increment frac
758: move mp_xstep,scratch
759: and mp_ffff,scratch
760: move mp_ystep,scratch2
761: shlq #16,scratch2
762: or scratch2,scratch
763: store scratch,(mp_blitter+8)
764:
765: ; *(int *)0xf02218 = (yfrac<<16)+(xfrac&0xffff); // a1 pixel frac
766: move mp_yfrac,scratch
767: shlq #16,scratch
768: move mp_xfrac,scratch2
769: and mp_ffff,scratch2
770: or scratch2,scratch
771: store scratch,(mp_blitter+6)
772:
773: ; *(int *)0xf02230 = (y<<16) + x; // a2 pixel pointers
774: shlq #16,mp_y
775: add mp_x,mp_y
776: store mp_y,(mp_blitter+12)
777:
778: ; *(int *)0xf02270 = light; // iinc
779: movei #$f02270,scratch
780: store mp_light,(scratch)
781:
782: ; count = 0;
783: moveq #0,mp_count
784:
785:
786: mp_stillremaining:
787:
788: ;===============
789: ;
790: ; x axis
791: ;
792: ;===============
793:
794: ; xfrac = (xfrac + count*xstep)&0x3fffff;
795: ; xpos = xfrac;
796: ; if (xstep >= 0)
797: ; xpos = 0x400000 - xpos;
798: ; xremain = (xpos / axstep);
799: move mp_axstep,scratch
800: move mp_axstep,scratch2
801: shrq #16,scratch2
802: mult mp_count,scratch
803: mult mp_count,scratch2
804: shlq #16,scratch2
805: add scratch2,scratch
806: or mp_xstep,mp_xstep
807: jr PL,mp_addxpos
808: nop
809: sub scratch,mp_xfrac
810: and mp_3fffff,mp_xfrac
811: jr T,mp_xadded
812: move mp_xfrac,mp_xremain ; delay slot
813:
814: mp_addxpos:
815: add scratch,mp_xfrac
816: and mp_3fffff,mp_xfrac
817: movefa alt_400000,mp_xremain
818: sub mp_xfrac,mp_xremain
819: mp_xadded:
820: div mp_axstep,mp_xremain
821:
822:
823: ;===============
824: ;
825: ; y axis
826: ;
827: ;===============
828:
829: ; yfrac = (yfrac + count*ystep)&0x3fffff;
830: ; yremain = (ypos / aystep) + 1;
831: move mp_aystep,scratch
832: move mp_aystep,scratch2
833: shrq #16,scratch2
834: mult mp_count,scratch
835: mult mp_count,scratch2
836: shlq #16,scratch2
837: add scratch2,scratch
838: or mp_ystep,mp_ystep
839: jr PL,mp_addypos
840: nop
841: sub scratch,mp_yfrac
842: and mp_3fffff,mp_yfrac
843: jr T,mp_yadded
844: move mp_yfrac,mp_yremain ; delay slot
845:
846: mp_addypos:
847: add scratch,mp_yfrac
848: and mp_3fffff,mp_yfrac
849: movefa alt_400000,mp_yremain
850: sub mp_yfrac,mp_yremain
851:
852: mp_yadded:
853: div mp_aystep,mp_yremain
854:
855: ;====================
856: ; prepare blitter registers
857: ;====================
858:
859: ; *(int *)0xf0220c = (yfrac&0xffff0000)+(xfrac>>16); // a1 pixel
860: move mp_yfrac,mp_a1pixel
861: and mp_ffff0000,mp_a1pixel
862: move mp_xfrac,scratch2
863: shrq #16,scratch2
864: or scratch2,mp_a1pixel
865:
866: ;=====================
867: ; count = remaining;
868: ; if (xremain < count)
869: ; count = xremain;
870: ; if (yremain < count)
871: ; count = yremain;
872: ; ramaining will allways be at least 1
873: ; xremain and yremain will allways be 0 or greater
874: ;=====================
875:
876: move mp_remaining,mp_count
877: subq #1,mp_count
878: cmp mp_xremain,mp_count
879: jr U_GT,mp_notxremain
880: nop
881: move mp_xremain,mp_count
882: mp_notxremain:
883: cmp mp_yremain,mp_count
884: jr U_GT,mp_notyremain
885: nop
886: move mp_yremain,mp_count
887: mp_notyremain:
888:
889: addq #1,mp_count
890:
891:
892: ;=====================
893: ; program blitter
894: ;=====================
895:
896: ; while ( ! (*(int *)0xf02238 & 1) ) // wait for blitter to finish
897: ; ;
898: mp_wait2:
899: load (mp_blitter+14),scratch
900: btst #0,scratch
901: jr EQ,mp_wait2
902: move mp_count,scratch ; harmless delay slot
903:
904: store mp_a1pixel,(mp_blitter+3) ; source location
905: bset #16,scratch ; one outer loop
906: store scratch,(mp_blitter+15) ; count register
907: store mp_blitcommand,(mp_blitter+14) ; command register
908: ;===========================
909:
910: ; remaining -= count;
911: movei #mp_stillremaining,scratch
912: sub mp_count,mp_remaining ; delay slot
913: jump NE,(scratch)
914: nop
915:
916: ;
917: ; all done with this line, see if there are more to do
918: ;
919: mp_linedone:
920: addq #4,FP
921: cmp FP,pl_stopfp
922: movei #mp_entry,scratch
923: jump NE,(scratch)
924: load (FP),RETURNPOINT ; harmless delay slot
925: jump T,(RETURNPOINT) ; go back to R_DrawPlanes
926: addq #4,FP ; delay slot
927:
928:
929:
930: ;======================
931: ;
932: ; scratch data tables
933: ;
934: ;======================
935: .long
936: _spanstart:: .dc.l 0 ; int spanstart[SCREENHEIGHT]
937:
938:
939: .phrase
940: .68000
941: codeend:
942:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.