|
|
1.1 root 1: //
2: // surf8.s
3: // x86 assembly-language 8 bpp surface block drawing code.
4: //
5:
6: #include "asm_i386.h"
7: #include "quakeasm.h"
8: #include "asm_draw.h"
9:
1.1.1.2 ! root 10: #if id386
1.1 root 11:
12: .data
13:
14: sb_v: .long 0
15:
16: .text
17:
18: .align 4
19: .globl C(R_Surf8Start)
20: C(R_Surf8Start):
21:
22: //----------------------------------------------------------------------
23: // Surface block drawer for mip level 0
24: //----------------------------------------------------------------------
25:
26: .align 4
27: .globl C(R_DrawSurfaceBlock8_mip0)
28: C(R_DrawSurfaceBlock8_mip0):
29: pushl %ebp // preserve caller's stack frame
30: pushl %edi
31: pushl %esi // preserve register variables
32: pushl %ebx
33:
34: // for (v=0 ; v<numvblocks ; v++)
35: // {
36: movl C(r_lightptr),%ebx
37: movl C(r_numvblocks),%eax
38:
39: movl %eax,sb_v
40: movl C(prowdestbase),%edi
41:
42: movl C(pbasesource),%esi
43:
44: Lv_loop_mip0:
45:
46: // lightleft = lightptr[0];
47: // lightright = lightptr[1];
48: // lightdelta = (lightleft - lightright) & 0xFFFFF;
49: movl (%ebx),%eax // lightleft
50: movl 4(%ebx),%edx // lightright
51:
52: movl %eax,%ebp
53: movl C(r_lightwidth),%ecx
54:
55: movl %edx,C(lightright)
56: subl %edx,%ebp
57:
58: andl $0xFFFFF,%ebp
59: leal (%ebx,%ecx,4),%ebx
60:
61: // lightptr += lightwidth;
62: movl %ebx,C(r_lightptr)
63:
64: // lightleftstep = (lightptr[0] - lightleft) >> blockdivshift;
65: // lightrightstep = (lightptr[1] - lightright) >> blockdivshift;
66: // lightdeltastep = ((lightleftstep - lightrightstep) & 0xFFFFF) |
67: // 0xF0000000;
68: movl 4(%ebx),%ecx // lightptr[1]
69: movl (%ebx),%ebx // lightptr[0]
70:
71: subl %eax,%ebx
72: subl %edx,%ecx
73:
74: sarl $4,%ecx
75: orl $0xF0000000,%ebp
76:
77: sarl $4,%ebx
78: movl %ecx,C(lightrightstep)
79:
80: subl %ecx,%ebx
81: andl $0xFFFFF,%ebx
82:
83: orl $0xF0000000,%ebx
84: subl %ecx,%ecx // high word must be 0 in loop for addressing
85:
86: movl %ebx,C(lightdeltastep)
87: subl %ebx,%ebx // high word must be 0 in loop for addressing
88:
89: Lblockloop8_mip0:
90: movl %ebp,C(lightdelta)
91: movb 14(%esi),%cl
92:
93: sarl $4,%ebp
94: movb %dh,%bh
95:
96: movb 15(%esi),%bl
97: addl %ebp,%edx
98:
99: movb %dh,%ch
100: addl %ebp,%edx
101:
102: movb 0x12345678(%ebx),%ah
103: LBPatch0:
104: movb 13(%esi),%bl
105:
106: movb 0x12345678(%ecx),%al
107: LBPatch1:
108: movb 12(%esi),%cl
109:
110: movb %dh,%bh
111: addl %ebp,%edx
112:
113: rorl $16,%eax
114: movb %dh,%ch
115:
116: addl %ebp,%edx
117: movb 0x12345678(%ebx),%ah
118: LBPatch2:
119:
120: movb 11(%esi),%bl
121: movb 0x12345678(%ecx),%al
122: LBPatch3:
123:
124: movb 10(%esi),%cl
125: movl %eax,12(%edi)
126:
127: movb %dh,%bh
128: addl %ebp,%edx
129:
130: movb %dh,%ch
131: addl %ebp,%edx
132:
133: movb 0x12345678(%ebx),%ah
134: LBPatch4:
135: movb 9(%esi),%bl
136:
137: movb 0x12345678(%ecx),%al
138: LBPatch5:
139: movb 8(%esi),%cl
140:
141: movb %dh,%bh
142: addl %ebp,%edx
143:
144: rorl $16,%eax
145: movb %dh,%ch
146:
147: addl %ebp,%edx
148: movb 0x12345678(%ebx),%ah
149: LBPatch6:
150:
151: movb 7(%esi),%bl
152: movb 0x12345678(%ecx),%al
153: LBPatch7:
154:
155: movb 6(%esi),%cl
156: movl %eax,8(%edi)
157:
158: movb %dh,%bh
159: addl %ebp,%edx
160:
161: movb %dh,%ch
162: addl %ebp,%edx
163:
164: movb 0x12345678(%ebx),%ah
165: LBPatch8:
166: movb 5(%esi),%bl
167:
168: movb 0x12345678(%ecx),%al
169: LBPatch9:
170: movb 4(%esi),%cl
171:
172: movb %dh,%bh
173: addl %ebp,%edx
174:
175: rorl $16,%eax
176: movb %dh,%ch
177:
178: addl %ebp,%edx
179: movb 0x12345678(%ebx),%ah
180: LBPatch10:
181:
182: movb 3(%esi),%bl
183: movb 0x12345678(%ecx),%al
184: LBPatch11:
185:
186: movb 2(%esi),%cl
187: movl %eax,4(%edi)
188:
189: movb %dh,%bh
190: addl %ebp,%edx
191:
192: movb %dh,%ch
193: addl %ebp,%edx
194:
195: movb 0x12345678(%ebx),%ah
196: LBPatch12:
197: movb 1(%esi),%bl
198:
199: movb 0x12345678(%ecx),%al
200: LBPatch13:
201: movb (%esi),%cl
202:
203: movb %dh,%bh
204: addl %ebp,%edx
205:
206: rorl $16,%eax
207: movb %dh,%ch
208:
209: movb 0x12345678(%ebx),%ah
210: LBPatch14:
211: movl C(lightright),%edx
212:
213: movb 0x12345678(%ecx),%al
214: LBPatch15:
215: movl C(lightdelta),%ebp
216:
217: movl %eax,(%edi)
218:
219: addl C(sourcetstep),%esi
220: addl C(surfrowbytes),%edi
221:
222: addl C(lightrightstep),%edx
223: addl C(lightdeltastep),%ebp
224:
225: movl %edx,C(lightright)
226: jc Lblockloop8_mip0
227:
228: // if (pbasesource >= r_sourcemax)
229: // pbasesource -= stepback;
230:
231: cmpl C(r_sourcemax),%esi
232: jb LSkip_mip0
233: subl C(r_stepback),%esi
234: LSkip_mip0:
235:
236: movl C(r_lightptr),%ebx
237: decl sb_v
238:
239: jnz Lv_loop_mip0
240:
241: popl %ebx // restore register variables
242: popl %esi
243: popl %edi
244: popl %ebp // restore the caller's stack frame
245: ret
246:
247:
248: //----------------------------------------------------------------------
249: // Surface block drawer for mip level 1
250: //----------------------------------------------------------------------
251:
252: .align 4
253: .globl C(R_DrawSurfaceBlock8_mip1)
254: C(R_DrawSurfaceBlock8_mip1):
255: pushl %ebp // preserve caller's stack frame
256: pushl %edi
257: pushl %esi // preserve register variables
258: pushl %ebx
259:
260: // for (v=0 ; v<numvblocks ; v++)
261: // {
262: movl C(r_lightptr),%ebx
263: movl C(r_numvblocks),%eax
264:
265: movl %eax,sb_v
266: movl C(prowdestbase),%edi
267:
268: movl C(pbasesource),%esi
269:
270: Lv_loop_mip1:
271:
272: // lightleft = lightptr[0];
273: // lightright = lightptr[1];
274: // lightdelta = (lightleft - lightright) & 0xFFFFF;
275: movl (%ebx),%eax // lightleft
276: movl 4(%ebx),%edx // lightright
277:
278: movl %eax,%ebp
279: movl C(r_lightwidth),%ecx
280:
281: movl %edx,C(lightright)
282: subl %edx,%ebp
283:
284: andl $0xFFFFF,%ebp
285: leal (%ebx,%ecx,4),%ebx
286:
287: // lightptr += lightwidth;
288: movl %ebx,C(r_lightptr)
289:
290: // lightleftstep = (lightptr[0] - lightleft) >> blockdivshift;
291: // lightrightstep = (lightptr[1] - lightright) >> blockdivshift;
292: // lightdeltastep = ((lightleftstep - lightrightstep) & 0xFFFFF) |
293: // 0xF0000000;
294: movl 4(%ebx),%ecx // lightptr[1]
295: movl (%ebx),%ebx // lightptr[0]
296:
297: subl %eax,%ebx
298: subl %edx,%ecx
299:
300: sarl $3,%ecx
301: orl $0x70000000,%ebp
302:
303: sarl $3,%ebx
304: movl %ecx,C(lightrightstep)
305:
306: subl %ecx,%ebx
307: andl $0xFFFFF,%ebx
308:
309: orl $0xF0000000,%ebx
310: subl %ecx,%ecx // high word must be 0 in loop for addressing
311:
312: movl %ebx,C(lightdeltastep)
313: subl %ebx,%ebx // high word must be 0 in loop for addressing
314:
315: Lblockloop8_mip1:
316: movl %ebp,C(lightdelta)
317: movb 6(%esi),%cl
318:
319: sarl $3,%ebp
320: movb %dh,%bh
321:
322: movb 7(%esi),%bl
323: addl %ebp,%edx
324:
325: movb %dh,%ch
326: addl %ebp,%edx
327:
328: movb 0x12345678(%ebx),%ah
329: LBPatch22:
330: movb 5(%esi),%bl
331:
332: movb 0x12345678(%ecx),%al
333: LBPatch23:
334: movb 4(%esi),%cl
335:
336: movb %dh,%bh
337: addl %ebp,%edx
338:
339: rorl $16,%eax
340: movb %dh,%ch
341:
342: addl %ebp,%edx
343: movb 0x12345678(%ebx),%ah
344: LBPatch24:
345:
346: movb 3(%esi),%bl
347: movb 0x12345678(%ecx),%al
348: LBPatch25:
349:
350: movb 2(%esi),%cl
351: movl %eax,4(%edi)
352:
353: movb %dh,%bh
354: addl %ebp,%edx
355:
356: movb %dh,%ch
357: addl %ebp,%edx
358:
359: movb 0x12345678(%ebx),%ah
360: LBPatch26:
361: movb 1(%esi),%bl
362:
363: movb 0x12345678(%ecx),%al
364: LBPatch27:
365: movb (%esi),%cl
366:
367: movb %dh,%bh
368: addl %ebp,%edx
369:
370: rorl $16,%eax
371: movb %dh,%ch
372:
373: movb 0x12345678(%ebx),%ah
374: LBPatch28:
375: movl C(lightright),%edx
376:
377: movb 0x12345678(%ecx),%al
378: LBPatch29:
379: movl C(lightdelta),%ebp
380:
381: movl %eax,(%edi)
382: movl C(sourcetstep),%eax
383:
384: addl %eax,%esi
385: movl C(surfrowbytes),%eax
386:
387: addl %eax,%edi
388: movl C(lightrightstep),%eax
389:
390: addl %eax,%edx
391: movl C(lightdeltastep),%eax
392:
393: addl %eax,%ebp
394: movl %edx,C(lightright)
395:
396: jc Lblockloop8_mip1
397:
398: // if (pbasesource >= r_sourcemax)
399: // pbasesource -= stepback;
400:
401: cmpl C(r_sourcemax),%esi
402: jb LSkip_mip1
403: subl C(r_stepback),%esi
404: LSkip_mip1:
405:
406: movl C(r_lightptr),%ebx
407: decl sb_v
408:
409: jnz Lv_loop_mip1
410:
411: popl %ebx // restore register variables
412: popl %esi
413: popl %edi
414: popl %ebp // restore the caller's stack frame
415: ret
416:
417:
418: //----------------------------------------------------------------------
419: // Surface block drawer for mip level 2
420: //----------------------------------------------------------------------
421:
422: .align 4
423: .globl C(R_DrawSurfaceBlock8_mip2)
424: C(R_DrawSurfaceBlock8_mip2):
425: pushl %ebp // preserve caller's stack frame
426: pushl %edi
427: pushl %esi // preserve register variables
428: pushl %ebx
429:
430: // for (v=0 ; v<numvblocks ; v++)
431: // {
432: movl C(r_lightptr),%ebx
433: movl C(r_numvblocks),%eax
434:
435: movl %eax,sb_v
436: movl C(prowdestbase),%edi
437:
438: movl C(pbasesource),%esi
439:
440: Lv_loop_mip2:
441:
442: // lightleft = lightptr[0];
443: // lightright = lightptr[1];
444: // lightdelta = (lightleft - lightright) & 0xFFFFF;
445: movl (%ebx),%eax // lightleft
446: movl 4(%ebx),%edx // lightright
447:
448: movl %eax,%ebp
449: movl C(r_lightwidth),%ecx
450:
451: movl %edx,C(lightright)
452: subl %edx,%ebp
453:
454: andl $0xFFFFF,%ebp
455: leal (%ebx,%ecx,4),%ebx
456:
457: // lightptr += lightwidth;
458: movl %ebx,C(r_lightptr)
459:
460: // lightleftstep = (lightptr[0] - lightleft) >> blockdivshift;
461: // lightrightstep = (lightptr[1] - lightright) >> blockdivshift;
462: // lightdeltastep = ((lightleftstep - lightrightstep) & 0xFFFFF) |
463: // 0xF0000000;
464: movl 4(%ebx),%ecx // lightptr[1]
465: movl (%ebx),%ebx // lightptr[0]
466:
467: subl %eax,%ebx
468: subl %edx,%ecx
469:
470: sarl $2,%ecx
471: orl $0x30000000,%ebp
472:
473: sarl $2,%ebx
474: movl %ecx,C(lightrightstep)
475:
476: subl %ecx,%ebx
477:
478: andl $0xFFFFF,%ebx
479:
480: orl $0xF0000000,%ebx
481: subl %ecx,%ecx // high word must be 0 in loop for addressing
482:
483: movl %ebx,C(lightdeltastep)
484: subl %ebx,%ebx // high word must be 0 in loop for addressing
485:
486: Lblockloop8_mip2:
487: movl %ebp,C(lightdelta)
488: movb 2(%esi),%cl
489:
490: sarl $2,%ebp
491: movb %dh,%bh
492:
493: movb 3(%esi),%bl
494: addl %ebp,%edx
495:
496: movb %dh,%ch
497: addl %ebp,%edx
498:
499: movb 0x12345678(%ebx),%ah
500: LBPatch18:
501: movb 1(%esi),%bl
502:
503: movb 0x12345678(%ecx),%al
504: LBPatch19:
505: movb (%esi),%cl
506:
507: movb %dh,%bh
508: addl %ebp,%edx
509:
510: rorl $16,%eax
511: movb %dh,%ch
512:
513: movb 0x12345678(%ebx),%ah
514: LBPatch20:
515: movl C(lightright),%edx
516:
517: movb 0x12345678(%ecx),%al
518: LBPatch21:
519: movl C(lightdelta),%ebp
520:
521: movl %eax,(%edi)
522: movl C(sourcetstep),%eax
523:
524: addl %eax,%esi
525: movl C(surfrowbytes),%eax
526:
527: addl %eax,%edi
528: movl C(lightrightstep),%eax
529:
530: addl %eax,%edx
531: movl C(lightdeltastep),%eax
532:
533: addl %eax,%ebp
534: movl %edx,C(lightright)
535:
536: jc Lblockloop8_mip2
537:
538: // if (pbasesource >= r_sourcemax)
539: // pbasesource -= stepback;
540:
541: cmpl C(r_sourcemax),%esi
542: jb LSkip_mip2
543: subl C(r_stepback),%esi
544: LSkip_mip2:
545:
546: movl C(r_lightptr),%ebx
547: decl sb_v
548:
549: jnz Lv_loop_mip2
550:
551: popl %ebx // restore register variables
552: popl %esi
553: popl %edi
554: popl %ebp // restore the caller's stack frame
555: ret
556:
557:
558: //----------------------------------------------------------------------
559: // Surface block drawer for mip level 3
560: //----------------------------------------------------------------------
561:
562: .align 4
563: .globl C(R_DrawSurfaceBlock8_mip3)
564: C(R_DrawSurfaceBlock8_mip3):
565: pushl %ebp // preserve caller's stack frame
566: pushl %edi
567: pushl %esi // preserve register variables
568: pushl %ebx
569:
570: // for (v=0 ; v<numvblocks ; v++)
571: // {
572: movl C(r_lightptr),%ebx
573: movl C(r_numvblocks),%eax
574:
575: movl %eax,sb_v
576: movl C(prowdestbase),%edi
577:
578: movl C(pbasesource),%esi
579:
580: Lv_loop_mip3:
581:
582: // lightleft = lightptr[0];
583: // lightright = lightptr[1];
584: // lightdelta = (lightleft - lightright) & 0xFFFFF;
585: movl (%ebx),%eax // lightleft
586: movl 4(%ebx),%edx // lightright
587:
588: movl %eax,%ebp
589: movl C(r_lightwidth),%ecx
590:
591: movl %edx,C(lightright)
592: subl %edx,%ebp
593:
594: andl $0xFFFFF,%ebp
595: leal (%ebx,%ecx,4),%ebx
596:
597: movl %ebp,C(lightdelta)
598: // lightptr += lightwidth;
599: movl %ebx,C(r_lightptr)
600:
601: // lightleftstep = (lightptr[0] - lightleft) >> blockdivshift;
602: // lightrightstep = (lightptr[1] - lightright) >> blockdivshift;
603: // lightdeltastep = ((lightleftstep - lightrightstep) & 0xFFFFF) |
604: // 0xF0000000;
605: movl 4(%ebx),%ecx // lightptr[1]
606: movl (%ebx),%ebx // lightptr[0]
607:
608: subl %eax,%ebx
609: subl %edx,%ecx
610:
611: sarl $1,%ecx
612:
613: sarl $1,%ebx
614: movl %ecx,C(lightrightstep)
615:
616: subl %ecx,%ebx
617: andl $0xFFFFF,%ebx
618:
619: sarl $1,%ebp
620: orl $0xF0000000,%ebx
621:
622: movl %ebx,C(lightdeltastep)
623: subl %ebx,%ebx // high word must be 0 in loop for addressing
624:
625: movb 1(%esi),%bl
626: subl %ecx,%ecx // high word must be 0 in loop for addressing
627:
628: movb %dh,%bh
629: movb (%esi),%cl
630:
631: addl %ebp,%edx
632: movb %dh,%ch
633:
634: movb 0x12345678(%ebx),%al
635: LBPatch16:
636: movl C(lightright),%edx
637:
638: movb %al,1(%edi)
639: movb 0x12345678(%ecx),%al
640: LBPatch17:
641:
642: movb %al,(%edi)
643: movl C(sourcetstep),%eax
644:
645: addl %eax,%esi
646: movl C(surfrowbytes),%eax
647:
648: addl %eax,%edi
649: movl C(lightdeltastep),%eax
650:
651: movl C(lightdelta),%ebp
652: movb (%esi),%cl
653:
654: addl %eax,%ebp
655: movl C(lightrightstep),%eax
656:
657: sarl $1,%ebp
658: addl %eax,%edx
659:
660: movb %dh,%bh
661: movb 1(%esi),%bl
662:
663: addl %ebp,%edx
664: movb %dh,%ch
665:
666: movb 0x12345678(%ebx),%al
667: LBPatch30:
668: movl C(sourcetstep),%edx
669:
670: movb %al,1(%edi)
671: movb 0x12345678(%ecx),%al
672: LBPatch31:
673:
674: movb %al,(%edi)
675: movl C(surfrowbytes),%ebp
676:
677: addl %edx,%esi
678: addl %ebp,%edi
679:
680: // if (pbasesource >= r_sourcemax)
681: // pbasesource -= stepback;
682:
683: cmpl C(r_sourcemax),%esi
684: jb LSkip_mip3
685: subl C(r_stepback),%esi
686: LSkip_mip3:
687:
688: movl C(r_lightptr),%ebx
689: decl sb_v
690:
691: jnz Lv_loop_mip3
692:
693: popl %ebx // restore register variables
694: popl %esi
695: popl %edi
696: popl %ebp // restore the caller's stack frame
697: ret
698:
699:
700: .globl C(R_Surf8End)
701: C(R_Surf8End):
702:
703: //----------------------------------------------------------------------
704: // Code patching routines
705: //----------------------------------------------------------------------
706: .data
707:
708: .align 4
709: LPatchTable8:
1.1.1.2 ! root 710: .long LBPatch0-4
! 711: .long LBPatch1-4
! 712: .long LBPatch2-4
! 713: .long LBPatch3-4
! 714: .long LBPatch4-4
! 715: .long LBPatch5-4
! 716: .long LBPatch6-4
! 717: .long LBPatch7-4
! 718: .long LBPatch8-4
! 719: .long LBPatch9-4
! 720: .long LBPatch10-4
! 721: .long LBPatch11-4
! 722: .long LBPatch12-4
! 723: .long LBPatch13-4
! 724: .long LBPatch14-4
! 725: .long LBPatch15-4
! 726: .long LBPatch16-4
! 727: .long LBPatch17-4
! 728: .long LBPatch18-4
! 729: .long LBPatch19-4
! 730: .long LBPatch20-4
! 731: .long LBPatch21-4
! 732: .long LBPatch22-4
! 733: .long LBPatch23-4
! 734: .long LBPatch24-4
! 735: .long LBPatch25-4
! 736: .long LBPatch26-4
! 737: .long LBPatch27-4
! 738: .long LBPatch28-4
! 739: .long LBPatch29-4
! 740: .long LBPatch30-4
! 741: .long LBPatch31-4
1.1 root 742:
743: .text
744:
745: .align 4
746: .globl C(R_Surf8Patch)
747: C(R_Surf8Patch):
748: pushl %ebx
749:
750: movl C(colormap),%eax
751: movl $LPatchTable8,%ebx
752: movl $32,%ecx
753: LPatchLoop8:
754: movl (%ebx),%edx
755: addl $4,%ebx
756: movl %eax,(%edx)
757: decl %ecx
758: jnz LPatchLoop8
759:
760: popl %ebx
761:
762: ret
763:
764: #endif // id386
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.