diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index cf16a16..3384721 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -33579,6 +33579,14 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass mIns[i + 1].mType = ASMIT_ROR; mIns[i + 1].mMode = ASMIM_IMPLIED; 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 ( 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)) @@ -35984,7 +35992,6 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass mIns[i + 3].mAddress = mIns[i + 0].mAddress; progress = true; } - if ( 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 && diff --git a/samples/sprites/sprmux64.c b/samples/sprites/sprmux64.c index 94cba11..d34434f 100644 --- a/samples/sprites/sprmux64.c +++ b/samples/sprites/sprmux64.c @@ -79,6 +79,24 @@ __interrupt void setspr(void) 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 // at start of line, so we need to patch it after the last // 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 if (phase & 0x80) { - // MSB mask - char xymask = 0; - - // Update all sprite x LSB and color, put MSB into - // xymask bit + // Update all sprite x LSB and color #pragma unroll(full) for(char i=0; i<8; i++) { - xymask = ((unsigned)xymask | (xp[i] & 0xff00)) >> 1; vic.spr_pos[i].x = xp[i]; vic.spr_color[i] = VCOL_ORANGE + i; } @@ -105,22 +118,16 @@ __interrupt void setspr(void) } else { - char xymask = 0; - - // Update all sprite x LSB and color, put MSB into - // xymask bit - + // Update all sprite x LSB and color #pragma unroll(full) 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_color[i] = VCOL_ORANGE + (7 - i); } - - // Update MSB - vic.spr_msbx = xymask; } + // Update MSB + vic.spr_msbx = xymask; } // Eight raster interrupts