icculus/mojozork

Stone Barrow is accessible upon startup...

icculus opened this issue · 4 comments

ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights reserved.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726

West of House
You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.

>sw
Stone Barrow
You are standing in front of a massive barrow of stone. In the east face is a huge stone door which is open. You cannot see into the dark of the tomb.

This is obviously wrong, as this is the endgame room and shouldn't be accessible before you put all the treasures in the trophy case.

In frotz:

West of House
You are standing in an open field west of a white house, with a boarded front door.
There is a small mailbox here.

>sw
You can't go that way.

This happens in both multizork and mojozork!!

Same issue with the nailed-shut door between the Living Room and Strange Passage. You shouldn't be able to pass through until the cyclops has destroyed it, but in mojozork...

Living Room
You are in the living room. There is a doorway to the east, a wooden door with strange gothic lettering to the west, which appears to be nailed shut, a trophy case, and a large oriental rug in the center of the room.
Above the trophy case hangs an elvish sword of great antiquity.
A battery-powered brass lantern is on the trophy case.

>w
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

...in frotz...

Living Room
You are in the living room. There is a doorway to the east, a wooden door with
strange gothic lettering to the west, which appears to be nailed shut, a trophy
case, and a large oriental rug in the center of the room.
Above the trophy case hangs an elvish sword of great antiquity.
A battery-powered brass lantern is on the trophy case.

>w
The door is nailed shut.

This is the relevant code in zork1, I think. It's just part of the object specification:

<ROOM WEST-OF-HOUSE
      (IN ROOMS)
      (DESC "West of House")
      (NORTH TO NORTH-OF-HOUSE)
      (SOUTH TO SOUTH-OF-HOUSE)
      (NE TO NORTH-OF-HOUSE)
      (SE TO SOUTH-OF-HOUSE)
      (WEST TO FOREST-1)
      (EAST "The door is boarded and you can't remove the boards.")
      (SW TO STONE-BARROW IF WON-FLAG)
      (IN TO STONE-BARROW IF WON-FLAG)
      (ACTION WEST-HOUSE)
      (FLAGS RLANDBIT ONBIT SACREDBIT)
      (GLOBAL WHITE-HOUSE BOARD FOREST)>

It's the IF WON-FLAG part. I checked, and the WON-FLAG is definitely not set (unless the Z-Machine is reading from the wrong piece of memory, I guess), so there's something broken about that test.

Start zork1 in mojozork, run sw to try to enter the Stone Barrow, and CTRL-C to exit the game. Roughed in some debug output into frotz and this is where it goes wrong:

In mojozork:

pc=8B01 opcode=65 ('je') [4,4]
pc=8B05 opcode=80 ('loadb') [1C37,1]
pc=8B09 opcode=174 ('load') [9C]
pc=8B0C opcode=160 ('jz') [9C]

In frotz:

pc=8B01 opcode=65 [4,4]
pc=8B05 opcode=80 [1C37,1]
pc=8B09 opcode=174 [9C]
pc=8B0C opcode=160 [0]

So it's the jz jumping on the wrong value for whatever reason.

This is the disassembly of that...

 8b01:  JE              L01,#04 [FALSE] 8b34
 8b05:  LOADB           L00,#01 -> -(SP)
 8b09:  LOAD            [(SP)+] -> -(SP)
 8b0c:  JZ              (SP)+ [TRUE] 8b1a

...maybe that LOAD is pushing and popping the stack in the wrong order?