aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/kgraphics32.cpp
AgeCommit message (Collapse)Author
2019-06-28SCI32: Fix kShakeScreen32 parameter count checksluicebox
2017-10-06SCI32: Clean up scriptWidth/scriptHeight/screenWidth/screenHeightColin Snover
This removes the unnecessary Buffer subclass and stops most places where the output buffer was being interrogated about dimensions instead of GfxFrameout.
2017-10-06SCI32: Clean up GfxRemap32Colin Snover
* Rewrap comments to 80 columns * Clarify comments where possible
2017-10-06SCI32: Clean up GfxFrameoutColin Snover
* Rewrap doxygen comments to 80 columns * Swap public/private sections so public APIs come first * Clarify comments where easily possible
2017-10-06SCI32: Clean up GfxTransitions32Colin Snover
* Use containers where appropriate * Re-wrap doxygen comments to 80 columns * Clarify comments for parts of the engine that are understood now but were not understood at the time of the initial implementation
2017-09-30SCI32: Fix support for RAMA demoColin Snover
Fixes Trac#10251.
2017-09-29SCI32: Clean up unused kBitmap code/subopsColin Snover
2017-09-29SCI32: Fix bad text rendering in RAMAColin Snover
In SCI3, Sierra removed the ability of the main renderer to automatically scale CelObjs with different source resolutions. Instead, in SCI3, all CelObjs are treated as having the same resolution as the screen (i.e. 640x480). In all SCI3 games other than RAMA, keeping the code paths for resolution-dependent scaling is not a problem because all the assets and game code are correctly designed to use the same 640x480 resolution throughout. RAMA, on the other hand, was written with the text subsystem set to a resolution of 630x450 (Phant1's screen resolution), and in SSCI, resolution-dependent scaling code was not removed from the *text* subsystem. As a result, RAMA's game scripts rely on the slightly larger scaled dimensions coming out of the text system when determining the size of screen items for rendering, and then also rely on the main renderer ignoring the 630x450 resolution baked into the bitmaps generated by the text subsystem when drawing them to the screen.
2017-09-03SCI32: Implement kCelLinkColin Snover
kCelLink exists in SSCI since 2.1mid, but it is only known to be used in Lighthouse, during the weapon creation puzzle near the end of the game.
2017-07-09SCI32: Fix kObjectIntersectWillem Jan Palenstijn
It was using SCI16 calls to get the NowSeenRects. This fixes #9855.
2017-05-08SCI: Translate messages passed to dialoguesColin Snover
2017-05-06SCI32: Detect and handle tight loops around kGetEventColin Snover
In SSCI, mouse events are received through a hardware interrupt and the cursor is drawn directly to the graphics card by the interrupt handler. This allows game scripts to omit calls to kFrameOut without stopping the mouse cursor from being redrawn in response to mouse movement. ScummVM, in contrast, needs to poll for events and submit screen updates explicitly from the main thread. Submitting screen updates may block on vsync, which means that this call should really only be made once per frame, just after the game has finished updating its back buffer. The closest signal in SCI32 for having completed drawing a frame is the kFrameOut call, so this is where the update is submitted (by calling OSystem::updateScreen). The problem with the approach in ScummVM is that, even though the mouse position is being updated (by calls to kGetEvent) and drawn to the backend's back buffer (by GfxCursor32::drawToHardware), OSystem::updateScreen is never called during game loops that omit calls to kFrameOut. This commit introduces a workaround that looks at the number of times kGetEvent is called between calls to kFrameOut. If the number of kGetEvent calls is higher than usual (where "usual" seems to be 0 or 1), we assume that the game is running one of these tight event loops, and kGetEvent starts calling OSystem::updateScreen until the next kFrameOut call. We also then start throttling the calls to kGetEvent to keep CPU usage down. This fixes at least two such known loops: 1. When interacting with the menu bar at the top of the screen in LSL6hires; 2. When restoring a game in Phant2 and sitting on the "click mouse" screen. A similar workaround may also be needed for kGetTime, though loops around kGetTime should preferably be replaced using a script patch to call kWait instead.
2017-05-02SCI32: Fix incorrect arguments to readPixel in kCelInfoColin Snover
Fixes Trac#9750.
2017-04-22SCI32: Fix bad kPointSize implementationColin Snover
Fixes text scaling gone mad in Phant2.
2017-04-22SCI32: Add palette code for late SCI2.1mid+ gamesColin Snover
Sometime during SCI2.1mid, the palette manager was changed to save and restore the source palette, and to add in-game gamma correction. Previously, only the vary start and target palettes were saved, and gamma correction was only configurable in SSCI by editing RESOURCE.CFG.
2017-03-30SCI32: Fix crash when using brightness slider in ShiversColin Snover
2017-01-09SCI32: Split kCelInfo into subopsColin Snover
Different subops have different call signature requirements.
2017-01-09SCI32: Fix kSetShowStyle signature for SCI3Colin Snover
2017-01-05SCI32: Add validity checks to kList iteration methodsColin Snover
In GK2, restoring a save game causes the segment manager to reset in the middle of a kListFirstTrue call, which invalidates all pointers and reg_ts to stored data. This means that when kListFirstTrue tries to decrement the list recursion counter at the end of iteration, it is writing to freed memory, potentially resulting in heap corruption. SCI3 added checks to prevent this from happening, but these checks seem like they should have also been applied to some SCI2.1 games as well (like GK2). Since there should be no negative side-effect to this check, it is applied universally to all SCI32 games.
2016-12-19SCI32: Add support for alternate graphics selectorsColin Snover
Used by at least Phantasmagoria 2.
2016-10-20SCI32: Split out detection of features that cross SSCI versionsColin Snover
2016-10-15SCI32: Fix kPalVary(SetVary) in SCI2.1early gamesColin Snover
Game scripts pass an extra argument which is never used in SSCI. This happens e.g. when warping from room 620 to room 860 in LSL6hires. Adding a signature for kPalVarySetVary for SCI2.1early games only does not work because KQ7 1.51 is detected as SCI2.1early but the interpreter includes kPalVary code that matches SCI2.1mid. Fixes Trac#9611.
2016-10-09SCI32: Clarify some identifiersColin Snover
transparentColor -> skipColor displace -> origin scaledWidth -> xResolution scaledHeight -> yResolution
2016-09-30SCI32: Fix some buildbot compiler warningsColin Snover
2016-09-29SCI32: Clean up and document GfxPalette32Colin Snover
2016-09-29SCI32: Implement kBitmapCreateFromView and kBitmapGetInfoColin Snover
Used by Torin room 40300 to perform pathfinding by bitmap.
2016-09-29SCI32: Rewrite kArray & kStringColin Snover
This change invalidates earlier SCI32 save games, which separated arrays and strings in an incompatible manner. Old save games contain invalid references to a string segment which no longer exists, and contain incompatible array structures that lack critical type information.
2016-08-27SCI32: Allow invalid bitmap references to be passed to kBitmapDestroyColin Snover
SSCI explicitly ignored invalid references passed to this function. Fixes GK1 room 410, when using the Rada Drum book on the drummer.
2016-08-26SCI32: Fix warningWillem Jan Palenstijn
2016-08-22SCI32: Add stubs for the kPlayVMDSetPreload and kPaletteSetGamma callsFilippos Karapetis
These were introduced in SCI3, and are used by RAMA. We don't preload videos, so we don't really need kPlayVMDSetPreload, but kPaletteSetGamma may need an implementation. With these two stubs, the main menu of RAMA is working again
2016-08-19SCI32: Fix limited data range comparison warningColin Snover
On at least DC platform, the ShowStyleType enum is fit to a 4-bit data size, so the 16-bit input value needs to be checked for validity *before* it is cast to a 4-bit ShowStyleType.
2016-08-19SCI32: Remove CoordAdjuster32, at least for the momentColin Snover
This may come back in the future to deduplicate some gfx code, but SCI32 had two different inlined ways of doing coordinate conversions with different rounding methods, so CoordAdjuster32 didn't get used when the graphics system was rewritten. At the moment, SCI32 code uses the mulru/mulinc methods from helper.h for scaling up/down coordinates.
2016-08-19SCI32: Add kSetNowSeen variant for older SCI32 gamesColin Snover
KQ7 2.00b, PQ:SWAT, Phant1, GK2, and Torin are all verified as using the 'ignore' variant; SQ6 and QFG4CD are verified as using the 'fail' variant. MGDX and Shivers could not be checked as they have only Phar Lap Win16 executables, so took a guess based on their release dates.
2016-08-19SCI32: Implement kShakeScreen for SCI32Colin Snover
2016-08-19SCI32: Remove GfxScreen from SCI32Colin Snover
2016-08-19SCI32: Implement SCI32 cursor supportColin Snover
2016-08-01SCI32: Add bitmap segment and remove GC option from hunk segmentColin Snover
2016-08-01SCI32: Add 6-argument signature of kAddPicAtColin Snover
This is used by Torin in room 50900.
2016-08-01SCI32: Implement plane transitions (kSetShowStyle and kSetScroll)Colin Snover
This commit implements all of the known plane transitions from SCI2 through SCI2.1mid games. Because kSetShowStyle is always called indirectly via the Styler game script, it is difficult to find all the places where transitions are used. As such, transitions that appeared to never be used have been added as stubs which will trigger a game crash with a message to report what was being done, so any missed transition types can be identified quickly and then implemented.
2016-08-01SCI32: Enable optional explicit memory management of hunk entriesColin Snover
Bitmaps in ScrollWindow and Robot code are managed by the kernel and not by game scripts, although they must be able to be referenced through a reg_t. To prevent incorrect GC of bitmaps that are in use but not referenced by any game script, explicit memory management of hunk entries can be enabled.
2016-07-11SCI32: Split GfxPalette and GfxPalette32 + HunkPaletteColin Snover
2016-07-11SCI32: Split kPalCycle into subop functionsColin Snover
2016-06-26SCI32: Fix broken Remap implementationColin Snover
Remap would crash SCI2.1early games with 19 remap slots, and did not actually work in most cases in SCI2.1mid+ games. The SCI16 implementation was moved to its own separate file but was otherwise touched as little as possible, so may still have similar problems to the SCI32 code. 1. Split SCI16 and SCI32 code into separate files 2. Use -32 prefixes for SCI32 code and no prefix for SCI16 code, where possible, to match other existing code 3. Avoid accidental corruption of values from the VM that may be valid when signed or larger than 8 bits 4. Added documentation 5. Add missing remap CelObj calls 6. Inline where possible in performance-critical code paths 7. Fix bad `matchColor` function, and move it from GfxPalette to GfxRemap32 since it is only used by GfxRemap32 8. Fix bad capitalisation in getCycleMap 9. Remove unnecessary initialisation of SingleRemaps 10. Update architecture to more closely mirror how SSCI worked 11. Clarify the purpose of each type of remap type (and associated variable names) 12. Split large `apply` function into smaller units 13. Fix buffer overrun when loading a SCI2.1early game with remap 14. Remove use of `#define` constants 15. Warn instead of crashing with an error on invalid input (to match SSCI more closely) 16. Change the collision avoidance mechanism between the RemapType enum and remap kernel functions 17. Add save/load function
2016-06-21SCI32: Implement kBitmapDrawViewColin Snover
2016-06-21SCI32: Expose a draw buffer on BitmapResource objectsColin Snover
Most of the time, we get a bitmap to draw on it. Exposing a buffer avoids consumers having to create their own all the time, and encourages use of common drawing code exposed by the buffer.
2016-06-21SCI32: Implement basic kMessageBoxColin Snover
This kernel call seems only to be used by KQ7 1.51 (which was Windows-only) to send warnings to the user. It was easy enough to do a basic implementation in the ScummVM GUI rather than just make it an empty call, so now it is a thing.
2016-06-21SCI32: Implement kScrollWindowWillem Jan Palenstijn
These should be all the actually used subfunctions. Co-authored-by: Colin Snover <github.com@zetafleet.com>
2016-06-21SCI32: Implement line drawing (kAddLine/kUpdateLine/kRemoveLine)Colin Snover
This line drawing code lives in a remodelled GfxPaint32 class that is totally separate from GfxPaint16.
2016-06-14SCI32: Fix video performance benchmarking in most SCI32 gamesColin Snover
Most SCI32 games draw a "fred" object to the screen when the game first starts to benchmark video performance. When framerate throttling is enabled (which fixes many/most timing-related bugs and reduces system load caused by unnecessary graphics updates), the game's performance check will think that video card is slow, causing some "high-performance" game features to be disabled. To avoid this, we simply disable throttling during benchmarking by detecting the "fred" object.
2016-05-27SCI32: Add explicit checks for null pointersColin Snover
CID 1351617, 1351618, 1351619, 1351620, 1351621, 1351622, 1354791.