Skip to content

Improve .ron export#83

Merged
bates64 merged 5 commits intobates64:mainfrom
Darxoon:main
Dec 29, 2025
Merged

Improve .ron export#83
bates64 merged 5 commits intobates64:mainfrom
Darxoon:main

Conversation

@Darxoon
Copy link
Copy Markdown
Contributor

@Darxoon Darxoon commented Dec 27, 2025

This PR significantly improves the readabililty and editability of mamar's ron files

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 27, 2025

@Darxoon is attempting to deploy a commit to the Alex Bates' projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
mamar Error Error Dec 28, 2025 10:39am

Copy link
Copy Markdown
Owner

@bates64 bates64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool idea, I like the user-facing results but I can't accept it as-is.

If you can repeat your changes to the canonical Bgm, and modify the frontend to work with it, I'd accept it. From what I can tell, the main changes are:

  • snake_case fields (ideally do this with serde aliases, rather than renaming the fields)
  • enum Polyphony
  • Option for parent_track_idx (which is in fact related to Polyphony - see the UI - so should maybe be included in a Polyphony struct alongside a VoiceCount enum?)

Comment thread mamar-wasm-bridge/src/lib.rs Outdated
#[wasm_bindgen]
pub fn ron_encode(bgm: &JsValue) -> JsValue {
let bgm: Bgm = from_js(bgm);
let bgm = bgm_ron::Bgm::from(bgm);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want this line anyway, but it would be better written (imo) as let bgm: bgm_rom::Bgm = bgm.into();

Comment thread pm64/src/bgm/bgm_ron.rs Outdated
@@ -0,0 +1,655 @@
use std::{collections::HashMap, mem::MaybeUninit};
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't accept a near identical copy of bgm.rs as I'd need to maintain both forever. It also makes it hard to see what you've changed unless I diff the two files.

Copy link
Copy Markdown
Owner

@bates64 bates64 Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if I was OK with the file existing, there is a ton of boilerplate here e.g. trait impls that are identical for bgm_ron::Bgm and Bgm as input, would be better off making a trait for both if you wanted to do this

Comment thread pm64/src/bgm/bgm_ron.rs Outdated
pub is_disabled: bool,
pub polyphony: Polyphony,
pub is_drum_track: bool,
pub parent_track_idx: Option<u8>,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option is both more correct and cooler

Comment thread pm64/src/bgm/bgm_ron.rs Outdated
#[serde(default)]
pub name: String,
pub is_disabled: bool,
pub polyphony: Polyphony,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change, make it work in bgm.rs and update js and I'll gladly accept it

Comment thread pm64/src/bgm/bgm_ron.rs Outdated
6 => Self::Manual { voices: 3 },
7 => Self::Manual { voices: 4 },
POLYPHONIC_IDX_AUTO_MAMAR => Self::Automatic,
_ => Self::Other { priority: value },
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly unfortunate that the variants overlap eachother in u8 representation, but I guess that can't be helped

@bates64 bates64 changed the title Improve mamar's ron format Improve .ron export Dec 28, 2025
Comment thread pm64/src/bgm/midi.rs
track.polyphony = Polyphony::Manual { voices: 0 };
} else {
track.polyphonic_idx = 1;
track.polyphony = Polyphony::Manual { voices: 1 };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
track.polyphony = Polyphony::Manual { voices: 1 };
track.polyphony = Polyphony::Automatic;

Comment thread pm64/src/bgm/midi.rs
126 => {
if value == 0 {
track.polyphonic_idx = 0;
track.polyphony = Polyphony::Manual { voices: 0 };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
track.polyphony = Polyphony::Manual { voices: 0 };
track.polyphony = Polyphony::Manual { voices: 1 };

@bates64
Copy link
Copy Markdown
Owner

bates64 commented Dec 29, 2025

Dry_Dry_Desert_Oasis_17 fails to match, as it uses conditional takeover. I suspect the encoded 1 voice count is wrong. You can run the tests locally and vbindiff the output, see pm64/tests/readme.me.

bates64 added a commit that referenced this pull request Dec 29, 2025
@bates64 bates64 merged commit 929d436 into bates64:main Dec 29, 2025
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants