Log In  

Hello !

With the arrival of Picotron comes a great system with a great many errors too. :)

🇵

I am using this symbol in my title until the category "Picotron" has been created. If you want to post your own Pictron code, in absence of a category you can use that emoji too. Just double-click it, press CTRL+C, then CTRL+V to paste it out later in your Picotron title.

Functions are now working and I did manage to write this to demonstrate how to access a multiarray image both in main code and a function. You are also welcome to use the font and sprites I drew and code I typed in your own Picotron projects.


Here now is the code you can try out in Picotron for the display above which includes the 1-line function to display custom 8x8 font + sprites in your own code. First highlight all of the code you see in white below. Move the mouse pointer so it is touching just before the first "-" and holding down the mouse button drag the mouse down all through the code. Let go when you reached the bottom line. Then let go of the mouse entirely.

Instructions continue after code.

-- 128-character 8x8 Pixel Font Library
-- Written by dw817 (01-02-23)
-- Standard Lexaloffle License (see notes where you found this cart)
function _init()

-- Clear screen.
  cls()

-- This string contains all 128 8x8 pixeled characters.
-- They are in no way compressed. If you want compressed, let me know and I will write
-- the code for it.
  fontz="000000000000000000000000000000000000000000000000000000000000000000077000007777000077775000077550000055000007700000005500000000000770077007750775005500550000000000000000000000000000000000000000077077007777777007757755777777700775775500550550000000000000000000077000007777700775555500777700000557700777775500577550000055000000000007700770077577550057755000775770077557750055005500000000077700007757700007775770775777557755775007775770005550550000000000077000000775000077550000055000000000000000000000000000000000000000770000775550077550000775000000770000000577000000055000000000077000000057700000007700000077500007755007755500005500000000000000077000770775770777777507777775775775770557750500005500000000000000000000077000000775000777777000577555000775000000550000000000000000000000000000000000000000000007700000077500007755000005500000000000000000000000000077777777055555550000000000000000000000000000000000000000000000000000000000077000000775000000550000000000000007700000777500077755007775500777550007755000005500000000000007777700775557707757077577575775775057750777775500555550000000000077700000077500000775000007750000077500007777000005555000000000007777000775577000555775000775550775550007777770005555550000000007777770005577550007755000005770077007750077775500055550000000000000777000077555007757700775577507777775005557750000005500000000077777700775555507777700005557700770077500777755000555500000000000077700007755500775770007750770077507750077775500055550000000000777777000555775000077550077775000775550077550000055000000000000077777700775577500777755077557700775077500777755000555500000000000777700077557700775077500770775000577550077755000055500000000000007700000077500000055000000000000077000000775000000550000000000000770000007750000005500000770000007750000075500007550000005000000000770000775550775550000577000000057700000005500000000000000000000000007777770005555550777777000555555000000000000000000000000077000000057700000005770000775550775550000550000000000000000000000777700077557700055077500077555000055000007700000005500000000000077700007055700705770707570757575777755070555500077700000055500000777700007577500775775007557750775777507550775005000550000000007777770077557750775775507750770077507750057775500005550000000000077777007755555077500000775000000770000000777700000555500000000077770000775770007750770077507750775077507777755005555500000000007777770077555550775770007750550077500000077777000055555000000000077777007755555077577000775055007750000077500000055000000000000007777000775555007750000077577700775077500777775000555550000000007700770077507750777777507755775077507750775077500550055000000000077770000077550000775000007750000077500007777000005555000000000000777700000577500000775000007750770077500777755000555500000000007700770077577550777755007777500077577000775077000550055000000000770000007750000077500000775000007750070077777750055555500000000770007707770777577777775775757757750577577500775055000550000000007700770077707750777777507757775077507750775077500550055000000000077770007755770077507750775077507750775007777550005555000000000077777000775577007750775077577550775055007750000005500000000000000777700077557700775077500777755000775500077770000055550000000000777770007755770077507750777705507757700077507700055005500000000000077700007755500077500000775000007750007775500005550000000000007777770005555550007700000077500000775000007750000005500000000000770077007750775077507750775077507757775007707750005505500000000077077700775077507757755077775500777550007755000005500000000000077007770775007757750077577570775777777750775777500550555000000000770077000777755000775500007750000777700077557700055005500000000077007700775077507750775007777550007755000077500000055000000000007777770075577550057755000775500077550700777777500555555000000000077770000775550007750000077500000775000007777000005555000000000077000000777000000777000000777000000777000000775000000550000000000777700000577500000775000007750000077500077775000055550000000000000000000070000007770000775770077550770055000550000000000000000000000000000000000000000000000000000000007777770005555550000000000777700000777500000775000000750000000500000000000000000000000000000000000777700000557700077077507755775007777750005555500000000077000000775770007750770077507750775775507777550005555000000000000000000007777000775555007750000077500000077770000055550000000000000077000770775077557750775077507750775007777750005555500000000000000000077770007755770077577750775055500777700000555500000000000007770000775550077777000077555000775000007750007775500005550000000000000777770077557750775077500770775000557750077775500055550077000000777770007755770077507750775077507750775005500550000000000077000000055000077700000077500000775000007750000005500000000000000770000000550000777000000775000007750000077500777755000555500077000000775077007757755077775500775770007750770005500550000000000777000000775000007750000077500000775000007770000005550000000000000000077707700777777707757577577505775775007750550005500000000000000000770770007770770077557750775077507750775005500550000000000000000007777000775577007750775077507750077775500055550000000000000000007777700077557700775077507757755077505500775000000550000000000000777770077557750775077500770775000557750000777700000555500000000077077000777077007755055077500000775000000550000000000000000000000007770000775550007750000077500077755000055500000000000007700000077770000775550007750000077500000077700000055500000000000000000077007700775077507750775077577750077077500055055000000000000000007700770077577550777755007775500077550000055000000000000000000007700077077500775775707757777777507757775005505550000000000000000077007700077775500077550007777000775577000550055000000000000000007700770077507750775077500770775000557750077775500055550000000000777777007557755005775500077557007777775005555550000000000007770007777750777777507777775007777750005777500000555000000000007700000077500000775000000550000077000000775000007750000005500077700000777770007777770077777750777775507775550005550000000000000000000077700007757707705507775000005550000000000000000000000000077700007055700707770707575557575777075070557550077755000055500aa404aa0a4a4a4a00afffa0057bfb7504f3f3f40a4fff4a00a404a00000000000000000084080480084848008484848087cdc7804f1f1f4004fff40000000000000a0000009a9000aaa7aaa004aaa40009a9a9000a404a0000000000000000000444440099999990444444409a979a909a999a909aaaaa909999999000000000000000000220220027828820288888200288e20000282000000200000000000000dcd0000c1c1c00d1c1c1d0cc171cc0d1c1c1d00c1c1c0000dcd0000000000009aaa9009a999a90a99a99a0a9aaa9a0a99a99a09a999a9009aaa90000000000022e22002e2d2e20222e2220ede7ede0222e22202e2d2e20022e220000000000c7c11111111c7c11111111111111111111111c7c1c7c11111111111111111111bbbbbbbbbabbbb3bbb3bbabbbbbbbbbbbbbbbbbbbbabb3bbb3bbbbabbbbbbbbb0000000006777600670707606780876006777600000000000067600000000000055006505845d000548d5d6005dd65050d566a0060d5a59050600900000500000044400000999000097079000a700a000977790000999000004440000000000000000000575000007675000000675000007667600000707000006760000000000067600007d0d70006d0d600dd676dd0d67076d0dd707dd0d66666d000000000077777760766666d06dddddd0000000077760777666d0766dddd06dd00000000000000000000000000555555005777770057777700577666005776000057760000000000000000005555555577777777777777776666666600000000000000000000000000000000555555007777750077777500666775000067750000677500005776000057760000577600005776000057760000577600005776000057760000000000000000000000000075757575000000000000000000000000000000000067750000677500006775000067750000677500006775000067750000677500005776000057760000577666005777770057777700555555000000000000000000000000000000006666666677777777777777775555555500000000000000000067750000677500666775007777750077777500555555000000000000000000000000000000000000000000000d000000000000000000000000000000000000d11111111000000010000000100000001000000010000000100000001000000000000000000000600000d56000d5d560d5d56660d56667706667777000000000444444404000004049000040495900404959594049595940444444400000000044a4406045550660455067604550676045506760444066000000600000000000070000000dddddd00ccccd000cccd0000ccccd000dddddd00700000000000000000000a00000090000dd80000d00d000d0000d00d0000d000d00d00000dd0000"

-- Draw out all 128-characters so you can see what they look like.
  for i=0,3 do
    for j=0,31 do

-- Draw them centered and near the top of the screen. See below for print8() function.
      print8(chr(j+i*32+32),112+j*8,8+i*8)
    end
  end

-- Set a sample string to display. Note character #130 for gold stars.
-- See original post for key number of all special characters.
  t="\130 Welcome To Picotron - Wave Of The Future ! \130"

-- Print 16-lines down.
  for i=0,15 do

-- Call custom function print8(). See details at function.
-- Notice that x-position gives nice wavy motion.
    print8(t,56+sin(i/15)*24,i*10+56)
  end
end

-- As flip() does not yet work, I have to have this function to make sure our command
-- prompt doesn't overwrite the display.
function _update()
end

-- Custom print 8x8 character from included font stored in string fontz.
-- t = Text to print. Use \128 to \159 for special characters.
-- Each character is separated by 8-pixels horizontally.
-- x = X-position pixel on screen.
-- y = Y-position pixel on screen.
function print8(t,x,y)local a for i=1,#t do a=(ord(sub(t,i,i))-32)*64+1 spr(userdata("[gfx]0808"..sub(fontz,a,a+63)),x,y)x+=8 end end

If you haven't already, highlight that code above. Once it is fully highlighted, press CTRL+C. Then go to this website:

https://www.lexaloffle.com/picotron.php?page=playground

From there click the big triangle to start it. Press [ESC], CTRL+V, the ENTER key, and CTRL+R to run it. Press [ESC] twice to return back to source-code view.


To have this 8x8 font and game sprites in your own original code, you really only need a few lines.

function _init()
  fontz="000000000000000000000000000000000000000000000000000000000000000000077000007777000077775000077550000055000007700000005500000000000770077007750775005500550000000000000000000000000000000000000000077077007777777007757755777777700775775500550550000000000000000000077000007777700775555500777700000557700777775500577550000055000000000007700770077577550057755000775770077557750055005500000000077700007757700007775770775777557755775007775770005550550000000000077000000775000077550000055000000000000000000000000000000000000000770000775550077550000775000000770000000577000000055000000000077000000057700000007700000077500007755007755500005500000000000000077000770775770777777507777775775775770557750500005500000000000000000000077000000775000777777000577555000775000000550000000000000000000000000000000000000000000007700000077500007755000005500000000000000000000000000077777777055555550000000000000000000000000000000000000000000000000000000000077000000775000000550000000000000007700000777500077755007775500777550007755000005500000000000007777700775557707757077577575775775057750777775500555550000000000077700000077500000775000007750000077500007777000005555000000000007777000775577000555775000775550775550007777770005555550000000007777770005577550007755000005770077007750077775500055550000000000000777000077555007757700775577507777775005557750000005500000000077777700775555507777700005557700770077500777755000555500000000000077700007755500775770007750770077507750077775500055550000000000777777000555775000077550077775000775550077550000055000000000000077777700775577500777755077557700775077500777755000555500000000000777700077557700775077500770775000577550077755000055500000000000007700000077500000055000000000000077000000775000000550000000000000770000007750000005500000770000007750000075500007550000005000000000770000775550775550000577000000057700000005500000000000000000000000007777770005555550777777000555555000000000000000000000000077000000057700000005770000775550775550000550000000000000000000000777700077557700055077500077555000055000007700000005500000000000077700007055700705770707570757575777755070555500077700000055500000777700007577500775775007557750775777507550775005000550000000007777770077557750775775507750770077507750057775500005550000000000077777007755555077500000775000000770000000777700000555500000000077770000775770007750770077507750775077507777755005555500000000007777770077555550775770007750550077500000077777000055555000000000077777007755555077577000775055007750000077500000055000000000000007777000775555007750000077577700775077500777775000555550000000007700770077507750777777507755775077507750775077500550055000000000077770000077550000775000007750000077500007777000005555000000000000777700000577500000775000007750770077500777755000555500000000007700770077577550777755007777500077577000775077000550055000000000770000007750000077500000775000007750070077777750055555500000000770007707770777577777775775757757750577577500775055000550000000007700770077707750777777507757775077507750775077500550055000000000077770007755770077507750775077507750775007777550005555000000000077777000775577007750775077577550775055007750000005500000000000000777700077557700775077500777755000775500077770000055550000000000777770007755770077507750777705507757700077507700055005500000000000077700007755500077500000775000007750007775500005550000000000007777770005555550007700000077500000775000007750000005500000000000770077007750775077507750775077507757775007707750005505500000000077077700775077507757755077775500777550007755000005500000000000077007770775007757750077577570775777777750775777500550555000000000770077000777755000775500007750000777700077557700055005500000000077007700775077507750775007777550007755000077500000055000000000007777770075577550057755000775500077550700777777500555555000000000077770000775550007750000077500000775000007777000005555000000000077000000777000000777000000777000000777000000775000000550000000000777700000577500000775000007750000077500077775000055550000000000000000000070000007770000775770077550770055000550000000000000000000000000000000000000000000000000000000007777770005555550000000000777700000777500000775000000750000000500000000000000000000000000000000000777700000557700077077507755775007777750005555500000000077000000775770007750770077507750775775507777550005555000000000000000000007777000775555007750000077500000077770000055550000000000000077000770775077557750775077507750775007777750005555500000000000000000077770007755770077577750775055500777700000555500000000000007770000775550077777000077555000775000007750007775500005550000000000000777770077557750775077500770775000557750077775500055550077000000777770007755770077507750775077507750775005500550000000000077000000055000077700000077500000775000007750000005500000000000000770000000550000777000000775000007750000077500777755000555500077000000775077007757755077775500775770007750770005500550000000000777000000775000007750000077500000775000007770000005550000000000000000077707700777777707757577577505775775007750550005500000000000000000770770007770770077557750775077507750775005500550000000000000000007777000775577007750775077507750077775500055550000000000000000007777700077557700775077507757755077505500775000000550000000000000777770077557750775077500770775000557750000777700000555500000000077077000777077007755055077500000775000000550000000000000000000000007770000775550007750000077500077755000055500000000000007700000077770000775550007750000077500000077700000055500000000000000000077007700775077507750775077577750077077500055055000000000000000007700770077577550777755007775500077550000055000000000000000000007700077077500775775707757777777507757775005505550000000000000000077007700077775500077550007777000775577000550055000000000000000007700770077507750775077500770775000557750077775500055550000000000777777007557755005775500077557007777775005555550000000000007770007777750777777507777775007777750005777500000555000000000007700000077500000775000000550000077000000775000007750000005500077700000777770007777770077777750777775507775550005550000000000000000000077700007757707705507775000005550000000000000000000000000077700007055700707770707575557575777075070557550077755000055500aa404aa0a4a4a4a00afffa0057bfb7504f3f3f40a4fff4a00a404a00000000000000000084080480084848008484848087cdc7804f1f1f4004fff40000000000000a0000009a9000aaa7aaa004aaa40009a9a9000a404a0000000000000000000444440099999990444444409a979a909a999a909aaaaa909999999000000000000000000220220027828820288888200288e20000282000000200000000000000dcd0000c1c1c00d1c1c1d0cc171cc0d1c1c1d00c1c1c0000dcd0000000000009aaa9009a999a90a99a99a0a9aaa9a0a99a99a09a999a9009aaa90000000000022e22002e2d2e20222e2220ede7ede0222e22202e2d2e20022e220000000000c7c11111111c7c11111111111111111111111c7c1c7c11111111111111111111bbbbbbbbbabbbb3bbb3bbabbbbbbbbbbbbbbbbbbbbabb3bbb3bbbbabbbbbbbbb0000000006777600670707606780876006777600000000000067600000000000055006505845d000548d5d6005dd65050d566a0060d5a59050600900000500000044400000999000097079000a700a000977790000999000004440000000000000000000575000007675000000675000007667600000707000006760000000000067600007d0d70006d0d600dd676dd0d67076d0dd707dd0d66666d000000000077777760766666d06dddddd0000000077760777666d0766dddd06dd00000000000000000000000000555555005777770057777700577666005776000057760000000000000000005555555577777777777777776666666600000000000000000000000000000000555555007777750077777500666775000067750000677500005776000057760000577600005776000057760000577600005776000057760000000000000000000000000075757575000000000000000000000000000000000067750000677500006775000067750000677500006775000067750000677500005776000057760000577666005777770057777700555555000000000000000000000000000000006666666677777777777777775555555500000000000000000067750000677500666775007777750077777500555555000000000000000000000000000000000000000000000d000000000000000000000000000000000000d11111111000000010000000100000001000000010000000100000001000000000000000000000600000d56000d5d560d5d56660d56667706667777000000000444444404000004049000040495900404959594049595940444444400000000044a4406045550660455067604550676045506760444066000000600000000000070000000dddddd00ccccd000cccd0000ccccd000dddddd00700000000000000000000a00000090000dd80000d00d000d0000d00d0000d000d00d00000dd0000"
end
function print8(t,x,y)local a for i=1,#t do a=(ord(sub(t,i,i))-32)*64+1 spr(userdata("[gfx]0808"..sub(fontz,a,a+63)),x,y)x+=8 end end

So it is essentially 2-lines of code. Where fontz the string is initialized and the 1-line function named print8()

Copy those and place in each respective function in your own code and you are all set !
To print in this font call print8(t,x,y) where t is a string like hello and x and y are pixel coordinates to draw this at. Use the backslash \ in the string to create special characters like \130 for gold star.

See next section below which details all the special game sprites.


.
If you stick with 8x8 pixeled sprites, you have 60-tiles across by 33-tiles down yielding 480-pixels across by 264-pixels down. In original Pico-8 you could only have 16-tiles across and 16-tiles down with 8x8 pixels, so it's worth considering using this size if you want to make large play areas like old DOS games did with their 80- or 40-characters across and 25-lines down.

Here are the special characters ASCII:

+128 Girl or NPC.
+129 Boy or Player.
+130 Gold Star or Experience Points.
+131 Treasure Chest.
+132 Life Heart.
+133 Jeweled Blue Crystal.
+134 Gold Coin.
+135 Jeweled Red Crystal.
+136 Water.
+137 Grass.
+138 Skull monster.
+139 Spider monster.
+140 Wristwatch or get more time.
+141 Key.
+142 Lock.
+143 Wall.
+144 Up to char #152 is to draw nice boxes and borders.
+148 Good to separate text lines vertically.
+153 Dot to see 8x8 area.
+154 Grid to see 8x8 area.
+155 Stairs leading up.
+156 Stairs leading down.
+157 Open doorway.
+158 Blue flag.
+159 Lit bomb.

So if you wanted to draw a Spider at 64,64 that would be print8("\139",64,64)


This code is Lexaloffle licensed. This means you can use this code and all images entirely for yourself without giving me any credit at all - provided the code is posted in the domain of https://lexaloffle.com/

This is true of all my Pico-8 projects, now, the past, and in the future. They are there for you to take and learn and build from and share in the Lexaloffle website. :)


If you find this helpful or have any questions about, please let me know.

Thanks !

P#123446 2023-01-01 20:41 ( Edited 2023-01-02 19:49)

Thought I would give an update to the code. There was no reason to create an array for the images, so I replaced that in favor of better and smaller code.

It's also only 2-lines of code you need now to use this font and graphic set in your own Picotron code. Defining the string fontz and the 1-line function to display its characters and sprites.

P#123526 2023-01-02 19:23

Hello,

Very nice tool, indeed. I copied it to the picotron, it works fine. I copied it my pico-8, I've got an error, it seems that the word "userdata" in the function print8() gives a NIL error. Did I miss something?

As there are some sections in a program like "lua" or sfx, a memory section like "@f800" (were @xxxx is a customizable address), followed by some data lines, could be very useful to poke some values in pico-8 memory.

P#125058 2023-01-31 08:56

Hi @pfeuh.

Glad you like it ! No, sorry, this code is exclusive to Picotron.

Remember the resolution of Picotron is 480x270 so to get even close to Pico-8 you would need to double the pixels from 128x128 to 256x256 yielding a 112 black unused pixels for the left and right and 7 black pixels for the top and bottom.

Personally I would like it more if the resolution was 512x256, more in standard with monitors, easier to work with in memory at 1-byte per pixel, and easy to resize for Pico-8, or to use 2 Pico-8 doubled screens both left and right.

. . .

If you like, however, I can rewrite this demo for Pico-8 where you still have the special sprites to use in your code. Just let me know. :)

P#125083 2023-01-31 19:15 ( Edited 2023-01-31 19:19)

I am a new bee on the pico-8, I discovered it a month ago, so with your post I also discovered the Picotron. :) I can't decently ask you to rewrite this demo. I'm especially interested in the 8x8 fonts, because in the early 80's I started assembler with an ATARI 800, I got a lot of 8x8 fonts from it. I've already noticed how to embed large things in a string, but I haven't seen anywhere how to display 8x8 fonts.

P#125110 2023-02-01 07:39

@pfeuh check out the "custom fonts" section of these release notes: https://www.lexaloffle.com/bbs/?tid=41544

P#125114 2023-02-01 10:55

Great, thanks a lot. Very useful info on this topic.

P#125115 2023-02-01 11:18

Hi @pancelor. These do not contain unique colors inside the 8x8 font and sprites though, something unique that is built in to Picotron.

@pfeuh:

If you want to build your own monochrome fonts using the custom font memory internal to current Pico-8, I have a tool for that:

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

Not now but later I'll build something simple for Pico-8 like the code above that does not use your sprite space and once again is just raw code that can be copied via normal text.

P#125127 2023-02-01 17:36

@pancelor great link, and not only for custom fonts

@dw817 I understand the memory concept but I don't know how to print these 8x8 fonts.

P#125160 2023-02-02 08:57

Hi @pfeuh. I am now addressing that HERE, true Pico-8 code for use for lazy coders in all of us :) and for the crew using the Educational Edition of Pico-8.

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

Load direct or copy that code, it will work for Pico-8 either the purchased edition or the free edition.

P#125286 2023-02-04 06:29

Nice job, and really useful. I appreciate also the delay effect on sfx and the easy notation of notes in a very educational way. I'm working on a gate midifile => pico*8 music in python3. A lot of traps, I will publish it in some weeks, I suppose.

P#125291 2023-02-04 07:21 ( Edited 2023-02-04 07:51)

[Please log in to post a comment]