snes-disassembler
Version:
A Super Nintendo (SNES) ROM disassembler for 65816 assembly
150 lines • 4.11 kB
TypeScript
/**
* SPC State Extractor for SNES Disassembler
* Analyzes SNES ROMs to extract SPC700 and DSP states for audio playback
*
* This module identifies:
* - SPC700 upload routines in SNES code
* - Audio data locations and formats
* - DSP register configurations
* - BRR sample data
* - Music sequence data
*/
import { DisassemblyLine } from './types';
import { SPC700State, DSPState, ID666Metadata } from './spc-exporter';
import { CartridgeInfo } from './cartridge-types';
export interface AudioDataLocation {
address: number;
size: number;
type: 'SPC_UPLOAD' | 'BRR_SAMPLES' | 'MUSIC_DATA' | 'DSP_DATA' | 'SPC_ENGINE';
description: string;
confidence: number;
}
export interface SPCUploadSequence {
startAddress: number;
endAddress: number;
instructions: DisassemblyLine[];
targetRamAddress: number;
dataSize: number;
uploadMethod: 'DIRECT' | 'DMA' | 'IPL_BOOT';
confidence: number;
}
export interface BRRSample {
address: number;
size: number;
loopPoint?: number;
sampleRate?: number;
name?: string;
confidence: number;
}
export interface MusicSequence {
address: number;
size: number;
trackCount: number;
channelMask: number;
instrument?: number;
tempo?: number;
confidence: number;
}
export interface ExtractedAudioState {
spc700State: Partial<SPC700State>;
dspState: Partial<DSPState>;
audioData: AudioDataLocation[];
spcUploads: SPCUploadSequence[];
brrSamples: BRRSample[];
musicSequences: MusicSequence[];
metadata: Partial<ID666Metadata>;
}
export declare class SPCStateExtractor {
private static readonly SPC_UPLOAD_PATTERNS;
private static readonly BRR_SIGNATURES;
private static readonly DSP_REGISTER_MAP;
/**
* Extract SPC700 and DSP states from ROM analysis
*/
static extractAudioState(lines: DisassemblyLine[], romData: Uint8Array, cartridgeInfo: CartridgeInfo): ExtractedAudioState;
/**
* Find SPC upload sequences in the disassembled code
*/
private static findSPCUploadSequences;
/**
* Check if instruction writes to APU ports ($2140-$2143)
*/
private static isAPUPortWrite;
/**
* Analyze potential SPC upload sequence starting at given line
*/
private static analyzePotentialSPCUpload;
/**
* Check if instruction reads from APU ports
*/
private static isAPUPortRead;
/**
* Check for IPL boot patterns
*/
private static isIPLBootPattern;
/**
* Check for DMA setup instructions
*/
private static isDMASetup;
/**
* Check if instruction is a loop instruction
*/
private static isLoopInstruction;
/**
* Find audio data locations in ROM
*/
private static findAudioDataLocations;
/**
* Analyze potential BRR directory
*/
private static analyzeBRRDirectory;
/**
* Check if data looks like music sequence data
*/
private static looksLikeMusicData;
/**
* Estimate music data size
*/
private static estimateMusicDataSize;
/**
* Find BRR samples in ROM data
*/
private static findBRRSamples;
/**
* Check if data at offset is a BRR block
*/
private static isBRRBlock;
/**
* Analyze BRR sample starting at offset
*/
private static analyzeBRRSample;
/**
* Find music sequences in ROM
*/
private static findMusicSequences;
/**
* Analyze SPC uploads to build SPC700 state
*/
private static analyzeSPCUploads;
/**
* Extract DSP register configurations
*/
private static extractDSPConfigurations;
/**
* Create basic SPC700 state
*/
private static createBasicSPC700State;
/**
* Create basic DSP state
*/
private static createBasicDSPState;
/**
* Extract basic metadata from cartridge info
*/
private static extractBasicMetadata;
/**
* Enhance metadata with additional information
*/
private static enhanceMetadata;
}
//# sourceMappingURL=spc-state-extractor.d.ts.map