Terminal program for MailStation devices

cleanup, fix sharing variables between c and asm

+42 -63
+10 -11
Makefile
··· 33 33 crt0.rel: crt0.s 34 34 $(ASZ80) -o ${.TARGET} $> 35 35 36 - isr.rel: isr.s 36 + getchar.rel: getchar.s 37 37 $(ASZ80) -o ${.TARGET} $> 38 38 39 - putchar.rel: putchar.s $(SRCDIR)/font/spleen-5x8.inc 40 - $(ASZ80) -o ${.TARGET} $(SRCDIR)/putchar.s 41 - 42 - getchar.rel: getchar.s 39 + isr.rel: isr.s 43 40 $(ASZ80) -o ${.TARGET} $> 44 41 45 42 lpt.rel: lpt.s ··· 48 45 modem.rel: modem.s 49 46 $(ASZ80) -o ${.TARGET} $> 50 47 48 + putchar.rel: putchar.s $(SRCDIR)/font/spleen-5x8.inc 49 + $(ASZ80) -o ${.TARGET} $(SRCDIR)/putchar.s 50 + 51 51 settings.rel: settings.s 52 52 $(ASZ80) -o ${.TARGET} $> 53 53 54 - # c code 55 - 54 + #csi.rel: csi.s 55 + # $(ASZ80) -o ${.TARGET} $> 56 56 csi.rel: csi.c 57 57 $(SDCC) -c ${.TARGET} $> 58 58 59 - mailstation.rel: mailstation.c 60 - $(SDCC) -c ${.TARGET} $> 59 + # c code 61 60 62 61 mslib.rel: mslib.c 63 62 $(SDCC) -c ${.TARGET} $> ··· 71 70 ruby $(SRCDIR)/tools/hexfont2inc.rb $> > $(SRCDIR)/${.TARGET} 72 71 73 72 # code-loc must be far enough to hold _HEADER code in crt0 74 - msterm.ihx: crt0.rel isr.rel putchar.rel getchar.rel lpt.rel mailstation.rel \ 75 - modem.rel msterm.rel mslib.rel csi.rel settings.rel 73 + msterm.ihx: crt0.rel isr.rel putchar.rel getchar.rel lpt.rel modem.rel \ 74 + msterm.rel mslib.rel csi.rel settings.rel 76 75 $(SDCC) --no-std-crt0 --code-loc 0x4100 --data-loc 0x0000 -o ${.TARGET} $> 77 76 78 77 msterm.bin: msterm.ihx
-30
mailstation.c
··· 1 - /* 2 - * msTERM 3 - * mailstation utility functions 4 - * 5 - * Copyright (c) 2019 joshua stein <jcs@jcs.org> 6 - * 7 - * Permission to use, copy, modify, and distribute this software for any 8 - * purpose with or without fee is hereby granted, provided that the above 9 - * copyright notice and this permission notice appear in all copies. 10 - * 11 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 - */ 19 - 20 - #include <stdio.h> 21 - #include <string.h> 22 - 23 - #include "mailstation.h" 24 - 25 - volatile unsigned char __at(0x0) mem0; 26 - volatile unsigned char __at(0xdba2) p2shadow; 27 - volatile unsigned char __at(0xdba3) p3shadow; 28 - volatile unsigned char __at(0xdba0) p28shadow; 29 - 30 - volatile unsigned char *memp = &mem0;
+7 -5
mailstation.h
··· 94 94 95 95 96 96 /* crt0.s */ 97 + extern void exit(void); 97 98 extern void powerdown_mode(void); 98 99 extern void new_mail(unsigned char on); 99 100 extern void reboot(void); ··· 154 155 155 156 156 157 /* modem.s */ 157 - extern volatile unsigned char __at(0xf600) modem_buf[]; 158 - extern volatile unsigned char __at(0xf700) modem_buf_pos; 159 - extern volatile unsigned char __at(0xf702) modem_buf_read_pos; 158 + extern volatile unsigned char modem_buf[]; 159 + extern volatile unsigned char modem_buf_pos; 160 + extern volatile unsigned char modem_buf_read_pos; 160 161 extern volatile unsigned char modem_curmsr; 161 162 extern int modem_init(void); 162 163 extern int modem_ier(void); ··· 169 170 170 171 171 172 /* msterm.c */ 172 - extern volatile unsigned char __at(0xf500) obuf[]; 173 - extern volatile unsigned char __at(0xf704) obuf_pos; 173 + extern volatile unsigned char mem0; 174 + extern volatile unsigned char obuf[]; 175 + extern volatile unsigned char obuf_pos; 174 176 extern void update_statusbar(char *status, ...); 175 177 176 178
+19 -4
mailstation.inc
··· 37 37 .equ lcd_buf, #0xc010 38 38 .equ lcd_buf_end, #0xc010 + ((LCD_WIDTH * LCD_HEIGHT) / 8) - 1 39 39 40 - ; circular char[] buffer offset by *modem_buf_pos 41 - .equ modem_buf, #0xf600 42 - .equ modem_buf_pos, #0xf700 43 - .equ modem_buf_read_pos, #0xf702 40 + ; circular char[] buffer offset by *_modem_buf_pos 41 + .equ _modem_buf, #0xf600 42 + .equ _modem_buf_pos, #0xf700 43 + .equ _modem_buf_read_pos, #0xf702 44 + 45 + .equ _obuf, #0xf500 46 + .equ _obuf_pos, #0xf704 44 47 45 48 ; some random dataflash location (0x18000) that looked empty 46 49 .equ settings_page, #6 ··· 78 81 79 82 .equ MODEM_DEFAULT_SPEED, #300 80 83 84 + .equ _mem0, #0 85 + .globl _mem0 86 + 81 87 .globl _saved_cursorx 82 88 .globl _saved_cursory 83 89 84 90 ; settings 85 91 .globl _setting_modem_speed 86 92 .globl _setting_modem_quiet 93 + 94 + .globl _modem_buf 95 + .globl _modem_buf_pos 96 + .globl _modem_buf_read_pos 97 + .globl _modem_curmsr 98 + .globl _modem_flowing 99 + 100 + .globl _obuf 101 + .globl _obuf_pos 87 102 88 103 ; debug variables 89 104 .globl _debug0
+6 -13
msterm.c
··· 22 22 23 23 #include "mailstation.h" 24 24 25 - extern volatile unsigned char mem0; 26 - 27 - volatile unsigned char __at(0xf500) obuf[]; 28 - volatile unsigned char __at(0xf704) obuf_pos; 29 - volatile unsigned char __at(0xf600) modem_buf[]; 30 - volatile unsigned char __at(0xf700) modem_buf_pos; 31 - volatile unsigned char __at(0xf702) modem_buf_read_pos; 32 - 33 25 unsigned char lastkey; 34 26 unsigned char esc; 35 27 unsigned char old_modem_msr; ··· 53 45 #define STATUSBAR_HANGUP " Hangup " 54 46 #define STATUSBAR_BLANK " " 55 47 #define STATUSBAR_SETTINGS " Settings " 48 + #define STATUSBAR_PAUSE " Pause " 49 + #define STATUSBAR_CONTINUE " Continue " 56 50 unsigned char statusbar_state; 57 51 unsigned char statusbar_time[16]; 58 52 59 53 void 60 54 obuf_queue(unsigned char *c) 61 55 { 62 - unsigned char l = strlen(c); 63 - unsigned char x; 56 + unsigned char l, x; 64 57 65 - for (x = 0; x < strlen(c); x++) 58 + for (x = 0, l = strlen(c); x < l; x++) 66 59 obuf[obuf_pos++] = c[x]; 67 60 } 68 61 ··· 75 68 restart: 76 69 lastkey = 0; 77 70 esc = 0; 78 - source = SOURCE_MODEM; //LPT; 71 + source = SOURCE_MODEM; // SOURCE_LPT; 79 72 putchar_sgr = 0; 80 73 in_csi = 0; 81 74 csibuflen = 0; ··· 85 78 old_minutes = 0; 86 79 debug0 = 0; 87 80 88 - clear_screen(); 89 81 settings_read(); 90 82 83 + clear_screen(); 91 84 maybe_update_statusbar(1); 92 85 93 86 if (source == SOURCE_MODEM) {