Register
BEdit » Wiki

BEdit Wiki

Featured Article: Tutorial HHA version 0 - Part 2 A Dynamic Language

This is part 2 of specifying HHA file format in BEdit layout language.

To recap, we left off having the following output:

>bedit.exe -layout hha.bet -data v0_hhas\intro_art.hha
hha_file
hha_header (.Header)
    0h            MagicValue                                     "hhaf"
   04h               Version                                          0
   08h              TagCount                                        109
   0Ch        AssetTypeCount                                         21
   10h            AssetCount                                         55
   14h                  Tags                                        2Ch
   1Ch            AssetTypes                                      3 94h
   24h                Assets                                      4 90h

hha_tag (.Tags[0])
   2Ch                    ID                             Tag_Smoothness
   30h                 Value                                   0.000000

...

hha_asset_type (.AssetTypes[0])
03 94h                TypeID                                 Asset_None
03 98h       FirstAssetIndex                                          0
03 9Ch OnePastLastAssetIndex                                          0

...

hha_asset (.Assets[0])
04 90h            DataOffset                                         0h
04 98h         FirstTagIndex                                          0
04 9Ch   OnePastLastTagIndex                                          0
04 A0h            DataHeader 0x0000000000000000000000000000000000000000

hha_asset (.Assets[1])
04 B4h            DataOffset                                      C 4Ch
04 BCh         FirstTagIndex                                          1
04 C0h   OnePastLastTagIndex                                          3
04 C4h            DataHeader 0x29090000800400000000003F0000003F00000000

and we would like to have the DataHeader displayed as it's proper type rather than just arbitrary bytes.

The type in question is

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
struct hha_asset
{
    u(8, hex) DataOffset;
    u32 FirstTagIndex;
    u32 OnePastLastTagIndex;
    /* TODO(Jens): We'll soon see how to get this behavior back.
    union
    {
        hha_bitmap Bitmap; // sizeof(hha_bitmap) == 4*4
        hha_sound Sound; // sizeof(hha_sound) == 3*4
        hha_font Font; // ...