basic: can now execute user apps!

Shell replacement sequence beginning in 3, 2, 1...
This commit is contained in:
Virgil Dupras 2019-11-25 22:05:10 -05:00
parent b29073b01d
commit 7c893dada1
4 changed files with 34 additions and 2 deletions

View File

@ -227,3 +227,9 @@ device (bseek, getb, putb).
**ldbas <fname>**: 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).
**basPgmHook**: That is not a command, but a routine to hook into
`BAS_FINDHOOK`. If you do, whenever a command name isn't found, the filesystem
is iterated to see if it finds a file with the same name. If it does, it loads
its contents at `USER_CODE` (from `user.h`) and calls that address, with HL
pointing to the the remaining args in the command line.

View File

@ -77,6 +77,29 @@ basFOPEN:
push de \ pop ix ; IX now points to the file handle.
jp fsOpen
basPgmHook:
; Cmd to find is in (DE)
ex de, hl
; (HL) is suitable for a direct fsFindFN call
call fsFindFN
ret nz
; We have a file! Let's load it in memory
ld ix, BFS_FILE_HDL
call fsOpen
ld hl, 0 ; addr that we read in file handle
ld de, USER_CODE ; addr in mem we write to
.loop:
call fsGetB ; we use Z at end of loop
ld (de), a ; Z preserved
inc hl ; Z preserved in 16-bit
inc de ; Z preserved in 16-bit
jr z, .loop
; Ready to jump. Return USER_CODE in IX and basCallCmd will take care
; of setting (HL) to the arg string.
ld ix, USER_CODE
cp a ; ensure Z
ret
basFSCmds:
.dw basFLS
.db "fls", 0, 0, 0

View File

@ -3,6 +3,7 @@
.inc "err.h"
.inc "ascii.h"
.equ RAMSTART 0x4000
.equ USER_CODE 0x4200
.equ STDIO_PORT 0x00
.equ FS_DATA_PORT 0x01
.equ FS_ADDR_PORT 0x02
@ -109,7 +110,9 @@ basFindCmdExtra:
call basFindCmd
ret z
ld hl, basBLKCmds
jp basFindCmd
call basFindCmd
ret z
jp basPgmHook
emulGetC:
; Blocks until a char is returned

View File

@ -1,5 +1,5 @@
.equ SHELL_RAMSTART 0x4100
.equ USER_CODE 0x4200
.equ USER_CODE 0x4200 ; in sync with glue.asm
; *** JUMP TABLE ***
.equ strncmp 0x03