Skip to content

N: Game Developer Cheat Sheet

europlus edited this page Sep 23, 2024 · 4 revisions

BASIC Networking Cheat Sheet

Before you begin

  1. Start with TNFS://atari-apps.irata.online/Games/lightcycles.atr.
  2. Use dupdsk on the disk to duplicate it to a new disk
  3. Boot the new disk.

Opening a client connection to another Atari (or server)

OPEN #1,12,0,"N:TCP://OTHER.ATARI.ADDRESS:PORT/"

Opening a listening socket (to accept a connection from another Atari)

OPEN #1,12,0,"N:TCP://:PORT/"

Listening for a connection

100 IF PEEK(748)=0 THEN 100
110 XIO 65,#1,12,0,"N:":REM ACCEPT THE CONNECTION, #1 IS NOW CONNECTED TO THE OTHER ATARI

Sending

PRINT #1;"SENDING SOME STUFF"

PRINT #1;A;",";B;",";C;",";D:REM SENDING MULTIPLE NUMERIC VALUES

PUT #1,A:XIO 15,#1,12,0,"N:":REM SENDING ONE BYTE WITH A FLUSH

Receiving Data

100 STATUS #1,A:IF PEEK(746)=0 THEN 200:REM GO DO SOMETHING ELSE, NOTHING HERE.
110 INPUT #1;A$:REM RECEVING THAT STRING FROM ABOVE
120 INPUT #1,A,B,C,D:REM GETTING FOUR NUMERIC VALUES
130 GET #1,A:REM GETTING ONE BYTE.

Tip

If you do a GET or an INPUT, and nothing is waiting, the program will block, waiting for input. This can be used to your advantage to synchronize the two end points, see the reversi example.

Closing the connection

CLOSE #1

Reversi Example

N: TCP Game Example: Reversi

Light Cycles Example

N: TCP Game Example: Light Cycles

Clone this wiki locally