From a3c4a44893ee5cc895526bef1f4bbd6e77bde109 Mon Sep 17 00:00:00 2001 From: Lesserkuma Date: Wed, 1 Nov 2023 17:19:55 +0100 Subject: [PATCH] 0.7 --- README.md | 5 ++++- rom_builder/rom_builder.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a556560..e3449c1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ The following section must be edited in order to specify the cartridge type to u ```json "cartridge": { "type": 2, - "battery_present": false + "battery_present": false, + "min_rom_size": 4194304 }, ``` Set `type` to `1` or `2`: @@ -24,6 +25,8 @@ Set `type` to `1` or `2`: Set `battery_present` to `true` or `false`. This will enable enhanced save data handling which will only be functional with a working battery. +Set `min_rom_size` to whatever your cartridge supports as the smallest possible ROM size. Many newer cartridges only support ROMs no smaller than 4 MiB (`4194304`) while some older cartridges can go as low as 512 KiB (`524288`). + In the `games` section, you can edit the game-related stuff: ```json "games": [ diff --git a/rom_builder/rom_builder.py b/rom_builder/rom_builder.py index a43b7b9..3774b8a 100644 --- a/rom_builder/rom_builder.py +++ b/rom_builder/rom_builder.py @@ -5,7 +5,7 @@ import sys, os, glob, json, math, re, struct, hashlib, argparse, datetime # Configuration -app_version = "0.6" +app_version = "0.7" default_file = "LK_MULTIMENU_.gba" ################################ @@ -83,6 +83,7 @@ if not os.path.exists(args.config): games = [] cartridge_type = 1 battery_present = False + min_rom_size = 0x400000 for file in files: d = { "enabled": True, @@ -102,6 +103,7 @@ if not os.path.exists(args.config): "cartridge": { "type": cartridge_type + 1, "battery_present": battery_present, + "min_rom_size": min_rom_size, }, "games": games, } @@ -124,6 +126,10 @@ else: games = j["games"] cartridge_type = j["cartridge"]["type"] - 1 battery_present = j["cartridge"]["battery_present"] + if "min_rom_size" in j["cartridge"]: + min_rom_size = j["cartridge"]["min_rom_size"] + else: + min_rom_size = 0x400000 # Prepare compilation flash_size = cartridge_types[cartridge_type]["flash_size"] @@ -176,7 +182,9 @@ for game in games: with open(f"roms/{game['file']}", "rb") as f: buffer = f.read() if b"Batteryless mod by Lesserkuma" in buffer: - size = 0x400000 + size = max(0x400000, min_rom_size) + else: + size = max(size, min_rom_size) game["index"] = index game["size"] = size if "title_font" in game: