aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/mapping.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-07-17 15:09:36 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:33:40 +0100
commit376dcb684ce779a7051bbc9a95359114e94cae5e (patch)
tree7bff7cc3dcbb4055efffcb3a172fc4aa238e9380 /lib/xixanta/src/mapping.rs
parent7822c00e8689c99ded0a360026f4e7ace1f2c87f (diff)
downloadtools.nes-376dcb684ce779a7051bbc9a95359114e94cae5e.tar.gz
tools.nes-376dcb684ce779a7051bbc9a95359114e94cae5e.zip
Add support for procedures
Procedures are marked with the '.proc' control statement and work both as a scoping mechanism and as a label that can be referenced. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/mapping.rs')
-rw-r--r--lib/xixanta/src/mapping.rs33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/xixanta/src/mapping.rs b/lib/xixanta/src/mapping.rs
index c097fd8..d2f1410 100644
--- a/lib/xixanta/src/mapping.rs
+++ b/lib/xixanta/src/mapping.rs
@@ -4,12 +4,41 @@ use std::collections::HashMap;
use crate::errors::ParseError;
type Result<T> = std::result::Result<T, ParseError>;
+lazy_static! {
+ pub static ref NROM: Vec<Segment> = vec![
+ Segment {
+ name: String::from("HEADER"),
+ start: 0x0000,
+ size: 0x0010,
+ fill: Some(Fill { value: 0x00 }),
+ },
+ Segment {
+ name: String::from("VECTORS"),
+ start: 0xFFFA,
+ size: 0x0006,
+ fill: Some(Fill { value: 0x00 }),
+ },
+ Segment {
+ name: String::from("CODE"),
+ start: 0x8000,
+ size: 0x7FFA,
+ fill: Some(Fill { value: 0x00 }),
+ },
+ Segment {
+ name: String::from("CHARS"),
+ start: 0x0000,
+ size: 0x2000,
+ fill: Some(Fill { value: 0x00 }),
+ }
+ ];
+}
+
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct Segment {
pub name: String,
pub start: u16,
pub size: usize,
- pub fill_value: Option<Fill>,
+ pub fill: Option<Fill>,
}
#[derive(Debug)]
@@ -21,7 +50,7 @@ pub struct Mapping {
impl Mapping {
pub fn new(mut segments: Vec<Segment>) -> Self {
- segments.sort_by(|a, b| b.start.cmp(&a.start));
+ segments.sort_by(|a, b| a.start.cmp(&b.start));
let mut nodes = HashMap::new();
for segment in segments.iter() {