NagyD / SDLPoP

An open-source port of Prince of Persia, based on the disassembly of the DOS version.
GNU General Public License v3.0
1.1k stars 141 forks source link

Changes and fixes for the replay format #112

Closed Falcury closed 7 years ago

Falcury commented 7 years ago

Replay format changes:

Other/related fixes:

The replay format is now:

HEADER
magic number (3 bytes) = 0x50 0x31 0x52 (ASCII: "P1R")
replay format version number (1 byte) = 100 
    (current version number of the replay format)
replay format deprecation number (1 byte) = 1 
    (can be incremented to break backwards compatibility gracefully in the future)
creation time (8 bytes): Unix time (seconds since 1970) at capture
length of the custom levelset name (1 byte) (if zero, the replay uses the original levels)
levelset name: name of the custom levelset (i.e. the folder from which to load custom assets)

SAVESTATE
savestate size (4 bytes)
savestate: currently 0xA87 bytes

REPLAY OPTIONS
(this is split into 5 sections)
size of the options section 'features' (4 bytes)
options section 'features'
size of the options section 'enhancements' (4 bytes)
options section 'enhancements'
size of the options section 'fixes' (4 bytes)
options section 'fixes'
size of the options section 'custom_general' (4 bytes)
options section 'custom_general'
size of the options section 'custom_per_level' (4 bytes)
options section 'custom_per_level'

REPLAY DATA
start level (2 bytes): level number where the replay starts
saved random seed (2 bytes)
number of replay ticks (2 bytes): length of the replay in ticks
moves (1 byte per tick)

Moves are encoded as follows:
struct {     
    sbyte x : 2;
    sbyte y : 2;
    byte shift : 1;
    byte special : 3;
};