1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-18 05:38:06 +11:00

recipes/rc2014/sdcard: use BASIC shell

This commit is contained in:
Virgil Dupras 2019-12-11 11:18:32 -05:00
parent 7907687abf
commit 880775ae69
5 changed files with 65 additions and 49 deletions

View File

@ -137,4 +137,6 @@ basFSCmds:
.dw basFNEW .dw basFNEW
.db "fdel", 0 .db "fdel", 0
.dw basFDEL .dw basFDEL
.db "fson", 0
.dw fsOn
.db 0xff ; end of table .db 0xff ; end of table

14
apps/basic/sdc.asm Normal file
View File

@ -0,0 +1,14 @@
; SDC-related basic commands
basSDCI:
jp sdcInitializeCmd
basSDCF:
jp sdcFlushCmd
basSDCCmds:
.db "sdci", 0
.dw basSDCI
.db "sdcf", 0
.dw basSDCF
.db 0xff ; end of table

View File

@ -101,8 +101,7 @@ fsInit:
xor a xor a
ld hl, FS_BLK ld hl, FS_BLK
ld b, FS_RAMEND-FS_BLK ld b, FS_RAMEND-FS_BLK
call fill jp fill
ret
; *** Navigation *** ; *** Navigation ***
@ -286,7 +285,7 @@ fsFindFN:
call fsNext call fsNext
jr z, .loop jr z, .loop
; End of the chain, not found ; End of the chain, not found
call unsetZ ; Z already unset
.end: .end:
pop de pop de
ret ret
@ -311,7 +310,7 @@ fsIsValid:
; Returns whether current block is deleted in Z flag. ; Returns whether current block is deleted in Z flag.
fsIsDeleted: fsIsDeleted:
ld a, (FS_META+FS_META_FNAME_OFFSET) ld a, (FS_META+FS_META_FNAME_OFFSET)
cp 0 ; Z flag is our answer or a ; Z flag is our answer
ret ret
; *** blkdev methods *** ; *** blkdev methods ***
@ -508,12 +507,9 @@ fsOn:
jr .end jr .end
.error: .error:
; couldn't mount. Let's reset our variables. ; couldn't mount. Let's reset our variables.
xor a call fsInit
ld b, FS_META-FS_BLK ; reset routine pointers and FS ptrs
ld hl, FS_BLK
call fill
ld a, FS_ERR_NO_FS ld a, FS_ERR_NO_FS
or a ; unset Z
.end: .end:
pop bc pop bc
pop de pop de
@ -524,18 +520,16 @@ fsOn:
fsIsOn: fsIsOn:
; check whether (FS_BLK) is zero ; check whether (FS_BLK) is zero
push hl push hl
push de
ld hl, (FS_BLK) ld hl, (FS_BLK)
ld de, 0 ld a, h
call cpHLDE or l
jr nz, .mounted jr nz, .mounted
; if equal, it means our FS is not mounted ; not mounted, unset Z
call unsetZ inc a
jr .end jr .end
.mounted: .mounted:
cp a ; ensure Z cp a ; ensure Z
.end: .end:
pop de
pop hl pop hl
ret ret
@ -545,8 +539,6 @@ fsIsOn:
; There are no error condition happening midway. If you get an error, then (IY) ; There are no error condition happening midway. If you get an error, then (IY)
; was never called. ; was never called.
fsIter: fsIter:
call fsIsOn
ret nz
call fsBegin call fsBegin
ret nz ret nz
.loop: .loop:

View File

@ -621,10 +621,7 @@ sdcCRC:
pop af pop af
ret ret
; *** shell cmds ***
sdcInitializeCmd: sdcInitializeCmd:
.db "sdci", 0, 0, 0
call sdcInitialize call sdcInitialize
ret nz ret nz
call .setBlkSize call .setBlkSize
@ -678,7 +675,6 @@ sdcInitializeCmd:
; Flush the current SDC buffer if dirty ; Flush the current SDC buffer if dirty
sdcFlushCmd: sdcFlushCmd:
.db "sdcf", 0, 0, 0
ld hl, SDC_BUFSEC1 ld hl, SDC_BUFSEC1
ld (SDC_BUFPTR), hl ld (SDC_BUFPTR), hl
call sdcWriteBlk call sdcWriteBlk
@ -724,14 +720,11 @@ _sdcPlaceBuf:
sdcGetB: sdcGetB:
push hl push hl
call _sdcPlaceBuf call _sdcPlaceBuf
jr nz, .error jr nz, .end ; NZ already set
; This is it! ; This is it!
ld a, (hl) ld a, (hl)
cp a ; ensure Z cp a ; ensure Z
jr .end
.error:
call unsetZ
.end: .end:
pop hl pop hl
ret ret

View File

@ -2,9 +2,9 @@
; The RAM module is selected on A15, so it has the range 0x8000-0xffff ; The RAM module is selected on A15, so it has the range 0x8000-0xffff
.equ RAMSTART 0x8000 .equ RAMSTART 0x8000
.equ RAMEND 0xffff .equ RAMEND 0xffff
.equ PGM_CODEADDR 0x9000
.equ ACIA_CTL 0x80 ; Control and status. RS off. .equ ACIA_CTL 0x80 ; Control and status. RS off.
.equ ACIA_IO 0x81 ; Transmit. RS on. .equ ACIA_IO 0x81 ; Transmit. RS on.
.equ USER_CODE 0xa000
jp init ; 3 bytes jp init ; 3 bytes
@ -45,25 +45,32 @@ jp aciaInt
.equ FS_HANDLE_COUNT 1 .equ FS_HANDLE_COUNT 1
.inc "fs.asm" .inc "fs.asm"
; *** Shell *** ; *** BASIC ***
; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20
.equ SCRATCHPAD FS_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm"
.inc "lib/parse.asm" .inc "lib/parse.asm"
.inc "lib/args.asm" .inc "lib/fmt.asm"
.inc "lib/stdio.asm" .equ EXPR_PARSE parseLiteralOrVar
.equ SHELL_RAMSTART FS_RAMEND .inc "lib/expr.asm"
.equ SHELL_EXTRA_CMD_COUNT 11 .inc "basic/util.asm"
.inc "shell/main.asm" .inc "basic/parse.asm"
.dw sdcInitializeCmd, sdcFlushCmd .inc "basic/tok.asm"
.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd .equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd .inc "basic/var.asm"
.equ BUF_RAMSTART VAR_RAMEND
.inc "basic/buf.asm"
.inc "basic/blk.asm"
.inc "basic/sdc.asm"
.equ BFS_RAMSTART BUF_RAMEND
.inc "basic/fs.asm"
.equ BAS_RAMSTART BFS_RAMEND
.inc "basic/main.asm"
.inc "shell/blkdev.asm" .equ SDC_RAMSTART BAS_RAMEND
.inc "shell/fs.asm"
.equ PGM_RAMSTART SHELL_RAMEND
.inc "shell/pgm.asm"
.equ SDC_RAMSTART PGM_RAMEND
.equ SDC_PORT_CSHIGH 6 .equ SDC_PORT_CSHIGH 6
.equ SDC_PORT_CSLOW 5 .equ SDC_PORT_CSLOW 5
.equ SDC_PORT_SPI 4 .equ SDC_PORT_SPI 4
@ -71,22 +78,30 @@ jp aciaInt
init: init:
di di
; setup stack ld sp, RAMEND
ld hl, RAMEND
ld sp, hl
im 1 im 1
call aciaInit call aciaInit
call fsInit call fsInit
call shellInit call basInit
ld hl, pgmShellHook ld hl, basFindCmdExtra
ld (SHELL_CMDHOOK), hl ld (BAS_FINDHOOK), hl
xor a xor a
ld de, BLOCKDEV_SEL ld de, BLOCKDEV_SEL
call blkSel call blkSel
ei ei
jp shellLoop jp basStart
basFindCmdExtra:
ld hl, basFSCmds
call basFindCmd
ret z
ld hl, basBLKCmds
call basFindCmd
ret z
ld hl, basSDCCmds
jp basFindCmd
; *** blkdev 2: file handle 0 *** ; *** blkdev 2: file handle 0 ***