Wox-xion Dev wiki

xvoe:yb

Yggdrasil binary (file)

The binary map format is based on chunks.
A chunk contains 3 byte parts :

chunk : < id | length | content >

The parser just has to read the id and the length.
If the chunk isn't interesting (known by id), it goes on and pass all content (known by length).

Structure

The id is a one byte data. Here is the list of known structures :

  • header : map definition container
    • name : map name (string)
      • location : map group (string)
    • author : map author (string)
    • width : inner width (int)
    • height : inner height (int)
    • altitude : altitude over the heightmap (int)
    • impl : implementation name (string)
  • ground : ground container
    • heightmap : heightmap container
    • grid : heightmap CDATA (the altitude, 1d list ⇒ converted into a 2d list level0=y, level1=x)
    • level : level container
      • id : level id/altitude (byte)
      • map : level CDATA (1d list)
    • accessibility: accessibility container
      • access : access container
        • id : accessibility id (string)
        • map : access CDATA (1d list)
  • core : core container
    • tile : tile definition
      • id : tile id (string)
      • src : tile source (string)
      • map : tile CDATA (1d list)
    • bgtile : ground tile definition
      • id : ground id (string)
      • src : ground source (string)
      • map : ground CDATA (1d list)
  • event : events container
    • eventname : event anchor name
    • eventpos : event location (3dpos)
  • security: security tag
    • algorithm : security algorithm
    • key : value computed on the non-security data

Chunks

Here is the definition of Chunkid which contains the list of valid chunkid and their respective code :

public enum Chunkid {
    // containers
    root(-0x01),
    reserved(0x00),
    header(0x01),
    ground(0x02, "bgtile"),
    access(0x03),
    core(0x04, "tile"),
    event(0x05),
    security(0x06),
    list1d(0x07),
    medium(0x08),
    // strings
    id(0x10, "name", "id"),
    src(0x11, "location"),
    impl(0x12, "impl"),
    author(0x13, "author"),
    // scalars
    // - integers
    size(0x20, "width", "height"),
    pos1i(0x21, "altitude"),
    pos2i(0x22),
    pos3i(0x23),
    rawlist(0x24),
    // - floats
    pos1f(0x30),
    pos2f(0x31),
    pos3f(0x32),
    floats(0x33),
    // - others
    pos1s(0x40),
    pos2s(0x41),
    pos3s(0x42),
    shorts(0x43),
    pos1b(0x44),
    pos2b(0x45),
    pos3b(0x46),
    bytes(0x47),
    pos1l(0x48),
    pos2l(0x49),
    pos3l(0x4a),
    longs(0x4b),
    pos1d(0x4c),
    pos2d(0x4d),
    pos3d(0x4e),
    doubles(0x4f),
    // unknown
    unknown(0xff);
    public final int code;
 
    private final String[] aliases;
 
    Chunkid(int code, String... aliases) {
        this.code = code;
        this.aliases = aliases;
    }
 
    public static Chunkid parse(byte b) {
        int code = b;
        if (code < 0) {
            code += 128;
        }
        assert code >= 0 : "Invalid byte !";
        return parse(code);
    }
 
    public static Chunkid parse(int code) {
        assert code >= 0 : "Invalid code !";
        for (Chunkid c : values()) {
            if (code == c.code) {
                return c;
            }
        }
        return unknown;
    }
 
    public static Chunkid parse(String name){
        for( Chunkid c : values()){
            for(String alias : c.aliases){
                if(alias.equals(name)){
                    return c;
                }
            }
        }
        return unknown;
    }
}

List and rawlist

A list/map is a general container whereas a rawlist/rawmap is specific container.

A list will contain other chunks whereas a rawlist won't. It will instead contains a list of size-defined raw bytes.

For example, /xw/ground/heightmap/grid could be a rawgrid. Then it would be a raw 1d list of bytes corresponding to the altitude of each case of the grid. It would then be translated into a 2d grid of low ints (byte in fact).

As a counterexample, a tile/bgtile may not be able to contain a rawlist since some of its cases may have attributes (luminosity or heightvar) which would imply non-standard-sized data.

Numerical values

There are different possible representations for the same numerical value (byte, short, int, long, float, double).

The yb format accepts any. Then you can use the one which is minimal (you may always, but are not restricted to).

It's up to you to know the type of rawlist and rawmap.

Posxt

The posxt ids correspond to specific list of numerical typed data.

Values of x

  • 1 : a unique value
  • 2 : a pair or a 2d coordinate
  • 3 : a 3d coordinate

Values of t

The type is a numerical type :

  • b : byte
  • s : short
  • i : int
  • l : long
  • f : float
  • d : double

Extensive

You can use larger list (even without defined bound) by using specific typed rawlists.

Their chund id is the complete type with 's'.

  • bytes
  • shorts
  • ints
  • longs
  • floats
  • doubles
xvoe/yb.txt · Dernière modification: 2011/09/04 23:35 (modification externe)