patterns: More accurate variable declarations on nes.hexpat, add n64, gen, and gbx.hexpat (#477)

* Add n64, gen, and gbx.hexpat

* Add n64, gbx, and gen.hexpat to README.md

* Remove leftover string import from n64.hexpat

* More accurate variable declarations on nes.hexpat

* Add source to gbx.hexpat

* Add accidentally missing curly brace in nes.hexpat
This commit is contained in:
gmestanley
2026-01-11 14:59:37 -03:00
committed by GitHub
parent 097ab49cae
commit fb84bbb5d1
5 changed files with 288 additions and 21 deletions

61
patterns/gbx.hexpat Normal file
View File

@@ -0,0 +1,61 @@
#pragma author gmestanley
#pragma description GameBoy ROM file GBX footer
#pragma source hhug.me/gbx/1.0
import gb;
bitfield SachenMMC2SolderPad {
padding : 5;
opt1 : 1;
openBus512KiBOuterBanks : 1;
openBus1MiBOuterBanks : 1;
};
bitfield VastFameRunningValueType {
TaiwanReleases : 1;
MainlandChinaReleases : 1;
};
enum VastFamePCBType : u8 {
DSHGGB81,
BCR1616T3P
};
fn specialMapper(str value) { return value == "SAM2" || value == "VF01" || value == "GB81"; };
struct MapperVariables {
match(parent.mapper) {
("SAM2"): SachenMMC2SolderPad solderPadConfig;
("VF01"): VastFameRunningValueType runningValue;
("GB81"): VastFamePCBType pcb; }
padding[3*specialMapper(parent.mapper)];
u32 mapperVariables[8-specialMapper(parent.mapper)];
};
struct CartridgeInformation {
char mapper[4];
bool battery;
bool rumble;
bool timer;
padding[1];
u32 romSize;
u32 ramSize;
if (specialMapper(mapper))
MapperVariables mapperVariables;
else
MapperVariables mapperVariables [[inline]];
};
struct GBXMetadata {
u32 footerSize;
u32 majorVersion;
u32 minorVersion;
char signature[4];
};
struct GBXFooter {
CartridgeInformation cartInfo;
GBXMetadata metadata;
};
be GBXFooter gbxFooter @ std::mem::size() - 0x40;