2019-05-10 04:09:40 +10:00
|
|
|
; Glue code for the emulated environment
|
2019-05-11 08:20:43 +10:00
|
|
|
.equ RAMSTART 0x4000
|
|
|
|
.equ USER_CODE 0x4800
|
2019-05-10 04:09:40 +10:00
|
|
|
.equ STDIO_PORT 0x00
|
2019-05-16 03:41:56 +10:00
|
|
|
.equ STDIN_SEEK 0x01
|
2019-05-10 04:09:40 +10:00
|
|
|
|
|
|
|
jr init ; 2 bytes
|
|
|
|
; *** JUMP TABLE ***
|
|
|
|
jp strncmp
|
|
|
|
jp addDE
|
2019-05-10 11:21:08 +10:00
|
|
|
jp addHL
|
2019-05-10 04:09:40 +10:00
|
|
|
jp upcase
|
|
|
|
jp unsetZ
|
|
|
|
jp intoDE
|
2019-05-13 12:07:21 +10:00
|
|
|
jp intoHL
|
2019-05-10 11:21:08 +10:00
|
|
|
jp findchar
|
2019-05-10 12:14:11 +10:00
|
|
|
jp parseHexPair
|
2019-05-11 08:20:43 +10:00
|
|
|
jp blkSel
|
2019-05-10 04:09:40 +10:00
|
|
|
|
|
|
|
init:
|
|
|
|
di
|
2019-05-11 08:20:43 +10:00
|
|
|
; We put the stack at the end of the kernel memory
|
|
|
|
ld hl, USER_CODE-1
|
2019-05-10 04:09:40 +10:00
|
|
|
ld sp, hl
|
2019-05-11 08:20:43 +10:00
|
|
|
ld h, 0 ; input blkdev
|
|
|
|
ld l, 1 ; output blkdev
|
2019-05-10 04:09:40 +10:00
|
|
|
call USER_CODE
|
|
|
|
; signal the emulator we're done
|
|
|
|
halt
|
|
|
|
|
2019-05-10 05:36:03 +10:00
|
|
|
emulGetC:
|
|
|
|
in a, (STDIO_PORT)
|
|
|
|
or a ; cp 0
|
|
|
|
jr z, .eof
|
|
|
|
cp a ; ensure z
|
|
|
|
ret
|
|
|
|
.eof:
|
|
|
|
call unsetZ
|
|
|
|
ret
|
|
|
|
|
|
|
|
emulPutC:
|
|
|
|
out (STDIO_PORT), a
|
|
|
|
ret
|
|
|
|
|
2019-05-11 10:32:05 +10:00
|
|
|
emulSeek:
|
2019-05-16 03:41:56 +10:00
|
|
|
; the STDIN_SEEK port works by poking it twice. First poke is for high
|
|
|
|
; byte, second poke is for low one.
|
|
|
|
ld a, h
|
|
|
|
out (STDIN_SEEK), a
|
|
|
|
ld a, l
|
|
|
|
out (STDIN_SEEK), a
|
2019-05-11 10:32:05 +10:00
|
|
|
ret
|
|
|
|
|
2019-05-10 04:09:40 +10:00
|
|
|
#include "core.asm"
|
2019-05-11 08:20:43 +10:00
|
|
|
.equ BLOCKDEV_RAMSTART RAMSTART
|
|
|
|
.equ BLOCKDEV_COUNT 2
|
|
|
|
#include "blockdev.asm"
|
|
|
|
; List of devices
|
2019-05-11 10:32:05 +10:00
|
|
|
.dw emulGetC, 0, emulSeek, 0
|
2019-05-11 08:20:43 +10:00
|
|
|
.dw 0, emulPutC, 0, 0
|