thanks for the hint, I tried to create AppVar and expand it to $1900 bytes
Code:
reserve_memory:
ld hl,AmountOfRAMINeed; where AmountOfRAMINeed is a the number of bytes you need
bcall(_enoughmem)
ret c
ld hl,AppVarName
rst rMOV9TOOP1
ld hl,AmountOfRAMINeed
bcall(_CreateAppVar)
insert_memory:
ld hl,reserve ; number bytes to insert
b_call(_enoughmem) ; check for free ram
ret c ; ret ca = 1 if not
;
ld hl,AppVarName
b_call(_mov9toop1) ; op1 = name of appvar
b_call(_chkfindsym) ; de = pointer to data if exists
inc de
inc de
ld (variable_data_start),de
dec de
dec de
ret c ; ret if not found
ld a,b ; archived status
add a,0ffh ; if archived then ca = 1
ret c ; ret if archived
;
push de ; save pointer to size bytes of
; data
inc de
inc de ; move de past size bytes
;
ld hl,reserve ; number bytes to insert
b_call(_insertmem) ; insert the memory
pop hl ; hl = pointer to size bytes
push hl ; save
;
b_call(_ldhlind) ; hl = old size of appvar,
; number bytes
ld bc,reserve
add hl,bc ; increase by 10, amount inserted
ex de,hl ; de = new size
pop hl ; pointer to size bytes location
ld (hl),e
inc hl
ld (hl),d ; write new size.
or a ; ca = 0 each or resets C
ret
reserve .equ $1980
AmountOfRAMINeed .equ 10
AppVarName:
.db AppVarObj,"AVDATA",0
variable_data_start .dw $ffff
but when I try to use "variable_data_start" as a pointer to free memory I get garbage on screen, I tested the very same code on ZX Spectrum and it works with no problems whatsoever. I make sure that the intervals between writes to lcd are long enough. What could be the reason for the bad data in the window I reserved?