mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:48:06 +11:00
recipes/rc2014/sdcard: use BASIC shell
This commit is contained in:
parent
7907687abf
commit
880775ae69
@ -137,4 +137,6 @@ basFSCmds:
|
||||
.dw basFNEW
|
||||
.db "fdel", 0
|
||||
.dw basFDEL
|
||||
.db "fson", 0
|
||||
.dw fsOn
|
||||
.db 0xff ; end of table
|
||||
|
14
apps/basic/sdc.asm
Normal file
14
apps/basic/sdc.asm
Normal 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
|
@ -101,8 +101,7 @@ fsInit:
|
||||
xor a
|
||||
ld hl, FS_BLK
|
||||
ld b, FS_RAMEND-FS_BLK
|
||||
call fill
|
||||
ret
|
||||
jp fill
|
||||
|
||||
; *** Navigation ***
|
||||
|
||||
@ -286,7 +285,7 @@ fsFindFN:
|
||||
call fsNext
|
||||
jr z, .loop
|
||||
; End of the chain, not found
|
||||
call unsetZ
|
||||
; Z already unset
|
||||
.end:
|
||||
pop de
|
||||
ret
|
||||
@ -311,7 +310,7 @@ fsIsValid:
|
||||
; Returns whether current block is deleted in Z flag.
|
||||
fsIsDeleted:
|
||||
ld a, (FS_META+FS_META_FNAME_OFFSET)
|
||||
cp 0 ; Z flag is our answer
|
||||
or a ; Z flag is our answer
|
||||
ret
|
||||
|
||||
; *** blkdev methods ***
|
||||
@ -508,12 +507,9 @@ fsOn:
|
||||
jr .end
|
||||
.error:
|
||||
; couldn't mount. Let's reset our variables.
|
||||
xor a
|
||||
ld b, FS_META-FS_BLK ; reset routine pointers and FS ptrs
|
||||
ld hl, FS_BLK
|
||||
call fill
|
||||
|
||||
call fsInit
|
||||
ld a, FS_ERR_NO_FS
|
||||
or a ; unset Z
|
||||
.end:
|
||||
pop bc
|
||||
pop de
|
||||
@ -524,18 +520,16 @@ fsOn:
|
||||
fsIsOn:
|
||||
; check whether (FS_BLK) is zero
|
||||
push hl
|
||||
push de
|
||||
ld hl, (FS_BLK)
|
||||
ld de, 0
|
||||
call cpHLDE
|
||||
ld a, h
|
||||
or l
|
||||
jr nz, .mounted
|
||||
; if equal, it means our FS is not mounted
|
||||
call unsetZ
|
||||
; not mounted, unset Z
|
||||
inc a
|
||||
jr .end
|
||||
.mounted:
|
||||
cp a ; ensure Z
|
||||
.end:
|
||||
pop de
|
||||
pop hl
|
||||
ret
|
||||
|
||||
@ -545,8 +539,6 @@ fsIsOn:
|
||||
; There are no error condition happening midway. If you get an error, then (IY)
|
||||
; was never called.
|
||||
fsIter:
|
||||
call fsIsOn
|
||||
ret nz
|
||||
call fsBegin
|
||||
ret nz
|
||||
.loop:
|
||||
|
@ -621,10 +621,7 @@ sdcCRC:
|
||||
pop af
|
||||
ret
|
||||
|
||||
; *** shell cmds ***
|
||||
|
||||
sdcInitializeCmd:
|
||||
.db "sdci", 0, 0, 0
|
||||
call sdcInitialize
|
||||
ret nz
|
||||
call .setBlkSize
|
||||
@ -678,7 +675,6 @@ sdcInitializeCmd:
|
||||
|
||||
; Flush the current SDC buffer if dirty
|
||||
sdcFlushCmd:
|
||||
.db "sdcf", 0, 0, 0
|
||||
ld hl, SDC_BUFSEC1
|
||||
ld (SDC_BUFPTR), hl
|
||||
call sdcWriteBlk
|
||||
@ -724,14 +720,11 @@ _sdcPlaceBuf:
|
||||
sdcGetB:
|
||||
push hl
|
||||
call _sdcPlaceBuf
|
||||
jr nz, .error
|
||||
jr nz, .end ; NZ already set
|
||||
|
||||
; This is it!
|
||||
ld a, (hl)
|
||||
cp a ; ensure Z
|
||||
jr .end
|
||||
.error:
|
||||
call unsetZ
|
||||
.end:
|
||||
pop hl
|
||||
ret
|
||||
|
@ -2,9 +2,9 @@
|
||||
; The RAM module is selected on A15, so it has the range 0x8000-0xffff
|
||||
.equ RAMSTART 0x8000
|
||||
.equ RAMEND 0xffff
|
||||
.equ PGM_CODEADDR 0x9000
|
||||
.equ ACIA_CTL 0x80 ; Control and status. RS off.
|
||||
.equ ACIA_IO 0x81 ; Transmit. RS on.
|
||||
.equ USER_CODE 0xa000
|
||||
|
||||
jp init ; 3 bytes
|
||||
|
||||
@ -45,25 +45,32 @@ jp aciaInt
|
||||
.equ FS_HANDLE_COUNT 1
|
||||
.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/ari.asm"
|
||||
.inc "lib/parse.asm"
|
||||
.inc "lib/args.asm"
|
||||
.inc "lib/stdio.asm"
|
||||
.equ SHELL_RAMSTART FS_RAMEND
|
||||
.equ SHELL_EXTRA_CMD_COUNT 11
|
||||
.inc "shell/main.asm"
|
||||
.dw sdcInitializeCmd, sdcFlushCmd
|
||||
.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd
|
||||
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
||||
.inc "lib/fmt.asm"
|
||||
.equ EXPR_PARSE parseLiteralOrVar
|
||||
.inc "lib/expr.asm"
|
||||
.inc "basic/util.asm"
|
||||
.inc "basic/parse.asm"
|
||||
.inc "basic/tok.asm"
|
||||
.equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
|
||||
.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"
|
||||
.inc "shell/fs.asm"
|
||||
|
||||
.equ PGM_RAMSTART SHELL_RAMEND
|
||||
.inc "shell/pgm.asm"
|
||||
|
||||
.equ SDC_RAMSTART PGM_RAMEND
|
||||
.equ SDC_RAMSTART BAS_RAMEND
|
||||
.equ SDC_PORT_CSHIGH 6
|
||||
.equ SDC_PORT_CSLOW 5
|
||||
.equ SDC_PORT_SPI 4
|
||||
@ -71,22 +78,30 @@ jp aciaInt
|
||||
|
||||
init:
|
||||
di
|
||||
; setup stack
|
||||
ld hl, RAMEND
|
||||
ld sp, hl
|
||||
ld sp, RAMEND
|
||||
im 1
|
||||
call aciaInit
|
||||
call fsInit
|
||||
call shellInit
|
||||
ld hl, pgmShellHook
|
||||
ld (SHELL_CMDHOOK), hl
|
||||
call basInit
|
||||
ld hl, basFindCmdExtra
|
||||
ld (BAS_FINDHOOK), hl
|
||||
|
||||
xor a
|
||||
ld de, BLOCKDEV_SEL
|
||||
call blkSel
|
||||
|
||||
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 ***
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user