@tmustier/pi-nes 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -23,7 +23,8 @@ pi-nes/
23
23
  ├── saves.ts # SRAM persistence
24
24
  └── native/
25
25
  ├── nes-core/ # Rust NES emulator addon (required)
26
- │ ├── Cargo.toml # Dependencies: nes_rust, napi
26
+ │ ├── Cargo.toml # Dependencies: vendored nes_rust, napi
27
+ │ ├── vendor/nes_rust/ # Patched nes_rust crate (SRAM helpers)
27
28
  │ ├── src/lib.rs # Exposes NativeNes class via napi-rs
28
29
  │ └── index.node # Compiled binary
29
30
  └── kitty-shm/ # Rust shared memory addon (optional)
@@ -33,7 +34,7 @@ pi-nes/
33
34
 
34
35
  ### Native Core
35
36
 
36
- The emulator uses the [`nes_rust`](https://crates.io/crates/nes_rust) crate with [napi-rs](https://napi.rs) bindings.
37
+ The emulator uses the [`nes_rust`](https://crates.io/crates/nes_rust) crate (vendored + patched in `native/nes-core/vendor/nes_rust` for SRAM helpers) with [napi-rs](https://napi.rs) bindings.
37
38
 
38
39
  **API exposed to JavaScript:**
39
40
  - `new NativeNes()` - Create emulator instance
@@ -41,6 +42,9 @@ The emulator uses the [`nes_rust`](https://crates.io/crates/nes_rust) crate with
41
42
  - `bootup()` / `reset()` - Start/restart emulation
42
43
  - `stepFrame()` - Advance one frame (~60fps)
43
44
  - `pressButton(n)` / `releaseButton(n)` - Controller input (0=select, 1=start, 2=A, 3=B, 4-7=dpad)
45
+ - `hasBatteryBackedRam()` - Whether the ROM supports battery SRAM
46
+ - `getSram()` / `setSram(Uint8Array)` - Read/write SRAM
47
+ - `isSramDirty()` / `markSramSaved()` - Dirty tracking for SRAM persistence
44
48
  - `getFramebuffer()` - Returns RGB pixel data (256×240×3 bytes, zero-copy via external buffer)
45
49
 
46
50
  ### Rendering Pipeline
package/README.md CHANGED
@@ -86,9 +86,9 @@ Config is stored at `~/.pi/nes/config.json`. Use `/nes config` for guided setup.
86
86
 
87
87
  ## Terminal Support
88
88
 
89
- **Best experience:** [Kitty](https://sw.kovidgoyal.net/kitty/) terminal with image protocol support.
89
+ **Best experience:** a Kitty-protocol terminal like Ghostty, Kitty, or WezTerm (image protocol + key-up events).
90
90
 
91
- - **Kitty** — Full graphics via image protocol (shared memory or file transport)
91
+ - **Kitty-protocol terminals** — Full graphics via image protocol (shared memory or file transport)
92
92
  - **Other terminals** — Falls back to ANSI half-block characters (`▀▄`)
93
93
 
94
94
  Set `"renderer": "text"` if you prefer the ANSI renderer or have display issues.
@@ -17,13 +17,13 @@ export interface NesConfig {
17
17
 
18
18
  const DEFAULT_ROM_DIR = path.join(path.sep, "roms", "nes");
19
19
 
20
- function defaultSaveDir(romDir: string): string {
20
+ export function getDefaultSaveDir(romDir: string): string {
21
21
  return path.join(romDir, "saves");
22
22
  }
23
23
 
24
24
  export const DEFAULT_CONFIG: NesConfig = {
25
25
  romDir: DEFAULT_ROM_DIR,
26
- saveDir: defaultSaveDir(DEFAULT_ROM_DIR),
26
+ saveDir: getDefaultSaveDir(DEFAULT_ROM_DIR),
27
27
  enableAudio: false,
28
28
  renderer: "image",
29
29
  pixelScale: 1.2,
@@ -49,7 +49,7 @@ export function normalizeConfig(raw: unknown): NesConfig {
49
49
  typeof parsed.romDir === "string" && parsed.romDir.length > 0
50
50
  ? normalizePath(parsed.romDir, DEFAULT_CONFIG.romDir)
51
51
  : DEFAULT_CONFIG.romDir;
52
- const saveDirFallback = defaultSaveDir(romDir);
52
+ const saveDirFallback = getDefaultSaveDir(romDir);
53
53
  const saveDir =
54
54
  typeof parsed.saveDir === "string" && parsed.saveDir.length > 0
55
55
  ? normalizePath(parsed.saveDir, saveDirFallback)
@@ -8,6 +8,7 @@ import {
8
8
  configExists,
9
9
  formatConfig,
10
10
  getConfigPath,
11
+ getDefaultSaveDir,
11
12
  loadConfig,
12
13
  normalizeConfig,
13
14
  saveConfig,
@@ -139,17 +140,28 @@ async function configureWithWizard(
139
140
  ctx: ExtensionCommandContext,
140
141
  config: Awaited<ReturnType<typeof loadConfig>>,
141
142
  ): Promise<boolean> {
142
- const romDirPlaceholder = displayPath(config.romDir);
143
- const romDirInput = await ctx.ui.input(
144
- "ROM directory (or wherever you want to keep your roms)",
145
- romDirPlaceholder,
146
- );
147
- if (romDirInput === undefined) {
143
+ const romDirDisplay = displayPath(config.romDir);
144
+ const romDirDefaultLabel = config.romDir === DEFAULT_CONFIG.romDir ? "Use default" : "Use current";
145
+ const romDirOptions = [
146
+ `${romDirDefaultLabel} (${romDirDisplay})`,
147
+ "Enter a custom path",
148
+ ];
149
+ const romDirChoice = await ctx.ui.select("ROM directory", romDirOptions);
150
+ if (!romDirChoice) {
148
151
  return false;
149
152
  }
150
- const trimmedRomDir = romDirInput.trim();
153
+
151
154
  let romDir = config.romDir;
152
- if (trimmedRomDir) {
155
+ if (romDirChoice === romDirOptions[1]) {
156
+ const romDirInput = await ctx.ui.input("ROM directory", romDirDisplay);
157
+ if (romDirInput === undefined) {
158
+ return false;
159
+ }
160
+ const trimmedRomDir = romDirInput.trim();
161
+ if (!trimmedRomDir) {
162
+ ctx.ui.notify("ROM directory cannot be empty.", "error");
163
+ return false;
164
+ }
153
165
  romDir = resolvePathInput(trimmedRomDir, ctx.cwd);
154
166
  const valid = await validateRomDir(romDir, ctx);
155
167
  if (!valid) {
@@ -192,9 +204,13 @@ async function configureWithWizard(
192
204
  pixelScale = parsed;
193
205
  }
194
206
 
207
+ const defaultSaveDir = getDefaultSaveDir(config.romDir);
208
+ const shouldSyncSaveDir = config.saveDir === defaultSaveDir;
209
+ const saveDir = shouldSyncSaveDir ? getDefaultSaveDir(romDir) : config.saveDir;
195
210
  const normalized = normalizeConfig({
196
211
  ...config,
197
212
  romDir,
213
+ saveDir,
198
214
  pixelScale,
199
215
  });
200
216
  await saveConfig(normalized);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmustier/pi-nes",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "NES emulator extension for pi",
5
5
  "keywords": [
6
6
  "pi-package",