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.

P#29829 2016-10-02 12:53 ( Edited 2016-10-03 14:40)

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

Check the manual

P#29833 2016-10-02 15:54 ( Edited 2016-10-02 19:54)

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 ?

P#29850 2016-10-02 20:07 ( Edited 2016-10-03 00:07)

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
P#29857 2016-10-02 23:07 ( Edited 2016-10-03 03:07)

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)
P#29859 2016-10-03 00:17 ( Edited 2016-10-03 04:57)

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

P#29861 2016-10-03 02:49 ( Edited 2016-10-03 06:49)

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 !

P#29877 2016-10-03 10:40 ( Edited 2016-10-03 14:40)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 10:07:42 | 0.007s | Q:18