aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-05-10 10:27:45 +0000
committerFilippos Karapetis2009-05-10 10:27:45 +0000
commitacd5a87922eb7a5268fa673f659be30d2eb39af6 (patch)
tree06ca6a353a606b392f9fa3038dd16fd0c9ffffe8
parentceee278def65e1a8641539602db4d7285d7a53fa (diff)
downloadscummvm-rg350-acd5a87922eb7a5268fa673f659be30d2eb39af6.tar.gz
scummvm-rg350-acd5a87922eb7a5268fa673f659be30d2eb39af6.tar.bz2
scummvm-rg350-acd5a87922eb7a5268fa673f659be30d2eb39af6.zip
Moved the code which retrieves the current room number in a separate function and merged _sci1_alloc_system_colors inside _reset_graphics_input
svn-id: r40412
-rw-r--r--engines/sci/engine/game.cpp9
-rw-r--r--engines/sci/engine/kpathing.cpp14
-rw-r--r--engines/sci/engine/kstring.cpp3
-rw-r--r--engines/sci/engine/state.h2
4 files changed, 11 insertions, 17 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 23e6d5eb64..1ebb68f81e 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -68,11 +68,6 @@ static int _init_vocabulary(EngineState *s) { // initialize vocabulary and relat
extern int _allocd_rules;
-static void _sci1_alloc_system_colors(EngineState *s) {
- gfx_color_t black = { PaletteEntry(0, 0, 0), 0, 0, 0, GFX_MASK_VISUAL };
- gfxop_set_system_color(s->gfx_state, 0, &black);
-}
-
int _reset_graphics_input(EngineState *s) {
Resource *resource;
int font_nr;
@@ -90,7 +85,9 @@ int _reset_graphics_input(EngineState *s) {
gfxop_set_system_color(s->gfx_state, i, &(s->ega_colors[i]));
}
} else {
- _sci1_alloc_system_colors(s);
+ // Allocate SCI1 system colors
+ gfx_color_t black = { PaletteEntry(0, 0, 0), 0, 0, 0, GFX_MASK_VISUAL };
+ gfxop_set_system_color(s->gfx_state, 0, &black);
// Check for Amiga palette file.
Common::File file;
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index cf1e7325ac..89fb58d0ff 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -1233,8 +1233,7 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) {
// WORKAROUND: broken polygon in LSL1VGA, room 350, after opening elevator
// Polygon has 17 points but size is set to 19
if ((size == 19) && (s->_gameName == "LSL1")) {
- // FIXME: implement function to get current room number
- if ((KP_UINT(s->script_000->locals_block->locals[13]) == 350)
+ if ((s->currentRoomNumber() == 350)
&& (read_point(list, is_reg_t, 18) == Common::Point(108, 137))) {
debug(1, "Applying fix for broken polygon in LSL1VGA, room 350");
size = 17;
@@ -1243,21 +1242,21 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) {
// WORKAROUND: self-intersecting polygons in ECO, rooms 221, 280 and 300
if ((size == 11) && (s->_gameName == "eco")) {
- if ((KP_UINT(s->script_000->locals_block->locals[13]) == 300)
+ if ((s->currentRoomNumber() == 300)
&& (read_point(list, is_reg_t, 10) == Common::Point(221, 0))) {
debug(1, "Applying fix for self-intersecting polygon in ECO, room 300");
size = 10;
}
}
if ((size == 12) && (s->_gameName == "eco")) {
- if ((KP_UINT(s->script_000->locals_block->locals[13]) == 280)
+ if ((s->currentRoomNumber() == 280)
&& (read_point(list, is_reg_t, 11) == Common::Point(238, 189))) {
debug(1, "Applying fix for self-intersecting polygon in ECO, room 280");
size = 10;
}
}
if ((size == 16) && (s->_gameName == "eco")) {
- if ((KP_UINT(s->script_000->locals_block->locals[13]) == 221)
+ if ((s->currentRoomNumber() == 221)
&& (read_point(list, is_reg_t, 1) == Common::Point(419, 175))) {
debug(1, "Applying fix for self-intersecting polygon in ECO, room 221");
// Swap the first two points
@@ -1437,11 +1436,8 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co
return NULL;
}
- if (s->_gameName == "Longbow") {
- // FIXME: implement function to get current room number
- if ((KP_UINT(s->script_000->locals_block->locals[13]) == 210))
+ if (s->_gameName == "Longbow" && s->currentRoomNumber() == 210)
fixLongbowRoom210(pf_s, *new_start, *new_end);
- }
// Merge start and end points into polygon set
pf_s->vertex_start = merge_point(pf_s, *new_start);
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 005440f679..ca5cd09a39 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -424,8 +424,7 @@ reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
// LSL5 stores the password at the beginning in memory.drv, using XOR encryption,
// which means that is_print_str() will fail. Therefore, do not use the heuristic to determine
// if we're handling a string or an array for LSL5's password screen (room 155)
- // FIXME: implement function to get current room number
- if (s->_gameName.equalsIgnoreCase("lsl5") && (KP_UINT(s->script_000->locals_block->locals[13]) == 155))
+ if (s->_gameName.equalsIgnoreCase("lsl5") && s->currentRoomNumber() == 155)
lsl5PasswordWorkaround = true;
const char* dst = (const char *)dest; // used just for code beautification purposes
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 849076fa3e..070db99823 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -231,6 +231,8 @@ public:
reg_t parser_event; /**< The event passed to Parse() and later used by Said() */
SegmentId script_000_segment;
Script *script_000; /**< script 000, e.g. for globals */
+
+ uint16 currentRoomNumber() { return KP_UINT(script_000->locals_block->locals[13]); }
int parser_lastmatch_word; /**< Position of the input word the parser last matched on, or SAID_NO_MATCH */