This project has moved. For the latest updates, please go here.

Byte type for BNF

Jun 16, 2010 at 1:08 AM
Edited Jan 25, 2015 at 6:12 PM
I am trying to create a BNF for *.td files but need a new type, byte.

/ File format information /
FILE = :terrain_desc .
FILE_NAME = "Tile Definition" .
FILE_EXT = "td" .
FILE_TYPE = "d" .
FILE_TYPE_VER = "1" .

/ Base types /
terrain_desc_tiles ==> :uint {:byte} .

/ Format types /
terrain_desc ==> :terrain_desc_tiles .

EOF / End of file /

At each level of the quad tree, four bits are used to mark each tile as divided and then four bits are used to mark each tile as populated. See post http://forums.trainsim.com/vbts/showthread.php?p=1492509#post1492509 for a description of the TD format.

Update: I tried the above BNF and it works! I had not noticed that byte was a valid type in the documentation.

Edit: Forum link http://www.trainsim.com/vbts/showthread.php?282192-TD-file
Coordinator
Jun 19, 2010 at 2:48 PM

I can't remember what file it was for, but I added :byte (one byte unsigned integer) and :word (two bytes unsigned integer) to go with :dword (four byte unsigned integer) to the code. They're available in both binary and text files (they expect hex numbers of 2 and 4 characters respectively, like :dword expects 8 character hex numbers).