PICO-8 0.1.12

0
0
Published 2023-06-12


Hey PICO-8 people! Builds for 0.1.12 are now live on Lexaloffle and Humble. UPDATE: PocketCHIP users can get it here.

If you just want to see what's new, please scroll down a bit. But first of all, I should issue a..

Future Compatibility: You'll need to update to 0.1.12 to play cartridges made in 0.1.12 or later. This update is another attempt at eternal future compatibility (can handle any future carts). There were a few bugs in 0.1.11g that needed a cart version bump to fix, and so I also took the chance to tweak the API (more on that below).

Backwards Compatibility: The time() function (also aliased as t() for tweetjammers) now always means time in seconds even at 60fps. This breaks a couple of 60fps carts that I know of (sorry @rez and @jobe!) but I think it's worth biting the bullet now to be more consistent and to match Voxatron's t() behaviour. With any luck this will also be the last backwards compatibility breakage.

A less disruptive change is in the music mixer: both the drop (3) and vibrato (2) effects are observed when playing an SFX-instrument. This only affects carts using SFX instruments, and which happen to have those (previously) dormant values sitting around, but I couldn't find any examples in the wild yet.

The gfx, map and audio editors now have unlimited undo stack. Unlike the code editor which has one undo stack per tab, the other undo stacks are global to the cartridge. It also works during audio playback, so it's possible to make a bunch of changes to various SFX and/or song patterns, and then roll the changes back and forth while it is playing.

As well as diving code into tabs, it's now also possible to insert code from external text files each time a cartridge is run. This is particularly useful when using an external text editor (no need to modify the .p8 file directly), and also to share code across cartridges while still being able to modify it in one place. Note that this does not make a difference to size limits -- it is just a convenience when working with .p8 files. (When saving .p8.png, the external code is injected). From the manual:

Copying a range of SFXes or song patterns will now copy them into the text clipboard in a format that can pasted into other cartridges, or into a BBS post (similar to GFX snippets). To select a range of SFX or patterns, click the first one you want, and then shift click the last one before using CTRL-C. When pasted into a post, it will show up like this: (doesn't work on mobile yet)

[sfx]

You can copy the snippet back into a cartridge by pressing the [ sfx ] button, CTRL-C, click the destination sfx or song pattern, and then CTRL-V. Note that songs that use SFX instruments will probably not work if you paste into a cartridge that already has data in SFX 0..7.

The default HTML template used for exporting now includes:

The default shell and upload also works a bit smoother with itch.io now -- see the manual for uploading instructions.

Instead of exporting a .js and .html pair, it is now possible to also generate a Web Assembly (.wasm) file which contains the main player code.

EXPORT -W FOO.HTML

Web assembly is supported by almost all browsers and servers now, and is more compact and in theory faster to load. CPU cost seems around the same for PICO-8, but the total exported filesize when zipped is around 300k instead of 400k. This hasn't been tested much yet though, so it's not the default and is marked experimental for now.

The binary exporter now generates a Raspberry Pi binary. It is the version with statically linked SDL2 and dynamically linked WiringPi, that I believe works for most Raspberry Pi users. But let me know if you need to generate the equivalent of pico8_dyn.

To export cartridges from commandline, you can use the new -export switch, and operate on cartridges outside of PICO-8's filesystem. The parameters to the EXPORT command are passed as a single string:

pico8 jelpi.p8 -export "-i 48 jelpi.bin"

Serial() allows you to communicate with other devices via the Raspberry Pi's data pins (the things sticking out that various hats also connect to). There are 2 supported for now: raw GPIO accesss, and WiringPi's spi interface (not tested!). Accessing GPIO via SERIAL() is useful when higher precision timing is needed than manually POKE()ing the gpio memory addresses; transactions including delay instructions are added to a queue that is executed at the end of each frame.

Here's an example, controlling a string of 40 LEDs inside Pimoroni's plasma button kit for Picade:

[tweet ]

Incidentally, 0.1.12 is also optimized to run well out of the box on a Picade, but more on that later!

You can now used Windows mode under Raspbian's desktop environment; Just hit alt-enter to toggle as usual. This only works in software blitting mode, so if you use "pico8 -pixel_perfect 0" it will force the the rpi driver to be used instead of x11. Running under the default driver (x11) now also resolves the issue of leaking keypresses and clicks to the desktop, but it is still present when using rpi.

CTRL-B to toggle commenting of a Block of lines
CTRL-W to jump to the start (the staWt?) of a line (CTRL-E for End of line)
CTRL-H for Hyper search -- search across tabs

The code editor now uses less cpu by caching code highlighting information, so is noticeable when editing long files on older machines or devices with limited battery life. Napkin calculation: after 250k hours of combined use, this will save enough electricity to drive a Chevrolet EV around the circumference of the Earth once.

The default code editor background is now blue! If you'd like to (permanently) change it back, you can now alter it from inside PICO-8 (instead of using config.txt):

> CONFIG THEME CLASSIC

Themes only control the background of the code editor at present, but might do more in future.

When cel values in the map editor have corresponding sprites with only black pixels, or when only black pixels are visible when zoomed out, there is no way to see which tiles have a non-zero value. So for these cases, PICO-8 0.1.12 now displays a single blue dot for that cel to indicate this.

API changes that required a cart version bump:

I took the opportunity to make some final adjustments to the API and CPU counting:

all(), foreach() are now not much slower than pairs() or manually iterating with integer indexes. The CPU usage reporting is also slightly more accurate, but it will will never be very precise, because keeping track of virtual CPU cost can be expensive itself! And also the PICO-8 CPU costs are made up and essentially silly when looked at too closely.

PICO-8 0.1.12 is now a bit better at managing scaling to different screen sizes. You probably don't need to know any of this, but here's how it works..

When possible, PICO-8 uses "pixel perfect" scaling, which means it chooses the highest possible scaling factor that is a whole number for which the PICO-8 display will fit on the screen. This means that PICO-8 pixels are a nice regular size and without blurry scaling artifacts, but for smaller screen resolutions it means you can get quite wide black boundaries.

0.1.12 addresses this by automatically choosing when to run in pixel perfect mode by default. If the size of the margins is more than 10% of the smallest screen axis, it will turn pixel perfect off. You can still force pixel perfect with "pico8 -pixel_perfect 0".

0.1.12 also introduces another setting: preblit_scale. Instead of doing a filtered scale from a 128x128 image (super-blurry), PICO-8 first performs a non-filtered scale up to something like 384x384, and then lets the platform-specific blitter stretch that instead. The default value of preblit_scale is set to automatic, which attempts to find the best trade-off between regular pixel size and pixel crispness.

On a related note, PICO-8 is now better at deciding when it is running in the foreground. There was a bug in 0.1.11g and earlier under Windows that caused PICO-8 to think it was in the background and so sleep() longer each frame. So some Windows users might notice improvement when running 60fps cartridges under 0.1.12 using a desktop-sized window (the default fullscreen method).

Search for carts by the same author. You can find this option under the per-cart menu (hit the menu button while the cartridge you want is selected). It will send you over to the search list, with a search phrase of "by:authorname". This also works in the BBS search bar.

This will be the last major update for PICO-8's alpha, apart from some stray bug fixing. Later this year PICO-8 will go into beta with one last feature: online scores. It will take a while though, as I'm hoping to make the architecture scalable and flexible, and will take some time to get it right. The high score tables allow an extra small blob of data that can be abused to do interesting things that might not even be related to keeping track of scores :p

Until then, I hope you enjoy 0.1.12, and please post any bugs if you find them!

-- zep

Added: #include a text file, or a tab from another cartridge
Added: Unlimited undo for gfx,map,sfx
Added: [sfx] snippets: copy and paste sound & music between PICO-8 instances and BBS posts
Added: (BBS) sfx snippet player
Added: CTRL-G in code editor to repeat search across all tabs
Added: Splore search text entry with cursor key button presses
Added: Custom tab widths (tab_width in config.txt)
Added: Web exporter template: joystick & touch support, preview image, menu buttons, adaptive size, controls screen
Added: .wasm exporter (use -w)
Added: Raspberry Pi binary exporter
Added: -export // run the EXPORT command from host commandline
Added: Toggle flags on multiple sprites at once by selecting them first
Added: Confirmations when loading/saving with unsaved changes
Added: Windowed mode support for Raspberry Pi
Added: serial() interface for Raspberry Pi // serial() -- spi, ws281x, direct bit banging
Added: api: peek2 poke2 rawset rawget rawlen rawequal next
Added: Comment/uncomment selected block with CTRL-B
Added: Can save screenshots and gifs from exported binaries via EXTCMD
Added: Can exit exported binaries after runtime error / stop(), and also via EXTCMD("SHUTDOWN")
Added: SHUTDOWN menu item added to pause menu when running via "-run cartfile"
Added: -kiosk to run in kiosk mode: boot into splore, favourites menu only, no cart menu
Added: -root_path to set root cartridges folder from commandline
Added: shift+space in song view to play from the current quarter of the selected channel
Added: CTRL-W, CTRL-E in code editor to jump to start / end of line
Added: -accept_future to load cartides made with future versions of PICO-8
Added: -preblit_scale (default: auto) for less blurry scaling with -pixel_perfect 0
Added: -pixel_perfect -1 (auto) only uses pixel perfect scaling when < 10% of the containing screen axis is wasted
Added: highlight all occurances when searching for text in code editor
Added: tab completion across directories
Added: In map editor, non-zero cels that are drawn all black are marked with a single blue dot
Changed: all(), foreach() cpu cost is now much cheaper (but still a little more than using a for loop)
Changed: cursor() can also set the current color with a third parameter
Changed: stat 24..26 return -1 when no music is playing
Changed: 3x4 font characters (uppercase in ascii) allowed in code editor (but not pasteable/editable)
Changed: time() / t() always means seconds since run (but still updated once per _update() / _update60)
Changed: line(x1,y1) can be used to draw from the end of the last line
Changed: del() returns the item deleted on success
Changed: single setting for audio volume (-volume switch, "volume" in config.txt)
Changed: allow '-' in cartdat() names
Changed: 8 and - only map to buttons 4 and 5 by default for CHIP build
Changed: Raspberry Pi pico8_dyn build does not support gpio/serial (and so does not require wiringPi)
Changed: Default theme is 1 (blue background in code editor)
Changed: When loading a cart from commandline, automatically set the current path if inside PICO-8's filesystem
Fixed: Code editor uses too much cpu / battery power
Fixed: cstore() with an external cart name broken when run from exported cart or as bbs cart
Fixed: Undoing changes to SFX after using pitch drawing tool clears SFX data
Fixed: Running headless scripts under Windows / Mac OSX crashes
Fixed: Running headless scripts with no video driver fails
Fixed: Can not load BBS carts in headless script mode (without auto-running)
Fixed: (Web exporter) mouse cursor doesn't work in fullscreen
Fixed: (Web exporter) mouse button 2 brings up context menu
Fixed: (Web exporter) Clusters of FS.syncfs calls causing error messages (and inefficient?)
Fixed: (Windows) PICO-8 behaves as if it is not the foreground application
Fixed: divide and abs sign flipping for 0x8000.0000
Fixed: sqrt(0x0000.0001) freezes
Fixed: "-1"+0 evaluates to 0xffff.0001
Fixed: shift-tabbing to unindent alters selection range
Fixed: background_sleep_ms reverts to default value
Fixed: "open in thread" option appears for local carts
Fixed: (code editor) undo markers in unexpected places
Fixed: root_path, desktop_path in config.txt doesn't work without trailing slash
Fixed: Audio sampling rate is wrong when device/driver doesn't support 22050MHz
Fixed: Loading cart with less than 5 pixel rows of gfx does not clear default white cross sprite
Fixed: cpu cycle exploit using peek4 with no parameters
Fixed: SFX keyboard editing operations (e.g. SPD +/-) sometimes applied to the wrong SFX
Fixed: Cursor behaviour when moving between song and sfx view, and when playing music
Fixed: Selecting SFX notes with shift + home/end/pgup/pgdown
Fixed: Vibrato (2) and drop (3) effects in SFX instruments not observed
Fixed: Can not place note at C-0 in pitch mode
Fixed: CTRL-F search in code skips matches that are close together
Fixed: (Mac) warning about unoptimized program (built with SDL 2.0.9, + now 64-bit)
Fixed: (Raspberry Pi) Keypresses leaking to desktop
Fixed: (Raspberry Pi) Keyboard layout fixed to US
Fixed: printh(nil) prints [false] instead of [nil]
Fixed: toggling audio mute twice returns to maximum volume
Fixed: alt+cursors moves cursor in code editor
Fixed: del does not work on first character of code or commandline
Fixed: preprocessor breaks on double slash in string s="\"
Fixed: sometimes code executing a little after point of runtime error
Fixed: Token count reported in editor is more than 0 after rebooting
Fixed: "Removed empty tabs" message displayed when loading cart with fewer tabs
Fixed: Member variables highlighted when same as API function names (e.g. actor.spr)
Fixed: Hot-plugged joysticks not recognized

v0.1.12b

Added: config command (e.g. CONFIG THEME CLASSIC)
Fixed: Windows sound resampling artifacts (moved to SDL2 2.0.9 audio:directsound)
Fixed: Glyphs stored as unicode can not load when #include'd
Fixed: Code highlighting is wrong after select and delete a line
Fixed: Last line endpoint not present in draw state memory
Fixed: Ubuntu 16.04 can not run because requires glibc 2.27 (reduced dependency to 2.14)
Fixed: stat(102) returns nil when run from binary instead of 0 (now 0)
Fixed: Loading cartridge from commandline fails when path contains "../"
Fixed: (OSX) Crash when reloading external changes with CTRL-R
Fixed: (Windows) Crash when running cart with included code
Fixed: Can not export or include extra cartridges outside of current directory
Fixed: Off by 1 when search for line 1 (affected ctrl-b, ctrl-l)
Fixed: html template -- mouse cursor showing over canvas (now hidden by default)

v0.1.12c

Fixed: CPU usage reported by stat(1) is higher than actual value
Fixed: Fail to load .p8 cartridges w/ BOM marker / CRLF endlines
Fixed: Syntax errors / crash caused by #including files containing BOM / CRLFs
Fixed: Can not save .p8 when contains unresolved #includes
Fixed: Can't open pico-8.txt in Notepad.exe (added CRLFs)
Fixed: Can delete null terminator at end of code (revealing previously deleted code)