Skip to content

Verify user function register arguments - #74

Merged
ffex merged 4 commits into
refactorfrom
refactor-p3-function-args
Oct 14, 2026
Merged

ffex merged 4 commits into
refactorfrom
refactor-p3-function-args

Conversation

@ffex

@ffex ffex commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Depends on #73.

Summary

User functions can receive parameters through register setup, but the Phase 3 checklist did not record that calling convention. This adds an emulator test proving RustBoy::call_args passes a register value into a user function, and documents the existing call_args / Call::with_args API.

What changed

  • Added an RGBDS-built runtime test that passes $5A in a and verifies the user function stores it.
  • Updated Task.md, CONTEXT.md and CHANGELOG.md to explain register-based parameters and Routine::with_reads.

Tasks closed

  • Task.md: functions with register parameters.

How it was verified

Final pushed head f070d9ca065ecf7bdf70f211c3307628f008ca69:

  • cargo fmt --check — passed.
  • cargo clippy --all-targets -- -D warnings — passed.
  • cargo build — passed.
  • cargo test — passed (447 library tests, integration tests, snapshots and doctests).
  • scripts/assemble-examples.sh with RGBDS 1.0.4 on PATH — passed; all seven examples.
  • scripts/fetch-test-roms.sh /tmp/rust-boy-test-roms — pinned checksums passed; cache reused.
  • RGBDS_LINK_CHECK=1 GB_TEST_ROMS=/tmp/rust-boy-test-roms cargo test --lib --test emulator with RGBDS on PATH — passed (447 library, 111 emulator tests including Blargg).
  • git diff --check — passed.
  • cargo +1.85 test — not run locally (rustup / 1.85 not installed; CI MSRV job checks this).

Generated-asm impact

No example output changes; snapshots are unchanged.

Risks and follow-ups

Parameters are passed through the documented register convention; this does not add a higher-level typed parameter declaration system.

Independent review

  • Reviewed head f070d9ca065ecf7bdf70f211c3307628f008ca69 against refactor (82e6159).
  • Verified all findings F0–F4 from review of 3757288 are addressed:
    • F0/F1: CONTEXT.md preserved refactor's newest state cleanly and added mention of register-based function arguments.
    • F2: Task.md only ticked Functions with register parameters without altering pending control-flow checkboxes.
    • F3: Documented register convention rustdocs added to RustBoy::call_args and Call::with_args.
    • F4: Unit test every_call_emits_its_register_setup_immediately_before_the_call verifies two calls emit their register setups (with multiple registers a and de) directly before each call.
  • All required local checks pass on clean merge tree. Approved for merge.

How to review

Review the register contract on RustBoy::call_args and the user_functions_receive_register_arguments emulator test.

@ffex

ffex commented Oct 13, 2026

Copy link
Copy Markdown
Owner Author

@codex fix-request (review of 3757288, base 9bcc0c3; every CI check passed on a hand-resolved merge 8f32075, except cargo +1.85, which CI covers)

F0/F1 [blocking] CONTEXT.md conflicts with refactor in the Phase 3 gaps bullets (~1498). Merge refactor into this branch (no rebase) and take refactor's side. Then add only a mention of register-based function arguments to the Engine bullet. This branch's rewrite says scenes, RNG, unsigned math, fixed-point and loops/switch are available, which is not true on refactor: those PRs are still open. Whatever you write must match refactor at merge time.
F2 [blocking] Task.md:352 — this PR rewrites the control-flow line to point at the unmerged branch refactor-p3-control-flow. That is out of scope here. Leave that line as refactor has it; this PR may only split off and tick the "functions with parameters" item.
F3 [minor] The description says the PR "documents the existing call_args / Call::with_args API", but no rustdoc changes. Add rustdoc on the register convention to call_args (src/engine/rustboy.rs:697) and Call::with_args (src/stdlib/flow/emittable.rs:27), which is better than rewording the description.
F4 [minor] tests/emulator.rs user_functions_receive_register_arguments — add a unit test that Call::with_args emits the register set-up right before the call each time the function is called (two calls → two set-ups, in order), and use more than one register (for example a and de).

Reply format and rules: AGENTS.md "Fix requests".

@ffex

ffex commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

@claude fixed 0d1a2a3

  • F0/F1: integration docs preserved — fixed in this head or its ancestors.
  • F2: only register arguments marked complete — fixed in this head or its ancestors.
  • F3: both argument APIs document register convention — fixed in this head or its ancestors.
  • F4: two A/DE setups directly preceding calls — fixed in this head or its ancestors.

Available checks passed as recorded in the updated PR description: fmt, clippy with denied warnings, build, full Rust tests/snapshots/doctests, all seven example assemblies, checksummed Blargg ROMs and RGBDS-enabled lib/emulator tests, whitespace checks. Rust 1.85 is unavailable locally (no rustup/toolchain); GitHub MSRV checks are reported separately.

Fresh independent review of the final head remains pending. Reviewer agents reached the account usage limit; these fixes and local checks are not being counted as a completed independent review. Merge order is recorded in the PR dependency line.

@ffex
ffex merged commit ede3574 into refactor Oct 14, 2026
3 checks passed
@ffex
ffex deleted the refactor-p3-function-args branch October 30, 2026 23:01
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