Log In  

Cart #trucolor256-3 | 2021-12-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
14
TO LOAD THIS PICO-8 CART in immediate mode type, load #trucolor256

VVhat's new ?

12/16/21
✅ Changed code so it will load any image, 3-bytes per pixel or 4-bytes per pixel such as images that include transparent layers. Thanks to @jo560hs for catching this error.
✅ Set the code to exit if you choose WEBSITE. No need for it to keep running.

Cart #mayasurama-0 | 2021-12-10 | Code ▽ | Embed ▽ | No License
14

[8x8]
From the lab of dw817 here is me wishing Happy Holidays to all of you. :)

Not only do you get a nice Christmas greeting in 256-colors, (you might need to squint a bit to remove the flicker), you can create your own 256-color pictures to add to your own Pico-8 games with the EXE tool I've included as well as some sample pictures to try on your own.

You can also import any PNGs or JPGs of any proportion or image size from your own collection or from the internet, my program will accept them all the same.

Once the filebox appears and you decide you want JPG, Press TAB and the down arrow key to change to view JPG images.

https://www.mediafire.com/file/i4ki5m561d1nkom/To256+(12-10-21).zip

To record your results you can save to the clipboard replacing the single line that contains your picture or save an entirely new Pico-8 program that features just the image you've put in it. No need to paste.

If you choose clipboard, once the code is run, go back to your Pico-8 code and press the following keys:

CTRL+P CTRL+V CTRL+P

Make certain you press CTRL+P twice. Once before and after CTRL+V. Then the image will be pasted properly.

Also this affects none of your sprites, mapper, SFX, or music. They are all untouched once the picture has been seen. This demo shows a box appear in the center at the end which is from the sprite worksheet to show nothing is affected.

The playback routine is also pretty small too at 186-tokens, and outside of the picture, no other code is needed.

If you get flicker, and you are using Firefox, shut it down completely and bring it back up. Apparently the timer is getting garbled somehow. I have received no flicker at all running it in the P8 system, however.

@zep ! Please add ability to play carts at 120fps =or= allow someone to plot 2-pixels in the same space merging the colors with the original. Doing so should remove the last of the flicker in this particular code.

If this cart becomes popular I'll consider adding to the converter the ability to edit the image in true-256 color fashion where you can fill in regions to match other colors so the direct conversion looks better as well as fine-tune editing - useful for real photographs which will almost always give trouble converting to 256-colors.

And there you have it !

As always if you have any questions, comments, or kerosene, please direct them below.

Merry Christmas !

P#102333 2021-12-10 22:26 ( Edited 2021-12-17 04:54)

1

nice program! for some reason when i put a png with a transparent backround the thing just breaks:

maybe replace transparent pixels with white?

P#102352 2021-12-11 00:22

Thanks, @jo560hs ... and,

Oh, transparency. Something I had not anticipated. I just tried it with one of my own PNGs with transparency and it works fine.

Can you post the PNG HERE or give me the URL to it please ? With that image I should be able to hunt down the problem.

Failing transparency on some images it should work for all other files. My program is especially looking for 128x128 PNG images with 24-bit color although it will reduce larger images and keep the proportion correct.

P#102362 2021-12-11 01:19 ( Edited 2021-12-11 02:19)

Usually I hate the flicker, but it's almost un-noticeable here! Definitely quite the illusion. I don't see much utility out-side of a splash screen though but it's a great party trick

P#102536 2021-12-13 05:14

Thanks, @ScrubSandwich. Yep, it's pretty well a parlor trick and while I'm certain you could play music behind it no problem and the illusion would be maintained, I doubt a real game could be developed and played in it.

Certainly it could be done you could post a cart that has 2-pieces. The first is opening music and 256-blended logo. Hit a key, it runs the main game via the load # command.

Yet this goes back once again to some suggestions and directions I'd like to see future Pico-8 take - hopefully @zep is reading.

We already have 128x128 pixels at 16-colors, that's 8192-bytes, that's fine.

We HAVE the potential to have many more resolutions though which I think would be well-appreciated. Here are 3 at the top.

  1. My favorite, 256x256 pixels with B&W dots only, or choose your two-colors. 8192-bytes.
  2. 64x128 pixels with 1-byte per pixel, 256-colors. Each pixel would appear 2-across by 1 down. Pretty well would look like just what I developed here but would not flicker. 8192-bytes.
  3. 64x64 pixels with 2-bytes per pixel, 65536 colors or mix and match the full spectrum of 32-shades of red, 64-shades of green, and 32-shades of blue. Each pixel would appear 2-across by 2-down. Also 8192-bytes.

The other idea might be simpler and that is to have a screen mode, a mode only, where you can blend up to 2-colors per pixel on the screen visually. Visual only. Memory does not change.

For instance if you plotted let's say color 4 and color 0 on this new screen mode. You would have a darker brown but if you read the pixel back it would still be zero, the last color you plotted.

So in fact the screen itself is still 128x128 at 16-color pixels but the MODE it runs in would let you BLEND up to 2-colors per pixel visually.

Thus it would require your code to plot 2-black pixels per pixel to erase it completely and CLS() might even have to be run twice to clear the screen completely.

I think these are good ideas and can be done ! Something to consider ...

P#102540 2021-12-13 06:06 ( Edited 2021-12-13 06:08)

@jo560hs I had not heard from you. Could you please post either here in Lexaloffle or the URL to the existing transparent PNG picture you have that will not convert in my program ?

I'd like to have it working for you, thanks.

P#102542 2021-12-13 06:10

oops i forgot to send it
here: https://drive.google.com/file/d/1B7IHjeIHk1XQW4SjFhnL6ssg_IiH7WpL/view?usp=sharing
(google drive because lexaloffle doesnt support transparent images)

P#102955 2021-12-17 02:36
1

Thanks, @jo560hs. I have the image in hand. Hmm ... There is a slight set of green pixels outlining in the image provided.

Here is the command code:

DrawImage LoadImage("transp.png"),0,0

And here are the image results:

.. wait, I am forgetting you said it did not load properly in my converter. Let me get that working first and I'll return.

. . .

Found the problem. Apparently loading a transparent PNG uses 4-channels instead of the standard 3. The easiest solution would be to treat it all images as custom PNG and force-load it using the resizer and method. There really was no reason for my code to skip over it if the image was already 128x128.

At a pixel level nothing will change, however all images will now be loaded internally instead of assuming 128x128 perfection at 3-bytes per. In this I should be able to give you your WHITE background.

Working on this ...

Solved. No pixel differences in other imports. Let me save it back. Be aware that any resized image which does not appear 1x1 proportions will have a white background behind it now, transparent source or not.

Cart #teperubimi-0 | 2021-12-17 | Code ▽ | Embed ▽ | No License
1

There are 2 changes now. See top for information.

Not now but later, JO560HS, I can see it would be helpful to have a pixel editor in the EXE converter for instance to remove or replace with a new color the stray green pixels. It is considered.

P#102957 2021-12-17 03:17 ( Edited 2021-12-17 04:04)

This stuff looks pretty cool.
Also, I was working on a way to do this with normal 4 bit sprites by making 16 color palettes (like the GBA).

P#103507 2021-12-25 04:48

Hi @Gabe_8_bit:

Glad you like it ! And no I haven't seen the GBA do this. This idea is actually based on an article I wrote for Call A.P.P.L.E. back when I was a tween. That and I think someone in Pico-8 showed a merge of colors use a cross-hatch pattern.

Is there an example cart for GBA ?

P#103511 2021-12-25 05:28 ( Edited 2021-12-25 05:32)

no I actually meant that I was trying to make PICO-8 sprites work like GBA sprites.

P#103513 2021-12-25 05:31

Oh, OKAY, @Gabe_8_bit. Welp prior to discovering Pico-8 I was coding on the GBA and eventually Blitz. In any case I can add a pixel editor to the main EXE for this 256-color converter - if someone shows an interest.

P#103514 2021-12-25 05:33 ( Edited 2021-12-25 05:34)

...but how to effectively use this as a subroutine to display dynamically generated 256 color graphics? Speaking asa non-magician.

P#113307 2022-06-18 06:47

Hi @r_leclair:

I don't know if that is possible. I did this years ago on the Apple ][ computer to give you "virtually" 560-pixels across and even wrote an article for Call A.P.P.L.E. about it. Yet to maintain the effect it had to run in a tight 6502-assembly loop.

As I remember it I made a loop where it would show HIRES 1 and look for a key. If there was a key it would exit. If no key it then showed HIRES 2 and look for a key. If there was a key it would exit. If no key was found it would return back to showing HIRES 1.

I used NOP between statements to fine-tune out the flicker.

https://www.lexaloffle.com/bbs/?pid=110956#p

For the full article, go HERE:

https://www.lexaloffle.com/bbs/?tid=47549

Until we can blend pixels I'm afraid this is as good as it gets. It must run in a tight loop to give the effect as well as it can.

Now if @zep can add the ability where a function can run automatically in the background of your main code giving it maximum priority over _draw() and _update(), say, function _pulse() running at 30/ 60/ or even 120fps, then it might be possible.

P#113314 2022-06-18 17:03 ( Edited 2022-06-18 17:32)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2022-12-06 22:59:04 | 0.067s | Q:38