#1✎ 35Forsaken_AstralDev1Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesDay PersonI like the warm sunshine and wake up early!Express Yourself?
#2✎ 114kitesinpowerlinesAvatar BlockI didn't change my avatar for 30 days.WebsiteAvatar EmbargoI didn't change my avatar for 90 daysWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteWhat have you tried so far
#3✎ 1528randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthSecond YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteWe need Ahorn 3DS lol
I dunno how to do this
We should just make a Celeste clone lol
#4✎ 35Forsaken_AstralDev1Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesDay PersonI like the warm sunshine and wake up early!Express Yourselftried loading the map
#6✎ 35Forsaken_AstralDev1Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesDay PersonI like the warm sunshine and wake up early!Express Yourselflike making a new program and just loading it in the map editor.
#7✎ 212seggiepantsOk, let's quit horsing around. When you ask a question, it is polite to let people know what you want, the first post should not just be a singe question mark that implies you need to read the thread title. You should:
State what you want. Something like: Hi, I would like to make some custom levels for the SmileBasic port of Celeste.
State what you have attempted so far. This should include enough information about the problem so that others can reproduce it. This means include any error messages. Something like: "I tried loading the file MAP in the smile basic map editor tool and it gives me an error that says DAT:MAP_MAP not found. I have not yet looked at the code."
Not doing these things wastes your time and everyone elses. You want someone to help you out, so don't make it hard for them to do so. Don't spread terse incomplete answers over a full week to questions about things you should have put in the first post. We can't read your mind.
With that out of the way, lets do some investigative work. I have an old version of Celeste on my 3DS, I don't know what key I got it from and it is out of date (I would guess 5VXN8AE), but I am going to use what is on my device. Any function names or line numbers may not be a match.
First, lets open up the program code the file name CELESTE. It starts with a large comment, and on line 10 it says "Original PICO-8 version is by".
Ok, we have a bit of information, lets research PICO-8 for a bit. It looks like the website for PICO-8 is at https://www.lexaloffle.com/pico-8.php Near the top of the page, it says:
Welcome to PICO-8!
PICO-8 is a fantasy console for making, sharing and playing tiny games and other computer programs. It feels like a regular console, but runs on Windows / Mac / Linux. When you turn it on, the machine greets you with a commandline, a suite of cartridge creation tools, and an online cartridge browser called SPLORE.
Reading a little bit further, we find some specifications.
Display 128x128 16 colours
Cartridge Size 32k
Sound 4 channel chip blerps
Sprites 256 8x8 sprites
Map 128x32 cels
A little more searching about and we find a link to play Celeste in the browser https://www.lexaloffle.com/bbs/?pid=11722#p There is even a drop down that lets you look at the LUA code.
The version I have is 2230 lines long, so not the smallest thing to get a handle on. Before we delve too deep lets look at what files are included with the code. I see:
CELESTE - Program
FONT - A font I am guessing.
GFF - Game flags I believe
GFX - Graphics
MAP - Map
PAL - Pallette (colors in PICO-8 are palette based, so you need the colors to map to the values 0-15 in the code)
SFX - Sound effects.
I was too lazy to look into GFF, but I think you will need it. I believe it is flags that give object behavior, but I didn't really look into it. I will leave that one to you.
Anyway, the file that sticks out like a sore thumb is MAP. If you try to load it in SmileBasic's map editor it will fail. If you try to load it in a code window, that will fail too. However, if we search for :MAP in the code, on line 1931 in the function SETUP I find: LOAD "DAT:MAP", MAP%, FALSE. This tells us that the data is loaded into an integer array called MAP% (the % says integer). It looks like we load the palette and flags right before that.
Below that we have a call to SETUP_IMAGES which loads DAT:GFX into an array and draws the data onto the BG/SPR layers. Since PICO-8 is 128x128 the graphics would look very small unless you do something about it. So all the pixels are doubled to 256x256 and each pixel from PICO-8 is a 2x2 square in SmileBasic. Unfortunately, 256 is larger than the 240 pixel screen height of smile basic so we scroll the view a half tile down. So this isn't a smile basic native graphics file either.
So what is in the map file? Well if you make a small program to load the file, you will see it is an array of 2048 (nice power of 2) 32-bit integers.If I were being lazy, each byte would be a tile number. The pico-8 screen allows for a screen of 16x16 tiles. So maybe if I grab that SETUP_IMAGES function we can call that, then try to plot some tiles.
The next problem you may run into is that we are dealing with 32 bit integers not 8 bit tile numbers. So you will need to unpack one integer into four tiles.
If you look at the specifications we have 128x32 cells, you may not be surprised it the data follows that format. With 2K of data we can have 32 16x16 tile screens. Anyway, lets get to some code to dump a map screen. It assumes the SETUP_IMAGES function was already called and the function is called with a number between 0 and 31.
DEF TILE_CHUNK START%
VAR BG_LAYER = 0
VAR BG_W_ALL = 128
VAR BG_W = 16
VAR BG_H = 16
VAR TILES_PER_INT = 4
VAR I, J, K, OFFSET%, TILE_ID%, TILE%
VAR MAPS_PER_ROW = BG_W_ALL / BG_W
BEGIN = START%
OFFSET% = 0
WHILE BEGIN >= MAPS_PER_ROW
INC OFFSET%, (BG_W_ALL / TILES_PER_INT) * BG_H
DEC BEGIN, MAPS_PER_ROW
INC OFFSET%, BEGIN * BG_W / TILES_PER_INT
BGSCREEN BG_LAYER, BG_W, BG_H
FOR J = 0 TO BG_H - 1
FOR I = 0 TO (BG_W / TILES_PER_INT) - 1
TILE_ID% = MAP%[OFFSET% + I]
FOR K = TILES_PER_INT - 1 TO 0 STEP - 1
TILE% = TILE_ID% AND &HFF 'Take the last 8 bits
TILE_ID% = TILE_ID% >> 8 'Move the remainder over 8 spaces
BG_PUT BG_LAYER, (I * TILES_PER_INT) + K, J, TILE%
INC OFFSET%, BG_W_ALL / TILES_PER_INT
BGOFS 0, 0, 8
If you use that you will notice that we can scroll around all 32 screens. The last screen is actually the title screen. I found that to be pretty slick. Some things will look odd, the player doesn't have their glorious mane of hair, the clouds are somewhat truncated, things like that. It looks like the code generates a cloud sprite when we put down the top corner instead of plotting a tile. Likewise it seems the hair is several extra sprites and that instead of plotting the character when found it sets the player start position. You will need those flags to give behavior to things like balloons and treasure chests.
So back to the original question, how do you edit this? The best thing is to make an editor program (by the way backup the original files first). Another option would be save the files as proper SmileBasic native files and edit the code to load those instead. A third option would be to make a text format file and add code to load from that instead. Or in short you will have to code something and likely change the program to accommodate the new files. If you just want to level hack, you could just load the map/flag arrays in code change the values in the array and re-save them.
Sorry if the first part sounded mean, I didn't mean it that way. Also sorry for the accidental post half way through editing.
#8✎ 35Forsaken_AstralDev1Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesDay PersonI like the warm sunshine and wake up early!Express Yourselfoh thank you