#oddeven_packing in Inform 6 compiler

Looking at the Inform 6 compiler source: I found a flag in the veneer routine Z__Region, called #oddeven_packing

I wonder if this flag is an old relic that is never set, or if it is used in some cases? If it is indeed used, does it affect v6 and/or v7 only?

For context: I have written my own replacement routines to quickly decide if a value can be a string or a routine, and this far I haven’t cared about this oddeven_packing feature. I wonder if I should.

I believe that would be this:

-B: In Z-code versions 6 and 7 (only), use different offset values for the packed addresses of routines and strings. In this mode, strings are distinguished by having odd (packed) addresses, whereas routines are even. This allows the game file to contain more executable code. (The default is -~B, where the routine and string segments use the same offset value, so string and routine values have different ranges.)

It’s a new (post-DM4) feature that’s very seldom used because most people don’t use Z6 and Z7.

3 Likes

It’s the -B option, and yes, it is v6/v7 only.

-B: In Z-code versions 6 and 7 (only), use different offset values for the packed addresses of routines and strings. In this mode, strings are distinguished by having odd (packed) addresses, whereas routines are even. This allows the game file to contain more executable code. (The default is -~B, where the routine and string segments use the same offset value, so string and routine values have different ranges.)

2 Likes

Ah, thanks!

And in this mode, are #code_offset and #strings_offset always positive numbers (when considered as signed 16-bit integers)?

In my experiments, this far they are always 256 and 257 - I can imagine that they always have these values, except they increase if the object count increases, so we can always tell a string address or routine address from an object ID. This would then mean that #code_offset and #strings_offset can never appear to be negative numbers, like they can when the -B option isn’t used.

BTW, I can compile a version 5 file using -B as well. The compiler doesn’t complain. The #code_offset and #strings_offset look like when doing a normal compilation, without -B, but the story file size gets a bit bigger than without -B. It seems like -B does make a difference, even in version 5.

Ooh, that’s a good question.

In my experiments, this far they are always 256 and 257 - I can imagine that they always have these values, except they increase if the object count increases, so we can always tell a string address or routine address from an object ID.

I think that’s right. #code_offset is 256 or (objcount+9), whichever is greater. With -B mode, #strings_offset is one higher.

BTW, I can compile a version 5 file using -B as well.

Heh. Treat that as unsupported behavior. It might have been intended to be supported, once, a long time ago… but I’d have to hunt around to verify that, and I don’t have time right now.

2 Likes