Log In  

I'm learning more about memory stuff with the pico-8 and it's super interesting!
I had one quick question for zep.

What is meant in the documentation by this line?

"0x5f00 draw state [,cart data] (1024 bytes incl. unused)"

What exactly is draw state?
How is the data interpreted/formatted?
What does [,cart data] mean?
What is meant by (1024 bytes incl. unused)?

Every part of this is so cryptic to me, please help!

P#11220 2015-06-10 13:05 ( Edited 2015-06-18 01:47)

The draw state is all of the data that drawing functions (line(), spr() etc) operate on. They're undocumented because they might change, but here they are (use at own risk!):

0x5f00+

0..0xf     draw palette
0x10..0x1f screen palette
0x20..0x23 clip coordinate left, right, top, bottom
0x24       unused
0x25       current draw colour
0x26       cursor x
0x27       cursor y
0x28..0x2b camera position x,y (small endian int16s)
0x2c       screen mode // 0 128x128 (normal)  1 64x128  2 128x64  3 64x64

0x5fc0..0x5fff will possible be for permanent data storage in future, maybe
this is what's meant by cart data

incl. unused means the data size (256 bytes) includes a bunch of unused addresses -- not every byte means something.

You can probably count on the first 128 bytes being used for draw state in future though. So if you need to backup and then restore all the clipping and palette settings etc for some reason, you can do something like memcpy(0x5e80, 0x5f00, 128) to backup and memcpy(0x5f00, 0x5e80, 128) to restore.

P#11224 2015-06-10 18:08 ( Edited 2015-06-10 22:08)

is there any way to differentiate the draw buffer and the actual screen buffer?

P#11311 2015-06-17 17:21 ( Edited 2015-06-17 21:21)

No, there isn't any access to the screen buffer (some abstract, separate video memory) -- basically anything you draw into 0x6000..0x7fff will show up on the screen at the end of _draw() and that's all the control you have.

P#11313 2015-06-17 21:47 ( Edited 2015-06-18 01:47)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 00:27:00 | 0.018s | Q:11