aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/kgraphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/kgraphics.cpp')
-rw-r--r--engines/sci/engine/kgraphics.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 07385fd3f9..33c819fa4c 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -33,6 +33,7 @@
#include "sci/sci.h"
#include "sci/debug.h" // for g_debug_sleeptime_factor
+#include "sci/event.h"
#include "sci/resource.h"
#include "sci/engine/features.h"
#include "sci/engine/state.h"
@@ -256,10 +257,11 @@ reg_t kGraphDrawLine(EngineState *s, int argc, reg_t *argv) {
int16 priority = (argc > 5) ? argv[5].toSint16() : -1;
int16 control = (argc > 6) ? argv[6].toSint16() : -1;
- // TODO: Find out why we get > 15 for color in EGA
- // FIXME: EGA? Which EGA? SCI0 or SCI1? Check the
- // workarounds inside kGraphFillBoxAny and kNewWindow
- if (!g_sci->getResMan()->isVGA() && !g_sci->getResMan()->isAmiga32color())
+ // WORKAROUND: SCI1 EGA games can set invalid colors (above 0 - 15).
+ // Colors above 15 are all white in SCI1 EGA games, which is why this was never
+ // observed. We clip them all to (0, 15) instead, as colors above 15 are used
+ // for the undithering algorithm in EGA games - bug #3048908.
+ if (g_sci->getResMan()->getViewType() == kViewEga && getSciVersion() >= SCI_VERSION_1_EARLY)
color &= 0x0F;
g_sci->_gfxPaint16->kernelGraphDrawLine(getGraphPoint(argv), getGraphPoint(argv + 2), color, priority, control);
@@ -297,7 +299,7 @@ reg_t kGraphFillBoxAny(EngineState *s, int argc, reg_t *argv) {
int16 priority = argv[6].toSint16(); // yes, we may read from stack sometimes here
int16 control = argv[7].toSint16(); // sierra did the same
- // WORKAROUND: PQ3 EGA is setting invalid colors (above 0 - 15).
+ // WORKAROUND: SCI1 EGA games can set invalid colors (above 0 - 15).
// Colors above 15 are all white in SCI1 EGA games, which is why this was never
// observed. We clip them all to (0, 15) instead, as colors above 15 are used
// for the undithering algorithm in EGA games - bug #3048908.
@@ -341,6 +343,11 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) {
int maxwidth = (argc > 3) ? argv[3].toUint16() : 0;
int font_nr = argv[2].toUint16();
+ if (!dest) {
+ debugC(2, kDebugLevelStrings, "GetTextSize: Empty destination");
+ return s->r_acc;
+ }
+
Common::String sep_str;
const char *sep = NULL;
if ((argc > 4) && (argv[4].segment)) {
@@ -350,7 +357,7 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) {
dest[0] = dest[1] = NULL_REG;
- if (text.empty() || !dest) { // Empty text
+ if (text.empty()) { // Empty text
dest[2] = dest[3] = make_reg(0, 0);
debugC(2, kDebugLevelStrings, "GetTextSize: Empty string");
return s->r_acc;
@@ -1083,7 +1090,7 @@ reg_t kNewWindow(EngineState *s, int argc, reg_t *argv) {
int colorPen = (argc > 7 + argextra) ? argv[7 + argextra].toSint16() : 0;
int colorBack = (argc > 8 + argextra) ? argv[8 + argextra].toSint16() : 255;
- // WORKAROUND: PQ3 EGA is setting invalid colors (above 0 - 15).
+ // WORKAROUND: SCI1 EGA games can set invalid colors (above 0 - 15).
// Colors above 15 are all white in SCI1 EGA games, which is why this was never
// observed. We clip them all to (0, 15) instead, as colors above 15 are used
// for the undithering algorithm in EGA games - bug #3048908.
@@ -1112,6 +1119,14 @@ reg_t kAnimate(EngineState *s, int argc, reg_t *argv) {
g_sci->_gfxAnimate->kernelAnimate(castListReference, cycle, argc, argv);
+ // WORKAROUND: At the end of Ecoquest 1, during the credits, the game
+ // doesn't call kGetEvent(), so no events are processed (e.g. window
+ // focusing, window moving etc). We poll events for that scene, to
+ // keep ScummVM responsive. Fixes ScummVM "freezing" during the credits,
+ // bug #3101846
+ if (g_sci->getGameId() == GID_ECOQUEST && s->currentRoomNumber() == 680)
+ g_sci->getEventManager()->getSciEvent(SCI_EVENT_PEEK);
+
return s->r_acc;
}
@@ -1254,6 +1269,7 @@ reg_t kIsHiRes(EngineState *s, int argc, reg_t *argv) {
// SCI32 variant, can't work like sci16 variants
reg_t kCantBeHere32(EngineState *s, int argc, reg_t *argv) {
+ // TODO
// reg_t curObject = argv[0];
// reg_t listReference = (argc > 1) ? argv[1] : NULL_REG;
@@ -1403,6 +1419,10 @@ reg_t kRobot(EngineState *s, int argc, reg_t *argv) {
break;
case 8: // sync
//warning("kRobot(sync), obj %04x:%04x", PRINT_REG(argv[1]));
+ // HACK: Make robots return immediately for now,
+ // otherwise they just hang for a while.
+ // TODO: Replace with proper robot functionality.
+ writeSelector(s->_segMan, argv[1], SELECTOR(signal), SIGNAL_REG);
break;
default:
warning("kRobot(%d)", subop);
@@ -1448,6 +1468,7 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv) {
// TODO: This is all a stub/skeleton, thus we're invoking kStub() for now
kStub(s, argc, argv);
+ // Can be called with 7, 8 or 9 parameters
// showStyle matches the style selector of the associated plane object
uint16 showStyle = argv[0].toUint16(); // 0 - 15
reg_t planeObj = argv[1];
@@ -1464,6 +1485,8 @@ reg_t kSetShowStyle(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
+ // TODO: Check if the plane is in the list of planes to draw
+
return s->r_acc;
}