Log In  

Hi, I'm trying to use the very handy looking PX9 to compress a bunch of map data, so I can get all the levels I need in my cart - but I have a strange issue.

In my cart I'm storing compressed map data for my 'levels' at 0x2400 for level 1, 0x2600 for level 2, 0x2800 for level 3, etc. So each level is maximum 0x200 bytes long compressed.

The decompressed map for each level is no more than 9 rows, so I have the top of the map (0x2000 to 0x3fff) to store
the decompressed level.

That's all good, I can decompress level 1, show the map, decompress level 2, show that map, but if I then try and decompress level 1 again it doesn't work :/

I've made a simplified example cart that shows the problem. When it runs you see level 1 decompressed and displayed, hit X to cycle through levels. The first time around is fine, but the second time level 1 never gets displayed.

Does any of that make sense, what strangeness have I created?!

Cart #nuhophina-0 | 2020-09-11 | Code ▽ | Embed ▽ | No License

-- px9 comp'd map 1 at 0x2400
-- px9 comp'd map 2 at 0x2600
-- px9 comp'd map 3 at 0x2800

function _init()
    num=0
    next_map()
end

function _draw()
    cls()
    map(0,0)
    print("this is map "..num,0,52)
    print("❎ for next map",0,60)
end

function _update()
    if btnp(❎) then
        next_map()
    end
end

function next_map()
        num+=1
        if num==4 then
            num=1
        end
        local adr=0x2200+num*0x0200
        px9_mdecomp(0,0,adr,mget,mset)
end

-- px9 decompress, memory-only
-- 273 tokens

function px9_mdecomp
(
...
}
P#81723 2020-09-11 20:10 ( Edited 2020-09-12 10:28)

I figured it out, decompressing 0x2400 to 0x2000 was overwriting the compressed data at 0x2400, seems kinda obvious now! I just need to shift the compressed data up a tiny bit from 0x2400.

P#81798 2020-09-14 10:49

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 16:16:27 | 0.010s | Q:15