Skip to content

JS5 Protocol

The JS5 protocol is installed by INIT_JS5.

Each inbound JS5 frame is exactly six bytes: a one-byte opcode followed by five bytes of opcode-specific data. The server accepts:

Opcode Name Remaining five bytes
0 Prefetch request Archive ID (1 byte), group ID (4 bytes)
1 Urgent request Archive ID (1 byte), group ID (4 bytes)
2 Logged in Ignored; sets the client's logged-in state to true
3 Logged out Ignored; sets the client's logged-in state to false
4 Update XOR key Ignored
6 Connected Ignored
7 Disconnect Ignored

Unknown opcodes raise a protocol error. Request packets enter separate urgent and prefetch queues; the server selects urgent requests first. Requests are served from the archive directory selected by the game and language in the hello handshake.

A file response is sent in 512-byte blocks. The first block starts with archive ID (1 byte), group ID (4 bytes), compression type (1 byte; bit 0x80 is set for prefetch responses), and file size (4 bytes), followed by file data. Continuation blocks begin with 0xFF followed by data.

First block (512 bytes maximum)
+----------------+----------------+----------------+----------------+------------------+
| Archive ID     | Group ID       | Compression    | File size      | File data        |
| 1 byte         | 4 bytes        | 1 byte         | 4 bytes        | up to 502 bytes  |
+----------------+----------------+----------------+----------------+------------------+
                 <---------------- 10-byte response header ---------------->

Each continuation block (512 bytes maximum)
+----------------+----------------------------------------------------------+
| 0xFF           | File data                                                |
| 1-byte marker  | up to 511 bytes                                          |
+----------------+----------------------------------------------------------+

The 0xFF marker precedes the file data in every continuation block; it is not part of the file data.