diff --git a/apple/mouse-rom.h b/apple/mouse-rom.h index ba2b739..134e81f 100644 --- a/apple/mouse-rom.h +++ b/apple/mouse-rom.h @@ -16,7 +16,7 @@ static 0x68, 0xAA, 0x68, 0xEA, 0x68, 0x99, 0x80, 0xC0, 0x60, 0x99, 0x81, 0xC0, 0x68, 0xBD, 0x38, 0x06, 0xAA, 0x68, 0xA8, 0x68, 0xBD, 0x00, 0x02, 0x60, -0xC9, 0x0A, 0xB0, 0x04, 0x8D, 0xCF, 0xC0, 0x60, +0xC9, 0x10, 0xB0, 0x04, 0x8D, 0xCF, 0xC0, 0x60, 0x38, 0x60, 0x48, 0x78, 0x8D, 0xCE, 0xC0, 0xA2, 0x04, 0xBD, 0xB8, 0x06, 0x29, 0x0E, 0xD0, 0x01, 0x38, 0x68, 0x60, 0x8D, 0xCB, 0xC0, 0x18, 0x60, diff --git a/apple/mouse.cpp b/apple/mouse.cpp index aa29c91..8a82ff6 100644 --- a/apple/mouse.cpp +++ b/apple/mouse.cpp @@ -10,6 +10,8 @@ enum { SW_W_INITPR = 0x00, SW_W_HANDLEIN = 0x01, + + SW_R_ERR = 0x07, SW_R_HOMEMOUSE = 0x08, SW_R_POSMOUSE = 0x09, @@ -159,6 +161,7 @@ void Mouse::writeSwitches(uint8_t s, uint8_t v) g_vm->getMMU()->write(0x778+4, interruptsTriggered); g_vm->getMMU()->write(0x6B8+4, interruptsTriggered); // hack to appease ROM interruptsTriggered = 0; + g_cpu->deassertIrq(); break; case SW_W_CLAMPMOUSE: { @@ -198,7 +201,7 @@ void Mouse::loadROM(uint8_t *toWhere) toWhere[i] = pgm_read_byte(&romData[i]); } #else - printf("loading HD32 rom\n"); + printf("loading Mouse rom\n"); memcpy(toWhere, romData, 256); #endif } @@ -216,11 +219,10 @@ void Mouse::maintainMouse(int64_t cycleCount) { // Fake a 60Hz VBL in case we need it for our interrupts static int64_t nextInterruptTime = cycleCount + 17050; - if ( (status & ST_MOUSEENABLE) && (status & ST_INTVBL) && (cycleCount >= nextInterruptTime) ) { - g_cpu->irq(); + g_cpu->assertIrq(); interruptsTriggered |= ST_INTVBL; @@ -232,14 +234,14 @@ void Mouse::maintainMouse(int64_t cycleCount) if ( (status & ST_MOUSEENABLE) && (status & ST_INTMOUSE) && (xpos != lastXForInt || ypos != lastYForInt) ) { - g_cpu->irq(); + g_cpu->assertIrq(); interruptsTriggered |= ST_INTMOUSE; lastXForInt = xpos; lastYForInt = ypos; } else if ( (status & ST_MOUSEENABLE) && (status & ST_INTBUTTON) && lastButtonForInt != g_mouse->getButton()) { - g_cpu->irq(); + g_cpu->assertIrq(); interruptsTriggered |= ST_INTBUTTON; lastButtonForInt = g_mouse->getButton(); diff --git a/apple/mouserom.asm b/apple/mouserom.asm index a176d24..dfe1c65 100644 --- a/apple/mouserom.asm +++ b/apple/mouserom.asm @@ -85,7 +85,7 @@ INHandler: RTS SetMouse: - CMP #$0A ; values >= 10 are invalid + CMP #$10 ; values >= $10 are invalid BCS ExitWithError STA $C0CF ; soft switch 0x0F, hard-coded slot 4 for now RTS diff --git a/apple/mouserom.lst b/apple/mouserom.lst index a5699ea..076edc0 100644 --- a/apple/mouserom.lst +++ b/apple/mouserom.lst @@ -89,7 +89,7 @@ Current file: mouserom.asm 00C45F 1 60 RTS 00C460 1 00C460 1 SetMouse: -00C460 1 C9 0A CMP #$0A ; values >= 10 are invalid +00C460 1 C9 10 CMP #$10 ; values >= $10 are invalid 00C462 1 B0 04 BCS ExitWithError 00C464 1 8D CF C0 STA $C0CF ; soft switch 0x0F, hard-coded slot 4 for now 00C467 1 60 RTS diff --git a/cpu.cpp b/cpu.cpp index 532a3b1..461fd69 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -444,6 +444,16 @@ void Cpu::brk() cycles += 2; } +void Cpu::assertIrq() +{ + irqPending = true; +} + +void Cpu::deassertIrq() +{ + irqPending = false; +} + void Cpu::irq() { // If interrupts are disabled, then do nothing @@ -472,7 +482,6 @@ uint8_t Cpu::Run(uint8_t numSteps) uint8_t Cpu::step() { if (irqPending) { - irqPending = false; irq(); } @@ -1217,11 +1226,6 @@ uint16_t Cpu::popS16() return (msb << 8) | lsb; } -void Cpu::stageIRQ() -{ - irqPending = true; -} - void Cpu::realtime() { realtimeProcessing = true; diff --git a/cpu.h b/cpu.h index a90a59a..13b9fb3 100644 --- a/cpu.h +++ b/cpu.h @@ -151,6 +151,9 @@ class Cpu { void brk(); void irq(); + void assertIrq(); + void deassertIrq(); + uint8_t Run(uint8_t numSteps); uint8_t step(); @@ -161,8 +164,6 @@ class Cpu { uint8_t SP(); uint8_t P(); - void stageIRQ(); - protected: // Stack manipulation void pushS8(uint8_t b);