2019-05-09 12:58:41 -04:00
|
|
|
; named shell_.asm to avoid infinite include loop.
|
2019-05-20 07:29:19 -04:00
|
|
|
.equ RAMSTART 0x4000
|
|
|
|
.equ RAMEND 0x5000
|
|
|
|
.equ STDIO_PORT 0x00
|
|
|
|
.equ FS_DATA_PORT 0x01
|
|
|
|
.equ FS_SEEKL_PORT 0x02
|
|
|
|
.equ FS_SEEKH_PORT 0x03
|
2019-05-09 12:58:41 -04:00
|
|
|
|
2019-05-20 07:29:19 -04:00
|
|
|
jp init
|
2019-05-09 12:58:41 -04:00
|
|
|
|
|
|
|
#include "core.asm"
|
2019-05-17 09:33:20 -04:00
|
|
|
#include "parse.asm"
|
2019-05-09 12:58:41 -04:00
|
|
|
|
2019-05-20 07:29:19 -04:00
|
|
|
.equ BLOCKDEV_RAMSTART RAMSTART
|
|
|
|
.equ BLOCKDEV_COUNT 4
|
2019-05-09 12:58:41 -04:00
|
|
|
#include "blockdev.asm"
|
|
|
|
; List of devices
|
|
|
|
.dw emulGetC, emulPutC, 0, 0
|
2019-05-12 11:20:31 -04:00
|
|
|
.dw fsdevGetC, fsdevPutC, fsdevSeek, fsdevTell
|
2019-05-12 15:38:58 -04:00
|
|
|
.dw stdoutGetC, stdoutPutC, stdoutSeek, stdoutTell
|
|
|
|
.dw stdinGetC, stdinPutC, stdinSeek, stdinTell
|
2019-05-09 12:58:41 -04:00
|
|
|
|
|
|
|
#include "blockdev_cmds.asm"
|
|
|
|
|
2019-05-20 07:29:19 -04:00
|
|
|
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
|
2019-05-17 08:14:19 -04:00
|
|
|
#include "stdio.asm"
|
|
|
|
|
|
|
|
.equ FS_RAMSTART STDIO_RAMEND
|
2019-05-12 11:20:31 -04:00
|
|
|
.equ FS_HANDLE_COUNT 2
|
|
|
|
#include "fs.asm"
|
2019-05-16 13:13:46 -04:00
|
|
|
#include "fs_cmds.asm"
|
2019-05-12 11:20:31 -04:00
|
|
|
|
2019-05-20 07:29:19 -04:00
|
|
|
.equ SHELL_RAMSTART FS_RAMEND
|
|
|
|
.equ SHELL_EXTRA_CMD_COUNT 7
|
2019-05-09 12:58:41 -04:00
|
|
|
#include "shell.asm"
|
2019-05-12 15:38:58 -04:00
|
|
|
.dw blkBselCmd, blkSeekCmd, fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
2019-05-12 11:20:31 -04:00
|
|
|
|
|
|
|
init:
|
|
|
|
di
|
|
|
|
; setup stack
|
|
|
|
ld hl, RAMEND
|
|
|
|
ld sp, hl
|
2019-05-17 08:14:19 -04:00
|
|
|
xor a
|
|
|
|
ld de, BLOCKDEV_GETC
|
|
|
|
call blkSel
|
|
|
|
call stdioInit
|
2019-05-12 11:20:31 -04:00
|
|
|
call fsInit
|
|
|
|
ld a, 1 ; select fsdev
|
|
|
|
ld de, BLOCKDEV_GETC
|
|
|
|
call blkSel
|
|
|
|
call fsOn
|
|
|
|
xor a ; select ACIA
|
|
|
|
ld de, BLOCKDEV_GETC
|
|
|
|
call blkSel
|
|
|
|
call shellInit
|
|
|
|
jp shellLoop
|
2019-05-09 12:58:41 -04:00
|
|
|
|
|
|
|
emulGetC:
|
|
|
|
; Blocks until a char is returned
|
|
|
|
in a, (STDIO_PORT)
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
|
|
|
emulPutC:
|
|
|
|
out (STDIO_PORT), a
|
|
|
|
ret
|
|
|
|
|
2019-05-12 11:20:31 -04:00
|
|
|
fsdevGetC:
|
|
|
|
in a, (FS_DATA_PORT)
|
2019-05-12 15:38:58 -04:00
|
|
|
cp a ; ensure Z
|
2019-05-12 11:20:31 -04:00
|
|
|
ret
|
|
|
|
|
|
|
|
fsdevPutC:
|
|
|
|
out (FS_DATA_PORT), a
|
|
|
|
ret
|
|
|
|
|
|
|
|
fsdevSeek:
|
2019-05-12 15:38:58 -04:00
|
|
|
push af
|
2019-05-12 11:20:31 -04:00
|
|
|
ld a, l
|
|
|
|
out (FS_SEEKL_PORT), a
|
|
|
|
ld a, h
|
|
|
|
out (FS_SEEKH_PORT), a
|
2019-05-12 15:38:58 -04:00
|
|
|
pop af
|
2019-05-12 11:20:31 -04:00
|
|
|
ret
|
|
|
|
|
|
|
|
fsdevTell:
|
2019-05-12 15:38:58 -04:00
|
|
|
push af
|
2019-05-12 11:20:31 -04:00
|
|
|
in a, (FS_SEEKL_PORT)
|
|
|
|
ld l, a
|
|
|
|
in a, (FS_SEEKH_PORT)
|
|
|
|
ld h, a
|
2019-05-12 15:38:58 -04:00
|
|
|
pop af
|
2019-05-12 11:20:31 -04:00
|
|
|
ret
|
2019-05-12 15:38:58 -04:00
|
|
|
|
|
|
|
.equ STDOUT_HANDLE FS_HANDLES
|
|
|
|
|
|
|
|
stdoutGetC:
|
|
|
|
ld de, STDOUT_HANDLE
|
|
|
|
jp fsGetC
|
|
|
|
|
|
|
|
stdoutPutC:
|
|
|
|
ld de, STDOUT_HANDLE
|
|
|
|
jp fsPutC
|
|
|
|
|
|
|
|
stdoutSeek:
|
|
|
|
ld de, STDOUT_HANDLE
|
|
|
|
jp fsSeek
|
|
|
|
|
|
|
|
stdoutTell:
|
|
|
|
ld de, STDOUT_HANDLE
|
|
|
|
jp fsTell
|
|
|
|
|
|
|
|
.equ STDIN_HANDLE FS_HANDLES+FS_HANDLE_SIZE
|
|
|
|
|
|
|
|
stdinGetC:
|
|
|
|
ld de, STDIN_HANDLE
|
|
|
|
jp fsGetC
|
|
|
|
|
|
|
|
stdinPutC:
|
|
|
|
ld de, STDIN_HANDLE
|
|
|
|
jp fsPutC
|
|
|
|
|
|
|
|
stdinSeek:
|
|
|
|
ld de, STDIN_HANDLE
|
|
|
|
jp fsSeek
|
|
|
|
|
|
|
|
stdinTell:
|
|
|
|
ld de, STDIN_HANDLE
|
|
|
|
jp fsTell
|
|
|
|
|