@gaialabs/core 0.1.19 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +0 -22
- package/dist/index.cjs +6598 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2452 -0
- package/dist/index.d.mts +2248 -631
- package/dist/index.mjs +6439 -3903
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -29
- package/dist/browser.d.mts +0 -2
- package/dist/browser.d.ts +0 -2
- package/dist/browser.js +0 -4
- package/dist/browser.js.map +0 -1
- package/dist/browser.mjs +0 -3
- package/dist/browser.mjs.map +0 -1
- package/dist/index.d.ts +0 -835
- package/dist/index.js +0 -3977
- package/dist/index.js.map +0 -1
- package/dist/node.d.mts +0 -2
- package/dist/node.d.ts +0 -2
- package/dist/node.js +0 -4
- package/dist/node.js.map +0 -1
- package/dist/node.mjs +0 -3
- package/dist/node.mjs.map +0 -1
- package/dist/worker.d.mts +0 -2
- package/dist/worker.d.ts +0 -2
- package/dist/worker.js +0 -4
- package/dist/worker.js.map +0 -1
- package/dist/worker.mjs +0 -3
- package/dist/worker.mjs.map +0 -1
package/dist/index.d.ts
DELETED
|
@@ -1,835 +0,0 @@
|
|
|
1
|
-
import { StatusFlags, DbRoot, AddressType, DbStringType, StringWrapper, Op, OpCode, ChunkFile, AsmBlock, Address, CopDef, DbEntryPoint, ICompressionProvider } from '@gaialabs/shared';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Lightweight ROM state placeholder used during early development.
|
|
5
|
-
* This stub will be expanded as the ROM extraction pipeline matures.
|
|
6
|
-
*/
|
|
7
|
-
declare class RomState {
|
|
8
|
-
readonly cgram: Uint8Array<ArrayBuffer>;
|
|
9
|
-
readonly vram: Uint8Array<ArrayBuffer>;
|
|
10
|
-
/**
|
|
11
|
-
* Create ROM state from scene metadata.
|
|
12
|
-
* Parameters are currently unused but kept for future implementation.
|
|
13
|
-
*/
|
|
14
|
-
static fromScene(_baseDir: string, _root: unknown, _metaFile: string, _id: number): Promise<RomState>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Utility helpers for working with RomState.
|
|
18
|
-
*/
|
|
19
|
-
declare class RomStateUtils {
|
|
20
|
-
/** Create an empty ROM state */
|
|
21
|
-
static createEmpty(): RomState;
|
|
22
|
-
/** Clear all data in the given ROM state */
|
|
23
|
-
static clear(state: RomState): void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Represents the stack for the 65816 processor
|
|
28
|
-
*/
|
|
29
|
-
declare class Stack {
|
|
30
|
-
bytes: Uint8Array;
|
|
31
|
-
location: number;
|
|
32
|
-
constructor();
|
|
33
|
-
/**
|
|
34
|
-
* Push a byte onto the stack
|
|
35
|
-
*/
|
|
36
|
-
push(value: number): void;
|
|
37
|
-
/**
|
|
38
|
-
* Push a 16-bit value onto the stack (little-endian)
|
|
39
|
-
*/
|
|
40
|
-
pushUInt16(value: number): void;
|
|
41
|
-
/**
|
|
42
|
-
* Pop a byte from the stack
|
|
43
|
-
*/
|
|
44
|
-
popByte(): number;
|
|
45
|
-
/**
|
|
46
|
-
* Pop a 16-bit value from the stack (little-endian)
|
|
47
|
-
*/
|
|
48
|
-
popUInt16(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Reset the stack to initial state
|
|
51
|
-
*/
|
|
52
|
-
reset(): void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Manages the 65816 processor registers and status flags
|
|
57
|
-
*/
|
|
58
|
-
declare class Registers {
|
|
59
|
-
accumulatorFlag?: boolean;
|
|
60
|
-
indexFlag?: boolean;
|
|
61
|
-
direct?: number;
|
|
62
|
-
dataBank?: number;
|
|
63
|
-
accumulator?: number;
|
|
64
|
-
xIndex?: number;
|
|
65
|
-
yIndex?: number;
|
|
66
|
-
stack: Stack;
|
|
67
|
-
constructor();
|
|
68
|
-
/**
|
|
69
|
-
* Get the current status flags
|
|
70
|
-
*/
|
|
71
|
-
get statusFlags(): StatusFlags;
|
|
72
|
-
/**
|
|
73
|
-
* Set the status flags
|
|
74
|
-
*/
|
|
75
|
-
set statusFlags(value: StatusFlags);
|
|
76
|
-
/**
|
|
77
|
-
* Reset all registers to initial state
|
|
78
|
-
*/
|
|
79
|
-
reset(): void;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Manages CPU processor state during ROM analysis
|
|
84
|
-
* Converted from GaiaLib/Rom/Extraction/ProcessorStateManager.cs
|
|
85
|
-
*/
|
|
86
|
-
declare class ProcessorStateManager {
|
|
87
|
-
readonly accumulatorFlags: Map<number, boolean | null>;
|
|
88
|
-
readonly indexFlags: Map<number, boolean | null>;
|
|
89
|
-
readonly bankNotes: Map<number, number | null>;
|
|
90
|
-
readonly stackPositions: Map<number, number>;
|
|
91
|
-
/**
|
|
92
|
-
* Hydrate processor registers with stored state
|
|
93
|
-
* Uses Registers from gaia-core/assembly for processor state management
|
|
94
|
-
*/
|
|
95
|
-
hydrateRegisters(position: number, reg: Registers): void;
|
|
96
|
-
getAccumulatorFlag(location: number): boolean | null | undefined;
|
|
97
|
-
setAccumulatorFlag(location: number, value: boolean | null): void;
|
|
98
|
-
tryAddAccumulatorFlag(location: number, value: boolean | null): boolean;
|
|
99
|
-
getIndexFlag(location: number): boolean | null | undefined;
|
|
100
|
-
setIndexFlag(location: number, value: boolean | null): void;
|
|
101
|
-
tryAddIndexFlag(location: number, value: boolean | null): boolean;
|
|
102
|
-
getBankNote(location: number): number | null | undefined;
|
|
103
|
-
setBankNote(location: number, value: number | null): void;
|
|
104
|
-
getStackPosition(location: number): number | undefined;
|
|
105
|
-
setStackPosition(location: number, value: number): void;
|
|
106
|
-
tryAddStackPosition(location: number, value: number): boolean;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Provides low-level ROM data reading functionality
|
|
111
|
-
* Converted from GaiaLib/Rom/Extraction/RomDataReader.cs
|
|
112
|
-
*/
|
|
113
|
-
declare class RomDataReader {
|
|
114
|
-
readonly romData: Uint8Array;
|
|
115
|
-
position: number;
|
|
116
|
-
constructor(romData: Uint8Array);
|
|
117
|
-
readByte(): number;
|
|
118
|
-
readSByte(): number;
|
|
119
|
-
readUShort(): number;
|
|
120
|
-
readShort(): number;
|
|
121
|
-
readAddress(): number;
|
|
122
|
-
readInt(): number;
|
|
123
|
-
peekByte(): number;
|
|
124
|
-
peekShort(): number;
|
|
125
|
-
peekAddress(): number;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Manages references, chunks, and markers during ROM analysis
|
|
130
|
-
* Converted from GaiaLib/Rom/Extraction/ReferenceManager.cs
|
|
131
|
-
*/
|
|
132
|
-
declare class ReferenceManager {
|
|
133
|
-
readonly structTable: Map<number, string>;
|
|
134
|
-
readonly markerTable: Map<number, number>;
|
|
135
|
-
readonly nameTable: Map<number, string>;
|
|
136
|
-
private readonly root;
|
|
137
|
-
constructor(root: DbRoot);
|
|
138
|
-
tryGetStruct(location: number): {
|
|
139
|
-
found: boolean;
|
|
140
|
-
chunkType?: string;
|
|
141
|
-
};
|
|
142
|
-
tryAddStruct(location: number, chunkType: string): boolean;
|
|
143
|
-
containsStruct(location: number): boolean;
|
|
144
|
-
tryGetName(location: number): {
|
|
145
|
-
found: boolean;
|
|
146
|
-
referenceName?: string;
|
|
147
|
-
};
|
|
148
|
-
tryAddName(location: number, referenceName: string): boolean;
|
|
149
|
-
tryGetMarker(location: number): {
|
|
150
|
-
found: boolean;
|
|
151
|
-
offset?: number;
|
|
152
|
-
};
|
|
153
|
-
setMarker(location: number, offset: number): void;
|
|
154
|
-
createBranchLabel(location: number): string;
|
|
155
|
-
createTypeName(type: string, location: number): string;
|
|
156
|
-
createFallbackName(location: number): string;
|
|
157
|
-
/**
|
|
158
|
-
* Finds a reference location by its assigned name.
|
|
159
|
-
*/
|
|
160
|
-
findLocationByName(name: string): number | undefined;
|
|
161
|
-
resolveName(location: number, type: AddressType, isBranch: boolean): string;
|
|
162
|
-
findClosestReference(location: number): string | null;
|
|
163
|
-
private processRewrite;
|
|
164
|
-
private processClosestMatch;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Reads and processes strings from ROM data
|
|
169
|
-
* Converted from GaiaLib/Rom/Extraction/StringReader.cs
|
|
170
|
-
*/
|
|
171
|
-
declare class StringReader {
|
|
172
|
-
static readonly STRING_REFERENCE_CHARACTERS: string[];
|
|
173
|
-
private readonly _blockReader;
|
|
174
|
-
private readonly _romDataReader;
|
|
175
|
-
constructor(blockReader: BlockReader);
|
|
176
|
-
private resolveCommand;
|
|
177
|
-
parseString(stringType: DbStringType): StringWrapper;
|
|
178
|
-
/**
|
|
179
|
-
* Handles character shifting based on string type
|
|
180
|
-
* This is a simplified implementation of the shift logic
|
|
181
|
-
*/
|
|
182
|
-
private shiftDown;
|
|
183
|
-
resolveString(sw: StringWrapper, isBranch: boolean): void;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Parses assembly instructions from ROM data, handling different addressing modes
|
|
188
|
-
* and maintaining CPU register state during analysis.
|
|
189
|
-
* Converted from GaiaLib/Rom/Extraction/AsmReader.cs
|
|
190
|
-
*/
|
|
191
|
-
declare class AsmReader {
|
|
192
|
-
private static readonly PROCESSOR_FLAG_MASK;
|
|
193
|
-
private static readonly ACCUMULATOR_OP_MASK;
|
|
194
|
-
private static readonly ACCUMULATOR_OP_VALUE;
|
|
195
|
-
static readonly VARIABLE_SIZE_INDICATOR = -2;
|
|
196
|
-
private static readonly TWO_BYTES_SIZE;
|
|
197
|
-
private static readonly THREE_BYTES_SIZE;
|
|
198
|
-
private readonly _blockReader;
|
|
199
|
-
private readonly _transformProcessor;
|
|
200
|
-
private readonly _addressingModeHandler;
|
|
201
|
-
private readonly _romDataReader;
|
|
202
|
-
constructor(blockReader: BlockReader);
|
|
203
|
-
parseAsm(reg: Registers): Op;
|
|
204
|
-
clearDestinationRegister(code: OpCode, reg: Registers): void;
|
|
205
|
-
private initializeOperation;
|
|
206
|
-
private calculateInstructionSize;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Handles parsing of different data types from ROM
|
|
211
|
-
* Converted from GaiaLib/Rom/Extraction/TypeParser.cs
|
|
212
|
-
*/
|
|
213
|
-
declare class TypeParser {
|
|
214
|
-
private readonly _blockReader;
|
|
215
|
-
private readonly _romDataReader;
|
|
216
|
-
private readonly _stringReader;
|
|
217
|
-
private readonly _stringTypes;
|
|
218
|
-
private readonly _referenceManager;
|
|
219
|
-
constructor(blockReader: BlockReader);
|
|
220
|
-
parseType(typeName: string, reg: Registers | null, depth: number, bank?: number): unknown;
|
|
221
|
-
private tryParseMemberType;
|
|
222
|
-
private parseWordSafe;
|
|
223
|
-
private parseBinary;
|
|
224
|
-
private parseLocation;
|
|
225
|
-
private parseCode;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Central class for reading and analyzing ROM blocks
|
|
230
|
-
* Converted from GaiaLib/Rom/Extraction/BlockReader.cs
|
|
231
|
-
*/
|
|
232
|
-
declare class BlockReader {
|
|
233
|
-
private static readonly REF_SEARCH_MAX_RANGE;
|
|
234
|
-
private static readonly BANK_MASK_CHECK;
|
|
235
|
-
private static readonly BYTE_DELIMITER_THRESHOLD;
|
|
236
|
-
private static readonly BANK_HIGH_MEMORY_1;
|
|
237
|
-
private static readonly BANK_HIGH_MEMORY_2;
|
|
238
|
-
private static readonly POINTER_CHARACTERS;
|
|
239
|
-
private static readonly LOCATION_REGEX;
|
|
240
|
-
readonly _root: DbRoot;
|
|
241
|
-
readonly _stringReader: StringReader;
|
|
242
|
-
readonly _asmReader: AsmReader;
|
|
243
|
-
readonly _typeParser: TypeParser;
|
|
244
|
-
readonly _romDataReader: RomDataReader;
|
|
245
|
-
readonly _stateManager: ProcessorStateManager;
|
|
246
|
-
readonly _referenceManager: ReferenceManager;
|
|
247
|
-
get AccumulatorFlags(): Map<number, boolean | null>;
|
|
248
|
-
get IndexFlags(): Map<number, boolean | null>;
|
|
249
|
-
get BankNotes(): Map<number, number | null>;
|
|
250
|
-
get StackPosition(): Map<number, number>;
|
|
251
|
-
get _structTable(): Map<number, string>;
|
|
252
|
-
get _markerTable(): Map<number, number>;
|
|
253
|
-
get _nameTable(): Map<number, string>;
|
|
254
|
-
_partEnd: number;
|
|
255
|
-
_currentChunk: ChunkFile | null;
|
|
256
|
-
_currentAsmBlock: AsmBlock | null;
|
|
257
|
-
_enrichedChunks: ChunkFile[];
|
|
258
|
-
constructor(romData: Uint8Array, root: DbRoot);
|
|
259
|
-
/**
|
|
260
|
-
* Processes predefined overrides for registers and bank notes
|
|
261
|
-
*/
|
|
262
|
-
private initializeOverrides;
|
|
263
|
-
/**
|
|
264
|
-
* Processes predefined file references
|
|
265
|
-
*/
|
|
266
|
-
private initializeFileReferences;
|
|
267
|
-
/**
|
|
268
|
-
* Resolves mnemonic for a given address
|
|
269
|
-
*/
|
|
270
|
-
resolveMnemonic(addr: Address): void;
|
|
271
|
-
/**
|
|
272
|
-
* Resolves name for a location (delegated to ReferenceManager)
|
|
273
|
-
*/
|
|
274
|
-
resolveName(location: number, type: AddressType, isBranch: boolean): string;
|
|
275
|
-
/**
|
|
276
|
-
* Resolves include for a location
|
|
277
|
-
*/
|
|
278
|
-
resolveInclude(loc: number, isBranch: boolean): void;
|
|
279
|
-
/**
|
|
280
|
-
* Notes a type at a location and manages chunk references
|
|
281
|
-
*/
|
|
282
|
-
noteType(loc: number, type: string, silent?: boolean, reg?: Registers): string;
|
|
283
|
-
private updateRegisterState;
|
|
284
|
-
/**
|
|
285
|
-
* Checks if a delimiter has been reached
|
|
286
|
-
*/
|
|
287
|
-
delimiterReached(delimiter?: number): boolean;
|
|
288
|
-
/**
|
|
289
|
-
* Checks if processing of the current part can continue
|
|
290
|
-
*/
|
|
291
|
-
partCanContinue(): boolean;
|
|
292
|
-
analyzeAndResolve(): ChunkFile[];
|
|
293
|
-
/**
|
|
294
|
-
* Analyzes all blocks in the ROM
|
|
295
|
-
*/
|
|
296
|
-
/**
|
|
297
|
-
* Initializes blocks and parts with base references
|
|
298
|
-
*/
|
|
299
|
-
private initializeBlocksAndParts;
|
|
300
|
-
/**
|
|
301
|
-
* Processes a single part
|
|
302
|
-
*/
|
|
303
|
-
private processPart;
|
|
304
|
-
/**
|
|
305
|
-
* Processes a continuous entry (same type as previous)
|
|
306
|
-
*/
|
|
307
|
-
private processContinuousEntry;
|
|
308
|
-
/**
|
|
309
|
-
* Processes a new entry
|
|
310
|
-
*/
|
|
311
|
-
private processNewEntry;
|
|
312
|
-
/**
|
|
313
|
-
* Creates ChunkFile objects from database structure
|
|
314
|
-
*/
|
|
315
|
-
private createChunkFilesFromDatabase;
|
|
316
|
-
/**
|
|
317
|
-
* Creates binary ChunkFiles from DbFiles (enriched with rawData)
|
|
318
|
-
*/
|
|
319
|
-
private createChunkFilesFromSfx;
|
|
320
|
-
/**
|
|
321
|
-
* Creates binary ChunkFiles from DbFiles (enriched with rawData)
|
|
322
|
-
*/
|
|
323
|
-
private createChunkFilesFromDbFiles;
|
|
324
|
-
/**
|
|
325
|
-
* Creates assembly ChunkFiles from DbBlocks (enriched with parts)
|
|
326
|
-
*/
|
|
327
|
-
private createChunkFilesFromDbBlocks;
|
|
328
|
-
/**
|
|
329
|
-
* Analyzes only assembly ChunkFiles (those with parts from DbBlocks)
|
|
330
|
-
*/
|
|
331
|
-
private analyzeChunkFiles;
|
|
332
|
-
/**
|
|
333
|
-
* Resolves references in assembly ChunkFiles only
|
|
334
|
-
*/
|
|
335
|
-
private resolveReferences;
|
|
336
|
-
/**
|
|
337
|
-
* Resolves a single object and its references
|
|
338
|
-
*/
|
|
339
|
-
private resolveObject;
|
|
340
|
-
/**
|
|
341
|
-
* Resolves references in an operation object
|
|
342
|
-
*/
|
|
343
|
-
private resolveOperationObject;
|
|
344
|
-
/**
|
|
345
|
-
* Checks if an operation is a branch operation
|
|
346
|
-
*/
|
|
347
|
-
private isBranchOperation;
|
|
348
|
-
/**
|
|
349
|
-
* Hydrates registers with stored state
|
|
350
|
-
*/
|
|
351
|
-
hydrateRegisters(reg: Registers): void;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Handles transform processing for assembly instructions
|
|
356
|
-
* Converted from GaiaLib/Rom/Extraction/TransformProcessor.cs
|
|
357
|
-
*/
|
|
358
|
-
declare class TransformProcessor {
|
|
359
|
-
private readonly _blockReader;
|
|
360
|
-
private readonly _romDataReader;
|
|
361
|
-
private readonly _referenceManager;
|
|
362
|
-
private readonly _labelLookup;
|
|
363
|
-
private static readonly LOCATION_REGEX;
|
|
364
|
-
constructor(romReader: BlockReader);
|
|
365
|
-
/**
|
|
366
|
-
* Retrieves transform information for the current ROM position
|
|
367
|
-
*/
|
|
368
|
-
getTransform(): string | null;
|
|
369
|
-
/**
|
|
370
|
-
* Applies transforms to operands
|
|
371
|
-
*/
|
|
372
|
-
applyTransforms(op1Label: string | null, op2Label: string | null, operands: unknown[]): void;
|
|
373
|
-
private applyTransform;
|
|
374
|
-
private applyDefaultTransform;
|
|
375
|
-
private cleanTransformName;
|
|
376
|
-
private resolveTransformReference;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Context information for an operation being processed
|
|
381
|
-
* Converted from GaiaLib/Rom/Extraction/AsmReader.cs OperationContext
|
|
382
|
-
*/
|
|
383
|
-
declare class OperationContext {
|
|
384
|
-
size: number;
|
|
385
|
-
nextAddress: number;
|
|
386
|
-
xForm1: string | null;
|
|
387
|
-
xForm2: string | null;
|
|
388
|
-
copDef: CopDef | null;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Handles different addressing modes for assembly instructions
|
|
392
|
-
* Converted from GaiaLib/Rom/Extraction/AddressingModeHandler.cs
|
|
393
|
-
*/
|
|
394
|
-
declare class AddressingModeHandler {
|
|
395
|
-
private readonly _blockReader;
|
|
396
|
-
private readonly _transformProcessor;
|
|
397
|
-
private readonly _copProcessor;
|
|
398
|
-
private readonly _dataReader;
|
|
399
|
-
constructor(blockReader: BlockReader, transformProcessor: TransformProcessor);
|
|
400
|
-
processAddressingMode(code: OpCode, context: OperationContext, reg: Registers): unknown[];
|
|
401
|
-
private handleImmediateMode;
|
|
402
|
-
private readImmediateOperand;
|
|
403
|
-
private updateRegisterForImmediateInstruction;
|
|
404
|
-
private calculateRegisterValue;
|
|
405
|
-
private updateStatusFlags;
|
|
406
|
-
private handleAbsoluteLongMode;
|
|
407
|
-
private handleBlockMoveMode;
|
|
408
|
-
private handleDirectPageMode;
|
|
409
|
-
private handlePCRelativeMode;
|
|
410
|
-
private handleStackRelativeMode;
|
|
411
|
-
private handleStackInterruptMode;
|
|
412
|
-
private handleStackOrImpliedMode;
|
|
413
|
-
private handleAbsoluteMode;
|
|
414
|
-
private isJumpInstruction;
|
|
415
|
-
private isPushInstruction;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Handles stack operations for various stack-related instructions
|
|
420
|
-
* Converted from GaiaLib/Rom/Extraction/StackOperations.cs
|
|
421
|
-
*/
|
|
422
|
-
declare class StackOperations {
|
|
423
|
-
private readonly _registers;
|
|
424
|
-
private readonly _blockReader;
|
|
425
|
-
constructor(registers: Registers, blockReader: BlockReader);
|
|
426
|
-
handleStackOperation(mnemonic: string): void;
|
|
427
|
-
private handleAccumulatorPush;
|
|
428
|
-
private handleAccumulatorPull;
|
|
429
|
-
private handleXIndexPush;
|
|
430
|
-
private handleXIndexPull;
|
|
431
|
-
private handleYIndexPush;
|
|
432
|
-
private handleYIndexPull;
|
|
433
|
-
private handleExchangeBytes;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Handles COP (Coprocessor) command processing
|
|
438
|
-
* Converted from GaiaLib/Rom/Extraction/CopCommandProcessor.cs
|
|
439
|
-
*/
|
|
440
|
-
declare class CopCommandProcessor {
|
|
441
|
-
private readonly _blockReader;
|
|
442
|
-
private readonly _romDataReader;
|
|
443
|
-
constructor(blockReader: BlockReader);
|
|
444
|
-
/**
|
|
445
|
-
* Parses a COP command based on its definition
|
|
446
|
-
*/
|
|
447
|
-
parseCopCommand(copDef: CopDef, operands: unknown[]): void;
|
|
448
|
-
private tryParseMemberType;
|
|
449
|
-
private getMemberTypeSize;
|
|
450
|
-
private readMemberTypeValue;
|
|
451
|
-
private createCopLocation;
|
|
452
|
-
private tryParseAddressType;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
declare enum ObjectType {
|
|
456
|
-
TableEntryArray = "TableEntryArray",
|
|
457
|
-
StructDef = "StructDef",
|
|
458
|
-
OpArray = "OpArray",
|
|
459
|
-
LocationWrapper = "LocationWrapper",
|
|
460
|
-
Address = "Address",
|
|
461
|
-
StringWrapper = "StringWrapper",
|
|
462
|
-
ByteArray = "ByteArray",
|
|
463
|
-
Array = "Array",
|
|
464
|
-
String = "String",
|
|
465
|
-
Number = "Number",
|
|
466
|
-
TypedNumber = "TypedNumber"
|
|
467
|
-
}
|
|
468
|
-
declare class BlockWriter {
|
|
469
|
-
private _root;
|
|
470
|
-
private _blockReader;
|
|
471
|
-
private _referenceManager;
|
|
472
|
-
private _postProcessor;
|
|
473
|
-
private _isInline;
|
|
474
|
-
private _currentPart;
|
|
475
|
-
constructor(reader: BlockReader);
|
|
476
|
-
generateAllAsm(chunkFiles: ChunkFile[]): any[];
|
|
477
|
-
generateAsm(block: ChunkFile): string;
|
|
478
|
-
private getMnemonicsForBlock;
|
|
479
|
-
private resolveOperand;
|
|
480
|
-
private getObjectType;
|
|
481
|
-
private writeObject;
|
|
482
|
-
private writeTableEntryArray;
|
|
483
|
-
private writeStructDef;
|
|
484
|
-
private writeOpArray;
|
|
485
|
-
private formatDefaultOperand;
|
|
486
|
-
private writeStringWrapper;
|
|
487
|
-
private writeArray;
|
|
488
|
-
private writeNumber;
|
|
489
|
-
private formatTypedNumber;
|
|
490
|
-
private writeTypedNumber;
|
|
491
|
-
private formatOperand;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Handles post processing of extracted blocks.
|
|
496
|
-
* Mirrors functionality of GaiaLib.Rom.Extraction.PostProcessor.
|
|
497
|
-
*/
|
|
498
|
-
declare class PostProcessor {
|
|
499
|
-
private readonly _referenceManager;
|
|
500
|
-
constructor(reader: BlockReader);
|
|
501
|
-
/**
|
|
502
|
-
* Execute post process directive on a block if present.
|
|
503
|
-
*/
|
|
504
|
-
process(block: ChunkFile): void;
|
|
505
|
-
/**
|
|
506
|
-
* Builds a lookup table from struct entries.
|
|
507
|
-
* Equivalent to PostProcessor.Lookup in C# implementation.
|
|
508
|
-
*/
|
|
509
|
-
Lookup(block: ChunkFile, keyIx: string, valueIx: string): void;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* ROM layout planner
|
|
514
|
-
* Converted from ext/GaiaLib/Rom/Rebuild/RomLayout.cs
|
|
515
|
-
*/
|
|
516
|
-
declare class RomLayout {
|
|
517
|
-
private static readonly MIN_ACCEPTED_REMAINING;
|
|
518
|
-
readonly unmatchedFiles: ChunkFile[];
|
|
519
|
-
private readonly bestResult;
|
|
520
|
-
private readonly bestSample;
|
|
521
|
-
private currentBank;
|
|
522
|
-
private currentUpper;
|
|
523
|
-
private bestDepth;
|
|
524
|
-
private bestOffset;
|
|
525
|
-
private bestRemain;
|
|
526
|
-
constructor(files: Iterable<ChunkFile>);
|
|
527
|
-
organize(): void;
|
|
528
|
-
private testDepth;
|
|
529
|
-
private commitPage;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* ROM writer (binary)
|
|
534
|
-
* Converted from ext/GaiaLib/Rom/Rebuild/RomWriter.cs (subset: binary write only)
|
|
535
|
-
*/
|
|
536
|
-
declare class RomWriter {
|
|
537
|
-
bpsPath?: string;
|
|
538
|
-
readonly outBuffer: Uint8Array;
|
|
539
|
-
readonly entryPoints: DbEntryPoint[];
|
|
540
|
-
readonly cartName: string;
|
|
541
|
-
readonly makerCode: string;
|
|
542
|
-
constructor(entryPoints: DbEntryPoint[], cartName: string, makerCode: string);
|
|
543
|
-
repack(files: ChunkFile[]): Promise<Uint8Array>;
|
|
544
|
-
writeHeader(): void;
|
|
545
|
-
writeChecksum(): void;
|
|
546
|
-
writeEntryPoints(asmFiles: ChunkFile[]): void;
|
|
547
|
-
writeTransform(location: number, value: number, size?: number): void;
|
|
548
|
-
writeFile(file: ChunkFile, _chunkLookup: Map<string, number>): Promise<number>;
|
|
549
|
-
private writeAscii;
|
|
550
|
-
/**
|
|
551
|
-
* Parse assembly blocks and write binary data to output buffer
|
|
552
|
-
* Converted from ext/GaiaLib/Rom/Rebuild/RomWriter.cs ParseAssembly method
|
|
553
|
-
*/
|
|
554
|
-
private parseAssembly;
|
|
555
|
-
/**
|
|
556
|
-
* Helper method to find index of any character from an array in a string
|
|
557
|
-
*/
|
|
558
|
-
private indexOfAny;
|
|
559
|
-
/**
|
|
560
|
-
* Helper method to check if an object is a StringMarker
|
|
561
|
-
*/
|
|
562
|
-
private isStringMarker;
|
|
563
|
-
private isTableEntry;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* ROM rebuild processor
|
|
568
|
-
* Converted from ext/GaiaLib/Rom/Rebuild/RomProcessor.cs
|
|
569
|
-
*/
|
|
570
|
-
declare class RomProcessor {
|
|
571
|
-
private readonly writer;
|
|
572
|
-
constructor(writer: RomWriter);
|
|
573
|
-
repack(allFiles: ChunkFile[]): Promise<void>;
|
|
574
|
-
static applyPatches(asmFiles: ChunkFile[], patches: ChunkFile[]): void;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* Shared context interface for assembler components
|
|
579
|
-
* This eliminates circular dependencies between Assembler, AssemblerState, and StringProcessor
|
|
580
|
-
*/
|
|
581
|
-
interface AssemblerContext {
|
|
582
|
-
readonly root: DbRoot;
|
|
583
|
-
readonly stringProcessor: StringProcessor;
|
|
584
|
-
currentBlock: AsmBlock | null;
|
|
585
|
-
lineBuffer: string;
|
|
586
|
-
blockIndex: number;
|
|
587
|
-
lastDelimiter: number | null;
|
|
588
|
-
blocks: AsmBlock[];
|
|
589
|
-
eof: boolean;
|
|
590
|
-
lineCount: number;
|
|
591
|
-
getLine(): boolean;
|
|
592
|
-
processRawData(): void;
|
|
593
|
-
parseOperand(operand: string): unknown;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* String processor for assembly parsing
|
|
598
|
-
* Converted from GaiaLib/Rom/Rebuild/StringProcessor.cs
|
|
599
|
-
*/
|
|
600
|
-
declare class StringProcessor {
|
|
601
|
-
private readonly memBuffer;
|
|
602
|
-
private readonly context;
|
|
603
|
-
private readonly root;
|
|
604
|
-
constructor(context: AssemblerContext);
|
|
605
|
-
dispose(): void;
|
|
606
|
-
consumeString(): void;
|
|
607
|
-
private flushBuffer;
|
|
608
|
-
private processString;
|
|
609
|
-
private applyLayers;
|
|
610
|
-
private applyMap;
|
|
611
|
-
private processStringCommand;
|
|
612
|
-
private getShiftUp;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* A map that sorts keys by length in descending order, then alphabetically
|
|
617
|
-
* This is used for tag replacement where longer tags should be replaced first
|
|
618
|
-
* to avoid conflicts (e.g., "ABCD" should be replaced before "ABC")
|
|
619
|
-
*/
|
|
620
|
-
declare class SortedMap<V> {
|
|
621
|
-
private map;
|
|
622
|
-
private _keys;
|
|
623
|
-
get size(): number;
|
|
624
|
-
set(key: string, value: V): this;
|
|
625
|
-
get(key: string): V | undefined;
|
|
626
|
-
has(key: string): boolean;
|
|
627
|
-
delete(key: string): boolean;
|
|
628
|
-
clear(): void;
|
|
629
|
-
keys(): string[];
|
|
630
|
-
values(): V[];
|
|
631
|
-
entries(): [string, V][];
|
|
632
|
-
[Symbol.iterator](): Generator<[string, V], void, unknown>;
|
|
633
|
-
private sortKeys;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Main assembler class for parsing assembly files
|
|
638
|
-
* Converted from GaiaLib/Rom/Rebuild/Assembler.cs
|
|
639
|
-
*/
|
|
640
|
-
declare class Assembler implements AssemblerContext {
|
|
641
|
-
readonly root: DbRoot;
|
|
642
|
-
private readonly lines;
|
|
643
|
-
private currentLineIndex;
|
|
644
|
-
readonly stringProcessor: StringProcessor;
|
|
645
|
-
lineBuffer: string;
|
|
646
|
-
includes: Set<string>;
|
|
647
|
-
blocks: AsmBlock[];
|
|
648
|
-
tags: SortedMap<string | null>;
|
|
649
|
-
currentBlock: AsmBlock | null;
|
|
650
|
-
lineCount: number;
|
|
651
|
-
blockIndex: number;
|
|
652
|
-
lastDelimiter: number | null;
|
|
653
|
-
reqBank: number | null;
|
|
654
|
-
eof: boolean;
|
|
655
|
-
constructor(dbRoot: DbRoot, textData: string);
|
|
656
|
-
dispose(): void;
|
|
657
|
-
parseAssembly(): {
|
|
658
|
-
blocks: AsmBlock[];
|
|
659
|
-
includes: Set<string>;
|
|
660
|
-
reqBank: number | null;
|
|
661
|
-
};
|
|
662
|
-
getLine(): boolean;
|
|
663
|
-
private trimComments;
|
|
664
|
-
private processDirectives;
|
|
665
|
-
private processTags;
|
|
666
|
-
private resolveTags;
|
|
667
|
-
parseOperand(opnd: string): unknown;
|
|
668
|
-
processRawData(): void;
|
|
669
|
-
private hexStringToBytes;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* Assembler state machine for processing assembly text
|
|
674
|
-
* Converted from GaiaLib/Rom/Rebuild/AssemblerState.cs
|
|
675
|
-
*/
|
|
676
|
-
declare class AssemblerState {
|
|
677
|
-
private readonly dbStruct;
|
|
678
|
-
private readonly parentStruct;
|
|
679
|
-
private readonly root;
|
|
680
|
-
private readonly discriminator;
|
|
681
|
-
private delimiter;
|
|
682
|
-
private memberOffset;
|
|
683
|
-
private dataOffset;
|
|
684
|
-
private readonly memberTypes;
|
|
685
|
-
private currentType;
|
|
686
|
-
private readonly context;
|
|
687
|
-
constructor(context: AssemblerContext, structType?: string | null, saveDelimiter?: boolean);
|
|
688
|
-
private checkDisc;
|
|
689
|
-
private advancePart;
|
|
690
|
-
private processOrigin;
|
|
691
|
-
private static doMath;
|
|
692
|
-
private tryCreateLabel;
|
|
693
|
-
processText(openTag?: string): void;
|
|
694
|
-
private hexStringToBytes;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
declare class RomGenerator {
|
|
698
|
-
readonly projectName?: string;
|
|
699
|
-
crc: number;
|
|
700
|
-
branchId: string;
|
|
701
|
-
dbRoot: DbRoot;
|
|
702
|
-
private sourceData;
|
|
703
|
-
constructor(projectName?: string);
|
|
704
|
-
initialize(): Promise<void>;
|
|
705
|
-
validateAndDownload(sourceData: Uint8Array): Promise<boolean>;
|
|
706
|
-
generateProject(modules: string[], manualFiles?: ChunkFile[], unshiftManualFiles?: boolean): Promise<Uint8Array>;
|
|
707
|
-
private applyProjectInit;
|
|
708
|
-
private assembleCodeFromText;
|
|
709
|
-
private generateAsmIncludeLookups;
|
|
710
|
-
applyPatchFile(chunkFile: ChunkFile, chunkFiles: ChunkFile[], asmFiles: ChunkFile[], patchFiles: ChunkFile[]): void;
|
|
711
|
-
private writeRom;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
/**
|
|
715
|
-
* QuintetLZ compression algorithm implementation
|
|
716
|
-
* Dictionary-based compression used in Quintet games
|
|
717
|
-
*/
|
|
718
|
-
declare class QuintetLZ implements ICompressionProvider {
|
|
719
|
-
static readonly DICTIONARY_SIZE = 256;
|
|
720
|
-
static readonly DICTIONARY_INIT = 32;
|
|
721
|
-
static readonly DICTIONARY_OFFSET = 239;
|
|
722
|
-
private static readonly DEFAULT_PAGE_SIZE;
|
|
723
|
-
/**
|
|
724
|
-
* Expand (decompress) data using QuintetLZ algorithm
|
|
725
|
-
* @param srcData Source data buffer
|
|
726
|
-
* @param srcPosition Starting position in source data
|
|
727
|
-
* @param srcLen Length of source data to process
|
|
728
|
-
* @returns Expanded data
|
|
729
|
-
*/
|
|
730
|
-
expand(srcData: Uint8Array, srcPosition?: number, srcLen?: number): Uint8Array;
|
|
731
|
-
/**
|
|
732
|
-
* Compact (compress) data using QuintetLZ algorithm
|
|
733
|
-
* @param srcData Source data to compress
|
|
734
|
-
* @returns Compressed data
|
|
735
|
-
*/
|
|
736
|
-
compact(srcData: Uint8Array): Uint8Array;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
* Register compression providers with the global registry
|
|
741
|
-
*/
|
|
742
|
-
declare function registerCompressionProviders(): void;
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Represents a single frame in a sprite animation sequence
|
|
746
|
-
*/
|
|
747
|
-
declare class SpriteFrame {
|
|
748
|
-
duration: number;
|
|
749
|
-
groupIndex: number;
|
|
750
|
-
/**
|
|
751
|
-
* Internal offset to the group data (not serialized)
|
|
752
|
-
*/
|
|
753
|
-
groupOffset: number;
|
|
754
|
-
constructor(duration?: number, groupIndex?: number, groupOffset?: number);
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* Represents a single part/piece of a sprite
|
|
759
|
-
*/
|
|
760
|
-
declare class SpritePart {
|
|
761
|
-
isLarge: boolean;
|
|
762
|
-
xOffset: number;
|
|
763
|
-
xOffsetMirror: number;
|
|
764
|
-
yOffset: number;
|
|
765
|
-
yOffsetMirror: number;
|
|
766
|
-
vMirror: boolean;
|
|
767
|
-
hMirror: boolean;
|
|
768
|
-
someOffset: number;
|
|
769
|
-
paletteIndex: number;
|
|
770
|
-
tileIndex: number;
|
|
771
|
-
constructor();
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
/**
|
|
775
|
-
* Represents a group of sprite parts that form a complete sprite frame
|
|
776
|
-
*/
|
|
777
|
-
declare class SpriteGroup {
|
|
778
|
-
xOffset: number;
|
|
779
|
-
xOffsetMirror: number;
|
|
780
|
-
yOffset: number;
|
|
781
|
-
yOffsetMirror: number;
|
|
782
|
-
xRecoilHitboxOffset: number;
|
|
783
|
-
yRecoilHitboxOffset: number;
|
|
784
|
-
xRecoilHitboxTilesize: number;
|
|
785
|
-
yRecoilHitboxTilesize: number;
|
|
786
|
-
xHostileHitboxOffset: number;
|
|
787
|
-
xHostileHitboxSize: number;
|
|
788
|
-
yHostileHitboxOffset: number;
|
|
789
|
-
yHostileHitboxSize: number;
|
|
790
|
-
parts: SpritePart[];
|
|
791
|
-
constructor();
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
/**
|
|
795
|
-
* Represents a complete sprite map with frame sets and groups
|
|
796
|
-
*/
|
|
797
|
-
declare class SpriteMap {
|
|
798
|
-
frameSets: SpriteFrame[][];
|
|
799
|
-
groups: SpriteGroup[];
|
|
800
|
-
constructor();
|
|
801
|
-
/**
|
|
802
|
-
* Create a SpriteMap from binary data
|
|
803
|
-
* @param data Binary data buffer
|
|
804
|
-
* @returns SpriteMap instance
|
|
805
|
-
*/
|
|
806
|
-
static fromBytes(data: Uint8Array): SpriteMap;
|
|
807
|
-
/**
|
|
808
|
-
* Convert this SpriteMap to binary data
|
|
809
|
-
* @returns Binary data buffer
|
|
810
|
-
*/
|
|
811
|
-
toBytes(): Uint8Array;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* GaiaCore - Universal ROM processing engine
|
|
816
|
-
*
|
|
817
|
-
* This package provides the core functionality for ROM processing
|
|
818
|
-
* that can run in both browser (Web Worker) and Node.js environments.
|
|
819
|
-
*
|
|
820
|
-
* High-level APIs:
|
|
821
|
-
* - RomProcessor: Unified ROM processing workflows
|
|
822
|
-
* - ProjectManager: Complete project lifecycle management
|
|
823
|
-
*
|
|
824
|
-
* Low-level modules:
|
|
825
|
-
* - ROM: ROM state management, project configuration
|
|
826
|
-
* - Assembly: 65816 instruction set, stack operations
|
|
827
|
-
* - Compression: QuintetLZ compression algorithm
|
|
828
|
-
* - Sprites: Sprite animation system
|
|
829
|
-
*/
|
|
830
|
-
declare const GAIA_CORE_VERSION = "0.1.6";
|
|
831
|
-
declare const isPlatformBrowser: boolean;
|
|
832
|
-
declare const isPlatformNode: string | false;
|
|
833
|
-
declare const isPlatformWebWorker: boolean;
|
|
834
|
-
|
|
835
|
-
export { AddressingModeHandler, AsmReader, Assembler, type AssemblerContext, AssemblerState, BlockReader, BlockWriter, CopCommandProcessor, GAIA_CORE_VERSION, ObjectType, OperationContext, PostProcessor, ProcessorStateManager, QuintetLZ, ReferenceManager, Registers, RomDataReader, RomGenerator, RomLayout, RomProcessor, RomState, RomStateUtils, RomWriter, SortedMap, SpriteFrame, SpriteGroup, SpriteMap, SpritePart, Stack, StackOperations, StringProcessor, StringReader, TransformProcessor, TypeParser, isPlatformBrowser, isPlatformNode, isPlatformWebWorker, registerCompressionProviders };
|