diff options
Diffstat (limited to '')
| -rw-r--r-- | c/gbos.h | 2 | ||||
| -rw-r--r-- | c/libc.s | 8 | ||||
| -rw-r--r-- | include/gbos.inc | 3 | ||||
| -rw-r--r-- | src/net.asm | 10 | ||||
| -rw-r--r-- | src/socket.asm | 11 | ||||
| -rw-r--r-- | src/syscall.asm | 1 |
6 files changed, 30 insertions, 5 deletions
@@ -17,6 +17,8 @@ void ssend(unsigned char b); /* link-port: transmit one byte */ unsigned char srecv(void); /* link-port: receive one byte (blocks) */ int srecv_nb(void); /* link-port: receive, or -1 if none */ unsigned char pollin(void); /* poll OSK for a typed char, or 0 */ +unsigned char pollcon(void); /* poll console ring (link-injected + input, filled by net pumps), or 0 */ unsigned char sys_net(void *req); /* socket layer trap (see sock.h) */ void gsleep(unsigned char units); /* delay units*(1/64)s (raw trap) */ void msleep(unsigned int ms); /* delay ~ms milliseconds */ @@ -1,6 +1,6 @@ .module libc .globl _writes, _putc, _puts, _nl, _strlen, _readc, _sexit, _getpid, _getargs - .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe, _ssend, _srecv, _srecv_nb, _pollin + .globl _open, _close, _fgetc, _fputc, _flist, _fremove, _pipe, _ssend, _srecv, _srecv_nb, _pollin, _pollcon .globl _sys_net, _gsleep ;; SDCC sm83 sdcccall(1): 1st arg -> A (byte) or DE (pointer); ret A / BC. ;; rst $30 (the trap) clobbers BC/DE/HL; SDCC treats them caller-saved, so @@ -136,6 +136,12 @@ _pollin: rst #0x30 ret + ;; unsigned char pollcon(void) -> A (queued console byte, or 0) +_pollcon: + ld c, #35 ; SYS_POLLCON + rst #0x30 + ret + ;; unsigned char open(const char *name /*DE*/, unsigned char mode /*A*/) -> A(fd) _open: ld b, a ; B = mode diff --git a/include/gbos.inc b/include/gbos.inc index e9f8d7d..55f0681 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -133,7 +133,8 @@ DEF SYS_SRECVNB EQU 31 ; link-port: receive, non-blocking (-> A=byte, CF=none) DEF SYS_POLLIN EQU 32 ; poll OSK for a typed char (-> A=char or 0) DEF SYS_NET EQU 33 ; socket layer (DE=&netreq -> A=result) DEF SYS_SLEEP EQU 34 ; cooperative delay (B = 1/64-second units) -DEF SYS_MAX EQU 35 +DEF SYS_POLLCON EQU 35 ; poll console ring (link-injected -> A=byte or 0) +DEF SYS_MAX EQU 36 ; ---- socket layer (SYS_NET) -------------------------------------------------- ; netreq struct (in caller RAM; DE points to it): diff --git a/src/net.asm b/src/net.asm index f2c4279..8309242 100644 --- a/src/net.asm +++ b/src/net.asm @@ -54,6 +54,16 @@ sys_srecv_nb:: and a ; CF = 0 (got a byte) ret +; sys_pollcon() -> A = a queued console-ring byte (link-injected input, +; e.g. gbhub 'type'), or 0 if none. Non-blocking twin of KGetc's con_pop +; path: programs that own their main loop (irc) poll this alongside the OSK. +; The ring fills during net pumps, which such programs do constantly. +sys_pollcon:: + call con_pop + ret nc ; got a byte + xor a + ret + ; sys_pollin() -> A = char typed on the OSK this poll, or 0 if none. sys_pollin:: call pad_poll diff --git a/src/socket.asm b/src/socket.asm index 0720b0a..51179b4 100644 --- a/src/socket.asm +++ b/src/socket.asm @@ -64,7 +64,12 @@ wNetRxBuf:: DS 320 ; rx frame assembly / parse wNetRxLen:: DS 2 ; 16-bit: frames can exceed 255 bytes (DHCP/BOOTP) wNetRxEsc:: DS 1 wNetInFrame:: DS 1 ; net_pump: currently inside a SLIP frame? -wConRing:: DS 16 ; console-input ring: non-framed bytes from the link +wConRing:: DS 64 ; console-input ring: non-framed bytes from the link + ; (link-injected console input, e.g. gbhub 'type'). + ; One net_pump drains a whole serial burst into here + ; at once, so it must hold a full injected command + ; line - 16 was too small (dropped bytes, merged + ; lines). Size MUST stay a power of two (mask below). wConHead:: DS 1 wConTail:: DS 1 wNetUdpPort:: DS 2 ; scratch: UDP dst port being demuxed @@ -112,7 +117,7 @@ con_push:: ld b, a ld a, [wConTail] inc a - and 15 + and 63 ld c, a ld a, [wConHead] cp c @@ -145,7 +150,7 @@ con_pop:: ld c, [hl] ld a, b inc a - and 15 + and 63 ld [wConHead], a ld a, c and a ; CF = 0 diff --git a/src/syscall.asm b/src/syscall.asm index 2adf5bf..bd58cc2 100644 --- a/src/syscall.asm +++ b/src/syscall.asm @@ -69,6 +69,7 @@ SyscallTable: dw sys_pollin ; 32 POLLIN dw sys_net ; 33 NET dw sys_sleep ; 34 SLEEP + dw sys_pollcon ; 35 POLLCON ; ----------------------------------------------------------------------------- sys_nosys: |
