aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-11 01:52:58 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-11 01:52:58 -0400
commitb05889cde25b565d0d0bfa0e72ad655b0394f0de (patch)
tree6d3e40304184cdf613d38e9396bc3be86f01370a /config
parentced2f97c201def0356f0fa0601b3c7ad5fb71a6c (diff)
downloadfujinet-chat-b05889cde25b565d0d0bfa0e72ad655b0394f0de.tar.gz
Add config/* stuff.
Diffstat (limited to 'config')
-rw-r--r--config/Makefile11
-rw-r--r--config/config.c163
-rw-r--r--config/conftest.c38
-rw-r--r--config/exetrailer.s14
4 files changed, 226 insertions, 0 deletions
diff --git a/config/Makefile b/config/Makefile
new file mode 100644
index 0000000..98eb07f
--- /dev/null
+++ b/config/Makefile
@@ -0,0 +1,11 @@
+all: config.xex
+
+config.xex: config.c exetrailer.s ../src/config.h
+ cl65 -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s
+
+test:
+ cl65 -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s
+ cl65 -t atari -C ../src/atari.cfg -o conftest.xex conftest.c
+ cat config.xex conftest.xex > autorun.sys
+ cp dos25_sd.atr test.atr
+ axe -w autorun.sys test.atr
diff --git a/config/config.c b/config/config.c
new file mode 100644
index 0000000..212d36b
--- /dev/null
+++ b/config/config.c
@@ -0,0 +1,163 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <atari.h>
+#include <conio.h>
+
+#include "../src/config.h"
+
+conf_t defaults = {
+ "N:TCP://irc.libera.chat:6667",
+ "FNChatTest",
+ "FujiNetChat User",
+ { 0xc0, 0x0c },
+ { "#testari8", { 0 }, { 0 }, { 0 }, { 0 } },
+ 3,
+ 1,
+ 0,
+ 1
+};
+
+char filename[100] = "D:FNCHAT.CFG";
+char buf[100];
+char server[100];
+char port[6];
+
+void print(const char *text) {
+ fputs(text, stdout);
+}
+
+void prompt(const char *text, char *p) {
+ print(text);
+ print(" [");
+ print(p);
+ print("]? ");
+ gets(buf);
+ if(buf[0]) strcpy(p, buf);
+}
+
+char yn(const char *text) {
+ char c;
+ print(text);
+ print(" [Y/n]? ");
+ c = cgetc();
+ if(c == '\n')
+ putchar('Y');
+ else
+ putchar(c);
+ putchar('\n');
+ return (c == '\n' || c == 'Y' || c == 'y');
+}
+
+void save(void) {
+ int fh, bad;
+
+ do {
+ bad = 0;
+
+ OS.shflok = 0x40;
+ prompt("Config File", filename);
+ OS.shflok = 0x00;
+
+ if((fh = open(filename, O_WRONLY | O_CREAT)) < 0) {
+ print("!! I/O error (open)\n");
+ bad = 1;
+ } else if((write(fh, conf, sizeof(conf_t))) != sizeof(conf_t)) {
+ print("!! I/O error (write)\n");
+ bad = 1;
+ }
+
+ if(fh >= 0) close(fh);
+
+ if(bad) {
+ if(!yn("Retry")) break;
+ }
+ } while(bad);
+}
+
+void load(void) {
+ int fh, bad = 0;
+
+ if(!yn("Load Config")) {
+ bad = 1;
+ print("OK");
+ } else {
+ OS.shflok = 0x40;
+ prompt("Config File", filename);
+ OS.shflok = 0x00;
+
+ if((fh = open(filename, O_RDONLY)) < 0) {
+ print("Not found");
+ bad = 1;
+ } else if((read(fh, conf, sizeof(conf_t))) != sizeof(conf_t)) {
+ print("Invalid");
+ bad = 1;
+ }
+
+ if(fh >= 0) close(fh);
+ }
+
+ if(bad) {
+ print(", using built-in defaults\n");
+ memcpy(conf, &defaults, sizeof(conf_t));
+ }
+}
+
+void make_url(void) {
+ conf->url[8] = '\0';
+ strcat(conf->url, server);
+ strcat(conf->url, ":");
+ strcat(conf->url, port);
+}
+
+void main(void) {
+ char *p, *q;
+
+ OS.color2 = defaults.colors[0];
+ OS.color1 = defaults.colors[1];
+
+ cursor(1);
+ puts("\x7d" "FujiNetChat Setup\n");
+
+ load();
+
+ OS.color2 = conf->colors[0];
+ OS.color1 = conf->colors[1];
+
+ q = server;
+ p = conf->url + 8; /* skip N:TCP:// */
+ while(*p) {
+ if(*p == ':') break;
+ *q++ = *p++;
+ }
+
+ *q = 0;
+ p++;
+ q = port;
+ strcpy(port, p);
+
+ while(1) {
+ prompt("\nServer", server);
+ prompt("Port ", port);
+ prompt("Nick ", conf->nick);
+ // prompt_colors();
+ // prompt_alert_type();
+ conf->show_ping = yn("Show PING/PONG");
+ conf->atract_away = yn("Set AWAY on ATRACT");
+ conf->hide_motd = yn("Hide MOTD");
+
+ make_url();
+ print("\nURL: ");
+ print(conf->url);
+ putchar('\n');
+
+ if(yn("Settings OK"))
+ break;
+ }
+
+ if(yn("Save to disk"))
+ save();
+
+ print("\nClient loading...");
+}
diff --git a/config/conftest.c b/config/conftest.c
new file mode 100644
index 0000000..4096b68
--- /dev/null
+++ b/config/conftest.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <atari.h>
+#include <conio.h>
+
+#include "../src/config.h"
+
+void print(const char *text) {
+ fputs(text, stdout);
+}
+
+void main(void) {
+ OS.color4 = 0xff;
+
+ print("\x7d" "URL: ");
+ print(conf->url);
+ putchar('\n');
+
+ print("Nick: ");
+ print(conf->nick);
+ putchar('\n');
+
+ print("Pingpong: ");
+ print(conf->show_ping ? "yes" : "no");
+ putchar('\n');
+
+ print("Autoaway: ");
+ print(conf->atract_away ? "yes" : "no");
+ putchar('\n');
+
+ print("Hidemotd: ");
+ print(conf->hide_motd ? "yes" : "no");
+ putchar('\n');
+
+ cgetc();
+}
diff --git a/config/exetrailer.s b/config/exetrailer.s
new file mode 100644
index 0000000..60e8393
--- /dev/null
+++ b/config/exetrailer.s
@@ -0,0 +1,14 @@
+; This file defines the EXE file "trailer" which sets the entry point
+
+; 20260311 bkw: Modified to use INITAD instead of RUNAD!
+
+ .export __AUTOSTART__: absolute = 1
+ .import start
+
+ .include "atari.inc"
+
+.segment "AUTOSTRT"
+ .word INITAD ; defined in atari.inc
+ .word INITAD+1
+ .word start
+