Log In  


It is popular with some programs to POKE directly into the graphic tile space either temporarily for storage or to save off some new generated tiles.

cls()
poke(0,255)
spr(0,64,64)
recover(0,1)

My question is - is there a way or command to 'recover' the tiles (or any other memory location you've messed with) WITHOUT creating or using a separate array of prior storage ?

These memory locations are after all ROM in every sense of the word in that when the program ends and you are back to the editor, all your tiles or mapping, etc. are untouched despite you using their space during run-time.



I believe you can use the reload command to restore rom.

Check the manual


Reload ? Let me check on that. No, the only thing it says about RELOAD is CTRL+R, to reset the game and start it over from the beginning.

Definitely not what I am looking for here.

Let me ask another technical question. Is it possible to use MEMCPY to copy memory locations to and from the content space of a variable array ? And if so - how ?


How did you find memcpy but not reload?

From the manual:

memcpy dest_addr source_addr len

	Copy len bytes of base ram from source to dest
	Sections can be overlapping

reload dest_addr source_addr len [filename]

	Same as memcpy, but copies from cart rom
	The code section ( >= 0x4300) is protected and can not be read.
	If filename specified, load data from a different cartridge

Wow. It's right there. Can't see the forest for the trees. Thanks, Springogeek ! :)

Okay, let me try this ...

cls()
poke(0,255)
spr(0,60,60)
flip()
repeat
until btnp(4)
reload(0,0,1)
spr(0,68,60)
repeat
until btnp(4)

Nailed it ! This is going to open up some interesting future opportunities for data storage. :)

That still leaves the question of transferring a chunk of memory via MEMCPY to a variable array storage space.

a={}
for i=1,1024 do
  a[i]=i%256
end
memcpy(0,varptr(a),1024)
spr(0,60,60)
flip()
repeat
until btnp(4)

I think you have to use peek() across the whole space if you want to copy rom into lua memory. Might be slow.


Yeah, I was hoping for something better. I think I have an idea that will work though. I'll try to post it today.

I Appreciate your help, Springogeek !



[Please log in to post a comment]