diff --git a/include/conio.c b/include/conio.c index f698ac4..4acd1ca 100644 --- a/include/conio.c +++ b/include/conio.c @@ -98,6 +98,15 @@ __asm bsplot __asm bsinit { +} +#elif defined(__VIC20__) +#define bsout 0xffd2 +#define bsin 0xffe4 +#define bsplot 0xfff0 +__asm bsinit +{ + lda #147 + jmp $ffd2 } #else #define bsout 0xffd2 diff --git a/include/stdio.c b/include/stdio.c index 3104d9e..a806adb 100644 --- a/include/stdio.c +++ b/include/stdio.c @@ -583,7 +583,7 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print) if (c >= '0' && c <='9') { - int i = 0; + char i = 0; while (c >= '0' && c <='9') { i = i * 10 + c - '0'; @@ -594,7 +594,7 @@ char * sformat(char * buff, const char * fmt, int * fps, bool print) if (c == '.') { - int i = 0; + char i = 0; c = *p++; while (c >= '0' && c <='9') { diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 5a9c891..24c95e7 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -25397,6 +25397,49 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool } #endif +#if 1 + if (mEntryBlocks.Size() > 1 && mIns.Size() > 0) + { + if (mIns[0].mType == ASMIT_STA) + { + int ts; + if ((ts = mEntryBlocks[0]->mIns.Size()) >= 2 && + mEntryBlocks[0]->mIns[ts - 2].mType == ASMIT_LDA && + mEntryBlocks[0]->mIns[ts - 2].mMode == ASMIM_ZERO_PAGE && + mEntryBlocks[0]->mIns[ts - 1].mType == ASMIT_ADC) + { + int addr = mEntryBlocks[0]->mIns[ts - 2].mAddress; + + int i = 1; + while (i < mEntryBlocks.Size() && + (ts = mEntryBlocks[i]->mIns.Size()) >= 2 && + mEntryBlocks[i]->mIns[ts - 2].mType == ASMIT_LDA && + mEntryBlocks[i]->mIns[ts - 2].mMode == ASMIM_ZERO_PAGE && + mEntryBlocks[i]->mIns[ts - 2].mAddress == addr && + mEntryBlocks[i]->mIns[ts - 1].mType == ASMIT_ADC) + i++; + if (i == mEntryBlocks.Size()) + { + ts = mEntryBlocks[0]->mIns.Size(); + mIns.Insert(0, NativeCodeInstruction(mEntryBlocks[0]->mIns[ts - 2].mIns, ASMIT_ADC, mEntryBlocks[0]->mIns[ts - 2])); + + for (int i = 0; i < mEntryBlocks.Size(); i++) + { + ts = mEntryBlocks[i]->mIns.Size(); + mEntryBlocks[i]->mIns[ts - 1].mType = ASMIT_LDA; + mEntryBlocks[i]->mIns[ts - 2].mType = ASMIT_NOP; + mEntryBlocks[i]->mIns[ts - 2].mMode = ASMIM_IMPLIED; + mEntryBlocks[i]->mExitRequiredRegs += addr; + mEntryBlocks[i]->mExitRequiredRegs += CPU_REG_C; + } + mEntryRequiredRegs += addr; + mEntryRequiredRegs += CPU_REG_C; + changed = true; + } + } + } + } +#endif #if 0 if (mFalseJump && mIns.Size() > 1) {