kaitai_struct_formats
kaitai_struct_formats copied to clipboard
Added GBMB GBR1 (broken) ksy format
As per: https://github.com/ZetaTwo/gameboy-project/issues/1 I am opening this PR. However, this KSY does not actually properly parse the file format since I have not found a good way to implement it. The problem is described in: https://github.com/kaitai-io/kaitai_struct/issues/172
The problem is as follows. The file format consists of a sequence of "Objects". Each such object has (among other things) a Type, an ObjectID and a MasterID. If the MasterID is 0, it is a regular object, otherwise it is a "Sub-object" referencing its parent. In particular, there are two type: Map (type=2) and Map Tile Data (type=3) where the Map has two attributes: width and height and the size of the Map Tile Data object is determined by looking up its master object and repeating a record "width*height" times.
Basically, it would be required to write something like:
object_map_tile_data:
seq:
- id: master_id
type: u2
- id: data
type: object_map_tile_data_record
repeat: expr
#repeat-expr: master.tile_count
repeat-expr: 0
instances:
master:
value: find_master(master_id)
How would you suggest I approach this with Kaitai currently?
Updated PR based on comments in #401
Updated PR based on your comments.
Made an implementation using opaque types in the meanwhile. It's not fantastic but it works.
Addressed both comments.
Can this be merged?
Have you used the wrong order of arguments of git rebase
command?
I did something wrong indeed but I believe I hade sorted it out now.