@wasm-gaming/fbneo-wasm 0.1.0 → 0.1.2

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 (43) hide show
  1. package/README.md +78 -1
  2. package/data/romsets/atari.json +12183 -0
  3. package/data/romsets/capcom.json +66781 -0
  4. package/data/romsets/cave.json +4888 -0
  5. package/data/romsets/channelf.json +463 -0
  6. package/data/romsets/coleco.json +5921 -0
  7. package/data/romsets/cps3.json +1777 -0
  8. package/data/romsets/dataeast.json +22415 -0
  9. package/data/romsets/galaxian.json +14107 -0
  10. package/data/romsets/index.json +116 -0
  11. package/data/romsets/irem.json +15032 -0
  12. package/data/romsets/konami.json +24780 -0
  13. package/data/romsets/megadrive.json +26352 -0
  14. package/data/romsets/midway.json +13213 -0
  15. package/data/romsets/msx.json +16287 -0
  16. package/data/romsets/neogeo.json +39274 -0
  17. package/data/romsets/nes.json +28301 -0
  18. package/data/romsets/pce.json +4397 -0
  19. package/data/romsets/pgm.json +8860 -0
  20. package/data/romsets/pgm2.json +397 -0
  21. package/data/romsets/pre90s.json +143783 -0
  22. package/data/romsets/psikyo.json +2205 -0
  23. package/data/romsets/pst90s.json +84614 -0
  24. package/data/romsets/sega.json +54871 -0
  25. package/data/romsets/sg1000.json +2300 -0
  26. package/data/romsets/sms.json +13532 -0
  27. package/data/romsets/snes.json +23630 -0
  28. package/data/romsets/spectrum.json +30187 -0
  29. package/data/romsets/taito.json +40373 -0
  30. package/data/romsets/toaplan.json +8177 -0
  31. package/dist/fbneo/neo.d.ts +83 -0
  32. package/dist/fbneo/neo.d.ts.map +1 -0
  33. package/dist/fbneo/neo.js +357 -0
  34. package/dist/fbneo/neo.js.map +1 -0
  35. package/dist/fbneo/romset.d.ts +0 -0
  36. package/dist/fbneo/romset.d.ts.map +1 -0
  37. package/dist/fbneo/romset.js +0 -0
  38. package/dist/fbneo/romset.js.map +1 -0
  39. package/package.json +17 -1
  40. package/src/neo.ts +463 -0
  41. package/src/romset.ts +0 -0
  42. package/dist/fbneo/fbneo.js +0 -2
  43. package/dist/fbneo/fbneo.wasm +0 -0
package/README.md CHANGED
@@ -35,7 +35,84 @@ engine.start();
35
35
  FBNeo identifies a game by the ROM zip **filename** (without extension). Pass the
36
36
  game short name explicitly via `options.driver` (e.g. `"mslug"`, `"sf2"`,
37
37
  `"kof98"`), or let it be inferred from `options.romFileName` / the picked file's
38
- name.
38
+ name. (The bytes are always written to MEMFS as `<driver>.zip`, so the source
39
+ file itself never needs renaming — only its *name* has to resolve to a driver.)
40
+
41
+ ### Identifying a ROM set from its contents
42
+
43
+ When the filename is unreliable (a browser-mangled `mslug (1).zip`) but the ROM
44
+ files inside must keep their canonical names, recover the driver from the zip's
45
+ **contents** with the opt-in `@wasm-gaming/fbneo-wasm/romset` helper. It matches
46
+ the CRC-32s stored in the zip's central directory against a dataset of every
47
+ FBNeo ROM set — the same identity FBNeo uses internally — so it is unaffected by
48
+ re-compression, entry reordering, or split/merged packaging.
49
+
50
+ ```js
51
+ import { RomsetIndex, resolveDriver } from '@wasm-gaming/fbneo-wasm/romset';
52
+
53
+ // Load the dataset for the system(s) you support (per-system JSON, loaded on demand).
54
+ const neogeo = await fetch('/romsets/neogeo.json').then((r) => r.json());
55
+ const index = new RomsetIndex([neogeo]);
56
+
57
+ const match = resolveDriver(romZipBytes, index); // { driver: 'mslug', coverage: 1, ... } | null
58
+ const engine = await load({
59
+ canvas,
60
+ assets: { rom: romZipBytes },
61
+ options: { driver: match?.driver }, // fall back to your own logic when null
62
+ });
63
+ ```
64
+
65
+ The dataset ships as `data/romsets/<system>.json` (also served at `/romsets/…`
66
+ from the built `dist/`); `data/romsets/index.json` lists the systems and game
67
+ counts. Regenerate it from a pinned FBNeo checkout with `make romsets`.
68
+
69
+ Each ROM entry carries its internal name (`n`) and CRC-32 (`c`). `neogeo.json`
70
+ additionally carries each chip's size (`s`) and hardware region (`r`) — the chip
71
+ *layout* — which is what lets the `neo` helper below rebuild a ROM set from a
72
+ flash-cart image.
73
+
74
+ Because the match is by CRC-32 — and FBNeo itself looks ROM chips up by CRC
75
+ before falling back to their names — a set is usually accepted as downloaded:
76
+ extra files, subdirectories, and non-canonical chip filenames inside the zip do
77
+ not matter. Only the zip's *name* has to resolve to a driver, which is exactly
78
+ what this helper supplies.
79
+
80
+ ### Neo Geo `.neo` files (NeoSD / Terraonion)
81
+
82
+ FBNeo reads `.zip` and `.7z` ROM sets only. A `.neo` — the single-file format for
83
+ NeoSD/Terraonion flash carts, and how most Neo Geo homebrew is distributed — is a
84
+ 4 KiB header followed by each ROM region as one contiguous blob (with the sprite
85
+ region byte-interleaved as the cartridge wires it), so it cannot be handed to the
86
+ engine as-is. The opt-in `@wasm-gaming/fbneo-wasm/neo` helper rebuilds the chip
87
+ split FBNeo expects, in the browser and with no dependencies:
88
+
89
+ ```js
90
+ import { isNeoFile, neoToRomset } from '@wasm-gaming/fbneo-wasm/neo';
91
+
92
+ const neogeo = await fetch('/romsets/neogeo.json').then((r) => r.json());
93
+
94
+ if (isNeoFile(bytes)) {
95
+ const { driver, zip } = neoToRomset(bytes, neogeo); // throws if it cannot be rebuilt
96
+ await load({ canvas, assets: { rom: zip }, options: { driver } });
97
+ }
98
+ ```
99
+
100
+ It identifies the driver by matching the `.neo`'s region sizes against the chip
101
+ layouts in `data/romsets/neogeo.json`, rebuilds the individual chip dumps
102
+ (de-interleaving sprites, undoing the `HARDWARE_SNK_SWAPP` program-ROM swap), and
103
+ CRC-32 verifies every chip before returning — so it throws loudly rather than
104
+ handing the engine a broken set. The zip it returns is *stored*, not deflated:
105
+ FBNeo decompresses each chip immediately, so compressing would only be undone.
106
+
107
+ The same conversion is available offline, which is handy for preparing a set once
108
+ rather than on every page load:
109
+
110
+ ```sh
111
+ node scripts/neo2romset.mjs mygame.neo --out ./roms # needs `make build-lib`
112
+ ```
113
+
114
+ Sets whose program ROM lives inside the SMA custom chip cannot be reproduced by a
115
+ straight carve; those fail CRC verification and are reported rather than written.
39
116
 
40
117
  ### Options
41
118