2019-04-16 22:36:26 +10:00
|
|
|
; mmap
|
|
|
|
;
|
|
|
|
; Block device that maps to memory.
|
|
|
|
;
|
|
|
|
; *** DEFINES ***
|
|
|
|
; MMAP_START: Memory address where the mmap begins
|
|
|
|
|
|
|
|
; Returns absolute addr of memory pointer in HL.
|
|
|
|
_mmapAddr:
|
|
|
|
push de
|
|
|
|
ld de, MMAP_START
|
|
|
|
add hl, de
|
|
|
|
jr nc, .end
|
|
|
|
; we have carry? out of bounds, set to maximum
|
|
|
|
ld hl, 0xffff
|
|
|
|
.end:
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
|
|
|
; if out of bounds, will continually return the last char
|
2019-04-23 04:26:16 +10:00
|
|
|
; TODO: add bounds check and return Z accordingly.
|
2019-04-16 22:36:26 +10:00
|
|
|
mmapGetC:
|
|
|
|
push hl
|
|
|
|
call _mmapAddr
|
|
|
|
ld a, (hl)
|
2019-04-23 04:26:16 +10:00
|
|
|
cp a ; ensure Z
|
2019-04-16 22:36:26 +10:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
mmapPutC:
|
|
|
|
push hl
|
|
|
|
call _mmapAddr
|
|
|
|
ld (hl), a
|
2019-04-24 02:04:09 +10:00
|
|
|
cp a ; ensure Z
|
2019-04-16 22:36:26 +10:00
|
|
|
pop hl
|
|
|
|
ret
|