Tetron 4 output data format 1.1 (*.tet)

Introduction

This data format is extremly easy to read and to interpret.
You don't need to code or know any tetron logic.
You can simply read the chunks and display them straight forward onto any display device.

This fileformat is designed for maximum simplicity for players

The file format

Header chunk
common chunks
....

Common Chunks

size chunktype timestamp (ulong) id
size: size of the actual chunk (relative offset to the next chunk)
chunktype: chunk type
timestamp: time (in ms) passed since start
id: source matrix or player id (depends on buffer type)

offsets are useful for compatibility issuses.
future versions may introduce new data before the old versioned data.

All chunks are common chunks except of the header chunk:

standard chunks (single player) additional chunks (multiplayer, weapons)
Stone Weapon
Newstone Gameover
Matrix Revive
Start PSelect
Stop WSelect
  Message

Implementing a viewer requires only to handle the standardchunks. The additional chunks are for special events that occur in multiplayer or weapon games.

Header Chunk

size 0 version participants day month year (ushort)
hour minute winnerid score(hi) score (ushort) gamemode ppf
network 0 lines (ushort) duration (ushort) level lives
team id 1 team id 2 team id 3 team id 4 team id 5 team id 6 team id 7 team id 8
signature (16 bytes)
off: player 0 off: player 1 off: player 2 off: player 3
off: player 4 off: player 5 off: player 6 off: player 7
playernames...

size: size of header + playernames (offset of start chunk)
version: file/stream version *10 (e.g. 09=0.9; 10=1.0, etc..) currently 11 (=0xb)
day(1-31)/month(1-12)/year/hour(0-23)/minute(0-59): date of game
participants: number of players
winnerid: id of the winner (ignored if it is a highscore game)
level: reached level of (winning) player
lives: number of lives in the game at start
duration: duration of game in seconds
gamemode: gamemode ( 0=friendly,1=classic,2=reserved,3=weapons,4=quickrace,5=battlecrown,6=highscore game)
ppf: players per field
network: if 0, no network game other wise: bit 7 =1, bit1-3 local player id.
score: score of (winning) player, score is a 24 bit value. the first 16 bit are in score(ushort) and the upper 8 bits in score(hi)
lines: number of lines of (winning) player
team id n: team id assigned to the n.th player (see Team Id later in this document)
off: player n: offset (from the beginning of the file) of the name of player with the id n
signature: just for verification purposes to ensure that this file was written with tetron, you can ignore it, if you are writing a player or viewer or whatsoever. it is just for the server to avoid fakes or patched data.

Stone Chunk (player moves a stone)

size 1 timestamp (ulong) player id offset
stone style x y rot netstat 0 0 0
offset: relative offset in bytes of data style (relative to playerid)
x: x position of stone anchor (see Stone Styles and Anchors later in this document)
y: y position of stone anchor
rot: rotation index (0=origin, 1=90 degrees, 2=180 degrees, 3=270 degrees)
netstat: (see NetStatus later in this document)

NewStone Chunk (player gets a new stone)

size 2 timestamp (ulong) player id offset
oldstyle oldx oldy oldrot newstyle newx newy newrot
nextstyle credits(hi) credits(ushort) 0 0 0 0
offset: relative offset in bytes of oldstyle (relative to playerid)
oldstyle: old stone style that is now a fixed part of the field matrix
oldx: x position of old stone anchor
oldy: y position of old stone anchor
newstyle: the new current stone style
newx: x position of the new stone anchor
newy: y position of the new stone anchor
newrot: rotation index of the new stone
credits: credit score 24 bit value. credits(hi) are the upper 8 bit and credits(ushort) the lower 16 bit
nextstyle: stone style of the next stone

Matrix Chunk (field matrix)

size 3 timestamp (ulong) matrix id offset
lives nextstyle lines (ushort) level credits (hi) credits (ushort)
2lines 3lines 4lines packdata ...      
offset.: relative offset of packed data (relative to matrix id)
2lines: numer of 2 lines crushed in one move
3lines: number of 3 lines crushed in one move
4lines: number of tetris (crushed 4 lines in a move)
lives: number of lives
level: level in bytecode (11 = 10a, ... )

Start Chunk (start of the game)

size 4 timestamp (ulong) 0 0

Stop Chunk (end of the game)

size 5 timestamp (ulong) 0 0

Weapon Chunk (player activates a weapon)

size 10 timestamp (ulong) player id target id
weapon id byteparam wordparam (ushort)        

Gameover Chunk (player is dead, multiplayer only)

size 11 timestamp (ulong) player id 0

Revive Chunk (player revived)

size 12 timestamp (ulong) matrix id lives left

PSelect Chunk (player selection)

size 13 timestamp (ulong) player id target id

WSelect Chunk (weapon selection)

size 14 timestamp (ulong) player id weapon id

Message Chunk (message from player)

size 20 timestamp (ulong) source id target id
message...
target id: target player id. if target id is zero (0) then this message is a broadcast message to all participants