mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
improve sh/hi levels
.. but reduce brigtness ~6% due to different rgb565 expansion git-svn-id: file:///home/notaz/opt/svn/PicoDrive@890 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
7c18e34a74
commit
a39d8ba585
2 changed files with 48 additions and 58 deletions
25
pico/draw.c
25
pico/draw.c
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* since renderer always draws line in 8bit mode, there are 2 spare bits:
|
||||
* b \ mode: s/h as sonic
|
||||
* 00 normal - -
|
||||
* 00 normal - pal index
|
||||
* 01 shadow - pal index
|
||||
* 10 hilight+op spr spr pal index
|
||||
* 11 shadow +op spr - pal index
|
||||
|
@ -1162,34 +1162,37 @@ unsigned short HighPal[0x100];
|
|||
void PicoDoHighPal555(int sh)
|
||||
{
|
||||
unsigned int *spal, *dpal;
|
||||
unsigned short *pal=HighPal;
|
||||
int i, t;
|
||||
unsigned int t, i;
|
||||
|
||||
Pico.m.dirtyPal = 0;
|
||||
|
||||
spal = (void *)Pico.cram;
|
||||
dpal = (void *)HighPal;
|
||||
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
unsigned int t = spal[i];
|
||||
for (i = 0; i < 0x40 / 2; i++) {
|
||||
t = spal[i];
|
||||
#ifdef USE_BGR555
|
||||
t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
|
||||
#else
|
||||
t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
|
||||
#endif
|
||||
t |= (t >> 3) & 0x18e318e3;
|
||||
// treat it like it was 4-bit per channel, since in s/h mode it somewhat is that.
|
||||
// otherwise intensity difference between this and s/h will be wrong
|
||||
t |= (t >> 4) & 0x08610861; // 0x18e318e3
|
||||
dpal[i] = t;
|
||||
}
|
||||
|
||||
// norm: xxx0, sh: 0xxx, hi: 0xxx + 7
|
||||
if (sh)
|
||||
{
|
||||
// shadowed pixels
|
||||
for (i = 0x3f; i >= 0; i--)
|
||||
pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e);
|
||||
for (i = 0; i < 0x40 / 2; i++)
|
||||
dpal[0x40/2 | i] = dpal[0xc0/2 | i] = (dpal[i] >> 1) & 0x738e738e;
|
||||
// hilighted pixels
|
||||
for (i = 0x3f; i >= 0; i--) {
|
||||
t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c;
|
||||
pal[0x80|i]=(unsigned short)t;
|
||||
for (i = 0; i < 0x40 / 2; i++) {
|
||||
t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef;
|
||||
t |= (t >> 4) & 0x08610861;
|
||||
dpal[0x80/2 | i] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1595,53 +1595,26 @@ FinalizeLineBGR444:
|
|||
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
|
||||
@ hilights 2 pixels in RGB555/BGR555 format
|
||||
.macro TileDoShHi2Pixels555 reg
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #27
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #26
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #27
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #27
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #26
|
||||
adds \reg, \reg, #0x40000000
|
||||
orrcs \reg, \reg, #0xf0000000
|
||||
mov \reg, \reg, ror #27
|
||||
.endm
|
||||
|
||||
|
||||
@ Convert 0000bbb0 ggg0rrr0
|
||||
@ to rrrrrggg gggbbbbb
|
||||
|
||||
@ r2,r3,r9 - scratch, lr = 0x001c001c, r8 = 0x00030003
|
||||
@ r2,r3 - scratch, lr = 0x001c001c, r8 = 0x08610861
|
||||
.macro convRGB565 reg
|
||||
and r2, lr, \reg,lsl #1
|
||||
and r9, r8, \reg,lsr #2
|
||||
orr r2, r2, r9 @ r2=red
|
||||
and r3, lr, \reg,lsr #7
|
||||
and r9, r8, \reg,lsr #10
|
||||
orr r3, r3, r9 @ r3=blue
|
||||
and \reg, \reg, lr, lsl #3
|
||||
orr \reg, \reg, \reg,lsl #3 @ green
|
||||
orr \reg, \reg, r2, lsl #11 @ add red back
|
||||
orr \reg, \reg, r3 @ add blue back
|
||||
and r2, lr, \reg,lsr #7 @ b
|
||||
and r3, lr, \reg,lsr #3 @ g
|
||||
and \reg, lr, \reg,lsl #1 @ r
|
||||
orr r2, r2, r3, lsl #6
|
||||
orr \reg, r2, \reg,lsl #11
|
||||
|
||||
and r2, r8, \reg,lsr #4
|
||||
orr \reg, \reg, r2
|
||||
.endm
|
||||
|
||||
@ trashes: r2-r9,r12,lr; r0,r1 are advanced
|
||||
@ trashes: r2-r8,r12,lr; r8 = 0x08610861; r0,r1 are advanced
|
||||
.macro vidConvCpyRGB565_local
|
||||
mov r12, r2, lsr #3 @ repeats
|
||||
mov lr, #0x001c0000
|
||||
orr lr, lr, #0x01c @ lr == pattern 0x001c001c
|
||||
mov r8, #0x00030000
|
||||
orr r8, r8, #0x003
|
||||
|
||||
0:
|
||||
ldmia r1!, {r4-r7}
|
||||
|
@ -1663,6 +1636,9 @@ FinalizeLineBGR444:
|
|||
|
||||
vidConvCpyRGB565: @ void *to, void *from, int pixels
|
||||
stmfd sp!, {r4-r9,lr}
|
||||
mov r8, #0x0061
|
||||
orr r8, r8, #0x0800
|
||||
orr r8, r8, lsl #16
|
||||
vidConvCpyRGB565_local
|
||||
ldmfd sp!, {r4-r9,lr}
|
||||
bx lr
|
||||
|
@ -1676,9 +1652,8 @@ PicoDoHighPal555:
|
|||
ldr r8, =(Pico+0x22228) @ Pico.video
|
||||
|
||||
PicoDoHighPal555_nopush:
|
||||
str r1, [sp, #-8] @ is called from FinalizeLine555?
|
||||
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h
|
||||
|
||||
str r0, [sp, #-4]
|
||||
ldr r0, =HighPal
|
||||
|
||||
mov r1, #0
|
||||
|
@ -1686,10 +1661,13 @@ PicoDoHighPal555_nopush:
|
|||
|
||||
sub r1, r8, #0x128 @ r1=Pico.cram
|
||||
mov r2, #0x40
|
||||
mov r8, #0x0061
|
||||
orr r8, r8, #0x0800
|
||||
orr r8, r8, lsl #16
|
||||
|
||||
vidConvCpyRGB565_local
|
||||
|
||||
ldr r0, [sp, #-4]
|
||||
tst r0, r0
|
||||
tst r9, #(1<<31)
|
||||
beq PicoDoHighPal555_end
|
||||
|
||||
ldr r3, =HighPal
|
||||
|
@ -1711,19 +1689,28 @@ PicoDoHighPal555_nopush:
|
|||
bne .fl_loopcpRGB555_sh
|
||||
|
||||
@ hilighted pixels:
|
||||
@ t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e;
|
||||
@ t |= (t >> 4) & 0x08610861;
|
||||
@ r8=0x08610861
|
||||
sub r3, r3, #0x40*2
|
||||
mov lr, #0x40/2
|
||||
mov lr, #0x40/4
|
||||
.fl_loopcpRGB555_hi:
|
||||
ldr r1, [r3], #4
|
||||
TileDoShHi2Pixels555 r1
|
||||
str r1, [r4], #4
|
||||
ldmia r3!, {r1,r6}
|
||||
and r1, r12, r1, lsr #1
|
||||
and r6, r12, r6, lsr #1
|
||||
add r1, r12, r1
|
||||
add r6, r12, r6
|
||||
and r5, r8, r1, lsr #4
|
||||
and r7, r8, r6, lsr #4
|
||||
orr r1, r1, r5
|
||||
orr r6, r6, r7
|
||||
stmia r4!, {r1,r6}
|
||||
subs lr, lr, #1
|
||||
bne .fl_loopcpRGB555_hi
|
||||
mov r0, #1
|
||||
|
||||
PicoDoHighPal555_end:
|
||||
ldr r1, [sp, #-8]
|
||||
tst r1, r1
|
||||
tst r9, #1
|
||||
ldmeqfd sp!, {r4-r9,pc}
|
||||
|
||||
ldr r8, =(Pico+0x22228) @ Pico.video
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue