interpreter memory vector access now always uses bound checking
This commit is contained in:
@@ -71,7 +71,7 @@ void Interpreter::tick() {
|
||||
|
||||
// fetch instruction
|
||||
sreg_t iInstAddr = mvSpecialReg[SR_PC];
|
||||
unsigned inst = (mvMemory[iInstAddr] << 8) | mvMemory[iInstAddr + 1];
|
||||
unsigned inst = (mvMemory.at(iInstAddr) << 8) | mvMemory.at(iInstAddr + 1);
|
||||
|
||||
// increment program counter
|
||||
mvSpecialReg[SR_PC] += 2;
|
||||
@@ -163,18 +163,18 @@ void Interpreter::tick() {
|
||||
mvSpecialReg[SR_I] = scLowRestFontAddr + 5 * mvReg[iRegDst];
|
||||
break;
|
||||
case 0xF033: // FX33 - convert to bcd
|
||||
mvMemory[mvSpecialReg[SR_I]] = (mvReg[iRegDst] / 100) % 10;
|
||||
mvMemory[mvSpecialReg[SR_I] + 1] = (mvReg[iRegDst] / 10) % 10;
|
||||
mvMemory[mvSpecialReg[SR_I] + 2] = mvReg[iRegDst] % 10;
|
||||
mvMemory.at(mvSpecialReg[SR_I]) = (mvReg[iRegDst] / 100) % 10;
|
||||
mvMemory.at(mvSpecialReg[SR_I] + 1) = (mvReg[iRegDst] / 10) % 10;
|
||||
mvMemory.at(mvSpecialReg[SR_I] + 2) = mvReg[iRegDst] % 10;
|
||||
break;
|
||||
case 0xF055: // FX55 - dump registers
|
||||
for(int i = 0; i <= iRegDst - R_V0; i++) {
|
||||
mvMemory[mvSpecialReg[SR_I]++] = mvReg[R_V0 + i];
|
||||
mvMemory.at(mvSpecialReg[SR_I]++) = mvReg[R_V0 + i];
|
||||
}
|
||||
break;
|
||||
case 0xF065: // FX65 - restore registers
|
||||
for(int i = 0; i <= iRegDst - R_V0; i++) {
|
||||
mvReg[R_V0 + i] = mvMemory[mvSpecialReg[SR_I]++];
|
||||
mvReg[R_V0 + i] = mvMemory.at(mvSpecialReg[SR_I]++);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -272,14 +272,14 @@ void Interpreter::executeDraw(uint8_t x, uint8_t y, uint8_t n) {
|
||||
uint16_t spriteRowBits;
|
||||
if(mIsHighResMode) {
|
||||
// draws an 8xN sprite
|
||||
spriteRowBits = mvMemory[iMemAddr++] << 8;
|
||||
spriteRowBits = mvMemory.at(iMemAddr++) << 8;
|
||||
if(n == 0) {
|
||||
// draws an 16xN sprite, so fetch another byte from sprite data
|
||||
spriteRowBits |= mvMemory[iMemAddr++];
|
||||
spriteRowBits |= mvMemory.at(iMemAddr++);
|
||||
}
|
||||
} else {
|
||||
// in low-res mode, each sprite pixel draws two on-screen pixels
|
||||
spriteRowBits = gcvLowResToHighResRowLookupTable[mvMemory[iMemAddr++]];
|
||||
spriteRowBits = gcvLowResToHighResRowLookupTable[mvMemory.at(iMemAddr++)];
|
||||
}
|
||||
|
||||
// convert to bitset and shift into absolute horizontal position on the screen
|
||||
|
||||
Reference in New Issue
Block a user