Main process loop found and other news

I’ve just been reading more of the Frotz code and I actually found the main process loop. It was much simpler than I anticipated. Actually, it delegates all the operations to an array of pointers to a function. In that way, it’s remarkably similar to an interpreted language, I think. Here’s the actual main loop:

One thing I’d like to figure out now is what the  finished  variable does. I’ve figured out it’s used to simulate interrupts, or at least I think it is.

This code links to the actual opcodes. They are stored in things like this:

This is an array of pointers to functions assigned in-line, which I find extremely cool. All the pointers are void to void because they take their arguments from and return their values into the Z-machine’s registry.

There will be more on this later in this blog, but even though these are op-codes, the ones I’m showing in the current blog post are actually directly related to interactive fiction: they move and look into game objects. This too is extremely cool.

So the main loop goes down the op codes in the game file, and executes the matching function based on which number in the array shown above or one like it a pointer to the function that executes the functionality of the op-code actually is. Again, there will be more about these functions later.

Finally, about two weeks ago, when I could not get Frotz for Windows to compile at all, I bought a boxed version of Microsoft Visual C++ on line to be physically delivered to the ETC-SV. It has still not arrived. I’m glad that I ended up not relying on it after all. I found a copy of Visual C++ 2003 online, as explained earlier in this blog. Then, of course, David Kinder told me he himself he used Visual Studio 2008…

UPDATE: The variable finished  was not, as I first suspected, about interrupts. It’s the stack of functions going on inside the Z-machine! So when it reaches zero, it means… I still don’t know but I’m going to figure it out!

UPDATE 2: The macro CODE_BYTE  expands to:

This is obviously how the Z-machine steps through its memory. Though I’m still not completely sure of what all of the pointers mean. There’s *pcp , *zmp , which I think stands for “Z memory” and a few others. I’ll have to figure that out as well.

 

Leave a Reply

Your email address will not be published. Required fields are marked *