Log In  


I'm a prematurely-retired professional video game programmer. I have some health problems that ruin my concentration and keep me from doing the kind of programming people will pay you for. PICO-8 is really nice for me, because the limited scope of the platform tends to keep the scope of problems and solutions limited enough for my limited concentration to cope with. I don't think I'll ever manage to produce a game for PICO-8, but it sure is fun just to play with.

(If I've just handed you some ideas or advice, probably for the fifth time this week, and you're getting sick of my doing that, then I have a couple of things I should say: first of all, you should let me know, because I know unwelcome advice is annoying and I don't want to be annoying; but also, second, try not to be too irritated with me, because giving advice is the only way I still feel like I can be a productive member of the video game developer community. I mean well, I swear.)

Oh, and about the avatar... once upon a time, I chose a nice little image of Miku in glasses for my avatar, purely because it struck me as adorable. However, I kept it because I discovered it kept away those useless people who would judge a book by its cover. This is that avatar, but hand-pixeled into low-res, pico-8 palette format.

Sample code for getting dead coroutine's stack trace
by Felice


Every now and then I get directed to a BBS post with a cart that I genuinely to see, but which is making my headphones screech into my ears because it's so loud.

Thing is, I already have both my system volume and my app-specific browser volume set to sensible levels for all other content, so I can't reasonably dial down the volume pre-emptively.

Unfortunately, sometimes it's appropriate for a game to do something loud, albeit briefly, so I wouldn't expect you to limit it in the player either.

Really, I think the solution is to have a slider of some sort on the web player. Even if it's limited to 8 different levels, like PICO-8 is internally, that'd help.

Maybe if the user right-clicks (or presses and holds) on the speaker icon, it pops up a slider that can be adjusted?

I dunno if it should be persistent and/or global. For reference, Youtube seems to be both, i.e. the most recent change you made becomes the default for the next video, regardless of how many windows you have open with different settings.


P#111981 2022-05-18 06:30 ( Edited 2022-05-18 06:31)


Hey! Remember when I suggested putting next in the globals, since we could get to it anyway by doing next=pairs{}? You did! And that's been great!

Would it be okay to get inext the same way? It seems to be present, since I can get it by (similarly) doing inext=ipairs{}, and it seems to work the same way, just limited to index,value instead of key,value.

It's just not officially exposed.

I'm asking because there's a token saved when you switch from the first to the second implementation here:

for k,v in pairs(t) do ... end
for i,v in ipairs(t) do ... end

-- these are a little less clear to the reader but they work the same and save a token
for k,v in next,t do ... end
for i,v in inext,t do ... end

Technically it also shaves a couple of cycles off of the loop setup by inlining the return tuple from pairs()/ipairs(), but it's really the token savings that would be handy in some cases.

P#109951 2022-04-09 09:47 ( Edited 2022-04-09 10:57)

I don't know if this is expected behavior, but I thought I should ask:

Is it expected that stringifying the table var/ref will give different results when it has a (blank?) metatable attached?

P#109433 2022-03-30 18:59 ( Edited 2022-03-30 20:41)

> Changed: Controller inputs are accepted even when PICO-8 is not the foreground application

PLEASE change this back. This is totally counter to how apps are supposed to work in a windowing environment. If an app doesn't have focus, the whole point is that it's not the one receiving input.

This is causing problems for me already because I can't safely pause a PICO-8 game while I play something else that uses a controller.

P#105889 2022-01-29 11:11 ( Edited 2022-01-29 11:15)

I saw @zep's tweetcart and wanted to fiddle with it to produce something like the pattern on the bag he showed in the thread. I use Voronoi cells to apply multiple patterns to each image.

Unfortunately, with the limited resolution, our eyes can't pick out patterns unless they are at least half the size of the screen and very regular, so I had to use a limited number of cells with a reduced amount of randomness in each pattern. It sorta works, but it'd be way more effective on a hi-res screen with more cells.

Cart #rajadadaji-0 | 2022-01-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#104012 2022-01-01 12:28 ( Edited 2022-01-01 12:44)

Yo @zep,

On discord and here on the BBS, we get a lot of people who basically need to get to the auto-backup of a cart they've lost somehow. It'd spare a lot of time writing blurbs like this if people could simply type "backups" and have it work like the "folder" command except it drops them in the 'backups' folder instead of 'carts'.

P#95618 2021-08-03 16:39 ( Edited 2021-08-03 16:40)

In all but one case I can think of, PICO-8 specifies screen rectangles as X1,Y1-X2,Y2 (inclusive).

The case where it doesn't is clip(x,y,w,h).

This has always bugged me. But worse, I noticed recently that the virtual hardware registers for the clip rect are actually set up like the other API calls: X1,Y1-X2,Y2 (inclusive), which means the API is actually translating between the paradigms.

Now I realize clip() can't suddenly change to work the other way, but...

What if we had a new command next to it called clp(x1,y1,x2,y2) that worked the same as everything else, worked like the virtual hardware, returned the same values you'd get by peeking the virtual hardware registers, etc., and simply marked clip() as deprecated, much like mapdraw() is deprecated?

It would hardly be the only abbreviated API call, e.g. sgn().

What do you think, @zep?

P#95332 2021-07-27 09:18 ( Edited 2021-07-27 09:58)

Right now, tostr(n) converts to decimal, and tostr(n,anything_except_nil_or_false) converts to hex.

Could it use the optional second arg as a base if it's a number? e.g.


For the sake of simplicity, you could limit it to the bases the parser can read. I think that's just decimal, hex, and binary.

P#94949 2021-07-16 14:06 ( Edited 2021-07-19 09:33)

"Are you there @zep? It's me again, Margaret Felice."

I was thinking about how the option to show additional screens could open up the ability to write on-target dev tools to complement the existing IDE, and yet we're not really seeing any of that (yet).

I don't think it's a big deal that these additional screens are officially unsupported and you have to alter the pico8.exe command line to use them at all, because only a dev needs dev tools, and devs know how to alter command lines. I don't think that's why.

I think the problem with dev tools and debug libraries comes in the form of the token limit.

Any and all dev tools are going to take up tokens, and once you go past 8192 tokens, your app can't even launch. So someone with a nearly-finished app that's utilizing most or all of the allowed tokens is going to be absolutely unable to use any form of dev tool, debugging library, or even just print() debugging.


Would it be possible to add a command-line option to increase the limit from 8K to, let's say, 32K tokens?

e.g. pico8.exe -dev_mode

That's similar to the 1:4 retail-vs-devkit RAM ratio on a PS2 devkit, for instance: 32MB vs 128MB. We had that extra RAM to hold debug libs, extra sanity-checking code, trace logs, etc., and it was absolutely invaluable.

And, most notably, this would only work when run from a proper pico8.exe with a command-line option set, meaning it is NOT supported under normal conditions and will NOT work in an exported/.png app, maintaining PICO-8's cozy limitations under normal circumstances.

Oh, and note that you should also increase the Lua heap to 8MB in this mode, btw. Or more. More code means more data.

Afterthought: This also might encourage people to write stuff that will, in turn, give you ideas to improve PICO-8, Voxatron, or whatever comes after. In fact, the reason why I'm posting about this is that someone on the Discord mentioned that some of the Respriter ideas may have worked their way back into PICO-8. Synergy is food for the dev's soul!

P#93481 2021-06-14 21:46 ( Edited 2021-06-14 21:48)

I just discovered there's "> ..." quote block feature.

Except there isn't...?

If I do this:

this is my introduction

> this is my quote

this is my response

I get this in the preview:

But when I click [Publish] it comes out like this:

Also, if this feature is intended to work, it should be in the [Formatting Help] helpbox.

P#92948 2021-06-03 06:17 ( Edited 2021-06-03 06:20)

Hey @zep,

There are a lot of people who come here and learn to code by modding existing carts, and personally I think iterating on someone else's project is a fantastic way to learn stuff (I do it too), so I'd never want to discourage it, but sometimes it floods the BBS too, especially when someone does a workshop or class where everyone does it.

Could we get a Mods category under Cartridges?

That also might let you curate that kind of cartridge a little better, since a lot of them are only slightly different from the original, or indeed might not even work properly, and don't really belong in Splore, even though it's useful for junior programmers to share their work with each other here on the BBS and bounce ideas back and forth and so on.

P#92188 2021-05-19 18:23 ( Edited 2021-05-19 18:24)

Hey @zep,

I'm not sure if this is related to the last += parser bug. It doesn't seem to be, but if it is, it's possible you already fixed it in your dev version.

Having a tab as whitespace in this construct:

t[1]    +=1

-- (with visible whitespace)

Produces an "unexpected symbol near +" error.

I copied the "see what the pre-parser does" trick to clipboard:

printh([=[t[1]  +=1]=], "@clip")

And got this when I pasted it back into an editor

t[1 ]    =   + (1)  

-- (with visible whitespace)

Note that it only seems to do this if the left value is a table deref. Mind you, other complex lvalue patterns might also trigger it.

Maybe your regex needs some "\s*" patterns where it currently only has " *"?

I'll assume this is enough for you to go on. :)

...oh, and one tiny, itty-bitty, almost-not-worth-mentioning afterthought, since you're mucking with that code...

It'd be awful cool if this worked:

x,y += 64,64

just sayin' ;)

P#91909 2021-05-14 02:21 ( Edited 2021-05-14 02:23)

Hey @zep,

I've been messing around with software synth via the PCM trick and I feel like there's sort of a fundamental problem that's detracting a lot from the quality of what comes out the back end, needlessly so, not to mention making it uncomfortable to the listener's ear.

As far as I can tell, you're feeding the 5512.5Hz signal into the audio version of a "nearest neighbor" sampler to upsample it to the host OS' audio hardware sample rate, which is typically gonna be either 44100Hz or 48000Hz. That means repeating the sample values as many times as necessary to fill the gaps. In this case it'd repeat the same value around 8 times. This of course produces stairsteps on the 44100Hz+ "curve".

The issue with that is that modern audio hardware has really good fidelity and it's going to reproduce those sharp stairsteps very faithfully, effectively overlaying a constant 5512.5Hz triangle wave on the original wave that pulsates its amplitude based on how big the deltas between samples are in the original wave.

Like, if the original wave was a 262Hz middle-C sine wave tone, you'd get a 5512.5Hz buzz overlaid that gets strongest each time the wave crosses 0, where the rate of change is maximal. It crosses 0 twice per cycle, so you're getting an audible crackling buzz at 524Hz.

That's not what would have happened on old analog audio output circuitry. There would be ramping time between levels, some sort of acceleration, deceleration, and maybe overshoot too, as the line settled at its new level. Basically the audio version of an LCD pixel's "response time" or "gray-to-gray time". The overlaid triangle wave would be closer to a sine wave, more of a tone than a buzz, still present and still distorting the intended wave a bit, but much less harsh to the ear.

I dunno what options you have to change the upsampling. If you're doing it by hand, your options are open, but if you're relying on hardware, you might need to experiment. You probably don't want to change it over to using full interpolation, because that'll make it hard for people to do deliberate buzzing.

If it were me, I'd try doing a manual nearest-neighbor upsample to 22100Hz (edit: or maybe just 11050Hz) to retain the low-resolution stairsteps you'd expect the low clock rates to produce on retro hardware, but I'd let the host OS/hardware do interpolation to upsample it the rest of the way to the true output rate of 44100Hz or 48000Hz, which will simulate the ramping up/down time. This'd take the edge off, for the sake of the listener's ear.

P#91667 2021-05-08 00:20 ( Edited 2021-05-08 02:46)

I've discovered that printing the "\b" character (8) moves the cursor back based on the width of the most recent glyph that was printed.

So, @zep, I can understand where your mind was going with this, because you wanted it to be possible to back up over something like a kana character or a PICO-8 emoji with a single backspace. That does make sense.

However, I think unless you're going to keep a long history of what was printed before that, and where the cursor was for each glyph, it's going to cause problems, because right now it's only guaranteed to work for backspacing over one character, not more.

For instance, if I print("abしd\b\bcd"), it doesn't put "cd" in the right place, as shown below, where I highlight the overprinting in the second print by changing the foreground color to orange:

Point being, you're trying to be helpful to the user by remembering the width of the last glyph, but it's not helpful to the next user who wants to back up over two glyphs. It's not a game I think you can play to win. I think it'd be better just to set backspace.dx to a constant for the font, be it oem or custom.

You should probably just set backspace to be literally a backwards space. Let the user deal with double-wide or narrow glyphs if they need to—they know what they're printing, after all.

(Another option would be to give us a command code to set the backspace size, e.g. "\^<4", and default it to 4 or whatever is appropriate for a custom font. Leaving it in our hands solves all the problems, honestly.)

P#90318 2021-04-10 11:58 ( Edited 2021-04-10 12:11)

I noticed this while looking at load/save behavior for my QoL idea.

You can load a file that has no extension, because load will try the raw filename first without adding an extension.

However, when you save that file, it will automatically add ".p8" to the name, possibly overwriting an existing file while not overwriting the file you actually loaded.

Probably not going to happen much in practice, but potentially disastrous when it does happen.

P#90002 2021-04-05 09:07 ( Edited 2021-04-05 09:08)

At the command prompt, if you try to load a filename with no extension:

load somefile

It'll try these in order:


It'd be nice if #include worked the same way.

e.g. with vector.p8 in the same folder:

#include vector

I think simply re-using the logic from load would work, because it behaves exactly the way I'm suggesting.

As for Lua files, it's probably best if the .lua extension has to be typed out explicitly, because you're essentially leaving the sphere of PICO-8 by using a raw lua file and it makes sense that PICO-8's name abbreviation would not apply. Plus this is the same behavior load already uses, so minimum effort required. ;)

P#90000 2021-04-05 08:54


It'd be really intuitive and helpful if the select() function also detected a boolean value for the first argument, and returned the first arg if true and the second arg if not.

A lot of us write our own ternary function that does this anyway, because it can work around some gotchas with the cond and tval or fval structure, so this would obviate the need for it while extending the existing API in a very intuitive way.


-- this works as you'd expect a C/C++/JS-style "cond? nil : that" ternary op to work
this = select( cond, nil, that )

-- this doesn't, it returns 'that' regardless of 'cond'
this = cond and nil or that

Plus I think this would evaluate faster on the host.

Should probably also treat nil as false, btw, for maximal usefulness and congruence with Lua's concept of conditions.

P#89523 2021-03-25 15:46 ( Edited 2021-03-28 20:34)

I can't see a way to disable the new "\#n" background-fill mode once it's been enabled. I've tried "0" for color 0, "G" for color 16, and "W" for color 32, but they just set the BG to black, and all other "0-Z" just repeat the palette. I've tried supplying a "-" for the color instead, I've tried repeating the "\#" code or just "#", I've tried various other symbols and the puny letters, and anything not in "0..Z" just sets it to black.

Is this a missing feature or is there supposed to be a way to do it? The manual says nothing of turning it off. Right now I have to start another print() to get back to no-BG mode and that seems... unintended?

I feel like it ought to be "\#-", based on the convention with the "\^" commands. Alternatively, "G" (or anything through "V") would technically make sense if you just consider bit #4 of the color to be a "transparency" bit.

Edit: Just to be clear, I mean within the same print string. You can print again and the flag will be cleared, but for the sake of tokens, I'd like to do it within the same string.

P#89182 2021-03-18 19:33 ( Edited 2021-03-20 04:19)

Before the most recent update, you could print anything below chr(32) and get an actual glyph in the output, aside from the obvious exceptions like \n and \t. For characters below chr(16) this is no longer possible, aside from chr(5), which I suspect is an oversight. In fact, that oversight is the "bug" that brought me here.

The thing is, this is a waste of 16 glyphs in the character set, and potentially up to 32 in the future if you add more control codes.

Can we get some kind of "raw" printing mode, where control character behaviors are completely ignored and their glyphs are simply printed?

Maybe turn the two oem/custom font selector characters into a single oem/custom toggle to free up chr(15), and use that as a raw-mode toggle, as in this pseudocode, where raw mode allows everything to be printed except the toggle itself, unless it is repeated:

fn print(s, ...)
    raw = false
    just_toggled_raw = false
    for each char c in s
        if c == raw_toggle then
            if just_toggled_raw then
                // escape the toggle
                draw_glyph( c )
            // remember if it was a lone toggle, forget if it was doubled to escape
            just_toggled_raw = not just_toggled_raw
            raw = not raw
            just_toggled_raw = false
            if raw then
                draw_glyph( c )
                ...insert existing print code here...

Apologies if I've missed some existing way to do this.

P#89089 2021-03-17 11:52 ( Edited 2021-03-17 11:57)

This is to do with the so-called "outpost" value, or the two's-complement wrap point, which in PICO-8's number system is 0x8000, or when printed as signed decimal, -32768.

Like the origin, 0x0000, it's technically not really signed, or maybe it's better to say it covers both signs simultaneously. Conventions assign the origin to the positive side, and the outpost to the negative side, but that's just a pragmatic choice for numbers that unavoidably behave strangely due to the encoding. The origin and the outpost are complementary values in this way.

(This is why 0 == -0 and -(-32768) == -32768 with a 16-bit signed integer, by the way.)

That being said, this is what I currently get for the outpost value:

> print(tostr(abs(-32768),true))

Obviously, there's no "good" result when we can't represent +32768 with a signed 16-bit integer.

But this result is just plain wrong in every way, because it has no connection to anything someone might expect to get as an alternative to the impossible correct result. It's not equal to -(-32768), it's not close to +32768, and it's not even exactly 0.

  • Technically, I think it should return 0x8000 a.k.a. -32768, just like -0x8000 a.k.a. -(-32768) does. This way, -abs(-32768) returns what it should, which matters in some cases. This is basically in keeping with the usual properties of the outpost value.

  • An option, albeit one I don't approve of because it's not symmetrical if you try to undo it, is to return 0x7fff.ffff, or not quite 32768. This would make the one rare edge case where someone was pushing numeric limits on PICO-8 work almost correctly, but honestly I think any calculation with a number this size is still going to fail and really ought to be done differently, so it's better if it fails obviously. Holding the hand of a new programmer in a rare edge case isn't worth breaking the behavior a seasoned one would expect in the same edge case.

  • Another option would be to return exactly 0, rather than slightly more than 0, to make the "bad input" situation more clear to the dev so they can fix it, because a dev trying to work with abs(0x8000) is not going to have a good day anyway and they should probably find out as soon as possible. This feels like a sketchy idea, though. And it brings us to the final option....

  • The most draconian option would be to trigger a runtime error, since it's literally impossible to represent the result. I'm not sure how I feel about this. It'd definitely help devs find problems with their math, but there's always the chance it won't happen to the dev during development and will happen to the user in the wild, which is not okay. A glitch in the wild is bad but tolerable, a crash isn't.

Anyway, as you can probably tell, I think abs(0x8000) should just return 0x8000, which means in layspeak that abs(-32768) returns -32768. That may (and should) feel nonsensical to a junior programmer, but everyone needs to learn the weird rules about the outpost value eventually anyway, so I think it's the real pragmatic choice.

/me steps off of soapbox

P#89048 2021-03-16 13:39 ( Edited 2021-03-16 13:41)

View Older Posts
Follow Lexaloffle:        
Generated 2022-07-02 17:32:35 | 0.090s | Q:52