Log In  

Hi, I'm planning out my next game, and I was thinking about sharing the code between carts:

For example, there is cart a:

function a()

And b:

-- load doesn't work so, it loads a cart
a() -- somehow

Any way to do that? Reload shouldn't help with code... Zep, maybe you could include this in 0.1.11?

P#45282 2017-10-17 03:53 ( Edited 2017-10-18 05:06)

Hey, it even existed in the console world.
Back in the day, you could by trainer carts to extend games with cheating functions!
Same concept here ;)

Such cart could cost a flat fee of 1000 tokens to make zep happy!

P#45286 2017-10-17 11:18 ( Edited 2017-10-17 15:18)

1000 is not a power of two, either 1024 or more, but I think, 8k is a good amount. I just need more for storing data like mobs and etc.

P#45287 2017-10-17 12:02 ( Edited 2017-10-17 16:02)
:: enargy

hey @egor -- one thing I've been doing is keeping persistent things in user data (starts at 0x4300) and using reload() to pull in data from other carts as needed.

P#45288 2017-10-17 12:14 ( Edited 2017-10-17 16:14)

Ok, I feel kinda stupid now...

For some reason, I thought that the User Data was "Read Only" portion (e.g. the actual cart code).
I didn't realise it's another area we can push & pull data to. D'Oh!


P#45289 2017-10-17 12:26 ( Edited 2017-10-17 16:26)
:: enargy

@LiquidDream: You were half right thinking that; it only exists as RAM and can't be written to a cart's ROM the way you can do with gfx/map/sfx data.

But during runtime you can use it to store decompressed data, a (partial) screenbuffer, fonts -- all kinds of neat stuff :p

And if you want to use multicart features, you can grab data to pop in there directly from another cart's gfx area or whatever.

P#45294 2017-10-17 16:23 ( Edited 2017-10-17 20:23)
:: zep

It's unlikely that PICO-8 will ever be able to load more than 8k tokens of code at once (for the usual reasons -- keeping size restrictions meaningful etc.), but it sounds like in this case converting the data to binary and cstore()ing / reload()ing it might indeed be sufficient.


-- store data (probably from a separate dev cart)
for i=1,100 do
 poke(0x42ff+i, mydat[i])

-- load data (from the main cart)
for i=1,100 do

This example only works for numbers 0..255, of course -- if you need to store strings and other types of data it might not be the best approach.

P#45296 2017-10-17 16:56 ( Edited 2017-10-17 20:59)

Ok, thanks, zep. Then I should think @enargy's solution with interpreting functions. (I was planning to store enemies AI in the second cart)

P#45303 2017-10-18 01:06 ( Edited 2017-10-18 05:08)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-10-28 09:23 | 0.057s | 2097k | Q:26