docs(architecture): add gb-api modularization plan - #267
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db4e951ba0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d502ef12e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c64f222ce1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| **Steps.** | ||
| 1. Add `gb-api` (with `persistence` + `audio` features) to `crates/gb-desktop/Cargo.toml`, alongside the retained `gb-core` dependency. | ||
| 2. For standalone sessions only, replace the play-loop construction/stepping/presentation calls with `gb_api::{Gameboy, Emulator}` and `gb_api::types::*`. Drive `step_until_next_frame`'s per-cycle work (audio `capture_t_cycle`, RTC sync, event polling, telemetry counters) through `run_frame_with`'s `CycleView`; route battery/RTC saves through `cartridge_persistent_state` and whole-machine saves through the `SaveStateBlob` API, writing with `as_bytes`/`into_bytes` and restoring bytes read from disk with `from_bytes`. Switch domain imports (`JoypadButton`, `HardwareRevision`, `ConsoleModel`, `StartupMode`, `ApuHostSample`, …) from `gb_core::` to `gb_api::types::` only in the standalone path. |
There was a problem hiding this comment.
Preserve desktop channel-isolated audio capture
When the standalone desktop loop is migrated through CycleView, this instruction only provides ApuHostSample for audio, but the current desktop audio paths require the live &Apu for selected-channel playback/recording: DesktopAudioOutput::capture_t_cycle calls recorded_channel_mix_tap_pre_hpf when the channel mask is not ALL, and DesktopAudioRecorder also reads per-channel taps for stems. In those CONFIG -> AUDIO CH1/CH2/CH3/CH4 or --audio-record-stems contexts, routing capture through the planned hook would silently collapse diagnostics to the full mixed sample unless the facade exposes a narrow tap API or these modes stay on the direct core path.
Useful? React with 👍 / 👎.
| ```rust | ||
| // crates/gb-api/src/emulator.rs | ||
| use crate::frontier::{ | ||
| AudioBatch, EmulatorConfig, EmulatorError, Framebuffer, FrameOutput, SaveStateBlob, |
There was a problem hiding this comment.
Gate SaveStateBlob imports with persistence
SaveStateBlob is defined later under #[cfg(feature = "persistence")], but this planned emulator.rs import pulls it unconditionally. Rust resolves the use item even when only the extension trait methods need the type, so the required cargo build -p gb-api --no-default-features gate will fail unless the import is also cfg-gated or moved inside a persistence-gated module/block.
Useful? React with 👍 / 👎.
Summary
docs/modularization-work.md, a scoped architecture plan for introducing a narrowgb-apifacade overgb-core.Impact
This is documentation/report-index preparation only. It does not change emulator runtime behavior or
gb-coreAPIs.Validation
git diff --checkpython3 -m json.tool crates/gb-test-runner/data/rom-reports-pages.json >/dev/nullcargo fmt-checkcargo lintcargo testscargo rom-report blarggcargo deny check