Log In  


Hello.

I am understanding I am not to write a program that allows you to import/export PNG files to and from P8 cartridges, so I wrote this in an attempt to assist other Pico-8 users of the educational edition since they cannot import or export graphics or music.

It uses a variance of the graphics for the little library I wrote, the first Picotron program written found HERE:

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

I exchanged the spider and bomb for Forest (tree) and rubble which can double as mountains. There are some miscellaneous sound effects and I also added a musical note player that overlaps the notes as they play so they sound better.

Cart #p8edulib-1 | 2023-02-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

(v01 02-04-23)
TO LOAD THIS PICO-8 CART, in immediate mode, type: load #p8edulib

-- educational edition library
-- written by dw817 (02-03-23)

-- standard pico-8 ⌂ license.

-- useful for either the
-- educational edition of
-- pico-8 or the lazy coder
-- in all of us. :)

function _init()

-- clear screen.
 cls()

-- this string contains all 128
-- 8x8 pixeled characters.
-- it includes uppercase
-- letters, lowercase letters,
-- and 32-special gaming
-- characters. they are in no
-- way compressed. if you want
-- compressed, let me know and
-- i will write the code for
-- it.
fontz="0000000000000000000000000000000000000000000000000000000000000000000770000077770005777700055770000055000000077000005500000000000007700770577057705500550000000000000000000000000000000000000000000077077007777777557757700777777755775770055055000000000000000000000770000777770055555770007777000775500055777770055775000055000000000000077007705577577005577500077577005775577055005500000000000000777000077577077577705577757705775577077577705505550000000000000770000057700000557700000550000000000000000000000000000000000000770000055577000005577000005770000077000077500005500000000000000000077000077500007700000577000005577000005557700000550000000000000770007757707757777770577777707757757750577550005500000000000000000000000770000057700007777770555775000057700000550000000000000000000000000000000000000000000000077000005770000055770000055000000000000000000000000000777777775555555000000000000000000000000000000000000000000000000000000000000770000057700000550000000000000770000057770000557770000557770000557770000557700000550000000000007777700775557757707577577575775775057755777770055555000000000000077700005770000057700000577000005770000077770005555000000000000077770007755770577555005557700000555770077777705555550000000000077777705577550005577000077500005770077055777700055550000000000007770000555770000775770057755770577777705775550055000000000000000777777055555770007777700775550057700770557777000555500000000000007770000555770000775770077057705770577055777700055550000000000007777770577555005577000005777700055577000005577000005500000000000777777057755770557777000775577057705770557777000555500000000000007777000775577057705770577077005577500005577700005550000000000000077000005770000055000000000000000770000057700000550000000000000007700000577000005500000007700000577000005570000005570000005000077000005557700000555770000775000775000055000000000000000000000000000000077777705555550007777770555555000000000000000000000000000000077000077500077500005557700000555770000055000000000000000000007777000775577057705500555770000055000000077000005500000000000000077700007550700707750757570757557777570555507000077700005550000000000000777700077550005770770057755770577777005555500000000000000007700077577007705770577057705577577005577770005555000000000000000000007777000555577000005770000057700077770005555000000000000770000057707700577557705770577057705770577777005555500000000000000000000077770007755770577757705550577000777700055550000000000007770000555770000777770055577000005770000057700000557770000555000000000007777700577557705770577057707700577550005577770005555000000007700077777007755770577057705770577057705770550055000000000000077000005500000007770000577000005770000057700000550000000000000077000005500000007770000577000005770000057700000557777000555500000007700770577055775770055777700077577007705770550055000000000000077700005770000057700000577000005770000077700005550000000000000000000000770777077777775775757757750577577005775500055000000000000000000077077007707770577557705770577057705770550055000000000000000000007777000775577057705770577057705577770005555000000000000000000000777770077557705770577055775770055057700000577000005500000000000077777005775577057705770577077005775500077770005555000000000000007707700770777055055770000057700000577000005500000000000000000007770000555770000057700000577000005577700005550000000000000077000077770005557700000577000005770000777000055500000000000000000000077007705770577057705770577757705770770055055000000000000000000007700770557757700557777000557770000557700000550000000000000000000770007757700577577075775777777757775770555055000000000000000000077007705577770005577000007777000775577055005500000000000000000007700770577057705770577057707700577550005577770005555000000000000777777055775570055775000755770057777770555555000000000000777700055577000005770000057700000577000077770005555000000000000000077000007770000777000077700007770000577000005500000000000000007777000577500005770000057700000577000005777700055550000000000000000000000070000007770000775770077055775500055000000000000000000000000000000000000000000000000000000000077777705555550000000000007777000577700005770000057000000500000000000000000000000000000007777000577570005775770057755700577757705770557055000500000000000777777057755770557757700770577057705770557775000555000000000000077777005555577000005770000057700000770007777000555500000000000000077770007757700770577057705770577057705577777005555500000000000777777055555770007757700550577000005770077777005555500000000000077777005555577000775770055057700000577000005770000055000000000000777700055557700000577007775770577057705777770055555000000000000770077057705770577777705775577057705770577057705500550000000000007777000557700000577000005770000057700000777700055550000000000007777000577500005770000057700000577007705577770005555000000000000770077055775770055777700057777000775770077057705500550000000000000007700000577000005770000057700700577057777770555555000000000007700077577707775777777757757577577505775770057755000550000000000770077057707770577777705777577057705770577057705500550000000000007777000775577057705770577057705770577055777700055550000000000000777770077557705770577055775770055057700000577000005500000000000077770007755770577057705577770005577000007777000555500000000000007777700775577057705770550777700077577007705770550055000000000007770000555770000057700000577000005770000055777000055500000000000777777055555500000770000057700000577000005770000055000000000000077007705770577057705770577057705777577057707700550550000000000007770770577057705577577005577770005577700005577000005500000000000777007757700577577005775770757757777777577757705550550000000000077007705577770005577000005770000077770007755770550055000000000007700770577057705770577055777700055770000057700000550000000000000777777055775570055775000055770007055770577777705555550000000000077700005777770057777770577777705777770057775000555000000000000000077000005770000057700000550000000770000057700000577000005500000000777000777770077777705777777055777770055577700005550000000000000000000000777077077577577705505550000000000000000000000000000000077700007550700707770757555757570777575575507005577700005550000aa404aa0a4a4a4a00afffa0057bfb7504f3f3f40a4fff4a00a404a00000000000000000084080480084848008484848087cdc7804f1f1f4004fff40000000000000a0000009a9000aaa7aaa004aaa40009a9a9000a404a0000000000000000000444440099999990444444409a979a909a999a909aaaaa9099999990000000000000000002202200288287202888882002e8820000282000000200000000000000dcd0000c1c1c00d1c1c1d0cc171cc0d1c1c1d00c1c1c0000dcd0000000000009aaa9009a999a90a99a99a0a9aaa9a0a99a99a09a999a9009aaa90000000000022e22002e2d2e20222e2220ede7ede0222e22202e2d2e20022e2200000000011111c7c11c7c1111111111111111111c7c111111111c7c11111111111111111bbbbbbbbb3bbbbabbbabb3bbbbbbbbbbbbbbbbbbbb3bbabbbabbbb3bbbbbbbbb333b3b3333b0b0b33b0b0b0b33b0b0b33b0b4b0b33b343b333334333333343330049909990440499909904409499000994409949099499444994400044099099000000000067776006707076067808760067776000000000000676000000000000044400000999000097079000a007a000977790000999000004440000000000000000000000057500005767000576000676670007070000067600000000000000067600007d0d70006d0d600dd676dd0d67076d0dd707dd0d66666d000000000000000000000000555555007777750077777500666775000067750000677500000000000000000055555555777777777777777766666666000000000000000000000000000000000055555500577777005777770057766600577600005776000067750000677500006775000067750000677500006775000067750000677500000000000000000000000000575757570000000000000000000000000000000000577600005776000057760000577600005776000057760000577600005776000067750000677500666775007777750077777500555555000000000000000000000000000000000066666666777777777777777755555555000000000000000000577600005776000057766600577777005777770055555500000000000000000000000000000000000000000000d000000000000000000000000000000000001111111d0000000100000001000000010000000100000001000000010000000167777770d6666670dddddd6000000000777067776670d666dd60dddd000000000000000006000000065d0000065d5d0006665d5d0776665d0777766600000000044444440400000404000094040095940495959404959594044444440000000006044a4406605554067605540676055406760554006604440006000000000000000000700dddddd000dcccc0000dccc000dcccc00dddddd00000007000000000"

-- draw out all 128-characters
-- so you can see what they
-- look like.
  for i=0,7 do
    for j=0,15 do
      print8(chr(j+i*16+32),j,i)
    end
  end

-- simple text.
-- notice i am swapping upper/
-- lower case so uppercase is
-- printed by default and
-- lowercase is achieved by
-- pressing ctrl+p for puny
-- mode and again to return
-- back to normal typing.
print8("\130 hello world! \130",0,12)

-- play all 8 notes, up an
-- octave, then sharps for
-- them.
music8("[cdefgab]c.cdefgab]c")
music8("[c#d#e#f#g#a#b#]c#.")
music8("c#d#e#f#g#a#b#]c#")

end

-- just loop forever.
function _update()
end

-- custom print 8x8 character
-- from included font stored in
-- global string fontz.
-- t = text to print.
-- use \128 to \159 for special
-- characters.
-- each character is separated
-- by 8-pixels horizontally and
-- 8-pixels vertically.
-- x = x-position (0-15).
-- y = y-position (0-15).
-- 82-tokens or 179-chars.
function print8(t,x,y)local s,a=sub for i=1,#t do a=(ord(s(t,i,i))-32)*64+1for j=0,7do poke4(24576+4*x+512*y+j*64,"0x"..(s(fontz,a,a+3).."."..s(fontz,a+4,a+7)))a+=8end x+=1end end

-- some simple sound effects
-- you may want to have in your
-- carts.

function sfxup()print("\ax1c")end

function sfxdown()print("\ax3c")end

function sfxshot()print("\ax3p5c")end

function sfxhiboom()print("\as~i6x3c5")end

function sfxloboom()print("\as~i6x3c1")end

function sfxwalk()print("\as3i6x3c3.c2")end

function sfxbip()print("\as2i7x5c5")end

function sfxbop()print("\as2i7x5c3")end

function sfxbeep()print("\a")end

-- play musical notes.
-- use a b c d e f g for notes.
-- use [ to decrease octave.
-- use ] to increase octave.
-- use . to skip a note.
-- use # to play sharp note ie:
-- a# b#
-- use - to play flat note ie:
-- a- b-
function music8(t)local s,a,p,c,d=sub,0,3for i=1,#t do c=s(t,i+a,i+a)d=s(t,i+1+a,i+1+a)if d=="#"or d=="-"then c=c..d a+=1end if c=="["then p=max(0,p-1)elseif c=="]"then p=min(5,p+1)else print("\^d9 \as\200i7x5"..c..p,0,0)end if i+a>=#t then break end end end

Users of the educational edition of Pico-8, you can copy this code by clipboard and paste directly in your source-code. It not only has 128-characters and game sprites but a fairly robust library of sound effects and the ability to play notes overlapping each other.

If you found this helpful or have further questions, please let me know.

Thanks !

9


thats really cool! i switch between edu and desktop a lot so this is really helpful and cool! thank you!


You are more than welcome, @AntiBrain.

I realize I could just post a cart making use of the spritesheet and SFX table normally, yet by keeping the entire program to 7-bit text ensures that any part of it can be easily ported to any other Pico-8 educational edition code without having to enter either GFX or SFX editor.


1

This is very useful for those of us using the Pico-8 Educational Edition! The import/export restrictions can be tricky, so having a library that simplifies graphics and sound effects is fantastic and will really help with learning. By the way, if you're also a part-time student like me and don't have enough time to do your homework, you can visit EduBirdie the professionals there write great essays. What will help to relieve you and better manage your time. The sound effects and sheet music addition are also a nice touch. Thanks for sharing!



[Please log in to post a comment]