Log In  

update: there are basically 3 tools that are relevant here:

  • this tool (sprimp) -- maybe still useful, but superceded by p8x8:
  • p8x8: a tool to fully convert PICO-8 carts to Picotron carts (some assembly required) -- this grew out of sprimp
  • my aseprite exporter plugin -- still useful

You probably want to check out p8x8 instead, but I'm leaving this thread as it is since it may still be useful or interesting to some people.


Cart #sprimp-1 | 2024-03-18 | Embed ▽ | License: CC4-BY-NC-SA
21

tada! now you can import pico8 spritesheets. and map too!

importing a .p8 file

  • put your game.p8 file somewhere inside picotron's file system
    • the filename should not have any dashes ("-"), they generally cause problems currently (picotron 0.1.0b2)
  • run this importer (sprimp)
  • import the p8 cart
    • you can drag-and-drop the cart onto the sprimp window
    • or you can use "Import .p8 file" in the menu (the dialog that pops up says "save as" -- please ignore this. this is the best way I know how to launch a system filepicker)

exporting sprites

  • press "Save gfx..". choose a filename; the default is /ram/cart/gfx/0.gfx (which is the default spritesheet for your current cart)
  • IMPORTANT: if the spritesheet was already open in picotron's gfx editor, you'll need to close the file and reopen it (right click on the tab, close, then press the plus)
  • if you saved to /ram/cart/... save your cart afterwards (ctrl-s)

exporting map

  • (same as exporting sprites, just click "Save map.." instead)
  • for an easy transition from pico8 maps to picotron maps, check out this snippet, which includes mget and mset replacements

other ways to import (copypaste, aseprite)

importing sprite by copy-paste

  • open the pico8 sprite editor
  • copy the entire spritesheet (press tab, ctrl-a, ctrl-c)
  • your clipboard now has a [gfx]... code in it
  • open this tool (sprimp) in picotron
  • past the [gfx]... code into the tool

importing a single sprite

  • you can copy from pico8 and paste into picotron directly, zep made that work already
  • you can even paste your entire spritesheet into a single picotron sprite -- it's sorta wild. but you probably wanted to spread the spritesheet out into individual sprites, right? that's where this tool can help

importing from aseprite

you can use my exporter script for aseprite to export aseprite images into the [gfx]... format, letting you paste them into picotron or sprimp (or even pico8!)

future plans

  • Yes: Make importing sprites/maps easy. (mostly done! still some UI/UX work tho)
  • Done but not yet published: importing p8 code tabs into .lua files. with a big disclaimer that you'll need to do a bunch of manual work to fix the code afterward
  • Maybe: sfx/music. I likely won't do this myself. If you have a working sfx/music importer and want to join forces, let me know!
  • No: make it possible to drag-and-drop a pico8 cart into picotron and have everything "just work". this is not meant to be a perfect emulator, just a stepping stone

maybe zep will add improvements to picotron itself, and this whole project will no longer be relevant. that would be great! but whether or not that happens, this was a fun small project for me to learn some basics of picotron tool-making

changelog

v0.2

  • add .p8 import -- thank you @Krystman for the idea!
  • add drag-and-drop support
  • add map import/export

v0.1

  • sprite import/export
P#143506 2024-03-17 13:58 ( Edited 2024-03-27 03:52)

1

hope, there's an update plan to implement import from .png spritesheet or something like that as a terminal command (like it was on pico-8)

You did good work there! :)

P#143523 2024-03-17 15:32
1

Sick!

P#143528 2024-03-17 15:54
1

Thank you very much this is very useful for me!

P#143531 2024-03-17 16:14
1

very useful, thank you!
Is it possible to import maps from pico-8? Not with this tool, but with some copy and paste? In pico-8 sprite editor we can copy data and paste it elsewhere, but it looks for the map editor you can copy, but it's only internally to pico-8, you can't paste it elsewhere.

P#143557 2024-03-17 18:55
2

We looked at this cart today on the stream. Based on the userdata trick we created a function to extract the GFX data directly from a P8 file
https://www.twitch.tv/videos/2093783120

-- load the file
local myFile = fetch("myfile.p8")

-- find the and extract gfx section
local gfxstart, gfxend = string.find(myFile, "__gfx__")
local mapstart, mapend = string.find(myFile, "__map__")
local gfx = myFile:sub(gfxend+2, mapstart-2)

-- remove the linebreaks
gfx = string.gsub(gfx, "\n", "")

-- convert into userdata
local myspritesheet = userdata("[".."gfx]8080"..gfx.."[/gfx]")

-- check if it worked
if not myspritesheet then
  notify(string.format("* error: No valid gfx data"))
  return
end

-- this is how you draw it
spr(myspritesheet,0,0)

(had to add a superfluous .. in the userdata line so the BBS would't try to draw the GFX)

This also might not quite work right if you don't have a map. But it could be a good starting point for a more general Pico-8 importer

P#143596 2024-03-17 23:48 ( Edited 2024-03-17 23:49)
1

@farvardin I've added map importing!

@Krystman -- ooh that's a great idea!! I've incorporated it into the main cart

P#143654 2024-03-18 07:38

nice !
I noticed that picotron's spr function doesn't work well with your importer when you draw large sprites, like 2x2
I havent tested your map importer yet, but I also had the issue that standard picotron map draw 16x16 sprites even if the gfx has an 8x8 grid, so it doesn't work well either
so here is a little snippet I made to replace function spr and map so they work like pico 8, you just drop that at the start of your picotron lua file
map doesn't handle flag layers yet, but it should be possible to add
I'm sure at some point someone will make a lua file you can include so your pico 8 game more or less works instantly, like importing the .p8 as gfx and map as Krystman showed, and even the lua code, that will be so great!

_old_spr=spr
function spr(_s,_x,_y,_w,_h,_mx,_my)
    _w=_w or 1
    _h=_h or 1
    for i=0,_w-1 do
        local _i=_mx and _w-i-1 or i
        for j=0,_h-1 do
            local _j=_my and _h-j-1 or j
            --_old_spr(_s+_i+_j*16,_x+i*8,_y+j*8,1,1,_mx,_my)
            _old_spr(_s+_i+_j*16,_x+i*8,_y+j*8,_mx,_my)
        end
    end
end

local _map_data=fetch("map/0.map")
function mget(x,y)
    if not _map_data or not _map_data[1] then return 0 end
    return _map_data[1].bmp:get(x,y)
end

_old_map=map
function map(_cx,_cy,_x,_y,_w,_h,...)
    for i=0,_w-1 do
        for j=0,_h-1 do
            local id=mget(_cx+i,_cy+j)
            if id!=0 then
                spr(id,_x+i*8,_y+j*8)
            end
        end
    end
end
P#143658 2024-03-18 08:26

[Please log in to post a comment]