Skip to content

Fixed SPU code on real hardware#1990

Open
CloudMracek wants to merge 1 commit intogrumpycoders:mainfrom
CloudMracek:main
Open

Fixed SPU code on real hardware#1990
CloudMracek wants to merge 1 commit intogrumpycoders:mainfrom
CloudMracek:main

Conversation

@CloudMracek
Copy link
Contributor

SPU fixes

  • SPU not being on for dummy block DMA transfer
  • Volume set to channels was over the maximum volume value for fixed volume mode
  • SPU_KEY_LOW and HIGH are readonly. Using a bitmask on them caused a read which caused undefined volume behavior on real hardware
  • Added a more robust detection of free channels using ENDX registers, which have also been added to common/hardware/spu.h

…e robust free channel detection, other various fixes
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b877a609-cb6e-44c4-812b-a33a369ef542

📥 Commits

Reviewing files that changed from the base of the PR and between 45fcccd and 63d85bd.

📒 Files selected for processing (2)
  • src/mips/common/hardware/spu.h
  • src/mips/psyqo/src/spu.cpp

📝 Walkthrough

Walkthrough

Adds two new SPU hardware register address macros (SPU_ENDX_LOW and SPU_ENDX_HIGH). Updates SPU voice state handling in multiple functions: adjusts channel silence sample rates, reconfigures SPU controller initialization values and output volumes, changes register write behavior in audio playback, and refactors free channel detection to use the new endx bitmask instead of volume checking.

Changes

Cohort / File(s) Summary
Hardware Register Definitions
src/mips/common/hardware/spu.h
Added two new SPU hardware register address macros for SPU_ENDX_LOW (0x1f801d9c) and SPU_ENDX_HIGH (0x1f801d9e).
SPU Voice State Logic
src/mips/psyqo/src/spu.cpp
Updated channel silence handling to set sample rate to 0x1000 instead of zeroing. Modified initialize() to configure SPU_CTRL with specific bitmask and reduce output volumes from 0x7fff to 0x3fff. Changed playADPCM() key-on/key-off behavior from OR-ing to direct register overwrites. Refactored getNextFreeChannel() to detect free channels via endx bitmask instead of checking current volume.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Registers shift in silicon streams,
Where endx bits unlock the channel's dreams,
Silence whispers at 0x1000,
SPU's heart beats steady, control set just right—
A rabbit's tune now rings so bright! 🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fixed SPU code on real hardware' directly relates to the main changes in the PR, which involve fixing SPU hardware register handling and behavior on actual hardware.
Description check ✅ Passed The description comprehensively covers the changeset, detailing four specific fixes: SPU not being enabled for DMA transfer, volume exceeding maximum values, readonly SPU_KEY register issues, and ENDX register-based channel detection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Tip

You can customize the high-level summary generated by CodeRabbit.

Configure the reviews.high_level_summary_instructions setting to provide custom instructions for generating the high-level summary.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant