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..
Breakage Warning!
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.
Unlimited Undo
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.
#INCLUDE
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:
Source code can be injected into a program at cartridge boot (but not during runtime), using `#INCLUDE FILENAME`, where FILENAME is either a plaintext file (containing Lua code), a tab from another cartridge, or all tabs from another cartridge: #INCLUDE SOMECODE.LUA #INCLUDE ONETAB.P8:1 #INCLUDE ALLTABS.P8 When the cartridge is run, the contents of each included file is treated as if it had been pasted into the editor in place of that line. Normal character count and token limits apply. |
SFX Snippets
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)
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.
Exporters
HTML Template
The default HTML template used for exporting now includes:
- Adaptive layout that also works on mobile
- Touch controls
- Gamepad support
- A controls help menu
- A start button with embedded preview image
- Fixed sound under iOS
- Integrated pause button / pause menu
The default shell and upload also works a bit smoother with itch.io now -- see the manual for uploading instructions.
WASM support
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.
Raspberry Pi Binary
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.
-export switch
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"
Raspberry Pi
SERIAL()
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!
Windowed Mode
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.
Editors
Code Editor Shortcuts
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
Code Editor CPU
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.
Blue Background
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.
Blue Dots
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
API changes that required a cart version bump:
- divide and abs sign flipping for 0x8000.0000
- sqrt(0x0000.0001) freezes
- "-1"+0 evaluates to 0xffff.0001
I took the opportunity to make some final adjustments to the API and CPU counting:
- cursor(x,y,col) can set the draw state colour
- t() / time() always means seconds even at 60fps
- line(x1,y1) can be used to draw from the end of the last line
- next() can be used to write custom iterators // core Lua thing
- Raw metatable operations: rawset rawget rawlen rawequal
- peek2() poke2() for writing/reading 16-bit values
CPU Costs
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.
Display Blitting
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 Author
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.
Road Ahead
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
Changelog
_
Hey Zep! Nice to see 0.1.12 released finally!
I have a question though. How do you make two or more instances of PICO-8 communicate with each other? I don't have a Raspberry Pi or Pocket C.H.I.P.
@StinkerB06 It's only currently possible using a web export, and then using the gpio values that exposed in javascript as pico8_gpio[]:
https://www.lexaloffle.com/bbs/?tid=30059
https://neopolita.itch.io/pico8com
It depends what you want to do though. For less real-time communication, you could set up a network drive and communicate via cstore/reload, for example.
Whoa. This is a huge update when you look at it all like this. I love all of the small QOL changes too. Simple things like the blue dots on the map are so useful! Thanks again! :D
Also, the staWt? hahahaha
Forgot to mention! THANK YOU for the Raspberry Pi changes! That will be hugely helpful this summer for the workshops I'm running! :D
@zep I don't want to use JS exports, I just want to communicate between PICO-8's locally on the host OS. My thread about it
Also, Google Chrome detected the Windows ZIP file for 0.1.12c having a virus in it. Can you please fix that?
@StinkerB06, I just now scanned the zip file with VirusTotal (which is uses 61 different anti-virus scanners) and they all reported clean. If you downloaded the installer version, that might be the problem. The installer version does set off 3 of the 61 scanners. However, not only is it only 3 out of 61, but those 3 are all reporting different things, which is usually a sign that that it's a false-positive.
If you want to be really safe, though, just grab the zip version instead and copy them over your currently installed version. (With a default Windows install, just type folder in the PICO-8 console and then go up one folder.)
This is a great release. Thanks for the prompt updates and looking forward to the possibilities with the (ab)use of online scores.
One small feature request: would it be possible to store somewhere in cart memory the current seed value of the pseudorandom number generator? It would be useful to be able to "pause" the state of deterministic randomness then later resume it.
There are probably many use cases, but here's an example hash function:
--let's say the current random seed is stored at 0xBEEF --returns the same normalized "random" value given the same (x,y) function hash(x,y) local curseed=peek4(0xBEEF) srand(bxor(x*1.031,y)) local h=rnd() srand(curseed) return h end |
EDIT: @MBoffin: that does produce the same effect—thanks!
@musurca This came up on the Discord recently. The easiest way to "pause" the PRNG is just do something like this:
--pause rnd_seed=rnd(32700) srand(5) --all your deterministic stuff --unpause srand(rnd_seed) |
so many great improvements and fixes! and yes we are overdue for another p8jam :>
is the BBS going to get the same nice new features as the HTML export?
Love the update, sfx snippets are so great, thank you so much!
Again, really great update Zep, thanks!
That "Blue Dot" change is brilliant.
No more shall I temporarily add a single green pixel to the middle of my black tile to tell the difference between "black bg" and "nothing bg" :D
Thanks so much, zep! And thanks for the rapid fixes of the stuff I and others reported on Twitter after the first release :)
@StinkerB06: If I remember correctly how that stuff works, as more and more people download PICO-8 0.1.12, Windows SmartScreen (the program that scans and warns you that downloaded files might be unsafe) will learn that it is probably trustworthy and let it through without warnings.
Hey @zep in the changelog you mentioned CHIP!? :D
but i don't see a CHIP build on the download page :(
is this because it will be released a little later, or is on the linux/raspi builds now compatible with Pocket CHIP?
> is the BBS going to get the same nice new features as the HTML export? |
@kittenm4ster: most of them! I had trouble integrating the adaptive layout, but will add the controls button etc. next website update.
> I just want to communicate between PICO-8's locally on the host OS |
@StinkerB06: it will likely be possible to do this at some point, as part of a more general solution. I don't want to promise anything yet though, because I'm still designing how / if it will work with other related features. I'll post in your other thread when I know more.
@JeremyRedhead a PocketCHIP build will be up Monday!
@Ikura: which operating system are you using? If Windows / OSX / Linux / Raspberry Pi, check the downloads page. For CHIP / PocketCHIP, check my blog on Monday.
@zep
why one i hit CTRL or ALT, the keyboard not responding to caracters and digits typings in Pico-8 on Raspberry Pi...?
Seeing how this version will break compatibility with previous versions - how would I go about upgrading pico8 on my PocketCHIP? I managed to flash it to the newest image available via http://chip.jfpossibilities.com/chip/debian/ and got to v0.1.11, but now I guess I am stuck till the JF repo is updated..?
@zep Somehow I believe my PocketCHIP has the power to summon you in order to stay alive
The SFX/song snippet player doesn't have any sound in Google Chrome.
EDIT: It does now.
@StinkerB06: It does in my Google Chrome (latest version, on both Windows 10 and Fedora Linux)
I've been having a lot of audio issues once exported to web. The audio will get laggy and sometimes clip when there's no reason for it to do so. The pixels also appear jagged, depending on where I'm looking at it from. This was a problem for me on my Chromebook, as well as my friend who was viewing with Firefox on Windows 10. This did not happen when exported from 0.11.
Here is a recording of the Pico-8 theme from a cart when exported to web, viewed on Windows 10 with Firefox: https://clyp.it/drwu5jn1
EDIT: Here is a screenshot of what I'm talking about when I say that the lines are jagged. You can see this is most prominent toward the upper half of the cart.
@zep
Thanks for the new background!
- Also the blue dots are really helpful, but I think I found a bug there:
it shows blue dots instead of my wall tiles when I zoom out
EDIT:
- the hyper search functions works perfectly, for all who also wonder:
press cmd+f, type your keyword to search for, then hit cmd+h to cycle thru tabs
/** outdated
- Also I am a bit curious about the hyper search function :D
on mac when I hit ctr+h or cmd+h it iterates through the code tabs.
It is not really a search function I guess.
Also the regular search function (cmd-f) always just finds one word,
how can I see the other results? A true search function would be really nice^^
Anyways thank you very much!
I really love the pico-8 and already learned a lot by using it!
*/
@zep Two bug reports:
1
I'm getting odd error messages when including files. It seems like it could be related encoding issues or "invisible characters" that Pico-8 gets choked up on. Here is an empty p8 file that includes test.txt.
And here is what test.txt looks like in Notepad++
Here is a link to test.txt
https://www.dropbox.com/s/h8ewx07vvzdy33s/test.txt?dl=0
2
It seems like uploading the HTML5 template it to itch.io shifts some things around which mis-aligns the touch control display. The buttons appear below from where they actually are. The issue occured to me on two Smartphones I had access to - iPhone 5C and iPhone 6S:
http://krystman.itch.io/breakout-hero
The template works fine when not embedded on itch.io.
Is there a way to turn off the Mobile functionality for those cases?
I can't run pico-8 v0.1.12c raspberry pi. I got this message error:
error while loading shared libraries: libsndio.so.6.1: cannot open shared object file: No such file or directory.
Pico-8 was running fine on v0.1.11g
What should I do? Please help
I see that there is now native support for "joystick" controls, but there doesn't seem to be a way to change these controls. I would love to play Tinysim with just my controller but I can't map Player 2 X and O to my controller.
EDIT: I managed to find a way to add custom controller mappings to sdl_controllers.txt, but it interprets x and y as fancier a and b's. Is there any way to make this map to player 2?
Can the export command line argument run headless? If it does I could set up an automated build system for web builds and then I'd have my dream of pico 8 development on my phone (mostly) sorted!
Hi, Zep! I just got a GameHAT for my RPi3, and I tried putting Pico-8 0.1.12 on it. But the controls don't work! They're accessed through GPIO, so is the GPIO feature interfering somehow? Is there a way to configure it?
EDIT!!!!!!
If you've updated to 0.1.12c, you'll discover that GPIO joystick stops working. Took me a lot of digging and trial and error, but this is the solution:
Download libSDL2 Source: https://www.libsdl.org/download-2.0.php
(Note, you don't need to compile the whole thing if you already have libsdl2 installed!)
Unzip the source code and cd to the directory test and compile controllermap.
unzip SDL2-2.0.7.tar.gz
cd SDL2-2.0.7/test
./configure
make controllermap
Now run controller map and follow the onscreen directions to get your config in a file.
./controllermap 0 >> controller.txt
Make a back up! You'll want this in the future!
Now copy it to ~/.lexaloffle/pico-8/sdl_controllers.txt
Run pico8 with joystick 0
pico8 -joystick 0
HAPPY TIMES!!!
TLDR: My config file is this:
15000000010000000500000000010000,GPIO Controller 1,platform:Linux,a:b1,b:b0,x:b4,y:b3,back:b11,start:b10,leftshoulder:b7,rightshoulder:b6,leftx:a0,lefty:a1,
@Krystman I tried #include today and came up with this:
If you export your cart to png you'll see that the last 21 characters of your lua file are duplicated during the import. So adding 21 minus characters at the end of your external lua file will do the trick.
-------------------- :)
+1 for #include issues
I've tried Txori's "fix" and that's not helping as the issue seems cumulative (including more and more lines?). I.e. first include duplicates X chars, second duplicates X*2 chars... or something like that.
UTF-8 files with CRLF. v0.1.12c
Is it us being dim, or are most people just not trying to use them?
EDIT:
OK, converted from CRLF to LF and it fixed the issue - guess the processor is not coping with CR chars when it calculates the length.
EDIT 2:
@samhocevar has a slightly more in depth explanation. https://www.lexaloffle.com/bbs/?pid=63569
@zep Do you think we could get some kind of feature to rearrange tabs? That would be awesome-sauce!
@zep This version’s HTML mobile player controls do not work on itch.io (and maybe other websites, but I’ve only seen this on itch.io). Here’s where I saw the bug : https://jalecko.itch.io/lead-valley I am using an iPad by the way.
Dear @zep,
I need to know everything about the “pixel perfect” formula and rules, and I found maybe a typo in your explanation of the parameter.
I need it to try to implement the same rules and algorithm in fbcp-ili9341 (see https://github.com/juj/fbcp-ili9341/issues/107 ).
This is to guarantee pixel perfect on the SPI LCD (128x128) I need from pico8 an integer scaling, always.
In the text above you say:
You can stll force pixel perfect with “pico8 -pixel_perfect 0”.
Are you sure it should not be “pico8 -pixel_perfect 1”?
For testing your heuristic, I started pico8 on a 640x480 HDMI resolution.
It take the whole height, so I assume 480x480, even if I put “-pixel_perfect 0”.
But if I put “-pixel_perfect 1”, it give a big border so I assume it scale to 384x384.
Is there a way to ouput the resolution pico8 chosed (on stdout or else)?
Regards
PS: Right now I will assume "-pixel_perfect 1" take the biggest integer scaling possible, and I will implement that in my algorithm.
good that I stuck around. Looks like a whole lot of new and useful additions in this edition.
NICE GOING, ZEP !
I'll find the IMPORT function quite useful for my works.
I haven't checked yet, but is there compile to Android APK available yet ?
@zep not sure it this qualifies as the same bug ZOSK mentioned, but mouse input doesn't on browser on mobile (BBS and exported to itch.io).
(It did work on some older versions)
Never could get it to work myself, @BoneVolt, something simple like Chris or mine's cellphone. It's a problem.
Oh I see that the update of the online BBS Pico-8 player is updated with the external gamepad's input support! Thanks!
[Please log in to post a comment]