I am creating Commodore PET on FPGA. I implemented my own 6502 kernel in Kansas Lava (the code is available at https://github.com/gergoerdi/mos6502-kansas-lava ), and placing enough IO around it ( https://github.com/gergoerdi/ eightbit-kansas-lava ) I was able to load the original Commodore ROM on it, get the blinking cursor and start typing.
However, after entering the classic BASIC program
10 PRINT "HELLO WORLD" 20 GOTO 10
it will work after a while (after a few seconds) with
?ILLEGAL QUANTITY ERROR IN 10
Since my code has fairly reasonable coverage for each code, and it passes AllSuiteA , I thought I would look for tests for more complex behavior, since I came up with Klaus Dormann interrupt testsuite . Running it in the Kansas Lava simulator showed a ton of errors in my initial interrupt implementation:
- Flag
I not set when entering the interrupt handler - Flag
B was everywhere - IRQ interrupts were completely ignored unless
I was set when they arrived (the correct behavior seems to be due to queue interrupts when I set and when it is disconnected, they should still be handled)
After fixing these, I can now successfully run the Klaus Dorman test, so I was hoping to get my car back to the real FPGA and the BASIC luck could go away.
However, the new version with fixed interrupt errors and passing the interrupt test in the simulator no longer responds to keyboard input or even simply blinks the cursor on a real FPGA. Please note that both keyboard input and cursor blinking are performed in response to an external IRQ (connected to the VBlank signal of the screen), so this means the fixed version somehow broke all interrupt handling ...
I am looking for any vague suggestions about what might happen wrong or how I can start debugging this.
The full code is available at https://github.com/gergoerdi/mos6502-kansas-lava/tree/interrupt-rewrite , offensive commit (the one that captures the test and breaks the PET): 7a09b794af . I understand that this is the exact opposite of minimally viable playback, but the change itself is tiny, because I have no idea where this is happening, and because the problem requires a machine that is efficient enough to load the Commodore PET ROM, I donβt know how I could squeeze it ...
Added:
I managed to reproduce the same problem on the same equipment with a very simple (I dare say, minimal) ROM instead of a PET ROM:
.org $C000 reset: ;; Initialize PIA LDY
interrupt emulation commodore lava 6502
Cactus
source share