2020-02-12 10:20:47 -05:00
|
|
|
; RAMSTART is a label at the end of the file
|
|
|
|
.equ RAMEND 0xcfff
|
2020-02-22 14:43:07 -05:00
|
|
|
; Address of the *CL driver. Same as in recv.asm
|
|
|
|
.equ COM_DRV_ADDR 0x0238
|
2020-02-22 20:06:59 -05:00
|
|
|
; in sync with user.h. Last BAS_RAMEND: 0x5705
|
|
|
|
.equ USER_CODE 0x5800
|
2020-02-12 10:20:47 -05:00
|
|
|
|
|
|
|
; Free memory in TRSDOS starts at 0x3000
|
|
|
|
.org 0x3000
|
|
|
|
jp init
|
|
|
|
|
2020-02-23 14:51:19 -05:00
|
|
|
; *** Jump Table ***
|
|
|
|
jp strncmp
|
|
|
|
jp upcase
|
|
|
|
jp findchar
|
|
|
|
jp printstr
|
|
|
|
jp blkSet
|
|
|
|
jp blkSel
|
|
|
|
jp _blkGetB
|
|
|
|
jp _blkPutB
|
|
|
|
jp _blkSeek
|
|
|
|
jp _blkTell
|
|
|
|
jp fsFindFN
|
|
|
|
jp fsOpen
|
|
|
|
jp fsGetB
|
|
|
|
|
2020-02-12 10:20:47 -05:00
|
|
|
.inc "err.h"
|
2020-02-21 19:30:57 -05:00
|
|
|
.inc "blkdev.h"
|
2020-02-22 20:06:59 -05:00
|
|
|
.inc "fs.h"
|
2020-02-12 10:20:47 -05:00
|
|
|
.inc "ascii.h"
|
|
|
|
.inc "core.asm"
|
|
|
|
.inc "str.asm"
|
|
|
|
|
|
|
|
.inc "trs80/kbd.asm"
|
|
|
|
.inc "trs80/vid.asm"
|
2020-02-21 19:30:57 -05:00
|
|
|
.equ FLOPPY_RAMSTART RAMSTART
|
|
|
|
.inc "trs80/floppy.asm"
|
2020-02-12 10:20:47 -05:00
|
|
|
|
2020-02-21 19:30:57 -05:00
|
|
|
.equ BLOCKDEV_RAMSTART FLOPPY_RAMEND
|
2020-02-22 20:06:59 -05:00
|
|
|
.equ BLOCKDEV_COUNT 3
|
2020-02-21 19:30:57 -05:00
|
|
|
.inc "blockdev.asm"
|
|
|
|
; List of devices
|
|
|
|
.dw floppyGetB, floppyPutB
|
2020-02-22 20:06:59 -05:00
|
|
|
.dw blk1GetB, blk1PutB
|
|
|
|
.dw blk2GetB, blk2PutB
|
2020-02-21 19:30:57 -05:00
|
|
|
|
|
|
|
.equ STDIO_RAMSTART BLOCKDEV_RAMEND
|
2020-02-12 10:20:47 -05:00
|
|
|
.equ STDIO_GETC trs80GetC
|
|
|
|
.equ STDIO_PUTC trs80PutC
|
|
|
|
.inc "stdio.asm"
|
|
|
|
|
2020-02-22 20:06:59 -05:00
|
|
|
.equ FS_RAMSTART STDIO_RAMEND
|
|
|
|
.equ FS_HANDLE_COUNT 2
|
|
|
|
.inc "fs.asm"
|
|
|
|
|
2020-02-21 08:40:42 -05:00
|
|
|
; The TRS-80 generates a double line feed if we give it both CR and LF.
|
|
|
|
.equ printcrlf printcr
|
|
|
|
|
2020-02-12 10:20:47 -05:00
|
|
|
; *** BASIC ***
|
|
|
|
|
|
|
|
; RAM space used in different routines for short term processing.
|
|
|
|
.equ SCRATCHPAD_SIZE STDIO_BUFSIZE
|
2020-02-22 20:06:59 -05:00
|
|
|
.equ SCRATCHPAD FS_RAMEND
|
2020-02-12 10:20:47 -05:00
|
|
|
.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"
|
2020-02-22 20:06:59 -05:00
|
|
|
.equ BFS_RAMSTART BUF_RAMEND
|
|
|
|
.inc "basic/fs.asm"
|
2020-02-21 19:30:57 -05:00
|
|
|
.inc "basic/blk.asm"
|
2020-02-22 12:09:43 -05:00
|
|
|
.inc "basic/floppy.asm"
|
2020-02-22 20:06:59 -05:00
|
|
|
.equ BAS_RAMSTART BFS_RAMEND
|
2020-02-12 10:20:47 -05:00
|
|
|
.inc "basic/main.asm"
|
|
|
|
|
2020-02-22 20:06:59 -05:00
|
|
|
.out BAS_RAMEND
|
|
|
|
|
2020-02-12 10:20:47 -05:00
|
|
|
init:
|
|
|
|
ld sp, RAMEND
|
2020-02-21 19:30:57 -05:00
|
|
|
call floppyInit
|
2020-02-22 20:06:59 -05:00
|
|
|
call fsInit
|
2020-02-12 10:20:47 -05:00
|
|
|
call basInit
|
2020-02-21 19:30:57 -05:00
|
|
|
ld hl, basFindCmdExtra
|
|
|
|
ld (BAS_FINDHOOK), hl
|
|
|
|
|
|
|
|
xor a
|
|
|
|
ld de, BLOCKDEV_SEL
|
|
|
|
call blkSel
|
|
|
|
|
2020-02-12 10:20:47 -05:00
|
|
|
jp basStart
|
|
|
|
|
2020-02-21 08:40:42 -05:00
|
|
|
printcr:
|
|
|
|
push af
|
|
|
|
ld a, CR
|
|
|
|
call STDIO_PUTC
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2020-02-22 14:43:07 -05:00
|
|
|
; Receive a byte from *cl and put it in A.
|
|
|
|
; Returns A > 0xff when receiving the last byte
|
|
|
|
recvCmd:
|
|
|
|
xor a
|
|
|
|
ld (VAR_TBL+1), a ; pre-set MSB
|
|
|
|
; put a 0xff mask in B, which will become 0x7f if we receive a 0x20
|
|
|
|
ld b, 0xff
|
|
|
|
.inner:
|
|
|
|
ld a, 0x03 ; @GET
|
|
|
|
ld de, COM_DRV_ADDR
|
|
|
|
rst 0x28
|
|
|
|
jr nz, .maybeerror
|
|
|
|
or a
|
|
|
|
jr z, .eof ; Sending a straight NULL ends the comm.
|
|
|
|
; @PUT that char back
|
|
|
|
ld c, a
|
|
|
|
ld a, 0x04 ; @PUT
|
|
|
|
ld de, COM_DRV_ADDR
|
|
|
|
rst 0x28
|
|
|
|
ret nz ; error
|
|
|
|
ld a, c
|
|
|
|
cp 0x20
|
|
|
|
jr z, .escapechar
|
|
|
|
; not an escape char, good
|
|
|
|
and b ; apply mask
|
|
|
|
ld (VAR_TBL), a
|
|
|
|
xor a ; ensure Z
|
|
|
|
ret
|
|
|
|
.maybeerror:
|
|
|
|
; was it an error?
|
|
|
|
or a
|
|
|
|
jr z, .inner ; not an error, just loop
|
|
|
|
ret ; error
|
|
|
|
.escapechar:
|
|
|
|
ld b, 0x7f
|
|
|
|
jr .inner
|
|
|
|
.eof:
|
|
|
|
dec a ; A = 0xff
|
|
|
|
ld (VAR_TBL+1), a
|
|
|
|
xor a ; ensure Z
|
|
|
|
ret
|
|
|
|
|
2020-02-21 19:30:57 -05:00
|
|
|
basFindCmdExtra:
|
2020-02-22 12:09:43 -05:00
|
|
|
ld hl, basFloppyCmds
|
|
|
|
call basFindCmd
|
|
|
|
ret z
|
2020-02-21 19:30:57 -05:00
|
|
|
ld hl, basBLKCmds
|
2020-02-22 14:43:07 -05:00
|
|
|
call basFindCmd
|
|
|
|
ret z
|
2020-02-22 20:06:59 -05:00
|
|
|
ld hl, basFSCmds
|
|
|
|
call basFindCmd
|
|
|
|
ret z
|
2020-02-22 14:43:07 -05:00
|
|
|
ld hl, .cmds
|
2020-02-23 14:51:19 -05:00
|
|
|
call basFindCmd
|
|
|
|
ret z
|
|
|
|
jp basPgmHook
|
2020-02-21 19:30:57 -05:00
|
|
|
|
2020-02-22 14:43:07 -05:00
|
|
|
.cmds:
|
|
|
|
.db "recv", 0
|
|
|
|
.dw recvCmd
|
|
|
|
.db 0xff ; end of table
|
|
|
|
|
2020-02-22 20:06:59 -05:00
|
|
|
; *** blkdev 1: file handle 0 ***
|
|
|
|
|
|
|
|
blk1GetB:
|
|
|
|
ld ix, FS_HANDLES
|
|
|
|
jp fsGetB
|
|
|
|
|
|
|
|
blk1PutB:
|
|
|
|
ld ix, FS_HANDLES
|
|
|
|
jp fsPutB
|
|
|
|
|
|
|
|
; *** blkdev 2: file handle 1 ***
|
|
|
|
|
|
|
|
blk2GetB:
|
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
|
|
|
jp fsGetB
|
|
|
|
|
|
|
|
blk2PutB:
|
|
|
|
ld ix, FS_HANDLES+FS_HANDLE_SIZE
|
|
|
|
jp fsPutB
|
|
|
|
|
2020-02-12 10:20:47 -05:00
|
|
|
RAMSTART:
|