From 2ca373182ee42830320a1da257eeb86d98a1ac50 Mon Sep 17 00:00:00 2001 From: gram Date: Thu, 1 Jan 2026 21:41:02 +0100 Subject: [PATCH] Bulb Script support --- assets/main.bulb | 98 +++++++++++++++++++++++++++++++++++++++++++++ src/commands/new.rs | 29 +++++++++++--- src/config.rs | 15 +++---- src/langs.rs | 10 +++++ 4 files changed, 139 insertions(+), 13 deletions(-) create mode 100644 assets/main.bulb diff --git a/assets/main.bulb b/assets/main.bulb new file mode 100644 index 0000000..63dbf81 --- /dev/null +++ b/assets/main.bulb @@ -0,0 +1,98 @@ +R start +🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🚩 ⚪️ ⚪️ ⚪️ 🐈 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🔑 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ ⚪️ 🧱 +🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 🧱 + + +T ⚪️ +IMAGE bg + +T 🧱 +IMAGE wall +WALL 1 + +T 🚩 +IMAGE bg +START 1 + +T 🐈 +IMAGE cat +WALL 1 +A +SAY Cat: I'm a cat. +SAY Yes, I can talk. + +T 🔑 +IMAGE key +A +SAY You found a key! +ADD key 1 +PLACE ⚪️ + + +P idle +. . . F F . . . +. . . F F . . . +. . . F F . . . +. . F F F F . . +. F F F F F F . +F . F F F F . F +. . F . . F . . +. . F . . F . . + +I bg +. . . . . . . . +. . . . . . . . +. . . . . . . . +. . . . . . . . +. . . . . . . . +. . . . . . . . +. . . . . . . . +. . . . . . . . + +I wall +D D D D D D D D +D . . . . . . D +D . D D D D . D +D . D . . D . D +D . D . . D . D +D . D D D D . D +D . . . . . . D +D D D D D D D D + +I cat +. . . . . . . . +. . . . . . . . +. 4 . 4 . . . 4 +. 4 4 4 . . . 4 +. 4 4 4 . . 4 . +. 4 4 4 4 4 . . +. . 4 4 4 4 . . +. . 4 . . 4 . . + +I key +. . . . . . . . +. . 2 2 2 2 . . +. . 2 . . 2 . . +. . 2 2 2 2 . . +. . . 2 . . . . +. . . 2 2 . . . +. . . 2 . . . . +. . . 2 2 . . . diff --git a/src/commands/new.rs b/src/commands/new.rs index 82db077..8551de8 100644 --- a/src/commands/new.rs +++ b/src/commands/new.rs @@ -32,6 +32,7 @@ pub fn cmd_new(args: &NewArgs) -> Result<()> { Lang::Lua => new_lua(&args.name).context("new Lua project")?, Lang::Moon => new_moon(&args.name).context("new Moon project")?, Lang::Bitsy => new_bitsy(&args.name).context("new Bitsy project")?, + Lang::Bulb => new_bulb(&args.name).context("new Bulb project")?, } write_config(lang, &args.name)?; init_git(&args.name)?; @@ -54,21 +55,28 @@ fn write_config(lang: Lang, name: &str) -> Result<()> { _ = writeln!(config, "app_name = \"{}\"", to_titlecase(name)); _ = writeln!(config, "lang = \"{}\"", lang.name()); + let is_script = matches!(lang, Lang::Lua | Lang::Bitsy | Lang::Bulb); + if is_script { + _ = writeln!(config, "\n[files]"); + } match lang { Lang::Lua => { - _ = writeln!(config, "\n[files]"); _ = writeln!(config, r#"main = {{ path = "main.lua", copy = true }}"#); } + Lang::Bulb => { + _ = writeln!(config, r#"main = {{ path = "main.bulb", copy = true }}"#); + } Lang::Bitsy => { - _ = writeln!(config, "\n[files]"); _ = writeln!(config, r#"main = {{ path = "main.bitsy", copy = true }}"#); - _ = writeln!( - config, - r#"font = {{ path = "eg_6x9.fff", url = "https://fonts.fireflyzero.com/fonts/ascii/eg_6x9.fff" }}"# - ); } _ => {} } + if is_script { + _ = writeln!( + config, + r#"font = {{ path = "eg_6x9.fff", url = "https://fonts.fireflyzero.com/fonts/ascii/eg_6x9.fff" }}"# + ); + } std::fs::write(config_path, config).context("write config")?; Ok(()) @@ -100,6 +108,7 @@ fn parse_lang(lang: &str) -> Result { "moon" | "moonbit" | "mbt" => Lang::Moon, "lua" => Lang::Lua, "bitsy" => Lang::Bitsy, + "bulb" | "bulbscript" | "bulb-script" => Lang::Bulb, _ => bail!("unsupported language: {lang}"), }; Ok(result) @@ -184,6 +193,14 @@ fn new_bitsy(name: &str) -> Result<()> { Ok(()) } +/// Create a new Bulb project. +fn new_bulb(name: &str) -> Result<()> { + let mut c = Commander::default(); + c.cd(name)?; + c.copy_asset(&["main.bulb"], "main.bulb")?; + Ok(()) +} + /// Create a new Moon project. fn new_moon(name: &str) -> Result<()> { check_installed("Moon", "moon", "version")?; diff --git a/src/config.rs b/src/config.rs index ae61b68..a2af0a3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -182,17 +182,18 @@ pub struct BoardConfig { #[derive(Deserialize, Debug, Copy, Clone)] #[serde(rename_all = "lowercase")] pub enum Lang { - Go, // 🏃 - Rust, // 🦀 - Zig, // ⚡️ AS, // 🟦 - TS, // 🟦 + Bitsy, // 🐈‍⬛ + Bulb, // 💡 C, // 🐀 Cpp, // 🐀 - Python, // 🐍 - Moon, // 🐰 + Go, // 🏃 Lua, // 🌙 - Bitsy, // 🐈‍⬛ + Moon, // 🐰 + Python, // 🐍 + Rust, // 🦀 + TS, // 🟦 + Zig, // ⚡️ } impl Lang { diff --git a/src/langs.rs b/src/langs.rs index ee01744..47bbfbf 100644 --- a/src/langs.rs +++ b/src/langs.rs @@ -31,6 +31,7 @@ pub fn build_bin(config: &Config, args: &BuildArgs) -> anyhow::Result<()> { Lang::Python => build_python(config), Lang::Lua => build_lua(config), Lang::Bitsy => build_bitsy(config), + Lang::Bulb => build_bulb(config), Lang::Moon => build_moon(config), }?; let bin_path = config.rom_path.join(BIN); @@ -101,6 +102,9 @@ fn detect_lang(root: &Path) -> anyhow::Result { if root.join("main.bitsy.txt").exists() { return Ok(Lang::Bitsy); } + if root.join("main.bulb").exists() { + return Ok(Lang::Bulb); + } if root.join("src").join("main.c").exists() { return Ok(Lang::C); } @@ -403,6 +407,12 @@ fn build_bitsy(config: &Config) -> anyhow::Result<()> { build_interpreted(config, url) } +// Build Bulb Script project. +fn build_bulb(config: &Config) -> anyhow::Result<()> { + let url = "https://github.com/firefly-zero/firefly-bulb/releases/latest/download/main.wasm"; + build_interpreted(config, url) +} + fn build_interpreted(config: &Config, url: &str) -> anyhow::Result<()> { let from_path = config.root_path.join("main.wasm"); if !from_path.is_file() {