Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite RGBFIX in Rust #2

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1547a30
wip: initial commit of work so far
Oneirical Mar 1, 2024
ceedd0f
refactor: derive cli + add evie's logo macro
Oneirical Mar 2, 2024
3e266b4
add more byte overwrites and remove UNSPECIFIED
Oneirical Mar 2, 2024
df70a3c
fix: many compile issues
Oneirical Mar 2, 2024
cc97c12
fix: bitwise operations on MbcType
Oneirical Mar 2, 2024
73b60d6
fix: some borrow checker issues
Oneirical Mar 2, 2024
6fe7d78
refactor: replace bitwise ops with match statement
Oneirical Mar 4, 2024
4211147
finish writing the file writing operations
Oneirical Mar 4, 2024
14f341e
add process_filename and write_bytes
Oneirical Mar 4, 2024
b43b25a
fix: some type casting
Oneirical Mar 4, 2024
4373afa
make it compile (not runtime tested)
Oneirical Mar 7, 2024
28624f7
fill in remaining flags
Oneirical Mar 7, 2024
47e905a
fix: make clap accept hexadecimals
Oneirical Mar 8, 2024
426d86c
fix: some overflowing subs and adds
Oneirical Mar 9, 2024
6398734
fix: stop casting u8s as u16 for no reason
Oneirical Mar 9, 2024
b94b1ea
implement "low-hanging fruit" review comments
Oneirical Mar 9, 2024
86d03a6
review: refactor MbcType into Option
Oneirical Mar 11, 2024
691a998
add more Err returns and remove useless casting
Oneirical Mar 11, 2024
2ba084c
document clap attributes with /// comments
Oneirical Mar 11, 2024
f59aca6
feat: refactor FixSpec away from vector type
Oneirical Mar 13, 2024
ff08605
Merge master
eievui5 Mar 16, 2024
aab3732
Remove duplicate loop and restore true ||
Oneirical Mar 17, 2024
b95f42e
Merge pull request #1 from eievui5/master
Oneirical Mar 17, 2024
2a00a10
Remove rgbfix's CliOptions
eievui5 Mar 20, 2024
d680806
Improve error handling
eievui5 Mar 22, 2024
7acd76c
Remove time from log messages
eievui5 Mar 22, 2024
252b521
Merge pull request #2 from eievui5/master
Oneirical Mar 22, 2024
fd7e107
feat: also support mbc string name values
Oneirical Mar 23, 2024
dd3f5cb
uniformize the macro definition to return results
Oneirical Mar 23, 2024
ab717af
fix: unreachable patterns in mbc match
Oneirical Mar 23, 2024
40aaca0
some review fixes
Oneirical Apr 17, 2024
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
Prev Previous commit
Next Next commit
document clap attributes with /// comments
  • Loading branch information
Oneirical committed Mar 11, 2024
commit 2ba084c9572b4b51b562617387b27ae5c0712f8d
56 changes: 37 additions & 19 deletions src/fix/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,61 +29,79 @@ pub struct CliOptions {
}

#[derive(Parser, Debug)]
#[clap(version = "1.0", help = "A tool to fix ROM files for Game Boy.")]
#[clap(version = "1.0", about = "A tool to fix ROM files for Game Boy.")]
struct Cli {
#[clap(short = 'C', long = "color-only", help = "Color-only mode")]
#[clap(short = 'C', long = "color-only")]
/// Color-only mode
color_only: bool,

#[clap(short = 'c', long = "color-compatible", help = "Color-compatible mode")]
#[clap(short = 'c', long = "color-compatible")]
/// Color-compatible mode
color_compatible: bool,

#[clap(short = 'f', long = "fix-spec", help = "Specify a fix specification", value_name = "FIX_SPEC")]
#[clap(short = 'f', long = "fix-spec", value_name = "FIX_SPEC")]
/// Specify a fix specification
fix_spec: Option<String>,

#[clap(short = 'i', long = "game-id", help = "Specify a game ID", value_name = "GAME_ID")]
#[clap(short = 'i', long = "game-id", value_name = "GAME_ID")]
/// Specify a game ID
game_id: Option<String>,

#[clap(short = 'j', long = "non-japanese", help = "Non-Japanese mode")]
#[clap(short = 'j', long = "non-japanese")]
/// Non-Japanese mode
non_japanese: bool,

#[clap(short = 'k', long = "new-licensee", help = "Specify a new licensee", value_name = "NEW_LICENSEE")]
#[clap(short = 'k', long = "new-licensee", value_name = "NEW_LICENSEE")]
/// Specify a new licensee
new_licensee: Option<String>,

#[clap(short = 'l', long = "old-licensee", help = "Specify an old licensee", value_name = "OLD_LICENSEE", value_parser=maybe_hex::<u8>)]
#[clap(short = 'l', long = "old-licensee", value_name = "OLD_LICENSEE", value_parser=maybe_hex::<u8>)]
/// Specify an old licensee
old_licensee: Option<u8>,

#[clap(short = 'm', long = "mbc-type", help = "Specify the MBC type", value_name = "MBC_TYPE")]
mbc_type: Option<String>, //TOCHECK: is parsing the string required or does clap do it for me?
#[clap(short = 'm', long = "mbc-type", value_name = "MBC_TYPE")]
/// Specify the MBC type
mbc_type: Option<String>,

#[clap(short = 'n', long = "rom-version", help = "Specify the ROM version", value_name = "ROM_VERSION", value_parser=maybe_hex::<u8>)]
#[clap(short = 'n', long = "rom-version", value_name = "ROM_VERSION", value_parser=maybe_hex::<u8>)]
/// Specify the ROM version
rom_version: Option<u8>,

#[clap(short = 'O', long = "overwrite", help = "Overwrite the file")]
#[clap(short = 'O', long = "overwrite")]
/// Overwrite the file
overwrite: bool,

#[clap(short = 'p', long = "pad-value", help = "Specify the padding value", value_name = "PAD_VALUE", value_parser=maybe_hex::<u8>)]
#[clap(short = 'p', long = "pad-value", value_name = "PAD_VALUE", value_parser=maybe_hex::<u8>)]
/// Specify the padding value
pad_value: Option<u8>,

#[clap(short = 'r', long = "ram-size", help = "Specify the RAM size", value_name = "RAM_SIZE", value_parser=maybe_hex::<u8>)]
#[clap(short = 'r', long = "ram-size", value_name = "RAM_SIZE", value_parser=maybe_hex::<u8>)]
/// Specify the RAM size
ram_size: Option<u8>,

#[clap(short = 's', long = "sgb-compatible", help = "SGB-compatible mode")]
#[clap(short = 's', long = "sgb-compatible")]
/// SGB-compatible mode
sgb_compatible: bool,

#[clap(short = 't', long = "title", help = "Specify the title", value_name = "TITLE")]
#[clap(short = 't', long = "title", value_name = "TITLE")]
/// Specify the title
title: Option<String>,

#[clap(short = 'V', long = "version", help = "Print RGBFIX version and exit")]
#[clap(short = 'V', long = "version")]
/// Print RGBFIX version and exit
version: bool,

#[clap(short = 'v', long = "validate", help = "Fix the header logo and both checksums (-f lhg)")]
#[clap(short = 'v', long = "validate")]
/// Fix the header logo and both checksums (-f lhg)
validate: bool,

#[clap(help = "Files to process")]
#[clap(value_name = "FILES")]
/// Files to process
files: Vec<String>,
}



#[derive(Debug, Clone, PartialEq)]
enum FixSpec {
FixLogo,
Expand Down