Some Py65 Emulator Enhancements

Topics pertaining to the emulation or simulation of the 65xx microprocessors and their peripheral chips.
Post Reply
tmr4
Posts: 147
Joined: 19 Feb 2022

Some Py65 Emulator Enhancements

Post by tmr4 »

TLDR: find some Py65 enhancements on my GitHub including support for the 65816, a real-time debug window and a few basic VIA and ACIA interrupts.

As a frequent reader I've gotten a lot of great information for my 6502 builds from the forum. Thanks to everyone for making this a great resource for hobbyists. I thought I'd share a few things I've done recently.

On the emulation side of things, I've worked with Py65 to help develop a version of Forth for my 6502 build. I wouldn't have had the patience to debug the program on my hardware, so Py65 was indispensable. I got my first introduction to Python by modifying Py65 to simulate mass storage access to test my Forth's Block word set.

With some Python experience under my belt, I decided adding some basic VIA and ACIA interrupt support so I could use my hardware binary directly in Py65. Maintaining a separate version of my code for Py65 was actually easier than modifying Py65 to handle the interrupts I was using. I'd say in most cases that's the way to go, but I haven't missed maintaining two versions of my code.

At this point, just for fun, I decided to add a real-time debug window to Py65. This is useful to examine what's going on while your program is running and without messing up your program's console I/O. See a sample screenshot here.

At this point my focus was shifting toward the 65816 but I was hesitant to get too far into a build without having an emulator. Given my experience with modifying Py65, I decided to take a stab at adding support for the 65816. I figured this would be fairly straight forward, but it was a lot of work (and it still isn't complete).

I've consolidated all of these enhancements into a local package that works alongside Py65. You can find out more at my py65816 repository. The features are pretty rough right now. I'm not sure if Py65 is being worked on anymore or if my enhancements have much appeal generally, but if so, perhaps someday they'll be of sufficient quality to be included.

I'd appreciate any suggestions for improvement.

Thanks
Terrance
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Some Py65 Emulator Enhancements

Post by BigEd »

Nice one Terrance, thanks for sharing! (And welcome!)
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Some Py65 Emulator Enhancements

Post by tmr4 »

BigEd wrote:
Nice one Terrance, thanks for sharing! (And welcome!)
Thanks for the welcome!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Some Py65 Emulator Enhancements

Post by BigEd »

I wonder, did you try running with Pypy? It's a faster Python than the usual one.
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Some Py65 Emulator Enhancements

Post by tmr4 »

I'm not familiar with Pypy. I'll have to check it out.
User avatar
cjs
Posts: 759
Joined: 01 Dec 2018
Location: Tokyo, Japan
Contact:

Re: Some Py65 Emulator Enhancements

Post by cjs »

BTW, you can probably get a significant speedup by using a bytearray instead of an int[] for the memory. That made for a very noticeable speedup in my Python 6800 simulator. That said, I don't think I've tried this with py65, and I don't know what knock-on effects this might have.

As far as the coding side of things, you might consider pytest. My unit tests for the 6800 instructions are less than 20% the length of those for py65 (1109 lines vs. 6065) and I think overall a lot clearer and easier to read; much of that is due to the facilities offered by pytest (particularly the ability to write one test and have it run with many different test vectors).
Curt J. Sampson - github.com/0cjs
tmr4
Posts: 147
Joined: 19 Feb 2022

Re: Some Py65 Emulator Enhancements

Post by tmr4 »

I've ported the py65 engine core to Typescript which greatly improved performance. I've also developed a Debug Adapter which allows debugging within Visual Studio Code. More detail at my Github db65xx.

For testing, I've just directly run the Klaus Dormann 6502 functional tests. This misses the 65816 side of things, but I'm ok with that.
Post Reply