Skip to content

Commit

Permalink
Improve parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekkio committed Dec 7, 2024
1 parent cbcbd9e commit 8a3753a
Show file tree
Hide file tree
Showing 21 changed files with 512 additions and 550 deletions.
2 changes: 1 addition & 1 deletion data/consoles/DMG/G01440218/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-01",
"u1": {
"label": "DMG-CPU A 8919 D"
"label": "DMG-CPU A © 1989 Nintendo JAPAN 8919 D"
}
}
}
2 changes: 1 addition & 1 deletion data/consoles/DMG/G03314395/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-02",
"u1": {
"label": "DMG-CPU A 8947 WA"
"label": "DMG-CPU A © 1989 Nintendo JAPAN 8947 WA"
}
}
}
2 changes: 1 addition & 1 deletion data/consoles/DMG/G09209621/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-04",
"u1": {
"label": "DMG-CPU B 9029 W"
"label": "DMG-CPU B © 1989 Nintendo JAPAN 9029 W"
}
}
}
2 changes: 1 addition & 1 deletion data/consoles/DMG/G37311091/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-06",
"u1": {
"label": "DMG-CPU B 9413 W"
"label": "DMG-CPU B © 1989 Nintendo JAPAN 9413 W"
}
}
}
2 changes: 1 addition & 1 deletion data/consoles/DMG/GH1339945/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-06",
"u1": {
"label": "DMG-CPU B 9404 D"
"label": "DMG-CPU B © 1989 Nintendo JAPAN 9404 D"
}
}
}
2 changes: 1 addition & 1 deletion data/consoles/DMG/GH3594311/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"mainboard": {
"label": "DMG-CPU-06",
"u1": {
"label": "DMG-CPU B 9440 W"
"label": "DMG-CPU B © 1989 Nintendo JAPAN 9440 W"
}
}
}
9 changes: 4 additions & 5 deletions model/src/config/cartridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use std::{
use crate::{
hash::{Crc32, Md5, Sha1, Sha256},
parser::{
accelerometer::accelerometer,
agb_mask_rom_tsop_ii_44_3v3,
agb_mask_rom_tsop_ii_44_3v3, analog,
crystal_32kihz::crystal_32kihz,
eeprom::{eeprom_sop_8_3v3, eeprom_tssop_8_5v},
flash_tsop_i_32_3v3, flash_tsop_i_40_5v, fram_sop_28_3v3, gb_mask_rom_glop_top_28_5v,
Expand Down Expand Up @@ -216,7 +215,7 @@ impl BoardConfig {
D::U2 => Some(BoardPart::Rom(agb_mask_rom_tsop_ii_44_3v3())),
// SOP-8 EEPROM
D::U3 => Some(BoardPart::Eeprom(eeprom_sop_8_3v3())),
D::U4 => Some(BoardPart::Accelerometer(accelerometer())),
D::U4 => Some(BoardPart::Accelerometer(&analog::ANALOG_ADXL202JE)),
_ => None,
},
BoardConfig::AgbE18 => match designator {
Expand Down Expand Up @@ -393,7 +392,7 @@ impl BoardConfig {
// TSSOP-8 EEPROM
D::U3 => Some(BoardPart::Eeprom(eeprom_tssop_8_5v())),
// QC-14 accelerometer
D::U4 => Some(BoardPart::Accelerometer(accelerometer())),
D::U4 => Some(BoardPart::Accelerometer(&analog::ANALOG_ADXL202JQC)),
_ => None,
},
BoardConfig::DmgA47 => match designator {
Expand All @@ -404,7 +403,7 @@ impl BoardConfig {
// TSSOP-8 EEPROM
D::U3 => Some(BoardPart::Eeprom(eeprom_tssop_8_5v())),
// QC-14 accelerometer
D::U4 => Some(BoardPart::Accelerometer(accelerometer())),
D::U4 => Some(BoardPart::Accelerometer(&analog::ANALOG_ADXL202JQC)),
_ => None,
},
BoardConfig::DmgAaa => match designator {
Expand Down
67 changes: 56 additions & 11 deletions model/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,22 @@ use crate::{
};

pub use self::{
accelerometer::Accelerometer,
ags_charge_ctrl::AgsChargeController,
cgb_stamp::CgbStamp,
coil::Coil,
dmg_stamp::DmgStamp,
eeprom::Eeprom,
gen1_soc::{Gen1Soc, Gen1SocKind},
gen2_soc::{Gen2Soc, Gen2SocKind},
lcd_chip::LcdChip,
lcd_screen::LcdScreen,
mapper::{Huc1Version, Mapper, MapperType, Mbc1Version, Mbc2Version, Mbc3Version},
};

pub mod accelerometer;
pub mod agb_soc_bga;
pub mod agb_soc_qfp_128;
pub mod agb_soc_qfp_156;
pub mod ags_charge_ctrl;
pub mod amic;
pub mod analog;
pub mod atmel;
pub mod bsi;
pub mod cgb_soc;
pub mod cgb_stamp;
pub mod cic;
pub mod coil;
pub mod crystal_20mihz;
pub mod crystal_32kihz;
Expand All @@ -46,8 +38,6 @@ pub mod crystal_8mihz;
pub mod dmg_stamp;
pub mod eeprom;
pub mod fujitsu;
pub mod gen1_soc;
pub mod gen2_soc;
pub mod hynix;
pub mod hyundai;
pub mod lcd_chip;
Expand Down Expand Up @@ -445,6 +435,17 @@ mod for_nom {
) -> impl Parser<&'a str, (O1, O2, O3, O4), E> {
tuple((a, line_sep, b, line_sep, c, line_sep, d)).map(|(a, _, b, _, c, _, d)| (a, b, c, d))
}

pub fn lines5<'a, O1, O2, O3, O4, O5, E: ParseError<&'a str>>(
a: impl Parser<&'a str, O1, E>,
b: impl Parser<&'a str, O2, E>,
c: impl Parser<&'a str, O3, E>,
d: impl Parser<&'a str, O4, E>,
e: impl Parser<&'a str, O5, E>,
) -> impl Parser<&'a str, (O1, O2, O3, O4, O5), E> {
tuple((a, line_sep, b, line_sep, c, line_sep, d, line_sep, e))
.map(|(a, _, b, _, c, _, d, _, e)| (a, b, c, d, e))
}
}

pub fn year2(text: &str) -> Result<Year, String> {
Expand Down Expand Up @@ -664,6 +665,10 @@ pub fn gbs_dol() -> &'static impl LabelParser<GenericPart> {
&nec::NEC_GBS_DOL
}

pub fn cic() -> &'static impl LabelParser<GenericPart> {
multi_parser!(GenericPart, &sharp::SHARP_F411, &sharp::SHARP_F413,)
}

pub fn icd2() -> &'static impl LabelParser<GenericPart> {
multi_parser!(
GenericPart,
Expand All @@ -673,6 +678,46 @@ pub fn icd2() -> &'static impl LabelParser<GenericPart> {
)
}

pub fn dmg_soc_qfp_80() -> &'static impl LabelParser<GenericPart> {
multi_parser!(GenericPart, &sharp::SHARP_LR35902, &sharp::SHARP_DMG_CPU)
}

pub fn dmg_soc_glop_top() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_DMG_CPU_GLOP_TOP
}

pub fn sgb_soc_qfp_80() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_SGB_CPU
}

pub fn mgb_soc_qfp_80() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_MGB
}

pub fn sgb2_soc_qfp_80() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_SGB2
}

pub fn cgb_soc_qfp_128_old() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_CGB
}

pub fn cgb_soc_qfp_128_new() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_CGB_E
}

pub fn agb_soc_qfp_128() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_AGB
}

pub fn agb_soc_qfp_156() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_AGB_B
}

pub fn agb_soc_bga() -> &'static impl LabelParser<GenericPart> {
&sharp::SHARP_CPU_AGB_E
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum GameRomType {
GlopTop, // 256 Kibit / 32 KiBit, gloptop
Expand Down
64 changes: 0 additions & 64 deletions model/src/parser/accelerometer.rs

This file was deleted.

27 changes: 0 additions & 27 deletions model/src/parser/agb_soc_bga.rs

This file was deleted.

27 changes: 0 additions & 27 deletions model/src/parser/agb_soc_qfp_128.rs

This file was deleted.

30 changes: 0 additions & 30 deletions model/src/parser/agb_soc_qfp_156.rs

This file was deleted.

Loading

0 comments on commit 8a3753a

Please sign in to comment.