Correct some outstanding LR35902 problems arising.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-06 22:04:13 +01:00
parent 016b3bca59
commit 88d773708c
3 changed files with 10 additions and 18 deletions

View File

@ -80,22 +80,19 @@ namespace EightBit {
void reset();
void writeRegister(int offset, uint8_t content) {
REG(offset) = content;
fireWriteBusEvent();
return Memory::write(BASE + offset, content);
}
uint8_t readRegister(int offset) {
auto returned = REG(offset);
fireReadBusEvent();
return returned;
return Memory::read(BASE + offset);
}
void incrementLY() {
REG(LY) = (REG(LY) + 1) % TotalLineCount;
writeRegister(LY, (readRegister(LY) + 1) % TotalLineCount);
}
void resetLY() {
REG(LY) = 0;
writeRegister(LY, 0);
}
void loadBootRom(const std::string& path);
@ -110,10 +107,5 @@ namespace EightBit {
private:
std::array<uint8_t, 0x100> m_boot;
uint8_t& REG(int offset) {
ADDRESS().word = BASE + offset;
return Memory::reference();
}
};
}

View File

@ -6,8 +6,8 @@ EightBit::Bus::Bus()
}
void EightBit::Bus::reset() {
REG(NR52) = 0xf1;
REG(LCDC) = 0x91;
writeRegister(NR52, 0xf1);
writeRegister(LCDC, 0x91);
}
void EightBit::Bus::loadBootRom(const std::string& path) {

View File

@ -570,16 +570,16 @@ void EightBit::LR35902::executeOther(int x, int y, int z, int p, int q) {
case 7: // Assorted operations on accumulator/flags
switch (y) {
case 0:
rlc(f, a);
a = rlc(f, a);
break;
case 1:
rrc(f, a);
a = rrc(f, a);
break;
case 2:
rl(f, a);
a = rl(f, a);
break;
case 3:
rr(f, a);
a = rr(f, a);
break;
case 4:
daa(a, f);