1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-10 17:52:51 +00:00

M3: Asset pipeline, sprite/palette/background declarations, debug symbols

Parser extensions:
- sprite declarations with chr: @chr("file.png"), @binary("file.bin"), or inline [hex]
- palette declarations with colors: [0x0F, 0x00, 0x10, 0x20]
- background declarations with chr: asset source
- @chr/@binary asset source parsing
- load_background and set_palette statements
- --debug CLI flag (plumbed through, not yet wired to codegen)

Asset pipeline (new module):
- PNG → CHR tile conversion using image crate (8x8 tiles, 2-bitplane encoding)
- NES color palette table (all 64 standard NES colors as RGB)
- Nearest-color matching (Euclidean distance in RGB space)

Debug module (new):
- Source map (ROM address → source Span mapping)
- Debug symbols with variable address table
- Mesen-compatible .mlb label export
- .sym symbol table export

192 tests total (13 new: 5 parser + 3 asset + 5 debug)

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 00:09:47 +00:00
parent 0dc06f7f1a
commit 058f7a87b6
No known key found for this signature in database
18 changed files with 884 additions and 5 deletions

View file

@ -7,10 +7,41 @@ pub struct Program {
pub constants: Vec<ConstDecl>,
pub functions: Vec<FunDecl>,
pub states: Vec<StateDecl>,
pub sprites: Vec<SpriteDecl>,
pub palettes: Vec<PaletteDecl>,
pub backgrounds: Vec<BackgroundDecl>,
pub start_state: String,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct SpriteDecl {
pub name: String,
pub chr_source: AssetSource,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct PaletteDecl {
pub name: String,
pub colors: Vec<u8>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct BackgroundDecl {
pub name: String,
pub chr_source: AssetSource,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum AssetSource {
Chr(String),
Binary(String),
Inline(Vec<u8>),
}
#[derive(Debug, Clone)]
pub struct GameDecl {
pub name: String,
@ -188,6 +219,8 @@ pub enum Statement {
Transition(String, Span),
WaitFrame(Span),
Call(String, Vec<Expr>, Span),
LoadBackground(String, Span),
SetPalette(String, Span),
}
#[derive(Debug, Clone)]