Skip to content

Conversation

@PringlesGang
Copy link
Member

@PringlesGang PringlesGang commented Dec 19, 2025

Rewrites core background and screencapture logic to more closely reflect its behaviour in the binary

CHLCC never renders its captures separately; always through a background object.
CCLCC does render its captures separately, along with through background objects.
This used to be handled by Vm::Interface::UpdateBackground2D, but that implementation was flawed, as when a background is rendered separately, SW_CAP variables are used, whereas when it's rendered through a background object, the corresponding SW_BG variables are used instead.

The distinction between background buffer and background id was also sometimes mishandled.

Between the two engine revisions, the SW_BG1DISPMODE variable also handles the background transformations differently. The class now properly changes behaviour based on the revision of the engine it is meant to emulate.

@PringlesGang PringlesGang self-assigned this Dec 19, 2025
@KKhanhH
Copy link
Collaborator

KKhanhH commented Dec 19, 2025

Do all instances of bgsprite need to be replaced with rendersprite then?

@PringlesGang
Copy link
Member Author

Do all instances of bgsprite need to be replaced with rendersprite then?

Not all of them. RenderSprite is the sprite that is ultimately to be rendered by that object in that pass; BgSprite still holds the texture that the underlying background "normally" renders

@PringlesGang PringlesGang linked an issue Dec 26, 2025 that may be closed by this pull request
@Enorovan Enorovan self-requested a review December 26, 2025 16:17
Copy link
Member

@Enorovan Enorovan left a comment

Choose a reason for hiding this comment

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

No visual regressions on Triggers, BG Movements, SetLinks, Sprites, Polygonal Effects, Sprites, Capture Events ✅

for (int i = static_cast<int>(Profile::ScreenCaptureCount) - 1; i >= 0; i--) {
const int capOffset = i * Profile::Vm::ScrWorkCaptureEffectInfoStructSize;
if (ScrWork[SW_EFF_CAP_BUF + capOffset] == GetScriptBufferId(bgId + 1)) {
RenderSprite = Screencaptures[i].BgSprite;
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of having two sprites, what if we just have a single sprite and update the spritesheet when necessary to the screencap sheet?

Copy link
Member Author

Choose a reason for hiding this comment

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

That would necessitate storing the SpriteSheet separately in each Background, as currently BgSprite is the only thing holding on to that. That ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that should be fine. You're already duplicating spritesheet by duplicating sprite, so there should just be less to dupe now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Idk man, I've just tried to dedupe the stuff, but the Sprite actually adds crucial information about the texture beyond what is already stored in the SpriteSheet

Mainly the BaseScale is important here, as for the captures and renderbuffers this represents the ratio between the window size and the design size, which is information that is not stored in the SpriteSheet but is crucial for how the texture is supposed to be rendered
Technically this could be set every time when the RenderSprite would be set, but this would also necessitate resetting it to either glm::vec2(1.0f) every time in case no capture is selected (and this is assuming there aren't ever any backgrounds that have a different BaseScale); or to a separately stored base scale, still duping it

There's an argument to be made for the Bounds, which is needlessly duped, but I don't think that fully justifies the above drop in code quality :/

tldr, I think the two sprites truly carry different semantic meaning: BgSprite is the full sprite held by the class, denoting everything that the class could render on that sheet, whereas RenderSprite denotes what part of that (or another) sheet should be rendered that frame

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, you can just leave it as bgsprite then

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.

Split Screen near the end of common, we're only missing the black bar (and other routes actually) Fix jagged script animations

4 participants