Optimize combining bits using shift

This commit is contained in:
drmortalwombat 2023-05-07 20:55:35 +02:00
parent 7b16d2c795
commit a9651a4f2e
2 changed files with 30 additions and 16 deletions

View File

@ -33579,6 +33579,14 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
mIns[i + 1].mType = ASMIT_ROR; mIns[i + 1].mMode = ASMIM_IMPLIED; mIns[i + 1].mType = ASMIT_ROR; mIns[i + 1].mMode = ASMIM_IMPLIED;
progress = true; progress = true;
} }
else if (
mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && !(mIns[i + 0].mLive & LIVE_MEM) &&
mIns[i + 1].IsShift() && mIns[i + 1].mMode == ASMIM_IMPLIED && !(mIns[i + 1].mLive & LIVE_CPU_REG_A))
{
mIns[i + 0].mType = mIns[i + 1].mType; mIns[i + 0].mLive |= LIVE_CPU_REG_C;
mIns[i + 1].mType = ASMIT_NOP; mIns[i + 1].mMode = ASMIM_IMPLIED;
progress = true;
}
else if ( else if (
mIns[i + 0].IsShift() && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && mIns[i + 0].IsShift() && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 1].mAddress == mIns[i + 0].mAddress && !(mIns[i + 1].mLive & LIVE_MEM)) mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 1].mAddress == mIns[i + 0].mAddress && !(mIns[i + 1].mLive & LIVE_MEM))
@ -35984,7 +35992,6 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
mIns[i + 3].mAddress = mIns[i + 0].mAddress; mIns[i + 3].mAddress = mIns[i + 0].mAddress;
progress = true; progress = true;
} }
if ( if (
mIns[i + 0].mType == ASMIT_LDY && mIns[i + 0].mMode == ASMIM_IMMEDIATE && mIns[i + 0].mAddress == 0 && mIns[i + 0].mType == ASMIT_LDY && mIns[i + 0].mMode == ASMIM_IMMEDIATE && mIns[i + 0].mAddress == 0 &&
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_INDIRECT_Y && mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_INDIRECT_Y &&

View File

@ -79,6 +79,24 @@ __interrupt void setspr(void)
xpos1 += step; xpos1 += step;
} }
// build highbyte for sprite pos
char xymask = 0;
if (phase & 0x80)
{
// put MSB into xymask bit
#pragma unroll(full)
for(char i=0; i<8; i++)
xymask = ((unsigned)xymask | (xp[i] & 0xff00)) >> 1;
}
else
{
// put MSB into xymask bit
#pragma unroll(full)
for(char i=0; i<8; i++)
xymask = ((unsigned)xymask | (xp[7 - i] & 0xff00)) >> 1;
}
// Wait for end of current sprite, xpos will take effect // Wait for end of current sprite, xpos will take effect
// at start of line, so we need to patch it after the last // at start of line, so we need to patch it after the last
// pixel line has started // pixel line has started
@ -87,15 +105,10 @@ __interrupt void setspr(void)
// Left to right or right to left to get a matching z order // Left to right or right to left to get a matching z order
if (phase & 0x80) if (phase & 0x80)
{ {
// MSB mask // Update all sprite x LSB and color
char xymask = 0;
// Update all sprite x LSB and color, put MSB into
// xymask bit
#pragma unroll(full) #pragma unroll(full)
for(char i=0; i<8; i++) for(char i=0; i<8; i++)
{ {
xymask = ((unsigned)xymask | (xp[i] & 0xff00)) >> 1;
vic.spr_pos[i].x = xp[i]; vic.spr_pos[i].x = xp[i];
vic.spr_color[i] = VCOL_ORANGE + i; vic.spr_color[i] = VCOL_ORANGE + i;
} }
@ -105,22 +118,16 @@ __interrupt void setspr(void)
} }
else else
{ {
char xymask = 0; // Update all sprite x LSB and color
// Update all sprite x LSB and color, put MSB into
// xymask bit
#pragma unroll(full) #pragma unroll(full)
for(char i=0; i<8; i++) for(char i=0; i<8; i++)
{ {
xymask = ((unsigned)xymask | (xp[7 - i] & 0xff00)) >> 1;
vic.spr_pos[i].x = xp[7 - i]; vic.spr_pos[i].x = xp[7 - i];
vic.spr_color[i] = VCOL_ORANGE + (7 - i); vic.spr_color[i] = VCOL_ORANGE + (7 - i);
} }
}
// Update MSB // Update MSB
vic.spr_msbx = xymask; vic.spr_msbx = xymask;
}
} }
// Eight raster interrupts // Eight raster interrupts