1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-24 14:38:05 +11:00

zasm: change ioRewind to ioSeek

Will need it soon.
This commit is contained in:
Virgil Dupras 2019-05-15 13:41:56 -04:00
parent 33a1ee250d
commit fa28d64278
4 changed files with 20 additions and 8 deletions

View File

@ -22,8 +22,7 @@ ioPutC:
ld ix, (IO_OUT_PUTC)
jp (ix)
ioRewind:
ld hl, 0
ioSeek:
ld ix, (IO_IN_SEEK)
jp (ix)

View File

@ -75,7 +75,8 @@ zasmMain:
call zasmParseFile
ret nz
; Second pass
call ioRewind
ld hl, 0
call ioSeek
xor a
ld (ZASM_FIRST_PASS), a
call zasmParseFile

View File

@ -27,7 +27,7 @@
// in sync with zasm_glue.asm
#define USER_CODE 0x4800
#define STDIO_PORT 0x00
#define STDIN_REWIND 0x01
#define STDIN_SEEK 0x01
// Other consts
#define STDIN_BUFSIZE 0x8000
@ -41,6 +41,7 @@ static uint8_t mem[0x10000];
static uint8_t inpt[STDIN_BUFSIZE];
static int inpt_size;
static int inpt_ptr;
static uint8_t received_first_seek_byte = 0;
static uint8_t io_read(int unused, uint16_t addr)
{
@ -65,8 +66,14 @@ static void io_write(int unused, uint16_t addr, uint8_t val)
#ifndef MEMDUMP
putchar(val);
#endif
} else if (addr == STDIN_REWIND) {
inpt_ptr = 0;
} else if (addr == STDIN_SEEK) {
if (received_first_seek_byte) {
inpt_ptr |= val;
received_first_seek_byte = 0;
} else {
inpt_ptr = (val << 8) & 0xff00;
received_first_seek_byte = 1;
}
} else {
fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val);
}

View File

@ -2,7 +2,7 @@
.equ RAMSTART 0x4000
.equ USER_CODE 0x4800
.equ STDIO_PORT 0x00
.equ STDIN_REWIND 0x01
.equ STDIN_SEEK 0x01
jr init ; 2 bytes
; *** JUMP TABLE ***
@ -43,7 +43,12 @@ emulPutC:
ret
emulSeek:
out (STDIN_REWIND), a
; 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
ret
#include "core.asm"