1 @ vim:filetype=armasm
\r
3 @ ARM assembly versions of some funtions from draw.c
\r
4 @ this is highly specialized, be careful if changing related C code!
\r
6 @ (c) Copyright 2007-2008, Grazvydas "notaz" Ignotas
\r
7 @ All Rights Reserved
\r
9 .include "port_config.s"
\r
14 .extern DrawScanline
\r
18 .extern DrawLineDest
\r
19 .extern DrawStripInterlace
\r
20 .extern HighCacheS_ptr
\r
22 .equ PDRAW_SPRITES_MOVED, (1<<0)
\r
23 .equ PDRAW_WND_DIFF_PRIO, (1<<1)
\r
24 .equ PDRAW_ACC_SPRITES, (1<<2)
\r
25 .equ PDRAW_DIRTY_SPRITES, (1<<4)
\r
26 .equ PDRAW_PLANE_HI_PRIO, (1<<6)
\r
27 .equ PDRAW_SHHI_DONE, (1<<7)
\r
30 .macro TilePixel pat lsrr offs
\r
34 ands r4, \pat, r2, lsr #\lsrr
\r
37 strneb r4, [r1,#\offs]
\r
40 @ TileNorm (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
42 TilePixel \pat, 12, 0 @ #0x0000f000
\r
43 TilePixel \pat, 8, 1 @ #0x00000f00
\r
44 TilePixel \pat, 4, 2 @ #0x000000f0
\r
45 TilePixel \pat, 0, 3 @ #0x0000000f
\r
46 TilePixel \pat, 28, 4 @ #0xf0000000
\r
47 TilePixel \pat, 24, 5 @ #0x0f000000
\r
48 TilePixel \pat, 20, 6 @ #0x00f00000
\r
49 TilePixel \pat, 16, 7 @ #0x000f0000
\r
52 @ TileFlip (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
54 TilePixel \pat, 16, 0 @ #0x000f0000
\r
55 TilePixel \pat, 20, 1 @ #0x00f00000
\r
56 TilePixel \pat, 24, 2 @ #0x0f000000
\r
57 TilePixel \pat, 28, 3 @ #0xf0000000
\r
58 TilePixel \pat, 0, 4 @ #0x0000000f
\r
59 TilePixel \pat, 4, 5 @ #0x000000f0
\r
60 TilePixel \pat, 8, 6 @ #0x00000f00
\r
61 TilePixel \pat, 12, 7 @ #0x0000f000
\r
64 @ shadow/hilight mode
\r
66 @ this one is for hi priority layer
\r
67 .macro TilePixelShHP lsrr offs
\r
71 ands r4, r12, r2, lsr #\lsrr
\r
73 ldreqb r4, [r1,#\offs]
\r
76 strb r4, [r1,#\offs]
\r
79 @ TileNormShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: register with helper pattern 0xf, touches r3 high bits
\r
81 TilePixelShHP 12, 0 @ #0x0000f000
\r
82 TilePixelShHP 8, 1 @ #0x00000f00
\r
83 TilePixelShHP 4, 2 @ #0x000000f0
\r
84 TilePixelShHP 0, 3 @ #0x0000000f
\r
85 TilePixelShHP 28, 4 @ #0xf0000000
\r
86 TilePixelShHP 24, 5 @ #0x0f000000
\r
87 TilePixelShHP 20, 6 @ #0x00f00000
\r
88 TilePixelShHP 16, 7 @ #0x000f0000
\r
91 @ TileFlipShHP (r1=pdest, r2=pixels8, r3=pal) r4: scratch, pat: register with helper pattern 0xf
\r
93 TilePixelShHP 16, 0 @ #0x000f0000
\r
94 TilePixelShHP 20, 1 @ #0x00f00000
\r
95 TilePixelShHP 24, 2 @ #0x0f000000
\r
96 TilePixelShHP 28, 3 @ #0xf0000000
\r
97 TilePixelShHP 0, 4 @ #0x0000000f
\r
98 TilePixelShHP 4, 5 @ #0x000000f0
\r
99 TilePixelShHP 8, 6 @ #0x00000f00
\r
100 TilePixelShHP 12, 7 @ #0x0000f000
\r
104 @ TileSingleSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx; r12: helper pattern 0xf
\r
105 .macro TileSingleSh
\r
106 tst r0, #1 @ not aligned?
\r
112 strneb r4, [r1], #1
\r
113 streqh r4, [r1], #2
\r
125 strneb r4, [r1], #1
\r
128 @ TileSingleHi (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
129 .macro TileSingleHi
\r
130 tst r1, #1 @ not aligned?
\r
133 ldrneb r4, [r1], #1
\r
134 ldreqh r4, [r1], #2 @ 1ci
\r
136 bic r4, r4, r7, lsr #1
\r
138 strneb r4, [r1, #-3]
\r
139 streqh r4, [r1, #-4]
\r
141 bic r12, r12, r7, lsr #1
\r
143 strh r12, [r1, #-4]
\r
145 bic r4, r4, r7, lsr #1
\r
149 bic r12, r12, r7, lsr #1
\r
151 strh r12, [r1, #-2]
\r
152 bicne r4, r4, r7, lsr #1
\r
154 strneb r4, [r1], #1
\r
158 .macro TileDoShGenPixel shift ofs
\r
160 ands r4, r12, r2, lsr #\shift
\r
166 ldrgeb r4, [r1,#\ofs]
\r
167 orrlt r4, r3, r4 @ normal
\r
169 biceq r4, r4, #0xc0 @ hilight
\r
170 orreq r4, r4, #0x80
\r
171 orrgt r4, r4, #0xc0 @ shadow
\r
173 strb r4, [r1,#\ofs]
\r
177 @ TileFlipSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
179 TileDoShGenPixel 16, 0 @ #0x000f0000
\r
180 TileDoShGenPixel 20, 1 @ #0x00f00000
\r
181 TileDoShGenPixel 24, 2 @ #0x0f000000
\r
182 TileDoShGenPixel 28, 3 @ #0xf0000000
\r
183 TileDoShGenPixel 0, 4 @ #0x0000000f
\r
184 TileDoShGenPixel 4, 5 @ #0x000000f0
\r
185 TileDoShGenPixel 8, 6 @ #0x00000f00
\r
186 TileDoShGenPixel 12, 7 @ #0x0000f000
\r
189 @ TileNormSh (r1=pdest, r2=pixels8, r3=pal) r4,r7: scratch, r0=sx, r12: register with helper pattern 0xf
\r
191 TileDoShGenPixel 12, 0 @ #0x0000f000
\r
192 TileDoShGenPixel 8, 1 @ #0x00000f00
\r
193 TileDoShGenPixel 4, 2 @ #0x000000f0
\r
194 TileDoShGenPixel 0, 3 @ #0x0000000f
\r
195 TileDoShGenPixel 28, 4 @ #0xf0000000
\r
196 TileDoShGenPixel 24, 5 @ #0x0f000000
\r
197 TileDoShGenPixel 20, 6 @ #0x00f00000
\r
198 TileDoShGenPixel 16, 7 @ #0x000f0000
\r
201 .macro TileDoShGenPixel_noop shift ofs
\r
203 and r4, r12, r2, lsr #\shift
\r
209 orrcc r4, r3, r4 @ 0-0xc (was 1-0xd)
\r
210 strccb r4, [r1,#\ofs]
\r
213 .macro TileFlipSh_noop
\r
214 TileDoShGenPixel_noop 16, 0 @ #0x000f0000
\r
215 TileDoShGenPixel_noop 20, 1 @ #0x00f00000
\r
216 TileDoShGenPixel_noop 24, 2 @ #0x0f000000
\r
217 TileDoShGenPixel_noop 28, 3 @ #0xf0000000
\r
218 TileDoShGenPixel_noop 0, 4 @ #0x0000000f
\r
219 TileDoShGenPixel_noop 4, 5 @ #0x000000f0
\r
220 TileDoShGenPixel_noop 8, 6 @ #0x00000f00
\r
221 TileDoShGenPixel_noop 12, 7 @ #0x0000f000
\r
224 .macro TileNormSh_noop
\r
225 TileDoShGenPixel_noop 12, 0 @ #0x0000f000
\r
226 TileDoShGenPixel_noop 8, 1 @ #0x00000f00
\r
227 TileDoShGenPixel_noop 4, 2 @ #0x000000f0
\r
228 TileDoShGenPixel_noop 0, 3 @ #0x0000000f
\r
229 TileDoShGenPixel_noop 28, 4 @ #0xf0000000
\r
230 TileDoShGenPixel_noop 24, 5 @ #0x0f000000
\r
231 TileDoShGenPixel_noop 20, 6 @ #0x00f00000
\r
232 TileDoShGenPixel_noop 16, 7 @ #0x000f0000
\r
235 .macro TileDoShGenPixel_onlyop_lp shift ofs
\r
237 ands r7, r12, r2, lsr #\shift
\r
241 ldrneb r4, [r1,#\ofs]
\r
246 biceq r4, r4, #0xc0 @ hilight
\r
247 orreq r4, r4, #0x80
\r
248 orrgt r4, r4, #0xc0 @ shadow
\r
249 strgeb r4, [r1,#\ofs]
\r
253 .macro TileFlipSh_onlyop_lp
\r
254 TileDoShGenPixel_onlyop_lp 16, 0 @ #0x000f0000
\r
255 TileDoShGenPixel_onlyop_lp 20, 1 @ #0x00f00000
\r
256 TileDoShGenPixel_onlyop_lp 24, 2 @ #0x0f000000
\r
257 TileDoShGenPixel_onlyop_lp 28, 3 @ #0xf0000000
\r
258 TileDoShGenPixel_onlyop_lp 0, 4 @ #0x0000000f
\r
259 TileDoShGenPixel_onlyop_lp 4, 5 @ #0x000000f0
\r
260 TileDoShGenPixel_onlyop_lp 8, 6 @ #0x00000f00
\r
261 TileDoShGenPixel_onlyop_lp 12, 7 @ #0x0000f000
\r
264 .macro TileNormSh_onlyop_lp
\r
265 TileDoShGenPixel_onlyop_lp 12, 0 @ #0x0000f000
\r
266 TileDoShGenPixel_onlyop_lp 8, 1 @ #0x00000f00
\r
267 TileDoShGenPixel_onlyop_lp 4, 2 @ #0x000000f0
\r
268 TileDoShGenPixel_onlyop_lp 0, 3 @ #0x0000000f
\r
269 TileDoShGenPixel_onlyop_lp 28, 4 @ #0xf0000000
\r
270 TileDoShGenPixel_onlyop_lp 24, 5 @ #0x0f000000
\r
271 TileDoShGenPixel_onlyop_lp 20, 6 @ #0x00f00000
\r
272 TileDoShGenPixel_onlyop_lp 16, 7 @ #0x000f0000
\r
276 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
280 @ int nametab; // 0x00
\r
281 @ int line; // 0x04
\r
282 @ int hscroll; // 0x08
\r
283 @ int xmask; // 0x0C
\r
284 @ int *hc; // 0x10 (pointer to cache buffer)
\r
285 @ int cells; // 0x14
\r
288 @ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
\r
293 stmfd sp!, {r4-r11,lr}
\r
295 ldr r11, =(Pico+0x22228) @ Pico.video
\r
298 ldrb r7, [r11, #16] @ ??vv??hh
\r
300 mov r6, r1 @ hcache
\r
301 orr r9, r3, r0, lsl #30
\r
302 orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp)
\r
305 orr r1, r1, #0x00ff
\r
309 biclt r1, r1, #0xfc00
\r
310 biceq r1, r1, #0xfe00
\r
311 bicgt r1, r1, #0xff00 @ r1=ymask=(height<<8)|0xff; ...; // Y Mask in pixels
\r
315 subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)
\r
318 mov r5, r8, lsl r10
\r
319 sub r5, r5, #1 @ r5=xmask
\r
323 ldreqb r12, [r11, #2]
\r
324 ldrneb r12, [r11, #4]
\r
326 ldr r2, =DrawScanline @ trying to make good use of pipeline here
\r
327 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
329 moveq r12, r12, lsl #10
\r
330 movne r12, r12, lsl #13
\r
331 and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
\r
333 ldrh r8, [r11, #12]
\r
334 ldrb r7, [r11, #11]
\r
337 mov r4, r8, lsr #8 @ pvid->reg[13]
\r
338 mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
\r
340 addne r4, r4, r2, lsl #2 @ htab+=DrawScanline<<1; // Offset by line
\r
342 biceq r4, r4, #0x1f @ htab&=~0xf; // Offset by tile
\r
343 add r4, r4, r0, lsl #1 @ htab+=plane
\r
344 bic r4, r4, #0x00ff0000 @ just in case
\r
345 ldrh r3, [lr, r4] @ r3=hscroll
\r
348 bne .DrawStrip_vsscroll
\r
350 @ Get vertical scroll value:
\r
351 add r7, lr, #0x012000
\r
352 add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
\r
357 bne .DrawStrip_interlace
\r
360 movne r7, r7, lsr #16
\r
362 @ Find the line in the name table
\r
366 add r10, r10, #1 @ shift[width]++
\r
367 add r12, r12, r4, lsl r10 @ nametab+=(ts.line>>3)<<shift[width];
\r
369 @ ldmia r0, {r1,r2,r3,r5,r6,r9} @ r2=line, r3=ts->hscroll, r5=ts->xmask, r6=ts->hc, r9=ts->cells
\r
372 mov r10,r10, lsl #1 @ r10=ty=(ts->line&7)<<1;
\r
373 orr r10,r10, r9, lsl #24
\r
376 mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
\r
380 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
\r
384 orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty)
\r
385 movne r3, #0x40 @ default to shadowed pal on sh mode
\r
388 addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll
\r
390 and r9, r9, #0xff00
\r
391 add r8, r8, r9, lsr #8 @ tilex+=cellskip
\r
392 add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
\r
393 sub r10,r10,r9, lsl #16 @ cells-=cellskip
\r
395 @ cache some stuff to avoid mem access
\r
396 .if OVERRIDE_HIGHCOL
\r
405 mvn r9, #0 @ r9=prevcode=-1
\r
406 add r1, r11, r7 @ r1=pdest
\r
409 @ r4 & r7 are scratch in this loop
\r
412 .dsloop: @ 40-41 times
\r
413 subs r10,r10, #0x01000000
\r
418 add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
\r
419 ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
425 bne .DrawStrip_hiprio
\r
428 beq .DrawStrip_samecode @ we know stuff about this tile already
\r
430 mov r9, r7 @ remember code
\r
431 orr r10, r10, #1<<21 @ seen non hi-prio tile
\r
433 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
435 add r2, r2, r10, lsl #17
\r
436 mov r2, r2, lsr #17
\r
437 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
439 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
442 and r3, r9, #0x6000
\r
443 add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
445 .DrawStrip_samecode:
\r
447 beq .dsloop @ tileline blank
\r
450 beq .DrawStrip_SingleColor @ tileline singlecolor
\r
453 bne .DrawStrip_TileFlip
\r
455 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
456 .DrawStrip_TileNorm:
\r
460 .DrawStrip_TileFlip:
\r
464 .DrawStrip_SingleColor:
\r
467 orr r4, r4, r4, lsl #8
\r
468 tst r1, #1 @ not aligned?
\r
469 strneb r4, [r1], #1
\r
470 streqh r4, [r1], #2
\r
474 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
477 .DrawStrip_hiprio_maybempt:
\r
479 beq .dsloop @ must've been empty, otherwise we wouldn't get here
\r
480 movs r2, r7, lsl #20 @ if (code&0x1000)
\r
482 add r2, r2, r10, lsl #17
\r
483 mov r2, r2, lsr #17
\r
484 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
485 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
486 mov r9, r7 @ remember code
\r
489 orr r10, r10, #1<<22
\r
492 tst r10, #0x00c00000
\r
493 beq .DrawStrip_hiprio_maybempt
\r
495 orr r7, r7, r0, lsl #16
\r
496 orr r7, r7, r10, lsl #25 @ (ty<<25)
\r
498 eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
\r
499 str r7, [r6], #4 @ cache hi priority tile
\r
504 tst r10, #1<<21 @ seen non hi-prio tile
\r
505 ldreq r1, =rendstatus
\r
508 str r0, [r6] @ terminate the cache list
\r
509 orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
\r
512 ldmfd sp!, {r4-r11,lr}
\r
515 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
517 .DrawStrip_vsscroll:
\r
519 mov r8, r8, lsr #3 @ r8=tilex=(-ts->hscroll)>>3
\r
520 bic r8, r8, #0x3fc00000
\r
521 orr r8, r8, r5, lsl #25 @ r8=(xmask[31:25]|had_output[24]|tilex[21:0])
\r
523 ldr r4, =DrawScanline
\r
524 orr r5, r1, r10, lsl #24
\r
527 orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
\r
529 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
\r
531 mov r10,r9, lsl #16
\r
533 orrne r10,r10, #0x8000
\r
536 orr r10,r10, #0xff000000 @ will be adjusted on entering loop
\r
537 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
538 movne r3, #0x40 @ default to shadowed pal on sh mode
\r
541 subne r10,r10, #0x01000000 @ have hscroll, start with negative cell
\r
543 and r9, r9, #0xff00
\r
544 add r8, r8, r9, lsr #8 @ tilex+=cellskip
\r
545 add r7, r7, r9, lsr #5 @ dx+=cellskip<<3;
\r
546 add r10,r10,r9, lsl #16 @ cell+=cellskip
\r
548 @ cache some stuff to avoid mem access
\r
549 .if OVERRIDE_HIGHCOL
\r
558 mvn r9, #0 @ r9=prevcode=-1
\r
559 add r1, r11, r7 @ r1=pdest
\r
561 @ r4 & r7 are scratch in this loop
\r
564 .dsloop_vs: @ 40-41 times
\r
565 add r10,r10, #0x01000000
\r
566 and r4, r10, #0x003f0000
\r
567 cmp r4, r10, asr #8
\r
568 ble .dsloop_vs_exit
\r
570 @ calc offset and read tileline code to r7, also calc ty
\r
571 add r7, lr, #0x012000
\r
572 add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
\r
573 add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
\r
575 tst r10,#0x8000 @ plane1?
\r
577 ldrh r7, [r7] @ r7=vscroll
\r
579 bic r10,r10,#0xff @ clear old ty
\r
580 and r4, r5, #0xff0000 @ scanline
\r
581 add r4, r4, r7, lsl #16 @ ... += vscroll
\r
582 and r4, r4, r5, lsl #16 @ ... &= ymask
\r
583 and r7, r4, #0x70000
\r
584 orr r10,r10,r7, lsr #15 @ new ty
\r
586 mov r4, r4, lsr #19
\r
587 mov r7, r5, lsr #24
\r
588 mov r4, r4, lsl r7 @ nametabadd
\r
590 and r7, r8, r8, lsr #25
\r
591 add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
\r
592 add r7, r7, r4, lsl #1
\r
593 ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
599 bne .DrawStrip_vs_hiprio
\r
602 beq .DrawStrip_vs_samecode @ we know stuff about this tile already
\r
604 mov r9, r7 @ remember code
\r
605 orr r8, r8, #(1<<24)@ seen non hi-prio tile
\r
607 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
609 add r2, r2, r10, lsl #17
\r
610 mov r2, r2, lsr #17
\r
611 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
613 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
616 and r3, r9, #0x6000
\r
617 add r3, r7, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
619 .DrawStrip_vs_samecode:
\r
621 beq .dsloop_vs @ tileline blank
\r
624 beq .DrawStrip_vs_SingleColor @ tileline singlecolor
\r
627 bne .DrawStrip_vs_TileFlip
\r
629 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
630 .DrawStrip_vs_TileNorm:
\r
634 .DrawStrip_vs_TileFlip:
\r
638 .DrawStrip_vs_SingleColor:
\r
641 orr r4, r4, r4, lsl #8
\r
642 tst r1, #1 @ not aligned?
\r
643 strneb r4, [r1], #1
\r
644 streqh r4, [r1], #2
\r
648 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
651 .DrawStrip_vs_hiprio:
\r
652 tst r10, #0x00c00000
\r
653 beq .DrawStrip_vs_hiprio_maybempt
\r
655 orr r7, r7, r0, lsl #16
\r
656 orr r7, r7, r10, lsl #25 @ (ty<<25)
\r
658 eorne r7, r7, #7<<26 @ if(code&0x1000) cval^=7<<26;
\r
659 str r7, [r6], #4 @ cache hi priority tile
\r
663 .DrawStrip_vs_hiprio_maybempt:
\r
665 beq .dsloop_vs @ must've been empty, otherwise we wouldn't get here
\r
666 movs r2, r7, lsl #20 @ if (code&0x1000)
\r
668 add r2, r2, r10, lsl #17
\r
669 mov r2, r2, lsr #17
\r
670 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
671 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
672 mov r9, r7 @ remember code
\r
674 orrne r10, r10, #1<<22
\r
675 bne .DrawStrip_vs_hiprio
\r
679 tst r8, #(1<<24) @ seen non hi-prio tile
\r
680 ldreq r1, =rendstatus
\r
683 str r0, [r6] @ terminate the cache list
\r
684 orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
\r
687 ldmfd sp!, {r4-r11,lr}
\r
691 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
693 @ interlace mode 2? Sonic 2?
\r
694 .DrawStrip_interlace:
\r
696 moveq r7, r7, lsl #21
\r
697 movne r7, r7, lsl #5
\r
699 @ Find the line in the name table
\r
700 add r2, r7, r2, lsl #22 @ r2=(vscroll+(DrawScanline<<1))<<21 (11 bits);
\r
701 orr r1, r1, #0x80000000
\r
702 and r2, r2, r1, ror #10 @ &((ymask<<1)|1)<<21;
\r
703 mov r2, r2, lsr #21
\r
705 mov r12, r12, lsr #1 @ halfwords
\r
706 add r0, r12, r4, lsl r10 @ nametab+=(ts.line>>4)<<shift[width];
\r
710 stmia sp, {r0,r2,r3,r5,r6,r9}
\r
713 bl DrawStripInterlace @ struct TileStrip *ts
\r
716 ldmfd sp!, {r4-r11,lr}
\r
721 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
724 .global BackFill @ int reg7, int sh
\r
727 stmfd sp!, {r4-r9,lr}
\r
729 .if OVERRIDE_HIGHCOL
\r
731 mov r0, r0, lsl #26
\r
733 mov r0, r0, lsr #26
\r
736 ldr lr, =(HighCol+8)
\r
737 mov r0, r0, lsl #26
\r
738 mov r0, r0, lsr #26
\r
741 orr r0, r0, r1, lsl #6
\r
742 orr r0, r0, r0, lsl #8
\r
743 orr r0, r0, r0, lsl #16
\r
754 stmia lr!, {r0-r7} @ 10*8*4
\r
765 ldmfd sp!, {r4-r9,r12}
\r
769 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
772 .global DrawTilesFromCache @ int *hc, int sh, int rlim
\r
774 DrawTilesFromCache:
\r
775 stmfd sp!, {r4-r8,r11,lr}
\r
777 @ cache some stuff to avoid mem access
\r
778 .if OVERRIDE_HIGHCOL
\r
786 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
788 mvn r5, #0 @ r5=prevcode=-1
\r
790 orr r8, r8, r2, lsl #1
\r
791 bne .dtfc_check_rendflags
\r
795 ldr r6, [r0], #4 @ read code
\r
796 movs r1, r6, lsr #16 @ r1=dx;
\r
797 ldmeqfd sp!, {r4-r8,r11,pc} @ dx is never zero, this must be a terminator, return
\r
798 bic r4, r1, #0xfe00
\r
799 add r1, r11, r4 @ r1=pdest
\r
801 mov r7, r6, lsl #16
\r
802 cmp r5, r7, lsr #16
\r
803 beq .dtfc_samecode @ if (code==prevcode)
\r
805 mov r5, r7, lsr #16
\r
807 mov r2, r5, lsl #21
\r
808 mov r2, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4;
\r
809 add r2, r2, r6, lsr #25 @ addr+=ty
\r
811 and r3, r5, #0x6000
\r
812 mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
814 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
817 rsbs r4, r4, r8, lsr #1
\r
827 beq .dtfc_SingleColor @ tileline singlecolor
\r
832 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
844 orr r4, r4, r4, lsl #8
\r
845 tst r1, #1 @ not aligned?
\r
846 strneb r4, [r1], #1
\r
847 streqh r4, [r1], #2
\r
851 strneb r4, [r1], #1 @ have a remaining unaligned pixel?
\r
856 beq .dtfc_shadow_blank
\r
859 beq .dtfc_SingleColor @ tileline singlecolor
\r
862 bne .dtfc_TileFlipShHP
\r
864 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
865 .dtfc_TileNormShHP:
\r
869 .dtfc_TileFlipShHP:
\r
873 .dtfc_shadow_blank:
\r
878 strneb r4, [r1], #1
\r
880 orr r6, r6, r6, lsl #8
\r
896 add r4, r4, #7 @ 0-6
\r
900 mov r2, r2, ror #16
\r
901 tst r5, #0x0800 @ flipped?
\r
904 mov r2, r2, ror #16
\r
914 @ check if we have detected layer covered with hi-prio tiles:
\r
915 .dtfc_check_rendflags:
\r
916 ldr r1, =rendstatus
\r
918 tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)
\r
920 bic r8, r8, #1 @ sh/hi mode off
\r
921 tst r2, #PDRAW_SHHI_DONE
\r
922 bne .dtfc_loop @ already processed
\r
923 orr r2, r2, #PDRAW_SHHI_DONE
\r
929 orr r6, r6, r6, lsl #8
\r
930 orr r6, r6, r6, lsl #16
\r
932 ldmia r1, {r2,r4,r5,r7}
\r
938 stmia r1!,{r2,r4,r5,r7}
\r
939 bne .dtfc_loop_shprep
\r
941 mvn r5, #0 @ r5=prevcode=-1
\r
946 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
949 .global DrawSpritesSHi @ unsigned char *sprited
\r
957 stmfd sp!, {r4-r11,lr}
\r
958 strb r12,[r0,#2] @ set end marker
\r
959 add r10,r0, #3 @ r10=HighLnSpr end
\r
960 add r10,r10,r3 @ r10=HighLnSpr end
\r
962 .if OVERRIDE_HIGHCOL
\r
970 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
975 ldrb r0, [r10,#-1]!
\r
976 ldr r1, =HighPreSpr
\r
977 @ ldr r8, [sp, #-4]
\r
979 ldmeqfd sp!, {r4-r11,pc} @ end of list
\r
981 add r0, r1, r0, lsl #3
\r
983 ldr r9, [r0, #4] @ sprite[1]
\r
984 mov r2, r9, asr #16 @ r2=sx
\r
986 mov r9, r9, lsl #16
\r
987 mov r3, r9, lsr #31 @ priority
\r
988 mov r9, r9, lsr #16
\r
989 @ orr r9, r9, r8, lsl #31 @ r9=code|sh[31] @@ sh is always on here now
\r
990 and r4, r9, #0x6000
\r
991 orr r9, r9, r4, lsl #16
\r
992 orr r9, r9, #0x90000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
\r
993 cmp r12,r9, lsr #28 @ sh/hi with pal3?
\r
994 cmpne r3, #1 @ if not, is ir hi prio?
\r
995 bne DrawSpriteSHi @ non-operator low sprite, already drawn
\r
997 ldr r3, [r0] @ sprite[0]
\r
998 ldr r7, =DrawScanline
\r
999 mov r6, r3, lsr #28
\r
1000 sub r6, r6, #1 @ r6=width-1 (inc later)
\r
1001 mov r5, r3, lsr #24
\r
1002 and r5, r5, #7 @ r5=height
\r
1004 mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)
\r
1007 sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy
\r
1010 movne r0, r5, lsl #3
\r
1012 subne r7, r0, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
\r
1014 add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
\r
1016 mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
\r
1017 rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
\r
1019 mov r8, r8, lsl #21
\r
1020 mov r8, r8, lsr #17
\r
1022 add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
\r
1024 mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
\r
1025 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
\r
1027 add r6, r6, #1 @ inc now
\r
1028 adds r0, r2, #0 @ mov sx to r0 and set ZV flags
\r
1029 b .dsprShi_loop_enter
\r
1032 subs r6, r6, #1 @ width--
\r
1034 adds r0, r0, #8 @ sx+=8
\r
1035 add r8, r8, r5 @ tile+=delta
\r
1037 .dsprShi_loop_enter:
\r
1038 ble .dsprShi_loop @ sx <= 0
\r
1042 mov r8, r8, lsl #17
\r
1043 mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
\r
1045 ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1046 add r1, r11, r0 @ r1=pdest
\r
1050 cmp r12, r9, lsr #28
\r
1051 beq .dsprShi_shadow
\r
1053 cmp r2, r2, ror #4
\r
1054 beq .dsprShi_SingleColor @ tileline singlecolor
\r
1057 bne .dsprShi_TileFlip
\r
1059 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1061 .dsprShi_TileNorm:
\r
1065 .dsprShi_TileFlip:
\r
1069 .dsprShi_SingleColor:
\r
1072 orr r4, r4, r4, lsl #8
\r
1073 tst r0, #1 @ not aligned?
\r
1074 strneb r4, [r1], #1
\r
1075 streqh r4, [r1], #2
\r
1079 strneb r4, [r1], #1
\r
1084 beq .dsprShi_shadow_lowpri
\r
1086 cmp r2, r2, ror #4
\r
1087 beq .dsprShi_singlec_sh
\r
1090 bne .dsprShi_TileFlip_sh
\r
1092 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1093 .dsprShi_TileNorm_sh:
\r
1097 .dsprShi_TileFlip_sh:
\r
1101 .dsprShi_singlec_sh:
\r
1102 cmp r2, #0xe0000000
\r
1103 bcc .dsprShi_SingleColor @ normal singlecolor tileline (carry inverted in ARM)
\r
1104 tst r2, #0x10000000
\r
1105 bne .dsprShi_sh_sh
\r
1113 .dsprShi_shadow_lowpri:
\r
1115 bne .dsprShi_TileFlip_sh_lp
\r
1117 .dsprShi_TileNorm_sh_lp:
\r
1118 TileNormSh_onlyop_lp
\r
1121 .dsprShi_TileFlip_sh_lp:
\r
1122 TileFlipSh_onlyop_lp
\r
1127 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1129 .global DrawAllSprites @ unsigned char *sprited, int prio, int sh
\r
1132 ldr r3, =rendstatus
\r
1133 orr r1, r2, r1, lsl #1
\r
1135 tst r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
\r
1137 stmfd sp!, {r0,r1,lr}
\r
1138 and r0, r12,#PDRAW_DIRTY_SPRITES
\r
1139 bic r12,r12,#(PDRAW_DIRTY_SPRITES|PDRAW_SPRITES_MOVED)
\r
1142 ldmfd sp!, {r0,r1,lr}
\r
1146 ands r3, r3, #0x7f
\r
1149 @ time to do some real work
\r
1150 stmfd sp!, {r4-r11,lr}
\r
1152 strb r12,[r0,#2] @ set end marker
\r
1154 add r10,r10,r3 @ r10=HighLnSpr end
\r
1156 str r1, [sp, #-4] @ no calls after this point
\r
1158 .if OVERRIDE_HIGHCOL
\r
1166 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1168 @ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size
\r
1169 @ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
\r
1171 DrawSprite: @ was: unsigned int *sprite, int sh, int acc_sprites
\r
1172 @ draw next sprite
\r
1173 ldrb r0, [r10,#-1]!
\r
1174 ldr r1, =HighPreSpr
\r
1176 mov r2, r0, lsr #7
\r
1178 ldmeqfd sp!, {r4-r11,pc} @ end of list
\r
1179 cmp r2, r8, lsr #1
\r
1180 bne DrawSprite @ wrong priority
\r
1182 add r0, r1, r0, lsl #3
\r
1184 @ stmfd sp!, {r4-r9,r11,lr}
\r
1185 @ orr r8, r2, r1, lsl #4
\r
1187 ldr r3, [r0] @ sprite[0]
\r
1188 ldr r7, =DrawScanline
\r
1189 mov r6, r3, lsr #28
\r
1190 sub r6, r6, #1 @ r6=width-1 (inc later)
\r
1191 mov r5, r3, lsr #24
\r
1192 and r5, r5, #7 @ r5=height
\r
1194 mov r4, r3, lsl #16 @ r4=sy<<16 (tmp)
\r
1198 sub r7, r7, r4, asr #16 @ r7=row=DrawScanline-sy
\r
1200 mov r2, r9, asr #16 @ r2=sx
\r
1201 mov r9, r9, lsl #16
\r
1202 mov r9, r9, lsr #16
\r
1203 orr r9, r9, r8, lsl #31 @ r9=code|sh[31]
\r
1206 movne r4, r5, lsl #3
\r
1208 subne r7, r4, r7 @ if (code&0x1000) row=(height<<3)-1-row; // Flip Y
\r
1210 add r8, r9, r7, lsr #3 @ tile+=row>>3; // Tile number increases going down
\r
1212 mlane r8, r5, r6, r8 @ if (code&0x0800) { tile+=delta*(width-1);
\r
1213 rsbne r5, r5, #0 @ delta=-delta; } // r5=delta now
\r
1215 mov r8, r8, lsl #21
\r
1216 mov r8, r8, lsr #17
\r
1218 add r8, r8, r7, lsl #1 @ tile+=(row&7)<<1; // Tile address
\r
1221 @ cache some stuff to avoid mem access
\r
1222 mov r5, r5, lsl #4 @ delta<<=4; // Delta of address
\r
1223 and r4, r9, #0x6000
\r
1224 orr r9, r9, r4, lsl #16
\r
1225 orrs r9, r9, #0x10000000 @ r9=scc1 ???? ... <code> (s=shadow/hilight, cc=pal)
\r
1227 mov r3, r4, lsr #9 @ r3=pal=((code>>9)&0x30);
\r
1228 orrmi r3, r3, #0x40 @ for sh/hi
\r
1230 add r6, r6, #1 @ inc now
\r
1231 adds r0, r2, #0 @ mov sx to r0 and set ZV flags
\r
1232 b .dspr_loop_enter
\r
1235 subs r6, r6, #1 @ width--
\r
1237 adds r0, r0, #8 @ sx+=8
\r
1238 add r8, r8, r5 @ tile+=delta
\r
1241 ble .dspr_loop @ sx <= 0
\r
1245 mov r8, r8, lsl #17
\r
1246 mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
\r
1248 ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1249 add r1, r11, r0 @ r1=pdest
\r
1253 cmp r12, r9, lsr #28
\r
1256 cmp r2, r2, ror #4
\r
1257 beq .dspr_SingleColor @ tileline singlecolor
\r
1260 bne .dspr_TileFlip
\r
1262 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1273 cmp r2, #0xe0000000
\r
1274 bcs .dspr_loop @ operator tileline, ignore
\r
1276 .dspr_SingleColor:
\r
1279 orr r4, r4, r4, lsl #8
\r
1280 tst r0, #1 @ not aligned?
\r
1281 strneb r4, [r1], #1
\r
1282 streqh r4, [r1], #2
\r
1286 strneb r4, [r1], #1
\r
1290 cmp r2, r2, ror #4
\r
1291 beq .dspr_singlec_sh
\r
1294 bne .dspr_TileFlip_sh
\r
1296 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r12: helper pattern
\r
1297 .dspr_TileNorm_sh:
\r
1301 .dspr_TileFlip_sh:
\r
1306 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1308 .global DrawWindow @ int tstart, int tend, int prio, int sh // int *hcache
\r
1311 stmfd sp!, {r4-r11,lr}
\r
1313 ldr r11, =(Pico+0x22228) @ Pico.video
\r
1314 ldr r10, =DrawScanline
\r
1315 ldrb r12, [r11, #3] @ pvid->reg[3]
\r
1318 ldr r4, [r11, #12]
\r
1319 mov r5, r10, lsr #3
\r
1321 mov r10, r10, lsl #1 @ r10=ty
\r
1323 mov r12, r12, lsl #10
\r
1325 tst r4, #1 @ 40 cell mode?
\r
1326 andne r12, r12, #0xf000 @ 0x3c<<10
\r
1327 andeq r12, r12, #0xf800
\r
1328 addne r12, r12, r5, lsl #7
\r
1329 addeq r12, r12, r5, lsl #6 @ nametab
\r
1330 add r12, r12, r0, lsl #2 @ +starttile
\r
1332 ldr r6, =rendstatus
\r
1333 ldr lr, =(Pico+0x10000) @ lr=Pico.vram
\r
1336 @ fetch the first code now
\r
1337 ldrh r7, [lr, r12]
\r
1339 ands r6, r6, #PDRAW_WND_DIFF_PRIO
\r
1342 eoreq r8, r2, r7, lsr #15 @ do prio bits differ?
\r
1344 ldmeqfd sp!, {r4-r11,pc} @ yes, assume that whole window uses same priority
\r
1346 orr r6, r6, r3, lsl #8 @ shadow mode
\r
1350 @ cache some stuff to avoid mem access
\r
1351 .if OVERRIDE_HIGHCOL
\r
1353 mov r8, r8, lsl #1 @ cells
\r
1355 mvn r9, #0 @ r9=prevcode=-1
\r
1358 ldr r11,=(HighCol+8)
\r
1359 mov r8, r8, lsl #1 @ cells
\r
1360 mvn r9, #0 @ r9=prevcode=-1
\r
1362 add r1, r11, r0, lsl #4 @ r1=pdest
\r
1366 @ r4,r5 are scratch in this loop
\r
1370 add r12, r12, #2 @ halfwords
\r
1371 ldrh r7, [lr, r12] @ r7=code (int, but from unsigned, no sign extend)
\r
1373 beq .dwloop_end @ done
\r
1375 eor r5, r6, r7, lsr #15
\r
1377 orrne r6, r6, #2 @ wrong pri
\r
1381 beq .dw_samecode @ we know stuff about this tile already
\r
1384 mov r9, r7 @ remember code
\r
1386 movs r2, r9, lsl #20 @ if (code&0x1000)
\r
1387 mov r2, r2, lsl #1
\r
1388 add r2, r10, r2, lsr #17 @ r2=addr=(code&0x7ff)<<4; addr+=ty
\r
1389 eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
\r
1391 and r3, r9, #0x6000
\r
1392 mov r3, r3, lsr #9 @ r3=pal=((code&0x6000)>>9);
\r
1394 ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
\r
1401 beq .dwloop @ tileline blank
\r
1403 cmp r2, r2, ror #4
\r
1404 beq .dw_SingleColor @ tileline singlecolor
\r
1409 @ (r1=pdest, r2=pixels8, r3=pal) r4: scratch, r0: helper pattern
\r
1419 and r4, r0, r2 @ #0x0000000f
\r
1421 orr r4, r4, r4, lsl #8
\r
1422 orr r4, r4, r4, lsl #16
\r
1424 stmia r1!, {r4,r5}
\r
1425 b .dwloop_nor1 @ we incremeted r1 ourselves
\r
1428 tst r6, #1 @ hi pri?
\r
1429 orreq r3, r3, #0x40
\r
1430 beq .dw_shadow_done
\r
1433 orr r5, r5, r5, lsl #8
\r
1434 orr r5, r5, r5, lsl #16
\r
1443 ldr r0, =rendstatus
\r
1445 and r6, r6, #PDRAW_WND_DIFF_PRIO
\r
1449 ldmfd sp!, {r4-r11,r12}
\r
1453 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1456 @ hilights 2 pixels in RGB444/BGR444 format
\r
1457 .macro TileDoShHi2Pixels444 reg
\r
1458 mov \reg, \reg, ror #12
\r
1459 adds \reg, \reg, #0x40000000
\r
1460 orrcs \reg, \reg, #0xf0000000
\r
1461 mov \reg, \reg, ror #28
\r
1462 adds \reg, \reg, #0x40000000
\r
1463 orrcs \reg, \reg, #0xf0000000
\r
1464 mov \reg, \reg, ror #28
\r
1465 adds \reg, \reg, #0x40000000
\r
1466 orrcs \reg, \reg, #0xf0000000
\r
1467 mov \reg, \reg, ror #24
\r
1468 adds \reg, \reg, #0x40000000
\r
1469 orrcs \reg, \reg, #0xf0000000
\r
1470 mov \reg, \reg, ror #28
\r
1471 adds \reg, \reg, #0x40000000
\r
1472 orrcs \reg, \reg, #0xf0000000
\r
1473 mov \reg, \reg, ror #28
\r
1474 adds \reg, \reg, #0x40000000
\r
1475 orrcs \reg, \reg, #0xf0000000
\r
1476 mov \reg, \reg, ror #12
\r
1480 .global FinalizeLineBGR444 @ int sh
\r
1482 FinalizeLineBGR444:
\r
1483 stmfd sp!, {r4-r6,lr}
\r
1485 ldr lr, =(Pico+0x22228) @ Pico.video
\r
1486 ldr r0, =DrawLineDest
\r
1487 ldrb r12, [lr, #12]
\r
1489 sub r3, lr, #0x128 @ r3=Pico.cram
\r
1492 movne r2, #320/4 @ len
\r
1493 bne .fl_no32colBGR444
\r
1498 addeq r0, r0, #32*2
\r
1500 .fl_no32colBGR444:
\r
1502 beq .fl_noshBGR444
\r
1506 ldrb r12, [lr, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1509 beq .fl_noshBGR444
\r
1511 strb r12, [lr, #-0x1a]
\r
1516 ldmia r3!, {r1,r5,r6,r12}
\r
1518 stmia r4!, {r1,r5,r6,r12}
\r
1519 bne .fl_loopcpBGR444
\r
1521 @ shadowed pixels:
\r
1523 orr r12,r12,#0x0700
\r
1524 orr r12,r12,r12,lsl #16
\r
1525 sub r3, r3, #0x40*2
\r
1526 add r5, r4, #0x80*2
\r
1528 .fl_loopcpBGR444_sh:
\r
1529 ldmia r3!, {r1,r6}
\r
1531 and r1, r12, r1, lsr #1
\r
1532 and r6, r12, r6, lsr #1
\r
1533 stmia r4!, {r1,r6}
\r
1534 stmia r5!, {r1,r6}
\r
1535 bne .fl_loopcpBGR444_sh
\r
1537 @ hilighted pixels:
\r
1538 sub r3, r3, #0x40*2
\r
1540 .fl_loopcpBGR444_hi:
\r
1542 TileDoShHi2Pixels444 r1
\r
1545 bne .fl_loopcpBGR444_hi
\r
1547 sub r3, r4, #0x40*3*2
\r
1552 ldr r12,=rendstatus
\r
1553 eors r6, r6, #1 @ sh is 0
\r
1556 tstne r12,#PDRAW_ACC_SPRITES
\r
1558 .if OVERRIDE_HIGHCOL
\r
1562 mov lr, lr, lsl #1
\r
1565 ldr r1, =(HighCol+8)
\r
1567 mov lr, lr, lsl #1
\r
1574 and r4, lr, r12, lsl #1
\r
1576 and r5, lr, r12, lsr #7
\r
1578 and r6, lr, r12, lsr #15
\r
1580 and r12,lr, r12, lsr #23
\r
1581 ldrh r12,[r3, r12] @ 1c.i.
\r
1582 orr r4, r4, r5, lsl #16
\r
1583 orr r5, r6, r12,lsl #16
\r
1585 stmia r0!, {r4,r5}
\r
1586 bne .fl_loopBGR444
\r
1589 ldmfd sp!, {r4-r6,lr}
\r
1593 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1596 @ hilights 2 pixels in RGB555/BGR555 format
\r
1597 .macro TileDoShHi2Pixels555 reg
\r
1598 adds \reg, \reg, #0x40000000
\r
1599 orrcs \reg, \reg, #0xf0000000
\r
1600 mov \reg, \reg, ror #27
\r
1601 adds \reg, \reg, #0x40000000
\r
1602 orrcs \reg, \reg, #0xf0000000
\r
1603 mov \reg, \reg, ror #26
\r
1604 adds \reg, \reg, #0x40000000
\r
1605 orrcs \reg, \reg, #0xf0000000
\r
1606 mov \reg, \reg, ror #27
\r
1607 adds \reg, \reg, #0x40000000
\r
1608 orrcs \reg, \reg, #0xf0000000
\r
1609 mov \reg, \reg, ror #27
\r
1610 adds \reg, \reg, #0x40000000
\r
1611 orrcs \reg, \reg, #0xf0000000
\r
1612 mov \reg, \reg, ror #26
\r
1613 adds \reg, \reg, #0x40000000
\r
1614 orrcs \reg, \reg, #0xf0000000
\r
1615 mov \reg, \reg, ror #27
\r
1619 @ Convert 0000bbb0 ggg0rrr0
\r
1620 @ to rrrrrggg gggbbbbb
\r
1622 @ r2,r3,r9 - scratch, lr = 0x001c001c, r8 = 0x00030003
\r
1623 .macro convRGB565 reg
\r
1624 and r2, lr, \reg,lsl #1
\r
1625 and r9, r8, \reg,lsr #2
\r
1626 orr r2, r2, r9 @ r2=red
\r
1627 and r3, lr, \reg,lsr #7
\r
1628 and r9, r8, \reg,lsr #10
\r
1629 orr r3, r3, r9 @ r3=blue
\r
1630 and \reg, \reg, lr, lsl #3
\r
1631 orr \reg, \reg, \reg,lsl #3 @ green
\r
1632 orr \reg, \reg, r2, lsl #11 @ add red back
\r
1633 orr \reg, \reg, r3 @ add blue back
\r
1636 .global vidConvCpyRGB565
\r
1638 vidConvCpyRGB565: @ void *to, void *from, int pixels
\r
1639 stmfd sp!, {r4-r9,lr}
\r
1641 mov r12, r2, lsr #3 @ repeats
\r
1642 mov lr, #0x001c0000
\r
1643 orr lr, lr, #0x01c @ lr == pattern 0x001c001c
\r
1644 mov r8, #0x00030000
\r
1645 orr r8, r8, #0x003
\r
1648 ldmia r1!, {r4-r7}
\r
1661 ldmfd sp!, {r4-r9,lr}
\r
1666 .global FinalizeLineRGB555 @ int sh
\r
1668 FinalizeLineRGB555:
\r
1669 stmfd sp!, {r4-r8,lr}
\r
1670 ldr r8, =(Pico+0x22228) @ Pico.video
\r
1673 ldrb r7, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
\r
1677 beq .fl_noconvRGB555
\r
1678 strb r1, [r8, #-0x1a]
\r
1679 sub r1, r8, #0x128 @ r1=Pico.cram
\r
1682 bl vidConvCpyRGB565
\r
1687 beq .fl_noshRGB555
\r
1689 beq .fl_noshRGB555
\r
1691 @ shadowed pixels:
\r
1693 orr r12,r12,#0x7300
\r
1694 orr r12,r12,r12,lsl #16
\r
1695 add r4, r3, #0x40*2
\r
1696 add r5, r3, #0xc0*2
\r
1698 .fl_loopcpRGB555_sh:
\r
1699 ldmia r3!, {r1,r6}
\r
1701 and r1, r12, r1, lsr #1
\r
1702 and r6, r12, r6, lsr #1
\r
1703 stmia r4!, {r1,r6}
\r
1704 stmia r5!, {r1,r6}
\r
1705 bne .fl_loopcpRGB555_sh
\r
1707 @ hilighted pixels:
\r
1708 sub r3, r3, #0x40*2
\r
1710 .fl_loopcpRGB555_hi:
\r
1712 TileDoShHi2Pixels555 r1
\r
1715 bne .fl_loopcpRGB555_hi
\r
1717 sub r3, r3, #0x40*2
\r
1721 ldr r12,=rendstatus
\r
1722 eors r6, r6, #1 @ sh is 0
\r
1725 tstne r12,#PDRAW_ACC_SPRITES
\r
1728 .if OVERRIDE_HIGHCOL
\r
1730 ldr r0, =DrawLineDest
\r
1735 ldr r0, =DrawLineDest
\r
1736 ldr r1, =(HighCol+8)
\r
1740 ldrb r12, [r8, #12]
\r
1741 mov lr, lr, lsl #1
\r
1744 movne r2, #320/8 @ len
\r
1745 bne .fl_no32colRGB555
\r
1750 bne .fl_32scale_RGB555
\r
1752 addeq r0, r0, #32*2
\r
1754 .fl_no32colRGB555:
\r
1756 .if UNALIGNED_DRAWLINEDEST
\r
1757 @ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer
\r
1766 and r4, lr, r12, lsl #1
\r
1768 and r5, lr, r12, lsr #7
\r
1770 and r6, lr, r12, lsr #15
\r
1772 orr r4, r4, r5, lsl #16
\r
1774 and r5, lr, r12, lsr #23
\r
1776 and r8, lr, r7, lsl #1
\r
1778 orr r5, r6, r5, lsl #16
\r
1780 and r6, lr, r7, lsr #7
\r
1782 and r12,lr, r7, lsr #15
\r
1783 ldrh r12,[r3, r12]
\r
1784 and r7, lr, r7, lsr #23
\r
1786 orr r8, r8, r6, lsl #16
\r
1789 orr r12,r12, r7, lsl #16
\r
1791 stmia r0!, {r4,r5,r8,r12}
\r
1792 bne .fl_loopRGB555
\r
1794 ldmfd sp!, {r4-r8,lr}
\r
1798 .fl_32scale_RGB555:
\r
1799 stmfd sp!, {r9,r10}
\r
1800 mov r9, #0x3900 @ f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1801 orr r9, r9, #0x00e7
\r
1803 .if UNALIGNED_DRAWLINEDEST
\r
1805 bne .fl_32scale_RGB555u
\r
1808 .fl_loop32scale_RGB555:
\r
1812 and r4, lr, r12,lsl #1
\r
1814 and r5, lr, r12,lsr #7
\r
1816 and r4, r4, r9, lsl #2
\r
1817 orr r4, r4, r4, lsl #14 @ r4[31:16] = 1/4 pix_s 0
\r
1818 and r5, r5, r9, lsl #2
\r
1819 sub r6, r5, r5, lsr #2 @ r6 = 3/4 pix_s 1
\r
1820 add r4, r4, r6, lsl #16 @ pix_d 0, 1
\r
1821 and r6, lr, r12,lsr #15
\r
1823 and r12,lr, r12,lsr #23
\r
1824 ldrh r12,[r3, r12]
\r
1825 and r6, r6, r9, lsl #2
\r
1827 mov r5, r5, lsr #1
\r
1828 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1829 orr r5, r5, r6, lsl #16
\r
1831 and r6, lr, r7, lsl #1
\r
1833 and r12,r12,r9, lsl #2
\r
1834 add r5, r5, r12,lsl #14 @ pix_d 2, 3
\r
1835 and r6, r6, r9, lsl #2
\r
1836 orr r6, r12,r6, lsl #16 @ pix_d 4, 5
\r
1838 and r12,lr, r7, lsr #7
\r
1839 ldrh r12,[r3, r12]
\r
1840 and r10,lr, r7, lsr #15
\r
1841 ldrh r10,[r3, r10]
\r
1842 and r12,r12,r9, lsl #2
\r
1843 sub r8, r12,r12,lsr #2 @ r8 = 3/4 pix_s 1
\r
1844 add r8, r8, r6, lsr #18
\r
1845 and r7, lr, r7, lsr #23
\r
1847 and r10,r10,r9, lsl #2
\r
1848 orr r8, r8, r10,lsl #15
\r
1849 add r8, r8, r12,lsl #15 @ pix_d 6, 7
\r
1850 sub r10,r10,r10,lsr #2 @ r10= 3/4 pix_s 2
\r
1851 and r7, r7, r9, lsl #2
\r
1852 add r10,r10,r7, lsr #2 @ += 1/4 pix_s 3
\r
1853 orr r10,r10,r7, lsl #16 @ pix_d 8, 9
\r
1857 stmia r0!, {r4,r5,r6,r8,r10}
\r
1858 bne .fl_loop32scale_RGB555
\r
1860 ldmfd sp!, {r9,r10}
\r
1861 ldmfd sp!, {r4-r8,lr}
\r
1864 .if UNALIGNED_DRAWLINEDEST
\r
1865 @ unaligned versions of loops
\r
1866 @ warning: starts drawing 2bytes before dst
\r
1869 sub r0, r0, #2 @ initial adjustment
\r
1876 and r6, lr, r12,lsl #1
\r
1878 and r5, lr, r12,lsr #7
\r
1880 orr r4, r8, r6, lsl #16
\r
1882 and r6, lr, r12,lsr #15
\r
1884 and r8, lr, r12,lsr #23
\r
1886 orr r5, r5, r6, lsl #16
\r
1888 and r6, lr, r7, lsl #1
\r
1890 and r12,lr, r7, lsr #7
\r
1891 ldrh r12,[r3, r12]
\r
1892 orr r6, r8, r6, lsl #16
\r
1894 and r8, lr, r7, lsr #15
\r
1896 and r7, lr, r7, lsr #23
\r
1899 orr r12,r12,r8, lsl #16
\r
1902 stmia r0!, {r4,r5,r6,r12}
\r
1903 bne .fl_loopRGB555u
\r
1907 ldmfd sp!, {r4-r8,lr}
\r
1911 .fl_32scale_RGB555u:
\r
1912 sub r0, r0, #2 @ initial adjustment
\r
1915 @ r9 f800 07e0 001f | e000 0780 001c | 3800 01e0 0007
\r
1916 .fl_loop32scale_RGB555u:
\r
1920 and r6, lr, r12,lsl #1
\r
1922 and r5, lr, r12,lsr #7
\r
1924 and r6, r6, r9, lsl #2
\r
1925 orr r4, r4, r6, lsl #16 @ r4 = pix_d -1, 0
\r
1927 and r5, r5, r9, lsl #2
\r
1928 sub r8, r5, r5, lsr #2 @ r8 = 3/4 pix_s 1
\r
1929 add r6, r8, r6, lsr #2 @ r6 = (1/4 pix_s 0) + (3/4 pix_s 1)
\r
1930 orr r5, r6, r5, lsl #15
\r
1932 and r6, lr, r12,lsr #15
\r
1934 and r12,lr, r12,lsr #23
\r
1935 ldrh r12,[r3, r12]
\r
1936 and r6, r6, r9, lsl #2
\r
1937 add r5, r5, r6, lsl #15 @ r5 = pix_d 1, 2
\r
1939 and r8, lr, r7, lsl #1
\r
1941 and r10,lr, r7, lsr #7
\r
1942 ldrh r10,[r3, r10]
\r
1943 and r12,r12,r9, lsl #2
\r
1944 sub r6, r6, r6, lsr #2 @ r6 = 3/4 pix_s 2
\r
1945 add r6, r6, r12,lsr #2
\r
1946 orr r6, r6, r12,lsl #16 @ r6 = pix_d 3, 4
\r
1948 and r8, r8, r9, lsl #2
\r
1949 and r10,r10,r9, lsl #2
\r
1950 sub r12,r10,r10,lsr #2 @ r12 = 3/4 pix_s 5
\r
1951 orr r8, r8, r8, lsl #14
\r
1952 add r8, r8, r12,lsl #16 @ r8 = pix_d 5, 6
\r
1953 and r12,lr, r7, lsr #15
\r
1954 ldrh r12,[r3, r12]
\r
1955 and r7, lr, r7, lsr #23
\r
1957 and r12,r12,r9, lsl #2
\r
1959 mov r10,r10, lsr #1
\r
1960 sub r12,r12,r12,lsr #2 @ r12 = 3/4 pix_s 6
\r
1961 orr r10,r10,r12,lsl #16
\r
1962 and r7, r7, r9, lsl #2
\r
1963 add r10,r10,r7, lsl #14 @ r10 = pix_d 7, 8
\r
1967 stmia r0!, {r4,r5,r6,r8,r10}
\r
1969 bne .fl_loop32scale_RGB555u
\r
1973 ldmfd sp!, {r9,r10}
\r
1974 ldmfd sp!, {r4-r8,lr}
\r
1977 .endif @ UNALIGNED_DRAWLINEDEST
\r
1980 @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
\r
1983 .global blockcpy @ void *dst, void *src, size_t n
\r
1986 stmfd sp!, {r4,r5}
\r
1987 mov r2, r2, lsr #4
\r
1989 ldmia r1!, {r3-r5,r12}
\r
1991 stmia r0!, {r3-r5,r12}
\r
1993 ldmfd sp!, {r4,r5}
\r
1997 .global blockcpy_or @ void *dst, void *src, size_t n, int pat
\r
2000 stmfd sp!, {r4-r6}
\r
2001 orr r3, r3, r3, lsl #8
\r
2002 orr r3, r3, r3, lsl #16
\r
2003 mov r2, r2, lsr #4
\r
2005 ldmia r1!, {r4-r6,r12}
\r
2011 stmia r0!, {r4-r6,r12}
\r
2012 bne blockcpy_loop_or
\r
2013 ldmfd sp!, {r4-r6}
\r