Substitute for FSTACK in XZIP

I am doing a project on Milliways, and I just can’t seem to get FSTACK to work. Apparently, it is only allowed in YZIP, but YZIP causes a load of fatal errors. Here is the ZIPped file: rest.zip - Google Drive
I understand I’m being useless, but I just don’t know what to do and have been stuck for days. Thanks!

1 Like

Most people aren’t very familiar with the Infocom opcode names, so for everyone else, that’s the pop_stack opcode (EXT:21). It is indeed a Z6 addition. As multiple stacks don’t exist in any other Z-Machine versions it’s also unnecessary.

2 Likes

So… how do I fix the total error? I can’t take any action without the [That sentence is too complicated] occurring.

I don’t know what the library is doing sorry.

1 Like

While they might not know the answer right off the bat, the folks in the punyinform discord have some pretty deep retro roots. They might know where to look or who to ask. Possibly a long shot, but I’ll drop them a line about these posts.

1 Like

Great thanks!

1 Like

There’s a ZIL Facebook group. All the ZIL experts hang out there. I’ve pointed them to this thread in case they can help. If you want to check it out yourself, it’s at ZIL - Zork Implementation Language | Facebook

2 Likes

I’m already on it. Wait - I should have gone there also. :face_in_clouds: But thanks for posting!!

1 Like

This might work:

;"From the Z-Machine Standards Document v1.1, section 6.6:

In Version 6, the Z-machine understands a third kind of stack: a 'user stack', which is a table of words in dynamic memory. The first word in this table always holds the number of spare slots on the stack (so the initial value is the capacity of the stack). The Z-machine makes no check on stack under-flow (i.e., pulling more values than were pushed) which would over-run the length of the table if the program allowed it to happen."

;"EXT:21 15 6 pop_stack items stack

The given number of items are thrown away from the top of a stack: by default the system stack, otherwise the one given as a second operand."

<ROUTINE FSTACK (N S)
    <PUT .S 0 <+ <GET .S 0> .N>>
    <RTRUE>>

;"EXT:24 18 6 push_stack value stack ?(label)

Pushes the value onto the specified user stack, and branching if this was successful. If the stack overflows, nothing happens (this is not an error condition)."

<ROUTINE XPUSH (V S "AUX" C)
    <COND (<0? <SET C <GET .S 0>>>
           <RFALSE>)
          (ELSE
           <PUT .S .C .V>
           <PUT .S 0 <- .C 1>>
           <RTRUE>)>>
2 Likes

I don’t really see why you need FSTACK for XZIP. My guess is that you try to compile the “new parser” in XZIP, instead of YZIP, and there are calls to FSTACK that give errors. My recommendation is to stick to YZIP if you’re using the “new parser”, otherwise you’re in for a ton of hurt… The “new parser” was designed for YZIP and would probably not work with other versions without major rewrites.

5 Likes

Yes, you can imitate FSTACK with an array in RAM, but there are probably other aspects of the YZIP parser that won’t work in earlier versions of the Z-machine. Unfortunately most interpreters don’t support YZIP (version 6) because of its graphics model, which is a huge pain to implement compared to any other version. But there are some that do, and you can stick to those for testing.

3 Likes

My gut feeling is that this is probably not the case? At a quick glance, I don’t see any use of the v6 window, menu, or image opcodes, nor PRINTF (@print_form).

(I’m looking at the zillib entry here.)

I could easily have missed something, but I feel like a V5/8 port of zillib is feasible.

5 Likes

Alright, I’ll switch to… V5, V8, I don’t mind, and go from there. The new parser is gonna give me a lotta questions to go on here. :person_shrugging:

1 Like

Milliways

I think you main issue here is with this line in the parser.zil file, which is attempting to ‘flush’ the FSTACK.

<FSTACK .RES ,STATE-STACK>

As mentioned this is a V6 (YZIP) only command and fails when attempting to build as V5 or V8 : If you substitute this line with the pstack.zil defined FLUSH-PSTACK which defines itself based on the type (YZIP or not) - that should get you past the compile issue.

e.g.

;(Replace FSTACK with PSTACK defined FLUSH)
<FLUSH-PSTACK ,STATE-STACK .RES>

I have attached a ‘working’ copy of your original zip file - with a few tweaks to get a working Inventory and tidy the status line. You will probably want to revisit that to get it as you require :slight_smile: - Good luck with the project. AG

2 Likes