-
Notifications
You must be signed in to change notification settings - Fork 71
Using FujiNet from fig FORTH
Because all I/O to FujiNet can occur using the standard SIO routines in the Atari Operating System ROM, it is possible to write words that can talk to FujiNet.
To help, you should define a screen of constants:
VOCABULARY FUJINET
FUJINET DEFINITIONS
BASE @ HEX
0300 CONSTANT DDEVIC
0301 CONSTANT DUNIT
0302 CONSTANT DCOMND
0303 CONSTANT DSTATS
0304 CONSTANT DBUF
0306 CONSTANT DTIMLO
0307 CONSTANT DRESVD
0308 CONSTANT DBYT
030A CONSTANT DAUX1
030B CONSTANT DAUX2
030A CONSTANT DAUX
E459 CONSTANT SIOV
BASE ! -->
And you should have a word that calls SIOV.
CODE (SIOV)
XSAVE STX,
SIOV JSR,
XSAVE LDX,
NEXT JMP,
With this, it's possible to make useful words, such as FRESET, which resets the fujinet.
BASE @ HEX
: FRESET ( -- )
70 DDEVIC C!
01 DUNIT C!
FF DCOMND C!
00 DSTATS C!
0000 DBUF !
0F DTIMLO C!
0000 DBYT !
0000 DAUX !
(SIOV) ;
BASE ! ;S
Because Fujinet's strings are fixed length and null terminated, the following word can display them:
SCR # 72
0 ( FLH - CEMIT word )
1
2
3
4 ( EMIT, but ignore null chars )
5
6 : CEMIT ( n -- )
7 DUP ( because 0= consumes it )
8 0= IF ( is char a null? )
9 DROP ( yes, drop it. )
10 ELSE ( otherwise ... )
11 EMIT ( Display it. )
12 THEN ; ( Done.)
13
14
15 -->
It works like EMIT, except that characters with a value of 0 (NULL) are not printed.
The following three words provide a way to define an in-line string, and to be able to put it into a buffer.
- ["] is the compiler word that skips over words inside the " while maintaining a length count for the ->STRING command.
- " provides the in-line string word, that works for both interpreting and compiling.
- <-STRING allows you to take an in-line string made with " and copy it to a destination buffer.
SCR # 7
0 ( N: STRING WORDS )
1
2 : ["]
3 R COUNT DUP 1+ R> + >R ;
4
5 : " ( start embedded string )
6 22 STATE @ IF
7 COMPILE ["] WORD HERE C@ 1+ ALLOT
8 ELSE
9 WORD HERE DUP C@ 1+ PAD SWAP CMOVE PAD COUNT
10 THEN ; IMMEDIATE
11
12 : <-STRING ( src len dest -- )
13 2DUP + >R
14 SWAP CMOVE R> 0 SWAP C! ;
15 -->
0 VARIABLE DSPEC 254 ALLOT ok ( 128 character buffer for devicespec )
" N:TNFS://RASPBERRYPI/FOO.TXT " DSPEC <-STRING ok
You can now use DSPEC, e.g. for the DBUF variable for an NOPEN command:
DSPEC DBUF ! ok
Since FujiNet uses SIOV for its I/O operations, the following error codes are returned in DSTATS (use C@):
- 138 TIMEOUT
- 139 Fujinet sent a NAK
- 144 Fujinet sent an ERROR
for 144, you need to send a status command to get the extended error code:
BASE @ HEX
02EA CONSTANT DVSTAT
: NSTATUS ( n -- )
70 DDEVIC C!
( n ) DUNIT C!
53 DCOMND C!
40 DSTATS C!
DVSTAT DBUF !
0F DTIMLO C!
0004 DBYT !
0000 DAUX !
(SIOV) ;
Where n is the unit number (for N1: use 1, N2: use 2, etc.)
You can then retrieve the error number via
: NERR ( -- n )
DVSTAT 3 + C@ ;
Any defined SIO command on one of these two pages can be sent via this method:
Copyright 2024 Contributors to the FujiNetWIFI project.
Join us on Discord: https://discord.gg/7MfFTvD
- Home
- What is FujiNet?
- The Definition of Done
- Board bring up for FujiNet Platform.IO code
- The Complete Linux CLI Guide
- The Complete macOS CLI Guide
- Development Env for Apps
- FujiNet-Development-Guidelines
- System Quickstarts
- FujiNet Flasher
- Setting up a TNFS Server
- FujiNet Configuration File: fnconfig.ini
- AppKey Registry - SIO Command $DC Open App Key
- CP-M Support
- BBS
- Official Hardware Versions
- Prototype Board Revisions
- FujiNet Development Guidelines
- Atari Programming
- Apple Programming
- C64 Programming
- ADAM Programming
- Testing Plan
- Hacker List
- FujiNet VirtualMachine