2019-11-16 07:37:49 +11:00
|
|
|
.inc "blkdev.h"
|
|
|
|
.inc "fs.h"
|
|
|
|
.inc "err.h"
|
|
|
|
.inc "ascii.h"
|
2019-12-12 06:05:34 +11:00
|
|
|
.equ RAMSTART 0x2000
|
|
|
|
.equ USER_CODE 0x4200
|
2019-05-20 21:29:19 +10:00
|
|
|
.equ STDIO_PORT 0x00
|
|
|
|
.equ FS_DATA_PORT 0x01
|
2019-06-05 01:53:02 +10:00
|
|
|
.equ FS_ADDR_PORT 0x02
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2019-05-20 21:29:19 +10:00
|
|
|
jp init
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2019-06-01 04:50:43 +10:00
|
|
|
; *** JUMP TABLE ***
|
2019-06-03 22:32:25 +10:00
|
|
|
jp strncmp
|
|
|
|
jp upcase
|
|
|
|
jp findchar
|
2019-11-16 07:37:49 +11:00
|
|
|
jp blkSelPtr
|
2019-06-03 22:32:25 +10:00
|
|
|
jp blkSel
|
2019-06-05 10:45:01 +10:00
|
|
|
jp blkSet
|
2019-11-16 07:37:49 +11:00
|
|
|
jp blkSeek
|
|
|
|
jp blkTell
|
|
|
|
jp blkGetB
|
|
|
|
jp blkPutB
|
2019-06-03 22:32:25 +10:00
|
|
|
jp fsFindFN
|
|
|
|
jp fsOpen
|
2019-10-31 07:59:35 +11:00
|
|
|
jp fsGetB
|
|
|
|
jp fsPutB
|
2019-07-22 01:39:00 +10:00
|
|
|
jp fsSetSize
|
2019-11-16 07:37:49 +11:00
|
|
|
jp fsOn
|
|
|
|
jp fsIter
|
|
|
|
jp fsAlloc
|
|
|
|
jp fsDel
|
|
|
|
jp fsHandle
|
2019-06-01 04:50:43 +10:00
|
|
|
jp printstr
|
2019-11-16 07:37:49 +11:00
|
|
|
jp printnstr
|
2019-10-31 07:59:35 +11:00
|
|
|
jp _blkGetB
|
|
|
|
jp _blkPutB
|
2019-06-05 01:53:02 +10:00
|
|
|
jp _blkSeek
|
|
|
|
jp _blkTell
|
2019-07-13 23:57:37 +10:00
|
|
|
jp printcrlf
|
2019-11-16 07:37:49 +11:00
|
|
|
jp stdioGetC
|
2019-07-14 04:01:20 +10:00
|
|
|
jp stdioPutC
|
2019-07-15 07:29:00 +10:00
|
|
|
jp stdioReadLine
|
2019-06-01 04:50:43 +10:00
|
|
|
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "core.asm"
|
2019-11-15 01:55:31 +11:00
|
|
|
.inc "str.asm"
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2019-05-20 21:29:19 +10:00
|
|
|
.equ BLOCKDEV_RAMSTART RAMSTART
|
2019-06-04 01:15:07 +10:00
|
|
|
.equ BLOCKDEV_COUNT 4
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "blockdev.asm"
|
2019-05-10 02:58:41 +10:00
|
|
|
; List of devices
|
2019-10-31 07:59:35 +11:00
|
|
|
.dw fsdevGetB, fsdevPutB
|
|
|
|
.dw stdoutGetB, stdoutPutB
|
|
|
|
.dw stdinGetB, stdinPutB
|
|
|
|
.dw mmapGetB, mmapPutB
|
2019-05-10 02:58:41 +10:00
|
|
|
|
|
|
|
|
2019-06-04 01:15:07 +10:00
|
|
|
.equ MMAP_START 0xe000
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "mmap.asm"
|
2019-06-04 01:15:07 +10:00
|
|
|
|
2019-06-05 01:53:02 +10:00
|
|
|
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
|
2019-11-05 01:55:12 +11:00
|
|
|
.equ STDIO_GETC emulGetC
|
|
|
|
.equ STDIO_PUTC emulPutC
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "stdio.asm"
|
2019-05-17 22:14:19 +10:00
|
|
|
|
|
|
|
.equ FS_RAMSTART STDIO_RAMEND
|
2019-05-13 01:20:31 +10:00
|
|
|
.equ FS_HANDLE_COUNT 2
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "fs.asm"
|
2019-05-13 01:20:31 +10:00
|
|
|
|
2019-12-12 06:05:34 +11:00
|
|
|
; *** 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/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"
|
|
|
|
.equ BFS_RAMSTART BUF_RAMEND
|
|
|
|
.inc "basic/fs.asm"
|
|
|
|
.inc "basic/blk.asm"
|
|
|
|
.equ BAS_RAMSTART BFS_RAMEND
|
|
|
|
.inc "basic/main.asm"
|
|
|
|
|
2019-05-13 01:20:31 +10:00
|
|
|
init:
|
|
|
|
di
|
|
|
|
; setup stack
|
2019-12-12 06:05:34 +11:00
|
|
|
ld sp, 0xffff
|
2019-05-13 01:20:31 +10:00
|
|
|
call fsInit
|
2019-06-03 00:50:18 +10:00
|
|
|
ld a, 0 ; select fsdev
|
2019-06-04 23:56:36 +10:00
|
|
|
ld de, BLOCKDEV_SEL
|
2019-05-13 01:20:31 +10:00
|
|
|
call blkSel
|
|
|
|
call fsOn
|
2019-12-12 06:05:34 +11:00
|
|
|
call basInit
|
|
|
|
ld hl, basFindCmdExtra
|
|
|
|
ld (BAS_FINDHOOK), hl
|
|
|
|
jp basStart
|
|
|
|
|
|
|
|
basFindCmdExtra:
|
|
|
|
ld hl, basFSCmds
|
|
|
|
call basFindCmd
|
|
|
|
ret z
|
|
|
|
ld hl, basBLKCmds
|
|
|
|
call basFindCmd
|
|
|
|
ret z
|
|
|
|
jp basPgmHook
|
2019-05-10 02:58:41 +10:00
|
|
|
|
2019-11-01 09:49:02 +11:00
|
|
|
emulGetC:
|
2019-05-10 02:58:41 +10:00
|
|
|
; Blocks until a char is returned
|
|
|
|
in a, (STDIO_PORT)
|
|
|
|
cp a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
2019-11-01 09:49:02 +11:00
|
|
|
emulPutC:
|
2019-05-10 02:58:41 +10:00
|
|
|
out (STDIO_PORT), a
|
|
|
|
ret
|
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
fsdevGetB:
|
2019-06-05 01:53:02 +10:00
|
|
|
ld a, e
|
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
ld a, h
|
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
ld a, l
|
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
in a, (FS_ADDR_PORT)
|
|
|
|
or a
|
|
|
|
ret nz
|
2019-05-13 01:20:31 +10:00
|
|
|
in a, (FS_DATA_PORT)
|
2019-05-13 05:38:58 +10:00
|
|
|
cp a ; ensure Z
|
2019-05-13 01:20:31 +10:00
|
|
|
ret
|
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
fsdevPutB:
|
2019-05-13 05:38:58 +10:00
|
|
|
push af
|
2019-05-29 05:56:39 +10:00
|
|
|
ld a, e
|
2019-06-05 01:53:02 +10:00
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
ld a, h
|
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
ld a, l
|
|
|
|
out (FS_ADDR_PORT), a
|
|
|
|
in a, (FS_ADDR_PORT)
|
2019-06-06 09:51:19 +10:00
|
|
|
cp 2 ; only A > 1 means error
|
|
|
|
jr nc, .error ; A >= 2
|
2019-05-13 05:38:58 +10:00
|
|
|
pop af
|
2019-06-05 01:53:02 +10:00
|
|
|
out (FS_DATA_PORT), a
|
2019-06-06 06:13:15 +10:00
|
|
|
cp a ; ensure Z
|
2019-05-13 01:20:31 +10:00
|
|
|
ret
|
2019-06-05 01:53:02 +10:00
|
|
|
.error:
|
2019-05-13 05:38:58 +10:00
|
|
|
pop af
|
2019-06-05 01:53:02 +10:00
|
|
|
jp unsetZ ; returns
|
2019-05-13 05:38:58 +10:00
|
|
|
|
|
|
|
.equ STDOUT_HANDLE FS_HANDLES
|
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
stdoutGetB:
|
2019-06-03 00:18:03 +10:00
|
|
|
ld ix, STDOUT_HANDLE
|
2019-10-31 07:59:35 +11:00
|
|
|
jp fsGetB
|
2019-05-13 05:38:58 +10:00
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
stdoutPutB:
|
2019-06-03 00:18:03 +10:00
|
|
|
ld ix, STDOUT_HANDLE
|
2019-10-31 07:59:35 +11:00
|
|
|
jp fsPutB
|
2019-05-13 05:38:58 +10:00
|
|
|
|
|
|
|
.equ STDIN_HANDLE FS_HANDLES+FS_HANDLE_SIZE
|
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
stdinGetB:
|
2019-06-03 00:18:03 +10:00
|
|
|
ld ix, STDIN_HANDLE
|
2019-10-31 07:59:35 +11:00
|
|
|
jp fsGetB
|
2019-05-13 05:38:58 +10:00
|
|
|
|
2019-10-31 07:59:35 +11:00
|
|
|
stdinPutB:
|
2019-06-03 00:18:03 +10:00
|
|
|
ld ix, STDIN_HANDLE
|
2019-10-31 07:59:35 +11:00
|
|
|
jp fsPutB
|