mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 22:48:05 +11:00
zasm: change ioRewind to ioSeek
Will need it soon.
This commit is contained in:
parent
33a1ee250d
commit
fa28d64278
@ -22,8 +22,7 @@ ioPutC:
|
|||||||
ld ix, (IO_OUT_PUTC)
|
ld ix, (IO_OUT_PUTC)
|
||||||
jp (ix)
|
jp (ix)
|
||||||
|
|
||||||
ioRewind:
|
ioSeek:
|
||||||
ld hl, 0
|
|
||||||
ld ix, (IO_IN_SEEK)
|
ld ix, (IO_IN_SEEK)
|
||||||
jp (ix)
|
jp (ix)
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ zasmMain:
|
|||||||
call zasmParseFile
|
call zasmParseFile
|
||||||
ret nz
|
ret nz
|
||||||
; Second pass
|
; Second pass
|
||||||
call ioRewind
|
ld hl, 0
|
||||||
|
call ioSeek
|
||||||
xor a
|
xor a
|
||||||
ld (ZASM_FIRST_PASS), a
|
ld (ZASM_FIRST_PASS), a
|
||||||
call zasmParseFile
|
call zasmParseFile
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
// in sync with zasm_glue.asm
|
// in sync with zasm_glue.asm
|
||||||
#define USER_CODE 0x4800
|
#define USER_CODE 0x4800
|
||||||
#define STDIO_PORT 0x00
|
#define STDIO_PORT 0x00
|
||||||
#define STDIN_REWIND 0x01
|
#define STDIN_SEEK 0x01
|
||||||
|
|
||||||
// Other consts
|
// Other consts
|
||||||
#define STDIN_BUFSIZE 0x8000
|
#define STDIN_BUFSIZE 0x8000
|
||||||
@ -41,6 +41,7 @@ static uint8_t mem[0x10000];
|
|||||||
static uint8_t inpt[STDIN_BUFSIZE];
|
static uint8_t inpt[STDIN_BUFSIZE];
|
||||||
static int inpt_size;
|
static int inpt_size;
|
||||||
static int inpt_ptr;
|
static int inpt_ptr;
|
||||||
|
static uint8_t received_first_seek_byte = 0;
|
||||||
|
|
||||||
static uint8_t io_read(int unused, uint16_t addr)
|
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
|
#ifndef MEMDUMP
|
||||||
putchar(val);
|
putchar(val);
|
||||||
#endif
|
#endif
|
||||||
} else if (addr == STDIN_REWIND) {
|
} else if (addr == STDIN_SEEK) {
|
||||||
inpt_ptr = 0;
|
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 {
|
} else {
|
||||||
fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val);
|
fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
.equ RAMSTART 0x4000
|
.equ RAMSTART 0x4000
|
||||||
.equ USER_CODE 0x4800
|
.equ USER_CODE 0x4800
|
||||||
.equ STDIO_PORT 0x00
|
.equ STDIO_PORT 0x00
|
||||||
.equ STDIN_REWIND 0x01
|
.equ STDIN_SEEK 0x01
|
||||||
|
|
||||||
jr init ; 2 bytes
|
jr init ; 2 bytes
|
||||||
; *** JUMP TABLE ***
|
; *** JUMP TABLE ***
|
||||||
@ -43,7 +43,12 @@ emulPutC:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
emulSeek:
|
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
|
ret
|
||||||
|
|
||||||
#include "core.asm"
|
#include "core.asm"
|
||||||
|
Loading…
Reference in New Issue
Block a user