Skip to content

Rewrite PPU pipeline for DMG-01 accuracy#18

Open
m0xsec wants to merge 1 commit intoagent_devfrom
codex/review-and-fix-ppu-implementation-for-gameboy
Open

Rewrite PPU pipeline for DMG-01 accuracy#18
m0xsec wants to merge 1 commit intoagent_devfrom
codex/review-and-fix-ppu-implementation-for-gameboy

Conversation

@m0xsec
Copy link
Owner

@m0xsec m0xsec commented Dec 6, 2025

Summary

  • replace the PPU with a cycle-driven DMG-01 implementation that manages LCD enable, modes, and STAT interrupts
  • implement full background/window/sprite rendering with palette mapping and correct tile addressing
  • enforce VRAM/OAM access timing rules and expose the screen pixel count constant used by the UI

Testing

  • cargo test -q

Codex Task

Copy link

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

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.

ℹ️ 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 on lines +321 to +323
let window_active =
self.lcdc.window_display_enable() && self.ly >= self.wy && self.wx <= 166;
let window_x_origin = self.wx.wrapping_sub(7);

Choose a reason for hiding this comment

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

P1 Badge Handle WX<7 without wrapping window start

The window X origin is computed with self.wx.wrapping_sub(7) and later compared to x as u8, so any WX value below 7 wraps to 0xF9–0xFF and the using_window check never fires. On real hardware WX−7 can be negative, allowing the window to appear from the left edge when WX is 0–6 (common for HUDs). With the current unsigned wrap the window is completely disabled for those values, so games that place the window at the left edge will render nothing.

Useful? React with 👍 / 👎.

Comment on lines +299 to +303
sprites.push((
x as u8,
y as u8,
tile,
SpriteAttrs {

Choose a reason for hiding this comment

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

P1 Badge Preserve negative sprite X positions

Sprite X positions are calculated as data[base + 1] as i16 - 8 but are immediately cast to u8 when pushed into line_sprites. For sprites whose X is less than 8 (partially off the left edge), this cast wraps negative coordinates to 0xF8+, and the later comparison (x as i16) < (*sprite_x as i16) causes the sprite to be skipped for every screen X. As a result, sprites near the left border never render even though the hardware draws their visible portion.

Useful? React with 👍 / 👎.

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