timotheeg / nestrischamps

A web-based OCR and restreamer system for NES Classic Tetris players
MIT License
45 stars 11 forks source link

Binary Frame Version 2 #103

Closed timotheeg closed 2 years ago

timotheeg commented 2 years ago

Context

As player skills skyrocketed (See Cheez's 2.3M score), the built-in limits of Nestrischamps have been reached.

The limiters of Nestrischamps were its compact binary frame format. Specifically the limitations of the frame format were as follows:

To support such high level play, Nestrischamps must be able to transmit what it sees on screen.

Approach

This PR introduces a binary format version 2. The format consumes 2 more bytes per frame with the following changes:

To accommodate bit and byte boundaries, the field order of the binary frame format have been changed as well.

The change is backward compatible. All replays should be able to handle .ngf files containing either v1 frames and v2 frames (although of course a .ngf file should NOT have multiple versions of frames therein).

The layout of a given game frame now looks like this:

Fiel Content Size in bits Range
1 version 3 7
2 game type 2 4
3 player num 3 7
4 game id 16 65,535
5 client time 28 268,435,455 (in ms; i.e. ~74h)
6 lines 12 4094
7 level 8 254
8 score 24 16,777,215
9 instant das 5 30
10 preview 3 7
11 cur piece das 5 30
12 cur piece 3 7
13 T 9 510
14 J 9 510
15 Z 9 510
16 O 9 510
17 S 9 510
18 L 9 510
19 I 9 510
20 field 400 2 bits x 10 columns x 20 lines

NestrisChamps - binary frame v2