Skip to content

Conversation

@Konamiman
Copy link
Owner

@Konamiman Konamiman commented Nov 16, 2025

The mechanism to change the current image file in disk emulation mode was broken and actually only the first seven image files could be switched to, making it impossible to play games consisting of eight or more disks using disk emulation mode. This pull request fixes this.

Summary by CodeRabbit

  • Refactor
    • Optimized internal kernel operations for improved performance.

Note: This is a technical update with no direct end-user visible changes.

@Konamiman Konamiman self-assigned this Nov 16, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 16, 2025

Walkthrough

A bit-rotation sequence in the CHGLOOP routine of a Z80 assembly file was reordered. The rotation previously applied to C, E, D registers now rotates H/L first, then D, E, C. The overall control flow and exit conditions remain unchanged.

Changes

Cohort / File(s) Summary
CHGLOOP bit-rotation reordering
source/kernel/drv.mac
Modified the rotation sequence within CHGLOOP: changed from rotating C, E, D via sra/rr to rotating H/L first (srl h; rr l) then rotating D, E, C (rr d; rr e; rr c). Control flow (bit 0 check, ret nz, increment A, djnz loop) remains unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Requires verification that the reordered rotation sequence produces the correct bit shifts for the key index algorithm
  • Confirm H/L register rotation doesn't alter intended behavior or correctness of the bit-rotation logic
  • Validate that the new rotation order achieves the same algorithmic outcome despite the register sequence change

Poem

🐰 Bits spin and rotate in Z80 dance,
H/L take their turn in this key rotation's prance,
D, E, C follow through with careful grace,
The same control flow holds its place,
Click, click, click — all bits find their space!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change—fixing key scanning for disk change in floppy emulation mode—which aligns with the PR's core objective of correcting broken disk image switching functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-disk-emulation-mode-disk-change-keys

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eeca10e and 8d33c60.

📒 Files selected for processing (1)
  • source/kernel/drv.mac (1 hunks)
🔇 Additional comments (1)
source/kernel/drv.mac (1)

232-245: LGTM! Correct fix for multi-byte key status rotation.

The change properly implements a 40-bit right rotation across all five registers (H→L→D→E→C) to scan the complete key status bitmap. The original code had two critical flaws:

  1. Used sra (arithmetic shift right) which preserves the sign bit, breaking the rotation chain
  2. Omitted H and L registers entirely, limiting the scan to only 24 bits instead of the full 40 bits

This fix correctly uses srl h to initiate the rotation and chains through all five registers with rr instructions, enabling all image files to be selected as intended.

Tip

📝 Customizable high-level summaries are now available!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide custom instructions to shape the summary (bullet lists, tables, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example:

"Create a concise high-level summary as a bullet-point list. Then include a Markdown table showing lines added and removed by each contributing author."


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Konamiman Konamiman added this to the v2.1.4 milestone Nov 16, 2025
@Konamiman Konamiman changed the base branch from v2.1 to v2.1.4 November 16, 2025 15:54
@Konamiman Konamiman merged commit 14e51a3 into v2.1.4 Nov 16, 2025
1 of 2 checks passed
@Konamiman Konamiman mentioned this pull request Nov 16, 2025
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.

2 participants