Skip to content

docs(architecture): add gb-api modularization plan - #267

Open
pakitovic wants to merge 3 commits into
mainfrom
codex/modularization-gb-api-plan
Open

docs(architecture): add gb-api modularization plan#267
pakitovic wants to merge 3 commits into
mainfrom
codex/modularization-gb-api-plan

Conversation

@pakitovic

Copy link
Copy Markdown
Owner

Summary

  • Add docs/modularization-work.md, a scoped architecture plan for introducing a narrow gb-api facade over gb-core.
  • Capture the intended facade contract, type seam, persistence boundaries, per-cycle desktop hook, migration phases, CI gates, and explicit non-goals.
  • Keep the ROM report Pages index ordered with the current report set.

Impact

This is documentation/report-index preparation only. It does not change emulator runtime behavior or gb-core APIs.

Validation

  • git diff --check
  • python3 -m json.tool crates/gb-test-runner/data/rom-reports-pages.json >/dev/null
  • cargo fmt-check
  • cargo lint
  • cargo tests
  • cargo rom-report blargg
  • commit hook: workspace check + cargo deny check

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/modularization-work.md
Comment thread docs/modularization-work.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/modularization-work.md Outdated
Comment thread docs/modularization-work.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant