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, #0xff000000
\r
448 orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[23: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
\r
508 add r4, r4, r7, lsl #16
\r
509 and r4, r4, r5, lsl #16 @ r4=line<<16
\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 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, r1, 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
\r
1038 stmfd sp!, {r4-r9,r11,lr}
\r
1040 ldr r3, [r0] @ sprite[0]
\r
1042 mov r6, r3, lsr #28
\r
1043 sub r6, r6, #1 @ r6=width-1 (inc later)
\r
1044 mov r5, r3, lsr #24
\r
1045 and r5, r5, #7 @ r5=height
\r
1047 mov r4, r3, lsl #16 @ r4=sy<<16 (tmp)
\r
1051 sub r7, r7, r4, asr #16 @ r7=row=Scanline-sy
\r
1054 mov r2, r9, asr #16 @ r2=sx
\r
1055 bic r9, r9, #0xfe000000
\r
1056 orrne r9, r9, #1<<31 @ r9=code|(sh<<31)
\r
1059 movne r4, r5, lsl #3
\r
1061 subne r7, r4, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
\r
1063 mov r8, r9, lsl #21
\r
1064 mov r8, r8, lsr #21
\r
1065 add r8, r8, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
\r
1068 mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
\r
1069 rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
\r
1071 mov r8, r8, lsl #4
\r
1073 add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
\r
1076 bne .dspr_cache @ if(code&0x8000) // high priority - cache it
\r
1078 @ cache some stuff to avoid mem access
\r
1079 .if OVERRIDE_HIGHCOL
\r
1087 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1089 mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
\r
1090 and r4, r9, #0x6000
\r
1091 orr r9, r9, r4, lsl #16
\r
1092 orr r9, r9, #0x10000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
\r
1095 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
\r
1096 orrne r3, r3, #0x40 @ shadow by default
\r
1098 add r6, r6, #1 @ inc now
\r
1099 adds r0, r2, #0 @ mov sx to r0 and set ZV flags
\r
1100 b .dspr_loop_enter
\r
1103 subs r6, r6, #1 @ width--
\r
1104 ldmeqfd sp!, {r4-r9,r11,pc}@ return
\r
1105 adds r0, r0, #8 @ sx+=8
\r
1106 add r8, r8, r5 @ tile+=delta
\r
1109 ble .dspr_loop @ sx <= 0
\r
1111 ldmgefd sp!, {r4-r9,r11,pc}@ return
\r
1113 mov r8, r8, lsl #17
\r
1114 mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
\r
1116 ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1117 add r1, r11, r0 @ r1=pdest
\r
1121 cmp r12, r9, lsr #28
\r
1124 cmp r2, r2, ror #4
\r
1125 beq .dspr_SingleColor @ tileline singlecolor
\r
1128 bne .dspr_TileFlip
\r
1130 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1140 .dspr_SingleColor:
\r
1143 orr r4, r4, r4, lsl #8
\r
1144 tst r0, #1 @ not aligned?
\r
1145 strneb r4, [r1], #1
\r
1146 streqh r4, [r1], #2
\r
1150 strneb r4, [r1], #1
\r
1154 cmp r2, r2, ror #4
\r
1155 beq .dspr_singlec_sh
\r
1158 bne .dspr_TileFlip_sh
\r
1160 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1161 .dspr_TileNorm_sh:
\r
1165 .dspr_TileFlip_sh:
\r
1170 cmp r2, #0xe0000000
\r
1171 bcc .dspr_SingleColor @ normal tileline
\r
1172 tst r2, #0x10000000
\r
1183 @ *(*hc)++ = (tile<<16)|((code&0x0800)<<5)|((sx<<6)&0x0000ffc0)|((code>>9)&0x30)|((sprite[0]>>24)&0xf);
\r
1184 mov r4, r8, lsl #16 @ tile
\r
1186 orrne r4, r4, #0x10000 @ code&0x0800
\r
1187 mov r2, r2, lsl #22
\r
1188 orr r4, r4, r2, lsr #16 @ (sx<<6)&0x0000ffc0
\r
1189 and r2, r9, #0x6000
\r
1190 orr r4, r4, r2, lsr #9 @ (code>>9)&0x30
\r
1191 mov r3, r3, lsl #12
\r
1193 orr r4, r4, r3, lsr #28 @ (sprite[0]>>24)&0xf
\r
1198 ldmfd sp!, {r4-r9,r11,lr}
\r
1201 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1203 .global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache
\r
1206 stmfd sp!, {r4-r11,lr}
\r
1208 ldr r11, =(Pico+0x22228) @ Pico.video
\r
1209 ldr r10, =Scanline
\r
1210 ldrb r12, [r11, #3] @ pvid->reg[3]
\r
1213 ldr r4, [r11, #12]
\r
1214 mov r5, r10, lsr #3
\r
1216 mov r10, r10, lsl #1 @ r10=ty
\r
1218 mov r12, r12, lsl #10
\r
1220 tst r4, #1 @ 40 cell mode?
\r
1221 andne r12, r12, #0xf000 @ 0x3c<<10
\r
1222 andeq r12, r12, #0xf800
\r
1223 addne r12, r12, r5, lsl #7
\r
1224 addeq r12, r12, r5, lsl #6 @ nametab
\r
1225 add r12, r12, r0, lsl #2 @ +starttile
\r
1227 ldr r6, =rendstatus
\r
1228 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1231 @ fetch the first code now
\r
1232 ldrh r7, [lr, r12]
\r
1234 ands r6, r6, #2 @ we care about bit 1 only
\r
1236 bne .dw_no_sameprio
\r
1238 cmp r2, r7, lsr #15
\r
1239 ldmnefd sp!, {r4-r11,pc} @ assume that whole window uses same priority
\r
1242 orr r6, r6, r3, lsl #8 @ shadow mode
\r
1246 @ cache some stuff to avoid mem access
\r
1247 .if OVERRIDE_HIGHCOL
\r
1249 mov r8, r8, lsl #1 @ cells
\r
1251 mvn r9, #0 @ r9=prevcode=-1
\r
1254 ldr r11,=(HighCol+8)
\r
1255 mov r8, r8, lsl #1 @ cells
\r
1256 mvn r9, #0 @ r9=prevcode=-1
\r
1258 add r1, r11, r0, lsl #4 @ r1=pdest
\r
1262 @ r4,r5 & r7 are scratch in this loop
\r
1266 add r12, r12, #2 @ halfwords
\r
1267 ldrh r7, [lr, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
1269 beq .dwloop_end @ done
\r
1271 eor r5, r6, r7, lsr #15
\r
1273 orrne r6, r6, #2 @ wrong pri
\r
1277 beq .dw_samecode @ we know stuff about this tile already
\r
1280 mov r9, r7 @ remember code
\r
1282 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
1283 mov r2, r2, lsl #1
\r
1284 add r2, r10, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4; addr+=ty
\r
1285 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
1287 and r3, r9, #0x6000
\r
1288 mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
1290 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1297 beq .dwloop @ tileline blank
\r
1299 cmp r2, r2, ror #4
\r
1300 beq .dw_SingleColor @ tileline singlecolor
\r
1305 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
1315 and r4, r0, r2 @ #0x0000000f
\r
1317 orr r4, r4, r4, lsl #8
\r
1318 orr r4, r4, r4, lsl #16
\r
1320 stmia r1!, {r4,r5}
\r
1321 b .dwloop_nor1 @ we incremeted r1 ourselves
\r
1324 tst r6, #1 @ hi pri?
\r
1325 orreq r3, r3, #0x40
\r
1326 beq .dw_shadow_done
\r
1328 tst r4, #0x00000080
\r
1329 biceq r4, r4, #0x000000c0
\r
1330 tst r4, #0x00008000
\r
1331 biceq r4, r4, #0x0000c000
\r
1332 tst r4, #0x00800000
\r
1333 biceq r4, r4, #0x00c00000
\r
1334 tst r4, #0x80000000
\r
1335 biceq r4, r4, #0xc0000000
\r
1338 tst r4, #0x00000080
\r
1339 biceq r4, r4, #0x000000c0
\r
1340 tst r4, #0x00008000
\r
1341 biceq r4, r4, #0x0000c000
\r
1342 tst r4, #0x00800000
\r
1343 biceq r4, r4, #0x00c00000
\r
1344 tst r4, #0x80000000
\r
1345 biceq r4, r4, #0xc0000000
\r
1350 ldr r0, =rendstatus
\r
1356 ldmfd sp!, {r4-r11,r12}
\r
1360 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1363 @ hilights 2 pixels in RGB444/BGR444 format
\r
1364 .macro TileDoShHi2Pixels444 reg
\r
1365 mov \reg, \reg, ror #12
\r
1366 adds \reg, \reg, #0x40000000
\r
1367 orrcs \reg, \reg, #0xf0000000
\r
1368 mov \reg, \reg, ror #28
\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 #24
\r
1375 adds \reg, \reg, #0x40000000
\r
1376 orrcs \reg, \reg, #0xf0000000
\r
1377 mov \reg, \reg, ror #28
\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 #12
\r
1387 .global FinalizeLineBGR444 @ int sh
\r
1389 FinalizeLineBGR444:
\r
1390 stmfd sp!, {r4-r6,lr}
\r
1392 ldr lr, =(Pico+0x22228) @ Pico.video
\r
1393 ldr r0, =DrawLineDest
\r
1394 ldrb r12, [lr, #12]
\r
1396 sub r3, lr, #0x128 @ r3=Pico.cram
\r
1399 movne r2, #320/4 @ len
\r
1400 bne .fl_no32colBGR444
\r
1405 addeq r0, r0, #32*2
\r
1407 .fl_no32colBGR444:
\r
1409 beq .fl_noshBGR444
\r
1413 ldrb r12, [lr, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1416 beq .fl_noshBGR444
\r
1418 strb r12, [lr, #-0x1a]
\r
1423 ldmia r3!, {r1,r5,r6,r12}
\r
1425 stmia r4!, {r1,r5,r6,r12}
\r
1426 bne .fl_loopcpBGR444
\r
1428 @ shadowed pixels:
\r
1430 orr r12,r12,#0x0700
\r
1431 orr r12,r12,r12,lsl #16
\r
1432 sub r3, r3, #0x40*2
\r
1433 add r5, r4, #0x80*2
\r
1435 .fl_loopcpBGR444_sh:
\r
1436 ldmia r3!, {r1,r6}
\r
1438 and r1, r12, r1, lsr #1
\r
1439 and r6, r12, r6, lsr #1
\r
1440 stmia r4!, {r1,r6}
\r
1441 stmia r5!, {r1,r6}
\r
1442 bne .fl_loopcpBGR444_sh
\r
1444 @ hilighted pixels:
\r
1445 sub r3, r3, #0x40*2
\r
1447 .fl_loopcpBGR444_hi:
\r
1449 TileDoShHi2Pixels444 r1
\r
1452 bne .fl_loopcpBGR444_hi
\r
1454 sub r3, r4, #0x40*3*2
\r
1458 .if OVERRIDE_HIGHCOL
\r
1462 mov lr, lr, lsl #1
\r
1465 ldr r1, =(HighCol+8)
\r
1467 mov lr, lr, lsl #1
\r
1475 and r4, lr, r12, lsl #1
\r
1477 and r5, lr, r12, lsr #7
\r
1479 and r6, lr, r12, lsr #15
\r
1481 orr r4, r4, r5, lsl #16
\r
1483 and r5, lr, r12, lsr #23
\r
1484 ldrh r5, [r3, r5] @ 2c.i.
\r
1485 orr r5, r6, r5, lsl #16
\r
1487 stmia r0!, {r4,r5}
\r
1488 bne .fl_loopBGR444
\r
1491 ldmfd sp!, {r4-r6,lr}
\r
1495 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1498 @ hilights 2 pixels in RGB555/BGR555 format
\r
1499 .macro TileDoShHi2Pixels555 reg
\r
1500 adds \reg, \reg, #0x40000000
\r
1501 orrcs \reg, \reg, #0xf0000000
\r
1502 mov \reg, \reg, ror #27
\r
1503 adds \reg, \reg, #0x40000000
\r
1504 orrcs \reg, \reg, #0xf0000000
\r
1505 mov \reg, \reg, ror #26
\r
1506 adds \reg, \reg, #0x40000000
\r
1507 orrcs \reg, \reg, #0xf0000000
\r
1508 mov \reg, \reg, ror #27
\r
1509 adds \reg, \reg, #0x40000000
\r
1510 orrcs \reg, \reg, #0xf0000000
\r
1511 mov \reg, \reg, ror #27
\r
1512 adds \reg, \reg, #0x40000000
\r
1513 orrcs \reg, \reg, #0xf0000000
\r
1514 mov \reg, \reg, ror #26
\r
1515 adds \reg, \reg, #0x40000000
\r
1516 orrcs \reg, \reg, #0xf0000000
\r
1517 mov \reg, \reg, ror #27
\r
1521 @ Convert 0000bbb0 ggg0rrr0
\r
1522 @ to rrrrrggg gggbbbbb
\r
1524 @ r2,r3,r9 - scratch, lr = 0x001c001c, r8 = 0x00030003
\r
1525 .macro convRGB565 reg
\r
1526 and r2, lr, \reg,lsl #1
\r
1527 and r9, r8, \reg,lsr #2
\r
1528 orr r2, r2, r9 @ r2=red
\r
1529 and r3, lr, \reg,lsr #7
\r
1530 and r9, r8, \reg,lsr #10
\r
1531 orr r3, r3, r9 @ r3=blue
\r
1532 and \reg, \reg, lr, lsl #3
\r
1533 orr \reg, \reg, \reg,lsl #3 @ green
\r
1534 orr \reg, \reg, r2, lsl #11 @ add red back
\r
1535 orr \reg, \reg, r3 @ add blue back
\r
1538 .global vidConvCpyRGB565
\r
1540 vidConvCpyRGB565: @ void *to, void *from, int pixels
\r
1541 stmfd sp!, {r4-r9,lr}
\r
1543 mov r12, r2, lsr #3 @ repeats
\r
1544 mov lr, #0x001c0000
\r
1545 orr lr, lr, #0x01c @ lr == pattern 0x001c001c
\r
1546 mov r8, #0x00030000
\r
1547 orr r8, r8, #0x003
\r
1550 ldmia r1!, {r4-r7}
\r
1563 ldmfd sp!, {r4-r9,lr}
\r
1568 .global FinalizeLineRGB555 @ int sh
\r
1570 FinalizeLineRGB555:
\r
1571 stmfd sp!, {r4-r8,lr}
\r
1572 ldr r8, =(Pico+0x22228) @ Pico.video
\r
1575 ldrb r7, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1579 beq .fl_noconvRGB555
\r
1580 strb r1, [r8, #-0x1a]
\r
1581 sub r1, r8, #0x128 @ r1=Pico.cram
\r
1584 bl vidConvCpyRGB565
\r
1589 beq .fl_noshRGB555
\r
1591 beq .fl_noshRGB555
\r
1593 @ shadowed pixels:
\r
1595 orr r12,r12,#0x7300
\r
1596 orr r12,r12,r12,lsl #16
\r
1597 add r4, r3, #0x40*2
\r
1598 add r5, r3, #0xc0*2
\r
1600 .fl_loopcpRGB555_sh:
\r
1601 ldmia r3!, {r1,r6}
\r
1603 and r1, r12, r1, lsr #1
\r
1604 and r6, r12, r6, lsr #1
\r
1605 stmia r4!, {r1,r6}
\r
1606 stmia r5!, {r1,r6}
\r
1607 bne .fl_loopcpRGB555_sh
\r
1609 @ hilighted pixels:
\r
1610 sub r3, r3, #0x40*2
\r
1612 .fl_loopcpRGB555_hi:
\r
1614 TileDoShHi2Pixels555 r1
\r
1617 bne .fl_loopcpRGB555_hi
\r
1619 sub r3, r3, #0x40*2
\r
1622 .if OVERRIDE_HIGHCOL
\r
1624 ldr r0, =DrawLineDest
\r
1629 ldr r0, =DrawLineDest
\r
1630 ldr r1, =(HighCol+8)
\r
1634 ldrb r12, [r8, #12]
\r
1636 mov lr, lr, lsl #1
\r
1639 movne r2, #320/8 @ len
\r
1640 bne .fl_no32colRGB555
\r
1645 bne .fl_32scale_RGB555
\r
1647 addeq r0, r0, #32*2
\r
1649 .fl_no32colRGB555:
\r
1651 .if UNALIGNED_DRAWLINEDEST
\r
1652 @ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer
\r
1661 and r4, lr, r12, lsl #1
\r
1663 and r5, lr, r12, lsr #7
\r
1665 and r6, lr, r12, lsr #15
\r
1667 orr r4, r4, r5, lsl #16
\r
1669 and r5, lr, r12, lsr #23
\r
1671 and r8, lr, r7, lsl #1
\r
1673 orr r5, r6, r5, lsl #16
\r
1675 and r6, lr, r7, lsr #7
\r
1677 and r12,lr, r7, lsr #15
\r
1678 ldrh r12,[r3, r12]
\r
1679 and r7, lr, r7, lsr #23
\r
1681 orr r8, r8, r6, lsl #16
\r
1684 orr r12,r12, r7, lsl #16
\r
1686 stmia r0!, {r4,r5,r8,r12}
\r
1687 bne .fl_loopRGB555
\r
1689 ldmfd sp!, {r4-r8,lr}
\r
1693 .fl_32scale_RGB555:
\r
1694 stmfd sp!, {r9,r10}
\r
1695 mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1696 orr r9, r9, #0x00e7
\r
1698 .if UNALIGNED_DRAWLINEDEST
\r
1700 bne .fl_32scale_RGB555u
\r
1703 .fl_loop32scale_RGB555:
\r
1707 and r4, lr, r12,lsl #1
\r
1709 and r5, lr, r12,lsr #7
\r
1711 and r4, r4, r9, lsl #2
\r
1712 orr r4, r4, r4, lsl #14 @ r4[31:16] = 1/4 pix_s 0
\r
1713 and r5, r5, r9, lsl #2
\r
1714 sub r6, r5, r5, lsr #2 @ r6 = 3/4 pix_s 1
\r
1715 add r4, r4, r6, lsl #16 @ pix_d 0, 1
\r
1716 and r6, lr, r12,lsr #15
\r
1718 and r12,lr, r12,lsr #23
\r
1719 ldrh r12,[r3, r12]
\r
1720 and r6, r6, r9, lsl #2
\r
1722 mov r5, r5, lsr #1
\r
1723 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1724 orr r5, r5, r6, lsl #16
\r
1726 and r6, lr, r7, lsl #1
\r
1728 and r12,r12,r9, lsl #2
\r
1729 add r5, r5, r12,lsl #14 @ pix_d 2, 3
\r
1730 and r6, r6, r9, lsl #2
\r
1731 orr r6, r12,r6, lsl #16 @ pix_d 4, 5
\r
1733 and r12,lr, r7, lsr #7
\r
1734 ldrh r12,[r3, r12]
\r
1735 and r10,lr, r7, lsr #15
\r
1736 ldrh r10,[r3, r10]
\r
1737 and r12,r12,r9, lsl #2
\r
1738 sub r8, r12,r12,lsr #2 @ r8 = 3/4 pix_s 1
\r
1739 add r8, r8, r6, lsr #18
\r
1740 and r7, lr, r7, lsr #23
\r
1742 and r10,r10,r9, lsl #2
\r
1743 orr r8, r8, r10,lsl #15
\r
1744 add r8, r8, r12,lsl #15 @ pix_d 6, 7
\r
1745 sub r10,r10,r10,lsr #2 @ r10= 3/4 pix_s 2
\r
1746 and r7, r7, r9, lsl #2
\r
1747 add r10,r10,r7, lsr #2 @ += 1/4 pix_s 3
\r
1748 orr r10,r10,r7, lsl #16 @ pix_d 8, 9
\r
1752 stmia r0!, {r4,r5,r6,r8,r10}
\r
1753 bne .fl_loop32scale_RGB555
\r
1755 ldmfd sp!, {r9,r10}
\r
1756 ldmfd sp!, {r4-r8,lr}
\r
1759 .if UNALIGNED_DRAWLINEDEST
\r
1760 @ unaligned versions of loops
\r
1761 @ warning: starts drawing 2bytes before dst
\r
1764 sub r0, r0, #2 @ initial adjustment
\r
1771 and r6, lr, r12,lsl #1
\r
1773 and r5, lr, r12,lsr #7
\r
1775 orr r4, r8, r6, lsl #16
\r
1777 and r6, lr, r12,lsr #15
\r
1779 and r8, lr, r12,lsr #23
\r
1781 orr r5, r5, r6, lsl #16
\r
1783 and r6, lr, r7, lsl #1
\r
1785 and r12,lr, r7, lsr #7
\r
1786 ldrh r12,[r3, r12]
\r
1787 orr r6, r8, r6, lsl #16
\r
1789 and r8, lr, r7, lsr #15
\r
1791 and r7, lr, r7, lsr #23
\r
1794 orr r12,r12,r8, lsl #16
\r
1797 stmia r0!, {r4,r5,r6,r12}
\r
1798 bne .fl_loopRGB555u
\r
1802 ldmfd sp!, {r4-r8,lr}
\r
1806 .fl_32scale_RGB555u:
\r
1807 sub r0, r0, #2 @ initial adjustment
\r
1810 @ r9 f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1811 .fl_loop32scale_RGB555u:
\r
1815 and r6, lr, r12,lsl #1
\r
1817 and r5, lr, r12,lsr #7
\r
1819 and r6, r6, r9, lsl #2
\r
1820 orr r4, r4, r6, lsl #16 @ r4 = pix_d -1, 0
\r
1822 and r5, r5, r9, lsl #2
\r
1823 sub r8, r5, r5, lsr #2 @ r8 = 3/4 pix_s 1
\r
1824 add r6, r8, r6, lsr #2 @ r6 = (1/4 pix_s 0) + (3/4 pix_s 1)
\r
1825 orr r5, r6, r5, lsl #15
\r
1827 and r6, lr, r12,lsr #15
\r
1829 and r12,lr, r12,lsr #23
\r
1830 ldrh r12,[r3, r12]
\r
1831 and r6, r6, r9, lsl #2
\r
1832 add r5, r5, r6, lsl #15 @ r5 = pix_d 1, 2
\r
1834 and r8, lr, r7, lsl #1
\r
1836 and r10,lr, r7, lsr #7
\r
1837 ldrh r10,[r3, r10]
\r
1838 and r12,r12,r9, lsl #2
\r
1839 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1840 add r6, r6, r12,lsr #2
\r
1841 orr r6, r6, r12,lsl #16 @ r6 = pix_d 3, 4
\r
1843 and r8, r8, r9, lsl #2
\r
1844 and r10,r10,r9, lsl #2
\r
1845 sub r12,r10,r10,lsr #2 @ r12 = 3/4 pix_s 5
\r
1846 orr r8, r8, r8, lsl #14
\r
1847 add r8, r8, r12,lsl #16 @ r8 = pix_d 5, 6
\r
1848 and r12,lr, r7, lsr #15
\r
1849 ldrh r12,[r3, r12]
\r
1850 and r7, lr, r7, lsr #23
\r
1852 and r12,r12,r9, lsl #2
\r
1854 mov r10,r10, lsr #1
\r
1855 sub r12,r12,r12,lsr #2 @ r12 = 3/4 pix_s 6
\r
1856 orr r10,r10,r12,lsl #16
\r
1857 and r7, r7, r9, lsl #2
\r
1858 add r10,r10,r7, lsl #14 @ r10 = pix_d 7, 8
\r
1862 stmia r0!, {r4,r5,r6,r8,r10}
\r
1864 bne .fl_loop32scale_RGB555u
\r
1868 ldmfd sp!, {r9,r10}
\r
1869 ldmfd sp!, {r4-r8,lr}
\r
1872 .endif @ UNALIGNED_DRAWLINEDEST
\r
1875 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1878 .global blockcpy @ void *dst, void *src, size_t n
\r
1881 stmfd sp!, {r4,r5}
\r
1882 mov r2, r2, lsr #4
\r
1884 ldmia r1!, {r3-r5,r12}
\r
1886 stmia r0!, {r3-r5,r12}
\r
1888 ldmfd sp!, {r4,r5}
\r
1892 .global blockcpy_or @ void *dst, void *src, size_t n, int pat
\r
1895 stmfd sp!, {r4-r6}
\r
1896 orr r3, r3, r3, lsl #8
\r
1897 orr r3, r3, r3, lsl #16
\r
1898 mov r2, r2, lsr #4
\r
1900 ldmia r1!, {r4-r6,r12}
\r
1906 stmia r0!, {r4-r6,r12}
\r
1907 bne blockcpy_loop_or
\r
1908 ldmfd sp!, {r4-r6}
\r