2019-04-16 08:36:26 -04: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-22 14:26:16 -04:00
|
|
|
; TODO: add bounds check and return Z accordingly.
|
2019-04-16 08:36:26 -04:00
|
|
|
mmapGetC:
|
|
|
|
push hl
|
|
|
|
call _mmapAddr
|
|
|
|
ld a, (hl)
|
2019-04-22 14:26:16 -04:00
|
|
|
cp a ; ensure Z
|
2019-04-16 08:36:26 -04:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
mmapPutC:
|
|
|
|
push hl
|
|
|
|
call _mmapAddr
|
|
|
|
ld (hl), a
|
2019-04-23 12:04:09 -04:00
|
|
|
cp a ; ensure Z
|
2019-04-16 08:36:26 -04:00
|
|
|
pop hl
|
|
|
|
ret
|