diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-03-28 07:26:46 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-03-28 07:26:46 -0400 |
| commit | 87b234ba73e9abb4ecb8966ef631a0d7b8f5915a (patch) | |
| tree | 8435c18071937d092e3265bb4c708caab24b9135 /src | |
| parent | 898cfeb8a558245fc48bbba948c16205509e6a11 (diff) | |
| download | fujinet-chat-87b234ba73e9abb4ecb8966ef631a0d7b8f5915a.tar.gz | |
Save some more bytes (strip down nio.c API).
Diffstat (limited to 'src')
| -rw-r--r-- | src/irc.c | 4 | ||||
| -rw-r--r-- | src/irc.h | 3 | ||||
| -rw-r--r-- | src/main.c | 6 | ||||
| -rw-r--r-- | src/nio.c | 132 | ||||
| -rw-r--r-- | src/nio.h | 51 | ||||
| -rw-r--r-- | src/sio.s | 16 |
6 files changed, 79 insertions, 133 deletions
@@ -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(); @@ -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) @@ -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 @@ -2,21 +2,28 @@ * 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 */ -#define UNIT 1 /* only support one FujiNet! */ +#define UNIT 1 /* only support one FujiNet connection! */ + +/* 0 = no translation (used to use 3, CRLF) */ +#define TRANS 0 -static char get_status(char *devicespec) { +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(devicespec); + nstatus(); return OS.dvstat[DVSTAT_EXTENDED_ERROR]; // return extended error. } } @@ -24,86 +31,81 @@ static char get_status(char *devicespec) { } 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 + 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 nopen(char* devicespec, unsigned char trans) -{ +char nopen(void) { set_defaults(); - OS.dcb.dcomnd = 'O'; // Open - OS.dcb.dstats = DWRITE; // sending to to SIO device - OS.dcb.dbuf = devicespec; // 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(devicespec); + 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 nclose(char* devicespec) -{ +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(); - - return get_status(devicespec); + OS.dcb.dcomnd = 'C'; // Close + OS.dcb.dstats = 0x00; + OS.dcb.dbuf = NULL; + OS.dcb.dbyt = 0; + OS.dcb.daux = 0; + siov(); + + return get_status(); } -unsigned char nstatus(char* devicespec) -{ +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 + 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 } -unsigned char nread(char* devicespec, unsigned char* buf, unsigned short len) -{ +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(); + 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(devicespec); + return get_status(); } -unsigned char nwrite(char* devicespec, unsigned char* buf, unsigned short len) -{ +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(); + OS.dcb.dcomnd = 'W'; // write + OS.dcb.dstats = DWRITE; + OS.dcb.dbuf = buf; + OS.dcb.dbyt = OS.dcb.daux = len; + siov(); - return get_status(devicespec); + return get_status(); } /* https://fujinet.online/wiki/?p=SIO-Command-%24FF-Reset-FujiNet */ -unsigned char nreset(void) { +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 + 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 } @@ -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 @@ -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 |
