Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions c/common/netdev_soft.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ uint8_t net_device;
#else
#define BIN_ARG ""
#endif
#ifdef NET_PLATFORM /* plat_config.h: which machine this is, for the relay's statistics */
#define PF_ARG "&pf=" NET_PLATFORM
#else
#define PF_ARG ""
#endif
/* The longest: /net?game=16974&code=ABCD&bin=1&pf=element-zx-128k */
static char path[52];
#define MSGQ 4
#define E_BUILD 6
#define E_NOROOM 8
Expand Down Expand Up @@ -330,12 +337,11 @@ uint8_t net_status(net_status_t *st) {
}

uint8_t net_create(uint16_t build, uint8_t slots, const uint8_t *settings, uint8_t len, char code[5], uint8_t *slot) {
static char path[40];
char *p;
uint8_t r;
if (slots < 1 || slots > NET_SLOTS) return E_PARAM;
if (len > 16) len = 16;
p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(p, "&create=1" BIN_ARG)[0] = 0;
p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(p, "&create=1" BIN_ARG PF_ARG)[0] = 0;
p = put_u(put_s(out, "{\"op\":\"create\",\"game\":"), NET_GAME_ID);
p = put_u(put_s(p, ",\"build\":"), build);
p = put_u(put_s(p, ",\"slots\":"), slots);
Expand All @@ -349,10 +355,9 @@ uint8_t net_create(uint16_t build, uint8_t slots, const uint8_t *settings, uint8
}

uint8_t net_join(uint16_t build, const char *code, uint8_t *slot, uint8_t *slots, uint8_t *settings, uint8_t *len) {
static char path[40];
char *p;
uint8_t r;
p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(put_s(put_s(p, "&code="), code), BIN_ARG)[0] = 0;
p = put_u(put_s(path, "/net?game="), NET_GAME_ID); put_s(put_s(put_s(p, "&code="), code), BIN_ARG PF_ARG)[0] = 0;
p = put_u(put_s(out, "{\"op\":\"join\",\"game\":"), NET_GAME_ID);
p = put_u(put_s(p, ",\"build\":"), build);
put_s(put_s(put_s(p, ",\"code\":\""), code), "\"}")[0] = 0;
Expand Down
1 change: 1 addition & 0 deletions c/platform/amiga/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): the 68000 is big-endian */
#define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */
#define NET_PLATFORM "amiga" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/atari/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#define JOY_ATARI 1 /* the two joystick ports */
#define PLAT_ASM_COMPOSITE 1 /* cpu/6502/loops.s */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): ~7 bytes on FujiNet's bus, not ~50 */
#define NET_PLATFORM "atari-xl" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/atarist/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): the 68000 is big-endian */
#define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */
#define NET_PLATFORM "atari-st" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/c64/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#define PLAT_JOY_TYPES 2
#define PLAT_ASM_COMPOSITE 1 /* cpu/6502/loops.s */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */
#define NET_PLATFORM "c64" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/cpc/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
(unused with NET_BINARY_INPUT) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): about 7 bytes, not 50 */
#define PLAT_ASM_TEXT 1 /* print_string, hud_text, title_text* in cpu/z80/loops.c */
#define NET_PLATFORM "amstrad-cpc" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/pc/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c): Watcom pads structures */
#define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */
#define NET_PLATFORM "pc-dos" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
1 change: 1 addition & 0 deletions c/platform/web/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
#define PLAT_HASH_PORTABLE 1 /* the state hash field by field (core/game.c) */
#define PLAT_RUNAHEAD 1 /* a frame ahead of the agreed one in a match (docs/rollback-plan.md) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1) */
#define NET_PLATFORM "browser" /* the relay's statistics: &pf= (docs/net-protocol.md) */
#endif
5 changes: 5 additions & 0 deletions c/platform/zx/plat_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
(unused with NET_BINARY_INPUT) */
#define NET_BINARY_INPUT 1 /* input lines as binary messages (the relay's bin=1): about 7 bytes, not 50 */
#define PLAT_ASM_TEXT 1 /* print_string, hud_text, title_text* in cpu/z80/loops.c */
#ifdef ZX128 /* the relay's statistics: &pf= (docs/net-protocol.md) */
#define NET_PLATFORM "element-zx-128k"
#else
#define NET_PLATFORM "zx-spectrum-48k"
#endif
#endif
8 changes: 8 additions & 0 deletions docs/net-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ One socket per device. JSON frames:
<- {"op":"error","code":6..11,"text":"..."}
```

**Which machine** (`&pf=<id>` in the URL, optional): the machine's name for
the production relay's statistics, the id of its port in the catalog (`c64`,
`amiga`, `atari-xl`, `atari-st`, `amstrad-cpc`, `pc-dos`, `zx-spectrum-48k`,
`element-zx-128k`, `browser`). It changes nothing in a game; the production
relay counts an unknown id as if there were none, and `relay/relay.py` ignores
it. `NET_PLATFORM` in a platform's `plat_config.h` sets it; the MZ-800 needs
none, because the MZPico firmware makes the connection and names itself.

Rooms die 10 minutes after their last message (a host may wait a while). Codes are 4 letters from a
26-letter alphabet without I/O. A room is bound to (game, build).

Expand Down
Loading