aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-03-11 08:26:28 -0400
committerB. Watson <urchlay@slackware.uk>2026-03-11 08:26:28 -0400
commit1315c7ba61567d853539b5e0d678f7a6435cef06 (patch)
tree5375f51e8aeaea92731571c9837acf638ecd55bb /config
parent8072f3fe1244d5c3891bf4e93ed2b63ab2e2d111 (diff)
downloadfujinet-chat-1315c7ba61567d853539b5e0d678f7a6435cef06.tar.gz
Fix yn() in config, futz with alignment.
Diffstat (limited to 'config')
-rw-r--r--config/Makefile6
-rw-r--r--config/config.c87
2 files changed, 59 insertions, 34 deletions
diff --git a/config/Makefile b/config/Makefile
index a371135..65de826 100644
--- a/config/Makefile
+++ b/config/Makefile
@@ -3,11 +3,11 @@ all: config.xex
#config.xex: config.c exetrailer.s ../src/config.h ../src/config.c
config.xex:
- cl65 -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s ../src/config.c
+ cl65 -Oris -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s ../src/config.c
test:
- cl65 -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s ../src/config.c
- cl65 -t atari -C ../src/atari.cfg -o conftest.xex conftest.c
+ cl65 -Oris -t atari -C ../src/atari.cfg -o config.xex config.c exetrailer.s ../src/config.c
+ cl65 -Oris -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
index 28e0f6d..d0a20ff 100644
--- a/config/config.c
+++ b/config/config.c
@@ -28,15 +28,19 @@ char server[101];
char port[6];
void detect_dos(void) {
- char i, j;
+ char i, j, h, d;
+ h = d = 0;
for(i = 0; i < 11; i++) {
j = OS.hatabs[i].id;
- if(j == 'D' || j == 'H') {
- have_dos = 1;
- break;
- }
+ if(j == 'D')
+ h = 1;
+ if(j == 'H')
+ d = 1;
}
+
+ if(h && !d) filename[0] = 'H';
+ if(h || d) have_dos = 1;
}
void print(const char *text) {
@@ -52,17 +56,29 @@ void prompt(const char *text, char *p, char limit) {
if(buf[0]) strncpy(p, buf, limit);
}
-char yn(const char *text) {
- char c;
+char yn(const char *text, char dflt) {
+ char c, bad;
+
print(text);
- print(" [Y/n]? ");
- c = cgetc();
- if(c == '\n')
- putchar('Y');
+
+ if(dflt)
+ print(" [Y/n]? ");
else
- putchar(c);
+ print(" [y/N]? ");
+
+ do {
+ bad = 1;
+ c = cgetc();
+ if(c == '\n')
+ c = dflt ? 'Y' : 'N';
+ if(c == 'Y' || c == 'N' || c == 'y' || c == 'n')
+ bad = 0;
+ } while(bad);
+
+ putchar(c);
putchar('\n');
- return (c == '\n' || c == 'Y' || c == 'y');
+
+ return (c == 'Y' || c == 'y');
}
void prompt_config_file(void) {
@@ -83,8 +99,8 @@ void prompt_colors(void) {
do {
bad = 0;
- prompt_color("Background", 0);
- prompt_color("Text", 1);
+ prompt_color("Text BG", 0);
+ prompt_color("Text FG", 1);
if((conf->colors[0] & 0x0e) == (conf->colors[1] & 0x0e)) {
print("!! Unreadable, try again.\n");
bad = 1;
@@ -96,21 +112,29 @@ void prompt_colors(void) {
}
void prompt_alert_type(void) {
- char c, bad;
+ char c, d, bad;
print(" 0:None, 1:Beep, 2:Flash, 3:Both\n");
+ d = conf->alert_type + '0';
do {
bad = 0;
- itoa(conf->alert_type, numbuf, 10);
- prompt("Alert type", numbuf, 2);
- c = atoi(numbuf);
- if(c < 0 || c > 3) {
+
+ print("Alert type [");
+ putchar(d);
+ print("]? ");
+
+ c = cgetc();
+ if(c == '\n') c = d;
+ putchar(c);
+
+ putchar('\n');
+ if(c < '0' || c > '3') {
bad = 1;
print("!! Range is 0-3, try again.\n");
}
} while(bad);
- conf->alert_type = c;
+ conf->alert_type = c - '0';
}
void save(void) {
@@ -130,7 +154,7 @@ void save(void) {
if(fh >= 0) close(fh);
if(bad) {
- if(!yn("Retry")) break;
+ if(!yn("Retry", 1)) break;
}
} while(bad);
}
@@ -139,7 +163,7 @@ void load(void) {
int fh, bad = 0;
if(have_dos) {
- if(!yn("Load Config")) {
+ if(!yn("Load Config", 1)) {
bad = 1;
print("OK");
} else {
@@ -180,7 +204,7 @@ void main(void) {
OS.color1 = defaults.colors[1];
cursor(1);
- puts("\x7d" "FujiNetChat Setup\n");
+ print("\x7d" "FujiNetChat Setup\n\n");
detect_dos();
load();
@@ -204,26 +228,27 @@ void main(void) {
prompt("\nServer", server, 100);
prompt("Port ", port, 5);
prompt("Nick ", conf->nick, 25);
- prompt("'Real' Name ", conf->real_name, 25);
+ prompt("Name ", conf->real_name, 25);
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");
+ conf->show_ping = yn("Show PING/PONG", conf->show_ping);
+ conf->atract_away = yn("Set AWAY on ATRACT", conf->atract_away);
+ conf->hide_motd = yn("Hide MOTD", conf->hide_motd);
make_url();
print("\nURL: ");
print(conf->url);
putchar('\n');
- if(yn("Settings OK"))
+ if(yn("Settings OK", 1))
break;
}
if(have_dos) {
- if(yn("Save to disk"))
+ if(yn("Save to disk", 1))
save();
}
- print("\nClient loading...");
+ print("\nPress any key to load the client...");
+ cgetc();
}