2019-05-09 15:36:03 -04:00
|
|
|
; *** Variables ***
|
2019-05-10 18:20:43 -04:00
|
|
|
.equ IO_IN_GETC IO_RAMSTART
|
|
|
|
.equ IO_IN_PUTC IO_IN_GETC+2
|
|
|
|
.equ IO_IN_SEEK IO_IN_PUTC+2
|
|
|
|
.equ IO_IN_TELL IO_IN_SEEK+2
|
|
|
|
.equ IO_OUT_GETC IO_IN_TELL+2
|
|
|
|
.equ IO_OUT_PUTC IO_OUT_GETC+2
|
|
|
|
.equ IO_OUT_SEEK IO_OUT_PUTC+2
|
|
|
|
.equ IO_OUT_TELL IO_OUT_SEEK+2
|
2019-05-16 07:53:42 -04:00
|
|
|
; see ioPutBack below
|
|
|
|
.equ IO_PUTBACK_BUF IO_OUT_TELL+2
|
|
|
|
.equ IO_RAMEND IO_PUTBACK_BUF+1
|
2019-05-09 15:36:03 -04:00
|
|
|
|
|
|
|
; *** Code ***
|
|
|
|
|
2019-05-16 07:53:42 -04:00
|
|
|
ioInit:
|
|
|
|
xor a
|
|
|
|
ld (IO_PUTBACK_BUF), a
|
|
|
|
ret
|
|
|
|
|
2019-05-09 15:36:03 -04:00
|
|
|
ioGetC:
|
2019-05-16 07:53:42 -04:00
|
|
|
ld a, (IO_PUTBACK_BUF)
|
|
|
|
or a ; cp 0
|
|
|
|
jr nz, .getback
|
2019-05-10 18:20:43 -04:00
|
|
|
ld ix, (IO_IN_GETC)
|
2019-05-09 15:36:03 -04:00
|
|
|
jp (ix)
|
2019-05-16 07:53:42 -04:00
|
|
|
.getback:
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld (IO_PUTBACK_BUF), a
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
; Put back non-zero character A into the "ioGetC stack". The next ioGetC call,
|
|
|
|
; instead of reading from IO_IN_GETC, will return that character. That's the
|
|
|
|
; easiest way I found to handle the readWord/gotoNextLine problem.
|
|
|
|
ioPutBack:
|
|
|
|
ld (IO_PUTBACK_BUF), a
|
|
|
|
ret
|
2019-05-09 15:36:03 -04:00
|
|
|
|
|
|
|
ioPutC:
|
2019-05-10 18:20:43 -04:00
|
|
|
ld ix, (IO_OUT_PUTC)
|
2019-05-09 15:36:03 -04:00
|
|
|
jp (ix)
|
|
|
|
|
2019-05-15 13:41:56 -04:00
|
|
|
ioSeek:
|
2019-05-10 20:32:05 -04:00
|
|
|
ld ix, (IO_IN_SEEK)
|
|
|
|
jp (ix)
|
|
|
|
|
2019-05-15 20:07:21 -04:00
|
|
|
ioTell:
|
|
|
|
ld ix, (IO_IN_TELL)
|
|
|
|
jp (ix)
|