erkyrath / lectrote

The IF interpreter in an Electron shell
Other
248 stars 28 forks source link

Adding Z-Code support #70

Closed curiousdannii closed 7 years ago

curiousdannii commented 7 years ago

I saw Zarf's comment and thought I'd write a few notes because I'm about to go away for a few days. This will be so much easier once I adapt ZVM to use Glk, but that's not going to happen before IFComp! But for a very crude minimal embedding of Parchment you should only need to intercept these few places:

erkyrath commented 7 years ago

Thanks! I intend to look at this over the weekend. (Which is not quite soon enough for IFComp early risers, but we gotta manage real life.)

The big hole is going to be autosave. Adding autosave to Quixe was a big chunk of the original Lectrote development -- it wasn't a weekend task. So the first cut at Parchment integration is just not going to have that.

curiousdannii commented 7 years ago

Just remembered that the saving/restoring probably won't work properly with the current ZVM. So use the code from the gh-pages branch (commit f458c458).

Autosaving is nice, but far from essential, and if none of the other OSX terps have it then it won't be missed in the short term!

erkyrath commented 7 years ago

I have created a branch https://github.com/erkyrath/parchment/tree/lectrote (forked from https://github.com/curiousdannii/parchment/tree/gh-pages) which contains the changes I've made so far.

This is all hasty work, so don't just merge it wholesale. Some of the changes should probably be handled differently.

erkyrath commented 7 years ago

Obviously, I haven't looked at save/restore support at all. Will get to that tomorrow.

erkyrath commented 7 years ago

Okay, I've cleaned up.

The current additions to my lectrote branch (as compared to https://github.com/curiousdannii/parchment/tree/gh-pages) are:

I added save/restore support by replacing the library.fromRunner() method after I create the library object. See zplay.js.

The one thing I'm missing is the ability to return "save failed", for the save event. (This occurs if the user cancels the save dialog.)

curiousdannii commented 7 years ago

Good to see that you got this worked out fairly quickly! Are you expecting to keep zcode support in for some time? If so then I'll take a look about merging in some of your commits.

The one thing I'm missing is the ability to return "save failed", for the save event. (This occurs if the user cancels the save dialog.)

Pass the event object back but add a property 'result' set to 0.

erkyrath commented 7 years ago

Yes, merging the current branch would be good.

Feel free to come up with a cleaner way to signal that the storyfile is an already-loaded game file, and that the VM is already loaded. (These could be independent options.)

Pass the event object back but add a property 'result' set to 0

I am trying this but it doesn't work.

if (!fref) {
    /* Save dialog cancelled. Mark event as having failed. */
    event.result = 0;
    console.log('### failed', event);
}
//...
runner.fromParchment( event );

A cancelled SAVE still says "Ok." in the game output.

curiousdannii commented 7 years ago

Oh, sorry, I made a dumb error. I'm simply ORing the result with 1, which means you can't pass in 0. In zvm.debug.js try replacing with this line: (line 3422)

            this.variable( data.storer, data.result === undefined ? 1 : data.result );

I'll fix this in ZVM, but probably not immediately because I'm in the process of adding Z3 support, which is ending up being rather tricky. So you're probably best hand editing the lib files for now. I'll post back here when it's stable again. (Or send a pull request.)

erkyrath commented 7 years ago

That worked, thanks!

I am putting this task down as "done" for the moment. Let me know when Parchment reaches a new stable point and I will update Lectrote again.