Advertisement
NovaYoshi

appvar allocate

Nov 2nd, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; check if there's even enough memory free
  2.   ld hl,MAPSIZE+16
  3.   bcall EnoughMem
  4.   jr nc,HasEnoughMem
  5.   bcall ErrMemory
  6.   ret
  7. HasEnoughMem:
  8.  
  9. ; create appvar
  10.   ld hl, AllocName
  11.   rst 20h
  12.   ld hl,MAPSIZE+16
  13.   bcall CreateAppVar
  14.   ld hl,16 ; not offsetting the data address before you write to it seems to
  15.            ; give the variable an invalid size and I don't know how much to offset, so 16
  16.   add hl,de
  17.   ld (MapPointer),hl
  18.  
  19. ; should set the map to all tile 1
  20.   ld bc, MAPSIZE
  21.   ld a,1
  22.   bcall MemSet
  23.  
  24. ; do whatever that uses the allocated memory
  25.  
  26. ; free up the memory allocated
  27.   ld hl, AllocName
  28.   rst 20h
  29.   bcall ChkFindSym
  30.   ret C
  31.   bcall DelVar
  32.   ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement