kosarev / z80

Fast and flexible Z80/i8080 emulator with C++ and Python APIs
MIT License
63 stars 10 forks source link

Does a method exist to query if interrupts are disabled (python) #58

Closed mortenjc closed 4 weeks ago

mortenjc commented 1 month ago

Hey

Thanks for the project!

As you know by now, I use the python bindings.

I've come to the point where I need to emulate keyboard interrupts to progress further. So far I do it in a crude way: periodically i do a 'kbhit()' call. If a key was pressed I store the key value in a variable, save the current PC on the stack and set the PC to 0x38.

This barely works: I have been somewhat successful in getting resposes from the OS but it is vary flaky. I suspect that I might trigger 'interrupts' while already in a interrupt or when interrupts are disabled.

Do you have a suggestion for how to query for the ei/di status? Or any other good ideas for how to do this?

Best Morten

kosarev commented 1 month ago

9577ae87d042b1262c15b22a530170ee790e0389 added Z80State.int_disabled and Z80State.halted properties. I guess to do it properly you would also need to use on_handle_active_int() which takes a flag that is raised if interrupt is initiated?

mortenjc commented 1 month ago

Thanks. For now I am happy. I am sure I will get into new problems along the road. But first - holiday!

kosarev commented 4 weeks ago

Sounds like this one is done.