From ec6df3087d8596dd18fe9798d6883102d60545a9 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 22 Feb 2020 14:43:07 -0500 Subject: [PATCH] recipes/trs80: add "recv" command This allows us to write contents from RS-232 directly to floppy! it works! --- recipes/trs80/README.md | 14 ++++++++++- recipes/trs80/glue.asm | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/recipes/trs80/README.md b/recipes/trs80/README.md index 52d3cf8..cee02f1 100644 --- a/recipes/trs80/README.md +++ b/recipes/trs80/README.md @@ -204,4 +204,16 @@ get a usable Collapse OS prompt! Like with the `recv` program, nothing stops you from dumping that binary to a floppy. -Have fun! +## Configuration + +In addition to the generic basic shell, this build of Collapse OS has support +for floppy drive `:1` as a block device (mapped to device `0`). Block device +commands work as expected. + +In addition to this, there is a `flush` command to ensure that dirty buffers are +synced to disk. Make sure you run this after a write operation or before +swapping disks. + +There is also a custom `recv` command that does the same "ping pong" as in +`recv.asm`, but once. It puts the result in `A`. This can be useful to send down +a raw CFS: you just need a while loop that repeatedly call `recv:putb a`. diff --git a/recipes/trs80/glue.asm b/recipes/trs80/glue.asm index ee689ed..159c2ef 100644 --- a/recipes/trs80/glue.asm +++ b/recipes/trs80/glue.asm @@ -1,5 +1,7 @@ ; RAMSTART is a label at the end of the file .equ RAMEND 0xcfff +; Address of the *CL driver. Same as in recv.asm +.equ COM_DRV_ADDR 0x0238 ; Free memory in TRSDOS starts at 0x3000 .org 0x3000 @@ -73,11 +75,61 @@ printcr: pop af ret +; Receive a byte from *cl and put it in A. +; Returns A > 0xff when receiving the last byte +recvCmd: + xor a + ld (VAR_TBL+1), a ; pre-set MSB + ; put a 0xff mask in B, which will become 0x7f if we receive a 0x20 + ld b, 0xff +.inner: + ld a, 0x03 ; @GET + ld de, COM_DRV_ADDR + rst 0x28 + jr nz, .maybeerror + or a + jr z, .eof ; Sending a straight NULL ends the comm. + ; @PUT that char back + ld c, a + ld a, 0x04 ; @PUT + ld de, COM_DRV_ADDR + rst 0x28 + ret nz ; error + ld a, c + cp 0x20 + jr z, .escapechar + ; not an escape char, good + and b ; apply mask + ld (VAR_TBL), a + xor a ; ensure Z + ret +.maybeerror: + ; was it an error? + or a + jr z, .inner ; not an error, just loop + ret ; error +.escapechar: + ld b, 0x7f + jr .inner +.eof: + dec a ; A = 0xff + ld (VAR_TBL+1), a + xor a ; ensure Z + ret + basFindCmdExtra: ld hl, basFloppyCmds call basFindCmd ret z ld hl, basBLKCmds + call basFindCmd + ret z + ld hl, .cmds jp basFindCmd +.cmds: + .db "recv", 0 + .dw recvCmd + .db 0xff ; end of table + RAMSTART: