Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions assets/main.bulb
Original file line number Diff line number Diff line change
@@ -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 . . .
29 changes: 23 additions & 6 deletions src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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(())
Expand Down Expand Up @@ -100,6 +108,7 @@ fn parse_lang(lang: &str) -> Result<Lang> {
"moon" | "moonbit" | "mbt" => Lang::Moon,
"lua" => Lang::Lua,
"bitsy" => Lang::Bitsy,
"bulb" | "bulbscript" | "bulb-script" => Lang::Bulb,
_ => bail!("unsupported language: {lang}"),
};
Ok(result)
Expand Down Expand Up @@ -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")?;
Expand Down
15 changes: 8 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions src/langs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -101,6 +102,9 @@ fn detect_lang(root: &Path) -> anyhow::Result<Lang> {
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);
}
Expand Down Expand Up @@ -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() {
Expand Down