*\r
* since renderer always draws line in 8bit mode, there are 2 spare bits:\r
* b \ mode: s/h as sonic\r
- * 00 normal - -\r
+ * 00 normal - pal index\r
* 01 shadow - pal index\r
* 10 hilight+op spr spr pal index\r
* 11 shadow +op spr - pal index\r
void PicoDoHighPal555(int sh)\r
{\r
unsigned int *spal, *dpal;\r
- unsigned short *pal=HighPal;\r
- int i, t;\r
+ unsigned int t, i;\r
\r
Pico.m.dirtyPal = 0;\r
\r
spal = (void *)Pico.cram;\r
dpal = (void *)HighPal;\r
\r
- for (i = 0; i < 0x40; i++) {\r
- unsigned int t = spal[i];\r
+ for (i = 0; i < 0x40 / 2; i++) {\r
+ t = spal[i];\r
#ifdef USE_BGR555\r
t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);\r
#else\r
t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);\r
#endif\r
- t |= (t >> 3) & 0x18e318e3;\r
+ // treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.\r
+ // otherwise intensity difference between this and s/h will be wrong\r
+ t |= (t >> 4) & 0x08610861; // 0x18e318e3\r
dpal[i] = t;\r
}\r
\r
+ // norm: xxx0, sh: 0xxx, hi: 0xxx + 7\r
if (sh)\r
{\r
// shadowed pixels\r
- for (i = 0x3f; i >= 0; i--)\r
- pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);\r
+ for (i = 0; i < 0x40 / 2; i++)\r
+ dpal[0x40/2 | i] = dpal[0xc0/2 | i] = (dpal[i] >> 1) & 0x738e738e;\r
// hilighted pixels\r
- for (i = 0x3f; i >= 0; i--) {\r
- t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;\r
- pal[0x80|i]=(unsigned short)t;\r
+ for (i = 0; i < 0x40 / 2; i++) {\r
+ t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;\r
+ t |= (t >> 4) & 0x08610861;\r
+ dpal[0x80/2 | i] = t;\r
}\r
}\r
}\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-@ hilights 2 pixels in RGB555/BGR555 format\r
-.macro TileDoShHi2Pixels555 reg\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #27\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #26\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #27\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #27\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #26\r
- adds \reg, \reg, #0x40000000\r
- orrcs \reg, \reg, #0xf0000000\r
- mov \reg, \reg, ror #27\r
-.endm\r
-\r
-\r
@ Convert 0000bbb0 ggg0rrr0\r
@ to rrrrrggg gggbbbbb\r
\r
-@ r2,r3,r9 - scratch, lr = 0x001c001c, r8 = 0x00030003\r
+@ r2,r3 - scratch, lr = 0x001c001c, r8 = 0x08610861\r
.macro convRGB565 reg\r
- and r2, lr, \reg,lsl #1\r
- and r9, r8, \reg,lsr #2\r
- orr r2, r2, r9 @ r2=red\r
- and r3, lr, \reg,lsr #7\r
- and r9, r8, \reg,lsr #10\r
- orr r3, r3, r9 @ r3=blue\r
- and \reg, \reg, lr, lsl #3\r
- orr \reg, \reg, \reg,lsl #3 @ green\r
- orr \reg, \reg, r2, lsl #11 @ add red back\r
- orr \reg, \reg, r3 @ add blue back\r
+ and r2, lr, \reg,lsr #7 @ b\r
+ and r3, lr, \reg,lsr #3 @ g\r
+ and \reg, lr, \reg,lsl #1 @ r\r
+ orr r2, r2, r3, lsl #6\r
+ orr \reg, r2, \reg,lsl #11\r
+\r
+ and r2, r8, \reg,lsr #4\r
+ orr \reg, \reg, r2\r
.endm\r
\r
-@ trashes: r2-r9,r12,lr; r0,r1 are advanced\r
+@ trashes: r2-r8,r12,lr; r8 = 0x08610861; r0,r1 are advanced\r
.macro vidConvCpyRGB565_local\r
mov r12, r2, lsr #3 @ repeats\r
mov lr, #0x001c0000\r
orr lr, lr, #0x01c @ lr == pattern 0x001c001c\r
- mov r8, #0x00030000\r
- orr r8, r8, #0x003\r
\r
0:\r
ldmia r1!, {r4-r7}\r
\r
vidConvCpyRGB565: @ void *to, void *from, int pixels\r
stmfd sp!, {r4-r9,lr}\r
+ mov r8, #0x0061\r
+ orr r8, r8, #0x0800\r
+ orr r8, r8, lsl #16\r
vidConvCpyRGB565_local\r
ldmfd sp!, {r4-r9,lr}\r
bx lr\r
ldr r8, =(Pico+0x22228) @ Pico.video\r
\r
PicoDoHighPal555_nopush:\r
- str r1, [sp, #-8] @ is called from FinalizeLine555?\r
+ orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h\r
\r
- str r0, [sp, #-4]\r
ldr r0, =HighPal\r
\r
mov r1, #0\r
\r
sub r1, r8, #0x128 @ r1=Pico.cram\r
mov r2, #0x40\r
+ mov r8, #0x0061\r
+ orr r8, r8, #0x0800\r
+ orr r8, r8, lsl #16\r
+\r
vidConvCpyRGB565_local\r
\r
- ldr r0, [sp, #-4]\r
- tst r0, r0\r
+ tst r9, #(1<<31)\r
beq PicoDoHighPal555_end\r
\r
ldr r3, =HighPal\r
bne .fl_loopcpRGB555_sh\r
\r
@ hilighted pixels:\r
+ @ t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e;\r
+ @ t |= (t >> 4) & 0x08610861;\r
+ @ r8=0x08610861\r
sub r3, r3, #0x40*2\r
- mov lr, #0x40/2\r
+ mov lr, #0x40/4\r
.fl_loopcpRGB555_hi:\r
- ldr r1, [r3], #4\r
- TileDoShHi2Pixels555 r1\r
- str r1, [r4], #4\r
+ ldmia r3!, {r1,r6}\r
+ and r1, r12, r1, lsr #1\r
+ and r6, r12, r6, lsr #1\r
+ add r1, r12, r1\r
+ add r6, r12, r6\r
+ and r5, r8, r1, lsr #4\r
+ and r7, r8, r6, lsr #4\r
+ orr r1, r1, r5\r
+ orr r6, r6, r7\r
+ stmia r4!, {r1,r6}\r
subs lr, lr, #1\r
bne .fl_loopcpRGB555_hi\r
mov r0, #1\r
\r
PicoDoHighPal555_end:\r
- ldr r1, [sp, #-8]\r
- tst r1, r1\r
+ tst r9, #1\r
ldmeqfd sp!, {r4-r9,pc}\r
\r
ldr r8, =(Pico+0x22228) @ Pico.video\r