kaitai_struct_formats icon indicating copy to clipboard operation
kaitai_struct_formats copied to clipboard

Added GBMB GBR1 (broken) ksy format

Open ZetaTwo opened this issue 4 years ago • 7 comments

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?

ZetaTwo avatar Jan 24 '21 01:01 ZetaTwo

Updated PR based on comments in #401

ZetaTwo avatar Jan 24 '21 17:01 ZetaTwo

Updated PR based on your comments.

ZetaTwo avatar Jan 25 '21 12:01 ZetaTwo

Made an implementation using opaque types in the meanwhile. It's not fantastic but it works.

ZetaTwo avatar Mar 07 '21 03:03 ZetaTwo

Addressed both comments.

ZetaTwo avatar Jun 19 '21 23:06 ZetaTwo

Can this be merged?

ZetaTwo avatar Oct 31 '21 15:10 ZetaTwo

Have you used the wrong order of arguments of git rebase command?

KOLANICH avatar May 17 '22 19:05 KOLANICH

I did something wrong indeed but I believe I hade sorted it out now.

ZetaTwo avatar May 17 '22 19:05 ZetaTwo