@wasm-gaming/fbneo-wasm 0.1.1 → 0.2.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 (65) hide show
  1. package/README.md +133 -76
  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 +66 -19
  7. package/dist/fbneo/fbneo.options.d.ts.map +1 -1
  8. package/dist/fbneo/fbneo.options.js +39 -44
  9. package/dist/fbneo/fbneo.options.js.map +1 -1
  10. package/dist/fbneo/fbneo.sdk.d.ts +137 -8
  11. package/dist/fbneo/fbneo.sdk.d.ts.map +1 -1
  12. package/dist/fbneo/fbneo.sdk.js +588 -184
  13. package/dist/fbneo/fbneo.sdk.js.map +1 -1
  14. package/dist/fbneo/fbneo.wasm +4 -0
  15. package/dist/fbneo/neo.d.ts +83 -0
  16. package/dist/fbneo/neo.d.ts.map +1 -0
  17. package/dist/fbneo/neo.js +357 -0
  18. package/dist/fbneo/neo.js.map +1 -0
  19. package/dist/fbneo/romset.d.ts +0 -0
  20. package/dist/fbneo/romset.d.ts.map +1 -1
  21. package/dist/fbneo/romset.js +0 -0
  22. package/dist/fbneo/romset.js.map +1 -1
  23. package/{data → dist/fbneo}/romsets/capcom.json +0 -144
  24. package/{data → dist/fbneo}/romsets/index.json +7 -7
  25. package/{data → dist/fbneo}/romsets/konami.json +0 -8
  26. package/{data → dist/fbneo}/romsets/megadrive.json +0 -18
  27. package/dist/fbneo/romsets/neogeo.json +39274 -0
  28. package/{data → dist/fbneo}/romsets/nes.json +0 -81
  29. package/{data → dist/fbneo}/romsets/pgm.json +0 -73
  30. package/{data → dist/fbneo}/romsets/pre90s.json +396 -273
  31. package/{data → dist/fbneo}/romsets/pst90s.json +0 -152
  32. package/{data → dist/fbneo}/romsets/sega.json +0 -175
  33. package/{data → dist/fbneo}/romsets/sms.json +0 -9
  34. package/{data → dist/fbneo}/romsets/taito.json +0 -24
  35. package/{data → dist/fbneo}/romsets/toaplan.json +0 -60
  36. package/package.json +15 -15
  37. package/src/app/app.css +112 -0
  38. package/src/app/app.js +646 -0
  39. package/src/fbneo.options.ts +107 -63
  40. package/src/fbneo.sdk.ts +644 -212
  41. package/src/neo.ts +463 -0
  42. package/src/romset.ts +0 -0
  43. package/data/romsets/neogeo.json +0 -28260
  44. package/dist/fbneo/fbneo.manifest.d.ts +0 -4
  45. package/dist/fbneo/fbneo.manifest.d.ts.map +0 -1
  46. package/dist/fbneo/fbneo.manifest.js +0 -33
  47. package/dist/fbneo/fbneo.manifest.js.map +0 -1
  48. package/dist/manifest.json +0 -91
  49. package/src/fbneo.manifest.ts +0 -38
  50. /package/{data → dist/fbneo}/romsets/atari.json +0 -0
  51. /package/{data → dist/fbneo}/romsets/cave.json +0 -0
  52. /package/{data → dist/fbneo}/romsets/channelf.json +0 -0
  53. /package/{data → dist/fbneo}/romsets/coleco.json +0 -0
  54. /package/{data → dist/fbneo}/romsets/cps3.json +0 -0
  55. /package/{data → dist/fbneo}/romsets/dataeast.json +0 -0
  56. /package/{data → dist/fbneo}/romsets/galaxian.json +0 -0
  57. /package/{data → dist/fbneo}/romsets/irem.json +0 -0
  58. /package/{data → dist/fbneo}/romsets/midway.json +0 -0
  59. /package/{data → dist/fbneo}/romsets/msx.json +0 -0
  60. /package/{data → dist/fbneo}/romsets/pce.json +0 -0
  61. /package/{data → dist/fbneo}/romsets/pgm2.json +0 -0
  62. /package/{data → dist/fbneo}/romsets/psikyo.json +0 -0
  63. /package/{data → dist/fbneo}/romsets/sg1000.json +0 -0
  64. /package/{data → dist/fbneo}/romsets/snes.json +0 -0
  65. /package/{data → dist/fbneo}/romsets/spectrum.json +0 -0
@@ -1,83 +1,127 @@
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;
37
+ }
38
+
39
+ export interface FbneoAssets {
40
+ /** The game's ROM set: a `.zip` (or `.7z`) named after its driver. Required to start. */
41
+ rom?: FbneoAsset;
42
+ /** A system BIOS set some games need (`neogeo.zip` for Neo Geo). */
43
+ bios?: FbneoAsset;
44
+ }
45
+
46
+ /** Where this engine's files live, and whether they outlive the page. */
47
+ export interface FbneoStorage {
10
48
  /**
11
- * The FBNeo driver/game name to load (e.g. "mslug", "sf2", "kof98").
12
- * If omitted, the driver is inferred from `romFileName` (without extension).
49
+ * Per-game folder for NVRAM/EEPROM, hiscores and save states.
50
+ *
51
+ * Relative to the engine's own folder: the SDK always prefixes `fbneo/`, so the files
52
+ * land in OPFS `fbneo/<namespace>/` and no namespace can reach another engine's
53
+ * files. Segments are cleaned (`.`/`..` dropped, odd characters → `_`); anything
54
+ * unusable becomes `"default"`. `play.storagePath` gives the result.
55
+ *
56
+ * @defaultValue `"default"`
13
57
  */
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;
58
+ namespace?: string;
59
+ /** `null` keeps nothing; leaving it out (or `'opfs'`) mirrors the save folder to OPFS. */
60
+ persist?: 'opfs' | null;
25
61
  }
26
62
 
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
- };
63
+ /** Engine events beyond the contract's core set. */
64
+ export interface FbneoEvents {
65
+ /** Save files were just written to `fbneo/<namespace>/` (names relative to it). */
66
+ saves: { files: string[] };
67
+ }
36
68
 
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.',
69
+ export interface FbneoPayloads extends EnginePayloads {
70
+ config: FbneoConfig;
71
+ options: FbneoOptions;
72
+ assets: FbneoAssets;
73
+ storage: FbneoStorage;
74
+ events: FbneoEvents;
75
+ }
76
+
77
+ /** The canvas's backing size; FBNeo scales each game's picture into it. */
78
+ export const FBNEO_VIDEO = { width: 640, height: 480, aspect: '4:3' } as const;
79
+
80
+ export const FBNEO_SPEC: EngineSpec<FbneoPayloads> = {
81
+ config: {
82
+ renderFilter: {
83
+ default: 'pixelated',
84
+ enum: ['pixelated', 'smooth'],
85
+ live: true,
86
+ description: 'Scaling: crisp pixels or linear filtering.',
45
87
  },
88
+ jsUrl: { live: false, description: 'Emscripten glue URL. Defaults to ./fbneo.js.' },
89
+ wasmUrl: { live: false, description: 'WASM URL. Defaults to ./fbneo.wasm.' },
90
+ },
91
+ options: {
46
92
  driver: {
47
- type: 'string',
48
93
  default: '',
49
- description:
50
- 'FBNeo driver/game name to load (e.g. "mslug"). If empty, inferred from romFileName without extension.',
94
+ live: false,
95
+ description: 'FBNeo driver (ROM-set short name, e.g. "mslug"). Empty: taken from romFileName.',
51
96
  },
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.',
97
+ romFileName: {
98
+ default: '',
99
+ live: false,
100
+ description: 'The ROM zip file name; its stem is the driver when driver is empty.',
57
101
  },
58
- audioSampleRate: {
59
- type: 'integer',
60
- default: 44100,
61
- minimum: 11025,
62
- maximum: 96000,
63
- description: 'Target audio sample rate in Hz.',
102
+ },
103
+ assets: {
104
+ rom: {
105
+ allowedTypes: ['.zip', '.7z'],
106
+ live: false,
107
+ description: 'The arcade ROM set, named after its driver. Required to start.',
64
108
  },
65
- vsync: {
66
- type: 'boolean',
67
- default: true,
68
- description: 'Enable vertical sync.',
109
+ bios: {
110
+ allowedTypes: ['.zip'],
111
+ live: false,
112
+ description: 'Optional system BIOS set (neogeo.zip for Neo Geo).',
69
113
  },
70
- integerScale: {
71
- type: 'boolean',
72
- default: false,
73
- description: 'Use integer scaling (no fractional stretching).',
114
+ },
115
+ storage: {
116
+ namespace: {
117
+ default: 'default',
118
+ live: false,
119
+ description: "Folder for this game's saves, inside the engine's own fbneo/ folder (OPFS fbneo/<namespace>/).",
74
120
  },
75
- windowScale: {
76
- type: 'integer',
77
- default: 2,
78
- minimum: 1,
79
- maximum: 8,
80
- description: 'Window scale multiplier for the internal render resolution.',
121
+ persist: {
122
+ enum: ['opfs', null],
123
+ live: false,
124
+ description: 'null keeps nothing; otherwise saves are mirrored to OPFS.',
81
125
  },
82
126
  },
83
- };
127
+ };