[I6lib] "Grammar properties might not work correctly"?

I ran into the following message when compiling my game: “**Warning: grammar properties might not work correctly **”.

The only information that I could find about it was the code adding the warning to the library and this newsgroup thread, with a fix. I used that fix, and it worked, the message is gone.

So apparently, if I understood correctly, the issue seemed to be that the dictionary starts before and ends after the address $8000. The problem is, when I look at both memory maps (before and after the fix), in both cases the dictionary starts before and ends after the address $8000 ! So it must be because of the 3rd condition, “-dict_end-dict_start is divisible by dict_entry_size”.

My question is: what does that condition do? I thought the number “-dict_end-dict_start” was supposed to be the dictionary size, except that it’s not; it’s not counted right in that case. For instance, if I add a useless array with 100 entries, both dict_start and dict_end are increased by 102, thus “-dict_end-dict_start” is decreased by 204 - this solves the problem providing 204 is not a multiple of your dict_entry_size, but it’s not exactly what was meant. If this number is supposed to be the dictionary size, it should be something like “$8000-dic_start + $8000+dict_end”.
And assuming the dictionary size was computed right, what is the condition supposed to check?

My other question: if this bug isn’t fixed or if I just ignore this warning, how bad could it break my game?

I include both my memory maps if someone wants to make sure I understood the addresses correctly.

Inform 6.32 for Win32 (18th November 2010)
[Compilé avec la version 2.4dev de la bibliothèque francophone.]
Dynamic ±--------------------+ 00000
memory | header |
±--------------------+ 00040
| abbreviations |
+ - - - - - - - - - - + 00148
| abbreviations table |
±--------------------+ 00208
| header extension |
±--------------------+ 00210
| property defaults |
+ - - - - - - - - - - + 0028e
| objects |
+ - - - - - - - - - - + 00a60
| object short names, |
| common prop values |
+ - - - - - - - - - - + 01dda
| class numbers table |
+ - - - - - - - - - - + 01dea
| symbol names table |
+ - - - - - - - - - - + 02917
| indiv prop values |
±--------------------+ 02a0e
| global variables |
+ - - - - - - - - - - + 02bee
| arrays |
+=====================+ 0393c
Readable| grammar table |
memory + - - - - - - - - - - + 04d3a
| actions |
+ - - - - - - - - - - + 04e80
| parsing routines |
+ - - - - - - - - - - + 04e82
| adjectives |
±--------------------+ 04e82
| dictionary |
+=====================+ 08240
Above | Z-code |
readable±--------------------+ 2d9a8
memory | strings |
±--------------------+ 514b0

Inform 6.32 for Win32 (18th November 2010)
[Compilé avec la version 2.4dev de la bibliothèque francophone.]
homeland.inf(15): Warning: Array “dictionary_push” declared but not used
Dynamic ±--------------------+ 00000
memory | header |
±--------------------+ 00040
| abbreviations |
+ - - - - - - - - - - + 00148
| abbreviations table |
±--------------------+ 00208
| header extension |
±--------------------+ 00210
| property defaults |
+ - - - - - - - - - - + 0028e
| objects |
+ - - - - - - - - - - + 00a60
| object short names, |
| common prop values |
+ - - - - - - - - - - + 01dda
| class numbers table |
+ - - - - - - - - - - + 01dea
| symbol names table |
+ - - - - - - - - - - + 02919
| indiv prop values |
±--------------------+ 02a10
| global variables |
+ - - - - - - - - - - + 02bf0
| arrays |
+=====================+ 039a2
Readable| grammar table |
memory + - - - - - - - - - - + 04da0
| actions |
+ - - - - - - - - - - + 04ee6
| parsing routines |
+ - - - - - - - - - - + 04ee8
| adjectives |
±--------------------+ 04ee8
| dictionary |
+=====================+ 082a8
Above | Z-code |
readable±--------------------+ 2da20
memory | strings |
±--------------------+ 51538
Compiled with 1 warning

(I didn’t pay attention to this set of changes back in the day, so I’m having to reverse-engineer the problem same as you.)

What’s going on: some code paths of the library store the negative of a dict word address. In the original library code (before L61006), the library simply tested (i < 0) to detect this case. The current code uses a more complicated test, which is safe unless the dictionary is aligned so that -i and i are both valid dict addresses (for some i).

So it’s not computing the dictionary size; it’s checking this alignment case. The dict_entry_size is normally 6 for Z-code. So, for example, if the dictionary starts at $7FF8 then there can’t be a collision, but if it starts at 0x7FF7 then there could be. (-$7FF7 == $8009 == 0x7FF7+3*6)

You should be able to avoid the warning by defining a dummy array of between 1 and 5 bytes.

Oh ok, that makes sense. So the fix is just to have a small array to “pad” it so that the warning doesn’t appear? No need to have a big array to push the dictionary in the “above $8000” memory zone, just to make sure there’s no unfortunate alignment?

Thanks for the explanation :slight_smile:

Yes.

The only nuisance is that you’ll probably have to keep tweaking the pad array length, as you add other game features and the memory layout bumps up. But the warning code is accurate (as far as I know), so if the warning doesn’t appear, you’re good.

As always, Zarf, thanks for your invaluable help :wink: