I'm looking to dynamically update the size of a program with alot of data. To decrease the size of the program, I will write the map data to an appvar, then remove the map data from the program itself. I do this with the following code:
Code:
Code:
Start:
ld hl,InstallStatus
ld a,(hl)
cp 0
jr z,InstallGame
InstallGame:
ld hl,MapsEnd-WorldMap
b_call(_EnoughMem)
jr c,Error
ex bc,hl
ld hl,AppVar
rst 20h
ld hl,MapsEnd-WorldMap
b_call(_CreateAppVar)
ld hl,WorldMap
ldir
ld hl,InstallStatus
ld a,1
ld a,(hl)
ld hl,WorldMap
ld de,MapsEnd-WorldMap
b_call(_DelMem)
**need to update size field. How?
jr Start
Error:
ld hl,$0000
ld (CurCol),hl
ld hl,ErrMem
b_call(_PutS)
b_call(_getKey)
b_call(_ClrLCDFull)
ret
AppVar:
.db AppVarObj,"ZelMap",0
ErrMem:
.db "Err: Memory",0
;################
;Install Status
InstallStatus:
.db 0
;################
;Map Data Start
WorldMap:
;data here
MapsEnd: