aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-07-08 21:10:46 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-07-08 21:10:46 +0200
commit34243afa568ffeb6433200062f0d3c9bc7c2c0ca (patch)
tree57eb452453eb33f30d6a019a4ad28b5f9b1e93e9 /lib
parentdcc6264d71e9a1ce58e56eebe5489e1ba16e2d4a (diff)
downloadtools.nes-34243afa568ffeb6433200062f0d3c9bc7c2c0ca.tar.gz
tools.nes-34243afa568ffeb6433200062f0d3c9bc7c2c0ca.zip
Add the SectionType::Vector enum value
It's actually valuable to distinguish that part of PRG-ROM that is part of the vectors segment. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/xixanta/src/cfg.rs6
-rw-r--r--lib/xixanta/src/mapping.rs11
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/xixanta/src/cfg.rs b/lib/xixanta/src/cfg.rs
index 52e075e..eacc5a4 100644
--- a/lib/xixanta/src/cfg.rs
+++ b/lib/xixanta/src/cfg.rs
@@ -269,6 +269,8 @@ pub fn parse_cfg_file(text: &str) -> Result<Vec<Mapping>, String> {
// realized it's CHR ROM.
if header {
header = false;
+ } else if start == 0xFFFA && size == 6 {
+ section_type = SectionType::Vector;
} else if start == 0x0000 {
section_type = SectionType::ChrRom;
} else if section_type != SectionType::ChrRom {
@@ -355,6 +357,8 @@ pub fn parse_nasm_cfg_file(text: &str) -> Result<Vec<Mapping>, String> {
// realized it's CHR ROM.
if header {
header = false;
+ } else if start == 0xFFFA && size == 6 {
+ section_type = SectionType::Vector;
} else if start == 0x0000 {
section_type = SectionType::ChrRom;
} else if section_type != SectionType::ChrRom {
@@ -485,7 +489,7 @@ FEATURES {
assert_eq!(romv.start, 0xFFFA);
assert_eq!(romv.size, 0x06);
assert_eq!(romv.fill, Some(0x00));
- assert_eq!(romv.section_type, SectionType::PrgRom);
+ assert_eq!(romv.section_type, SectionType::Vector);
assert_eq!(
romv.segments
.iter()
diff --git a/lib/xixanta/src/mapping.rs b/lib/xixanta/src/mapping.rs
index 2270ad3..fe255d2 100644
--- a/lib/xixanta/src/mapping.rs
+++ b/lib/xixanta/src/mapping.rs
@@ -18,6 +18,9 @@ pub enum SectionType {
/// Bank to be stored in CHR ROM with a size multiple of 4KB.
ChrRom,
+
+ /// The 6 final bytes describing the addresses for nmi, reset and irq.
+ Vector,
}
/// A segment inside of a memory mapping, used to organize the code inside of a
@@ -149,11 +152,15 @@ fn validate_configuration(mappings: &[Mapping]) -> Result<(), String> {
.iter()
.filter(|m| m.section_type == SectionType::PrgRom)
.fold(0, |acc, x| acc + x.size);
+ let vec_rom_len = mappings
+ .iter()
+ .filter(|m| m.section_type == SectionType::Vector)
+ .fold(0, |acc, x| acc + x.size);
- if prg_rom_len < 0x4000 {
+ if prg_rom_len + vec_rom_len < 0x4000 {
return Err("PRG ROM must be at least 8KB long".to_string());
}
- if prg_rom_len % 0x4000 != 0 {
+ if (prg_rom_len + vec_rom_len) % 0x4000 != 0 {
return Err("PRG ROM must be formed by banks of exactly 8KB".to_string());
}