aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/config.c4
-rw-r--r--src/irc.c4
-rw-r--r--src/irc.h3
-rw-r--r--src/main.c6
-rw-r--r--src/nio.c265
-rw-r--r--src/nio.h51
-rw-r--r--src/sio.s16
7 files changed, 101 insertions, 248 deletions
diff --git a/config/config.c b/config/config.c
index b753bbd..8d09e8e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -531,7 +531,7 @@ void detect_xl(void) {
return;
}
- yn("XL/XE detected, use extra RAM", use_xl_ram);
+ use_xl_ram = yn("XL/XE detected, use extra RAM", use_xl_ram);
if(!use_xl_ram) return;
os_to_ram();
@@ -565,7 +565,7 @@ void main(void) {
print("Version " VERSION "\n\n");
detect_dos();
- detect_xl();
+ // detect_xl(); // not yet
if(!load(0))
print("Using built-in default config.\n");
diff --git a/src/irc.c b/src/irc.c
index 6b2b599..f31d89c 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -756,7 +756,7 @@ int irc_read(void) {
if(!trip) return 1;
last_read_min = minutes;
- err = nstatus(conf->url);
+ err = nstatus();
if(err != 1) {
scr_display(SCR_SERVER);
@@ -779,7 +779,7 @@ int irc_read(void) {
ind_net_rx();
if(rxbuflen > 0) {
- err = nread(conf->url, rx_buf, rxbuflen);
+ err = nread(rx_buf, rxbuflen);
if(err != 1) {
ind_net_down();
print_errnum();
diff --git a/src/irc.h b/src/irc.h
index b0ff260..8ced02d 100644
--- a/src/irc.h
+++ b/src/irc.h
@@ -1,6 +1,3 @@
-/* 0 = no translation (used to use 3, CRLF) */
-#define FNET_TRANSLATION 0
-
#define MAX_IRC_MSG_LEN 512
#define streq(x,y) !strcmp(x,y)
diff --git a/src/main.c b/src/main.c
index 5535343..4a938b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,7 +78,7 @@ void txbuf_send(void) {
tx_buf[txbuflen++] = 0x0a;
ind_net_tx();
- nwrite(conf->url, tx_buf, txbuflen);
+ nwrite(tx_buf, txbuflen);
ind_net_idle();
txbuf_init();
}
@@ -95,7 +95,7 @@ int fn_connect(void) {
scr_print_current(conf->url);
scr_eol_current();
- err = nopen(conf->url, FNET_TRANSLATION);
+ err = nopen();
if(err != SUCCESS) {
scr_print_current("Connection failed: ");
@@ -118,7 +118,7 @@ int fn_connect(void) {
}
void fn_disconnect(void) {
- nclose(conf->url);
+ nclose();
// Restore old PROCEED interrupt.
PIA.pactl &= ~1; // disable interrupts
diff --git a/src/nio.c b/src/nio.c
index 399b06d..9deae3c 100644
--- a/src/nio.c
+++ b/src/nio.c
@@ -2,201 +2,110 @@
* N: I/O
*/
-#include "nio.h"
-#include "sio.h"
+/* "stripped down" version that harcodes some parameters! Don't
+ use this as example code for writing your own fujinet app! */
+
#include <atari.h>
#include <stddef.h>
+#include "nio.h"
+#include "sio.h"
+#include "config.h"
#define TIMEOUT 0x1f /* approx 30 seconds */
-unsigned char nunit(char* devicespec)
-{
- unsigned char unit=1;
-
- // Set unit to 1 unless explicitly specified.
- if (devicespec[1]==':')
- unit=1;
- else if (devicespec[2]==':')
- unit=devicespec[1]-0x30; // convert from alpha to integer.
- else
- unit=1;
-
- return unit;
+#define UNIT 1 /* only support one FujiNet connection! */
+
+/* 0 = no translation (used to use 3, CRLF) */
+#define TRANS 0
+
+static char get_status(void) {
+ if(OS.dcb.dstats != SUCCESS) {
+ // something went wrong
+ // do we need to return extended status?
+ if(OS.dcb.dstats == DERROR) {
+ nstatus();
+ return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error.
+ }
+ }
+ return OS.dcb.dstats; // Return SIO error or success
}
-unsigned char nopen(char* devicespec, unsigned char trans)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic = DFUJI; // Fuji Device Identifier
- OS.dcb.dunit = unit; // Unit number integer 1 through 4
- OS.dcb.dcomnd = 'O'; // Open
- OS.dcb.dstats = DWRITE; // sending to to SIO device
- OS.dcb.dbuf = devicespec; // eg: N:TCP//
- OS.dcb.dtimlo = TIMEOUT; // approximately 30 second timeout
- OS.dcb.dbyt = 256; // max size of our device spec
- OS.dcb.daux1 = OUPDATE; // Read and write
- OS.dcb.daux2 = trans; // CR/LF translation
- siov();
-
- if (OS.dcb.dstats!=SUCCESS)
- {
- // something went wrong
- // do we need to return extended status?
- if (OS.dcb.dstats==DERROR)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error.
- }
- }
- return OS.dcb.dstats; // Return SIO error or success
+static void set_defaults(void) {
+ OS.dcb.ddevic = DFUJI; // Fuji Device Identifier
+ OS.dcb.dunit = UNIT; // Unit number integer 1 through 4
+ OS.dcb.dtimlo = TIMEOUT; // approximately 30 second timeout
}
-unsigned char nclose(char* devicespec)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic = DFUJI;
- OS.dcb.dunit = unit;
- OS.dcb.dcomnd = 'C'; // Close
- OS.dcb.dstats = 0x00;
- OS.dcb.dbuf = NULL;
- OS.dcb.dtimlo = TIMEOUT;
- OS.dcb.dbyt = 0;
- OS.dcb.daux = 0;
- siov();
-
- if (OS.dcb.dstats!=SUCCESS)
- {
- // something went wrong
- // do we need to return extended status?
- if (OS.dcb.dstats==DERROR)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error.
- }
- }
- return OS.dcb.dstats; // Return SIO error or success.
+char nopen(void) {
+ set_defaults();
+ OS.dcb.dcomnd = 'O'; // Open
+ OS.dcb.dstats = DWRITE; // sending to to SIO device
+ OS.dcb.dbuf = conf->url; // eg: N:TCP//
+ OS.dcb.dbyt = 256; // max size of our device spec
+ OS.dcb.daux1 = OUPDATE; // Read and write
+ OS.dcb.daux2 = TRANS; // CR/LF translation
+ siov();
+
+ return get_status();
}
-unsigned char nstatus(char* devicespec)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic = DFUJI;
- OS.dcb.dunit = unit;
- OS.dcb.dcomnd = 'S'; // status
- OS.dcb.dstats = DREAD;
- OS.dcb.dbuf = OS.dvstat;
- OS.dcb.dtimlo = TIMEOUT;
- OS.dcb.dbyt = sizeof(OS.dvstat);
- OS.dcb.daux = 0;
- siov();
-
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended status
-}
+char nclose(void) {
+ set_defaults();
+ OS.dcb.dcomnd = 'C'; // Close
+ OS.dcb.dstats = 0x00;
+ OS.dcb.dbuf = NULL;
+ OS.dcb.dbyt = 0;
+ OS.dcb.daux = 0;
+ siov();
-unsigned char nread(char* devicespec, unsigned char* buf, unsigned short len)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic = DFUJI;
- OS.dcb.dunit = unit;
- OS.dcb.dcomnd = 'R'; // read
- OS.dcb.dstats = DREAD;
- OS.dcb.dbuf = buf;
- OS.dcb.dtimlo = TIMEOUT;
- OS.dcb.dbyt = OS.dcb.daux = len; // Set the buffer size AND daux with length
- siov();
-
- if (OS.dcb.dstats!=SUCCESS)
- {
- // something went wrong
- // do we need to return extended status?
- if (OS.dcb.dstats==DERROR)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error.
- }
- }
- return OS.dcb.dstats; // Return SIO error or success.
+ return get_status();
}
-unsigned char nwrite(char* devicespec, unsigned char* buf, unsigned short len)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic = DFUJI;
- OS.dcb.dunit = unit;
- OS.dcb.dcomnd = 'W'; // write
- OS.dcb.dstats = DWRITE;
- OS.dcb.dbuf = buf;
- OS.dcb.dtimlo = TIMEOUT;
- OS.dcb.dbyt = OS.dcb.daux = len;
- siov();
-
- if (OS.dcb.dstats!=SUCCESS)
- {
- // something went wrong
- // do we need to return extended status?
- if (OS.dcb.dstats==DERROR)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error.
- }
- }
- return OS.dcb.dstats; // Return SIO error or success.
+char nstatus(void) {
+ set_defaults();
+ OS.dcb.dcomnd = 'S'; // status
+ OS.dcb.dstats = DREAD;
+ OS.dcb.dbuf = OS.dvstat;
+ OS.dcb.dbyt = sizeof(OS.dvstat);
+ OS.dcb.daux = 0;
+ siov();
+
+ return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended status
}
-/* https://fujinet.online/wiki/?p=SIO-Command-%24FF-Reset-FujiNet */
-unsigned char nreset(void) {
- OS.dcb.ddevic = 0x70;
- OS.dcb.dunit = 1;
- OS.dcb.dcomnd = 0xff; /* reset */
- OS.dcb.dstats = DWRITE;
- OS.dcb.dbuf = 0;
- OS.dcb.dtimlo = TIMEOUT;
- OS.dcb.dbyt = 0;
- OS.dcb.daux = 0;
- siov();
-
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended status
+char nread(char *buf, unsigned short len) {
+ set_defaults();
+ OS.dcb.dcomnd = 'R'; // read
+ OS.dcb.dstats = DREAD;
+ OS.dcb.dbuf = buf;
+ OS.dcb.dbyt = OS.dcb.daux = len; // Set the buffer size AND daux with length
+ siov();
+
+ return get_status();
}
+char nwrite(char *buf, unsigned short len) {
+ set_defaults();
+ OS.dcb.dcomnd = 'W'; // write
+ OS.dcb.dstats = DWRITE;
+ OS.dcb.dbuf = buf;
+ OS.dcb.dbyt = OS.dcb.daux = len;
+ siov();
+
+ return get_status();
+}
-/* IRC doesn't need this */
-#if 0
-unsigned char nlogin(char* devicespec, char *login, char *password)
-{
- unsigned char unit=nunit(devicespec);
-
- OS.dcb.ddevic=0x71;
- OS.dcb.dunit=unit;
- OS.dcb.dcomnd=0xFD;
- OS.dcb.dstats=0x80;
- OS.dcb.dbuf=login;
- OS.dcb.dtimlo=0x1f;
- OS.dcb.dbyt=256;
- OS.dcb.daux=0;
- siov();
-
- if (OS.dcb.dstats!=1)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return ext err
- }
-
- OS.dcb.dcomnd=0xFE;
- OS.dcb.dstats=0x80;
- OS.dcb.dbuf=password;
- siov();
-
- if (OS.dcb.dstats!=1)
- {
- nstatus(devicespec);
- return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return ext err
- }
-
- return OS.dcb.dstats;
+/* https://fujinet.online/wiki/?p=SIO-Command-%24FF-Reset-FujiNet */
+char nreset(void) {
+ set_defaults();
+ OS.dcb.ddevic = 0x70;
+ OS.dcb.dcomnd = 0xff; /* reset */
+ OS.dcb.dstats = DWRITE;
+ OS.dcb.dbuf = 0;
+ OS.dcb.dbyt = 0;
+ OS.dcb.daux = 0;
+ siov();
+
+ return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended status
}
-#endif
+
diff --git a/src/nio.h b/src/nio.h
index bc63da8..63b4997 100644
--- a/src/nio.h
+++ b/src/nio.h
@@ -22,51 +22,12 @@
#define DVSTAT_PROTOCOL 2
#define DVSTAT_EXTENDED_ERROR 3
-/**
- * Open N: device with devicespec
- * @param devicespec - an N: device spec, e.g. N:TCP://FOO.COM:1234/
- * @param translation mode, 0=none, 1=cr, 2=lf, 3=cr/lf
- * @return error code, or 1 if successful.
- */
-unsigned char nopen(char* devicespec, unsigned char trans);
-
-/**
- * Close N: device with devicespec
- * @param devicespec - an N: device spec to close (the unit number is extracted)
- * @return error code, or 1 if successful.
- */
-unsigned char nclose(char* devicespec);
-
-/**
- * Get status of specific N: device
- * @param devicespec - an N: device spec to status (the unit number is extracted)
- * @return error code, or 1 if successful, DVSTAT is also filled with status info.
- *
- * Format of DVSTAT:
- * OS.dcb.dvstat[0] = # of bytes waiting LO
- * OS.dcb.dvstat[1] = # of bytes waiting HI
- * OS.dcb.dvstat[2] = reserved
- * OS.dcb.dvstat[3] = Error code of last I/O operation. !1 = error.
- */
-unsigned char nstatus(char* devicespec);
-
-/**
- * Read # of bytes from specific N: device.
- * @param devicespec - an N: device spec to read bytes from.
- * @param buf - The buffer to read into, must be at least as big as len.
- * @param len - The # of bytes to read (up to 65535)
- * @return error code, or 1 if successful, buf is filled with data.
- */
-unsigned char nread(char* devicespec, unsigned char* buf, unsigned short len);
-
-/**
- * Write # of bytes to specific N: device.
- * @param devicespec - an N: device spec to write to.
- * @param buf - The buffer to write to device, should be at least as big as len.
- * @param len - The # of bytes to write (up to 65535)
- * @return error code, or 1 if successful, buf is filled with data.
- */
-unsigned char nwrite(char* devicespec, unsigned char* buf, unsigned short len);
+char nopen(void);
+char nclose(void);
+char nstatus(void);
+char nread(char *buf, unsigned short len);
+char nwrite(char *buf, unsigned short len);
+char nreset(void);
/**
* Send username and password credentials
diff --git a/src/sio.s b/src/sio.s
index 3dd9191..829fbcb 100644
--- a/src/sio.s
+++ b/src/sio.s
@@ -1,17 +1,3 @@
;; Call SIO
-
.export _siov
- .export _rtclr
- .export _cold_start
-
-_siov: JSR $E459
- RTS
-
-_rtclr: LDA #$00
- STA $12
- STA $13
- STA $14
- RTS
-
-_cold_start:
- JMP $E477
+ _siov = $e459