Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion emulator/include/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ BYTE8 HWReadKeyboardHardware(WORD16 address);
void HWWriteKeyboardHardware(WORD16 address,BYTE8 data);
void HWResetKeyboardHardware(void);
void HWKeyboardHardwareDequeue(int key);
int HWCheckKeyboardInterruptEnabled(void);

#endif
23 changes: 20 additions & 3 deletions emulator/src/hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ void HWSync(void) {
int key = HWQueueRemove(&keyboardQueue);
HWKeyboardHardwareDequeue(key);
//printf("Dequeue %x\n",key);
if (HWCheckKeyboardInterruptEnabled()) {
//printf("Interrupt\n");
CPUInterruptMaskable(); // fire IRQ
// Trigger a kbd interrupt (if it's not masked).
if ((IOReadMemory(0,0xD66C) & 0x04) == 0) {
// mark it pending
BYTE8 pending = IOReadMemory(0, 0xD660);
pending |= 0x04;
IOWriteMemory(0, 0xD660, pending);
}
}
if (IOReadMemory(0,0xD658) & 1) { // Timer on.
Expand All @@ -133,6 +136,20 @@ void HWSync(void) {
a++;
}
}

// Trigger an SOF interrupt (if it's not masked).
if ((IOReadMemory(0,0xD66C) & 0x01) == 0) {
// mark it pending
BYTE8 pending = IOReadMemory(0, 0xD660);
pending |= 0x01;
IOWriteMemory(0, 0xD660, pending);
}

// if there are any interrupts pending, tell the CPU to run the handler.
if (IOReadMemory(0, 0xD660) != 0) {
CPUInterruptMaskable();
}

}

// *******************************************************************************************************************************
Expand Down
8 changes: 0 additions & 8 deletions emulator/src/hw_8042.cpp.unused
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,3 @@ void HWWriteKeyboardHardware(WORD16 address,BYTE8 data) {
if (data == 0x60) {} // TODO: Enable interrupt ?
}
}

int HWCheckKeyboardInterruptEnabled(void) {
if ((IOReadMemory(0,0xD66C) & 0x04) == 0) { // Bit masked zero ?
IOWriteMemory(0,0xD660,4); // Set Pending Reg Bit 2
return -1;
}
return 0;
}
14 changes: 0 additions & 14 deletions emulator/src/hw_fifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,3 @@ BYTE8 HWReadKeyboardHardware(WORD16 address) {
void HWWriteKeyboardHardware(WORD16 address,BYTE8 data) {
// Should clear the queue here. Not really required ?
}

// *******************************************************************************************************************************
//
// Interrupt for new key enabled ?
//
// *******************************************************************************************************************************

int HWCheckKeyboardInterruptEnabled(void) {
if ((IOReadMemory(0,0xD66C) & 0x04) == 0) { // Bit masked zero ?
IOWriteMemory(0,0xD660,4); // Set Pending Reg Bit 2
return -1;
}
return 0;
}