aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c64
1 files changed, 26 insertions, 38 deletions
diff --git a/src/main.c b/src/main.c
index 068322d..1f533b3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,49 +10,41 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
-#include <conio.h> // for cgetc() only
#include "nio.h"
#include "irc.h"
#include "screen.h"
#include "edbox.h"
#include "config.h"
-#include "keyclick.h"
+#include "kgetc.h"
#include "indic8.h"
+#include "timers.h"
unsigned char err; // error code of last operation.
unsigned char trip = 0; // if trip == 1, fujinet is asking us for attention.
char old_enabled = 0; // were interrupts enabled for old vector
void *old_vprced; // old PROCEED vector, restored on exit.
-unsigned short rxbuflen; // RX buffer length
+unsigned int rxbuflen; // RX buffer length
unsigned int txbuflen; // TX buffer length
-char hz; /* 50 for PAL, 60 for NSTC */
char reconnect_timeout = 1;
-/* TODO: user modes (default +iw), fg/bg color... */
-
extern void ih(); // defined in intr.s
void txbuf_init(void) {
txbuflen = tx_buf[0] = 0;
}
-void txbuf_append_str(const char *str) {
- while(*str) {
- tx_buf[txbuflen++] = *str++;
- }
-}
-
void txbuf_append_str2(const char *s1, const char *s2) {
txbuf_append_str(s1);
txbuf_append_str(s2);
}
+/*
void txbuf_append_str3(const char *s1, const char *s2, const char *s3) {
txbuf_append_str(s1);
txbuf_append_str(s2);
txbuf_append_str(s3);
}
+*/
void txbuf_set_str(const char *str) {
txbuf_init();
@@ -73,12 +65,15 @@ void txbuf_send(void) {
/* don't send empty buffer */
if(!txbuflen) return;
- /* always terminate with EOL */
- if(tx_buf[txbuflen - 1] != '\n')
- tx_buf[txbuflen++] = '\n';
+ /* always terminate with *ASCII* CRLF.
+ DO NOT USE '\n' or even '\x0a', cc65 turns it into $9b! */
+ // tx_buf[txbuflen++] = 0x0d;
+ // tx_buf[txbuflen++] = 0x0a;
+ txbuf_append_chr(0x0d);
+ txbuf_append_chr(0x0a);
ind_net_tx();
- nwrite(conf->url, tx_buf, txbuflen);
+ nwrite_txbuf();
ind_net_idle();
txbuf_init();
}
@@ -92,10 +87,10 @@ void txbuf_send_str(const char *str) {
int fn_connect(void) {
scr_display(SCR_SERVER);
scr_print_current("Connecting to: ");
- scr_print_current(conf->url);
+ scr_print_current(config.url);
scr_eol_current();
- err = nopen(conf->url, FNET_TRANSLATION);
+ err = nopen();
if(err != SUCCESS) {
scr_print_current("Connection failed: ");
@@ -118,7 +113,7 @@ int fn_connect(void) {
}
void fn_disconnect(void) {
- nclose(conf->url);
+ nclose();
// Restore old PROCEED interrupt.
PIA.pactl &= ~1; // disable interrupts
@@ -130,9 +125,9 @@ void init_channels(void) {
char i;
for(i = 0; i < MAX_SCREENS - 2; i++) {
- if(conf->channels[i][0]) {
+ if(config.channels[i][0]) {
scr_status[i + 2] = SCR_INACTIVE;
- strcpy(scr_names[i + 2], conf->channels[i]);
+ strcpy(scr_names[i + 2], config.channels[i]);
}
}
}
@@ -145,37 +140,30 @@ void reconnect(void) {
OS.cdtmf3 = OS.ch = 0xff;
if(reconnect_timeout) {
- OS.cdtmv3 = reconnect_timeout * hz;
+ OS.cdtmv3 = reconnect_timeout * timers.hz;
scr_print_current(" or wait ");
- itoa(reconnect_timeout, numbuf, 10);
- scr_print_current(numbuf);
+ scr_cur_printnum(reconnect_timeout);
scr_print_current(" sec");
if(reconnect_timeout < 64)
reconnect_timeout <<= 1;
}
scr_print_current(" to reconnect.\n");
- while(OS.cdtmf3 == 0xff && OS.ch == 0xff)
+ while(OS.cdtmf3 == 0xff && !keypress())
/* NOP */;
- if(OS.ch != 0xff) {
- keyclick();
- OS.ch = 0xff;
- }
+ if(keypress()) kgetc();
}
void main(void) {
- bell_type = conf->alert_type; /* TODO: have bell.s read staight from the struct */
+ bell_type = config.alert_type; /* TODO: have bell.s read staight from the struct */
OS.shflok = 0; // turn off shift-lock.
OS.soundr = 0; // Turn off SIO beeping sound
- OS.color2 = conf->colors[0]; /* text BG, user-selected */
- // OS.color1 = (conf->colors[1] & 0x0f) | 0xc0; /* green (at user's brightness) */
- OS.color1 = conf->colors[1];
+ OS.color2 = config.colors[0]; /* text BG, user-selected */
+ OS.color1 = config.colors[1];
OS.color0 = 0x06; /* grey for inactive */
- OS.color3 = 0x46; /* red for highlight (not used yet) */
- OS.noclik = conf->disable_keyclick;
-
- hz = (GTIA_READ.pal & 0x0e) ? 60 : 50;
+ OS.color3 = 0x46; /* red for highlight */
+ OS.noclik = config.disable_keyclick;
edbox_clear();
scr_init();