pysimm -- pre-alpha Z-machine interpreter in Python

As my first major Python project, really my first formal coding project, I’m working on a Z-code interpreter, which I’m calling pysimm. It’s in a really early pre-alpha stage right now. I’m using The Z-Machine Standards Document, version 1.0 and Aldo Cumani’s interpreter sfrotz as references. I’ve taught myself Python over the past couple weeks, and I really have no idea what I’m doing.

My major impetus for starting the project was the difficulty I had in compiling sfrotz on Windows. Windows Frotz is fantastic, but sfrotz is the interpreter I use most on my primary OS, and I thought it would be well-adapted to bundling with a story file. Python seemed like a good target system for building a more cross-platform replacement. I was aware of two previous unfinished (and apparently stalled) Python Z-code interpreter projects, but I wanted to start from scratch for some reason. If somehow I ever surpass these other projects, I’d like to invite other people to join the project.

My primary goals are cross-platform compatibility and standards compliance for Z-machine versions 1 through 8, including 6.

When I finally start working on the graphical console interface, I plan to use pyglet to handle all the graphics. I also want to include optional sound support using avbin. For MOD tracker music support, I’d probably have to use libmikmod through ctypes or something.

I’ve finally managed to implement opcode dictionaries, but that’s about all I’ve got so far. So there’s not much for anyone to look at right now, but I guess I’d like to know if I’m starting with the right approach here, and whether anyone has any better ideas about getting MOD support in my Python project.

MOD was never widely used; I wouldn’t consider it a high priority.

Are you doing curses I/O right now?

My experience with Python is that it’s cross-platform as long as you don’t ask Windows users to use it. :confused: But, perfectly reasonable as a learning project.

Haven’t even got the I/O yet; just working out some of the basics of loading bytecode into an array and recognizing opcodes. But I think I may start out using curses before moving on to pyglet. Or maybe something like urwid.

There’s always py2exe? I tried it out on my Windows partition and it seems like if I ever get this thing working I should be able to distribute binaries for people who don’t have Python installed on their Windows systems.

Also forgot to mention this is Python 2 for now. Mostly because the current stable version of pyglet isn’t compatible with Python 3.

I’ll be keeping my eye on this but unfortunately I have no time to help anytime soon (and when I do have time, I should work on Grotesque…).

py2exe is fine for packaging for Windows users. I used it for Grotesque. The only downside is that the executable is relatively huge since it has to include the entire Python interpreter.

Good luck!

I didn’t know about pyifbabel until I saw your signature, jakobcreutzfelt. I do believe I’ll want to use that.

OK, now we will have a Z-machine interpreter in Python. (I do not intend to join[size=55] because I write my own interpreters Fweep and Aimfiz; there are still a few things to add to Aimfiz such as full picture and sound support, although I believe it mostly works[/size]) Is there a more precise reason for the name “pysimm”?

What kind of features are you planning to implement and to not implement? (You can see the IF Wiki list of Z-machine interpreters for a list of some of the features which might be implement/not-implement, although you can also specify other things here)

Sure, let me know if you ever have any questions. The documentation remains…sparse.
(note that I had forgotten to update the URL in my signature; it’s fixed now)

Zarf also wrote a python blorb library, which might be useful to you:

It’s a reference to Perry Simm in A Mind Forever Voyaging. (I felt obliged to do something Infocom-themed for a name.)

Ideally I’d like to implement everything sfrotz implements, except maybe MOD support, and do it with a high degree of portability. I’m also giving it some simple GUI elements using Tkinter, so if somebody wants to run it without any command line arguments (say, by opening the executable from a graphical file explorer) they can choose a file to load via a dialog box. I think my favorite interpreter is actually Windows Frotz, but I hardly ever use Windows these days, and sfrotz is basically the closest thing to Windows Frotz that compiles natively on a Unix-like OS, so that’s what I’m trying to immitate. And because of the way Python handles namespaces &c. I’m motivated by the idea that the code for pysimm could be easily incorporated into other projects.

I’ll let you know. For now, though, I’ve already got the hang of using the treatyofbabel.babel module to extract story file data from a blorb file, and that’s a good start. Thanks.

Thanks for the tip. I’ll keep the script around and poke at it a bit.

If you ever decide to add MOD support, note that there’s also libmodplug. I found it very easy to work with, and it can play multiple files simultaneously.

So I’m revisiting this project for some fresh tinkering and I have an API dilemma and I’m mentioning it here in case someone happens to have some wxPython experience.

I was looking into using wxPython’s wx.TextCtrl widget as the primary interface, but I had no idea how to make it into an interactive console where only the line currently being written by the end-user is editable. And then I found the package, formerly known as PyCrust, which was created to provide a Python shell (and related services) based on wx.TextCtrl. I’m not sure whether this package would provide a better starting place for me, or if I’m better off just subclassing wx.TextCtrl myself and doing something with that (in which case I’ll need some example code to study).

Or maybe I should give up on wxPython altogether and use PyQt instead? I like QTads a lot. I was trying wxPython mostly because I gather it looks really native on most systems, but looking into Qt I think it might be just about as good in that arena? (I’ve experienced Qt applications looking alien on my GTK-based desktops until I’ve fiddled with the settings but that hasn’t happened much lately and it’s not such a big deal.)

Edited to add: It looks like I can repurpose to do what I want. It’s just not a very thoroughly documented class, so I have to stretch my novice skills a bit.