[A83] Re: Copying the screen to the graph buffer


[Prev][Next][Index][Thread]

[A83] Re: Copying the screen to the graph buffer




Saferam is one of the most important parts of programming to use it, in the header put your variables directly after '.LIST'
Ex:
LIST
ypos = saferam1    ;1 byte y coord up to 64
xpos = ypos+1      ;1 byte x coord up to 96
score = xpos+1     ;2 bytes score
timer = score+2    ;1 byte timer up to 255

.. rest of header ...

initialize:
  ld a,0        ;sets all the variables
  ld (ypos),a   ;to '0'
  ld (xpos),a
  ld (timer),a
  ld hl,0       ;score is 2 bytes, so use
  ld (score),hl ;'hl' instead of 'a'

mainloop:
.. whatever ...
  ld hl,(ypos)  ;since xpos is directly after ypos in
                ;the equates this loads xpos into 'h' 
                ;and ypos into 'l'.  saves some mem.
  ld a,h        ;a=xpos, l =ypos
  ld b,8        ;sprite 8 tall
  ld ix,sprite  ;sprite
  call ionPutSprite;sprite on buffer
  call ionFastCopy ;buffer on LCD
  jr mainloop   ;repeats loop

That was just a small example of a program that displays your sprite at (xpos),(ypos).

-Cole South