@gaialabs/core 0.2.4 → 0.2.6

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.
Files changed (44) hide show
  1. package/client/client.d.ts +1 -0
  2. package/client/client.js +5 -0
  3. package/client/default.d.ts +1 -0
  4. package/client/default.js +5 -0
  5. package/client/edge.d.ts +1 -0
  6. package/client/edge.js +373 -0
  7. package/client/index-browser.js +399 -0
  8. package/client/index.d.ts +34222 -0
  9. package/client/index.js +373 -0
  10. package/client/package.json +144 -0
  11. package/client/query_compiler_fast_bg.js +2 -0
  12. package/client/query_compiler_fast_bg.wasm +0 -0
  13. package/client/query_compiler_fast_bg.wasm-base64.js +2 -0
  14. package/client/query_engine-windows.dll.node +0 -0
  15. package/client/query_engine_bg.js +2 -0
  16. package/client/query_engine_bg.wasm +0 -0
  17. package/client/runtime/client.d.ts +3358 -0
  18. package/client/runtime/client.js +86 -0
  19. package/client/runtime/edge-esm.js +35 -0
  20. package/client/runtime/edge.js +35 -0
  21. package/client/runtime/index-browser.d.ts +90 -0
  22. package/client/runtime/index-browser.js +6 -0
  23. package/client/runtime/library.d.ts +3982 -0
  24. package/client/runtime/library.js +147 -0
  25. package/client/runtime/react-native.js +84 -0
  26. package/client/runtime/wasm-compiler-edge.js +76 -0
  27. package/client/runtime/wasm-engine-edge.js +38 -0
  28. package/client/schema.prisma +404 -0
  29. package/client/wasm-edge-light-loader.mjs +5 -0
  30. package/client/wasm-worker-loader.mjs +5 -0
  31. package/client/wasm.d.ts +1 -0
  32. package/client/wasm.js +421 -0
  33. package/dist/index.cjs +1228 -427
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +1038 -348
  36. package/dist/index.d.cts.map +1 -0
  37. package/dist/index.d.mts +1038 -348
  38. package/dist/index.d.mts.map +1 -0
  39. package/dist/index.mjs +1225 -424
  40. package/dist/index.mjs.map +1 -1
  41. package/package.json +16 -1
  42. package/prisma.cjs +1 -0
  43. package/prisma.d.ts +1 -0
  44. package/prisma.mjs +9 -0
package/dist/index.mjs CHANGED
@@ -1,6 +1,846 @@
1
- import { writeFileSync } from "fs";
2
1
  import { createClient } from "@supabase/supabase-js";
3
2
 
3
+ //#region snes/addressingModes.json
4
+ var addressingModes_default = {
5
+ Absolute: {
6
+ "shorthand": "abs",
7
+ "operands": ["Offset"],
8
+ "size": 3,
9
+ "formatString": "${0:X4}",
10
+ "parseRegex": "^\\$([A-Fa-f0-9]{4}|&[A-Za-z0-9-+_]+)$",
11
+ "instructions": {
12
+ "ADC": 109,
13
+ "AND": 45,
14
+ "ASL": 14,
15
+ "BIT": 44,
16
+ "CMP": 205,
17
+ "CPX": 236,
18
+ "CPY": 204,
19
+ "DEC": 206,
20
+ "EOR": 77,
21
+ "INC": 238,
22
+ "JMP": 76,
23
+ "JSR": 32,
24
+ "LDA": 173,
25
+ "LDX": 174,
26
+ "LDY": 172,
27
+ "LSR": 78,
28
+ "ORA": 13,
29
+ "PEA": 244,
30
+ "ROL": 46,
31
+ "ROR": 110,
32
+ "SBC": 237,
33
+ "STA": 141,
34
+ "STX": 142,
35
+ "STY": 140,
36
+ "STZ": 156,
37
+ "TRB": 28,
38
+ "TSB": 12
39
+ }
40
+ },
41
+ AbsoluteIndexedX: {
42
+ "shorthand": "abs_x",
43
+ "operands": ["Offset"],
44
+ "size": 3,
45
+ "formatString": "${0:X4}, X",
46
+ "parseRegex": "^(\\$[A-Fa-f0-9]{4}|\\$?&[A-Za-z0-9-+_]+),\\s?[Xx]$",
47
+ "instructions": {
48
+ "ADC": 125,
49
+ "AND": 61,
50
+ "ASL": 30,
51
+ "BIT": 60,
52
+ "CMP": 221,
53
+ "DEC": 222,
54
+ "EOR": 93,
55
+ "INC": 254,
56
+ "LDA": 189,
57
+ "LDY": 188,
58
+ "LSR": 94,
59
+ "ORA": 29,
60
+ "ROL": 62,
61
+ "ROR": 126,
62
+ "SBC": 253,
63
+ "STA": 157,
64
+ "STZ": 158
65
+ }
66
+ },
67
+ AbsoluteIndexedY: {
68
+ "shorthand": "abs_y",
69
+ "operands": ["Offset"],
70
+ "size": 3,
71
+ "formatString": "${0:X4}, Y",
72
+ "parseRegex": "^(\\$[A-Fa-f0-9]{4}|\\$?&[A-Za-z0-9-+_]+),\\s?[Yy]$",
73
+ "instructions": {
74
+ "ADC": 121,
75
+ "AND": 57,
76
+ "CMP": 217,
77
+ "EOR": 89,
78
+ "LDA": 185,
79
+ "LDX": 190,
80
+ "ORA": 25,
81
+ "SBC": 249,
82
+ "STA": 153
83
+ }
84
+ },
85
+ AbsoluteIndirect: {
86
+ "shorthand": "abs_ind",
87
+ "operands": ["Offset"],
88
+ "size": 3,
89
+ "formatString": "(${0})",
90
+ "parseRegex": "^\\((\\$[A-Fa-f0-9]{4}|\\$?&[A-Za-z0-9-+_]+)\\)$",
91
+ "instructions": { "JMP": 108 }
92
+ },
93
+ AbsoluteIndirectLong: {
94
+ "shorthand": "abs_indl",
95
+ "operands": ["Offset"],
96
+ "size": 3,
97
+ "formatString": "[${0}]",
98
+ "parseRegex": "^\\[(\\$[A-Fa-f0-9]{4}|\\$?&[A-Za-z0-9-+_]+)\\]$",
99
+ "instructions": { "JML": 220 }
100
+ },
101
+ AbsoluteIndexedIndirect: {
102
+ "shorthand": "abs_x_ind",
103
+ "operands": ["Offset"],
104
+ "size": 3,
105
+ "formatString": "(${0}, X)",
106
+ "parseRegex": "^\\((\\$[A-Fa-f0-9]{4}|\\$?&[A-Za-z0-9-+_]+),\\s*[Xx]\\)$",
107
+ "instructions": {
108
+ "JMP": 124,
109
+ "JSR": 252
110
+ }
111
+ },
112
+ AbsoluteLong: {
113
+ "shorthand": "long",
114
+ "operands": ["Address"],
115
+ "size": 4,
116
+ "formatString": "${0:X6}",
117
+ "parseRegex": "^\\$([A-Fa-f0-9]{6}|\\@[A-Za-z0-9-+_]+)$",
118
+ "instructions": {
119
+ "ADC": 111,
120
+ "AND": 47,
121
+ "CMP": 207,
122
+ "EOR": 79,
123
+ "JML": 92,
124
+ "JSL": 34,
125
+ "LDA": 175,
126
+ "ORA": 15,
127
+ "SBC": 239,
128
+ "STA": 143
129
+ }
130
+ },
131
+ AbsoluteLongIndexedX: {
132
+ "shorthand": "long_x",
133
+ "operands": ["Address"],
134
+ "size": 4,
135
+ "formatString": "${0:X6}, X",
136
+ "parseRegex": "^(\\$[A-Fa-f0-9]{6}|\\$?@[A-Za-z0-9-+_]+),\\s?[Xx]$",
137
+ "instructions": {
138
+ "ADC": 127,
139
+ "AND": 63,
140
+ "CMP": 223,
141
+ "EOR": 95,
142
+ "LDA": 191,
143
+ "ORA": 31,
144
+ "SBC": 255,
145
+ "STA": 159
146
+ }
147
+ },
148
+ DirectPage: {
149
+ "shorthand": "dp",
150
+ "operands": ["Direct"],
151
+ "size": 2,
152
+ "formatString": "${0:X2}",
153
+ "parseRegex": "^\\$([A-Fa-f0-9]{2})$",
154
+ "instructions": {
155
+ "ADC": 101,
156
+ "AND": 37,
157
+ "ASL": 6,
158
+ "BIT": 36,
159
+ "CMP": 197,
160
+ "CPX": 228,
161
+ "CPY": 196,
162
+ "DEC": 198,
163
+ "EOR": 69,
164
+ "INC": 230,
165
+ "LDA": 165,
166
+ "LDX": 166,
167
+ "LDY": 164,
168
+ "LSR": 70,
169
+ "ORA": 5,
170
+ "ROL": 38,
171
+ "ROR": 102,
172
+ "SBC": 229,
173
+ "STA": 133,
174
+ "STX": 134,
175
+ "STY": 132,
176
+ "STZ": 100,
177
+ "TRB": 20,
178
+ "TSB": 4
179
+ }
180
+ },
181
+ DirectPageIndexedX: {
182
+ "shorthand": "dp_x",
183
+ "operands": ["Direct"],
184
+ "size": 2,
185
+ "formatString": "${0:X2}, X",
186
+ "parseRegex": "^\\$([A-Fa-f0-9]{2}),\\s?[Xx]$",
187
+ "instructions": {
188
+ "ADC": 117,
189
+ "AND": 53,
190
+ "ASL": 22,
191
+ "BIT": 52,
192
+ "CMP": 213,
193
+ "DEC": 214,
194
+ "EOR": 85,
195
+ "INC": 246,
196
+ "LDA": 181,
197
+ "LDY": 180,
198
+ "LSR": 86,
199
+ "ORA": 21,
200
+ "ROL": 54,
201
+ "ROR": 118,
202
+ "SBC": 245,
203
+ "STA": 149,
204
+ "STY": 148,
205
+ "STZ": 116
206
+ }
207
+ },
208
+ DirectPageIndexedY: {
209
+ "shorthand": "dp_y",
210
+ "operands": ["Direct"],
211
+ "size": 2,
212
+ "formatString": "${0:X2}, Y",
213
+ "parseRegex": "^\\$([A-Fa-f0-9]{2}),\\s?[Yy]$",
214
+ "instructions": {
215
+ "LDX": 182,
216
+ "STX": 150
217
+ }
218
+ },
219
+ DirectPageIndirect: {
220
+ "shorthand": "dp_ind",
221
+ "operands": ["Direct"],
222
+ "size": 2,
223
+ "formatString": "(${0:X2})",
224
+ "parseRegex": "^\\(\\$([A-Fa-f0-9]{2})\\)$",
225
+ "instructions": {
226
+ "ADC": 114,
227
+ "AND": 50,
228
+ "CMP": 210,
229
+ "EOR": 82,
230
+ "LDA": 178,
231
+ "ORA": 18,
232
+ "PEI": 212,
233
+ "SBC": 242,
234
+ "STA": 146
235
+ }
236
+ },
237
+ DirectPageIndirectLong: {
238
+ "shorthand": "dp_indl",
239
+ "operands": ["Direct"],
240
+ "size": 2,
241
+ "formatString": "[${0:X2}]",
242
+ "parseRegex": "^\\[\\$([A-Fa-f0-9]{2})\\]$",
243
+ "instructions": {
244
+ "ADC": 103,
245
+ "AND": 39,
246
+ "CMP": 199,
247
+ "EOR": 71,
248
+ "LDA": 167,
249
+ "ORA": 7,
250
+ "SBC": 231,
251
+ "STA": 135
252
+ }
253
+ },
254
+ DirectPageIndexedIndirectX: {
255
+ "shorthand": "dp_x_ind",
256
+ "operands": ["Direct"],
257
+ "size": 2,
258
+ "formatString": "(${0:X2}, X)",
259
+ "parseRegex": "^\\(\\$([A-Fa-f0-9]{2}),\\s?[Xx]\\)$",
260
+ "instructions": {
261
+ "ADC": 97,
262
+ "AND": 33,
263
+ "CMP": 193,
264
+ "EOR": 65,
265
+ "LDA": 161,
266
+ "ORA": 1,
267
+ "SBC": 225,
268
+ "STA": 129
269
+ }
270
+ },
271
+ DirectPageIndirectIndexedY: {
272
+ "shorthand": "dp_ind_y",
273
+ "operands": ["Direct"],
274
+ "size": 2,
275
+ "formatString": "(${0:X2}), Y",
276
+ "parseRegex": "^\\(\\$([A-Fa-f0-9]{2})\\),\\s?[Yy]$",
277
+ "instructions": {
278
+ "ADC": 113,
279
+ "AND": 49,
280
+ "CMP": 209,
281
+ "EOR": 81,
282
+ "LDA": 177,
283
+ "ORA": 17,
284
+ "SBC": 241,
285
+ "STA": 145
286
+ }
287
+ },
288
+ DirectPageIndirectLongIndexedY: {
289
+ "shorthand": "dp_indl_y",
290
+ "operands": ["Direct"],
291
+ "size": 2,
292
+ "formatString": "[${0:X2}], Y",
293
+ "parseRegex": "^\\[\\$([A-Fa-f0-9]{2})\\],\\s?[Yy]$",
294
+ "instructions": {
295
+ "ADC": 119,
296
+ "AND": 55,
297
+ "CMP": 215,
298
+ "EOR": 87,
299
+ "LDA": 183,
300
+ "ORA": 23,
301
+ "SBC": 247,
302
+ "STA": 151
303
+ }
304
+ },
305
+ Immediate: {
306
+ "shorthand": "imm",
307
+ "operands": ["Immediate"],
308
+ "size": 2,
309
+ "formatString": "#${0:X2}",
310
+ "parseRegex": "^#(\\$[A-Fa-f0-9]{2,4}|\\$?[&^*][A-Za-z0-9-+_]+)$",
311
+ "instructions": {
312
+ "ADC": 105,
313
+ "AND": 41,
314
+ "BIT": 137,
315
+ "CMP": 201,
316
+ "CPX": 224,
317
+ "CPY": 192,
318
+ "EOR": 73,
319
+ "LDA": 169,
320
+ "LDX": 162,
321
+ "LDY": 160,
322
+ "ORA": 9,
323
+ "REP": 194,
324
+ "SBC": 233,
325
+ "SEP": 226
326
+ }
327
+ },
328
+ Implied: {
329
+ "shorthand": "imp",
330
+ "operands": [],
331
+ "size": 1,
332
+ "formatString": null,
333
+ "parseRegex": null,
334
+ "instructions": {
335
+ "CLC": 24,
336
+ "CLD": 216,
337
+ "CLI": 88,
338
+ "CLV": 184,
339
+ "DEX": 202,
340
+ "DEY": 136,
341
+ "INX": 232,
342
+ "INY": 200,
343
+ "NOP": 234,
344
+ "SEC": 56,
345
+ "SED": 248,
346
+ "SEI": 120,
347
+ "STP": 219,
348
+ "TAX": 170,
349
+ "TAY": 168,
350
+ "TCD": 91,
351
+ "TCS": 27,
352
+ "TDC": 123,
353
+ "TSC": 59,
354
+ "TSX": 186,
355
+ "TXA": 138,
356
+ "TXS": 154,
357
+ "TXY": 155,
358
+ "TYA": 152,
359
+ "TYX": 187,
360
+ "WAI": 203,
361
+ "WDM": 66,
362
+ "XBA": 235,
363
+ "XCE": 251
364
+ }
365
+ },
366
+ Accumulator: {
367
+ "shorthand": "acc",
368
+ "operands": [],
369
+ "size": 1,
370
+ "formatString": null,
371
+ "parseRegex": null,
372
+ "instructions": {
373
+ "ASL": 10,
374
+ "DEC": 58,
375
+ "INC": 26,
376
+ "LSR": 74,
377
+ "ROL": 42,
378
+ "ROR": 106
379
+ }
380
+ },
381
+ PCRelative: {
382
+ "shorthand": "rel",
383
+ "operands": ["Relative"],
384
+ "size": 2,
385
+ "formatString": "{0}",
386
+ "parseRegex": "^([A-Za-z_][A-Za-z0-9_]*|\\$[A-Fa-f0-9]{2})$",
387
+ "instructions": {
388
+ "BPL": 16,
389
+ "BMI": 48,
390
+ "BRA": 128,
391
+ "BCC": 144,
392
+ "BCS": 176,
393
+ "BNE": 208,
394
+ "BEQ": 240,
395
+ "BVC": 80,
396
+ "BVS": 112
397
+ }
398
+ },
399
+ PCRelativeLong: {
400
+ "shorthand": "rel16",
401
+ "operands": ["RelativeLong"],
402
+ "size": 3,
403
+ "formatString": "{0}",
404
+ "parseRegex": "^([A-Za-z_][A-Za-z0-9_]*|\\$[A-Fa-f0-9]{4})$",
405
+ "instructions": {
406
+ "BRL": 130,
407
+ "PER": 98
408
+ }
409
+ },
410
+ StackRelative: {
411
+ "shorthand": "stkr",
412
+ "operands": ["Byte"],
413
+ "size": 2,
414
+ "formatString": "${0:X2}, S",
415
+ "parseRegex": "^\\$([A-Fa-f0-9]{2}),\\s?[Ss]$",
416
+ "instructions": {
417
+ "ADC": 99,
418
+ "AND": 35,
419
+ "CMP": 195,
420
+ "EOR": 67,
421
+ "LDA": 163,
422
+ "ORA": 3,
423
+ "SBC": 227,
424
+ "STA": 131
425
+ }
426
+ },
427
+ StackRelativeIndirectIndexedY: {
428
+ "shorthand": "stkr_ind_y",
429
+ "operands": ["Byte"],
430
+ "size": 2,
431
+ "formatString": "(${0:X2}, S), Y",
432
+ "parseRegex": "^\\(\\$([A-Fa-f0-9]{2}),\\s?[Ss]\\),\\s?[Yy]$",
433
+ "instructions": {
434
+ "ADC": 115,
435
+ "AND": 51,
436
+ "CMP": 211,
437
+ "EOR": 83,
438
+ "LDA": 179,
439
+ "ORA": 19,
440
+ "SBC": 243,
441
+ "STA": 147
442
+ }
443
+ },
444
+ BlockMove: {
445
+ "shorthand": "src_dest",
446
+ "operands": ["Byte", "Byte"],
447
+ "size": 3,
448
+ "formatString": "#${0:X2}, #${1:X2}",
449
+ "parseRegex": "^#\\$([A-Fa-f0-9]{2}|\\^[A-Za-z0-9-+_]+),\\s?#\\$([A-Fa-f0-9]{2}|\\^[A-Za-z0-9-+_]+)$",
450
+ "instructions": {
451
+ "MVN": 84,
452
+ "MVP": 68
453
+ }
454
+ },
455
+ StackInterrupt: {
456
+ "shorthand": "stk_int",
457
+ "operands": ["Byte"],
458
+ "size": 2,
459
+ "formatString": "#${0:X2}",
460
+ "parseRegex": "^#\\$([A-Fa-f0-9]{2})$",
461
+ "instructions": {
462
+ "BRK": 0,
463
+ "COP": 2
464
+ }
465
+ },
466
+ Stack: {
467
+ "shorthand": "stk",
468
+ "operands": [],
469
+ "size": 1,
470
+ "formatString": null,
471
+ "parseRegex": null,
472
+ "instructions": {
473
+ "PHA": 72,
474
+ "PHB": 139,
475
+ "PHD": 11,
476
+ "PHK": 75,
477
+ "PHP": 8,
478
+ "PHX": 218,
479
+ "PHY": 90,
480
+ "PLA": 104,
481
+ "PLB": 171,
482
+ "PLD": 43,
483
+ "PLP": 40,
484
+ "PLX": 250,
485
+ "PLY": 122,
486
+ "RTI": 64,
487
+ "RTL": 107,
488
+ "RTS": 96
489
+ }
490
+ }
491
+ };
492
+
493
+ //#endregion
494
+ //#region snes/vectors.json
495
+ var vectors_default = {
496
+ "8448": "INIDISP",
497
+ "8449": "OBJSEL",
498
+ "8450": "OAMADDL",
499
+ "8451": "OAMADDH",
500
+ "8452": "OAMDATA",
501
+ "8453": "BGMODE",
502
+ "8454": "MOSAIC",
503
+ "8455": "BG1SC",
504
+ "8456": "BG2SC",
505
+ "8457": "BG3SC",
506
+ "8458": "BG4SC",
507
+ "8459": "BG12NBA",
508
+ "8460": "BG34NBA",
509
+ "8461": "BG1HOFS",
510
+ "8462": "BG1VOFS",
511
+ "8463": "BG2HOFS",
512
+ "8464": "BG2VOFS",
513
+ "8465": "BG3HOFS",
514
+ "8466": "BG3VOFS",
515
+ "8467": "BG4HOFS",
516
+ "8468": "BG4VOFS",
517
+ "8469": "VMAIN",
518
+ "8470": "VMADDL",
519
+ "8471": "VMADDH",
520
+ "8472": "VMDATAL",
521
+ "8473": "VMDATAH",
522
+ "8474": "M7SEL",
523
+ "8475": "M7A",
524
+ "8476": "M7B",
525
+ "8477": "M7C",
526
+ "8478": "M7D",
527
+ "8479": "M7X",
528
+ "8480": "M7Y",
529
+ "8481": "CGADD",
530
+ "8482": "CGDATA",
531
+ "8483": "W12SEL",
532
+ "8484": "W34SEL",
533
+ "8485": "WOBJSEL",
534
+ "8486": "WH0",
535
+ "8487": "WH1",
536
+ "8488": "WH2",
537
+ "8489": "WH3",
538
+ "8490": "WBGLOG",
539
+ "8491": "WOBJLOG",
540
+ "8492": "_TM",
541
+ "8493": "_TS",
542
+ "8494": "TMW",
543
+ "8495": "TSW",
544
+ "8496": "CGWSEL",
545
+ "8497": "CGADSUB",
546
+ "8498": "COLDATA",
547
+ "8499": "SETINI",
548
+ "8500": "MPYL",
549
+ "8501": "MPYM",
550
+ "8502": "MPYH",
551
+ "8503": "SLHV",
552
+ "8504": "OAMDATAREAD",
553
+ "8505": "VMDATALREAD",
554
+ "8506": "VMDATAHREAD",
555
+ "8507": "CGDATAREAD",
556
+ "8508": "OPHCT",
557
+ "8509": "OPVCT",
558
+ "8510": "STAT77",
559
+ "8511": "STAT78",
560
+ "8512": "APUIO0",
561
+ "8513": "APUIO1",
562
+ "8514": "APUIO2",
563
+ "8515": "APUIO3",
564
+ "8576": "WMDATA",
565
+ "8577": "WMADDL",
566
+ "8578": "WMADDM",
567
+ "8579": "WMADDH",
568
+ "16406": "JOYSER0",
569
+ "16407": "JOYSER1",
570
+ "16896": "NMITIMEN",
571
+ "16897": "WRIO",
572
+ "16898": "WRMPYA",
573
+ "16899": "WRMPYB",
574
+ "16900": "WRDIVL",
575
+ "16901": "WRDIVH",
576
+ "16902": "WRDIVB",
577
+ "16903": "HTIMEL",
578
+ "16904": "HTIMEH",
579
+ "16905": "VTIMEL",
580
+ "16906": "VTIMEH",
581
+ "16907": "MDMAEN",
582
+ "16908": "HDMAEN",
583
+ "16909": "MEMSEL",
584
+ "16912": "RDNMI",
585
+ "16913": "TIMEUP",
586
+ "16914": "HVBJOY",
587
+ "16915": "RDIO",
588
+ "16916": "RDDIVL",
589
+ "16917": "RDDIVH",
590
+ "16918": "RDMPYL",
591
+ "16919": "RDMPYH",
592
+ "16920": "JOY1L",
593
+ "16921": "JOY1H",
594
+ "16922": "JOY2L",
595
+ "16923": "JOY2H",
596
+ "16924": "JOY3L",
597
+ "16925": "JOY3H",
598
+ "16926": "JOY4L",
599
+ "16927": "JOY4H",
600
+ "17152": "DMAP0",
601
+ "17153": "BBAD0",
602
+ "17154": "A1T0L",
603
+ "17155": "A1T0H",
604
+ "17156": "A1B0",
605
+ "17157": "DAS0L",
606
+ "17158": "DAS0H",
607
+ "17159": "DASB0",
608
+ "17160": "A2A0L",
609
+ "17161": "A2A0H",
610
+ "17162": "NLTR0",
611
+ "17168": "DMAP1",
612
+ "17169": "BBAD1",
613
+ "17170": "A1T1L",
614
+ "17171": "A1T1H",
615
+ "17172": "A1B1",
616
+ "17173": "DAS1L",
617
+ "17174": "DAS1H",
618
+ "17175": "DASB1",
619
+ "17176": "A2A1L",
620
+ "17177": "A2A1H",
621
+ "17178": "NLTR1",
622
+ "17184": "DMAP2",
623
+ "17185": "BBAD2",
624
+ "17186": "A1T2L",
625
+ "17187": "A1T2H",
626
+ "17188": "A1B2",
627
+ "17189": "DAS2L",
628
+ "17190": "DAS2H",
629
+ "17191": "DASB2",
630
+ "17192": "A2A2L",
631
+ "17193": "A2A2H",
632
+ "17194": "NLTR2",
633
+ "17200": "DMAP3",
634
+ "17201": "BBAD3",
635
+ "17202": "A1T3L",
636
+ "17203": "A1T3H",
637
+ "17204": "A1B3",
638
+ "17205": "DAS3L",
639
+ "17206": "DAS3H",
640
+ "17207": "DASB3",
641
+ "17208": "A2A3L",
642
+ "17209": "A2A3H",
643
+ "17210": "NLTR3",
644
+ "17216": "DMAP4",
645
+ "17217": "BBAD4",
646
+ "17218": "A1T4L",
647
+ "17219": "A1T4H",
648
+ "17220": "A1B4",
649
+ "17221": "DAS4L",
650
+ "17222": "DAS4H",
651
+ "17223": "DASB4",
652
+ "17224": "A2A4L",
653
+ "17225": "A2A4H",
654
+ "17226": "NLTR4",
655
+ "17232": "DMAP5",
656
+ "17233": "BBAD5",
657
+ "17234": "A1T5L",
658
+ "17235": "A1T5H",
659
+ "17236": "A1B5",
660
+ "17237": "DAS5L",
661
+ "17238": "DAS5H",
662
+ "17239": "DASB5",
663
+ "17240": "A2A5L",
664
+ "17241": "A2A5H",
665
+ "17242": "NLTR5",
666
+ "17248": "DMAP6",
667
+ "17249": "BBAD6",
668
+ "17250": "A1T6L",
669
+ "17251": "A1T6H",
670
+ "17252": "A1B6",
671
+ "17253": "DAS6L",
672
+ "17254": "DAS6H",
673
+ "17255": "DASB6",
674
+ "17256": "A2A6L",
675
+ "17257": "A2A6H",
676
+ "17258": "NLTR6",
677
+ "17264": "DMAP7",
678
+ "17265": "BBAD7",
679
+ "17266": "A1T7L",
680
+ "17267": "A1T7H",
681
+ "17268": "A1B7",
682
+ "17269": "DAS7L",
683
+ "17270": "DAS7H",
684
+ "17271": "DASB7",
685
+ "17272": "A2A7L",
686
+ "17273": "A2A7H",
687
+ "17274": "NLTR7"
688
+ };
689
+
690
+ //#endregion
691
+ //#region snes/headers.json
692
+ var headers_default = [{
693
+ "address": 65456,
694
+ "condition": "values.developerId === 51",
695
+ "parts": [
696
+ {
697
+ "name": "makerCode",
698
+ "size": 2,
699
+ "type": "string"
700
+ },
701
+ {
702
+ "name": "gameCode",
703
+ "size": 4,
704
+ "type": "string"
705
+ },
706
+ {
707
+ "name": "reserved",
708
+ "size": 10,
709
+ "type": "byte",
710
+ "value": 0
711
+ }
712
+ ]
713
+ }, {
714
+ "address": 65472,
715
+ "parts": [
716
+ {
717
+ "name": "gameTitle",
718
+ "size": 21,
719
+ "type": "string"
720
+ },
721
+ {
722
+ "name": "mapMode",
723
+ "size": 1,
724
+ "type": "byte"
725
+ },
726
+ {
727
+ "name": "chipset",
728
+ "size": 1,
729
+ "type": "byte"
730
+ },
731
+ {
732
+ "name": "romSize",
733
+ "size": 1,
734
+ "type": "byte"
735
+ },
736
+ {
737
+ "name": "ramSize",
738
+ "size": 1,
739
+ "type": "byte"
740
+ },
741
+ {
742
+ "name": "countryCode",
743
+ "size": 1,
744
+ "type": "byte"
745
+ },
746
+ {
747
+ "name": "developerId",
748
+ "size": 1,
749
+ "type": "byte"
750
+ },
751
+ {
752
+ "name": "gameVersion",
753
+ "size": 1,
754
+ "type": "byte"
755
+ },
756
+ {
757
+ "name": "compliment",
758
+ "size": 2,
759
+ "type": "word"
760
+ },
761
+ {
762
+ "name": "checksum",
763
+ "size": 2,
764
+ "type": "word"
765
+ },
766
+ {
767
+ "name": "reserved",
768
+ "size": 4,
769
+ "type": "byte",
770
+ "value": 0
771
+ },
772
+ {
773
+ "name": "nativeCop",
774
+ "size": 2,
775
+ "type": "entry"
776
+ },
777
+ {
778
+ "name": "nativeBrk",
779
+ "size": 2,
780
+ "type": "entry"
781
+ },
782
+ {
783
+ "name": "nativeAbort",
784
+ "size": 2,
785
+ "type": "entry"
786
+ },
787
+ {
788
+ "name": "nativeNmi",
789
+ "size": 2,
790
+ "type": "entry"
791
+ },
792
+ {
793
+ "name": "reserved",
794
+ "size": 2,
795
+ "type": "byte",
796
+ "value": 0
797
+ },
798
+ {
799
+ "name": "nativeIrq",
800
+ "size": 2,
801
+ "type": "entry"
802
+ },
803
+ {
804
+ "name": "reserved",
805
+ "size": 4,
806
+ "type": "byte",
807
+ "value": 0
808
+ },
809
+ {
810
+ "name": "emulationCop",
811
+ "size": 2,
812
+ "type": "entry"
813
+ },
814
+ {
815
+ "name": "reserved",
816
+ "size": 2,
817
+ "type": "byte",
818
+ "value": 0
819
+ },
820
+ {
821
+ "name": "emulationAbort",
822
+ "size": 2,
823
+ "type": "entry"
824
+ },
825
+ {
826
+ "name": "emulationNmi",
827
+ "size": 2,
828
+ "type": "entry"
829
+ },
830
+ {
831
+ "name": "emulationReset",
832
+ "size": 2,
833
+ "type": "entry"
834
+ },
835
+ {
836
+ "name": "emulationBrk",
837
+ "size": 2,
838
+ "type": "entry"
839
+ }
840
+ ]
841
+ }];
842
+
843
+ //#endregion
4
844
  //#region src/rom/state.ts
5
845
  /**
6
846
  * Lightweight ROM state placeholder used during early development.
@@ -808,23 +1648,6 @@ var CompressionRegistry = class {
808
1648
  //#endregion
809
1649
  //#region src/types/files.ts
810
1650
  /**
811
- * Types that should have a compression header by default but should not be compressed
812
- */
813
- const UNCOMPRESSED_TYPES = [
814
- "Bitmap",
815
- "Tilemap",
816
- "Tileset",
817
- "Spritemap",
818
- "Meta17"
819
- ];
820
- /**
821
- * Type guard to check if a type is an uncompressed type
822
- * Works with both BinType enum values and string values
823
- */
824
- function isUncompressedType(type) {
825
- return UNCOMPRESSED_TYPES.includes(type);
826
- }
827
- /**
828
1651
  * Chunk file for ROM processing
829
1652
  * Converted from GaiaLib/Types/ChunkFile.cs
830
1653
  */
@@ -851,7 +1674,7 @@ var ChunkFile = class {
851
1674
  this.size = size;
852
1675
  this.location = location;
853
1676
  this.mnemonics = {};
854
- this.compressed = isUncompressedType(type.type) ? false : void 0;
1677
+ this.compressed = type.compressed;
855
1678
  this.type = type;
856
1679
  }
857
1680
  };
@@ -897,7 +1720,7 @@ function enrichWithRawDataFromDbFile(rom, chunkFile, compression, dbFile, fileTy
897
1720
  }
898
1721
  let length = dbFile.end - start;
899
1722
  let fileData;
900
- if (dbFile.compressed === true) {
1723
+ if (dbFile.compressed === true && compression) {
901
1724
  const expanded = compression.expand(rom, start, length);
902
1725
  fileData = combineHeader(expanded, 0, expanded.length, header, fileType.type);
903
1726
  } else {
@@ -950,12 +1773,12 @@ var ChunkFileUtils = class {
950
1773
  */
951
1774
  static calculateSize(chunkFile) {
952
1775
  if (!chunkFile.parts) {
953
- let size$1 = chunkFile.rawData?.length ?? chunkFile.size;
1776
+ let size = chunkFile.rawData?.length ?? chunkFile.size;
954
1777
  if (chunkFile.type.header === -2 || chunkFile.compressed === false) {
955
- size$1 += 2;
956
- chunkFile.size = size$1;
1778
+ size += 2;
1779
+ chunkFile.size = size;
957
1780
  }
958
- return size$1;
1781
+ return size;
959
1782
  }
960
1783
  let size = 0;
961
1784
  for (let x = 0; x < chunkFile.parts.length; x++) {
@@ -1697,18 +2520,18 @@ var DbFile = class {
1697
2520
  group;
1698
2521
  scene;
1699
2522
  constructor(data) {
1700
- this.name = data.name ?? "";
1701
- this.type = data.type ?? "";
1702
- this.start = data.start ?? void 0;
1703
- this.end = data.end ?? 0;
2523
+ if (!data.name) throw new Error("Name is required");
2524
+ if (!data.type) throw new Error("Type is required");
2525
+ if (typeof data.start !== "number") throw new Error("Start is required");
2526
+ if (typeof data.end !== "number") throw new Error("End is required");
2527
+ this.name = data.name;
2528
+ this.type = data.type;
2529
+ this.start = data.start;
2530
+ this.end = data.end;
1704
2531
  this.compressed = data.compressed ?? void 0;
1705
2532
  this.upper = data.upper ?? void 0;
1706
2533
  this.group = data.group || void 0;
1707
2534
  this.scene = data.scene || void 0;
1708
- if (!this.name) throw new Error("Name is required");
1709
- if (!this.type) throw new Error("Type is required");
1710
- if (this.start === void 0) throw new Error("Start is required");
1711
- if (!this.end) throw new Error("End is required");
1712
2535
  }
1713
2536
  };
1714
2537
  var DbFileType = class {
@@ -1718,6 +2541,7 @@ var DbFileType = class {
1718
2541
  isPatch;
1719
2542
  isBlock;
1720
2543
  header;
2544
+ compressed;
1721
2545
  constructor(data) {
1722
2546
  this.name = data.name ?? "";
1723
2547
  this.extension = data.extension ?? "";
@@ -1725,6 +2549,7 @@ var DbFileType = class {
1725
2549
  this.isPatch = data.isPatch ?? false;
1726
2550
  this.isBlock = data.isBlock ?? false;
1727
2551
  this.header = data.header ?? 0;
2552
+ this.compressed = data.compressed ?? void 0;
1728
2553
  if (!this.name) throw new Error("Name is required");
1729
2554
  if (!this.extension) throw new Error("Extension is required");
1730
2555
  if (!this.type) throw new Error("Type is required");
@@ -1764,17 +2589,17 @@ var DbAddressingMode = class {
1764
2589
  parseRegex;
1765
2590
  instructions;
1766
2591
  constructor(data) {
1767
- this.name = data.name ?? "";
1768
- this.shorthand = data.shorthand ?? "";
2592
+ if (!data.name) throw new Error("Addressing mode name is required");
2593
+ if (!data.shorthand) throw new Error("Addressing mode shorthand is required");
2594
+ if (!data.instructions) throw new Error("Addressing mode instructions are required");
2595
+ if (!data.size) throw new Error("Addressing mode size is required");
2596
+ this.name = data.name;
2597
+ this.shorthand = data.shorthand;
1769
2598
  this.operands = data.operands ?? [];
1770
2599
  this.size = data.size ?? 1;
1771
2600
  this.formatString = data.formatString ?? void 0;
1772
2601
  this.parseRegex = data.parseRegex ?? void 0;
1773
- this.instructions = data.instructions ?? void 0;
1774
- if (!this.name) throw new Error("Addressing mode name is required");
1775
- if (!this.shorthand) throw new Error("Addressing mode shorthand is required");
1776
- if (!this.instructions) throw new Error("Addressing mode instructions are required");
1777
- if (!this.size) throw new Error("Addressing mode size is required");
2602
+ this.instructions = data.instructions;
1778
2603
  }
1779
2604
  };
1780
2605
 
@@ -1792,14 +2617,14 @@ var DbStringCommand = class {
1792
2617
  halt;
1793
2618
  dictionary;
1794
2619
  constructor(data) {
1795
- this.id = data.id ?? void 0;
1796
- this.name = data.name ?? "";
2620
+ if (typeof data.id !== "number") throw new Error("Id is required");
2621
+ if (!data.name) throw new Error("Name is required");
2622
+ this.id = data.id;
2623
+ this.name = data.name;
1797
2624
  this.types = data.types ?? [];
1798
2625
  this.delimiter = data.delimiter ?? void 0;
1799
2626
  this.halt = data.halt ?? false;
1800
2627
  this.dictionary = data.dictionary ?? void 0;
1801
- if (!this.id && this.id !== 0) throw new Error("Id is required");
1802
- if (!this.name) throw new Error("Name is required");
1803
2628
  }
1804
2629
  };
1805
2630
  var DbStringDictionary = class {
@@ -1809,14 +2634,14 @@ var DbStringDictionary = class {
1809
2634
  name;
1810
2635
  entries;
1811
2636
  constructor(data) {
2637
+ if (typeof data.base !== "number" && typeof data.command !== "number") throw new Error("Base or command is required");
2638
+ if (!data.name) throw new Error("Name is required");
2639
+ if (!data.entries || data.entries.length === 0) throw new Error("Entries is required");
1812
2640
  this.base = data.base ?? void 0;
1813
2641
  this.range = data.range ?? 0;
1814
2642
  this.command = data.command ?? void 0;
1815
- this.name = data.name ?? "";
1816
- this.entries = data.entries ?? void 0;
1817
- if (this.base === void 0 && this.command === void 0) throw new Error("Base or command is required");
1818
- if (!this.name) throw new Error("Name is required");
1819
- if (!this.entries) throw new Error("Entries is required");
2643
+ this.name = data.name;
2644
+ this.entries = data.entries;
1820
2645
  if (this.base !== void 0) this.range = this.base + this.entries.length;
1821
2646
  }
1822
2647
  };
@@ -1835,11 +2660,15 @@ var DbStringType = class {
1835
2660
  dictionaries;
1836
2661
  dictionaryLookup;
1837
2662
  constructor(data) {
1838
- this.name = data.name ?? "";
1839
- this.delimiter = data.delimiter ?? "";
1840
- this.terminator = data.terminator ?? 0;
2663
+ if (!data.name) throw new Error("Name is required");
2664
+ if (!data.delimiter) throw new Error("Delimiter is required");
2665
+ if (typeof data.terminator !== "number") throw new Error("Terminator is required");
2666
+ if (!data.layers || !data.layers.length) throw new Error("Layers are required");
2667
+ this.name = data.name;
2668
+ this.delimiter = data.delimiter;
2669
+ this.terminator = data.terminator;
1841
2670
  this.commands = data.commands ?? {};
1842
- this.layers = data.layers ?? [];
2671
+ this.layers = data.layers;
1843
2672
  this.greedyTerminator = data.greedyTerminator ?? false;
1844
2673
  this.dictionaries = data.dictionaries ?? {};
1845
2674
  this.commandLookup = Object.values(this.commands).reduce((acc, x) => {
@@ -1848,12 +2677,8 @@ var DbStringType = class {
1848
2677
  }, {});
1849
2678
  this.dictionaryLookup = Object.values(this.dictionaries).flatMap((y) => y.entries.map((z, ix) => ({
1850
2679
  text: z,
1851
- id: y.command << 8 | y.base + ix
2680
+ id: (y.command ?? 0) | (y.base ?? 0 + ix)
1852
2681
  }))).sort((a, b) => b.text.length - a.text.length);
1853
- if (!this.name) throw new Error("Name is required");
1854
- if (!this.delimiter) throw new Error("Delimiter is required");
1855
- if (!this.terminator && this.terminator !== 0) throw new Error("Terminator is required");
1856
- if (!this.layers.length) throw new Error("Layers are required");
1857
2682
  }
1858
2683
  };
1859
2684
  /**
@@ -1891,13 +2716,13 @@ var CopDef = class {
1891
2716
  parts;
1892
2717
  halt;
1893
2718
  constructor(data) {
1894
- this.name = data.name ?? void 0;
1895
- this.id = data.id ?? void 0;
2719
+ if (!data.name) throw new Error("Name is required");
2720
+ if (typeof data.id !== "number") throw new Error("ID is required");
2721
+ this.name = data.name;
2722
+ this.id = data.id;
1896
2723
  this.parts = data.parts ?? [];
1897
2724
  this.halt = data.halt ?? false;
1898
2725
  this.size = data.size ?? 0;
1899
- if (!this.name) throw new Error("Name is required");
1900
- if (this.id === void 0) throw new Error("ID is required");
1901
2726
  }
1902
2727
  };
1903
2728
 
@@ -2047,13 +2872,17 @@ async function listDirectory(dirPath, options = {}) {
2047
2872
  for (const item of items) {
2048
2873
  const itemPath = pathModule.join(fullPath, item);
2049
2874
  const stats = await stat(itemPath);
2875
+ const isFile = stats.isFile();
2876
+ const extIx = isFile ? item.indexOf(".") : -1;
2877
+ const ext = extIx > 0 ? item.substring(extIx + 1) : null;
2050
2878
  const entry = {
2051
- name: item,
2879
+ name: extIx > 0 ? item.substring(0, extIx) : item,
2052
2880
  path: itemPath,
2053
- isDirectory: stats.isDirectory(),
2054
- isFile: stats.isFile()
2881
+ extension: ext,
2882
+ isFile,
2883
+ isDirectory: stats.isDirectory()
2055
2884
  };
2056
- if (extension && entry.isFile && !entry.name.endsWith(extension)) continue;
2885
+ if (extension && ext !== extension) continue;
2057
2886
  if (filter && !filter(entry)) continue;
2058
2887
  entries.push(entry);
2059
2888
  if (recursive && entry.isDirectory) {
@@ -2296,129 +3125,6 @@ function decodeBase64String(base64String) {
2296
3125
  }
2297
3126
  }
2298
3127
 
2299
- //#endregion
2300
- //#region src/utils/debug-export.ts
2301
- /**
2302
- * Debug utility to export processing results as JSON for comparison
2303
- */
2304
- var DebugExporter = class {
2305
- /**
2306
- * Export chunk files to JSON for comparison with C# output
2307
- */
2308
- static exportChunkFiles(files, filename) {
2309
- const exportData = {
2310
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2311
- totalFiles: files.length,
2312
- files: files.map((file) => ({
2313
- name: file.name,
2314
- type: file.type,
2315
- size: file.size,
2316
- location: file.location,
2317
- bank: file.bank,
2318
- upper: file.upper,
2319
- compressed: file.compressed,
2320
- hasTextData: !!file.textData,
2321
- textDataLength: file.textData?.length || 0,
2322
- hasParts: !!file.parts,
2323
- partsCount: file.parts?.length || 0,
2324
- hasIncludes: !!file.includes,
2325
- includesCount: file.includes?.size || 0,
2326
- includesList: file.includes ? Array.from(file.includes).sort() : [],
2327
- parts: file.parts?.map((part) => ({
2328
- label: part.label,
2329
- location: part.location,
2330
- size: part.size,
2331
- objListCount: part.objList?.length || 0,
2332
- hasObjList: !!part.objList,
2333
- objList: part.objList?.map((obj) => ({
2334
- location: obj.location,
2335
- size: obj.size,
2336
- hasObject: !!obj.object,
2337
- objectType: obj.object?.constructor?.name || "unknown"
2338
- })) || []
2339
- })) || []
2340
- }))
2341
- };
2342
- try {
2343
- writeFileSync(filename, JSON.stringify(exportData, null, 2));
2344
- console.log(`📄 Exported ${files.length} files to ${filename}`);
2345
- } catch (error) {
2346
- console.error(`❌ Failed to export to ${filename}:`, error);
2347
- }
2348
- }
2349
- /**
2350
- * Export patch application summary
2351
- */
2352
- static exportPatchSummary(originalFiles, patchedFiles, patches, filename) {
2353
- const summary = {
2354
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2355
- originalFileCount: originalFiles.length,
2356
- patchedFileCount: patchedFiles.length,
2357
- patchCount: patches.length,
2358
- patches: patches.map((patch) => ({
2359
- name: patch.name,
2360
- partsCount: patch.parts?.length || 0,
2361
- includesCount: patch.includes?.size || 0,
2362
- includes: patch.includes ? Array.from(patch.includes).sort() : []
2363
- })),
2364
- sizeChanges: patchedFiles.map((file) => {
2365
- const original = originalFiles.find((f) => f.name === file.name);
2366
- return {
2367
- name: file.name,
2368
- originalSize: original?.size || 0,
2369
- patchedSize: file.size || 0,
2370
- sizeDelta: (file.size || 0) - (original?.size || 0),
2371
- originalPartsCount: original?.parts?.length || 0,
2372
- patchedPartsCount: file.parts?.length || 0,
2373
- partsCountDelta: (file.parts?.length || 0) - (original?.parts?.length || 0)
2374
- };
2375
- }).filter((change) => change.sizeDelta !== 0 || change.partsCountDelta !== 0)
2376
- };
2377
- try {
2378
- writeFileSync(filename, JSON.stringify(summary, null, 2));
2379
- console.log(`📊 Exported patch summary to ${filename}`);
2380
- } catch (error) {
2381
- console.error(`❌ Failed to export patch summary to ${filename}:`, error);
2382
- }
2383
- }
2384
- /**
2385
- * Export layout debugging information
2386
- */
2387
- static exportLayoutDebug(files, filename) {
2388
- const layoutData = {
2389
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2390
- totalFiles: files.length,
2391
- filesWithSize: files.filter((f) => (f.size || 0) > 0).length,
2392
- filesWithoutSize: files.filter((f) => (f.size || 0) === 0).length,
2393
- asmFiles: files.filter((f) => !!f.parts).length,
2394
- binaryFiles: files.filter((f) => !f.parts).length,
2395
- files: files.map((file) => ({
2396
- name: file.name,
2397
- size: file.size || 0,
2398
- hasSize: (file.size || 0) > 0,
2399
- isAsm: !!file.parts,
2400
- bank: file.bank,
2401
- upper: file.upper,
2402
- location: file.location,
2403
- partsCount: file.parts?.length || 0
2404
- })).sort((a, b) => {
2405
- const aAsm = a.isAsm ? 0 : 1;
2406
- const bAsm = b.isAsm ? 0 : 1;
2407
- if (aAsm !== bAsm) return aAsm - bAsm;
2408
- if (b.size !== a.size) return b.size - a.size;
2409
- return a.location - b.location;
2410
- }),
2411
- zeroSizeFiles: files.filter((f) => (f.size || 0) === 0).map((f) => f.name)
2412
- };
2413
- try {
2414
- writeFileSync(filename, JSON.stringify(layoutData, null, 2));
2415
- console.log(`🏗️ Exported layout debug info to ${filename}`);
2416
- } catch (error) {
2417
- console.error(`❌ Failed to export layout debug to ${filename}:`, error);
2418
- }
2419
- }
2420
- };
2421
-
2422
3128
  //#endregion
2423
3129
  //#region src/utils/index.ts
2424
3130
  /**
@@ -2530,16 +3236,16 @@ var DbPart = class {
2530
3236
  bank;
2531
3237
  order;
2532
3238
  constructor(data) {
2533
- this.name = data.name ?? "";
2534
- this.start = data.start ?? void 0;
2535
- this.end = data.end ?? 0;
2536
- this.type = data.type ?? "";
3239
+ if (typeof data.start !== "number") throw new Error("Start is required");
3240
+ if (!data.name) throw new Error("Name is required");
3241
+ if (!data.end) throw new Error("End is required");
3242
+ if (!data.type) throw new Error("Struct is required");
3243
+ this.name = data.name;
3244
+ this.start = data.start;
3245
+ this.end = data.end;
3246
+ this.type = data.type;
2537
3247
  this.bank = data.bank ?? void 0;
2538
3248
  this.order = data.order ?? void 0;
2539
- if (!this.name) throw new Error("Name is required");
2540
- if (this.start === void 0) throw new Error("Start is required");
2541
- if (!this.end) throw new Error("End is required");
2542
- if (!this.type) throw new Error("Struct is required");
2543
3249
  }
2544
3250
  };
2545
3251
 
@@ -2785,7 +3491,6 @@ var PostProcessor = class {
2785
3491
  //#region src/rom/extraction/writer.ts
2786
3492
  const isWindows = (() => {
2787
3493
  if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
2788
- if (typeof navigator !== "undefined" && navigator.userAgent) return navigator.userAgent.includes("Windows");
2789
3494
  return false;
2790
3495
  })();
2791
3496
  const NEWLINE = isWindows ? "\r\n" : "\n";
@@ -3249,13 +3954,13 @@ var AsmReader = class AsmReader {
3249
3954
  clearDestinationRegister(code, reg) {
3250
3955
  switch (code.mnem) {
3251
3956
  case "LDA":
3252
- reg.value["accumulator"] = void 0;
3957
+ delete reg.value["accumulator"];
3253
3958
  break;
3254
3959
  case "LDX":
3255
- reg.value["xIndex"] = void 0;
3960
+ delete reg.value["xIndex"];
3256
3961
  break;
3257
3962
  case "LDY":
3258
- reg.value["yIndex"] = void 0;
3963
+ delete reg.value["yIndex"];
3259
3964
  break;
3260
3965
  }
3261
3966
  }
@@ -3690,8 +4395,9 @@ var BlockReader = class {
3690
4395
  * Creates assembly ChunkFiles from DbBlocks (enriched with parts)
3691
4396
  */
3692
4397
  createChunkFilesFromDbBlocks() {
4398
+ const fileType = Object.values(this._root.fileTypes).find((x) => x.isBlock);
3693
4399
  for (const block of this._root.blocks) {
3694
- const chunkFile = createChunkFileFromDbBlock(block, Object.values(this._root.fileTypes).find((x) => x.isBlock), this._root.config.memoryMode);
4400
+ const chunkFile = createChunkFileFromDbBlock(block, fileType, this._root.config.memoryMode);
3695
4401
  this._enrichedChunks.push(chunkFile);
3696
4402
  }
3697
4403
  }
@@ -3850,6 +4556,7 @@ var RomLayout = class RomLayout {
3850
4556
  let offset = 0;
3851
4557
  while (remain > 0 && this.sfxFiles.length) {
3852
4558
  const file = this.sfxFiles.shift();
4559
+ if (!file) continue;
3853
4560
  file.location = start + offset;
3854
4561
  console.log(` ${file.location.toString(16).toUpperCase().padStart(6, "0")}: ${file.name}`);
3855
4562
  offset += file.size;
@@ -3962,12 +4669,15 @@ var RomProcessor = class RomProcessor {
3962
4669
  async repack(allFiles) {
3963
4670
  const patches = [];
3964
4671
  const asmFiles = [];
4672
+ const compression = this.writer.root.compression;
4673
+ const canCompress = !!compression;
4674
+ const conditionFiles = [];
3965
4675
  for (const file of allFiles) {
3966
4676
  if (file.type.type === "Patch") patches.push(file);
3967
4677
  else if (file.type.type !== "Assembly") {
3968
- if (file.compressed === true) if (this.writer.root.config.uncompress) file.compressed = false;
4678
+ if (file.compressed === true && canCompress) if (this.writer.root.config.uncompress) file.compressed = false;
3969
4679
  else {
3970
- let newData = this.writer.root.compression.compact(file.rawData, file.type.header);
4680
+ let newData = compression.compact(file.rawData, file.type.header);
3971
4681
  if (file.type.header) newData = new Uint8Array([...file.rawData.slice(0, file.type.header), ...newData]);
3972
4682
  file.rawData = newData;
3973
4683
  file.size = newData.length;
@@ -3975,27 +4685,34 @@ var RomProcessor = class RomProcessor {
3975
4685
  continue;
3976
4686
  }
3977
4687
  asmFiles.push(file);
3978
- if (!file.parts) {
3979
- const { blocks, includes, reqBank } = new Assembler(this.writer.root, file.textData).parseAssembly();
3980
- file.parts = blocks;
3981
- file.includes = includes;
3982
- file.bank = reqBank ?? void 0;
3983
- }
4688
+ conditionFiles.push(file.name);
4689
+ }
4690
+ for (const file of asmFiles) if (!file.parts) {
4691
+ const { blocks, includes, reqBank } = new Assembler(this.writer.root, file.textData, conditionFiles).parseAssembly();
4692
+ file.parts = blocks;
4693
+ file.includes = includes;
4694
+ file.bank = reqBank ?? void 0;
3984
4695
  }
3985
4696
  RomProcessor.applyPatches(asmFiles, patches);
3986
4697
  for (const file of allFiles) ChunkFileUtils.calculateSize(file);
3987
4698
  const pages = new RomLayout(allFiles, this.writer.root).organize();
3988
4699
  for (const file of asmFiles) ChunkFileUtils.rebase(file);
4700
+ const masterLookup = /* @__PURE__ */ new Map();
3989
4701
  for (const f of asmFiles) {
3990
4702
  const includeBlocks = asmFiles.filter((x) => f.includes?.has(x.name.toUpperCase())).flatMap((x) => x.parts).filter((b) => !!b.label);
3991
4703
  f.includeLookup = /* @__PURE__ */ new Map();
3992
4704
  for (const b of includeBlocks) if (b.label) f.includeLookup.set(b.label.toUpperCase(), b);
3993
- for (const b of (f.parts || []).filter((x) => !!x.label)) if (b.label) f.includeLookup.set(b.label.toUpperCase(), b);
4705
+ for (const b of f.parts) if (b.label) {
4706
+ const nameUpper = b.label.toUpperCase();
4707
+ masterLookup.set(nameUpper, b.location);
4708
+ f.includeLookup.set(nameUpper, b);
4709
+ }
3994
4710
  }
3995
- const blockLookup = /* @__PURE__ */ new Map();
3996
- for (const f of allFiles) blockLookup.set(f.name.toUpperCase(), f.location);
4711
+ const fileLookup = /* @__PURE__ */ new Map();
4712
+ for (const f of allFiles) fileLookup.set(f.name.toUpperCase(), f.location);
3997
4713
  this.writer.allocate(pages);
3998
- for (const file of allFiles) await this.writer.writeFile(file, blockLookup);
4714
+ for (const file of allFiles) await this.writer.writeFile(file, fileLookup);
4715
+ return masterLookup;
3999
4716
  }
4000
4717
  static applyPatches(asmFiles, patches) {
4001
4718
  for (const patch of patches.filter((x) => x.includes && x.includes.size > 0)) {
@@ -4041,19 +4758,13 @@ var RomWriter = class {
4041
4758
  bpsPath;
4042
4759
  outBuffer;
4043
4760
  romSize;
4044
- cartName;
4045
- makerCode;
4046
4761
  root;
4047
- constructor(root, cartName, makerCode) {
4048
- this.cartName = cartName;
4049
- this.makerCode = makerCode;
4762
+ constructor(root) {
4050
4763
  this.root = root;
4051
4764
  }
4052
4765
  async repack(files) {
4053
- await new RomProcessor(this).repack(files);
4054
- this.writeHeader();
4055
- this.writeEntryPoints(files.filter((x) => !!x.parts));
4056
- this.writeChecksum();
4766
+ const masterLookup = await new RomProcessor(this).repack(files);
4767
+ this.writeHeaders(masterLookup);
4057
4768
  return this.outBuffer;
4058
4769
  }
4059
4770
  allocate(pages) {
@@ -4067,36 +4778,93 @@ var RomWriter = class {
4067
4778
  this.romSize = bits;
4068
4779
  this.outBuffer = new Uint8Array(target);
4069
4780
  }
4070
- writeHeader() {
4781
+ writeHeaders(masterLookup) {
4782
+ const values = this.prepareHeaderValues();
4783
+ for (const header of this.root.headers) {
4784
+ if (header.condition && !eval(header.condition)) continue;
4785
+ this.writeHeader(header, values, masterLookup);
4786
+ }
4787
+ this.writeChecksum(values);
4788
+ }
4789
+ prepareHeaderValues() {
4790
+ const values = { ...this.root.config };
4791
+ values.romSize = this.romSize;
4792
+ values.checksum = 0;
4793
+ values.compliment = 65535;
4794
+ values.mapMode = 32 | (values.cpuMode === CpuMode.Fast ? 16 : 0) | (values.memoryMode === MemoryMapMode.Hi ? 1 : values.memoryMode === MemoryMapMode.ExHi ? 5 : 0);
4795
+ return values;
4796
+ }
4797
+ writeHeader(header, values, masterLookup) {
4071
4798
  const buf = this.outBuffer;
4072
- let pos = this.root.config.memoryMode === MemoryMapMode.Lo ? 32688 : 65456;
4073
- this.writeAscii(this.makerCode.padEnd(6, " "), pos);
4074
- pos += 6;
4075
- for (let i = 0; i < 10; i++) buf[pos++] = 0;
4076
- this.writeAscii(this.cartName.toUpperCase().padEnd(21, " "), pos);
4077
- pos += 21;
4078
- buf[pos++] = 32 | (this.root.config.cpuMode === CpuMode.Fast ? 16 : 0) | (this.root.config.memoryMode === MemoryMapMode.Hi ? 1 : this.root.config.memoryMode === MemoryMapMode.ExHi ? 5 : 0);
4079
- buf[pos++] = this.root.config.chipset;
4080
- buf[pos++] = this.romSize;
4081
- buf[pos++] = this.root.config.ramSize;
4082
- buf[pos++] = 1;
4083
- buf[pos++] = 51;
4084
- buf[pos++] = 0;
4085
- }
4086
- writeChecksum() {
4799
+ let pos = new Address(header.bank, header.address, this.root.config.memoryMode).toLocation();
4800
+ for (const part of header.parts) {
4801
+ let type = part.type;
4802
+ let value = part.value ?? values[part.name] ?? (type === "string" ? "" : 0);
4803
+ let size = part.size;
4804
+ if (!size) if (!type) {
4805
+ if (typeof value === "string") throw new Error(`String size for ${part.name} is not specified`);
4806
+ if (typeof value === "number") if (value <= 255) {
4807
+ size = 1;
4808
+ type = "byte";
4809
+ } else {
4810
+ size = 2;
4811
+ type = "word";
4812
+ }
4813
+ } else switch (type) {
4814
+ case "byte":
4815
+ size = 1;
4816
+ break;
4817
+ case "word":
4818
+ case "entry":
4819
+ size = 2;
4820
+ break;
4821
+ case "string": throw new Error(`String size for ${part.name} is not specified`);
4822
+ default: throw new Error(`Invalid type ${type} for ${part.name}`);
4823
+ }
4824
+ switch (part.type) {
4825
+ case "string":
4826
+ value = value.toString();
4827
+ value = value.length > size ? value.substring(0, size) : value.padEnd(size, " ");
4828
+ this.writeAscii(value, pos);
4829
+ break;
4830
+ case "byte":
4831
+ buf[pos] = value & 255;
4832
+ break;
4833
+ case "entry":
4834
+ let location = 0;
4835
+ if (typeof value === "string") location = value === "" ? 0 : masterLookup.get(value.toUpperCase()) ?? 0;
4836
+ else if (typeof value === "number") location = value;
4837
+ value = location;
4838
+ case "word":
4839
+ buf[pos] = value & 255;
4840
+ buf[pos + 1] = value >> 8 & 255;
4841
+ break;
4842
+ }
4843
+ part.value = value;
4844
+ part.size = size;
4845
+ part.type = type;
4846
+ pos += size;
4847
+ }
4848
+ }
4849
+ writeChecksum(values) {
4087
4850
  const buf = this.outBuffer;
4088
- let pos = this.root.config.memoryMode === MemoryMapMode.Lo ? 32732 : 65500;
4089
- buf[pos] = 255;
4090
- buf[pos + 1] = 255;
4091
- buf[pos + 2] = 0;
4092
- buf[pos + 3] = 0;
4093
4851
  let sum = 0;
4094
4852
  for (let i = 0; i < buf.length; i++) sum += buf[i];
4095
- buf[pos + 2] = sum & 255;
4096
- buf[pos + 3] = sum >> 8 & 255;
4097
4853
  const comp = ~sum;
4098
- buf[pos] = comp & 255;
4099
- buf[pos + 1] = comp >> 8 & 255;
4854
+ for (const header of this.root.headers) {
4855
+ if (header.condition && !eval(header.condition)) continue;
4856
+ let pos = new Address(header.bank, header.address, this.root.config.memoryMode).toLocation();
4857
+ for (const part of header.parts) {
4858
+ if (part.name === "checksum") {
4859
+ buf[pos] = sum & 255;
4860
+ buf[pos + 1] = sum >> 8 & 255;
4861
+ } else if (part.name === "compliment") {
4862
+ buf[pos] = comp & 255;
4863
+ buf[pos + 1] = comp >> 8 & 255;
4864
+ }
4865
+ pos += part.size;
4866
+ }
4867
+ }
4100
4868
  }
4101
4869
  writeEntryPoints(asmFiles) {
4102
4870
  const buf = this.outBuffer;
@@ -4111,7 +4879,7 @@ var RomWriter = class {
4111
4879
  }
4112
4880
  }
4113
4881
  }
4114
- async writeFile(file, _chunkLookup) {
4882
+ async writeFile(file, fileLookup) {
4115
4883
  const start = file.location;
4116
4884
  let pos = start;
4117
4885
  const buf = this.outBuffer;
@@ -4141,7 +4909,7 @@ var RomWriter = class {
4141
4909
  }
4142
4910
  } else if (file.parts && file.parts.length > 0) {
4143
4911
  if (file.parts[0].location !== file.location && (file.location || 0) !== 0) throw new Error("Assembly was not based properly");
4144
- this.parseAssembly(file.parts, _chunkLookup, file.includeLookup);
4912
+ this.parseAssembly(file.parts, fileLookup, file.includeLookup);
4145
4913
  }
4146
4914
  return pos - start;
4147
4915
  }
@@ -4153,11 +4921,12 @@ var RomWriter = class {
4153
4921
  * Parse assembly blocks and write binary data to output buffer
4154
4922
  * Converted from ext/GaiaLib/Rom/Rebuild/RomWriter.cs ParseAssembly method
4155
4923
  */
4156
- parseAssembly(blocks, chunkLookup, includeLookup) {
4924
+ parseAssembly(blocks, fileLookup, includeLookup) {
4157
4925
  if (!blocks) throw new Error("Assembly has not been parsed");
4158
4926
  const buf = this.outBuffer;
4159
4927
  let bix = 0;
4160
4928
  for (const block of blocks) {
4929
+ let oldPos = null;
4161
4930
  let position = block.location;
4162
4931
  const objList = block.objList;
4163
4932
  let oix = 0;
@@ -4165,7 +4934,7 @@ var RomWriter = class {
4165
4934
  const processObject = (obj, parentOp) => {
4166
4935
  let currentObj = obj;
4167
4936
  while (true) if (Array.isArray(currentObj)) {
4168
- for (const obj$1 of currentObj) processObject(obj$1, parentOp);
4937
+ for (const obj of currentObj) processObject(obj, parentOp);
4169
4938
  break;
4170
4939
  } else if (this.isTableEntry(currentObj)) {
4171
4940
  currentObj = currentObj.object;
@@ -4202,29 +4971,32 @@ var RomWriter = class {
4202
4971
  label = label.substring(0, operatorIdx);
4203
4972
  }
4204
4973
  const labelUpper = label.toUpperCase();
4205
- let target;
4974
+ let target = null;
4206
4975
  if (includeLookup.has(labelUpper)) {
4207
4976
  target = includeLookup.get(labelUpper);
4208
4977
  loc = target.location;
4209
- } else if (chunkLookup.has(labelUpper)) loc = chunkLookup.get(labelUpper);
4978
+ } else if (fileLookup.has(labelUpper)) loc = fileLookup.get(labelUpper);
4210
4979
  else {
4211
4980
  if (label.startsWith("#")) label = label.substring(1);
4212
4981
  if (label.startsWith("$")) label = label.substring(1);
4213
4982
  if (isRelative && label.length > 4) throw new Error(`Invalid relative operand '${label}'`);
4214
- else switch (label.length) {
4215
- case 1:
4216
- case 2:
4217
- currentObj = new Byte(parseInt(label, 16));
4218
- continue;
4219
- case 3:
4220
- case 4:
4221
- currentObj = new Word(parseInt(label, 16));
4222
- continue;
4223
- case 5:
4224
- case 6:
4225
- currentObj = new Long(parseInt(label, 16));
4226
- continue;
4227
- default: throw new Error(`Invalid operand '${label}'`);
4983
+ else {
4984
+ let num;
4985
+ switch (label.length) {
4986
+ case 1:
4987
+ case 2:
4988
+ currentObj = new Byte(parseInt(label, 16));
4989
+ continue;
4990
+ case 3:
4991
+ case 4:
4992
+ currentObj = new Word(parseInt(label, 16));
4993
+ continue;
4994
+ case 5:
4995
+ case 6:
4996
+ currentObj = new Long(parseInt(label, 16));
4997
+ continue;
4998
+ default: throw new Error(`Invalid operand '${label}'`);
4999
+ }
4228
5000
  }
4229
5001
  }
4230
5002
  let type = isRelative ? parentOp?.size === 3 ? AddressType.WRelative : AddressType.Relative : Address.typeFromCode(str[0]);
@@ -4234,7 +5006,7 @@ var RomWriter = class {
4234
5006
  if (type === AddressType.Unknown && !(loc < 128 || loc >= 4194176)) throw new Error("Relative out of range");
4235
5007
  }
4236
5008
  if (offset !== null) loc += offset;
4237
- else if (useMarker && target) {
5009
+ else if (useMarker && target instanceof AsmBlock) {
4238
5010
  let markerOffset = 0;
4239
5011
  for (const part of target.objList) if (this.isStringMarker(part)) {
4240
5012
  loc += markerOffset;
@@ -4321,6 +5093,36 @@ var RomWriter = class {
4321
5093
  }
4322
5094
  };
4323
5095
 
5096
+ //#endregion
5097
+ //#region src/database/header.ts
5098
+ var DbHeader = class {
5099
+ bank;
5100
+ address;
5101
+ condition;
5102
+ parts;
5103
+ constructor(data) {
5104
+ if (typeof data.address !== "number") throw new Error("Address is required");
5105
+ if (!data.parts || !data.parts.length) throw new Error("Parts are required");
5106
+ this.bank = data.bank ?? 0;
5107
+ this.address = data.address;
5108
+ this.condition = data.condition ?? void 0;
5109
+ this.parts = data.parts.map((p) => new DbHeaderPart(p));
5110
+ }
5111
+ };
5112
+ var DbHeaderPart = class {
5113
+ name;
5114
+ size;
5115
+ type;
5116
+ value;
5117
+ constructor(data) {
5118
+ if (!data.name) throw new Error("Name is required");
5119
+ this.name = data.name;
5120
+ this.size = data.size ?? 0;
5121
+ this.type = data.type ?? "";
5122
+ this.value = data.value ?? void 0;
5123
+ }
5124
+ };
5125
+
4324
5126
  //#endregion
4325
5127
  //#region src/database/root.ts
4326
5128
  /**
@@ -4330,33 +5132,6 @@ var DbRootUtils = class {
4330
5132
  /**
4331
5133
  * JSON serialization options
4332
5134
  */
4333
- /**
4334
- * Load database from a single file
4335
- */
4336
- static async fromFolder(folderPath, systemPath) {
4337
- return this.fromGameModule(await this.gameModuleFromFolder(folderPath, systemPath));
4338
- }
4339
- /**
4340
- * Load database from folder structure
4341
- */
4342
- static async gameModuleFromFolder(folderPath, systemPath) {
4343
- return {
4344
- mnemonics: await readJsonFile(`${folderPath}/mnemonics.json`),
4345
- overrides: await readJsonFile(`${folderPath}/overrides.json`),
4346
- rewrites: await readJsonFile(`${folderPath}/rewrites.json`),
4347
- blocks: await readJsonFile(`${folderPath}/blocks.json`),
4348
- files: await readJsonFile(`${folderPath}/files.json`),
4349
- config: await readJsonFile(`${folderPath}/config.json`),
4350
- labels: await readJsonFile(`${folderPath}/labels.json`),
4351
- structs: await readJsonFile(`${folderPath}/structs.json`),
4352
- copdef: await readJsonFile(`${folderPath}/copdef.json`),
4353
- addrModes: await readJsonFile(`${systemPath}/addressingModes.json`),
4354
- strings: await readJsonFile(`${folderPath}/stringTypes.json`),
4355
- transforms: await readJsonFile(`${folderPath}/transforms.json`),
4356
- groups: await readJsonFile(`${folderPath}/groups.json`),
4357
- fileTypes: await readJsonFile(`${folderPath}/fileTypes.json`)
4358
- };
4359
- }
4360
5135
  static fromGameModule(module) {
4361
5136
  const opCodes = {};
4362
5137
  const opLookup = {};
@@ -4400,7 +5175,7 @@ var DbRootUtils = class {
4400
5175
  const groupLookup = Object.entries(module.groups).reduce((acc, x) => {
4401
5176
  const groupData = x[1];
4402
5177
  const groupName = x[0];
4403
- const scenes = Object.entries(groupData.scenes).reduce((acc$1, y) => {
5178
+ const scenes = Object.entries(groupData.scenes ?? {}).reduce((acc, y) => {
4404
5179
  const sceneData = y[1];
4405
5180
  const sceneName = y[0];
4406
5181
  const scene = new DbScene({
@@ -4408,8 +5183,8 @@ var DbRootUtils = class {
4408
5183
  name: sceneName
4409
5184
  });
4410
5185
  sceneLookup[scene.id] = scene;
4411
- acc$1[sceneName] = scene;
4412
- return acc$1;
5186
+ acc[sceneName] = scene;
5187
+ return acc;
4413
5188
  }, {});
4414
5189
  acc[groupName] = new DbGroup({
4415
5190
  ...groupData,
@@ -4430,25 +5205,25 @@ var DbRootUtils = class {
4430
5205
  const stringLookup = Object.entries(module.strings).reduce((acc, x) => {
4431
5206
  const stringType = x[1];
4432
5207
  const name = x[0];
4433
- const commands = Object.entries(stringType.commands ?? {}).reduce((acc$1, y) => {
4434
- acc$1[y[0]] = new DbStringCommand({
5208
+ const commands = Object.entries(stringType.commands ?? {}).reduce((acc, y) => {
5209
+ acc[y[0]] = new DbStringCommand({
4435
5210
  ...y[1],
4436
5211
  name: y[0]
4437
5212
  });
4438
- return acc$1;
5213
+ return acc;
4439
5214
  }, {});
4440
- const dictionaries = Object.entries(stringType.dictionaries ?? {}).reduce((acc$1, y) => {
5215
+ const dictionaries = Object.entries(stringType.dictionaries ?? {}).reduce((acc, y) => {
4441
5216
  const dictionary = new DbStringDictionary({
4442
5217
  ...y[1],
4443
5218
  name: y[0]
4444
5219
  });
4445
- acc$1[y[0]] = dictionary;
5220
+ acc[y[0]] = dictionary;
4446
5221
  if (dictionary.command !== void 0) commands[dictionary.command] = new DbStringCommand({
4447
5222
  id: dictionary.command,
4448
5223
  name: dictionary.name,
4449
5224
  dictionary
4450
5225
  });
4451
- return acc$1;
5226
+ return acc;
4452
5227
  }, {});
4453
5228
  const st = new DbStringType({
4454
5229
  ...stringType,
@@ -4493,15 +5268,13 @@ var DbRootUtils = class {
4493
5268
  return acc;
4494
5269
  }, {});
4495
5270
  const cfg = module.config;
4496
- const compression = cfg.compression ? CompressionAlgorithms[cfg.compression]() : null;
5271
+ const compression = cfg.compression ? CompressionAlgorithms[cfg.compression]() : void 0;
4497
5272
  return {
5273
+ headers: module.headers.map((h) => new DbHeader(h)),
4498
5274
  mnemonics: module.mnemonics,
4499
5275
  overrides: module.overrides,
4500
5276
  rewrites: module.rewrites,
4501
- labels: module.labels.reduce((acc, x) => {
4502
- acc[x.location] = x.label;
4503
- return acc;
4504
- }, {}),
5277
+ labels: module.labels,
4505
5278
  structs: structLookup,
4506
5279
  blocks: blocksArray.sort((a, b) => {
4507
5280
  const orderA = a.order ?? 0;
@@ -4529,17 +5302,13 @@ var DbRootUtils = class {
4529
5302
  }
4530
5303
  static async applyFolder(root, folderPath, sourceFiles = []) {
4531
5304
  const chunkFiles = sourceFiles;
4532
- const folderEntries = await listDirectory(folderPath);
4533
- for (const entry of folderEntries) if (entry.isDirectory) await this.applyFolder(root, entry.path, chunkFiles);
4534
- else {
4535
- const index = entry.name.indexOf(".");
4536
- if (!index) continue;
4537
- const name = entry.name.substring(0, index);
4538
- const extension = entry.name.substring(index + 1);
4539
- const type = root.fileExtLookup[extension];
5305
+ const folderEntries = await listDirectory(folderPath, { recursive: true });
5306
+ for (const entry of folderEntries) {
5307
+ if (!entry.isFile || !entry.extension) continue;
5308
+ const type = root.fileExtLookup[entry.extension];
4540
5309
  if (!type) continue;
4541
- const existing = chunkFiles.find((x) => x.name === name && x.type.type === type.type);
4542
- const chunkFile = existing ?? new ChunkFile(name, 0, 0, type);
5310
+ const existing = chunkFiles.find((x) => x.name === entry.name && x.type.type === type.type);
5311
+ const chunkFile = existing ?? new ChunkFile(entry.name, 0, 0, type);
4543
5312
  if (chunkFile.type.type === "Assembly" || chunkFile.type.type === "Patch") {
4544
5313
  const chunkData = await readFileAsText(entry.path);
4545
5314
  chunkFile.textData = chunkData;
@@ -4550,7 +5319,7 @@ var DbRootUtils = class {
4550
5319
  chunkFile.size = chunkData.length;
4551
5320
  }
4552
5321
  if (!existing) {
4553
- const sourceFile = root.files.find((x) => x.name === name && x.type === type.type);
5322
+ const sourceFile = root.files.find((x) => x.name === entry.name && x.type === type.type);
4554
5323
  if (sourceFile) {
4555
5324
  chunkFile.location = sourceFile.start;
4556
5325
  chunkFile.upper = sourceFile.upper;
@@ -4580,7 +5349,7 @@ var DbRootUtils = class {
4580
5349
  static async rebuildAllContent(root, inPath, outPath) {
4581
5350
  var sourceFiles = [];
4582
5351
  for (const path of inPath) sourceFiles = await this.applyFolder(root, path, sourceFiles);
4583
- await saveFileAsBinary(outPath, await new RomWriter(root, "TEST", "TEST").repack(sourceFiles));
5352
+ await saveFileAsBinary(outPath, await new RomWriter(root).repack(sourceFiles));
4584
5353
  return sourceFiles;
4585
5354
  }
4586
5355
  };
@@ -4592,12 +5361,12 @@ var DbOverride = class {
4592
5361
  register;
4593
5362
  value;
4594
5363
  constructor(values) {
4595
- this.location = values.location ?? 0;
4596
- this.register = values.register ?? "";
4597
- this.value = values.value ?? void 0;
4598
- if (!this.location) throw new Error("Location is required");
4599
- if (!this.register) throw new Error("Register is required");
4600
- if (this.value === void 0) throw new Error("Value is required");
5364
+ if (typeof values.value !== "number") throw new Error("Value is required");
5365
+ if (typeof values.location !== "number") throw new Error("Location is required");
5366
+ if (!values.register) throw new Error("Register is required");
5367
+ this.location = values.location;
5368
+ this.register = values.register;
5369
+ this.value = values.value;
4601
5370
  }
4602
5371
  };
4603
5372
 
@@ -4686,7 +5455,7 @@ var StringReader = class StringReader {
4686
5455
  if (cmd.halt) break;
4687
5456
  } else {
4688
5457
  let found = false;
4689
- for (const dictionary of Object.values(dictionaries)) if (c >= dictionary.base && c <= dictionary.range) {
5458
+ for (const dictionary of Object.values(dictionaries)) if (dictionary.base !== void 0 && c >= dictionary.base && c <= dictionary.range) {
4690
5459
  builder.push(dictionary.entries[c - dictionary.base]);
4691
5460
  found = true;
4692
5461
  break;
@@ -4788,10 +5557,10 @@ var StringProcessor = class {
4788
5557
  str = this.context.lineBuffer.substring(1, endIx);
4789
5558
  this.context.lineBuffer = this.context.lineBuffer.substring(endIx + 1).replace(/^[\s,\t]+/, "");
4790
5559
  if (this.context.lineBuffer.startsWith("(")) {
4791
- const endIx$1 = this.context.lineBuffer.indexOf(")");
4792
- if (endIx$1 >= 0) {
4793
- fixedStr = parseInt(this.context.lineBuffer.substring(1, endIx$1), 10);
4794
- this.context.lineBuffer = this.context.lineBuffer.substring(endIx$1 + 1).replace(/^[\s,\t]+/, "");
5560
+ const endIx = this.context.lineBuffer.indexOf(")");
5561
+ if (endIx >= 0) {
5562
+ fixedStr = parseInt(this.context.lineBuffer.substring(1, endIx), 10);
5563
+ this.context.lineBuffer = this.context.lineBuffer.substring(endIx + 1).replace(/^[\s,\t]+/, "");
4795
5564
  }
4796
5565
  }
4797
5566
  } else {
@@ -4835,7 +5604,7 @@ var StringProcessor = class {
4835
5604
  const c = str[x];
4836
5605
  if (c === "[") {
4837
5606
  const endIx = str.indexOf("]", x + 1);
4838
- const parts = str.substring(x + 1, endIx).split(/* @__PURE__ */ new RegExp(`[${[
5607
+ const parts = str.substring(x + 1, endIx).split(new RegExp(`[${[
4839
5608
  ":",
4840
5609
  ",",
4841
5610
  " "
@@ -5028,7 +5797,6 @@ var AssemblerState = class AssemblerState {
5028
5797
  }
5029
5798
  const location = parseInt(hex, 16);
5030
5799
  this.context.blocks.push(this.context.currentBlock = new AsmBlock(location));
5031
- this.context.blockIndex++;
5032
5800
  }
5033
5801
  static doMath(operand) {
5034
5802
  const ix = operand.search(/[-+]/);
@@ -5057,7 +5825,6 @@ var AssemblerState = class AssemblerState {
5057
5825
  const newBlock = new AsmBlock(this.context.currentBlock.location + this.context.currentBlock.size, 0, this.root.stringDelimiters.includes(operand[0]), mnemonic);
5058
5826
  this.context.blocks.push(newBlock);
5059
5827
  this.context.currentBlock = newBlock;
5060
- this.context.blockIndex++;
5061
5828
  if (labelChar === ":") this.context.lineBuffer = this.context.lineBuffer.substring(1);
5062
5829
  else if (labelChar === "[" || labelChar === "{") {
5063
5830
  this.context.lineBuffer = operand.substring(1).replace(/^[\s,\t]+/, "");
@@ -5144,8 +5911,8 @@ var AssemblerState = class AssemblerState {
5144
5911
  }
5145
5912
  this.context.lineBuffer = "";
5146
5913
  if (!operand) {
5147
- const opCode$1 = codes.find((x) => this.root.addrLookup[x.mode].size === 1);
5148
- this.context.currentBlock.objList.push(new Op(opCode$1, 0, [], 1));
5914
+ const opCode = codes.find((x) => this.root.addrLookup[x.mode].size === 1);
5915
+ this.context.currentBlock.objList.push(new Op(opCode, 0, [], 1));
5149
5916
  this.context.currentBlock.size++;
5150
5917
  continue;
5151
5918
  }
@@ -5221,16 +5988,20 @@ var Assembler = class {
5221
5988
  tags = new SortedMap();
5222
5989
  currentBlock = null;
5223
5990
  lineCount = 0;
5224
- blockIndex = 0;
5225
5991
  lastDelimiter = null;
5226
5992
  reqBank = null;
5227
5993
  eof = false;
5228
5994
  strDelimRegex;
5229
- constructor(dbRoot, textData) {
5995
+ conditionFiles;
5996
+ inCondition = false;
5997
+ exitCondition = false;
5998
+ failCondition = false;
5999
+ constructor(dbRoot, textData, conditionFiles) {
5230
6000
  this.root = dbRoot;
5231
6001
  this.lines = textData.split(/\r?\n/);
5232
6002
  this.stringProcessor = new StringProcessor(this);
5233
- this.strDelimRegex = /* @__PURE__ */ new RegExp(`[${this.root.stringDelimiters.map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}]`);
6003
+ this.strDelimRegex = new RegExp(`[${this.root.stringDelimiters.map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}]`);
6004
+ this.conditionFiles = conditionFiles;
5234
6005
  }
5235
6006
  parseAssembly() {
5236
6007
  this.blocks.push(this.currentBlock = new AsmBlock());
@@ -5269,6 +6040,10 @@ var Assembler = class {
5269
6040
  this.lineBuffer = "";
5270
6041
  continue;
5271
6042
  }
6043
+ if (this.failCondition) {
6044
+ this.lineBuffer = "";
6045
+ continue;
6046
+ }
5272
6047
  if (this.lineBuffer[0] === "!") {
5273
6048
  this.processTags();
5274
6049
  this.lineBuffer = "";
@@ -5288,7 +6063,7 @@ var Assembler = class {
5288
6063
  processDirectives() {
5289
6064
  let endIx = this.lineBuffer.search(RomProcessingConstants.COMMA_SPACE_REGEX);
5290
6065
  if (endIx < 0) endIx = this.lineBuffer.length;
5291
- const value = this.lineBuffer.substring(endIx).replace(/^[\s,\t]+/, "");
6066
+ let value = this.lineBuffer.substring(endIx).replace(/^[\s,\t]+/, "");
5292
6067
  switch (this.lineBuffer.substring(1, endIx).toUpperCase()) {
5293
6068
  case "BANK":
5294
6069
  this.reqBank = parseInt(value, 16);
@@ -5296,6 +6071,45 @@ var Assembler = class {
5296
6071
  case "INCLUDE":
5297
6072
  if (value.length > 0) this.includes.add(value.toUpperCase().replace(/'/g, ""));
5298
6073
  break;
6074
+ case "IF":
6075
+ if (this.inCondition) throw new Error("IF without ENDIF");
6076
+ value = value.replace(/'/g, "");
6077
+ if (!value) throw new Error("IF without condition");
6078
+ this.inCondition = true;
6079
+ if (!this.conditionFiles.includes(value)) {
6080
+ this.failCondition = true;
6081
+ this.exitCondition = false;
6082
+ } else {
6083
+ this.failCondition = false;
6084
+ this.exitCondition = true;
6085
+ }
6086
+ break;
6087
+ case "ELSEIF":
6088
+ if (!this.inCondition) throw new Error("ELSEIF without IF");
6089
+ value = value.replace(/'/g, "");
6090
+ if (!value) throw new Error("ELSEIF without condition");
6091
+ if (this.exitCondition || !this.conditionFiles.includes(value)) this.failCondition = true;
6092
+ else {
6093
+ this.exitCondition = true;
6094
+ this.failCondition = false;
6095
+ }
6096
+ break;
6097
+ case "ELSE":
6098
+ if (!this.inCondition) throw new Error("ELSE without IF");
6099
+ if (value) throw new Error("ELSE with condition");
6100
+ if (this.exitCondition) this.failCondition = true;
6101
+ else {
6102
+ this.failCondition = false;
6103
+ this.exitCondition = true;
6104
+ }
6105
+ break;
6106
+ case "ENDIF":
6107
+ if (!this.inCondition) throw new Error("ENDIF without IF");
6108
+ if (value) throw new Error("ENDIF with condition");
6109
+ this.failCondition = false;
6110
+ this.exitCondition = false;
6111
+ this.inCondition = false;
6112
+ break;
5299
6113
  }
5300
6114
  }
5301
6115
  processTags() {
@@ -5596,7 +6410,13 @@ async function fromSupabaseById(baseRomBranchId) {
5596
6410
  config,
5597
6411
  files,
5598
6412
  blocks,
5599
- fixups,
6413
+ rewrites,
6414
+ transforms,
6415
+ overrides,
6416
+ labels,
6417
+ mnemonics,
6418
+ fileTypes,
6419
+ groups,
5600
6420
  strings,
5601
6421
  structs,
5602
6422
  createdAt,
@@ -5609,7 +6429,6 @@ async function fromSupabaseById(baseRomBranchId) {
5609
6429
  notes,
5610
6430
  platformId,
5611
6431
  addressingModes,
5612
- instructionSet,
5613
6432
  vectors,
5614
6433
  types,
5615
6434
  createdAt,
@@ -5710,9 +6529,15 @@ async function fromSupabaseByName(options) {
5710
6529
  coplib,
5711
6530
  files,
5712
6531
  blocks,
5713
- fixups,
6532
+ rewrites,
6533
+ transforms,
6534
+ overrides,
6535
+ labels,
6536
+ mnemonics,
6537
+ fileTypes,
5714
6538
  strings,
5715
6539
  structs,
6540
+ groups,
5716
6541
  createdAt,
5717
6542
  updatedAt,
5718
6543
  platformBranch:PlatformBranch!inner(
@@ -5723,8 +6548,8 @@ async function fromSupabaseByName(options) {
5723
6548
  notes,
5724
6549
  platformId,
5725
6550
  addressingModes,
5726
- instructionSet,
5727
6551
  vectors,
6552
+ headers,
5728
6553
  types,
5729
6554
  createdAt,
5730
6555
  updatedAt
@@ -5929,7 +6754,13 @@ async function fromSupabaseByProject(projectName, branchId) {
5929
6754
  coplib,
5930
6755
  files,
5931
6756
  blocks,
5932
- fixups,
6757
+ rewrites,
6758
+ transforms,
6759
+ overrides,
6760
+ labels,
6761
+ mnemonics,
6762
+ fileTypes,
6763
+ groups,
5933
6764
  strings,
5934
6765
  structs,
5935
6766
  createdAt,
@@ -5951,7 +6782,6 @@ async function fromSupabaseByProject(projectName, branchId) {
5951
6782
  id,
5952
6783
  name,
5953
6784
  meta,
5954
- platformId,
5955
6785
  createdAt,
5956
6786
  updatedAt
5957
6787
  )
@@ -5964,8 +6794,8 @@ async function fromSupabaseByProject(projectName, branchId) {
5964
6794
  notes,
5965
6795
  platformId,
5966
6796
  addressingModes,
5967
- instructionSet,
5968
6797
  vectors,
6798
+ headers,
5969
6799
  types,
5970
6800
  createdAt,
5971
6801
  updatedAt,
@@ -5991,14 +6821,8 @@ async function fromSupabaseByProject(projectName, branchId) {
5991
6821
  });
5992
6822
  const baseRomBranch = branchData.baseRomBranch;
5993
6823
  const projectFiles = await loadProjectFiles(branchData.id);
5994
- const baseRomFiles = await loadBaseRomFiles(baseRomBranch.id);
6824
+ await loadBaseRomFiles(baseRomBranch.id);
5995
6825
  fileQueryTime = performance.now() - branchStart - branchQueryTime;
5996
- const payload = {
5997
- projectBranch: branchData,
5998
- projectFiles,
5999
- baseRomBranch,
6000
- baseRomFiles
6001
- };
6002
6826
  const totalTime = performance.now() - startTime;
6003
6827
  const stats = {
6004
6828
  branchQueryTime,
@@ -6007,7 +6831,23 @@ async function fromSupabaseByProject(projectName, branchId) {
6007
6831
  fileCount: projectFiles.length
6008
6832
  };
6009
6833
  console.log("Project ROM load stats:", stats);
6010
- return payload;
6834
+ return {
6835
+ mnemonics: baseRomBranch.gameRomBranch.mnemonics,
6836
+ overrides: baseRomBranch.gameRomBranch.overrides,
6837
+ rewrites: baseRomBranch.gameRomBranch.rewrites,
6838
+ blocks: baseRomBranch.gameRomBranch.blocks,
6839
+ files: baseRomBranch.gameRomBranch.files,
6840
+ config: baseRomBranch.gameRomBranch.config,
6841
+ labels: baseRomBranch.gameRomBranch.labels,
6842
+ structs: baseRomBranch.gameRomBranch.structs,
6843
+ copdef: baseRomBranch.gameRomBranch.coplib,
6844
+ strings: baseRomBranch.gameRomBranch.strings,
6845
+ transforms: baseRomBranch.gameRomBranch.transforms,
6846
+ groups: baseRomBranch.gameRomBranch.groups,
6847
+ fileTypes: baseRomBranch.gameRomBranch.fileTypes,
6848
+ addrModes: baseRomBranch.gameRomBranch.platformBranch.addressingModes,
6849
+ headers: baseRomBranch.gameRomBranch.platformBranch.headers
6850
+ };
6011
6851
  } catch (error) {
6012
6852
  if (error instanceof SupabaseFromError) throw error;
6013
6853
  throw new SupabaseFromError(`Failed to load Project data: ${error instanceof Error ? error.message : "Unknown error"}`, SupabaseErrorCode.NETWORK_ERROR, {
@@ -6036,7 +6876,13 @@ async function fromSupabaseByGameRom(gameName, regionName, platformName, branchI
6036
6876
  config,
6037
6877
  files,
6038
6878
  blocks,
6039
- fixups,
6879
+ rewrites,
6880
+ transforms,
6881
+ overrides,
6882
+ labels,
6883
+ mnemonics,
6884
+ fileTypes,
6885
+ groups,
6040
6886
  strings,
6041
6887
  structs,
6042
6888
  createdAt,
@@ -6059,7 +6905,6 @@ async function fromSupabaseByGameRom(gameName, regionName, platformName, branchI
6059
6905
  id,
6060
6906
  name,
6061
6907
  meta,
6062
- platformId,
6063
6908
  createdAt,
6064
6909
  updatedAt
6065
6910
  )
@@ -6071,7 +6916,7 @@ async function fromSupabaseByGameRom(gameName, regionName, platformName, branchI
6071
6916
  isActive,
6072
6917
  platformId,
6073
6918
  addressingModes,
6074
- instructionSet,
6919
+ headers,
6075
6920
  vectors,
6076
6921
  types,
6077
6922
  createdAt,
@@ -6195,6 +7040,7 @@ async function summaryFromSupabaseByProject(projectName) {
6195
7040
  version,
6196
7041
  isActive,
6197
7042
  notes,
7043
+ fileTypes,
6198
7044
  baseRomId,
6199
7045
  gameRomBranchId,
6200
7046
  createdAt,
@@ -6234,7 +7080,6 @@ async function summaryFromSupabaseByProject(projectName) {
6234
7080
  id,
6235
7081
  name,
6236
7082
  meta,
6237
- platformId,
6238
7083
  createdAt,
6239
7084
  updatedAt
6240
7085
  )
@@ -6292,17 +7137,21 @@ async function summaryFromSupabaseByProject(projectName) {
6292
7137
  //#region src/rom/generator.ts
6293
7138
  var RomGenerator = class {
6294
7139
  projectName;
6295
- crc = 0;
6296
- branchId = "";
7140
+ crc;
6297
7141
  dbRoot = {};
6298
7142
  sourceData = new Uint8Array();
6299
- constructor(projectName) {
7143
+ constructor(projectName, crc) {
6300
7144
  this.projectName = projectName;
7145
+ this.crc = crc ?? 0;
6301
7146
  }
6302
- async initialize() {
6303
- var projectData = await summaryFromSupabaseByProject(this.projectName);
6304
- this.crc = projectData.baseRomBranch.gameRomBranch.gameRom.crc;
6305
- this.branchId = projectData.id;
7147
+ async validateAndDownload(sourceData) {
7148
+ if (crc32_buffer(sourceData) === this.crc) {
7149
+ const moduleData = await fromSupabaseByProject(this.projectName);
7150
+ this.dbRoot = DbRootUtils.fromGameModule(moduleData);
7151
+ this.sourceData = sourceData;
7152
+ return true;
7153
+ }
7154
+ return false;
6306
7155
  }
6307
7156
  async generateProject(modules, manualFiles, unshiftManualFiles = false) {
6308
7157
  if (!this.dbRoot) throw new Error("Database not initialized");
@@ -6318,45 +7167,20 @@ var RomGenerator = class {
6318
7167
  if (unshiftManualFiles) for (const file of manualFiles ?? []) this.applyPatchFile(file, chunkFiles, asmFiles, patchFiles);
6319
7168
  for (const module of modules) for (const file of moduleLookup.get(module)) this.applyPatchFile(file, chunkFiles, asmFiles, patchFiles);
6320
7169
  if (!unshiftManualFiles) for (const file of manualFiles ?? []) this.applyPatchFile(file, chunkFiles, asmFiles, patchFiles);
6321
- this.assembleCodeFromText(asmFiles);
6322
- RomProcessor.applyPatches(asmFiles, patchFiles);
6323
- for (const asm of chunkFiles) ChunkFileUtils.calculateSize(asm);
6324
- const pages = new RomLayout(chunkFiles, this.dbRoot).organize();
6325
- for (const file of asmFiles) ChunkFileUtils.rebase(file);
6326
- this.generateAsmIncludeLookups(asmFiles);
6327
- const blockLookup = /* @__PURE__ */ new Map();
6328
- for (const f of chunkFiles) blockLookup.set(f.name.toUpperCase(), f.location);
6329
- return await this.writeRom(blockLookup, chunkFiles, asmFiles, pages);
7170
+ return await new RomWriter(this.dbRoot).repack(chunkFiles);
6330
7171
  }
6331
7172
  applyProjectInit(chunkFiles, asmFiles, patchFiles) {
6332
7173
  const moduleLookup = /* @__PURE__ */ new Map();
6333
7174
  for (const chunkFile of this.dbRoot.projectFiles) {
6334
7175
  console.log(`Processing patch: ${chunkFile.name}`);
6335
7176
  if (chunkFile.group) {
6336
- let modArray;
6337
- if (!moduleLookup.has(chunkFile.group)) moduleLookup.set(chunkFile.group, modArray = []);
6338
- else modArray = moduleLookup.get(chunkFile.group);
7177
+ let modArray = moduleLookup.get(chunkFile.group);
7178
+ if (!modArray) moduleLookup.set(chunkFile.group, modArray = []);
6339
7179
  modArray.push(chunkFile);
6340
7180
  } else this.applyPatchFile(chunkFile, chunkFiles, asmFiles, patchFiles);
6341
7181
  }
6342
7182
  return moduleLookup;
6343
7183
  }
6344
- assembleCodeFromText(asmFiles) {
6345
- for (const block of asmFiles) {
6346
- const { blocks, includes, reqBank } = new Assembler(this.dbRoot, block.textData).parseAssembly();
6347
- block.parts = blocks;
6348
- block.includes = includes;
6349
- block.bank = reqBank ?? void 0;
6350
- }
6351
- }
6352
- generateAsmIncludeLookups(asmFiles) {
6353
- for (const f of asmFiles) {
6354
- const includeBlocks = asmFiles.filter((x) => f.includes?.has(x.name.toUpperCase())).flatMap((x) => x.parts).filter((b) => !!b.label);
6355
- f.includeLookup = /* @__PURE__ */ new Map();
6356
- for (const b of includeBlocks) if (b.label) f.includeLookup.set(b.label.toUpperCase(), b);
6357
- for (const b of (f.parts || []).filter((x) => !!x.label)) if (b.label) f.includeLookup.set(b.label.toUpperCase(), b);
6358
- }
6359
- }
6360
7184
  applyPatchFile(chunkFile, chunkFiles, asmFiles, patchFiles) {
6361
7185
  console.log(`Processing patch: ${chunkFile.name}`);
6362
7186
  const existing = chunkFiles.find((x) => x.name === chunkFile.name);
@@ -6371,15 +7195,6 @@ var RomGenerator = class {
6371
7195
  existing.size = chunkFile.size;
6372
7196
  } else chunkFiles.push(chunkFile);
6373
7197
  }
6374
- async writeRom(blockLookup, chunkFiles, asmFiles, pages) {
6375
- const romWriter = new RomWriter(this.dbRoot, "GAIALABS", "01JG ");
6376
- romWriter.allocate(pages);
6377
- for (const file of chunkFiles) await romWriter.writeFile(file, blockLookup);
6378
- romWriter.writeHeader();
6379
- romWriter.writeEntryPoints(asmFiles);
6380
- romWriter.writeChecksum();
6381
- return romWriter.outBuffer;
6382
- }
6383
7198
  };
6384
7199
 
6385
7200
  //#endregion
@@ -6614,27 +7429,13 @@ var SpriteMap = class SpriteMap {
6614
7429
 
6615
7430
  //#endregion
6616
7431
  //#region src/index.ts
6617
- /**
6618
- * GaiaCore - Universal ROM processing engine
6619
- *
6620
- * This package provides the core functionality for ROM processing
6621
- * that can run in both browser (Web Worker) and Node.js environments.
6622
- *
6623
- * High-level APIs:
6624
- * - RomProcessor: Unified ROM processing workflows
6625
- * - ProjectManager: Complete project lifecycle management
6626
- *
6627
- * Low-level modules:
6628
- * - ROM: ROM state management, project configuration
6629
- * - Assembly: 65816 instruction set, stack operations
6630
- * - Compression: QuintetLZ compression algorithm
6631
- * - Sprites: Sprite animation system
6632
- */
6633
- const GAIA_CORE_VERSION = "0.1.6";
6634
- const isPlatformBrowser = typeof window !== "undefined";
7432
+ const snes = {
7433
+ addressingModes: addressingModes_default,
7434
+ vectors: vectors_default,
7435
+ headers: headers_default
7436
+ };
6635
7437
  const isPlatformNode = typeof process !== "undefined" && process.versions?.node;
6636
- const isPlatformWebWorker = typeof importScripts !== "undefined";
6637
7438
 
6638
7439
  //#endregion
6639
- export { Address, AddressSpace, AddressType, AddressingModeHandler, AsmBlock, AsmBlockUtils, AsmReader, Assembler, AssemblerState, BinType, BitStream, BlockReader, BlockReaderConstants, BlockWriter, Byte, ChunkFile, ChunkFileUtils, CompressionAlgorithms, CompressionRegistry, CopCommandProcessor, CopDef, CpuMode, DbAddressingMode, DbBlock, DbFile, DbFileType, DbGroup, DbOverride, DbPart, DbRootUtils, DbScene, DbStringCommand, DbStringDictionary, DbStringType, DbStringTypeUtils, DbStruct, DbTransform, DebugExporter, GAIA_CORE_VERSION, LocationWrapper, Long, MapExt, MemberType, MemoryMapMode, ObjectType, Op, OpCode, OperationContext, PostProcessor, ProcessorStateManager, QuintetLZ, ReferenceManager, RegisterType, Registers, RomDataReader, RomGenerator, RomLayout, RomProcessingConstants, RomProcessor, RomState, RomStateUtils, RomWriter, SortedMap, SpriteFrame, SpriteGroup, SpriteMap, SpritePart, Stack, StackOperations, StatusFlags, StringProcessor, StringReader, StringSizeComparer, SupabaseErrorCode, SupabaseFromError, TableEntry, TransformProcessor, TypeParser, TypedNumber, Word, XformType, base64ToUint8Array, binaryToUtf8String, bytesToHex, clamp, crc32_buffer, crc32_text_utf16, crc32_text_utf8, createChunkFileFromDbBlock, createChunkFileFromDbFile, createDbPath, createSupabaseClient, createTempDirectory, decodeBase64, decodeBase64String, decodeDataString, encodeBase64, encodeBase64String, fileExists, fromSupabaseByGameRom, fromSupabaseById, fromSupabaseByName, fromSupabaseByProject, getDirectory, getEnvVar, getNestedProperty, getSupabaseClient, hexToBytes, hexToUint8Array, indexOfAny, isPlatformBrowser, isPlatformNode, isPlatformWebWorker, isValidBase64, listDirectory, readFileAsBinary, readFileAsText, readJsonFile, removeDirectory, resetSupabaseClient, saveFileAsBinary, saveFileAsText, summaryFromSupabaseByProject, uint8ArrayToBase64, validateEnvironmentVariables };
7440
+ export { Address, AddressSpace, AddressType, AddressingModeHandler, AsmBlock, AsmBlockUtils, AsmReader, Assembler, AssemblerState, BinType, BitStream, BlockReader, BlockReaderConstants, BlockWriter, Byte, ChunkFile, ChunkFileUtils, CompressionAlgorithms, CompressionRegistry, CopCommandProcessor, CopDef, CpuMode, DbAddressingMode, DbBlock, DbFile, DbFileType, DbGroup, DbHeader, DbHeaderPart, DbOverride, DbPart, DbRootUtils, DbScene, DbStringCommand, DbStringDictionary, DbStringType, DbStringTypeUtils, DbStruct, DbTransform, LocationWrapper, Long, MapExt, MemberType, MemoryMapMode, ObjectType, Op, OpCode, OperationContext, PostProcessor, ProcessorStateManager, QuintetLZ, ReferenceManager, RegisterType, Registers, RomDataReader, RomGenerator, RomLayout, RomProcessingConstants, RomProcessor, RomState, RomStateUtils, RomWriter, SortedMap, SpriteFrame, SpriteGroup, SpriteMap, SpritePart, Stack, StackOperations, StatusFlags, StringProcessor, StringReader, StringSizeComparer, SupabaseErrorCode, SupabaseFromError, TableEntry, TransformProcessor, TypeParser, TypedNumber, Word, XformType, base64ToUint8Array, binaryToUtf8String, bytesToHex, clamp, crc32_buffer, crc32_text_utf16, crc32_text_utf8, createChunkFileFromDbBlock, createChunkFileFromDbFile, createDbPath, createSupabaseClient, createTempDirectory, decodeBase64, decodeBase64String, decodeDataString, encodeBase64, encodeBase64String, fileExists, fromSupabaseByGameRom, fromSupabaseById, fromSupabaseByName, fromSupabaseByProject, getDirectory, getEnvVar, getNestedProperty, getSupabaseClient, hexToBytes, hexToUint8Array, indexOfAny, isPlatformNode, isValidBase64, listDirectory, readFileAsBinary, readFileAsText, readJsonFile, removeDirectory, resetSupabaseClient, saveFileAsBinary, saveFileAsText, snes, summaryFromSupabaseByProject, uint8ArrayToBase64, validateEnvironmentVariables };
6640
7441
  //# sourceMappingURL=index.mjs.map