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