From e6766d6d00ced02ed02cc0b371503b2c81eab0f3 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Mon, 15 Jul 2024 19:57:53 -0400 Subject: [PATCH] Updated readme --- README.md | 23 +++++++++++++++++++++++ helpers/makecart.lua | 11 ++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cb17bde..eb10bbf 100644 --- a/README.md +++ b/README.md @@ -146,3 +146,26 @@ ardugotools flashcart generate helpers/applysaves.lua myflashcart.bin newflashca ``` Then you can flash `outflashcart.bin` to your Arduboy. + +#### Make Cart from folder + +If you don't want to write a script yourself to create a custom flashcart, you can instead +set up a folder with all the categories and games and use `helpers/makecart.lua` to generate +it for you. The folder must be setup in a certain way; see the comments in +[makecart.lua](helpers/makecart.lua) to get started. In general, you simply setup a folder +where: +- Each folder inside is a category +- Each `.arduboy` package within the category folders are games in that category +- You need a `title.png` at the root of the folder for the "bootloader" image +- You need a `title.png` at the root of each category for the category image +- Each package must have some image inside it to use as a title image. If it's missing + or if you want to override it, simply place a png file with the same name as the package + in the category directory next to the package. + +The arguments to pass in are the folder to read from, the devices to choose inside the +packages, and the path to save the flashcart binary to. An optional fourth parameter lets +you indicate ignored folders by name, comma separated. Example: + +``` +ardugotools flashcart generate helpers/makecart mycart "Arduboy,ArduboyFX" flashcart.bin "ignore,trash" +``` diff --git a/helpers/makecart.lua b/helpers/makecart.lua index 69a9b34..14198f7 100644 --- a/helpers/makecart.lua +++ b/helpers/makecart.lua @@ -105,11 +105,12 @@ for _, catinfo in ipairs(maindirlist) do elseif string.sub(catfile.name, -8) == ".arduboy" then -- This is a normal arduboy package slot = packageany(catfile.path, devices) - if slot.image == nil then - -- Try to find an image with the same name as the package. - testimage = string.sub(catfile.name, 0, -8) .. "png" - log("Looking for alternate image in " .. testimage) - slot.image = load_title(catlist, testimage) + -- Try to find an image with the same name as the package. + local testimage = string.sub(catfile.name, 0, -8) .. "png" + local image = load_title(catlist, testimage) + if image ~= nil then + slot.image = image + log("Loaded alternate image in " .. testimage) end add_slot(slot) elseif catfile.name ~= "title.png" then