diff --git a/apps/basic/README.md b/apps/basic/README.md index 7474a22..417a46f 100644 --- a/apps/basic/README.md +++ b/apps/basic/README.md @@ -224,6 +224,11 @@ handle 1 maps to blkid 2. Once a file is opened, you can use the mapped blkid as you would with any block device (bseek, getb, putb). +**fnew **: Allocates space of "blkcnt" blocks (each block is +0x100 bytes in size) for a new file names "fname". Maximum blkcnt is 0xff. + +**fdel **: Mark file named "fname" as deleted. + **ldbas **: loads the content of the file specified in the argument (as an unquoted filename) and replace the current code listing with this contents. Any line not starting with a number is ignored (not an error). diff --git a/apps/basic/fs.asm b/apps/basic/fs.asm index d5d75b2..d097582 100644 --- a/apps/basic/fs.asm +++ b/apps/basic/fs.asm @@ -4,6 +4,7 @@ .equ BFS_FILE_HDL BFS_RAMSTART .equ BFS_RAMEND @+FS_HANDLE_SIZE +; Lists filenames in currently active FS basFLS: ld iy, .iter jp fsIter @@ -77,6 +78,25 @@ basFOPEN: push de \ pop ix ; IX now points to the file handle. jp fsOpen +; Takes one byte block number to allocate as well we one string arg filename +; and allocates a new file in the current fs. +basFNEW: + call rdExpr ; file block count + ret nz + call rdSep ; HL now points to filename + push ix \ pop de + ld a, e + out (42), a + jp fsAlloc + +; Deletes filename with specified name +basFDEL: + call fsFindFN + ret nz + ; Found! delete + jp fsDel + + basPgmHook: ; Cmd to find is in (DE) ex de, hl @@ -107,4 +127,8 @@ basFSCmds: .db "ldbas", 0 .dw basFOPEN .db "fopen", 0 + .dw basFNEW + .db "fnew", 0, 0 + .dw basFDEL + .db "fdel", 0, 0 .db 0xff, 0xff, 0xff ; end of table