
PX9 Data Compression - polm23
https://www.lexaloffle.com/bbs/?tid=34058
======
wolf550e

        px9_comp(x,y,w,h, dest_addr, vget)
        returns the number of bytes written
    

Then

    
    
        reload(0x0, 0x0, 0x2000, "mycart.p8")
        clen = px9_comp(0, 0, 128, 128, 0x2000, sget)
        cstore(0x0, 0x2000, clen, "mycart_c.p8")
    

This function does not accept the output buffer size as an argument.

Is there an implicit constant buffer size in the framework, language or
device, like a single page or something?

To a C programmer, this looks extremely unsafe.

The blog post is tagged "pico-8", which I guess is [1].

1 -
[https://en.wikipedia.org/wiki/Pico-8](https://en.wikipedia.org/wiki/Pico-8)

~~~
lifthrasiir
PICO-8 is a "fantasy console" with an arbitrary limitation to imitate the real
world console in the past century. While it uses Lua as a scripting language,
it comes with very severe memory (<2MB) and code size (<8K tokens) limitation
so that it is actually akin to programming in slightly more powerful BASIC and
PEEK and POKE (yes they are actual names).

To elaborate what happens when the buffer overflows... The official README
explains that map (normally sprites) starts at 0x2000 and some other data
starts at 0x3000. Therefore it will start overflowing other data, and
depending on what you expect in those area, it may or may not break the game.
The entirety of PICO-8 is intentionally constructed in this way to give its
look and feel.

~~~
jamesgeck0
One of the example games distributed with PICO-8 has a "glitch mode" that
POKEs at a random spot in memory every few seconds. The game becomes
progressively more corrupted as you play, creating an effect similar to a NES
cartridge that needs cleaning.

