@wasm-gaming/fbneo-wasm 0.1.2 → 0.3.0

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 (59) hide show
  1. package/README.md +112 -69
  2. package/dist/fbneo/app/app.css +112 -0
  3. package/dist/fbneo/app/app.js +646 -0
  4. package/dist/fbneo/engine-specs.js +646 -0
  5. package/dist/fbneo/fbneo.js +2 -0
  6. package/dist/fbneo/fbneo.options.d.ts +72 -19
  7. package/dist/fbneo/fbneo.options.d.ts.map +1 -1
  8. package/dist/fbneo/fbneo.options.js +49 -48
  9. package/dist/fbneo/fbneo.options.js.map +1 -1
  10. package/dist/fbneo/fbneo.sdk.d.ts +157 -8
  11. package/dist/fbneo/fbneo.sdk.d.ts.map +1 -1
  12. package/dist/fbneo/fbneo.sdk.js +641 -181
  13. package/dist/fbneo/fbneo.sdk.js.map +1 -1
  14. package/dist/fbneo/fbneo.wasm +4 -0
  15. package/dist/fbneo/romset.d.ts +0 -0
  16. package/dist/fbneo/romset.d.ts.map +1 -1
  17. package/dist/fbneo/romset.js.map +1 -1
  18. package/{data → dist/fbneo}/romsets/atari.json +5036 -118
  19. package/{data → dist/fbneo}/romsets/capcom.json +3392 -848
  20. package/{data → dist/fbneo}/romsets/cave.json +460 -115
  21. package/{data → dist/fbneo}/romsets/channelf.json +200 -50
  22. package/{data → dist/fbneo}/romsets/coleco.json +2650 -658
  23. package/{data → dist/fbneo}/romsets/cps3.json +240 -60
  24. package/{data → dist/fbneo}/romsets/dataeast.json +1352 -338
  25. package/{data → dist/fbneo}/romsets/galaxian.json +1192 -298
  26. package/dist/fbneo/romsets/gba.json +197 -0
  27. package/{data → dist/fbneo}/romsets/index.json +16 -12
  28. package/{data → dist/fbneo}/romsets/irem.json +796 -199
  29. package/{data → dist/fbneo}/romsets/konami.json +1644 -411
  30. package/{data → dist/fbneo}/romsets/megadrive.json +11899 -2926
  31. package/{data → dist/fbneo}/romsets/midway.json +560 -140
  32. package/{data → dist/fbneo}/romsets/msx.json +7204 -1798
  33. package/{data → dist/fbneo}/romsets/neogeo.json +2704 -614
  34. package/{data → dist/fbneo}/romsets/nes.json +12815 -3155
  35. package/{data → dist/fbneo}/romsets/pce.json +1952 -488
  36. package/{data → dist/fbneo}/romsets/pgm.json +796 -199
  37. package/{data → dist/fbneo}/romsets/pgm2.json +32 -8
  38. package/{data → dist/fbneo}/romsets/pre90s.json +10002 -2084
  39. package/{data → dist/fbneo}/romsets/psikyo.json +160 -40
  40. package/{data → dist/fbneo}/romsets/pst90s.json +6400 -1597
  41. package/{data → dist/fbneo}/romsets/sega.json +2756 -658
  42. package/{data → dist/fbneo}/romsets/sg1000.json +1032 -255
  43. package/{data → dist/fbneo}/romsets/sms.json +6012 -1503
  44. package/{data → dist/fbneo}/romsets/snes.json +10991 -2816
  45. package/{data → dist/fbneo}/romsets/spectrum.json +13579 -3361
  46. package/{data → dist/fbneo}/romsets/taito.json +2496 -624
  47. package/{data → dist/fbneo}/romsets/toaplan.json +576 -144
  48. package/package.json +10 -15
  49. package/src/app/app.css +112 -0
  50. package/src/app/app.js +646 -0
  51. package/src/fbneo.options.ts +119 -63
  52. package/src/fbneo.sdk.ts +712 -211
  53. package/src/romset.ts +0 -0
  54. package/dist/fbneo/fbneo.manifest.d.ts +0 -4
  55. package/dist/fbneo/fbneo.manifest.d.ts.map +0 -1
  56. package/dist/fbneo/fbneo.manifest.js +0 -33
  57. package/dist/fbneo/fbneo.manifest.js.map +0 -1
  58. package/dist/manifest.json +0 -91
  59. package/src/fbneo.manifest.ts +0 -38
@@ -1,83 +1,139 @@
1
- import type { JSONSchema } from '@wasm-gaming/engine-specs';
1
+ /**
2
+ * What FBNeo accepts, as types and as data.
3
+ *
4
+ * The four payloads of the wasm-gaming engine contract, closed for this engine, and
5
+ * {@link FBNEO_SPEC} — the same thing as data the contract's base class reads: every
6
+ * default lives there and nowhere else.
7
+ */
8
+ import type { EnginePayloads, EngineSpec } from '@wasm-gaming/engine-specs';
2
9
 
10
+ /** Bytes, or a thunk that produces them only when the engine actually needs them. */
11
+ export type FbneoAsset =
12
+ | Uint8Array
13
+ | ArrayBuffer
14
+ | null
15
+ | (() => Uint8Array | ArrayBuffer | null | Promise<Uint8Array | ArrayBuffer | null>);
16
+
17
+ /** The engine: fixed for the life of the wasm instance (`renderFilter` aside). */
18
+ export interface FbneoConfig {
19
+ /** How the picture is scaled to the mount: crisp pixels or linear filtering. */
20
+ renderFilter?: 'pixelated' | 'smooth';
21
+ /** Emscripten glue URL. Defaults to `./fbneo.js` next to the SDK. */
22
+ jsUrl?: string;
23
+ /** WASM URL. Defaults to `./fbneo.wasm` next to the SDK. */
24
+ wasmUrl?: string;
25
+ }
26
+
27
+ /** The session: which game the ROM set is. */
3
28
  export interface FbneoOptions {
4
29
  /**
5
- * Filename used when writing the ROM zip bytes to Emscripten MEMFS.
6
- * FBNeo identifies a game by the zip filename (without extension), so this
7
- * should match the driver's expected ROM set name (e.g. "mslug" for Metal Slug).
30
+ * The FBNeo driver (ROM-set short name, e.g. `mslug`). When empty it is taken from
31
+ * {@link FbneoOptions.romFileName}; the `romset` helper can recover it from a zip's
32
+ * contents when the file name is unreliable.
8
33
  */
34
+ driver?: string;
35
+ /** The ROM zip's file name (`mslug.zip`), used for the driver when `driver` is empty. */
9
36
  romFileName?: string;
10
37
  /**
11
- * The FBNeo driver/game name to load (e.g. "mslug", "sf2", "kof98").
12
- * If omitted, the driver is inferred from `romFileName` (without extension).
38
+ * How a Neo Geo set boots: `mvs`, the arcade board (coins, credits — FBNeo's default),
39
+ * or `aes`, the home console: the AES BIOS from the `bios` zip (or Universe BIOS 4.0 in
40
+ * AES mode) and a memory card per game. Other systems ignore it.
13
41
  */
14
- driver?: string;
15
- /** Canvas scaling filter: `pixelated` for crisp pixels, `smooth` for linear filtering. */
16
- renderFilter?: 'pixelated' | 'smooth';
17
- /** Target audio sample rate in Hz. FBNeo defaults to 44100. */
18
- audioSampleRate?: number;
19
- /** Enable vertical sync. Defaults to true. */
20
- vsync?: boolean;
21
- /** Use integer scaling (no fractional stretching). Defaults to false. */
22
- integerScale?: boolean;
23
- /** Window scale multiplier for the internal render resolution. Defaults to 2. */
24
- windowScale?: number;
42
+ neogeo?: 'mvs' | 'aes';
25
43
  }
26
44
 
27
- export const DEFAULT_FBNEO_OPTIONS: Required<FbneoOptions> = {
28
- romFileName: 'game.zip',
29
- driver: '',
30
- renderFilter: 'pixelated',
31
- audioSampleRate: 44100,
32
- vsync: true,
33
- integerScale: false,
34
- windowScale: 2,
35
- };
45
+ export interface FbneoAssets {
46
+ /** The game's ROM set: a `.zip` (or `.7z`) named after its driver. Required to start. */
47
+ rom?: FbneoAsset;
48
+ /** A system BIOS set some games need (`neogeo.zip` for Neo Geo). */
49
+ bios?: FbneoAsset;
50
+ }
36
51
 
37
- export const FBNEO_OPTIONS_SCHEMA: JSONSchema = {
38
- type: 'object',
39
- additionalProperties: false,
40
- properties: {
41
- romFileName: {
42
- type: 'string',
43
- default: 'game.zip',
44
- description: 'ROM zip filename written to Emscripten MEMFS when loading a game.',
52
+ /** Where this engine's files live, and whether they outlive the page. */
53
+ export interface FbneoStorage {
54
+ /**
55
+ * Per-game folder for NVRAM/EEPROM, hiscores and save states.
56
+ *
57
+ * Relative to the engine's own folder: the SDK always prefixes `fbneo/`, so the files
58
+ * land in OPFS `fbneo/<namespace>/` and no namespace can reach another engine's
59
+ * files. Segments are cleaned (`.`/`..` dropped, odd characters → `_`); anything
60
+ * unusable becomes `"default"`. `play.storagePath` gives the result.
61
+ *
62
+ * @defaultValue `"default"`
63
+ */
64
+ namespace?: string;
65
+ /** `null` keeps nothing; leaving it out (or `'opfs'`) mirrors the save folder to OPFS. */
66
+ persist?: 'opfs' | null;
67
+ }
68
+
69
+ /** Engine events beyond the contract's core set. */
70
+ export interface FbneoEvents {
71
+ /** Save files were just written to `fbneo/<namespace>/` (names relative to it). */
72
+ saves: { files: string[] };
73
+ }
74
+
75
+ export interface FbneoPayloads extends EnginePayloads {
76
+ config: FbneoConfig;
77
+ options: FbneoOptions;
78
+ assets: FbneoAssets;
79
+ storage: FbneoStorage;
80
+ events: FbneoEvents;
81
+ }
82
+
83
+ /** The canvas's backing size; FBNeo scales each game's picture into it. */
84
+ export const FBNEO_VIDEO = { width: 640, height: 480, aspect: '4:3' } as const;
85
+
86
+ export const FBNEO_SPEC: EngineSpec<FbneoPayloads> = {
87
+ config: {
88
+ renderFilter: {
89
+ default: 'pixelated',
90
+ enum: ['pixelated', 'smooth'],
91
+ live: true,
92
+ description: 'Scaling: crisp pixels or linear filtering.',
45
93
  },
94
+ jsUrl: { live: false, description: 'Emscripten glue URL. Defaults to ./fbneo.js.' },
95
+ wasmUrl: { live: false, description: 'WASM URL. Defaults to ./fbneo.wasm.' },
96
+ },
97
+ options: {
46
98
  driver: {
47
- type: 'string',
48
99
  default: '',
49
- description:
50
- 'FBNeo driver/game name to load (e.g. "mslug"). If empty, inferred from romFileName without extension.',
100
+ live: false,
101
+ description: 'FBNeo driver (ROM-set short name, e.g. "mslug"). Empty: taken from romFileName.',
51
102
  },
52
- renderFilter: {
53
- type: 'string',
54
- enum: ['pixelated', 'smooth'],
55
- default: 'pixelated',
56
- description: 'Canvas scaling filter: pixelated for crisp pixels, smooth for linear filtering.',
103
+ romFileName: {
104
+ default: '',
105
+ live: false,
106
+ description: 'The ROM zip file name; its stem is the driver when driver is empty.',
57
107
  },
58
- audioSampleRate: {
59
- type: 'integer',
60
- default: 44100,
61
- minimum: 11025,
62
- maximum: 96000,
63
- description: 'Target audio sample rate in Hz.',
108
+ neogeo: {
109
+ default: 'mvs',
110
+ enum: ['mvs', 'aes'],
111
+ live: false,
112
+ description: 'Neo Geo sets: mvs (arcade, FBNeo default) or aes (home console: AES BIOS, memory card).',
64
113
  },
65
- vsync: {
66
- type: 'boolean',
67
- default: true,
68
- description: 'Enable vertical sync.',
114
+ },
115
+ assets: {
116
+ rom: {
117
+ allowedTypes: ['.zip', '.7z'],
118
+ live: false,
119
+ description: 'The arcade ROM set, named after its driver. Required to start.',
120
+ },
121
+ bios: {
122
+ allowedTypes: ['.zip'],
123
+ live: false,
124
+ description: 'Optional system BIOS set (neogeo.zip for Neo Geo).',
69
125
  },
70
- integerScale: {
71
- type: 'boolean',
72
- default: false,
73
- description: 'Use integer scaling (no fractional stretching).',
126
+ },
127
+ storage: {
128
+ namespace: {
129
+ default: 'default',
130
+ live: false,
131
+ description: "Folder for this game's saves, inside the engine's own fbneo/ folder (OPFS fbneo/<namespace>/).",
74
132
  },
75
- windowScale: {
76
- type: 'integer',
77
- default: 2,
78
- minimum: 1,
79
- maximum: 8,
80
- description: 'Window scale multiplier for the internal render resolution.',
133
+ persist: {
134
+ enum: ['opfs', null],
135
+ live: false,
136
+ description: 'null keeps nothing; otherwise saves are mirrored to OPFS.',
81
137
  },
82
138
  },
83
- };
139
+ };