2019-07-21 15:37:03 -04:00
|
|
|
; 8K of onboard RAM
|
|
|
|
.equ RAMSTART 0xc000
|
2019-07-25 14:23:13 -04:00
|
|
|
.equ USER_RAMSTART 0xc200
|
2019-07-21 15:37:03 -04:00
|
|
|
; Memory register at the end of RAM. Must not overwrite
|
|
|
|
.equ RAMEND 0xddd0
|
|
|
|
|
|
|
|
jp init
|
|
|
|
|
|
|
|
; *** JUMP TABLE ***
|
|
|
|
jp strncmp
|
|
|
|
jp addDE
|
|
|
|
jp addHL
|
|
|
|
jp upcase
|
|
|
|
jp unsetZ
|
|
|
|
jp intoDE
|
|
|
|
jp intoHL
|
|
|
|
jp writeHLinDE
|
|
|
|
jp findchar
|
|
|
|
jp parseHex
|
|
|
|
jp parseHexPair
|
|
|
|
jp blkSel
|
|
|
|
jp blkSet
|
|
|
|
jp fsFindFN
|
|
|
|
jp fsOpen
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
|
|
|
jp fsPutB
|
2019-07-21 15:37:03 -04:00
|
|
|
jp fsSetSize
|
|
|
|
jp cpHLDE
|
|
|
|
jp parseArgs
|
|
|
|
jp printstr
|
2019-10-30 16:59:35 -04:00
|
|
|
jp _blkGetB
|
|
|
|
jp _blkPutB
|
2019-07-21 15:37:03 -04:00
|
|
|
jp _blkSeek
|
|
|
|
jp _blkTell
|
|
|
|
jp printcrlf
|
|
|
|
jp stdioPutC
|
|
|
|
jp stdioReadLine
|
|
|
|
|
|
|
|
.fill 0x66-$
|
|
|
|
retn
|
|
|
|
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "err.h"
|
2019-11-13 20:38:06 -05:00
|
|
|
.inc "ascii.h"
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "core.asm"
|
|
|
|
.inc "parse.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "sms/kbd.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
.equ KBD_RAMSTART RAMSTART
|
|
|
|
.equ KBD_FETCHKC smskbdFetchKCB
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "kbd.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
.equ VDP_RAMSTART KBD_RAMEND
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "sms/vdp.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
.equ STDIO_RAMSTART VDP_RAMEND
|
2019-11-04 09:55:12 -05:00
|
|
|
.equ STDIO_GETC kbdGetC
|
|
|
|
.equ STDIO_PUTC vdpPutC
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "stdio.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-07-25 14:23:13 -04:00
|
|
|
.equ MMAP_START 0xd700
|
|
|
|
; 0x180 is to leave some space for the stack
|
|
|
|
.equ MMAP_LEN RAMEND-MMAP_START-0x180
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "mmap.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
.equ BLOCKDEV_RAMSTART STDIO_RAMEND
|
|
|
|
.equ BLOCKDEV_COUNT 3
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "blockdev.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
; List of devices
|
2019-10-30 16:59:35 -04:00
|
|
|
.dw mmapGetB, mmapPutB
|
|
|
|
.dw f0GetB, f0PutB
|
|
|
|
.dw f1GetB, f1PutB
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
.equ FS_RAMSTART BLOCKDEV_RAMEND
|
|
|
|
.equ FS_HANDLE_COUNT 2
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "fs.asm"
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
.equ SHELL_RAMSTART FS_RAMEND
|
2019-07-25 14:23:13 -04:00
|
|
|
.equ SHELL_EXTRA_CMD_COUNT 10
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "shell.asm"
|
2019-07-25 14:23:13 -04:00
|
|
|
.dw edCmd, zasmCmd, fnewCmd, fdelCmd, fopnCmd, flsCmd, blkBselCmd
|
2019-07-21 15:37:03 -04:00
|
|
|
.dw blkSeekCmd, blkLoadCmd, blkSaveCmd
|
|
|
|
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "blockdev_cmds.asm"
|
|
|
|
.inc "fs_cmds.asm"
|
2019-07-23 15:42:52 -04:00
|
|
|
|
2019-07-25 14:23:13 -04:00
|
|
|
.equ PGM_RAMSTART SHELL_RAMEND
|
|
|
|
.equ PGM_CODEADDR USER_RAMSTART
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "pgm.asm"
|
2019-07-25 14:23:13 -04:00
|
|
|
|
|
|
|
.out PGM_RAMEND
|
|
|
|
|
2019-07-21 15:37:03 -04:00
|
|
|
init:
|
|
|
|
di
|
|
|
|
im 1
|
|
|
|
|
|
|
|
ld sp, RAMEND
|
|
|
|
|
|
|
|
; init a FS in mmap
|
|
|
|
ld hl, MMAP_START
|
|
|
|
ld a, 'C'
|
|
|
|
ld (hl), a
|
|
|
|
inc hl
|
|
|
|
ld a, 'F'
|
|
|
|
ld (hl), a
|
|
|
|
inc hl
|
|
|
|
ld a, 'S'
|
|
|
|
ld (hl), a
|
2019-07-23 23:01:17 -04:00
|
|
|
|
2019-07-21 15:37:03 -04:00
|
|
|
call fsInit
|
|
|
|
xor a
|
2019-07-23 23:01:17 -04:00
|
|
|
ld de, BLOCKDEV_SEL
|
2019-07-21 15:37:03 -04:00
|
|
|
call blkSel
|
2019-07-23 23:01:17 -04:00
|
|
|
call fsOn
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
call kbdInit
|
|
|
|
call vdpInit
|
|
|
|
|
|
|
|
call shellInit
|
2019-07-25 14:23:13 -04:00
|
|
|
ld hl, pgmShellHook
|
|
|
|
ld (SHELL_CMDHOOK), hl
|
2019-07-21 15:37:03 -04:00
|
|
|
jp shellLoop
|
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
f0GetB:
|
2019-07-21 15:37:03 -04:00
|
|
|
ld ix, FS_HANDLES
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
f0PutB:
|
2019-07-21 15:37:03 -04:00
|
|
|
ld ix, FS_HANDLES
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsPutB
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
f1GetB:
|
2019-07-21 15:37:03 -04:00
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsGetB
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-10-30 16:59:35 -04:00
|
|
|
f1PutB:
|
2019-07-21 15:37:03 -04:00
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
2019-10-30 16:59:35 -04:00
|
|
|
jp fsPutB
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
edCmd:
|
2019-07-21 15:57:55 -04:00
|
|
|
.db "ed", 0, 0, 0b1001, 0, 0
|
2019-07-21 15:37:03 -04:00
|
|
|
push hl \ pop ix
|
|
|
|
ld l, (ix)
|
|
|
|
ld h, (ix+1)
|
2019-07-22 10:10:42 -04:00
|
|
|
jp 0x1900
|
2019-07-21 15:37:03 -04:00
|
|
|
|
|
|
|
zasmCmd:
|
|
|
|
.db "zasm", 0b1001, 0, 0
|
|
|
|
push hl \ pop ix
|
|
|
|
ld l, (ix)
|
|
|
|
ld h, (ix+1)
|
2019-07-22 10:10:42 -04:00
|
|
|
jp 0x1d00
|
2019-07-21 15:37:03 -04:00
|
|
|
|
2019-07-22 10:10:42 -04:00
|
|
|
; last time I checked, PC at this point was 0x183c. Let's give us a nice margin
|
2019-07-21 15:37:03 -04:00
|
|
|
; for the start of ed.
|
2019-07-22 10:10:42 -04:00
|
|
|
.fill 0x1900-$
|
2019-07-21 15:37:03 -04:00
|
|
|
.bin "ed.bin"
|
|
|
|
|
2019-07-22 10:10:42 -04:00
|
|
|
; Last check: 0x1c4e
|
|
|
|
.fill 0x1d00-$
|
2019-07-21 15:37:03 -04:00
|
|
|
.bin "zasm.bin"
|
|
|
|
|
|
|
|
.fill 0x7ff0-$
|
|
|
|
.db "TMR SEGA", 0x00, 0x00, 0xfb, 0x68, 0x00, 0x00, 0x00, 0x4c
|
|
|
|
|
|
|
|
|