1 @ vim:filetype=armasm
\r
3 @ assembly "optimized" version of some funtions from draw.c
\r
4 @ this is highly specialized, be careful if changing related C code!
\r
6 @ (c) Copyright 2007, Grazvydas "notaz" Ignotas
\r
7 @ All Rights Reserved
\r
9 .include "port_config.s"
\r
17 .extern DrawLineDest
\r
18 .extern DrawStripInterlace
\r
22 .macro TilePixel pat lsrr offs
\r
26 ands r4, \pat, r2, lsr #\lsrr
\r
29 strneb r4, [r1,#\offs]
\r
32 @ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
34 TilePixel \pat, 12, 0 @ #0x0000f000
\r
35 TilePixel \pat, 8, 1 @ #0x00000f00
\r
36 TilePixel \pat, 4, 2 @ #0x000000f0
\r
37 TilePixel \pat, 0, 3 @ #0x0000000f
\r
38 TilePixel \pat, 28, 4 @ #0xf0000000
\r
39 TilePixel \pat, 24, 5 @ #0x0f000000
\r
40 TilePixel \pat, 20, 6 @ #0x00f00000
\r
41 TilePixel \pat, 16, 7 @ #0x000f0000
\r
44 @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
46 TilePixel \pat, 16, 0 @ #0x000f0000
\r
47 TilePixel \pat, 20, 1 @ #0x00f00000
\r
48 TilePixel \pat, 24, 2 @ #0x0f000000
\r
49 TilePixel \pat, 28, 3 @ #0xf0000000
\r
50 TilePixel \pat, 0, 4 @ #0x0000000f
\r
51 TilePixel \pat, 4, 5 @ #0x000000f0
\r
52 TilePixel \pat, 8, 6 @ #0x00000f00
\r
53 TilePixel \pat, 12, 7 @ #0x0000f000
\r
56 @ shadow/hilight mode
\r
58 @ this one is for hi priority layer
\r
59 .macro TilePixelShHP lsrr offs
\r
63 ands r4, r12, r2, lsr #\lsrr
\r
65 ldreqb r4, [r1,#\offs]
\r
67 strneb r4, [r1,#\offs]
\r
70 streqb r4, [r1,#\offs]
\r
73 @ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
\r
75 TilePixelShHP 12, 0 @ #0x0000f000
\r
76 TilePixelShHP 8, 1 @ #0x00000f00
\r
77 TilePixelShHP 4, 2 @ #0x000000f0
\r
78 TilePixelShHP 0, 3 @ #0x0000000f
\r
79 TilePixelShHP 28, 4 @ #0xf0000000
\r
80 TilePixelShHP 24, 5 @ #0x0f000000
\r
81 TilePixelShHP 20, 6 @ #0x00f00000
\r
82 TilePixelShHP 16, 7 @ #0x000f0000
\r
85 @ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
87 TilePixelShHP 16, 0 @ #0x000f0000
\r
88 TilePixelShHP 20, 1 @ #0x00f00000
\r
89 TilePixelShHP 24, 2 @ #0x0f000000
\r
90 TilePixelShHP 28, 3 @ #0xf0000000
\r
91 TilePixelShHP 0, 4 @ #0x0000000f
\r
92 TilePixelShHP 4, 5 @ #0x000000f0
\r
93 TilePixelShHP 8, 6 @ #0x00000f00
\r
94 TilePixelShHP 12, 7 @ #0x0000f000
\r
98 @ TileSingleSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx; r12: helper pattern 0xf
\r
100 tst r0, #1 @ not aligned?
\r
106 strneb r4, [r1], #1
\r
107 streqh r4, [r1], #2
\r
119 strneb r4, [r1], #1
\r
122 @ TileSingleHi (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
123 .macro TileSingleHi
\r
124 tst r1, #1 @ not aligned?
\r
127 ldrneb r4, [r1], #1
\r
128 ldreqh r4, [r1], #2 @ 1ci
\r
130 bic r4, r4, r7, lsr #1
\r
132 strneb r4, [r1, #-3]
\r
133 streqh r4, [r1, #-4]
\r
135 bic r12, r12, r7, lsr #1
\r
137 strh r12, [r1, #-4]
\r
139 bic r4, r4, r7, lsr #1
\r
143 bic r12, r12, r7, lsr #1
\r
145 strh r12, [r1, #-2]
\r
146 bicne r4, r4, r7, lsr #1
\r
148 strneb r4, [r1], #1
\r
152 .macro TileDoShGenPixel shift ofs
\r
154 ands r4, r12, r2, lsr #\shift
\r
163 strb r4, [r1,#\ofs]
\r
166 ldrb r4, [r1,#\ofs] @ 2ci
\r
168 strb r4, [r1,#\ofs]
\r
171 ldrb r4, [r1,#\ofs] @ 2ci
\r
174 strb r4, [r1,#\ofs]
\r
178 @ TileFlipSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
180 TileDoShGenPixel 16, 0 @ #0x000f0000
\r
181 TileDoShGenPixel 20, 1 @ #0x00f00000
\r
182 TileDoShGenPixel 24, 2 @ #0x0f000000
\r
183 TileDoShGenPixel 28, 3 @ #0xf0000000
\r
184 TileDoShGenPixel 0, 4 @ #0x0000000f
\r
185 TileDoShGenPixel 4, 5 @ #0x000000f0
\r
186 TileDoShGenPixel 8, 6 @ #0x00000f00
\r
187 TileDoShGenPixel 12, 7 @ #0x0000f000
\r
190 @ TileNormSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
192 TileDoShGenPixel 12, 0 @ #0x0000f000
\r
193 TileDoShGenPixel 8, 1 @ #0x00000f00
\r
194 TileDoShGenPixel 4, 2 @ #0x000000f0
\r
195 TileDoShGenPixel 0, 3 @ #0x0000000f
\r
196 TileDoShGenPixel 28, 4 @ #0xf0000000
\r
197 TileDoShGenPixel 24, 5 @ #0x0f000000
\r
198 TileDoShGenPixel 20, 6 @ #0x00f00000
\r
199 TileDoShGenPixel 16, 7 @ #0x000f0000
\r
203 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
207 @ int nametab; // 0x00
\r
208 @ int line; // 0x04
\r
209 @ int hscroll; // 0x08
\r
210 @ int xmask; // 0x0C
\r
211 @ int *hc; // 0x10 (pointer to cache buffer)
\r
212 @ int cells; // 0x14
\r
215 @ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
\r
220 stmfd sp!, {r4-r11,lr}
\r
222 ldr r11, =(Pico+0x22228) @ Pico.video
\r
225 ldrb r7, [r11, #16] @ ??vv??hh
\r
227 mov r6, r1 @ hcache
\r
228 orr r9, r3, r0, lsl #30
\r
229 orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp)
\r
232 orr r1, r1, #0x00ff
\r
236 biclt r1, r1, #0xfc00
\r
237 biceq r1, r1, #0xfe00
\r
238 bicgt r1, r1, #0xff00 @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels
\r
242 subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)
\r
245 mov r5, r8, lsl r10
\r
246 sub r5, r5, #1 @ r5=xmask
\r
250 ldreqb r12, [r11, #2]
\r
251 ldrneb r12, [r11, #4]
\r
253 ldr r2, =Scanline @ trying to make good use of pipeline here
\r
254 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
256 moveq r12, r12, lsl #10
\r
257 movne r12, r12, lsl #13
\r
258 and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
\r
260 ldrh r8, [r11, #12]
\r
261 ldrb r7, [r11, #11]
\r
264 mov r4, r8, lsr #8 @ pvid->reg[13]
\r
265 mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
\r
267 addne r4, r4, r2, lsl #2 @ htab+=Scanline<<1; // Offset by line
\r
269 biceq r4, r4, #0x1f @ htab&=~0xf; // Offset by tile
\r
270 add r4, r4, r0, lsl #1 @ htab+=plane
\r
271 bic r4, r4, #0x00ff0000 @ just in case
\r
272 ldrh r3, [lr, r4] @ r3=hscroll
\r
275 bne .DrawStrip_vsscroll
\r
277 @ Get vertical scroll value:
\r
278 add r7, lr, #0x012000
\r
279 add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
\r
284 bne .DrawStrip_interlace
\r
287 movne r7, r7, lsr #16
\r
289 @ Find the line in the name table
\r
293 add r10, r10, #1 @ shift[width]++
\r
294 add r12, r12, r4, lsl r10 @ nametab+=(ts.line>>3)<<shift[width];
\r
296 @ ldmia r0, {r1,r2,r3,r5,r6,r9} @ r2=line, r3=ts->hscroll, r5=ts->xmask, r6=ts->hc, r9=ts->cells
\r
299 mov r10,r10, lsl #1 @ r10=ty=(ts->line&7)<<1;
\r
300 orr r10,r10, r9, lsl #24
\r
303 mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
\r
307 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
\r
311 orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty)
\r
312 movne r3, #0x40 @ default to shadowed pal on sh mode
\r
315 addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll
\r
317 and r9, r9, #0xff00
\r
318 add r8, r8, r9, lsr #8 @ tilex+=cellskip
\r
319 add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
\r
320 sub r10,r10,r9, lsl #16 @ cells-=cellskip
\r
322 @ cache some stuff to avoid mem access
\r
323 .if OVERRIDE_HIGHCOL
\r
332 mvn r9, #0 @ r9=prevcode=-1
\r
333 add r1, r11, r7 @ r1=pdest
\r
336 @ r4 & r7 are scratch in this loop
\r
339 .dsloop: @ 40-41 times
\r
340 subs r10,r10, #0x01000000
\r
345 add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
\r
346 ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
352 bne .DrawStrip_hiprio
\r
355 beq .DrawStrip_samecode @ we know stuff about this tile already
\r
357 mov r9, r7 @ remember code
\r
358 orr r10, r10, #1<<21 @ seen non hi-prio tile
\r
360 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
362 add r2, r2, r10, lsl #17
\r
363 mov r2, r2, lsr #17
\r
364 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
366 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
369 and r3, r9, #0x6000
\r
370 add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
372 .DrawStrip_samecode:
\r
374 beq .dsloop @ tileline blank
\r
377 beq .DrawStrip_SingleColor @ tileline singlecolor
\r
380 bne .DrawStrip_TileFlip
\r
382 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
383 .DrawStrip_TileNorm:
\r
387 .DrawStrip_TileFlip:
\r
391 .DrawStrip_SingleColor:
\r
394 orr r4, r4, r4, lsl #8
\r
395 tst r1, #1 @ not aligned?
\r
396 strneb r4, [r1], #1
\r
397 streqh r4, [r1], #2
\r
401 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
404 .DrawStrip_hiprio_maybempt:
\r
406 beq .dsloop @ must've been empty, otherwise we wouldn't get here
\r
407 movs r2, r7, lsl #20 @ if (code&0x1000)
\r
409 add r2, r2, r10, lsl #17
\r
410 mov r2, r2, lsr #17
\r
411 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
412 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
413 mov r9, r7 @ remember code
\r
416 orr r10, r10, #1<<22
\r
419 tst r10, #0x00c00000
\r
420 beq .DrawStrip_hiprio_maybempt
\r
422 orr r7, r7, r0, lsl #16
\r
423 orr r7, r7, r10, lsl #25 @ (ty<<25)
\r
425 eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
\r
426 str r7, [r6], #4 @ cache hi priority tile
\r
431 tst r10, #1<<21 @ seen non hi-prio tile
\r
432 ldreq r1, =rendstatus
\r
435 str r0, [r6] @ terminate the cache list
\r
436 orreq r2, r2, #0x40 @ had a layer with all hi-prio tiles
\r
439 ldmfd sp!, {r4-r11,lr}
\r
442 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
444 .DrawStrip_vsscroll:
\r
446 mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
\r
447 bic r8, r8, #0x3fc00000
\r
448 orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[21:0])
\r
451 orr r5, r1, r10, lsl #24
\r
454 orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
\r
456 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
\r
458 mov r10,r9, lsl #16
\r
460 orrne r10,r10, #0x8000
\r
463 orr r10,r10, #0xff000000 @ will be adjusted on entering loop
\r
464 orrne r10,r10, #1<<23 @ r10=(cell[31:24]|sh[23]|hi_not_empty[22]|cells_max[21:16]|plane[15]|ty[14:0])
\r
465 movne r3, #0x40 @ default to shadowed pal on sh mode
\r
468 subne r10,r10, #0x01000000 @ have hscroll, start with negative cell
\r
470 and r9, r9, #0xff00
\r
471 add r8, r8, r9, lsr #8 @ tilex+=cellskip
\r
472 add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
\r
473 add r10,r10,r9, lsl #16 @ cell+=cellskip
\r
475 @ cache some stuff to avoid mem access
\r
476 .if OVERRIDE_HIGHCOL
\r
485 mvn r9, #0 @ r9=prevcode=-1
\r
486 add r1, r11, r7 @ r1=pdest
\r
488 @ r4 & r7 are scratch in this loop
\r
491 .dsloop_vs: @ 40-41 times
\r
492 add r10,r10, #0x01000000
\r
493 and r4, r10, #0x003f0000
\r
494 cmp r4, r10, asr #8
\r
495 ble .dsloop_vs_exit
\r
497 @ calc offset and read tileline code to r7, also calc ty
\r
498 add r7, lr, #0x012000
\r
499 add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
\r
500 add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
\r
502 tst r10,#0x8000 @ plane1?
\r
504 ldrh r7, [r7] @ r7=vscroll
\r
506 bic r10,r10,#0xff @ clear old ty
\r
507 and r4, r5, #0xff0000 @ scanline
\r
508 add r4, r4, r7, lsl #16 @ ... += vscroll
\r
509 and r4, r4, r5, lsl #16 @ ... &= ymask
\r
510 and r7, r4, #0x70000
\r
511 orr r10,r10,r7, lsr #15 @ new ty
\r
513 mov r4, r4, lsr #19
\r
514 mov r7, r5, lsr #24
\r
515 mov r4, r4, lsl r7 @ nametabadd
\r
517 and r7, r8, r8, lsr #25
\r
518 add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
\r
519 add r7, r7, r4, lsl #1
\r
520 ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
526 bne .DrawStrip_vs_hiprio
\r
529 beq .DrawStrip_vs_samecode @ we know stuff about this tile already
\r
531 mov r9, r7 @ remember code
\r
532 orr r8, r8, #(1<<24)@ seen non hi-prio tile
\r
534 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
536 add r2, r2, r10, lsl #17
\r
537 mov r2, r2, lsr #17
\r
538 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
540 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
543 and r3, r9, #0x6000
\r
544 add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
546 .DrawStrip_vs_samecode:
\r
548 beq .dsloop_vs @ tileline blank
\r
551 beq .DrawStrip_vs_SingleColor @ tileline singlecolor
\r
554 bne .DrawStrip_vs_TileFlip
\r
556 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
557 .DrawStrip_vs_TileNorm:
\r
561 .DrawStrip_vs_TileFlip:
\r
565 .DrawStrip_vs_SingleColor:
\r
568 orr r4, r4, r4, lsl #8
\r
569 tst r1, #1 @ not aligned?
\r
570 strneb r4, [r1], #1
\r
571 streqh r4, [r1], #2
\r
575 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
578 .DrawStrip_vs_hiprio:
\r
579 tst r10, #0x00c00000
\r
580 beq .DrawStrip_vs_hiprio_maybempt
\r
582 orr r7, r7, r0, lsl #16
\r
583 orr r7, r7, r10, lsl #25 @ (ty<<25)
\r
585 eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
\r
586 str r7, [r6], #4 @ cache hi priority tile
\r
590 .DrawStrip_vs_hiprio_maybempt:
\r
592 beq .dsloop_vs @ must've been empty, otherwise we wouldn't get here
\r
593 movs r2, r7, lsl #20 @ if (code&0x1000)
\r
595 add r2, r2, r10, lsl #17
\r
596 mov r2, r2, lsr #17
\r
597 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
598 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
599 mov r9, r7 @ remember code
\r
601 orrne r10, r10, #1<<22
\r
602 bne .DrawStrip_vs_hiprio
\r
606 tst r8, #(1<<24) @ seen non hi-prio tile
\r
607 ldreq r1, =rendstatus
\r
610 str r0, [r6] @ terminate the cache list
\r
611 orreq r2, r2, #0x40 @ had a layer with all hi-prio tiles
\r
614 ldmfd sp!, {r4-r11,lr}
\r
618 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
620 @ interlace mode 2? Sonic 2?
\r
621 .DrawStrip_interlace:
\r
623 moveq r7, r7, lsl #21
\r
624 movne r7, r7, lsl #5
\r
626 @ Find the line in the name table
\r
627 add r2, r7, r2, lsl #22 @ r2=(vscroll+(Scanline<<1))<<21 (11 bits);
\r
628 orr r1, r1, #0x80000000
\r
629 and r2, r2, r1, ror #10 @ &((ymask<<1)|1)<<21;
\r
630 mov r2, r2, lsr #21
\r
632 mov r12, r12, lsr #1 @ halfwords
\r
633 add r0, r12, r4, lsl r10 @ nametab+=(ts.line>>4)<<shift[width];
\r
637 stmia sp, {r0,r2,r3,r5,r6,r9}
\r
640 bl DrawStripInterlace @ struct TileStrip *ts
\r
643 ldmfd sp!, {r4-r11,lr}
\r
648 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
651 .global BackFill @ int reg7, int sh
\r
654 stmfd sp!, {r4-r9,lr}
\r
656 .if OVERRIDE_HIGHCOL
\r
658 mov r0, r0, lsl #26
\r
660 mov r0, r0, lsr #26
\r
663 ldr lr, =(HighCol+8)
\r
664 mov r0, r0, lsl #26
\r
665 mov r0, r0, lsr #26
\r
668 orr r0, r0, r1, lsl #6
\r
669 orr r0, r0, r0, lsl #8
\r
670 orr r0, r0, r0, lsl #16
\r
681 stmia lr!, {r0-r7} @ 10*8*4
\r
692 ldmfd sp!, {r4-r9,r12}
\r
696 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
699 .global DrawTilesFromCache @ int *hc, int sh, int rlim
\r
701 DrawTilesFromCache:
\r
702 stmfd sp!, {r4-r8,r11,lr}
\r
704 @ cache some stuff to avoid mem access
\r
705 .if OVERRIDE_HIGHCOL
\r
713 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
715 mvn r5, #0 @ r5=prevcode=-1
\r
717 orr r8, r8, r2, lsl #1
\r
718 bne .dtfc_check_rendflags
\r
722 ldr r6, [r0], #4 @ read code
\r
723 movs r1, r6, lsr #16 @ r1=dx;
\r
724 ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return
\r
725 bic r4, r1, #0xfe00
\r
726 add r1, r11, r4 @ r1=pdest
\r
728 mov r7, r6, lsl #16
\r
729 cmp r5, r7, lsr #16
\r
730 beq .dtfc_samecode @ if (code==prevcode)
\r
732 mov r5, r7, lsr #16
\r
734 mov r2, r5, lsl #21
\r
735 mov r2, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4;
\r
736 add r2, r2, r6, lsr #25 @ addr+=ty
\r
738 and r3, r5, #0x6000
\r
739 mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
741 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
744 rsbs r4, r4, r8, lsr #1
\r
754 beq .dtfc_SingleColor @ tileline singlecolor
\r
759 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
771 orr r4, r4, r4, lsl #8
\r
772 tst r1, #1 @ not aligned?
\r
773 strneb r4, [r1], #1
\r
774 streqh r4, [r1], #2
\r
778 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
783 beq .dtfc_shadow_blank
\r
786 beq .dtfc_SingleColor @ tileline singlecolor
\r
789 bne .dtfc_TileFlipShHP
\r
791 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
792 .dtfc_TileNormShHP:
\r
796 .dtfc_TileFlipShHP:
\r
800 .dtfc_shadow_blank:
\r
801 ldrb r4, [r1] @ 1ci
\r
808 andeq r12,r12,#0x3f
\r
816 andeq r12,r12,#0x3f
\r
824 andeq r12,r12,#0x3f
\r
831 andeq r12,r12,#0x3f
\r
837 add r4, r4, #7 @ 0-6
\r
841 mov r2, r2, ror #16
\r
842 tst r5, #0x0800 @ flipped?
\r
845 mov r2, r2, ror #16
\r
855 @ check if we have detected layer covered with hi-prio tiles:
\r
856 .dtfc_check_rendflags:
\r
857 ldr r1, =rendstatus
\r
861 bic r8, r8, #1 @ sh/hi mode off
\r
863 bne .dtfc_loop @ already processed
\r
870 orr r7, r7, r7, lsl #8
\r
871 orr r7, r7, r7, lsl #16
\r
873 orr r6, r6, r6, lsl #8
\r
874 orr r6, r6, r6, lsl #16
\r
877 bmi .dtfc_loop @ done
\r
882 beq .dtfc_loop_shprep
\r
883 tst r2, #0x80000000
\r
884 biceq r2, r2, #0xc0000000
\r
885 tst r2, #0x00800000
\r
886 biceq r2, r2, #0x00c00000
\r
887 tst r2, #0x00008000
\r
888 biceq r2, r2, #0x0000c000
\r
889 tst r2, #0x00000080
\r
890 biceq r2, r2, #0x000000c0
\r
892 b .dtfc_loop_shprep
\r
896 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
899 .global DrawSpritesFromCache @ int *hc, int maxwidth, int prio, int sh
\r
901 DrawSpritesFromCache:
\r
902 stmfd sp!, {r4-r11,lr}
\r
904 @ cache some stuff to avoid mem access
\r
905 .if OVERRIDE_HIGHCOL
\r
913 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
914 mov r6, r3, lsl #31
\r
920 ldr r9, [r10], #4 @ read code
\r
921 bic r6, r6, #7 @ using pipeline
\r
923 ldmeqfd sp!, {r4-r11,pc}
\r
925 mov r4, r9, lsl #28
\r
926 orr r6, r6, r4, lsr #30
\r
927 add r6, r6, #1 @ r6=s1cc???? ... ?????www (s=shadow/hilight, cc=pal, w=width)
\r
930 add r5, r5, #1 @ r5=delta
\r
932 rsbne r5, r5, #0 @ Flip X
\r
935 mov r2, r9, lsr #17
\r
936 mov r8, r2, lsl #1 @ tile=((unsigned int)code>>17)<<1;
\r
938 and r3, r9, #0x30 @ r3=pal=(code&0x30);
\r
941 orr r6, r6, r3, lsl #24
\r
943 mov r0, r9, lsl #16
\r
944 mov r0, r0, asr #22 @ sx=(code<<16)>>22
\r
945 adds r0, r0, #0 @ set ZV
\r
946 b .dsfc_inloop_enter
\r
956 .dsfc_inloop_enter:
\r
961 mov r8, r8, lsl #17
\r
962 mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
\r
964 ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+tile); // Get 8 pixels
\r
965 add r1, r11, r0 @ r1=pdest
\r
969 cmp r12, r6, lsr #28
\r
973 beq .dsfc_SingleColor @ tileline singlecolor
\r
978 @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
988 tst r0, #1 @ not aligned?
\r
991 orr r4, r4, r4, lsl #8
\r
992 strneb r4, [r1], #1
\r
993 streqh r4, [r1], #2
\r
997 strneb r4, [r1], #1
\r
1001 cmp r2, r2, ror #4
\r
1002 beq .dsfc_singlec_sh
\r
1005 bne .dsfc_TileFlip_sh
\r
1007 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1008 .dsfc_TileNorm_sh:
\r
1012 .dsfc_TileFlip_sh:
\r
1017 cmp r2, #0xe0000000
\r
1018 bcc .dsfc_SingleColor @ normal singlecolor tileline (carry inverted in ARM)
\r
1019 tst r2, #0x10000000
\r
1030 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1032 @ + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
\r
1033 @ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
1035 .global DrawSprite @ unsigned int *sprite, int **hc, int sh, int acc_sprites
\r
1038 stmfd sp!, {r4-r9,r11,lr}
\r
1040 orr r8, r3, r2, lsl #4
\r
1041 ldr r3, [r0] @ sprite[0]
\r
1043 mov r6, r3, lsr #28
\r
1044 sub r6, r6, #1 @ r6=width-1 (inc later)
\r
1045 mov r5, r3, lsr #24
\r
1046 and r5, r5, #7 @ r5=height
\r
1048 mov r4, r3, lsl #16 @ r4=sy<<16 (tmp)
\r
1052 sub r7, r7, r4, asr #16 @ r7=row=Scanline-sy
\r
1054 mov r2, r9, asr #16 @ r2=sx
\r
1055 mov r9, r9, lsl #16
\r
1056 mov r9, r9, lsr #16
\r
1057 orr r9, r9, r8, lsl #27 @ r9=code|sh[31]|as[27]
\r
1060 movne r4, r5, lsl #3
\r
1062 subne r7, r4, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
\r
1064 mov r8, r9, lsl #21
\r
1065 mov r8, r8, lsr #21
\r
1066 add r8, r8, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
\r
1069 mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
\r
1070 rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
\r
1072 mov r8, r8, lsl #4
\r
1074 add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
\r
1077 bne .dspr_cache @ if(code&0x8000) // high priority - cache it
\r
1080 @ cache some stuff to avoid mem access
\r
1081 .if OVERRIDE_HIGHCOL
\r
1089 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1091 mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
\r
1092 and r4, r9, #0x6000
\r
1093 orr r9, r9, r4, lsl #16
\r
1094 orrs r9, r9, #0x10000000 @ r9=scc1 a??? ... <code> (s=shadow/hilight, cc=pal, a=acc_spr)
\r
1096 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
\r
1097 orrmi r3, r3, #0x40 @ shadow by default
\r
1099 add r6, r6, #1 @ inc now
\r
1100 adds r0, r2, #0 @ mov sx to r0 and set ZV flags
\r
1101 b .dspr_loop_enter
\r
1104 subs r6, r6, #1 @ width--
\r
1105 ldmeqfd sp!, {r4-r9,r11,pc}@ return
\r
1106 adds r0, r0, #8 @ sx+=8
\r
1107 add r8, r8, r5 @ tile+=delta
\r
1110 ble .dspr_loop @ sx <= 0
\r
1112 ldmgefd sp!, {r4-r9,r11,pc}@ return
\r
1114 mov r8, r8, lsl #17
\r
1115 mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
\r
1117 ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1118 add r1, r11, r0 @ r1=pdest
\r
1122 cmp r12, r9, lsr #28
\r
1125 cmp r2, r2, ror #4
\r
1126 beq .dspr_SingleColor @ tileline singlecolor
\r
1129 bne .dspr_TileFlip
\r
1131 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1141 .dspr_SingleColor:
\r
1144 orr r4, r4, r4, lsl #8
\r
1145 tst r0, #1 @ not aligned?
\r
1146 strneb r4, [r1], #1
\r
1147 streqh r4, [r1], #2
\r
1151 strneb r4, [r1], #1
\r
1155 cmp r2, r2, ror #4
\r
1156 beq .dspr_singlec_sh
\r
1159 bne .dspr_TileFlip_sh
\r
1161 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1162 .dspr_TileNorm_sh:
\r
1166 .dspr_TileFlip_sh:
\r
1171 cmp r2, #0xe0000000
\r
1172 bcc .dspr_SingleColor @ normal tileline
\r
1173 tst r2, #0x10000000
\r
1184 @ *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>24)&0xf);
\r
1185 mov r4, r8, lsl #16 @ tile
\r
1187 orrne r4, r4, #0x10000 @ code&0x0800
\r
1188 mov r0, r2, lsl #22
\r
1189 orr r4, r4, r0, lsr #16 @ (sx<<6)&0x0000ffc0
\r
1190 and r0, r9, #0x6000
\r
1191 orr r4, r4, r0, lsr #9 @ (code>>9)&0x30
\r
1192 mov r3, r3, lsl #12
\r
1194 orr r4, r4, r3, lsr #28 @ (sprite[0]>>24)&0xf
\r
1200 ldmeqfd sp!, {r4-r9,r11,lr}
\r
1201 bne .dspr_continue @ draw anyway if accurate sprites enabled
\r
1204 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1206 .global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache
\r
1209 stmfd sp!, {r4-r11,lr}
\r
1211 ldr r11, =(Pico+0x22228) @ Pico.video
\r
1212 ldr r10, =Scanline
\r
1213 ldrb r12, [r11, #3] @ pvid->reg[3]
\r
1216 ldr r4, [r11, #12]
\r
1217 mov r5, r10, lsr #3
\r
1219 mov r10, r10, lsl #1 @ r10=ty
\r
1221 mov r12, r12, lsl #10
\r
1223 tst r4, #1 @ 40 cell mode?
\r
1224 andne r12, r12, #0xf000 @ 0x3c<<10
\r
1225 andeq r12, r12, #0xf800
\r
1226 addne r12, r12, r5, lsl #7
\r
1227 addeq r12, r12, r5, lsl #6 @ nametab
\r
1228 add r12, r12, r0, lsl #2 @ +starttile
\r
1230 ldr r6, =rendstatus
\r
1231 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1234 @ fetch the first code now
\r
1235 ldrh r7, [lr, r12]
\r
1237 ands r6, r6, #2 @ we care about bit 1 only
\r
1239 bne .dw_no_sameprio
\r
1241 cmp r2, r7, lsr #15
\r
1242 ldmnefd sp!, {r4-r11,pc} @ assume that whole window uses same priority
\r
1245 orr r6, r6, r3, lsl #8 @ shadow mode
\r
1249 @ cache some stuff to avoid mem access
\r
1250 .if OVERRIDE_HIGHCOL
\r
1252 mov r8, r8, lsl #1 @ cells
\r
1254 mvn r9, #0 @ r9=prevcode=-1
\r
1257 ldr r11,=(HighCol+8)
\r
1258 mov r8, r8, lsl #1 @ cells
\r
1259 mvn r9, #0 @ r9=prevcode=-1
\r
1261 add r1, r11, r0, lsl #4 @ r1=pdest
\r
1265 @ r4,r5 & r7 are scratch in this loop
\r
1269 add r12, r12, #2 @ halfwords
\r
1270 ldrh r7, [lr, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
1272 beq .dwloop_end @ done
\r
1274 eor r5, r6, r7, lsr #15
\r
1276 orrne r6, r6, #2 @ wrong pri
\r
1280 beq .dw_samecode @ we know stuff about this tile already
\r
1283 mov r9, r7 @ remember code
\r
1285 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
1286 mov r2, r2, lsl #1
\r
1287 add r2, r10, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4; addr+=ty
\r
1288 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
1290 and r3, r9, #0x6000
\r
1291 mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
1293 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1300 beq .dwloop @ tileline blank
\r
1302 cmp r2, r2, ror #4
\r
1303 beq .dw_SingleColor @ tileline singlecolor
\r
1308 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
1318 and r4, r0, r2 @ #0x0000000f
\r
1320 orr r4, r4, r4, lsl #8
\r
1321 orr r4, r4, r4, lsl #16
\r
1323 stmia r1!, {r4,r5}
\r
1324 b .dwloop_nor1 @ we incremeted r1 ourselves
\r
1327 tst r6, #1 @ hi pri?
\r
1328 orreq r3, r3, #0x40
\r
1329 beq .dw_shadow_done
\r
1331 tst r4, #0x00000080
\r
1332 biceq r4, r4, #0x000000c0
\r
1333 tst r4, #0x00008000
\r
1334 biceq r4, r4, #0x0000c000
\r
1335 tst r4, #0x00800000
\r
1336 biceq r4, r4, #0x00c00000
\r
1337 tst r4, #0x80000000
\r
1338 biceq r4, r4, #0xc0000000
\r
1341 tst r4, #0x00000080
\r
1342 biceq r4, r4, #0x000000c0
\r
1343 tst r4, #0x00008000
\r
1344 biceq r4, r4, #0x0000c000
\r
1345 tst r4, #0x00800000
\r
1346 biceq r4, r4, #0x00c00000
\r
1347 tst r4, #0x80000000
\r
1348 biceq r4, r4, #0xc0000000
\r
1353 ldr r0, =rendstatus
\r
1359 ldmfd sp!, {r4-r11,r12}
\r
1363 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1366 @ hilights 2 pixels in RGB444/BGR444 format
\r
1367 .macro TileDoShHi2Pixels444 reg
\r
1368 mov \reg, \reg, ror #12
\r
1369 adds \reg, \reg, #0x40000000
\r
1370 orrcs \reg, \reg, #0xf0000000
\r
1371 mov \reg, \reg, ror #28
\r
1372 adds \reg, \reg, #0x40000000
\r
1373 orrcs \reg, \reg, #0xf0000000
\r
1374 mov \reg, \reg, ror #28
\r
1375 adds \reg, \reg, #0x40000000
\r
1376 orrcs \reg, \reg, #0xf0000000
\r
1377 mov \reg, \reg, ror #24
\r
1378 adds \reg, \reg, #0x40000000
\r
1379 orrcs \reg, \reg, #0xf0000000
\r
1380 mov \reg, \reg, ror #28
\r
1381 adds \reg, \reg, #0x40000000
\r
1382 orrcs \reg, \reg, #0xf0000000
\r
1383 mov \reg, \reg, ror #28
\r
1384 adds \reg, \reg, #0x40000000
\r
1385 orrcs \reg, \reg, #0xf0000000
\r
1386 mov \reg, \reg, ror #12
\r
1390 .global FinalizeLineBGR444 @ int sh
\r
1392 FinalizeLineBGR444:
\r
1393 stmfd sp!, {r4-r6,lr}
\r
1395 ldr lr, =(Pico+0x22228) @ Pico.video
\r
1396 ldr r0, =DrawLineDest
\r
1397 ldrb r12, [lr, #12]
\r
1399 sub r3, lr, #0x128 @ r3=Pico.cram
\r
1402 movne r2, #320/4 @ len
\r
1403 bne .fl_no32colBGR444
\r
1408 addeq r0, r0, #32*2
\r
1410 .fl_no32colBGR444:
\r
1412 beq .fl_noshBGR444
\r
1416 ldrb r12, [lr, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1419 beq .fl_noshBGR444
\r
1421 strb r12, [lr, #-0x1a]
\r
1426 ldmia r3!, {r1,r5,r6,r12}
\r
1428 stmia r4!, {r1,r5,r6,r12}
\r
1429 bne .fl_loopcpBGR444
\r
1431 @ shadowed pixels:
\r
1433 orr r12,r12,#0x0700
\r
1434 orr r12,r12,r12,lsl #16
\r
1435 sub r3, r3, #0x40*2
\r
1436 add r5, r4, #0x80*2
\r
1438 .fl_loopcpBGR444_sh:
\r
1439 ldmia r3!, {r1,r6}
\r
1441 and r1, r12, r1, lsr #1
\r
1442 and r6, r12, r6, lsr #1
\r
1443 stmia r4!, {r1,r6}
\r
1444 stmia r5!, {r1,r6}
\r
1445 bne .fl_loopcpBGR444_sh
\r
1447 @ hilighted pixels:
\r
1448 sub r3, r3, #0x40*2
\r
1450 .fl_loopcpBGR444_hi:
\r
1452 TileDoShHi2Pixels444 r1
\r
1455 bne .fl_loopcpBGR444_hi
\r
1457 sub r3, r4, #0x40*3*2
\r
1462 ldr r12,=rendstatus
\r
1463 eors r6, r6, #1 @ sh is 0
\r
1466 tstne r12,#(1<<2) @ and PDRAW_ACC_SPRITES
\r
1468 .if OVERRIDE_HIGHCOL
\r
1472 mov lr, lr, lsl #1
\r
1475 ldr r1, =(HighCol+8)
\r
1477 mov lr, lr, lsl #1
\r
1484 and r4, lr, r12, lsl #1
\r
1486 and r5, lr, r12, lsr #7
\r
1488 and r6, lr, r12, lsr #15
\r
1490 and r12,lr, r12, lsr #23
\r
1491 ldrh r12,[r3, r12] @ 1c.i.
\r
1492 orr r4, r4, r5, lsl #16
\r
1493 orr r5, r6, r12,lsl #16
\r
1495 stmia r0!, {r4,r5}
\r
1496 bne .fl_loopBGR444
\r
1499 ldmfd sp!, {r4-r6,lr}
\r
1503 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1506 @ hilights 2 pixels in RGB555/BGR555 format
\r
1507 .macro TileDoShHi2Pixels555 reg
\r
1508 adds \reg, \reg, #0x40000000
\r
1509 orrcs \reg, \reg, #0xf0000000
\r
1510 mov \reg, \reg, ror #27
\r
1511 adds \reg, \reg, #0x40000000
\r
1512 orrcs \reg, \reg, #0xf0000000
\r
1513 mov \reg, \reg, ror #26
\r
1514 adds \reg, \reg, #0x40000000
\r
1515 orrcs \reg, \reg, #0xf0000000
\r
1516 mov \reg, \reg, ror #27
\r
1517 adds \reg, \reg, #0x40000000
\r
1518 orrcs \reg, \reg, #0xf0000000
\r
1519 mov \reg, \reg, ror #27
\r
1520 adds \reg, \reg, #0x40000000
\r
1521 orrcs \reg, \reg, #0xf0000000
\r
1522 mov \reg, \reg, ror #26
\r
1523 adds \reg, \reg, #0x40000000
\r
1524 orrcs \reg, \reg, #0xf0000000
\r
1525 mov \reg, \reg, ror #27
\r
1529 @ Convert 0000bbb0 ggg0rrr0
\r
1530 @ to rrrrrggg gggbbbbb
\r
1532 @ r2,r3,r9 - scratch, lr = 0x001c001c, r8 = 0x00030003
\r
1533 .macro convRGB565 reg
\r
1534 and r2, lr, \reg,lsl #1
\r
1535 and r9, r8, \reg,lsr #2
\r
1536 orr r2, r2, r9 @ r2=red
\r
1537 and r3, lr, \reg,lsr #7
\r
1538 and r9, r8, \reg,lsr #10
\r
1539 orr r3, r3, r9 @ r3=blue
\r
1540 and \reg, \reg, lr, lsl #3
\r
1541 orr \reg, \reg, \reg,lsl #3 @ green
\r
1542 orr \reg, \reg, r2, lsl #11 @ add red back
\r
1543 orr \reg, \reg, r3 @ add blue back
\r
1546 .global vidConvCpyRGB565
\r
1548 vidConvCpyRGB565: @ void *to, void *from, int pixels
\r
1549 stmfd sp!, {r4-r9,lr}
\r
1551 mov r12, r2, lsr #3 @ repeats
\r
1552 mov lr, #0x001c0000
\r
1553 orr lr, lr, #0x01c @ lr == pattern 0x001c001c
\r
1554 mov r8, #0x00030000
\r
1555 orr r8, r8, #0x003
\r
1558 ldmia r1!, {r4-r7}
\r
1571 ldmfd sp!, {r4-r9,lr}
\r
1576 .global FinalizeLineRGB555 @ int sh
\r
1578 FinalizeLineRGB555:
\r
1579 stmfd sp!, {r4-r8,lr}
\r
1580 ldr r8, =(Pico+0x22228) @ Pico.video
\r
1583 ldrb r7, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1587 beq .fl_noconvRGB555
\r
1588 strb r1, [r8, #-0x1a]
\r
1589 sub r1, r8, #0x128 @ r1=Pico.cram
\r
1592 bl vidConvCpyRGB565
\r
1597 beq .fl_noshRGB555
\r
1599 beq .fl_noshRGB555
\r
1601 @ shadowed pixels:
\r
1603 orr r12,r12,#0x7300
\r
1604 orr r12,r12,r12,lsl #16
\r
1605 add r4, r3, #0x40*2
\r
1606 add r5, r3, #0xc0*2
\r
1608 .fl_loopcpRGB555_sh:
\r
1609 ldmia r3!, {r1,r6}
\r
1611 and r1, r12, r1, lsr #1
\r
1612 and r6, r12, r6, lsr #1
\r
1613 stmia r4!, {r1,r6}
\r
1614 stmia r5!, {r1,r6}
\r
1615 bne .fl_loopcpRGB555_sh
\r
1617 @ hilighted pixels:
\r
1618 sub r3, r3, #0x40*2
\r
1620 .fl_loopcpRGB555_hi:
\r
1622 TileDoShHi2Pixels555 r1
\r
1625 bne .fl_loopcpRGB555_hi
\r
1627 sub r3, r3, #0x40*2
\r
1631 ldr r12,=rendstatus
\r
1632 eors r6, r6, #1 @ sh is 0
\r
1635 tstne r12,#(1<<2) @ and PDRAW_ACC_SPRITES
\r
1638 .if OVERRIDE_HIGHCOL
\r
1640 ldr r0, =DrawLineDest
\r
1645 ldr r0, =DrawLineDest
\r
1646 ldr r1, =(HighCol+8)
\r
1650 ldrb r12, [r8, #12]
\r
1651 mov lr, lr, lsl #1
\r
1654 movne r2, #320/8 @ len
\r
1655 bne .fl_no32colRGB555
\r
1660 bne .fl_32scale_RGB555
\r
1662 addeq r0, r0, #32*2
\r
1664 .fl_no32colRGB555:
\r
1666 .if UNALIGNED_DRAWLINEDEST
\r
1667 @ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer
\r
1676 and r4, lr, r12, lsl #1
\r
1678 and r5, lr, r12, lsr #7
\r
1680 and r6, lr, r12, lsr #15
\r
1682 orr r4, r4, r5, lsl #16
\r
1684 and r5, lr, r12, lsr #23
\r
1686 and r8, lr, r7, lsl #1
\r
1688 orr r5, r6, r5, lsl #16
\r
1690 and r6, lr, r7, lsr #7
\r
1692 and r12,lr, r7, lsr #15
\r
1693 ldrh r12,[r3, r12]
\r
1694 and r7, lr, r7, lsr #23
\r
1696 orr r8, r8, r6, lsl #16
\r
1699 orr r12,r12, r7, lsl #16
\r
1701 stmia r0!, {r4,r5,r8,r12}
\r
1702 bne .fl_loopRGB555
\r
1704 ldmfd sp!, {r4-r8,lr}
\r
1708 .fl_32scale_RGB555:
\r
1709 stmfd sp!, {r9,r10}
\r
1710 mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1711 orr r9, r9, #0x00e7
\r
1713 .if UNALIGNED_DRAWLINEDEST
\r
1715 bne .fl_32scale_RGB555u
\r
1718 .fl_loop32scale_RGB555:
\r
1722 and r4, lr, r12,lsl #1
\r
1724 and r5, lr, r12,lsr #7
\r
1726 and r4, r4, r9, lsl #2
\r
1727 orr r4, r4, r4, lsl #14 @ r4[31:16] = 1/4 pix_s 0
\r
1728 and r5, r5, r9, lsl #2
\r
1729 sub r6, r5, r5, lsr #2 @ r6 = 3/4 pix_s 1
\r
1730 add r4, r4, r6, lsl #16 @ pix_d 0, 1
\r
1731 and r6, lr, r12,lsr #15
\r
1733 and r12,lr, r12,lsr #23
\r
1734 ldrh r12,[r3, r12]
\r
1735 and r6, r6, r9, lsl #2
\r
1737 mov r5, r5, lsr #1
\r
1738 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1739 orr r5, r5, r6, lsl #16
\r
1741 and r6, lr, r7, lsl #1
\r
1743 and r12,r12,r9, lsl #2
\r
1744 add r5, r5, r12,lsl #14 @ pix_d 2, 3
\r
1745 and r6, r6, r9, lsl #2
\r
1746 orr r6, r12,r6, lsl #16 @ pix_d 4, 5
\r
1748 and r12,lr, r7, lsr #7
\r
1749 ldrh r12,[r3, r12]
\r
1750 and r10,lr, r7, lsr #15
\r
1751 ldrh r10,[r3, r10]
\r
1752 and r12,r12,r9, lsl #2
\r
1753 sub r8, r12,r12,lsr #2 @ r8 = 3/4 pix_s 1
\r
1754 add r8, r8, r6, lsr #18
\r
1755 and r7, lr, r7, lsr #23
\r
1757 and r10,r10,r9, lsl #2
\r
1758 orr r8, r8, r10,lsl #15
\r
1759 add r8, r8, r12,lsl #15 @ pix_d 6, 7
\r
1760 sub r10,r10,r10,lsr #2 @ r10= 3/4 pix_s 2
\r
1761 and r7, r7, r9, lsl #2
\r
1762 add r10,r10,r7, lsr #2 @ += 1/4 pix_s 3
\r
1763 orr r10,r10,r7, lsl #16 @ pix_d 8, 9
\r
1767 stmia r0!, {r4,r5,r6,r8,r10}
\r
1768 bne .fl_loop32scale_RGB555
\r
1770 ldmfd sp!, {r9,r10}
\r
1771 ldmfd sp!, {r4-r8,lr}
\r
1774 .if UNALIGNED_DRAWLINEDEST
\r
1775 @ unaligned versions of loops
\r
1776 @ warning: starts drawing 2bytes before dst
\r
1779 sub r0, r0, #2 @ initial adjustment
\r
1786 and r6, lr, r12,lsl #1
\r
1788 and r5, lr, r12,lsr #7
\r
1790 orr r4, r8, r6, lsl #16
\r
1792 and r6, lr, r12,lsr #15
\r
1794 and r8, lr, r12,lsr #23
\r
1796 orr r5, r5, r6, lsl #16
\r
1798 and r6, lr, r7, lsl #1
\r
1800 and r12,lr, r7, lsr #7
\r
1801 ldrh r12,[r3, r12]
\r
1802 orr r6, r8, r6, lsl #16
\r
1804 and r8, lr, r7, lsr #15
\r
1806 and r7, lr, r7, lsr #23
\r
1809 orr r12,r12,r8, lsl #16
\r
1812 stmia r0!, {r4,r5,r6,r12}
\r
1813 bne .fl_loopRGB555u
\r
1817 ldmfd sp!, {r4-r8,lr}
\r
1821 .fl_32scale_RGB555u:
\r
1822 sub r0, r0, #2 @ initial adjustment
\r
1825 @ r9 f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1826 .fl_loop32scale_RGB555u:
\r
1830 and r6, lr, r12,lsl #1
\r
1832 and r5, lr, r12,lsr #7
\r
1834 and r6, r6, r9, lsl #2
\r
1835 orr r4, r4, r6, lsl #16 @ r4 = pix_d -1, 0
\r
1837 and r5, r5, r9, lsl #2
\r
1838 sub r8, r5, r5, lsr #2 @ r8 = 3/4 pix_s 1
\r
1839 add r6, r8, r6, lsr #2 @ r6 = (1/4 pix_s 0) + (3/4 pix_s 1)
\r
1840 orr r5, r6, r5, lsl #15
\r
1842 and r6, lr, r12,lsr #15
\r
1844 and r12,lr, r12,lsr #23
\r
1845 ldrh r12,[r3, r12]
\r
1846 and r6, r6, r9, lsl #2
\r
1847 add r5, r5, r6, lsl #15 @ r5 = pix_d 1, 2
\r
1849 and r8, lr, r7, lsl #1
\r
1851 and r10,lr, r7, lsr #7
\r
1852 ldrh r10,[r3, r10]
\r
1853 and r12,r12,r9, lsl #2
\r
1854 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1855 add r6, r6, r12,lsr #2
\r
1856 orr r6, r6, r12,lsl #16 @ r6 = pix_d 3, 4
\r
1858 and r8, r8, r9, lsl #2
\r
1859 and r10,r10,r9, lsl #2
\r
1860 sub r12,r10,r10,lsr #2 @ r12 = 3/4 pix_s 5
\r
1861 orr r8, r8, r8, lsl #14
\r
1862 add r8, r8, r12,lsl #16 @ r8 = pix_d 5, 6
\r
1863 and r12,lr, r7, lsr #15
\r
1864 ldrh r12,[r3, r12]
\r
1865 and r7, lr, r7, lsr #23
\r
1867 and r12,r12,r9, lsl #2
\r
1869 mov r10,r10, lsr #1
\r
1870 sub r12,r12,r12,lsr #2 @ r12 = 3/4 pix_s 6
\r
1871 orr r10,r10,r12,lsl #16
\r
1872 and r7, r7, r9, lsl #2
\r
1873 add r10,r10,r7, lsl #14 @ r10 = pix_d 7, 8
\r
1877 stmia r0!, {r4,r5,r6,r8,r10}
\r
1879 bne .fl_loop32scale_RGB555u
\r
1883 ldmfd sp!, {r9,r10}
\r
1884 ldmfd sp!, {r4-r8,lr}
\r
1887 .endif @ UNALIGNED_DRAWLINEDEST
\r
1890 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1893 .global blockcpy @ void *dst, void *src, size_t n
\r
1896 stmfd sp!, {r4,r5}
\r
1897 mov r2, r2, lsr #4
\r
1899 ldmia r1!, {r3-r5,r12}
\r
1901 stmia r0!, {r3-r5,r12}
\r
1903 ldmfd sp!, {r4,r5}
\r
1907 .global blockcpy_or @ void *dst, void *src, size_t n, int pat
\r
1910 stmfd sp!, {r4-r6}
\r
1911 orr r3, r3, r3, lsl #8
\r
1912 orr r3, r3, r3, lsl #16
\r
1913 mov r2, r2, lsr #4
\r
1915 ldmia r1!, {r4-r6,r12}
\r
1921 stmia r0!, {r4-r6,r12}
\r
1922 bne blockcpy_loop_or
\r
1923 ldmfd sp!, {r4-r6}
\r