X Tutup
Skip to content

SCI: (KQ6WinCD) - fix hires drawing glitches#6319

Merged
bluegr merged 12 commits intoscummvm:masterfrom
athrxx:sci-bug-15594
Dec 17, 2024
Merged

SCI: (KQ6WinCD) - fix hires drawing glitches#6319
bluegr merged 12 commits intoscummvm:masterfrom
athrxx:sci-bug-15594

Conversation

@athrxx
Copy link
Contributor

@athrxx athrxx commented Dec 16, 2024

This should fix issues 1- 3 from bug ticket no. 15594.

I have added redrawing functionality for the hires gfx from the original interpreter. I guess the original only needed that code to handle WM_PAINT messages (= full window redraw). It also does actually call a redraw in kDisposeWindow, the same way I implemented it here, to refresh the inventory. But that is only needed for the speech+text mode which isn't supported in the original. Maybe they ditched the mode only after they had already implemened that, who knows...

I have also improved the workaround for the out-of-bounds portraits to catch the case from the bug ticket.

(items 1- 3 from bug ticket no. 15594)

I have added redrawing functionality for the hires gfx from the
original interpreter. I guess the original only needed that code
to handle WM_PAINT messages (= full window redraw). It also
does actually call a redraw in kDisposeWindow, the same way I
implemented it here, to refresh the inventory. But that is really
only needed for the speech+text mode which isn't supported
in the original. Maybe they ditched the mode only after they
had already implemened that, who knows...

I have also improved the workaround for the out-of-bounds
portraits to catch the case from the bug ticket.
// window background when recieving WM_PAINT messages (which is irrelevant for us, since that happens in the backend) and the other is
// redrawing the inventory after displaying a text window over it. This only happens in mixed speech+text mode which does not even exist
// in the original. We do have that mode as a ScummVM feature, though. That's why we have that code, to be able to refresh the inventory.
// We also check if the portrait is drawn outside the viewport boundaries (happens in the inofficial mixed speech+text mode) and set
Copy link
Member

Choose a reason for hiding this comment

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

"unofficial"

// This is used as replacement for drawCelAndShow() when hires-cels are drawn to
// screen. Hires-cels are available only SCI 1.1+.
void GfxPaint16::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, reg_t upscaledHiresHandle, uint16 scaleX, uint16 scaleY) {
// This is used as replacement for drawCelAndShow() when hires-cels are drawn to screen. Hires-cels are available only SCI 1.1+.
Copy link
Member

Choose a reason for hiding this comment

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

"SCI 1.1+" => "SCI 1.1", since this is SCI16-only code. (I know it's an existing comment)

@sluicebox
Copy link
Member

LGTM; I haven't tested this but it's well commented and, as always, I'm convinced you know what you're doing =)

Thanks for reverse engineering these edge cases! I'll let @bluegr take a look and merge it, so that I can blame him if it crashes later.

Copy link
Member

@bluegr bluegr left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work :)
Shouldn't we add a game ID check in all that hires SCI11 code? If no other games are affected, we can skip the check

@athrxx
Copy link
Contributor Author

athrxx commented Dec 17, 2024

LGTM! Nice work :) Shouldn't we add a game ID check in all that hires SCI11 code? If no other games are affected, we can skip the check

Thanks! KQ6Win is the only game to reach the relevant code paths. No other game will call drawHiresCelAndShow(). And if that method is not called, the draw chain (_hiresDrawObjs) will remain a nullptr. Which means, the rest of the code will not be executed either. Unless I made a mistake somwhere...

athrxx and others added 9 commits December 17, 2024 01:45
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
Co-authored-by: Filippos Karapetis <bluegr@gmail.com>
@sluicebox
Copy link
Member

LGTM! Nice work :) Shouldn't we add a game ID check in all that hires SCI11 code? If no other games are affected, we can skip the check

Thanks! KQ6Win is the only game to reach the relevant code paths. No other game will call drawHiresCelAndShow(). And if that method is not called, the draw chain (_hiresDrawObjs) will remain a nullptr. Which means, the rest of the code will not be executed either. Unless I made a mistake somwhere...

When I was reviewing I was going to something similar to @bluegr but then I looked close and saw that the linked list implementation meant a nullptr wasn't going to crash it. So while I don't think it needs to change, that's two people who this raised a question for. Although for me it was on the kDisposeWindow change because that gets called by so many other games. @athrxx it's up to you, but maybe a game/version check there for more the sake of clarity and documentation? I don't feel strongly about this, but when two of us do the same double take, maybe it could be clearer..

I added a check in kDisposeWindow. It isn't strictly necessary,
but it it makes the code easier to understand.

I also renamed a var that I had previously renamed in a way
that makes no sense. I had renamed it from `upscaledHiresRect'
to 'portraitRect' since it is neither upscaled nor hires (it is just a
lowres rect). But it isn't a portrait rect either. The portraits get
drawn elsewhere. It's more likely to be a picture frame, a gui
control or an inventory item.
@athrxx
Copy link
Contributor Author

athrxx commented Dec 17, 2024

I have added two sanity checks at locations which might not be so obvious (including kDisposeWindow ).

And I also renamed a var that I had renamed previously, because the name made no sense. But I managed to rename it to something that also made no sense 😅 .

@bluegr
Copy link
Member

bluegr commented Dec 17, 2024

Looks good now, thanks! Squashing

@bluegr bluegr merged commit fdd1d16 into scummvm:master Dec 17, 2024
@athrxx athrxx deleted the sci-bug-15594 branch December 17, 2024 14:55
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.

3 participants

X Tutup