mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-10 10:29:43 +00:00
Add keyboard interrupt handling (TBC)
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
e1b838355e
commit
2060989ac7
@ -93,7 +93,7 @@ namespace EightBit {
|
|||||||
DisplayControlStatus = Processor::Bit1, // LCDC Status
|
DisplayControlStatus = Processor::Bit1, // LCDC Status
|
||||||
TimerOverflow = Processor::Bit2, // Timer Overflow
|
TimerOverflow = Processor::Bit2, // Timer Overflow
|
||||||
SerialTransfer = Processor::Bit3, // Serial Transfer
|
SerialTransfer = Processor::Bit3, // Serial Transfer
|
||||||
Keypad = Processor::Bit3 // Hi-Lo of P10-P13
|
KeypadPressed = Processor::Bit3 // Hi-Lo transition of P10-P13
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LcdcControl {
|
enum LcdcControl {
|
||||||
@ -217,29 +217,29 @@ namespace EightBit {
|
|||||||
void loadBootRom(const std::string& path);
|
void loadBootRom(const std::string& path);
|
||||||
void loadGameRom(const std::string& path);
|
void loadGameRom(const std::string& path);
|
||||||
|
|
||||||
void pressUp() { m_upPressed = true; }
|
void pressUp(bool pressed = true) { triggerKeypadInterrupt(m_upPressed = pressed); }
|
||||||
void releaseUp() { m_upPressed = false; }
|
void releaseUp() { pressUp(false); }
|
||||||
|
|
||||||
void pressDown() { m_downPressed = true; }
|
void pressDown(bool pressed = true) { triggerKeypadInterrupt(m_downPressed = pressed); }
|
||||||
void releaseDown() { m_downPressed = false; }
|
void releaseDown() { pressDown(false); }
|
||||||
|
|
||||||
void pressLeft() { m_leftPressed = true; }
|
void pressLeft(bool pressed = true) { triggerKeypadInterrupt(m_leftPressed = pressed); }
|
||||||
void releaseLeft() { m_leftPressed = false; }
|
void releaseLeft() { pressLeft(false); }
|
||||||
|
|
||||||
void pressRight() { m_rightPressed = true; }
|
void pressRight(bool pressed = true) { triggerKeypadInterrupt(m_rightPressed = pressed); }
|
||||||
void releaseRight() { m_rightPressed = false; }
|
void releaseRight() { pressRight(false); }
|
||||||
|
|
||||||
void pressA() { m_aPressed = true; }
|
void pressA(bool pressed = true) { triggerKeypadInterrupt(m_aPressed = pressed); }
|
||||||
void releaseA() { m_aPressed = false; }
|
void releaseA() { pressA(false); }
|
||||||
|
|
||||||
void pressB() { m_bPressed = true; }
|
void pressB(bool pressed = true) { triggerKeypadInterrupt(m_bPressed = pressed); }
|
||||||
void releaseB() { m_bPressed = false; }
|
void releaseB() { pressB(false); }
|
||||||
|
|
||||||
void pressSelect() { m_selectPressed = true; }
|
void pressSelect(bool pressed = true) { triggerKeypadInterrupt(m_selectPressed = pressed); }
|
||||||
void releaseSelect() { m_selectPressed = false; }
|
void releaseSelect() { pressSelect(false); }
|
||||||
|
|
||||||
void pressStart() { m_startPressed = true; }
|
void pressStart(bool pressed = true) { triggerKeypadInterrupt(m_startPressed = pressed); }
|
||||||
void releaseStart() { m_startPressed = false; }
|
void releaseStart() { pressStart(false); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uint8_t& reference(uint16_t address, bool& rom) {
|
virtual uint8_t& reference(uint16_t address, bool& rom) {
|
||||||
@ -325,6 +325,11 @@ namespace EightBit {
|
|||||||
mask(ADDRESS().word, masking);
|
mask(ADDRESS().word, masking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void triggerKeypadInterrupt(bool pressed) {
|
||||||
|
if (pressed)
|
||||||
|
triggerInterrupt(Interrupts::KeypadPressed);
|
||||||
|
}
|
||||||
|
|
||||||
void Bus_WritingByte(uint16_t address);
|
void Bus_WritingByte(uint16_t address);
|
||||||
void Bus_WrittenByte(uint16_t address);
|
void Bus_WrittenByte(uint16_t address);
|
||||||
void Bus_ReadingByte(uint16_t address);
|
void Bus_ReadingByte(uint16_t address);
|
||||||
|
@ -151,13 +151,12 @@ void EightBit::GameBoy::Bus::Bus_ReadingByte(const uint16_t address) {
|
|||||||
break;
|
break;
|
||||||
case NR52:
|
case NR52:
|
||||||
pokeRegister(NR52,
|
pokeRegister(NR52,
|
||||||
m_soundChannelEnabled[0]
|
(int)m_soundChannelEnabled[0]
|
||||||
| (m_soundChannelEnabled[1] << 1)
|
| (m_soundChannelEnabled[1] << 1)
|
||||||
| (m_soundChannelEnabled[2] << 2)
|
| (m_soundChannelEnabled[2] << 2)
|
||||||
| (m_soundChannelEnabled[3] << 3)
|
| (m_soundChannelEnabled[3] << 3)
|
||||||
| Processor::Bit4 | Processor::Bit5 | Processor::Bit6
|
| Processor::Bit4 | Processor::Bit5 | Processor::Bit6
|
||||||
| (m_soundEnabled << 7)
|
| (m_soundEnabled << 7));
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// LCD Display Registers
|
// LCD Display Registers
|
||||||
@ -283,7 +282,7 @@ void EightBit::GameBoy::Bus::Bus_WrittenByte(const uint16_t address) {
|
|||||||
case BASE + NR51:
|
case BASE + NR51:
|
||||||
break;
|
break;
|
||||||
case BASE + NR52:
|
case BASE + NR52:
|
||||||
m_soundEnabled = value & Processor::Bit7;
|
m_soundEnabled = (value & Processor::Bit7) != 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BASE + LCDC:
|
case BASE + LCDC:
|
||||||
|
@ -376,7 +376,7 @@ int EightBit::GameBoy::LR35902::singleStep() {
|
|||||||
current += interrupt(0x50);
|
current += interrupt(0x50);
|
||||||
} else if (ime && (masked & Bus::Interrupts::SerialTransfer)) {
|
} else if (ime && (masked & Bus::Interrupts::SerialTransfer)) {
|
||||||
current += interrupt(0x58);
|
current += interrupt(0x58);
|
||||||
} else if (ime && (masked & Bus::Interrupts::Keypad)) {
|
} else if (ime && (masked & Bus::Interrupts::KeypadPressed)) {
|
||||||
current += interrupt(0x60);
|
current += interrupt(0x60);
|
||||||
} else {
|
} else {
|
||||||
current += isHalted() ? 1 : step();
|
current += isHalted() ? 1 : step();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user