2019-05-10 05:36:03 +10:00
|
|
|
; *** Variables ***
|
2019-05-11 08:20:43 +10: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 21:53:42 +10:00
|
|
|
; see ioPutBack below
|
|
|
|
.equ IO_PUTBACK_BUF IO_OUT_TELL+2
|
|
|
|
.equ IO_RAMEND IO_PUTBACK_BUF+1
|
2019-05-10 05:36:03 +10:00
|
|
|
|
|
|
|
; *** Code ***
|
|
|
|
|
2019-05-16 21:53:42 +10:00
|
|
|
ioInit:
|
|
|
|
xor a
|
|
|
|
ld (IO_PUTBACK_BUF), a
|
|
|
|
ret
|
|
|
|
|
2019-05-10 05:36:03 +10:00
|
|
|
ioGetC:
|
2019-05-16 21:53:42 +10:00
|
|
|
ld a, (IO_PUTBACK_BUF)
|
|
|
|
or a ; cp 0
|
|
|
|
jr nz, .getback
|
2019-05-11 08:20:43 +10:00
|
|
|
ld ix, (IO_IN_GETC)
|
2019-05-10 05:36:03 +10:00
|
|
|
jp (ix)
|
2019-05-16 21:53:42 +10: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-10 05:36:03 +10:00
|
|
|
|
|
|
|
ioPutC:
|
2019-05-11 08:20:43 +10:00
|
|
|
ld ix, (IO_OUT_PUTC)
|
2019-05-10 05:36:03 +10:00
|
|
|
jp (ix)
|
|
|
|
|
2019-05-16 03:41:56 +10:00
|
|
|
ioSeek:
|
2019-05-11 10:32:05 +10:00
|
|
|
ld ix, (IO_IN_SEEK)
|
|
|
|
jp (ix)
|
|
|
|
|
2019-05-16 10:07:21 +10:00
|
|
|
ioTell:
|
|
|
|
ld ix, (IO_IN_TELL)
|
|
|
|
jp (ix)
|