Log In  

Hi guys, I'm working on a tabletop style game and using mset to make tile variations for each different levels (like how you place doors and rocks in games like heroquest). What I would like to do is to be able to reload the map data from the cartridge rom (ideally without iterating through the map and undoing my mset changes).

I've tried to make a very small example below. I am setting the top left orange square through an mset call in _init. I would like to be able to call something that re-reads the map data from the cartridge rom so I can undo in-memory mset changes.

Hope someone can help :)

Cart #37274 | 2017-02-08 | Code ▽ | Embed ▽ | No License
1

P#37275 2017-02-07 23:06 ( Edited 2017-02-08 05:39)

I managed to solve by creating a duplicate of the board in the map data, and copying it back over to the data I'm using

    for col=1, map_w do
        for row=1, map_h do
            mset(col, row, mget(col + map_w, row))
        end
    end 

It isn't ideal, I am trying to conserve tokens at this stage of the project. So I'm definitely open to a better suggestion :)

P#37277 2017-02-08 00:07 ( Edited 2017-02-08 05:07)

I think what you want is reload() ...?


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


And for reloading the map data, would probably be

reload(0x2000, 0x2000, 0x1000)
P#37278 2017-02-08 00:24 ( Edited 2017-02-08 05:27)

Thanks! much better than my solution :)

P#37279 2017-02-08 00:39 ( Edited 2017-02-08 05:39)

[Please log in to post a comment]