Import Debian changes 1.23-12
[debian-dgen.git] / asm_tiles.asmu
blob59708bd7a594be2094f993d0a77092925e2b2f6b
1 bits 32
3 section .text
5 %define which   [ebp+36]        ; int which
6 %define line    [ebp+40]        ; int line
7 %define where   [ebp+44]        ; unsigned char *where
9 %define vram    [ebp+24]        ; unsigned char *vram
10 %define reg     [ebp+28]        ; unsigned char reg[0x20]
11 %define highpal [ebp+32]        ; unsigned int *highpal
13 ;%define cache_align times ($$-$) & 3 nop       ; Align to 4-byte boundary
14 ;%define cache_align times ($$-$) & 7 nop       ; Align to 8-byte boundary
15 %define cache_align times ($$-$) & 31 nop       ; Align to 32-byte boundary
17 global __asm_tiles_init
18 global __drawtile1_solid
19 global __drawtile1
20 global __drawtile2_solid
21 global __drawtile2
22 global __drawtile3_solid
23 global __drawtile3
24 global __drawtile4_solid
25 global __drawtile4
27 ; Neat utility macro
28 %macro triple_xor 2
29         xor %1, %2      ; Triple XOR for a neat register exchange  ;)
30         xor %2, %1
31         xor %1, %2
32 %endmacro
34 %macro blit_pixel1 1-*          ; 8bpp blitting, solid
35         mov eax, ebx
36         and eax, %1
37     %if %0 > 1
38         shr eax, byte %2
39     %endif
40         or eax, [esi]
41         mov byte [edi], al
42         inc edi
43 %endmacro
45 %macro blit_pixel1_trans 1-*    ; 8bpp blitting, transparent
46         mov eax, ebx
47         and eax, %1
48         jz %%trans
49     %if %0 > 1
50         shr eax, byte %2
51     %endif
52         or eax, [esi]
53         mov byte [edi], al
54     %%trans:
55         inc edi
56 %endmacro
58 %macro blit_pixel2 1-*          ; 16bpp blitting, solid
59         mov eax, ebx
60         and eax, %1
61     %if %0 > 1
62         shr eax, byte %2
63     %endif
64         lea edx, [esi+eax*4]
65         mov eax, [edx]
66         mov word [edi], ax
67         add edi, byte 2
68 %endmacro
70 %macro blit_pixel2_trans 1-*    ; 16bpp blitting, transparent
71         mov eax, ebx
72         and eax, %1
73         jz %%trans
74     %if %0 > 1
75         shr eax, byte %2
76     %endif
77         lea edx, [esi+eax*4]
78         mov eax, [edx]
79         mov word [edi], ax
80     %%trans:
81         add edi, byte 2
82 %endmacro
84 %macro blit_pixel3 1-*          ; 24bpp blitting, solid
85         mov eax, ebx
86         and eax, %1
87     %if %0 > 1
88         shr eax, byte %2
89     %endif
90         lea edx, [esi+eax*4+1]
91         mov ax, word [edx]
92         mov word [edi], ax
93         add edi, 2
94         dec edx
95         mov al, byte [edx]
96         mov byte [edi], al
97         inc edi
98 %endmacro
100 %macro blit_pixel3_trans 1-*    ; 24bpp blitting, transparent
101         mov eax, ebx
102         and eax, %1
103         jz %%trans
104     %if %0 > 1
105         shr eax, byte %2
106     %endif
107         lea edx, [esi+eax*4+1]
108         mov ax, word [edx]
109         mov word [edi], ax
110         add edi, 2
111         dec edx
112         mov al, byte [edx]
113         mov byte [edi], al
114         inc edi
115         jmp %%next
116     %%trans:
117         add edi, byte 3
118     %%next:
119 %endmacro
121 %macro blit_pixel4 1-*          ; 32bpp blitting, solid
122         mov eax, ebx
123         and eax, %1
124     %if %0 > 1
125         shr eax, byte %2
126     %endif
127         lea edx, [esi+eax*4]
128         mov eax, [edx]
129         mov [edi], eax
130         add edi, byte 4
131 %endmacro
133 %macro blit_pixel4_trans 1-*    ; 32bpp blitting, transparent
134         mov eax, ebx
135         and eax, %1
136         jz %%trans
137     %if %0 > 1
138         shr eax, byte %2
139     %endif
140         lea edx, [esi+eax*4]
141         mov eax, [edx]
142         mov [edi], eax
143     %%trans:
144         add edi, byte 4
145 %endmacro
147 ; ----------------------------------------
148 ; int _asm_tiles_init
149 ;   (unsigned char *vram, unsigned char *reg, unsigned char *highpal)
150 ; ----------------------------------------
152         cache_align
154 __asm_tiles_init:
156         push eax
157         push ebx
158         push edx
159         push esp
160         push ebp
161         mov ebp, esp
163         mov eax, vram
164         mov ebx, reg
165         mov edx, highpal
166         mov [__vram], eax
167         mov [__reg], ebx
168         mov [__highpal], edx
170         pop ebp
171         pop esp
172         pop edx
173         pop ebx
174         pop eax
176         ret
178         cache_align
180 ; ----------------------------------------
181 ; int _drawtile1_solid
182 ;   (int which, int line, unsigned char *where)
183 ; ----------------------------------------
185         cache_align
187 __drawtile1_solid:
189         pushad
190         mov ebp, esp
192 .setup
194 .get_pal:       
196         mov ebx, which
197         mov esi, [__highpal]
198         mov eax, ebx
199         shr eax, byte 7
200         and eax, 0xc0
201         add esi, eax
202         mov edi, [__reg]
203         push esi
205 .check_y_flip:
207         mov eax, ebx
208         xor ecx, ecx
209         mov edx, line
210         test eax, 0x1000
212         jz .check_interlace
214 .y_flipped:
216         xor edx, byte 7
218         cache_align
220 .check_interlace:
222         mov esi, [__reg]
223         mov cl, [esi+12]
224         mov esi, [__vram]
225         and eax, 0x7ff
226         test cl, byte 0x2
228         jz .no_interlace
230 .interlace:
232         lea edx, [edx*8]
233         shl eax, 6
234         jmp .check_x_flip
236         cache_align
238 .no_interlace:
240         lea edx, [edx*4]
241         shl eax, 5
243         cache_align
245 .check_x_flip:
247         add eax, edx
248         mov edi, where
249         lea esi, [esi+eax]
250         mov ebx, [esi]
251         pop esi
252         mov eax, which
253         test eax, 0x800
255         jz near .x_not_flipped
257 .x_flipped:
259         blit_pixel1 0x0f000000, 24      ; pixel 8
260         blit_pixel1 0xf0000000, 28      ; ..... 7
261         blit_pixel1 0x000f0000, 16      ; ..... 6
262         blit_pixel1 0x00f00000, 20      ; ..... 5
263         blit_pixel1 0x00000f00, 8       ; ..... 4
264         blit_pixel1 0x0000f000, 12      ; ..... 3
265         blit_pixel1 0x0000000f          ; ..... 2
266         blit_pixel1 0x000000f0, 4       ; ..... 1
268         jmp .cleanup
270         cache_align
272 .x_not_flipped:
274         blit_pixel1 0x000000f0, 4       ; pixel 1
275         blit_pixel1 0x0000000f          ; ..... 2
276         blit_pixel1 0x0000f000, 12      ; ..... 3
277         blit_pixel1 0x00000f00, 8       ; ..... 4
278         blit_pixel1 0x00f00000, 20      ; ..... 5
279         blit_pixel1 0x000f0000, 16      ; ..... 6
280         blit_pixel1 0xf0000000, 28      ; ..... 7
281         blit_pixel1 0x0f000000, 24      ; ..... 8
283         cache_align
285 .cleanup:
287         popad
289         ret
291         cache_align
293 ; ----------------------------------------
295 __drawtile1:
297         pushad
298         mov ebp, esp
300 .setup
302 .get_pal:       
304         mov ebx, which
305         mov esi, [__highpal]
306         mov eax, ebx
307         shr eax, byte 7
308         and eax, 0xc0
309         add esi, eax
310         push esi
312 .check_y_flip:
314         mov eax, ebx
315         xor ecx, ecx
316         mov edx, line
317         test eax, 0x1000
319         jz .check_interlace
321 .y_flipped:
323         xor edx, byte 7
325         cache_align
327 .check_interlace:
329         mov esi, [__reg]
330         mov cl, [esi+12]
331         mov esi, [__vram]
332         and eax, 0x7ff
333         test cl, byte 0x2
335         jz .no_interlace
337 .interlace:
339         lea edx, [edx*8]
340         shl eax, 6
341         jmp .check_x_flip
343         cache_align
345 .no_interlace:
347         lea edx, [edx*4]
348         shl eax, 5
350         cache_align
352 .check_x_flip:
354         add eax, edx
355         mov edi, where
356         lea esi, [esi+eax]
357         mov ebx, [esi]
358         pop esi
359         test ebx, ebx
361         jz near .cleanup                ; Don't waste time if the tile is blank!
363         mov eax, which
364         test eax, 0x800
366         jz near .x_not_flipped
368 .x_flipped:
370         blit_pixel1_trans 0x0f000000, 24        ; pixel 8
371         blit_pixel1_trans 0xf0000000, 28        ; ..... 7
372         blit_pixel1_trans 0x000f0000, 16        ; ..... 6
373         blit_pixel1_trans 0x00f00000, 20        ; ..... 5
374         blit_pixel1_trans 0x00000f00, 8         ; ..... 4
375         blit_pixel1_trans 0x0000f000, 12        ; ..... 3
376         blit_pixel1_trans 0x0000000f            ; ..... 2
377         blit_pixel1_trans 0x000000f0, 4         ; ..... 1
379         jmp .cleanup
381         cache_align
383 .x_not_flipped:
385         blit_pixel1_trans 0x000000f0, 4         ; pixel 1
386         blit_pixel1_trans 0x0000000f            ; ..... 2
387         blit_pixel1_trans 0x0000f000, 12        ; ..... 3
388         blit_pixel1_trans 0x00000f00, 8         ; ..... 4
389         blit_pixel1_trans 0x00f00000, 20        ; ..... 5
390         blit_pixel1_trans 0x000f0000, 16        ; ..... 6
391         blit_pixel1_trans 0xf0000000, 28        ; ..... 7
392         blit_pixel1_trans 0x0f000000, 24        ; ..... 8
394         cache_align
396 .cleanup:
398         popad
400         ret
402         cache_align
404 ; ----------------------------------------
406         cache_align
408 __drawtile2_solid:
410         pushad
411         mov ebp, esp
413 .setup
415 .get_pal:       
417         mov ebx, which
418         mov esi, [__highpal]
419         mov ecx, esi
420         mov eax, ebx
421         shr eax, byte 7
422         and eax, 0xc0
423         add esi, eax
424 ; -
425         mov edi, [__reg]
426         mov edx, [edi + 7]
427         push dword [esi]
428         and edx, 0x3f
429         mov eax, [ecx + edx*4]
430         mov [esi], eax
431 ; -
432         push esi
434 .check_y_flip:
436         mov eax, ebx
437         xor ecx, ecx
438         mov edx, line
439         test eax, 0x1000
441         jz .check_interlace
443 .y_flipped:
445         xor edx, byte 7
447         cache_align
449 .check_interlace:
451         mov esi, [__reg]
452         mov cl, [esi+12]
453         mov esi, [__vram]
454         and eax, 0x7ff
455         test cl, byte 0x2
457         jz .no_interlace
459 .interlace:
461         lea edx, [edx*8]
462         shl eax, 6
463         jmp .check_x_flip
465         cache_align
467 .no_interlace:
469         lea edx, [edx*4]
470         shl eax, 5
472         cache_align
474 .check_x_flip:
476         add eax, edx
477         mov edi, where
478         lea esi, [esi+eax]
479         mov ebx, [esi]
480         pop esi
481         mov eax, which
482         test eax, 0x800
484         jz near .x_not_flipped
486 .x_flipped:
488         blit_pixel2 0x0f000000, 24      ; pixel 8
489         blit_pixel2 0xf0000000, 28      ; ..... 7
490         blit_pixel2 0x000f0000, 16      ; ..... 6
491         blit_pixel2 0x00f00000, 20      ; ..... 5
492         blit_pixel2 0x00000f00, 8       ; ..... 4
493         blit_pixel2 0x0000f000, 12      ; ..... 3
494         blit_pixel2 0x0000000f          ; ..... 2
495         blit_pixel2 0x000000f0, 4       ; ..... 1
497         jmp .cleanup
499         cache_align
501 .x_not_flipped:
503         blit_pixel2 0x000000f0, 4       ; pixel 1
504         blit_pixel2 0x0000000f          ; ..... 2
505         blit_pixel2 0x0000f000, 12      ; ..... 3
506         blit_pixel2 0x00000f00, 8       ; ..... 4
507         blit_pixel2 0x00f00000, 20      ; ..... 5
508         blit_pixel2 0x000f0000, 16      ; ..... 6
509         blit_pixel2 0xf0000000, 28      ; ..... 7
510         blit_pixel2 0x0f000000, 24      ; ..... 8
512         cache_align
514 .cleanup:
515         pop dword [esi]
516         popad
517         ret
519         cache_align
521 ; ----------------------------------------
523         cache_align
525 __drawtile2:
527         pushad
528         mov ebp, esp
530 .get_pal:       
532         mov ebx, which
533         mov esi, [__highpal]
534         mov eax, ebx    
535         shr eax, 7
536         and eax, 0xc0
537         add esi, eax
538         push esi
540 .check_y_flip:
542         mov eax, ebx
543         xor ecx, ecx
544         mov edx, line
545         test eax, 0x1000
547         jz .check_interlace
549 .y_flipped:
551         xor edx, byte 7
553         cache_align
555 .check_interlace:
557         mov esi, [__reg]
558         mov cl, [esi+12]
559         mov esi, [__vram]
560         and eax, 0x7ff
561         test cl, byte 0x2
563         jz .no_interlace
565 .interlace:
567         lea edx, [edx*8]
568         shl eax, 6
570         jmp .check_x_flip
572         cache_align
574 .no_interlace:
575         lea edx, [edx*4]
576         shl eax, 5
578         cache_align
580 .check_x_flip:
582         add eax, edx
583         mov edi, where
584         lea esi, [esi+eax]
585         mov ebx, [esi]
586         pop esi
587         test ebx, ebx
589         jz near .cleanup                ; Don't waste time if the tile is blank!
591         mov eax, which
592         test eax, 0x800
594         jz near .x_not_flipped
596 .x_flipped:
598         blit_pixel2_trans 0x0f000000, 24        ; pixel 8
599         blit_pixel2_trans 0xf0000000, 28        ; ..... 7
600         blit_pixel2_trans 0x000f0000, 16        ; ..... 6
601         blit_pixel2_trans 0x00f00000, 20        ; ..... 5
602         blit_pixel2_trans 0x00000f00, 8         ; ..... 4
603         blit_pixel2_trans 0x0000f000, 12        ; ..... 3
604         blit_pixel2_trans 0x0000000f            ; ..... 2
605         blit_pixel2_trans 0x000000f0, 4         ; ..... 1
607         jmp .cleanup
609         cache_align
611 .x_not_flipped:
613         blit_pixel2_trans 0x000000f0, 4         ; pixel 1
614         blit_pixel2_trans 0x0000000f            ; ..... 2
615         blit_pixel2_trans 0x0000f000, 12        ; ..... 3
616         blit_pixel2_trans 0x00000f00, 8         ; ..... 4
617         blit_pixel2_trans 0x00f00000, 20        ; ..... 5
618         blit_pixel2_trans 0x000f0000, 16        ; ..... 6
619         blit_pixel2_trans 0xf0000000, 28        ; ..... 7
620         blit_pixel2_trans 0x0f000000, 24        ; ..... 8
622         cache_align
624 .cleanup:
625         popad
626         ret
628         cache_align
630 ; ----------------------------------------
632 __drawtile3_solid:
634         pushad
635         mov ebp, esp
637 .setup
639 .get_pal:       
641         mov ebx, which
642         mov esi, [__highpal]
643         mov ecx, esi
644         mov eax, ebx
645         shr eax, byte 7
646         and eax, 0xc0
647         add esi, eax
648 ; -
649         mov edi, [__reg]
650         mov edx, [edi + 7]
651         push dword [esi]
652         and edx, 0x3f
653         mov eax, [ecx + edx*4]
654         mov [esi], eax
655 ; -
656         push esi
658 .check_y_flip:
660         mov eax, ebx
661         xor ecx, ecx
662         mov edx, line
663         test eax, 0x1000
665         jz .check_interlace
667 .y_flipped:
669         xor edx, byte 7
671         cache_align
673 .check_interlace:
675         mov esi, [__reg]
676         mov cl, [esi+12]
677         mov esi, [__vram]
678         and eax, 0x7ff
679         test cl, byte 0x2
681         jz .no_interlace
683 .interlace:
685         lea edx, [edx*8]
686         shl eax, 6
687         jmp .check_x_flip
689         cache_align
691 .no_interlace:
693         lea edx, [edx*4]
694         shl eax, 5
696         cache_align
698 .check_x_flip:
700         add eax, edx
701         mov edi, where
702         lea esi, [esi+eax]
703         mov ebx, [esi]
704         pop esi
705         mov eax, which
706         test eax, 0x800
708         jz near .x_not_flipped
710 .x_flipped:
712         blit_pixel3 0x0f000000, 24      ; pixel 8
713         blit_pixel3 0xf0000000, 28      ; ..... 7
714         blit_pixel3 0x000f0000, 16      ; ..... 6
715         blit_pixel3 0x00f00000, 20      ; ..... 5
716         blit_pixel3 0x00000f00, 8       ; ..... 4
717         blit_pixel3 0x0000f000, 12      ; ..... 3
718         blit_pixel3 0x0000000f          ; ..... 2
719         blit_pixel3 0x000000f0, 4       ; ..... 1
721         jmp .cleanup
723         cache_align
725 .x_not_flipped:
727         blit_pixel3 0x000000f0, 4       ; pixel 1
728         blit_pixel3 0x0000000f          ; ..... 2
729         blit_pixel3 0x0000f000, 12      ; ..... 3
730         blit_pixel3 0x00000f00, 8       ; ..... 4
731         blit_pixel3 0x00f00000, 20      ; ..... 5
732         blit_pixel3 0x000f0000, 16      ; ..... 6
733         blit_pixel3 0xf0000000, 28      ; ..... 7
734         blit_pixel3 0x0f000000, 24      ; ..... 8
736         cache_align
738 .cleanup:
740         pop dword [esi]
741         popad
742         ret
744         cache_align
746 ; ----------------------------------------
748 __drawtile3:
750         pushad
751         mov ebp, esp
753 .setup
755 .get_pal:       
757         mov ebx, which
758         mov esi, [__highpal]
759         mov eax, ebx
760         shr eax, byte 7
761         and eax, 0xc0
762         add esi, eax
763         push esi
765 .check_y_flip:
767         mov eax, ebx
768         xor ecx, ecx
769         mov edx, line
770         test eax, 0x1000
772         jz .check_interlace
774 .y_flipped:
776         xor edx, byte 7
778         cache_align
780 .check_interlace:
782         mov esi, [__reg]
783         mov cl, [esi+12]
784         mov esi, [__vram]
785         and eax, 0x7ff
786         test cl, byte 0x2
788         jz .no_interlace
790 .interlace:
792         lea edx, [edx*8]
793         shl eax, 6
794         jmp .check_x_flip
796         cache_align
798 .no_interlace:
800         lea edx, [edx*4]
801         shl eax, 5
803         cache_align
805 .check_x_flip:
807         add eax, edx
808         mov edi, where
809         lea esi, [esi+eax]
810         mov ebx, [esi]
811         pop esi
812         test ebx, ebx
814         jz near .cleanup                ; Don't waste time if the tile is blank!
816         mov eax, which
817         test eax, 0x800
819         jz near .x_not_flipped
821 .x_flipped:
823         blit_pixel3_trans 0x0f000000, 24        ; pixel 8
824         blit_pixel3_trans 0xf0000000, 28        ; ..... 7
825         blit_pixel3_trans 0x000f0000, 16        ; ..... 6
826         blit_pixel3_trans 0x00f00000, 20        ; ..... 5
827         blit_pixel3_trans 0x00000f00, 8         ; ..... 4
828         blit_pixel3_trans 0x0000f000, 12        ; ..... 3
829         blit_pixel3_trans 0x0000000f            ; ..... 2
830         blit_pixel3_trans 0x000000f0, 4         ; ..... 1
832         jmp .cleanup
834         cache_align
836 .x_not_flipped:
838         blit_pixel3_trans 0x000000f0, 4         ; pixel 1
839         blit_pixel3_trans 0x0000000f            ; ..... 2
840         blit_pixel3_trans 0x0000f000, 12        ; ..... 3
841         blit_pixel3_trans 0x00000f00, 8         ; ..... 4
842         blit_pixel3_trans 0x00f00000, 20        ; ..... 5
843         blit_pixel3_trans 0x000f0000, 16        ; ..... 6
844         blit_pixel3_trans 0xf0000000, 28        ; ..... 7
845         blit_pixel3_trans 0x0f000000, 24        ; ..... 8
847         cache_align
849 .cleanup:
851         popad
853         ret
855         cache_align
857 ; ----------------------------------------
859 __drawtile4_solid:
861         pushad
862         mov ebp, esp
864 .setup
866 .get_pal:       
868         mov ebx, which
869         mov esi, [__highpal]
870         mov ecx, esi
871         mov eax, ebx
872         shr eax, byte 7
873         and eax, 0xc0
874         add esi, eax
875 ; -
876         mov edi, [__reg]
877         mov edx, [edi + 7]
878         push dword [esi]
879         and edx, 0x3f
880         mov eax, [ecx + edx*4]
881         mov [esi], eax
882 ; -
883         push esi
885 .check_y_flip:
887         mov eax, ebx
888         xor ecx, ecx
889         mov edx, line
890         test eax, 0x1000
892         jz .check_interlace
894 .y_flipped:
896         xor edx, byte 7
898         cache_align
900 .check_interlace:
902         mov esi, [__reg]
903         mov cl, [esi+12]
904         mov esi, [__vram]
905         and eax, 0x7ff
906         test cl, byte 0x2
908         jz .no_interlace
910 .interlace:
912         lea edx, [edx*8]
913         shl eax, 6
914         jmp .check_x_flip
916         cache_align
918 .no_interlace:
920         lea edx, [edx*4]
921         shl eax, 5
923         cache_align
925 .check_x_flip:
927         add eax, edx
928         mov edi, where
929         lea esi, [esi+eax]
930         mov ebx, [esi]
931         pop esi
932         mov eax, which
933         test eax, 0x800
935         jz near .x_not_flipped
937 .x_flipped:
939         blit_pixel4 0x0f000000, 24      ; pixel 8
940         blit_pixel4 0xf0000000, 28      ; ..... 7
941         blit_pixel4 0x000f0000, 16      ; ..... 6
942         blit_pixel4 0x00f00000, 20      ; ..... 5
943         blit_pixel4 0x00000f00, 8       ; ..... 4
944         blit_pixel4 0x0000f000, 12      ; ..... 3
945         blit_pixel4 0x0000000f          ; ..... 2
946         blit_pixel4 0x000000f0, 4       ; ..... 1
948         jmp .cleanup
950         cache_align
952 .x_not_flipped:
954         blit_pixel4 0x000000f0, 4       ; pixel 1
955         blit_pixel4 0x0000000f          ; ..... 2
956         blit_pixel4 0x0000f000, 12      ; ..... 3
957         blit_pixel4 0x00000f00, 8       ; ..... 4
958         blit_pixel4 0x00f00000, 20      ; ..... 5
959         blit_pixel4 0x000f0000, 16      ; ..... 6
960         blit_pixel4 0xf0000000, 28      ; ..... 7
961         blit_pixel4 0x0f000000, 24      ; ..... 8
963         cache_align
965 .cleanup:
967         pop dword [esi]
968         popad
969         ret
971         cache_align
973 ; ----------------------------------------
975 __drawtile4:
977         pushad
978         mov ebp, esp
980 .setup
982 .get_pal:       
984         mov ebx, which
985         mov esi, [__highpal]
986         mov eax, ebx
987         shr eax, byte 7
988         and eax, 0xc0
989         add esi, eax
990         push esi
992 .check_y_flip:
994         mov eax, ebx
995         xor ecx, ecx
996         mov edx, line
997         test eax, 0x1000
999         jz .check_interlace
1001 .y_flipped:
1003         xor edx, byte 7
1005         cache_align
1007 .check_interlace:
1009         mov esi, [__reg]
1010         mov cl, [esi+12]
1011         mov esi, [__vram]
1012         and eax, 0x7ff
1013         test cl, byte 0x2
1015         jz .no_interlace
1017 .interlace:
1019         lea edx, [edx*8]
1020         shl eax, 6
1021         jmp .check_x_flip
1023         cache_align
1025 .no_interlace:
1027         lea edx, [edx*4]
1028         shl eax, 5
1030         cache_align
1032 .check_x_flip:
1034         add eax, edx
1035         mov edi, where
1036         lea esi, [esi+eax]
1037         mov ebx, [esi]
1038         pop esi
1039         test ebx, ebx
1041         jz near .cleanup                ; Don't waste time if the tile is blank!
1043         mov eax, which
1044         test eax, 0x800
1046         jz near .x_not_flipped
1048 .x_flipped:
1050         blit_pixel4_trans 0x0f000000, 24        ; pixel 8
1051         blit_pixel4_trans 0xf0000000, 28        ; ..... 7
1052         blit_pixel4_trans 0x000f0000, 16        ; ..... 6
1053         blit_pixel4_trans 0x00f00000, 20        ; ..... 5
1054         blit_pixel4_trans 0x00000f00, 8         ; ..... 4
1055         blit_pixel4_trans 0x0000f000, 12        ; ..... 3
1056         blit_pixel4_trans 0x0000000f            ; ..... 2
1057         blit_pixel4_trans 0x000000f0, 4         ; ..... 1
1059         jmp .cleanup
1061         cache_align
1063 .x_not_flipped:
1065         blit_pixel4_trans 0x000000f0, 4         ; pixel 1
1066         blit_pixel4_trans 0x0000000f            ; ..... 2
1067         blit_pixel4_trans 0x0000f000, 12        ; ..... 3
1068         blit_pixel4_trans 0x00000f00, 8         ; ..... 4
1069         blit_pixel4_trans 0x00f00000, 20        ; ..... 5
1070         blit_pixel4_trans 0x000f0000, 16        ; ..... 6
1071         blit_pixel4_trans 0xf0000000, 28        ; ..... 7
1072         blit_pixel4_trans 0x0f000000, 24        ; ..... 8
1074         cache_align
1076 .cleanup:
1078         popad
1080         ret
1082         cache_align
1084 section .data
1086         __vram          dd 0
1087         __reg           dd 0
1088         __highpal       dd 0
1090 ; ----------------------------------------