Log In  


up
by dw817
Cart #up-1 | 2020-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7


(01-02-20) If you just want to see it in action, try out the cart above and examine the source-code. For a more detailed demonstration including compression, try out the cart below this.

by dw817
Cart #sccm-4 | 2020-01-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

TO LOAD THIS CART in Pico-8, in immediate mode type:

load #sccm

UPDATE (01-01-20) Removed all loose global variables.
UPDATE (12-31-19) Tightened code slightly.

The mapper for Pico-8 is a good idea, isn't it ? But maybe it doesn't cover all the space you need for all the levels you want in your game. Thus I have made (especially for Scrubsandwich) two useful functions.

One compresses map data to a 6-bit string.
The other decompresses map data from that 6-bit string.

And why would you use a string do you ask ? Quite simply so you can include it directly in your code.

To make use of the first function, STR=COMPRESMAP(H,V,X,Y)

Understand the 5-arguments used for this function:

  1. Where H and V are the top-left hand coordinates of the map you wish to compress.
  2. Where X and Y are the number of tiles across and down for the map you wish to compress.
  3. Where STR is the string that is recorded to.

For instance if you wanted to compress mapper data starting from coordinates 0,0 to 15,15 and wanted to save it in the string called "ROOM" that would be:

ROOM=COMPRESMAP(0,0,15,15)

Room would then be a 6-bit string of about 214-chars. Less if there were less tiles in that area.

. . .

The 2nd function is DECOMPRESMAP(H,V,STR)

Understand the 3-arguments used for this function:

  1. Where H and V are the top-left hand coordinates of where you will overwrite existing mapper data.
  2. Where STR is the 6-bit string that contains the mapper data you wish to overwrite at this position.

For instance if you wanted to decompress mapper data starting from coordinates 0,0 and wanted to use the 6-bit string called, "ROOM" that already contains the mapper data you want, that would be:

DECOMPRESMAP(0,0,ROOM)

Understanding that the SIZE of this map is already encoded in the 6-bit string and does not need to be entered later for decompression.

Thanks big to @merwok for considering using a function within a function. Works great and frees up the need to have true exposed global variables remaining after you compress or decompress.

ALSO important, forgot to mention. I am using the number 255 as a reference to compression so you CANNOT use sprite #255 in here if you want to maintain the compression. Nothing else is needed. You're still welcome to use all the sprites #0-254.

. . .

If you want to save the newly compressed 6-bit map string to your cart, in immediate mode type:

printh(t,"@clip")

Which will save it to your clipboard.

Then in your new cart, type out:

mapp="

(or whatever variable you want to create) with an opening quote. Press CTRL+V, then an ending quote "

Include the CHAR6 routine above and the DECOMPRES() function below and it's all you need !

And that's it. Feel free to try out this demo and examine the source-code to see how it was done. I hope you find these two functions useful and instrumental in your code.

Comments, Questions, Kerosene :) Let me know.

7


1

Thanks @dw817 for the compressor/decompressor, I hope you don't mind that I use it in my next game. It's really useful.


Certainly, braindead. Please keep me apprised of your game, would like to see it.

I'm still working on EVE in Blitz for Sorcery. Here for the long haul. :)


1

Hi @dw817, finally the game I was making using your compress data method is finished.
You can take a look here: https://www.lexaloffle.com/bbs/?tid=42320

Thanks for your compress code, it was really useful!
Best regards


I wrote you there, @braindead. Quite the sterling work you wrote, superb action game, very challenging.

Thanks for including me in your project !

Write me again if you make something turn-based as that's always of interest to me ...


@dw817 This is great, but is there a way to somehow decompress the tiles outside of the 127x63 map area? I think I can get around it, but being able to do that would be helpful with creating larger seamless worlds.


Ah ! It has been sometime since I worked in Pico-8, @Peteksi. Did you want then to not use any of the hardware mapping space but to generate your own graphic mapper ? This can be done.



[Please log in to post a comment]