Skip to content

Conversation

DnCraptor
Copy link
Contributor

  • bug-fix

Copy link

Summary of Changes

Hello @DnCraptor, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This PR refactors the ghosting implementation in the Gamate emulator, moving the logic into supervision_exec_ex for a more controlled and potentially improved visual effect. It updates the ghosting configuration, adjusts menu interaction for color editing, and modifies build settings.

Highlights

  • Intent: This pull request aims to refactor and improve the ghosting effect implementation for Gamate emulation, addressing a potential bug and enhancing the visual quality of the ghosting. It also includes minor configuration and menu interaction improvements.
  • Key Changes: The core ghosting logic has been completely rewritten and moved from gpu.c into supervision_exec_ex within watara.c. The new implementation utilizes intermediate expected_screen and rich_screen buffers to apply a more nuanced ghosting effect based on a ghosting parameter. The supervision_set_ghosting function and gpu_render_scanline have been removed, with the ghosting level now passed directly to supervision_exec_ex. Default ghosting settings have been adjusted (from 8 to 4), and the maximum configurable value in the menu is now 6, with a safeguard in load_config to cap older settings. Menu navigation has been refined, preventing movement while editing hex color values. Additionally, the CMakeLists.txt file was updated to set 'murmulator' as the default board and disable HDMI output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new ghosting effect and refactors how it's applied, which is a great improvement. However, I've found a few critical issues that will prevent the code from compiling or cause incorrect behavior at runtime. Please see my detailed comments below.

supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0, settings.ghosting);
} else {
supervision_exec_ex((uint8_t *) SCREEN, SV_W, 0);
supervision_exec_ex((uint8_t *) SCREEN, SV_W, 0, settings.ghosting);

Choose a reason for hiding this comment

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

critical

The function signature for supervision_exec_ex has been updated to include a ghosting parameter, but not all call sites have been updated. The call within the #else block for non-VGA builds is still using the old signature, which will cause a compilation error.

// Around line 1253 in the new file
#else
    supervision_exec_ex((uint8_t *) SCREEN + 240 * 20 + 40, 240, 0);
#endif

Please update all calls to supervision_exec_ex to match the new four-argument signature.

p_exp = expected_screen;
uint8_t* p_out = backbuffer;
uint8_t* p_rich = rich_screen;
for (int i = 0; i < sizeof(rich_screen); ++i) {

Choose a reason for hiding this comment

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

critical

The loop for applying the ghosting effect has incorrect bounds. It iterates sizeof(rich_screen) times, which is a fixed 200 * 240 = 48000.

However, the actual rendered area is SV_H (160) lines high, and the memory layout of each line is determined by backbufferWidth. The preceding loop that populates expected_screen only processes this SV_H-line area.

This discrepancy will cause the loop to read from uninitialized parts of expected_screen and write beyond the intended area in backbuffer, leading to visual artifacts and undefined behavior.

The loop bounds should be based on the actual rendered area, which is SV_H * backbufferWidth.

        for (int i = 0; i < SV_H * backbufferWidth; ++i) {

Comment on lines +22 to +26
set(PICO_BOARD "murmulator" CACHE STRING "Board type")
#set(PICO_BOARD "murmulator2" CACHE STRING "Board type")
#set(PICO_BOARD "olimex-pico-pc" CACHE STRING "Board type")
#set(PICO_BOARD "waveshare_rp2040_pizero" CACHE STRING "Board type")
set(PICO_BOARD "waveshare_rp2350_pizero" CACHE STRING "Board type")
#set(PICO_BOARD "waveshare_rp2350_pizero" CACHE STRING "Board type")

Choose a reason for hiding this comment

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

medium

These changes to PICO_BOARD and the HDMI option (on line 51) appear to be local development configurations. They switch the default target board to murmulator and disable HDMI output.

Are these changes intended to be part of this pull request? If not, they should be reverted to avoid altering the default build configuration for other developers.

@xrip xrip merged commit e4cd80c into xrip:main Oct 10, 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