recipes/trs80: add "recv" command

This allows us to write contents from RS-232 directly to floppy! it works!
This commit is contained in:
Virgil Dupras 2020-02-22 14:43:07 -05:00
parent 049f2cf222
commit ec6df3087d
2 changed files with 65 additions and 1 deletions

View File

@ -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`.

View File

@ -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: