diff options
| author | user <user@clank> | 2026-09-22 16:02:55 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-22 16:02:55 +0200 |
| commit | 43e43b6dcec29e2b008d20135f5d02523b62fbcf (patch) | |
| tree | d647acd07596e290c70a9884c1dc5d8c20a31067 /src/net.asm | |
| parent | net: three TCP receive bugs - caller corruption, data loss, early EOF (diff) | |
| download | gbos-43e43b6dcec29e2b008d20135f5d02523b62fbcf.tar.gz gbos-43e43b6dcec29e2b008d20135f5d02523b62fbcf.tar.xz gbos-43e43b6dcec29e2b008d20135f5d02523b62fbcf.zip | |
usr: grep, more, cp, nc - and make pollcon pump the link
The shell has had pipes for a while with nothing to pipe *through*, and
an 18-row screen with no way to stop output scrolling off it.
- grep [-vin] PAT [file]: substring match (no regex), stdin or a file,
grep(1)'s exit convention. The other end of the pipe, at last.
- more [file]: pages 17 lines at a time, --More-- bar in white-on-blue,
any key pages, q quits. Counts *screen* rows, so wrapped lines pay
their real cost. Keys come from pollin/pollcon, not stdin, so
`cat big | more` still has a keyboard.
- cp SRC DST: the fs has rm/mkdir but no way to duplicate a file. mv is
this plus rm (there is no rename). Rejects SRC == DST, which would
otherwise truncate the source via O_WRITE before reading a byte.
- nc [-s] HOST PORT: raw TCP. Interactive (START sends the line with a
CRLF, /q quits) or -s to pump stdin and print the reply with its own
wall-clock idle timeout, because the kernel's blocking recv counts
pumps, not seconds. Generalizes what chat/irc hardcode:
`nc towel.blinkenlights.nl 23` works.
sys_pollcon now pumps the link before draining the console ring. The
ring is filled *by* net_pump, so a program that never touches the
network polled a ring nothing would ever fill: host-injected keys
(gbtype/gbdemo) hung `more` forever, and the Game Boy stopped answering
pings for as long as it ran. KGetc already pumps for this reason.
New tools take banks 35-38. Locals over statics in all four: a program's
_DATA starts at $A000, where the shell leaves the command line.
Diffstat (limited to 'src/net.asm')
| -rw-r--r-- | src/net.asm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/net.asm b/src/net.asm index 8309242..a5f0210 100644 --- a/src/net.asm +++ b/src/net.asm @@ -56,9 +56,16 @@ sys_srecv_nb:: ; 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. +; path: programs that own their main loop (irc, nc, more) poll this alongside +; the OSK. +; +; Pump the link first. The ring is filled BY net_pump, so a caller that never +; touches the network (a pager, a game) would otherwise poll a ring nothing +; ever fills - host-injected keys (gbtype/gbdemo) would hang it forever, and +; the Game Boy would stop answering pings for as long as it ran. KGetc already +; pumps for exactly this reason; pollcon now matches it. sys_pollcon:: + call net_pump call con_pop ret nc ; got a byte xor a |
