Hello all. I’m playing around with reading Z-machine story files for the first time in Java. I’ve got the following function which reads a word from the memory
Path path = Paths.get(filePath);
byte[] data = Files.readAllBytes(path);
When i get the length from memory address 0x1A using this function I get that the length is 31231. Because the story file is an inform 5 file, I multiply this with 4 and get a length of 124924. Now the thing that confuses me is that if I run data.length in Java, I get back 124928. I expected this to be the same, but its actually 4 bytes larger. Is this to be expected?
I downloaded another z5 game from there (905.z5) and the difference there is larger. The story file reports it as being 86672, wheras the java byte[] array is 87040 in length, which interestingly is also an exact multiple of 256. So padding may definately be a possibility.
When you say it’s an Inform 5 file, I assume you mean it’s Z-machine version 5 file. Then it makes sense to mutiply the stored length by 4.
Z-machine files are often padded to a length which is a multiple of 256 or 512 bytes. The padding may consist of 0-bytes or other values. The padding is not to be considered part of the story data. When calculating the checksum for the file, the padding data must not be included either.