diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-02-18 13:08:23 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-02-18 13:08:23 -0500 |
| commit | 48feffd829f30d393b39ae1cbdc7bf3eddca7652 (patch) | |
| tree | 0db282f0c9b9a0fd9825426a51742fc37afbe128 | |
| parent | f1bf0a483e917b67cf9db6483072db261f7688c3 (diff) | |
| download | fujinet-chat-48feffd829f30d393b39ae1cbdc7bf3eddca7652.tar.gz | |
WIP, still not working.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | size.pl | 26 | ||||
| -rw-r--r-- | src/edbox.c | 43 | ||||
| -rw-r--r-- | src/edbox.h | 23 | ||||
| -rw-r--r-- | src/irc.c | 2 | ||||
| -rw-r--r-- | uitest/test.c | 6 |
6 files changed, 99 insertions, 3 deletions
@@ -14,7 +14,7 @@ client: $(MAKE) -f Makefile.client clean: - rm -f $(PARTS) + rm -f $(PARTS) *.o $(MAKE) -f Makefile.client clean %.xex: %.asm @@ -0,0 +1,26 @@ +#!/usr/bin/perl -w + +# from src/atari.cfg: +my $code_start = 0x2000; +my $stack_size = 0x0800; + +# from memsetup.asm: +my $ramtop = 0xa000; + +open MAP, "client.xex.map" or die $!; +while(<MAP>) { + next unless /^BSS/; + (undef, $bss_start, $bss_end, undef) = split /\s+/; + $bss_start = hex $bss_start; + $bss_end = hex $bss_end; +} +close MAP; + +$free = ($ramtop - $stack_size) - $bss_end + 1; +$code_size = $bss_start - $code_start; +$bss_size = $bss_end - $bss_start + 1; + +printf "===> code ends at \$%04x (%d, %.1fK)\n", ($bss_start - 1), $code_size, $code_size / 1024; +printf "===> BSS ends at \$%04x (%d, %.1fK)\n", $bss_end, $bss_size, $bss_size / 1024; +printf "===> stack starts at \$%04x\n", $ramtop - $stack_size; +printf "===> free code space \$%04x (%d, %.1fK)\n", $free, $free, $free / 1024; diff --git a/src/edbox.c b/src/edbox.c index b1b06a7..b64ef11 100644 --- a/src/edbox.c +++ b/src/edbox.c @@ -37,6 +37,7 @@ void edbox_show(void) { scr_waitvcount(116); *dlist_bottom_lms = addr; + show_cursor(); } void edbox_hide(void) { @@ -52,6 +53,44 @@ void edbox_putc(char c) { edbox_show(); } +void edbox_append(char *s) { + while(*s) + edit_box[edbox_pos++] = *s++; +} + +void edbox_preset(char *s) { + edbox_pos = 0; + edbox_append(s); +} + +static char readline_done, readline_len; +static char *readline_dest; +static void readline_callback(void) { + strncpy(readline_dest, edit_box, readline_len); + readline_done = 1; +} + +void edbox_readline(char *dest, char len) { + void (*old_callback)(void); + + edbox_clear(); + if(*dest) + edbox_preset(dest); + edbox_show(); + + old_callback = edbox_callback; + edbox_callback = readline_callback; + readline_dest = dest; + readline_len = len; + + readline_done = 0; + + while(!readline_done) + edbox_keystroke(); + + edbox_callback = old_callback; +} + static void special_keystroke(char c) { OS.ch = 0xff; edbox_putc(c); @@ -74,6 +113,7 @@ static void normal_keystroke(void) { switch(c) { case CH_EOL: edbox_putc(c); + hide_cursor(); if(edbox_callback) (*edbox_callback)(); /* fall thru */ @@ -99,6 +139,9 @@ static void normal_keystroke(void) { void edbox_keystroke(void) { char c; + while(OS.ch == 0xff) + ; + hide_cursor(); edbox_show(); diff --git a/src/edbox.h b/src/edbox.h index ad70cc6..a410cec 100644 --- a/src/edbox.h +++ b/src/edbox.h @@ -4,11 +4,32 @@ #define EDBOX_SIZE 160 +/* clear the contents of the edit box (whether it's visible or not) */ void edbox_clear(void); + +/* make the edit box visible */ void edbox_show(void); + +/* make the edit box go away (current screen's status lines display instead) */ void edbox_hide(void); + +/* put one character into the edit box. */ void edbox_putc(char c); + +/* wait for a keystroke, insert its character into the edit box. if Return + is pressed, edbox_callback gets called (if it's set!) */ void edbox_keystroke(void); -/* called when the user presses Enter */ +/* append a string to the edit box. */ +void edbox_append(char *s); + +/* explicitly set the edit box's contents. wipes out whatever was there + before. */ +void edbox_preset(char *s); + +/* read a complete line into the edit box; doesn't return until the user + pressed Return. copies it to dest, up to len characters. */ +void edbox_readline(char *dest, char len); + +/* called when the user presses Return */ extern void (*edbox_callback)(void); @@ -355,7 +355,7 @@ void irc_loop(void) { while(1) { if(!irc_read()) return; - if(kbhit()) + if(OS.ch != 0xff) if(joined) keystroke(); else join_channel(); diff --git a/uitest/test.c b/uitest/test.c index 93264dd..056eb48 100644 --- a/uitest/test.c +++ b/uitest/test.c @@ -32,6 +32,12 @@ int main() { scr_print(0, buf); } + scr_print(0, "login:\n"); + strcpy(buf, "Urchlay"); + edbox_readline(buf, sizeof(buf)); + scr_print(0, "You are logged in as "); + scr_print(0, buf); + scr_print(0, "Hold Start and press:\n"); scr_print(0, "N: Create new screen, C: Close screen\n"); scr_print(0, "1-7: Switch to screen (if exists).\n"); |
