From 2860a10f7126a8aef55d265481caa5a095380369 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 22 Feb 2020 20:06:59 -0500 Subject: [PATCH] recipes/trs80: add CFS support --- recipes/trs80/README.md | 5 +++++ recipes/trs80/glue.asm | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/recipes/trs80/README.md b/recipes/trs80/README.md index cee02f1..02d2916 100644 --- a/recipes/trs80/README.md +++ b/recipes/trs80/README.md @@ -214,6 +214,11 @@ 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. +On top of that, there's CFS support builtin. To enable a FS, type `fson` while +the active block device is properly placed (you can initialize a new FS by +writing `CFS\0\0\0\0` to the disk). If it doesn't error out, commands like +`fls` and `fnew` will work. Don't forget to flush when you're finished :) + 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 159c2ef..da9cc82 100644 --- a/recipes/trs80/glue.asm +++ b/recipes/trs80/glue.asm @@ -2,6 +2,8 @@ .equ RAMEND 0xcfff ; Address of the *CL driver. Same as in recv.asm .equ COM_DRV_ADDR 0x0238 +; in sync with user.h. Last BAS_RAMEND: 0x5705 +.equ USER_CODE 0x5800 ; Free memory in TRSDOS starts at 0x3000 .org 0x3000 @@ -9,6 +11,7 @@ .inc "err.h" .inc "blkdev.h" +.inc "fs.h" .inc "ascii.h" .inc "core.asm" .inc "str.asm" @@ -19,16 +22,22 @@ .inc "trs80/floppy.asm" .equ BLOCKDEV_RAMSTART FLOPPY_RAMEND -.equ BLOCKDEV_COUNT 1 +.equ BLOCKDEV_COUNT 3 .inc "blockdev.asm" ; List of devices .dw floppyGetB, floppyPutB +.dw blk1GetB, blk1PutB +.dw blk2GetB, blk2PutB .equ STDIO_RAMSTART BLOCKDEV_RAMEND .equ STDIO_GETC trs80GetC .equ STDIO_PUTC trs80PutC .inc "stdio.asm" +.equ FS_RAMSTART STDIO_RAMEND +.equ FS_HANDLE_COUNT 2 +.inc "fs.asm" + ; The TRS-80 generates a double line feed if we give it both CR and LF. .equ printcrlf printcr @@ -36,7 +45,7 @@ ; RAM space used in different routines for short term processing. .equ SCRATCHPAD_SIZE STDIO_BUFSIZE -.equ SCRATCHPAD STDIO_RAMEND +.equ SCRATCHPAD FS_RAMEND .inc "lib/util.asm" .inc "lib/ari.asm" .inc "lib/parse.asm" @@ -50,14 +59,19 @@ .inc "basic/var.asm" .equ BUF_RAMSTART VAR_RAMEND .inc "basic/buf.asm" +.equ BFS_RAMSTART BUF_RAMEND +.inc "basic/fs.asm" .inc "basic/blk.asm" .inc "basic/floppy.asm" -.equ BAS_RAMSTART BUF_RAMEND +.equ BAS_RAMSTART BFS_RAMEND .inc "basic/main.asm" +.out BAS_RAMEND + init: ld sp, RAMEND call floppyInit + call fsInit call basInit ld hl, basFindCmdExtra ld (BAS_FINDHOOK), hl @@ -124,6 +138,9 @@ basFindCmdExtra: ld hl, basBLKCmds call basFindCmd ret z + ld hl, basFSCmds + call basFindCmd + ret z ld hl, .cmds jp basFindCmd @@ -132,4 +149,24 @@ basFindCmdExtra: .dw recvCmd .db 0xff ; end of table +; *** blkdev 1: file handle 0 *** + +blk1GetB: + ld ix, FS_HANDLES + jp fsGetB + +blk1PutB: + ld ix, FS_HANDLES + jp fsPutB + +; *** blkdev 2: file handle 1 *** + +blk2GetB: + ld ix, FS_HANDLES+FS_HANDLE_SIZE + jp fsGetB + +blk2PutB: + ld ix, FS_HANDLES+FS_HANDLE_SIZE + jp fsPutB + RAMSTART: