[Scummvm-git-logs] scummvm master -> a2ffe428bfe8e53ec5d6a1422515ea036ee75bfa
dreammaster
noreply at scummvm.org
Mon Jan 13 20:33:00 UTC 2025
This automated email contains information about 13 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1ca3ba3a9b GOT: Code formatting in folders Data (+ status)
4c8b879fc6 GOT: modify access to global arrays in gfx, code alignment
cf9a65e0e0 GOT: Rest of code alignment in gfx
58f88bcf29 GOT: Remove the obsolete panel.h
2f2157eb1f GOT: Fix compilation warning
c149ea878e GOT: Change includes in res_archive, code formatting in utils
81c0e64973 GOT: Remove unused class
a475bf6d39 GOT: Start working on views (modification of access to global arrays, code formatting)
b8fe361e47 GOT: Fix handling of slow_mode and _setup.speed
a61f1bedf8 GOT: More code formatting in dialogs
dd24330482 GOT : Change access to global arrays in game_content
6ec2d60b32 GOT: Remove unimplemented method in game_content
a2ffe428bf GOT: global array access and code formating in views (partial)
Commit: 1ca3ba3a9b70c7406d466d044eec634c1f955ad0
https://github.com/scummvm/scummvm/commit/1ca3ba3a9b70c7406d466d044eec634c1f955ad0
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:15-08:00
Commit Message:
GOT: Code formatting in folders Data (+ status)
Changed paths:
engines/got/data/actor.cpp
engines/got/data/actor.h
engines/got/data/defines.h
engines/got/data/high_scores.cpp
engines/got/data/high_scores.h
engines/got/data/level.cpp
engines/got/data/level.h
engines/got/data/sd_data.cpp
engines/got/data/sd_data.h
engines/got/data/setup.cpp
engines/got/data/setup.h
engines/got/data/thor_info.cpp
engines/got/data/thor_info.h
engines/got/game/back.h
engines/got/game/status.cpp
engines/got/game/status.h
diff --git a/engines/got/data/actor.cpp b/engines/got/data/actor.cpp
index aaf26b36a5d..f0d3c4d0a84 100644
--- a/engines/got/data/actor.cpp
+++ b/engines/got/data/actor.cpp
@@ -19,76 +19,77 @@
*
*/
+#include "got/data/actor.h"
#include "common/algorithm.h"
#include "common/memstream.h"
-#include "got/data/actor.h"
namespace Got {
void ACTOR::loadFixed(Common::SeekableReadStream *src) {
- move = src->readByte();
- width = src->readByte();
- height = src->readByte();
- directions = src->readByte();
- frames = src->readByte();
- frame_speed = src->readByte();
- src->read(frame_sequence, 4);
- speed = src->readByte();
- size_x = src->readByte();
- size_y = src->readByte();
- strength = src->readByte();
- health = src->readByte();
- num_moves = src->readByte();
- shot_type = src->readByte();
- shot_pattern = src->readByte();
- shots_allowed = src->readByte();
- solid = src->readByte();
- flying = src->readByte();
- rating = src->readByte();
- type = src->readByte();
- src->read(name, 9);
- func_num = src->readByte();
- func_pass = src->readByte();
- magic_hurts = src->readSint16LE();
- src->read(future1, 4);
+ move = src->readByte();
+ width = src->readByte();
+ height = src->readByte();
+ directions = src->readByte();
+ frames = src->readByte();
+ frame_speed = src->readByte();
+ src->read(frame_sequence, 4);
+ speed = src->readByte();
+ size_x = src->readByte();
+ size_y = src->readByte();
+ strength = src->readByte();
+ health = src->readByte();
+ num_moves = src->readByte();
+ shot_type = src->readByte();
+ shot_pattern = src->readByte();
+ shots_allowed = src->readByte();
+ solid = src->readByte();
+ flying = src->readByte();
+ rating = src->readByte();
+ type = src->readByte();
+ src->read(name, 9);
+ func_num = src->readByte();
+ func_pass = src->readByte();
+ magic_hurts = src->readSint16LE();
+ src->read(future1, 4);
}
void ACTOR::loadFixed(const byte *src) {
- Common::MemoryReadStream stream(src, 40);
- loadFixed(&stream);
+ Common::MemoryReadStream stream(src, 40);
+ loadFixed(&stream);
}
void ACTOR::copyFixedAndPics(const ACTOR &src) {
- move = src.move;
- width = src.width;
- height = src.height;
- directions = src.directions;
- frames = src.frames;
- frame_speed = src.frame_speed;
- Common::copy(src.frame_sequence, src.frame_sequence + 4, frame_sequence);
- speed = src.speed;
- size_x = src.size_x;
- size_y = src.size_y;
- strength = src.strength;
- health = src.health;
- num_moves = src.num_moves;
- shot_type = src.shot_type;
- shot_pattern = src.shot_pattern;
- shots_allowed = src.shots_allowed;
- solid = src.solid;
- flying = src.flying;
- rating = src.rating;
- type = src.type;
- Common::copy(src.name, src.name + 9, name);
- func_num = src.func_num;
- func_pass = src.func_pass;
- magic_hurts = src.magic_hurts;
- Common::copy(src.future1, src.future1 + 4, future1);
+ move = src.move;
+ width = src.width;
+ height = src.height;
+ directions = src.directions;
+ frames = src.frames;
+ frame_speed = src.frame_speed;
+ Common::copy(src.frame_sequence, src.frame_sequence + 4, frame_sequence);
+ speed = src.speed;
+ size_x = src.size_x;
+ size_y = src.size_y;
+ strength = src.strength;
+ health = src.health;
+ num_moves = src.num_moves;
+ shot_type = src.shot_type;
+ shot_pattern = src.shot_pattern;
+ shots_allowed = src.shots_allowed;
+ solid = src.solid;
+ flying = src.flying;
+ rating = src.rating;
+ type = src.type;
+ Common::copy(src.name, src.name + 9, name);
+ func_num = src.func_num;
+ func_pass = src.func_pass;
+ magic_hurts = src.magic_hurts;
+ Common::copy(src.future1, src.future1 + 4, future1);
- // Copy all the surfaces for all the directions over
- for (int d = 0; d < DIRECTION_COUNT; ++d)
+ // Copy all the surfaces for all the directions over
+ for (int d = 0; d < DIRECTION_COUNT; ++d) {
for (int f = 0; f < FRAME_COUNT; ++f)
pic[d][f].copyFrom(src.pic[d][f]);
+ }
}
ACTOR &ACTOR::operator=(const ACTOR &src) {
diff --git a/engines/got/data/actor.h b/engines/got/data/actor.h
index deea054e046..ac3233b3f82 100644
--- a/engines/got/data/actor.h
+++ b/engines/got/data/actor.h
@@ -30,95 +30,95 @@ namespace Got {
#define DIRECTION_COUNT 4
#define FRAME_COUNT 4
-struct ACTOR { // Size=256
- // First part loaded from disk (size=40)
- byte move = 0; // Movement pattern (0=none)
- byte width = 0; // Physical width
- byte height = 0; // Physical height
- byte directions = 0; // 1,2 or 4 (1=uni-directional)
- byte frames = 0; // # frames per direction
- byte frame_speed = 0; // # cycles between frame changes
- byte frame_sequence[4] = {}; // Sequence
- byte speed = 0; // Move every Nth cycle
- byte size_x = 0; // Non-physical padding on X coordinate
- byte size_y = 0; // Non-physical padding on Y coordinate
- byte strength = 0; // Hit strength
- byte health = 0; //
- byte num_moves = 0; // # of moves every <speed> cycles
- byte shot_type = 0; // Actor # of shot
- byte shot_pattern = 0; // Func number to decide to shoot
- byte shots_allowed = 0; // # shots allowed on screen
- byte solid = 0; // 1=solid (not ghost,etc)
- byte flying = 0; //
- byte rating = 0; // rnd(100) < rating = jewel
- byte type = 0; // Actor (0=thor,1=hammer,2=enemy,3=shot)
- char name[9] = {}; // Actors name
- byte func_num = 0; // Special function when thor touches
- byte func_pass = 0; // Value to pass to func
- uint16 magic_hurts = 0; // Bitwise magic hurts flags
- byte future1[4] = {};
+struct ACTOR { // Size=256
+ // First part loaded from disk (size=40)
+ byte move = 0; // Movement pattern (0=none)
+ byte width = 0; // Physical width
+ byte height = 0; // Physical height
+ byte directions = 0; // 1,2 or 4 (1=uni-directional)
+ byte frames = 0; // # frames per direction
+ byte frame_speed = 0; // # cycles between frame changes
+ byte frame_sequence[4] = {}; // Sequence
+ byte speed = 0; // Move every Nth cycle
+ byte size_x = 0; // Non-physical padding on X coordinate
+ byte size_y = 0; // Non-physical padding on Y coordinate
+ byte strength = 0; // Hit strength
+ byte health = 0; //
+ byte num_moves = 0; // # of moves every <speed> cycles
+ byte shot_type = 0; // Actor # of shot
+ byte shot_pattern = 0; // Func number to decide to shoot
+ byte shots_allowed = 0; // # shots allowed on screen
+ byte solid = 0; // 1=solid (not ghost,etc)
+ byte flying = 0; //
+ byte rating = 0; // rnd(100) < rating = jewel
+ byte type = 0; // Actor (0=thor,1=hammer,2=enemy,3=shot)
+ char name[9] = {}; // Actors name
+ byte func_num = 0; // Special function when thor touches
+ byte func_pass = 0; // Value to pass to func
+ uint16 magic_hurts = 0; // Bitwise magic hurts flags
+ byte future1[4] = {};
- // The rest is dynamic //size=216
- // Direction/frame surfaces
- Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
+ // The rest is dynamic //size=216
+ // Direction/frame surfaces
+ Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
- byte frame_count = 0; // Count to switch frames
- byte dir = 0; // Direction of travel
- byte last_dir = 0; // Last direction of travel
- int x = 0; // Actual X coordinate
- int y = 0; // Actual Y coordinate
- int center = 0; // Center of object
- int last_x[2] = {}; // Last X coordinate on each page
- int last_y[2] = {}; // Last Y coordinate on each page
- byte used = 0; // 1=active, 0=not active
- byte next = 0; // Next frame to be shown
- byte speed_count = 0; // Count down to movement
- byte vunerable = 0; // Count down to vulnerability
- byte shot_cnt = 0; // Count down to another shot
- byte num_shots = 0; // # of shots currently on screen
- byte creator = 0; // Which actor # created this actor
- byte pause = 0; // Pause must be 0 to move
- byte actor_num = 0;
- byte move_count = 0;
- byte dead = 0;
- byte toggle = 0;
- byte center_x = 0;
- byte center_y = 0;
- byte show = 0; // Display or not (for blinking)
- byte temp1 = 0;
- byte temp2 = 0;
- byte counter = 0;
- byte move_counter = 0;
- byte edge_counter = 0;
- byte temp3 = 0;
- byte temp4 = 0;
- byte temp5 = 0;
- byte hit_thor = 0;
- int rand = 0;
- byte init_dir = 0;
- byte pass_value = 0;
- byte shot_actor = 0;
- byte magic_hit = 0;
- byte temp6 = 0;
- int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
- byte init_health = 0;
- byte talk_counter = 0;
- byte etype = 0;
- byte future2[25] = {};
+ byte frame_count = 0; // Count to switch frames
+ byte dir = 0; // Direction of travel
+ byte last_dir = 0; // Last direction of travel
+ int x = 0; // Actual X coordinate
+ int y = 0; // Actual Y coordinate
+ int center = 0; // Center of object
+ int last_x[2] = {}; // Last X coordinate on each page
+ int last_y[2] = {}; // Last Y coordinate on each page
+ byte used = 0; // 1=active, 0=not active
+ byte next = 0; // Next frame to be shown
+ byte speed_count = 0; // Count down to movement
+ byte vunerable = 0; // Count down to vulnerability
+ byte shot_cnt = 0; // Count down to another shot
+ byte num_shots = 0; // # of shots currently on screen
+ byte creator = 0; // Which actor # created this actor
+ byte pause = 0; // Pause must be 0 to move
+ byte actor_num = 0;
+ byte move_count = 0;
+ byte dead = 0;
+ byte toggle = 0;
+ byte center_x = 0;
+ byte center_y = 0;
+ byte show = 0; // Display or not (for blinking)
+ byte temp1 = 0;
+ byte temp2 = 0;
+ byte counter = 0;
+ byte move_counter = 0;
+ byte edge_counter = 0;
+ byte temp3 = 0;
+ byte temp4 = 0;
+ byte temp5 = 0;
+ byte hit_thor = 0;
+ int rand = 0;
+ byte init_dir = 0;
+ byte pass_value = 0;
+ byte shot_actor = 0;
+ byte magic_hit = 0;
+ byte temp6 = 0;
+ int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+ byte init_health = 0;
+ byte talk_counter = 0;
+ byte etype = 0;
+ byte future2[25] = {};
- void loadFixed(Common::SeekableReadStream *src);
- void loadFixed(const byte *src);
+ void loadFixed(Common::SeekableReadStream *src);
+ void loadFixed(const byte *src);
- /**
+ /**
* Copies the fixed portion and pics from a source actor.
*/
- void copyFixedAndPics(const ACTOR &src);
+ void copyFixedAndPics(const ACTOR &src);
ACTOR &operator=(const ACTOR &src);
- int getPos() const {
- return ((x + 7) / 16) + (((y + 8) / 16) * 20);
- }
+ int getPos() const {
+ return ((x + 7) / 16) + (((y + 8) / 16) * 20);
+ }
};
} // namespace Got
diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index cffc806084e..80486dfba12 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -26,7 +26,6 @@
#include "common/serializer.h"
#include "got/data/actor.h"
-
namespace Got {
struct HEADER {
@@ -42,7 +41,7 @@ struct HEADER {
//==========================================================================
// Defines
-#define MAX_ACTORS 35
+#define MAX_ACTORS 35
#define MAX_ENEMIES 16
#define STAMINA 20
@@ -50,16 +49,16 @@ struct HEADER {
#define _B 48
#define TMP_SIZE 5800
-#define GAME1 (_G(area)==1)
-#define GAME2 (_G(area)==2)
-#define GAME3 (_G(area)==3)
+#define GAME1 (_G(area) == 1)
+#define GAME2 (_G(area) == 2)
+#define GAME3 (_G(area) == 3)
-#define APPLE_MAGIC 1
-#define LIGHTNING_MAGIC 2
-#define BOOTS_MAGIC 4
-#define WIND_MAGIC 8
-#define SHIELD_MAGIC 16
-#define THUNDER_MAGIC 32
+#define APPLE_MAGIC 1
+#define LIGHTNING_MAGIC 2
+#define BOOTS_MAGIC 4
+#define WIND_MAGIC 8
+#define SHIELD_MAGIC 16
+#define THUNDER_MAGIC 32
#define BOSS_LEVEL1 59
#define BOSS_LEVEL2 60
diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
index 0b9f9fb4b3b..cd1d5d745da 100644
--- a/engines/got/data/high_scores.cpp
+++ b/engines/got/data/high_scores.cpp
@@ -19,89 +19,89 @@
*
*/
+#include "got/data/high_scores.h"
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
-#include "got/data/high_scores.h"
#include "got/got.h"
namespace Got {
static const char *DEFAULT_NAMES[HIGH_SCORES_PER_AREA] = {
"Ron Davis", "Gary Sirois", "Adam Pedersen", "Jason Blochowiak",
- "Roy Davis", "Wayne Timmerman", "Dan Linton"
-};
+ "Roy Davis", "Wayne Timmerman", "Dan Linton"};
void HighScore::sync(Common::Serializer &s) {
- s.syncAsUint16LE(_unused);
- s.syncAsUint32LE(_total);
- s.syncBytes((byte *)_name, 32);
+ s.syncAsUint16LE(_unused);
+ s.syncAsUint32LE(_total);
+ s.syncBytes((byte *)_name, 32);
}
void HighScores::sync(Common::Serializer &s) {
- for (int area = 0; area < 3; ++area)
- for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
- _scores[area][num].sync(s);
+ for (int area = 0; area < 3; ++area) {
+ for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+ _scores[area][num].sync(s);
+ }
}
void HighScores::load() {
- Common::File f;
- Common::InSaveFile *sf;
- Common::String scoresName = g_engine->getHighScoresSaveName();
+ Common::File f;
+ Common::String scoresName = g_engine->getHighScoresSaveName();
+ Common::InSaveFile *sf = g_system->getSavefileManager()->openForLoading(scoresName);
- if ((sf = g_system->getSavefileManager()->openForLoading(scoresName)) != nullptr) {
- // ScummVM high scores data present
- Common::Serializer s(sf, nullptr);
- sync(s);
- delete sf;
- } else if (f.open("config.got")) {
- // Otherwise fall back on original generated config.got
- f.seek(0x32);
- Common::Serializer s(&f, nullptr);
- sync(s);
- } else {
- // Generate new data
- for (int area = 0; area < 3; ++area)
+ if (sf != nullptr) {
+ // ScummVM high scores data present
+ Common::Serializer s(sf, nullptr);
+ sync(s);
+ delete sf;
+ } else if (f.open("config.got")) {
+ // Otherwise fall back on original generated config.got
+ f.seek(0x32);
+ Common::Serializer s(&f, nullptr);
+ sync(s);
+ } else {
+ // Generate new data
+ for (int area = 0; area < 3; ++area) {
for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
- _scores[area][num] = HighScore(DEFAULT_NAMES[num],
- 10000 - (num * 1000));
- }
+ _scores[area][num] = HighScore(DEFAULT_NAMES[num], 10000 - (num * 1000));
+ }
+ }
}
void HighScores::save() {
- Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(
- g_engine->getHighScoresSaveName());
- if (!sf)
- error("Error creating high scores save file");
+ Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(g_engine->getHighScoresSaveName());
+ if (!sf)
+ error("Error creating high scores save file");
- Common::Serializer s(nullptr, sf);
- sync(s);
- sf->finalize();
- delete sf;
+ Common::Serializer s(nullptr, sf);
+ sync(s);
+ sf->finalize();
+ delete sf;
}
void HighScores::add(int area, const Common::String &name, uint total) {
- // Find the index for the new score in the list
- int newIndex;
- for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
- total < _scores[area - 1][newIndex]._total; ++newIndex) {
- }
- if (newIndex == HIGH_SCORES_PER_AREA)
- // Lower than all current scores, so ignore it
- return;
+ // Find the index for the new score in the list
+ int newIndex;
+ for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
+ total < _scores[area - 1][newIndex]._total;
+ ++newIndex) {
+ }
+ if (newIndex == HIGH_SCORES_PER_AREA)
+ // Lower than all current scores, so ignore it
+ return;
- // Shift any lower scores to make space
- for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
- _scores[area - 1][i] = _scores[area - 1][i - 1];
+ // Shift any lower scores to make space
+ for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
+ _scores[area - 1][i] = _scores[area - 1][i - 1];
- // Insert in new score
- HighScore &hs = _scores[area - 1][newIndex];
- Common::fill(hs._name, hs._name + 32, 0);
- Common::strcpy_s(hs._name, name.c_str());
- hs._total = total;
+ // Insert in new score
+ HighScore &hs = _scores[area - 1][newIndex];
+ Common::fill(hs._name, hs._name + 32, 0);
+ Common::strcpy_s(hs._name, name.c_str());
+ hs._total = total;
- // Save the resulting table
- save();
+ // Save the resulting table
+ save();
}
} // namespace Got
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
index 16a40432720..30cf0c4ac16 100644
--- a/engines/got/data/high_scores.h
+++ b/engines/got/data/high_scores.h
@@ -29,27 +29,27 @@ namespace Got {
#define HIGH_SCORES_PER_AREA 7
struct HighScore {
- uint16 _unused = 0;
- uint32 _total = 0;
+ uint16 _unused = 0;
+ uint32 _total = 0;
char _name[32] = {};
HighScore() {}
HighScore(const char *name, uint32 total) : _total(total) {
Common::strcpy_s(_name, name);
}
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
};
struct HighScores {
private:
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
public:
- HighScore _scores[3][HIGH_SCORES_PER_AREA];
+ HighScore _scores[3][HIGH_SCORES_PER_AREA];
- void load();
- void save();
- void add(int area, const Common::String &name, uint total);
+ void load();
+ void save();
+ void add(int area, const Common::String &name, uint total);
};
} // namespace Got
diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index cc91dd8241b..239358f7871 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -27,43 +27,43 @@
namespace Got {
void LEVEL::sync(Common::Serializer &s) {
- for (int i = 0; i < 12; ++i)
- s.syncBytes(icon[i], 20);
+ for (int i = 0; i < 12; ++i)
+ s.syncBytes(icon[i], 20);
- s.syncAsByte(bg_color);
- s.syncAsByte(type);
+ s.syncAsByte(bg_color);
+ s.syncAsByte(type);
- s.syncBytes(actor_type, 16);
- s.syncBytes(actor_loc, 16);
- s.syncBytes(actor_value, 16);
- s.syncBytes(pal_colors, 3);
- s.syncBytes(actor_invis, 16);
- s.syncBytes(extra, 13);
- s.syncBytes(static_obj, 30);
+ s.syncBytes(actor_type, 16);
+ s.syncBytes(actor_loc, 16);
+ s.syncBytes(actor_value, 16);
+ s.syncBytes(pal_colors, 3);
+ s.syncBytes(actor_invis, 16);
+ s.syncBytes(extra, 13);
+ s.syncBytes(static_obj, 30);
- for (int i = 0; i < 30; ++i)
- s.syncAsSint16LE(static_x[i]);
- for (int i = 0; i < 30; ++i)
- s.syncAsSint16LE(static_y[i]);
+ for (int i = 0; i < 30; ++i)
+ s.syncAsSint16LE(static_x[i]);
+ for (int i = 0; i < 30; ++i)
+ s.syncAsSint16LE(static_y[i]);
- s.syncBytes(new_level, 10);
- s.syncBytes(new_level_loc, 10);
+ s.syncBytes(new_level, 10);
+ s.syncBytes(new_level_loc, 10);
- s.syncAsByte(area);
- s.syncBytes(actor_dir, 16);
- s.syncBytes(future, 3);
+ s.syncAsByte(area);
+ s.syncBytes(actor_dir, 16);
+ s.syncBytes(future, 3);
}
void LEVEL::load(int level) {
- Common::MemoryReadStream src(_G(sd_data)[level], 512);
- Common::Serializer s(&src, nullptr);
- sync(s);
+ Common::MemoryReadStream src(_G(sd_data)[level], 512);
+ Common::Serializer s(&src, nullptr);
+ sync(s);
}
void LEVEL::save(int level) {
- Common::MemoryWriteStream dest(_G(sd_data)[level], 512);
- Common::Serializer s(nullptr, &dest);
- sync(s);
+ Common::MemoryWriteStream dest(_G(sd_data)[level], 512);
+ Common::Serializer s(nullptr, &dest);
+ sync(s);
}
} // namespace Got
diff --git a/engines/got/data/level.h b/engines/got/data/level.h
index 76a5e255214..2308e3dd83d 100644
--- a/engines/got/data/level.h
+++ b/engines/got/data/level.h
@@ -28,38 +28,39 @@ namespace Got {
#define OBJECTS_COUNT 30
-struct LEVEL { // size=512
+struct LEVEL { // size=512
private:
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
+
public:
- byte icon[12][20] = {}; // 0 grid of icons
- byte bg_color = 0; // 240 background color
- byte type = 0; // 241 music
- byte actor_type[16] = {}; // 242 type of enemies (12 max)
- byte actor_loc[16] = {}; // 254 location of enemies
- byte actor_value[16] = {}; // pass value
- byte pal_colors[3] = {}; // change 251,253,254 to these three
- byte actor_invis[16] = {};
- byte extra[13] = {};
+ byte icon[12][20] = {}; // 0 grid of icons
+ byte bg_color = 0; // 240 background color
+ byte type = 0; // 241 music
+ byte actor_type[16] = {}; // 242 type of enemies (12 max)
+ byte actor_loc[16] = {}; // 254 location of enemies
+ byte actor_value[16] = {}; // pass value
+ byte pal_colors[3] = {}; // change 251,253,254 to these three
+ byte actor_invis[16] = {};
+ byte extra[13] = {};
- byte static_obj[OBJECTS_COUNT] = {}; // 302 static objects (treasure, keys,etc)
- int static_x[OBJECTS_COUNT] = {}; // 332 X coor of static objects
- int static_y[OBJECTS_COUNT] = {}; // 392 Y coor of static objects
- byte new_level[10] = {}; // 452 level jump for icon 200-204
- byte new_level_loc[10] = {}; // 462 grid location to jump in to
- byte area = 0; // 472 game area (1=forest,etc)
- byte actor_dir[16] = {}; // initial dir
- byte future[3] = {}; // 473
+ byte static_obj[OBJECTS_COUNT] = {}; // 302 static objects (treasure, keys,etc)
+ int static_x[OBJECTS_COUNT] = {}; // 332 X coor of static objects
+ int static_y[OBJECTS_COUNT] = {}; // 392 Y coor of static objects
+ byte new_level[10] = {}; // 452 level jump for icon 200-204
+ byte new_level_loc[10] = {}; // 462 grid location to jump in to
+ byte area = 0; // 472 game area (1=forest,etc)
+ byte actor_dir[16] = {}; // initial dir
+ byte future[3] = {}; // 473
- /**
+ /**
* Loads level data from the global sd_data for the given level
*/
- void load(int level);
+ void load(int level);
- /**
+ /**
* Saves the level data to the global sd_data
*/
- void save(int level);
+ void save(int level);
};
} // namespace Got
diff --git a/engines/got/data/sd_data.cpp b/engines/got/data/sd_data.cpp
index 664888b7f4c..f97c442bd1e 100644
--- a/engines/got/data/sd_data.cpp
+++ b/engines/got/data/sd_data.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/memstream.h"
#include "got/data/sd_data.h"
+#include "common/memstream.h"
#include "got/utils/file.h"
namespace Got {
@@ -28,27 +28,27 @@ namespace Got {
#define SD_DATA_SIZE 61440
SdData::SdData() {
- _data = new byte[SD_DATA_SIZE];
+ _data = new byte[SD_DATA_SIZE];
}
SdData::~SdData() {
- delete[] _data;
+ delete[] _data;
}
void SdData::load() {
- Common::String fname = Common::String::format("SDAT%d", _area);
- res_read(fname, _data);
+ Common::String fname = Common::String::format("SDAT%d", _area);
+ res_read(fname, _data);
}
void SdData::setArea(int area) {
- if (area != _area) {
- _area = area;
- load();
- }
+ if (area != _area) {
+ _area = area;
+ load();
+ }
}
void SdData::sync(Common::Serializer &s) {
- s.syncBytes(_data, SD_DATA_SIZE);
+ s.syncBytes(_data, SD_DATA_SIZE);
}
} // namespace Got
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
index 8dba23a8eac..1d8e2c72e1e 100644
--- a/engines/got/data/sd_data.h
+++ b/engines/got/data/sd_data.h
@@ -23,30 +23,29 @@
#define GOT_DATA_SD_DATA_H
#include "common/serializer.h"
-#include "got/data/level.h"
namespace Got {
class SdData {
private:
- byte *_data;
- int _area = 1;
+ byte *_data;
+ int _area = 1;
public:
- SdData();
- ~SdData();
- void load();
+ SdData();
+ ~SdData();
+ void load();
- bool getArea() const {
- return _area;
- }
- void setArea(int area);
+ bool getArea() const {
+ return _area;
+ }
+ void setArea(int area);
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
- byte *operator[](int level) const {
- return _data + level * 512;
- }
+ byte *operator[](int level) const {
+ return _data + level * 512;
+ }
};
} // namespace Got
diff --git a/engines/got/data/setup.cpp b/engines/got/data/setup.cpp
index a12978a31fd..4e37ab464aa 100644
--- a/engines/got/data/setup.cpp
+++ b/engines/got/data/setup.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/algorithm.h"
#include "got/data/setup.h"
+#include "common/algorithm.h"
namespace Got {
@@ -34,9 +34,10 @@ void SetupFlags::sync(Common::Serializer &s) {
int i;
if (s.isSaving()) {
- for (i = 0; i < 64; ++i)
+ for (i = 0; i < 64; ++i) {
if (_flags[i])
flags[i / 8] = flags[i / 8] | (1 << (i % 8));
+ }
s.syncBytes(flags, 8);
} else {
s.syncBytes(flags, 8);
@@ -46,22 +47,22 @@ void SetupFlags::sync(Common::Serializer &s) {
}
void SETUP::sync(Common::Serializer &s) {
- // Sync the flags bit-fields
+ // Sync the flags bit-fields
SetupFlags::sync(s);
- s.syncBytes(value, 16);
- s.syncAsByte(junk);
- s.syncAsByte(game);
- s.syncAsByte(area);
- s.syncAsByte(pc_sound);
- s.syncAsByte(dig_sound);
- s.syncAsByte(music);
- s.syncAsByte(speed);
- s.syncAsByte(scroll_flag);
- s.syncBytes(boss_dead, 3);
- s.syncAsByte(skill);
- s.syncAsByte(game_over);
- s.syncBytes(future, 19);
+ s.syncBytes(value, 16);
+ s.syncAsByte(junk);
+ s.syncAsByte(game);
+ s.syncAsByte(area);
+ s.syncAsByte(pc_sound);
+ s.syncAsByte(dig_sound);
+ s.syncAsByte(music);
+ s.syncAsByte(speed);
+ s.syncAsByte(scroll_flag);
+ s.syncBytes(boss_dead, 3);
+ s.syncAsByte(skill);
+ s.syncAsByte(game_over);
+ s.syncBytes(future, 19);
}
} // namespace Got
diff --git a/engines/got/data/setup.h b/engines/got/data/setup.h
index 2613ef6c775..90ad19b9728 100644
--- a/engines/got/data/setup.h
+++ b/engines/got/data/setup.h
@@ -99,21 +99,21 @@ struct SetupFlags {
};
struct SETUP : public SetupFlags {
- byte value[16] = {};
- byte junk = 0;
- byte game = 0;
- byte area = 0; //1,2,3
- byte pc_sound = 0; //1=enabled
- byte dig_sound = 0; //1 & !pc_sound = enabled
- byte music = 0; //1=enabled
- byte speed = 0; //1=slow mode (for slower 286's)
- byte scroll_flag = 0; //unused
- byte boss_dead[3] = {};
- byte skill = 0; //0=easy, 1=normal, 2=hard
- byte game_over = 0;
- byte future[19] = {}; //probably not needed
+ byte value[16] = {};
+ byte junk = 0;
+ byte game = 0;
+ byte area = 0; //1,2,3
+ byte pc_sound = 0; //1=enabled
+ byte dig_sound = 0; //1 & !pc_sound = enabled
+ byte music = 0; //1=enabled
+ byte speed = 0; //1=slow mode (for slower 286's)
+ byte scroll_flag = 0; //unused
+ byte boss_dead[3] = {};
+ byte skill = 0; //0=easy, 1=normal, 2=hard
+ byte game_over = 0;
+ byte future[19] = {}; //probably not needed
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
};
} // namespace Got
diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
index 7f55b472a59..1294743fe08 100644
--- a/engines/got/data/thor_info.cpp
+++ b/engines/got/data/thor_info.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/algorithm.h"
#include "got/data/thor_info.h"
+#include "common/algorithm.h"
#include "got/game/back.h"
namespace Got {
@@ -53,39 +53,39 @@ void THOR_INFO::clear() {
}
void THOR_INFO::sync(Common::Serializer &s) {
- uint32 ptr = 0;
+ uint32 ptr = 0;
- s.syncAsByte(magic);
- s.syncAsByte(keys);
- s.syncAsSint16LE(jewels);
- s.syncAsByte(last_area);
- s.syncAsByte(last_screen);
- s.syncAsByte(last_icon);
- s.syncAsByte(last_dir);
- s.syncAsSint16LE(inventory);
- s.syncAsByte(item);
- s.syncAsByte(last_health);
- s.syncAsByte(last_magic);
- s.syncAsSint16LE(last_jewels);
- s.syncAsByte(last_keys);
- s.syncAsByte(last_item);
- s.syncAsSint16LE(last_inventory);
- s.syncAsByte(level);
- s.syncAsUint32LE(score);
- s.syncAsUint32LE(last_score);
+ s.syncAsByte(magic);
+ s.syncAsByte(keys);
+ s.syncAsSint16LE(jewels);
+ s.syncAsByte(last_area);
+ s.syncAsByte(last_screen);
+ s.syncAsByte(last_icon);
+ s.syncAsByte(last_dir);
+ s.syncAsSint16LE(inventory);
+ s.syncAsByte(item);
+ s.syncAsByte(last_health);
+ s.syncAsByte(last_magic);
+ s.syncAsSint16LE(last_jewels);
+ s.syncAsByte(last_keys);
+ s.syncAsByte(last_item);
+ s.syncAsSint16LE(last_inventory);
+ s.syncAsByte(level);
+ s.syncAsUint32LE(score);
+ s.syncAsUint32LE(last_score);
- s.syncAsByte(object);
- s.syncAsUint16LE(ptr);
- s.syncAsByte(last_object);
- s.syncAsUint16LE(ptr);
+ s.syncAsByte(object);
+ s.syncAsUint16LE(ptr);
+ s.syncAsByte(last_object);
+ s.syncAsUint16LE(ptr);
- s.syncAsByte(armor);
- s.syncBytes(future, 65);
+ s.syncAsByte(armor);
+ s.syncBytes(future, 65);
- if (s.isLoading()) {
- object_name = (object == 0) ? nullptr : OBJECT_NAMES[object - 1];
- last_object_name = (last_object == 0) ? nullptr : OBJECT_NAMES[last_object - 1];
- }
+ if (s.isLoading()) {
+ object_name = (object == 0) ? nullptr : OBJECT_NAMES[object - 1];
+ last_object_name = (last_object == 0) ? nullptr : OBJECT_NAMES[last_object - 1];
+ }
}
} // namespace Got
diff --git a/engines/got/data/thor_info.h b/engines/got/data/thor_info.h
index 99d9a38bdc6..f0bb6d64996 100644
--- a/engines/got/data/thor_info.h
+++ b/engines/got/data/thor_info.h
@@ -27,33 +27,33 @@
namespace Got {
struct THOR_INFO {
- byte magic = 0;
- byte keys = 0;
- int jewels = 0;
- byte last_area = 0;
- byte last_screen = 0;
- byte last_icon = 0;
- byte last_dir = 0;
- int inventory = 0;
- byte item = 0; //currently selected item
- byte last_health = 0;
- byte last_magic = 0;
- int last_jewels = 0;
- byte last_keys = 0;
- byte last_item = 0;
- int last_inventory = 0;
- byte level = 0; //current level (1,2,3)
- long score = 0;
- long last_score = 0;
- byte object = 0;
- const char *object_name = nullptr;
- byte last_object = 0;
- const char *last_object_name = nullptr;
- byte armor = 0;
- byte future[65] = {};
+ byte magic = 0;
+ byte keys = 0;
+ int jewels = 0;
+ byte last_area = 0;
+ byte last_screen = 0;
+ byte last_icon = 0;
+ byte last_dir = 0;
+ int inventory = 0;
+ byte item = 0; //currently selected item
+ byte last_health = 0;
+ byte last_magic = 0;
+ int last_jewels = 0;
+ byte last_keys = 0;
+ byte last_item = 0;
+ int last_inventory = 0;
+ byte level = 0; //current level (1,2,3)
+ long score = 0;
+ long last_score = 0;
+ byte object = 0;
+ const char *object_name = nullptr;
+ byte last_object = 0;
+ const char *last_object_name = nullptr;
+ byte armor = 0;
+ byte future[65] = {};
void clear();
- void sync(Common::Serializer &s);
+ void sync(Common::Serializer &s);
};
} // namespace Got
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index 38e74ad0879..a86b57e01ea 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -29,7 +29,6 @@ namespace Got {
extern const char *OBJECT_NAMES[];
extern const char *ITEM_NAMES[];
-
/**
* Shows a new level
* In the original this did some initial actors setup and rendering.
diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
index 32736307ee5..4a491815343 100644
--- a/engines/got/game/status.cpp
+++ b/engines/got/game/status.cpp
@@ -26,42 +26,42 @@
namespace Got {
void add_jewels(int num) {
- _G(thor_info).jewels = CLIP(_G(thor_info).jewels + num, 0, 999);
+ _G(thor_info).jewels = CLIP(_G(thor_info).jewels + num, 0, 999);
}
void add_score(int num) {
- _G(thor_info).score = CLIP(_G(thor_info).score + num, 0l, 999999l);
+ _G(thor_info).score = CLIP(_G(thor_info).score + num, 0l, 999999l);
}
void add_magic(int num) {
- _G(thor_info).magic = CLIP(_G(thor_info).magic + num, 0, 150);
+ _G(thor_info).magic = CLIP(_G(thor_info).magic + num, 0, 150);
}
void add_health(int num) {
- _G(thor)->health = CLIP(_G(thor)->health + num, 0, 150);
+ _G(thor)->health = CLIP(_G(thor)->health + num, 0, 150);
- if (_G(thor)->health < 1)
- g_events->send(GameMessage("THOR_DIES"));
+ if (_G(thor)->health < 1)
+ g_events->send(GameMessage("THOR_DIES"));
}
void add_keys(int num) {
- _G(thor_info).keys = CLIP(_G(thor_info).keys + num, 0, 99);
+ _G(thor_info).keys = CLIP(_G(thor_info).keys + num, 0, 99);
}
void fill_health() {
- add_health(150);
+ add_health(150);
}
void fill_magic() {
- add_magic(150);
+ add_magic(150);
}
void fill_score(int num, const char *endMessage) {
- GameMessage msg("FILL_SCORE");
- if (endMessage)
- msg._stringValue = endMessage;
- msg._value = num;
- g_events->send("GameStatus", msg);
+ GameMessage msg("FILL_SCORE");
+ if (endMessage)
+ msg._stringValue = endMessage;
+ msg._value = num;
+ g_events->send("GameStatus", msg);
}
} // namespace Got
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
index 299295eb774..58b1df4de09 100644
--- a/engines/got/game/status.h
+++ b/engines/got/game/status.h
@@ -22,8 +22,6 @@
#ifndef GOT_GAME_STATUS_H
#define GOT_GAME_STATUS_H
-#include "got/data/defines.h"
-
namespace Got {
extern void add_jewels(int num);
Commit: 4c8b879fc6ea000949e9dd50b17c6262ff841c8a
https://github.com/scummvm/scummvm/commit/4c8b879fc6ea000949e9dd50b17c6262ff841c8a
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:16-08:00
Commit Message:
GOT: modify access to global arrays in gfx, code alignment
Changed paths:
engines/got/game/move.cpp
engines/got/gfx/font.cpp
engines/got/gfx/font.h
engines/got/gfx/gfx_chunks.cpp
engines/got/gfx/gfx_chunks.h
engines/got/gfx/gfx_pics.cpp
engines/got/gfx/gfx_pics.h
engines/got/gfx/gfx_surface.cpp
engines/got/gfx/gfx_surface.h
engines/got/gfx/image.cpp
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index ebade012132..060ac8e58a7 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -291,7 +291,7 @@ int actor_shoots(ACTOR *actr, int dir) {
int icn = 140;
- if (_G(shot[actr->shot_type - 1]).flying == 1)
+ if (_G(shot[actr->shot_type - 1]).flying)
icn = 80;
switch (dir) {
diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
index fb90a4df1fa..fd9452da263 100644
--- a/engines/got/gfx/font.cpp
+++ b/engines/got/gfx/font.cpp
@@ -19,54 +19,52 @@
*
*/
-#include "common/file.h"
#include "got/gfx/font.h"
+#include "common/file.h"
#include "got/gfx/gfx_pics.h"
namespace Got {
namespace Gfx {
-const byte DIALOG_COLOR[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
+const byte DIALOG_COLOR[] = {14, 54, 120, 138, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
void Font::load() {
- Common::File f;
- if (!f.open("TEXT"))
- error("Could not open font");
+ Common::File f;
+ if (!f.open("TEXT"))
+ error("Could not open font");
- _font.resize(f.size() / 72 + 32);
+ _font.resize(f.size() / 72 + 32);
- for (uint i = 32; i < _font.size(); ++i) {
- byte buff[8 * 9];
- f.read(buff, 8 * 9);
+ for (uint i = 32; i < _font.size(); ++i) {
+ byte buff[8 * 9];
+ f.read(buff, 8 * 9);
- _font[i].create(8, 9);
- convertPaneDataToSurface(buff, _font[i]);
- }
+ _font[i].create(8, 9);
+ convertPaneDataToSurface(buff, _font[i]);
+ }
}
-void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
- const Common::String &text, int color) {
- char ch;
- const char *string = text.c_str();
- Common::Point pt = pos;
+void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos, const Common::String &text, int color) {
+ const char *string = text.c_str();
+ Common::Point pt = pos;
- while (*string) {
- ch = *string++;
- if (ch == '~' && Common::isXDigit(*string)) {
- ch = *string++;
- if (Common::isDigit(ch)) {
- ch -= 48;
- } else {
- ch = toupper(ch) - 55;
- }
- color = DIALOG_COLOR[(byte)ch];
- continue;
- }
- if (ch > 31 && ch < 127)
- drawChar(src, ch, pt.x, pt.y, color);
+ while (*string) {
+ char ch = *string++;
+ if (ch == '~' && Common::isXDigit(*string)) {
+ ch = *string++;
+ if (Common::isDigit(ch)) {
+ ch -= 48;
+ } else {
+ ch = toupper(ch) - 55;
+ }
+ color = DIALOG_COLOR[(byte)ch];
+ continue;
+ }
+ if (ch > 31 && ch < 127)
+ drawChar(src, ch, pt.x, pt.y, color);
- pt.x += 8;
- }
+ pt.x += 8;
+ }
}
void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
@@ -79,16 +77,16 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
void Font::rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
const Graphics::ManagedSurface &glyph = _font[chr];
- for (int yp = 0; yp < glyph.h; ++yp) {
- int startY = y + yp;
- const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
- byte *destP = (byte *)dst->getBasePtr(x, startY);
+ for (int yp = 0; yp < glyph.h; ++yp) {
+ int startY = y + yp;
+ const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
+ byte *destP = (byte *)dst->getBasePtr(x, startY);
- for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
- if (*srcP)
- *destP = color;
- }
- }
+ for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
+ if (*srcP)
+ *destP = color;
+ }
+ }
}
} // namespace Gfx
diff --git a/engines/got/gfx/font.h b/engines/got/gfx/font.h
index 744d446ce05..3c04be60053 100644
--- a/engines/got/gfx/font.h
+++ b/engines/got/gfx/font.h
@@ -33,28 +33,28 @@ extern const byte DIALOG_COLOR[];
class Font : public Graphics::Font {
private:
- Common::Array<Graphics::ManagedSurface> _font;
+ Common::Array<Graphics::ManagedSurface> _font;
public:
- void load();
-
- int getFontHeight() const override {
- return 9;
- }
- int getMaxCharWidth() const override {
- return 8;
- }
- int getCharWidth(uint32 chr) const override {
- return 8;
- }
- void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
- void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
- Graphics::Font::drawChar(dst, chr, x, y, color);
- }
+ void load();
+
+ int getFontHeight() const override {
+ return 9;
+ }
+ int getMaxCharWidth() const override {
+ return 8;
+ }
+ int getCharWidth(uint32 chr) const override {
+ return 8;
+ }
+ void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+ void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
+ Graphics::Font::drawChar(dst, chr, x, y, color);
+ }
void rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const;
- void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
- const Common::String &text, int color);
+ void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
+ const Common::String &text, int color);
};
} // namespace Gfx
diff --git a/engines/got/gfx/gfx_chunks.cpp b/engines/got/gfx/gfx_chunks.cpp
index cab437a727f..11e2d96eede 100644
--- a/engines/got/gfx/gfx_chunks.cpp
+++ b/engines/got/gfx/gfx_chunks.cpp
@@ -19,69 +19,66 @@
*
*/
-#include "common/file.h"
#include "got/gfx/gfx_chunks.h"
+#include "common/file.h"
#include "got/utils/compression.h"
namespace Got {
namespace Gfx {
void GraphicChunk::load(Common::SeekableReadStream *src, const byte *data) {
- _compressMode = src->readUint16LE();
- _offset = src->readUint32LE();
- _uncompressedSize = src->readUint16LE();
- _compressedSize = src->readUint16LE();
- _width = src->readUint16LE();
- _height = src->readUint16LE();
-
- _data = data + _offset;
+ _compressMode = src->readUint16LE();
+ _offset = src->readUint32LE();
+ _uncompressedSize = src->readUint16LE();
+ _compressedSize = src->readUint16LE();
+ _width = src->readUint16LE();
+ _height = src->readUint16LE();
+
+ _data = data + _offset;
}
void GraphicChunk::enable() {
- // Data already uncompressed, nothing further needed
- if (_compressMode == UNCOMPRESSED)
- return;
+ // Data already uncompressed, nothing further needed
+ if (_compressMode == UNCOMPRESSED)
+ return;
- _decompressedData.resize(_uncompressedSize);
+ _decompressedData.resize(_uncompressedSize);
- switch (_compressMode) {
- case LZSS:
- lzss_decompress(_data, &_decompressedData[0], _uncompressedSize);
- break;
+ switch (_compressMode) {
+ case LZSS:
+ lzss_decompress(_data, &_decompressedData[0], _uncompressedSize);
+ break;
- case RLE:
- rle_decompress(_data, &_decompressedData[0], _uncompressedSize);
- break;
+ case RLE:
+ rle_decompress(_data, &_decompressedData[0], _uncompressedSize);
+ break;
- default:
- error("Unknown compression type %d", _compressMode);
- break;
- }
+ default:
+ error("Unknown compression type %d", _compressMode);
+ }
- // Mark the entry as uncompressed, and point to the data
- _compressMode = UNCOMPRESSED;
- _data = &_decompressedData[0];
+ // Mark the entry as uncompressed, and point to the data
+ _compressMode = UNCOMPRESSED;
+ _data = &_decompressedData[0];
}
GraphicChunk::operator const Graphics::ManagedSurface() const {
- Graphics::ManagedSurface s;
- s.w = s.pitch = _width;
- s.h = _height;
- s.format = Graphics::PixelFormat::createFormatCLUT8();
- s.setPixels(const_cast<byte *>(_data));
+ Graphics::ManagedSurface s;
+ s.w = s.pitch = _width;
+ s.h = _height;
+ s.format = Graphics::PixelFormat::createFormatCLUT8();
+ s.setPixels(const_cast<byte *>(_data));
- return s;
+ return s;
}
GraphicChunk::operator const Gfx::Palette63() const {
- return Gfx::Palette63(_data);
+ return Gfx::Palette63(_data);
}
-
-
void GfxChunks::load() {
- // Get stream to access images
- Common::SeekableReadStream *f = getStream();
+ // Get stream to access images
+ Common::SeekableReadStream *f = getStream();
#if 0
Common::DumpFile df;
@@ -92,58 +89,57 @@ void GfxChunks::load() {
df.close();
#endif
- // Keep a copy in memory for decoding images as needed
- _data = new byte[f->size()];
- f->read(_data, f->size());
+ // Keep a copy in memory for decoding images as needed
+ _data = new byte[f->size()];
+ f->read(_data, f->size());
- // Set the number of images
- f->seek(0);
- _chunks.resize(f->readUint16LE());
+ // Set the number of images
+ f->seek(0);
+ _chunks.resize(f->readUint16LE());
- // Iterate through loading the image metrics
- for (uint i = 0; i < _chunks.size(); ++i)
- _chunks[i].load(f, _data);
+ // Iterate through loading the image metrics
+ for (uint i = 0; i < _chunks.size(); ++i)
+ _chunks[i].load(f, _data);
- // Close the file
- delete f;
+ // Close the file
+ delete f;
- // Decompress two ranges of chunks by default
- for (uint i = 0; i < 34; ++i)
- _chunks[i].enable();
+ // Decompress two ranges of chunks by default
+ for (uint i = 0; i < 34; ++i)
+ _chunks[i].enable();
}
GraphicChunk &GfxChunks::operator[](uint idx) {
- GraphicChunk &chunk = _chunks[idx];
- chunk.enable();
+ GraphicChunk &chunk = _chunks[idx];
+ chunk.enable();
- return chunk;
+ return chunk;
}
Common::SeekableReadStream *GfxChunks::getStream() const {
- // Check for stand-alone graphics file
- Common::File *f = new Common::File;
- if (f->open("got.gfx"))
- return f;
- delete f;
-
- // Check for got.exe executable
- Common::File fExe;
- if (!fExe.open("got.exe"))
- error("Could not locate got graphics");
-
- if (fExe.readUint16BE() != MKTAG16('M', 'Z'))
- error("Invalid exe header");
-
- int lastPageSize = fExe.readUint16LE();
- int totalPages = fExe.readUint16LE();
- int offset = lastPageSize ? ((totalPages - 1) << 9) + lastPageSize :
- totalPages << 9;
-
- fExe.seek(offset);
- if (fExe.readUint16BE() != MKTAG16(0xe2, 0x4a))
- error("Invalid embedded graphics signature");
-
- return fExe.readStream(fExe.size() - fExe.pos());
+ // Check for stand-alone graphics file
+ Common::File *f = new Common::File;
+ if (f->open("got.gfx"))
+ return f;
+ delete f;
+
+ // Check for got.exe executable
+ Common::File fExe;
+ if (!fExe.open("got.exe"))
+ error("Could not locate got graphics");
+
+ if (fExe.readUint16BE() != MKTAG16('M', 'Z'))
+ error("Invalid exe header");
+
+ int lastPageSize = fExe.readUint16LE();
+ int totalPages = fExe.readUint16LE();
+ int offset = lastPageSize ? ((totalPages - 1) << 9) + lastPageSize : totalPages << 9;
+
+ fExe.seek(offset);
+ if (fExe.readUint16BE() != MKTAG16(0xe2, 0x4a))
+ error("Invalid embedded graphics signature");
+
+ return fExe.readStream(fExe.size() - fExe.pos());
}
} // namespace Gfx
diff --git a/engines/got/gfx/gfx_chunks.h b/engines/got/gfx/gfx_chunks.h
index 905391e406b..8c043447408 100644
--- a/engines/got/gfx/gfx_chunks.h
+++ b/engines/got/gfx/gfx_chunks.h
@@ -23,49 +23,51 @@
#define GOT_GFX_GFX_CHUNKS_H
#include "common/stream.h"
-#include "graphics/managed_surface.h"
#include "got/gfx/palette.h"
+#include "graphics/managed_surface.h"
namespace Got {
namespace Gfx {
class GfxChunks;
-enum CompressMode { UNCOMPRESSED = 0, LZSS = 1, RLE = 2 };
+enum CompressMode { UNCOMPRESSED = 0,
+ LZSS = 1,
+ RLE = 2 };
-struct GraphicChunk {
+struct GraphicChunk {
private:
- Common::Array<byte> _decompressedData;
+ Common::Array<byte> _decompressedData;
public:
- int _compressMode = UNCOMPRESSED;
- uint32 _offset = 0;
- uint16 _uncompressedSize = 0;
- uint16 _compressedSize = 0;
- uint16 _width = 0;
- uint16 _height = 0;
+ int _compressMode = UNCOMPRESSED;
+ uint32 _offset = 0;
+ uint16 _uncompressedSize = 0;
+ uint16 _compressedSize = 0;
+ uint16 _width = 0;
+ uint16 _height = 0;
- const byte *_data = nullptr;
+ const byte *_data = nullptr;
- /**
+ /**
* Load the overall info for a chunk
*/
- void load(Common::SeekableReadStream *src, const byte *data);
+ void load(Common::SeekableReadStream *src, const byte *data);
- /**
+ /**
* Handles any decompression necessary for the entry
*/
- void enable();
+ void enable();
- /**
+ /**
* Provides a managed surface wrapper for raw data
*/
- operator const Graphics::ManagedSurface() const;
+ operator const Graphics::ManagedSurface() const;
- /**
+ /**
* Provides a data pointer, used for getting palette chunks
*/
- operator const Gfx::Palette63() const;
+ operator const Gfx::Palette63() const;
};
/**
@@ -77,28 +79,28 @@ public:
*/
class GfxChunks {
private:
- Common::Array<GraphicChunk> _chunks;
- byte *_data = nullptr;
+ Common::Array<GraphicChunk> _chunks;
+ byte *_data = nullptr;
- /**
+ /**
* Opens the graphics for access
*/
- Common::SeekableReadStream *getStream() const;
+ Common::SeekableReadStream *getStream() const;
public:
- ~GfxChunks() {
- delete[] _data;
- }
+ ~GfxChunks() {
+ delete[] _data;
+ }
- /**
+ /**
* Loads the graphic data
*/
- void load();
+ void load();
- /**
+ /**
* Access a chunk
*/
- GraphicChunk &operator[](uint idx);
+ GraphicChunk &operator[](uint idx);
};
} // namespace Gfx
diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index 3bb9908a149..da478e7b6ee 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -19,73 +19,72 @@
*
*/
-#include "common/textconsole.h"
-#include "common/file.h"
#include "got/gfx/gfx_pics.h"
+#include "common/file.h"
+#include "common/textconsole.h"
#include "got/utils/file.h"
namespace Got {
namespace Gfx {
void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
- surf.setTransparentColor(0);
-
- // It's split into 4 panes per 4 pixels, so we need
- // to juggle the pixels into their correct order
- for (int plane = 0; plane < 4; ++plane) {
- for (int y = 0; y < surf.h; ++y) {
- byte *dest = (byte *)surf.getBasePtr(plane, y);
-
- for (int x = 0; x < (surf.w / 4); ++x, dest += 4, ++src) {
- // For some reason, both '0' and '15' are both hard-coded
- // as transparent colors in the graphics drawing. Simplify
- // this for ScummVM by changing all 15's to 0
- *dest = (*src == 15) ? 0 : *src;
- }
- }
- }
+ surf.setTransparentColor(0);
+
+ // It's split into 4 panes per 4 pixels, so we need
+ // to juggle the pixels into their correct order
+ for (int plane = 0; plane < 4; ++plane) {
+ for (int y = 0; y < surf.h; ++y) {
+ byte *dest = (byte *)surf.getBasePtr(plane, y);
+
+ for (int x = 0; x < (surf.w / 4); ++x, dest += 4, ++src) {
+ // For some reason, both '0' and '15' are both hard-coded
+ // as transparent colors in the graphics drawing. Simplify
+ // this for ScummVM by changing all 15's to 0
+ *dest = (*src == 15) ? 0 : *src;
+ }
+ }
+ }
}
-
void GfxPics::clear() {
delete[] _array;
_array = nullptr;
}
void GfxPics::resize(uint newSize) {
- assert(!_array); // Don't support multiple resizes
+ assert(!_array); // Don't support multiple resizes
_array = new Graphics::ManagedSurface[newSize];
_size = newSize;
}
void GfxPics::load(const Common::String &name, int blockSize) {
- File f(name);
+ File f(name);
- // Set up array of images
- clear();
- if (blockSize == -1) {
- // Only a single image
- resize(1);
- blockSize = f.size();
- } else {
- resize(f.size() / blockSize);
- }
+ // Set up array of images
+ clear();
+ if (blockSize == -1) {
+ // Only a single image
+ resize(1);
+ blockSize = f.size();
+ } else {
+ resize(f.size() / blockSize);
+ }
- byte *buff = new byte[blockSize];
+ byte *buff = new byte[blockSize];
- for (uint idx = 0; idx < size(); ++idx) {
- int w = f.readUint16LE() * 4;
- int h = f.readUint16LE();
- f.skip(2); // Unused transparent color. It's always 15
- f.read(buff, blockSize - 6);
+ for (uint idx = 0; idx < size(); ++idx) {
+ int w = f.readUint16LE() * 4;
+ int h = f.readUint16LE();
+ f.skip(2); // Unused transparent color. It's always 15
+ f.read(buff, blockSize - 6);
- Graphics::ManagedSurface &s = (*this)[idx];
- s.create(w, h);
+ Graphics::ManagedSurface &s = (*this)[idx];
+ s.create(w, h);
- convertPaneDataToSurface(buff, s);
- }
+ convertPaneDataToSurface(buff, s);
+ }
- delete[] buff;
+ delete[] buff;
}
GfxPics &GfxPics::operator=(const GfxPics &src) {
@@ -98,17 +97,16 @@ GfxPics &GfxPics::operator=(const GfxPics &src) {
return *this;
}
-
void BgPics::setArea(int area) {
- if (area != _area) {
- _area = area;
- load();
- }
+ if (area != _area) {
+ _area = area;
+ load();
+ }
}
void BgPics::load() {
- Common::String fname = Common::String::format("BPICS%d", _area);
- GfxPics::load(fname, 262);
+ Common::String fname = Common::String::format("BPICS%d", _area);
+ GfxPics::load(fname, 262);
}
} // namespace Gfx
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index c1b73b9eabe..1057fff00f4 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -37,22 +37,20 @@ namespace Gfx {
*/
extern void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf);
-
class GfxPics {
private:
Graphics::ManagedSurface *_array = nullptr;
size_t _size = 0;
protected:
-
public:
~GfxPics() {
clear();
- }
+ }
void clear();
void resize(uint newSize);
- void load(const Common::String &name, int blockSize);
+ void load(const Common::String &name, int blockSize);
Graphics::ManagedSurface &operator[](uint idx) {
return _array[idx];
@@ -66,34 +64,33 @@ public:
class BgPics : public GfxPics {
private:
- int _area = 1;
+ int _area = 1;
public:
- void load();
+ void load();
- bool getArea() const {
- return _area;
- }
- void setArea(int area);
+ bool getArea() const {
+ return _area;
+ }
+ void setArea(int area);
};
class Pics : public GfxPics {
private:
- Common::String _resName;
- int _blockSize = -1;
+ Common::String _resName;
+ int _blockSize = -1;
public:
- Pics(const Common::String &resName, int blockSize = -1,
- bool immediateLoad = true) :
- _resName(resName), _blockSize(blockSize) {
- if (immediateLoad)
- load();
- }
- Pics() {}
-
- void load() {
- GfxPics::load(_resName, _blockSize);
- }
+ Pics(const Common::String &resName, int blockSize = -1,
+ bool immediateLoad = true) : _resName(resName), _blockSize(blockSize) {
+ if (immediateLoad)
+ load();
+ }
+ Pics() {}
+
+ void load() {
+ GfxPics::load(_resName, _blockSize);
+ }
};
} // namespace Gfx
diff --git a/engines/got/gfx/gfx_surface.cpp b/engines/got/gfx/gfx_surface.cpp
index bc2924aabf8..b12f15492c3 100644
--- a/engines/got/gfx/gfx_surface.cpp
+++ b/engines/got/gfx/gfx_surface.cpp
@@ -26,12 +26,12 @@ namespace Got {
namespace Gfx {
void GfxSurface::print(const Common::Point &pos,
- const Common::String &text, int color) {
- _G(font).drawString(this, pos, text, color);
+ const Common::String &text, int color) {
+ _G(font).drawString(this, pos, text, color);
}
void GfxSurface::printChar(uint32 chr, int x, int y, uint32 color) {
- _G(font).drawChar(this, chr, x, y, color);
+ _G(font).drawChar(this, chr, x, y, color);
}
void GfxSurface::rawPrintChar(uint32 chr, int x, int y, uint32 color) {
diff --git a/engines/got/gfx/gfx_surface.h b/engines/got/gfx/gfx_surface.h
index ee40855082c..7997cf14411 100644
--- a/engines/got/gfx/gfx_surface.h
+++ b/engines/got/gfx/gfx_surface.h
@@ -29,17 +29,16 @@ namespace Gfx {
class GfxSurface : public Graphics::ManagedSurface {
public:
- GfxSurface() : Graphics::ManagedSurface() {
- }
- GfxSurface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) :
- Graphics::ManagedSurface(surf, bounds) {
- }
+ GfxSurface() : Graphics::ManagedSurface() {
+ }
+ GfxSurface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) : Graphics::ManagedSurface(surf, bounds) {
+ }
- /**
+ /**
* Write some text to the surface
*/
- void print(const Common::Point &pos, const Common::String &text, int color);
- void printChar(uint32 chr, int x, int y, uint32 color);
+ void print(const Common::Point &pos, const Common::String &text, int color);
+ void printChar(uint32 chr, int x, int y, uint32 color);
void rawPrintChar(uint32 chr, int x, int y, uint32 color);
};
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 672d23dca56..36ab9322b6f 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -19,260 +19,259 @@
*
*/
-#include "common/memstream.h"
#include "got/gfx/image.h"
+#include "common/memstream.h"
#include "got/events.h"
-#include "got/utils/file.h"
#include "got/got.h"
+#include "got/utils/file.h"
#include "got/vars.h"
namespace Got {
static void createSurface(Graphics::ManagedSurface &s, const byte *src) {
- s.create(16, 16);
+ s.create(16, 16);
- // Both 0 and 15 are transparent colors, so as we load the
- // surface, standard on a single color
- byte *dest = (byte *)s.getPixels();
- for (int i = 0; i < 16 * 16; ++i, ++src, ++dest)
- *dest = (*src == 15) ? 0 : *src;
+ // Both 0 and 15 are transparent colors, so as we load the
+ // surface, standard on a single color
+ byte *dest = (byte *)s.getPixels();
+ for (int i = 0; i < 16 * 16; ++i, ++src, ++dest)
+ *dest = (*src == 15) ? 0 : *src;
- s.setTransparentColor(0);
+ s.setTransparentColor(0);
}
void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
- actr->next = 0; // Next frame to be shown
- actr->frame_count = actr->frame_speed;
- actr->dir = dir; // Direction of travel
- actr->last_dir = dir; // Last direction of travel
- if (actr->directions == 1) actr->dir = 0;
- if (actr->directions == 2) actr->dir &= 1;
- if (actr->directions == 4 && actr->frames == 1) {
- actr->dir = 0;
- actr->next = dir;
- }
-
- actr->x = x; // Actual X coor
- actr->y = y; // Actual Y coor
- actr->width = 16; // Actual X coor
- actr->height = 16; // Actual Y coor
- actr->center = 0; // Center of object
- actr->last_x[0] = x; // Last X coor on each page
- actr->last_x[1] = x;
- actr->last_y[0] = y; // Last Y coor on each page
- actr->last_y[1] = y;
- actr->used = 1; // 1=active, 0=not active
- actr->speed_count = 8; // Count down to movement
- actr->vunerable = STAMINA; // Count down to vunerability
- actr->shot_cnt = 20; // Count down to another shot
- actr->num_shots = 0; // # of shots currently on screen
- actr->creator = 0; // which actor # created this actor
- actr->pause = 0; // Pause must be 0 to move
- actr->show = 0;
- actr->actor_num = num;
- actr->counter = 0;
- actr->move_counter = 0;
- actr->edge_counter = 20;
- actr->hit_thor = 0;
- actr->rand = g_engine->getRandomNumber(99);
- actr->temp1 = 0;
- actr->init_health = actr->health;
+ actr->next = 0; // Next frame to be shown
+ actr->frame_count = actr->frame_speed;
+ actr->dir = dir; // Direction of travel
+ actr->last_dir = dir; // Last direction of travel
+ if (actr->directions == 1)
+ actr->dir = 0;
+ if (actr->directions == 2)
+ actr->dir &= 1;
+ if (actr->directions == 4 && actr->frames == 1) {
+ actr->dir = 0;
+ actr->next = dir;
+ }
+
+ actr->x = x; // Actual X coor
+ actr->y = y; // Actual Y coor
+ actr->width = 16; // Actual X coor
+ actr->height = 16; // Actual Y coor
+ actr->center = 0; // Center of object
+ actr->last_x[0] = x; // Last X coor on each page
+ actr->last_x[1] = x;
+ actr->last_y[0] = y; // Last Y coor on each page
+ actr->last_y[1] = y;
+ actr->used = 1; // 1=active, 0=not active
+ actr->speed_count = 8; // Count down to movement
+ actr->vunerable = STAMINA; // Count down to vulnerability
+ actr->shot_cnt = 20; // Count down to another shot
+ actr->num_shots = 0; // # of shots currently on screen
+ actr->creator = 0; // which actor # created this actor
+ actr->pause = 0; // Pause must be 0 to move
+ actr->show = 0;
+ actr->actor_num = num;
+ actr->counter = 0;
+ actr->move_counter = 0;
+ actr->edge_counter = 20;
+ actr->hit_thor = 0;
+ actr->rand = g_engine->getRandomNumber(99);
+ actr->temp1 = 0;
+ actr->init_health = actr->health;
}
void make_actor_surface(ACTOR *actr) {
- int d, f;
-
- assert(actr->directions <= 4 && actr->frames <= 4);
- for (d = 0; d < actr->directions; d++) {
- for (f = 0; f < actr->frames; f++) {
- Graphics::ManagedSurface &s = actr->pic[d][f];
- const byte *src = &_G(tmp_buff)[256 * ((d * 4) + f)];
- createSurface(s, src);
- }
- }
+ assert(actr->directions <= 4 && actr->frames <= 4);
+ for (int d = 0; d < actr->directions; d++) {
+ for (int f = 0; f < actr->frames; f++) {
+ Graphics::ManagedSurface &s = actr->pic[d][f];
+ const byte *src = &_G(tmp_buff[256 * ((d * 4) + f)]);
+ createSurface(s, src);
+ }
+ }
}
int load_standard_actors() {
- load_actor(0, 100 + _G(thor_info).armor); // Load Thor
- _G(actor)[0].loadFixed(_G(tmp_buff) + 5120);
- setup_actor(&_G(actor)[0], 0, 0, 100, 100);
- _G(thor) = &_G(actor)[0];
+ load_actor(0, 100 + _G(thor_info).armor); // Load Thor
+ _G(actor[0]).loadFixed(_G(tmp_buff) + 5120);
+ setup_actor(&_G(actor[0]), 0, 0, 100, 100);
+ _G(thor) = &_G(actor[0]);
- make_actor_surface(&_G(actor)[0]);
+ make_actor_surface(&_G(actor[0]));
- _G(thor_x1) = _G(thor)->x + 2;
- _G(thor_y1) = _G(thor)->y + 2;
- _G(thor_x2) = _G(thor)->x + 14;
- _G(thor_y2) = _G(thor)->y + 14;
+ _G(thor_x1) = _G(thor)->x + 2;
+ _G(thor_y1) = _G(thor)->y + 2;
+ _G(thor_x2) = _G(thor)->x + 14;
+ _G(thor_y2) = _G(thor)->y + 14;
- load_actor(0, 103 + _G(thor_info).armor); // Load hammer
- _G(actor)[1].loadFixed(_G(tmp_buff) + 5120);
- setup_actor(&_G(actor)[1], 1, 0, 100, 100);
- _G(actor)[1].used = 0;
- _G(hammer) = &_G(actor)[1];
+ load_actor(0, 103 + _G(thor_info).armor); // Load hammer
+ _G(actor[1]).loadFixed(_G(tmp_buff) + 5120);
+ setup_actor(&_G(actor[1]), 1, 0, 100, 100);
+ _G(actor[1]).used = 0;
+ _G(hammer) = &_G(actor[1]);
- make_actor_surface(&_G(actor)[1]);
+ make_actor_surface(&_G(actor[1]));
- // Load sparkle
- load_actor(0, 106);
- _G(sparkle).loadFixed(_G(tmp_buff) + 5120);
- setup_actor(&_G(sparkle), 20, 0, 100, 100);
- _G(sparkle).used = 0;
- make_actor_surface(&_G(sparkle));
+ // Load sparkle
+ load_actor(0, 106);
+ _G(sparkle).loadFixed(_G(tmp_buff) + 5120);
+ setup_actor(&_G(sparkle), 20, 0, 100, 100);
+ _G(sparkle).used = 0;
+ make_actor_surface(&_G(sparkle));
- // Load explosion
- load_actor(0, 107);
- _G(explosion).loadFixed(_G(tmp_buff) + 5120);
- setup_actor(&_G(explosion), 21, 0, 100, 100);
- _G(explosion).used = 0;
- make_actor_surface(&_G(explosion));
+ // Load explosion
+ load_actor(0, 107);
+ _G(explosion).loadFixed(_G(tmp_buff) + 5120);
+ setup_actor(&_G(explosion), 21, 0, 100, 100);
+ _G(explosion).used = 0;
+ make_actor_surface(&_G(explosion));
- // Load tornado
- load_actor(0, 108);
- _G(magic_item)[0].loadFixed((const byte *)_G(tmp_buff) + 5120);
- Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[0]);
+ // Load tornado
+ load_actor(0, 108);
+ _G(magic_item[0]).loadFixed((const byte *)_G(tmp_buff) + 5120);
+ Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic[0]));
- setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
- _G(magic_item)[0].used = 0;
+ setup_actor(&_G(magic_item[0]), 20, 0, 0, 0);
+ _G(magic_item[0]).used = 0;
- // Load shield
- load_actor(0, 109);
- _G(magic_item)[1].loadFixed((const byte *)_G(tmp_buff) + 5120);
- Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[1]);
+ // Load shield
+ load_actor(0, 109);
+ _G(magic_item[1]).loadFixed((const byte *)_G(tmp_buff) + 5120);
+ Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic[1]));
- setup_actor(&_G(magic_item)[1], 20, 0, 0, 0);
- _G(magic_item)[1].used = 0;
+ setup_actor(&_G(magic_item[1]), 20, 0, 0, 0);
+ _G(magic_item[1]).used = 0;
- _G(actor)[2].used = 0;
+ _G(actor[2]).used = 0;
- make_actor_surface(&_G(magic_item)[0]);
+ make_actor_surface(&_G(magic_item[0]));
- return 1;
+ return 1;
}
void show_enemies() {
- int i, d, r;
-
- for (i = 3; i < MAX_ACTORS; i++)
- _G(actor)[i].used = 0;
- for (i = 0; i < MAX_ENEMIES; i++)
- _G(enemy_type)[i] = 0;
-
- for (i = 0; i < MAX_ENEMIES; i++) {
- if (_G(scrn).actor_type[i] > 0) {
- r = load_enemy(_G(scrn).actor_type[i]);
- if (r >= 0) {
- _G(actor)[i + 3] = _G(enemy)[r];
-
- d = _G(scrn).actor_dir[i];
-
- setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
- (_G(scrn).actor_loc[i] / 20) * 16);
- _G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
- _G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
-
- if (_G(actor)[i + 3].move == 23) {
- // Spinball
- if (_G(actor)[i + 3].pass_value & 1)
- _G(actor)[i + 3].move = 24;
- }
-
- if (_G(scrn).actor_invis[i])
- _G(actor)[i + 3].used = 0;
- }
-
- _G(etype)[i] = r;
- }
- }
+ int i, d, r;
+
+ for (i = 3; i < MAX_ACTORS; i++)
+ _G(actor[i]).used = 0;
+ for (i = 0; i < MAX_ENEMIES; i++)
+ _G(enemy_type[i]) = 0;
+
+ for (i = 0; i < MAX_ENEMIES; i++) {
+ if (_G(scrn).actor_type[i] > 0) {
+ r = load_enemy(_G(scrn).actor_type[i]);
+ if (r >= 0) {
+ _G(actor[i + 3]) = _G(enemy[r]);
+
+ d = _G(scrn).actor_dir[i];
+
+ setup_actor(&_G(actor[i + 3]), i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
+ (_G(scrn).actor_loc[i] / 20) * 16);
+ _G(actor[i + 3]).init_dir = _G(scrn).actor_dir[i];
+ _G(actor[i + 3]).pass_value = _G(scrn).actor_value[i];
+
+ if (_G(actor[i + 3]).move == 23) {
+ // Spinball
+ if (_G(actor[i + 3]).pass_value & 1)
+ _G(actor[i + 3]).move = 24;
+ }
+
+ if (_G(scrn).actor_invis[i])
+ _G(actor[i + 3]).used = 0;
+ }
+
+ _G(etype[i]) = r;
+ }
+ }
}
int load_enemy(int type) {
- int i, e;
-
- for (i = 0; i < MAX_ENEMIES; i++) {
- if (_G(enemy_type)[i] == type)
- return i;
- }
-
- if (!load_actor(1, type)) {
- return -1;
- }
-
- e = -1;
- for (i = 0; i < MAX_ENEMIES; i++) {
- if (!_G(enemy_type)[i]) {
- e = i;
- break;
- }
- }
- if (e == -1)
- return -1;
-
- Common::MemoryReadStream inf(_G(tmp_buff) + 5120, 40);
- _G(enemy)[e].loadFixed(&inf);
-
- make_actor_surface(&_G(enemy)[e]);
- _G(enemy_type)[e] = type;
- _G(enemy)[e].shot_type = 0;
-
- if (_G(enemy)[e].shots_allowed) {
- _G(enemy)[e].shot_type = e + 1;
-
- // Set up shot info
- _G(shot)[e].loadFixed(_G(tmp_buff) + 5160);
-
- // Loop to set up graphics
- for (int d = 0; d < _G(shot)[e].directions; d++) {
- for (int f = 0; f < _G(shot)[e].frames; f++) {
- if (_G(shot)[e].directions < _G(shot)[e].frames) {
- Graphics::ManagedSurface &s = _G(shot)[e].pic[d][f];
- const byte *src = &_G(tmp_buff)[4096 + (256 * ((d * 4) + f))];
- createSurface(s, src);
- } else {
- Graphics::ManagedSurface &s = _G(shot)[e].pic[f][d];
- const byte *src = &_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
- createSurface(s, src);
- }
- }
- }
- }
-
- return e;
+ int i, e;
+
+ for (i = 0; i < MAX_ENEMIES; i++) {
+ if (_G(enemy_type[i]) == type)
+ return i;
+ }
+
+ if (!load_actor(1, type)) {
+ return -1;
+ }
+
+ e = -1;
+ for (i = 0; i < MAX_ENEMIES; i++) {
+ if (!_G(enemy_type[i])) {
+ e = i;
+ break;
+ }
+ }
+ if (e == -1)
+ return -1;
+
+ Common::MemoryReadStream inf(_G(tmp_buff) + 5120, 40);
+ _G(enemy[e]).loadFixed(&inf);
+
+ make_actor_surface(&_G(enemy[e]));
+ _G(enemy_type[e]) = type;
+ _G(enemy[e]).shot_type = 0;
+
+ if (_G(enemy[e]).shots_allowed) {
+ _G(enemy[e]).shot_type = e + 1;
+
+ // Set up shot info
+ _G(shot[e]).loadFixed(_G(tmp_buff) + 5160);
+
+ // Loop to set up graphics
+ for (int d = 0; d < _G(shot[e]).directions; d++) {
+ for (int f = 0; f < _G(shot[e]).frames; f++) {
+ if (_G(shot[e]).directions < _G(shot[e]).frames) {
+ Graphics::ManagedSurface &s = _G(shot[e]).pic[d][f];
+ const byte *src = &_G(tmp_buff[4096 + (256 * ((d * 4) + f))]);
+ createSurface(s, src);
+ } else {
+ Graphics::ManagedSurface &s = _G(shot[e]).pic[f][d];
+ const byte *src = &_G(tmp_buff[4096 + (256 * ((f * 4) + d))]);
+ createSurface(s, src);
+ }
+ }
+ }
+ }
+
+ return e;
}
int actor_visible(int invis_num) {
- int i, d;
-
- for (i = 0; i < MAX_ENEMIES; i++) {
- if (_G(scrn).actor_invis[i] == invis_num) {
- if (_G(etype)[i] >= 0 && !_G(actor)[i + 3].used) {
- _G(actor)[i + 3] = _G(enemy)[_G(etype)[i]];
-
- d = _G(scrn).actor_dir[i];
- setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
- (_G(scrn).actor_loc[i] / 20) * 16);
- _G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
- _G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
- return i;
- } else return -1;
- }
- }
- return -1;
+ int i, d;
+
+ for (i = 0; i < MAX_ENEMIES; i++) {
+ if (_G(scrn).actor_invis[i] == invis_num) {
+ int etype = _G(etype[i]);
+ if (etype >= 0 && !_G(actor[i + 3]).used) {
+ _G(actor[i + 3]) = _G(enemy[etype]);
+
+ d = _G(scrn).actor_dir[i];
+ setup_actor(&_G(actor[i + 3]), i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
+ (_G(scrn).actor_loc[i] / 20) * 16);
+ _G(actor[i + 3]).init_dir = _G(scrn).actor_dir[i];
+ _G(actor[i + 3]).pass_value = _G(scrn).actor_value[i];
+ return i;
+ } else
+ return -1;
+ }
+ }
+ return -1;
}
void setup_magic_item(int item) {
- int i;
-
- for (i = 0; i < 4; i++) {
- createSurface(_G(magic_item)[item].pic[i / 4][i % 4],
- &_G(magic_pic)[item][256 * i]);
- }
+ for (int i = 0; i < 4; i++) {
+ createSurface(_G(magic_item[item]).pic[i / 4][i % 4], &_G(magic_pic[item][256 * i]));
+ }
}
void load_new_thor() {
- load_actor(0, 100 + _G(thor_info).armor); // Load Thor
+ load_actor(0, 100 + _G(thor_info).armor); // Load Thor
- make_actor_surface(&_G(actor)[0]);
+ make_actor_surface(&_G(actor[0]));
}
} // namespace Got
Commit: cf9a65e0e0ac9855a3067b322084f645d6ad5abb
https://github.com/scummvm/scummvm/commit/cf9a65e0e0ac9855a3067b322084f645d6ad5abb
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:16-08:00
Commit Message:
GOT: Rest of code alignment in gfx
Changed paths:
engines/got/gfx/image.cpp
engines/got/gfx/palette.cpp
engines/got/gfx/palette.h
engines/got/gfx/panel.h
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 36ab9322b6f..bd244c0c984 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -241,22 +241,21 @@ int load_enemy(int type) {
}
int actor_visible(int invis_num) {
- int i, d;
-
- for (i = 0; i < MAX_ENEMIES; i++) {
+ for (int i = 0; i < MAX_ENEMIES; i++) {
if (_G(scrn).actor_invis[i] == invis_num) {
int etype = _G(etype[i]);
if (etype >= 0 && !_G(actor[i + 3]).used) {
_G(actor[i + 3]) = _G(enemy[etype]);
- d = _G(scrn).actor_dir[i];
+ int d = _G(scrn).actor_dir[i];
setup_actor(&_G(actor[i + 3]), i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
(_G(scrn).actor_loc[i] / 20) * 16);
_G(actor[i + 3]).init_dir = _G(scrn).actor_dir[i];
_G(actor[i + 3]).pass_value = _G(scrn).actor_value[i];
return i;
- } else
- return -1;
+ }
+
+ return -1;
}
}
return -1;
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index dd48d2d49d2..71b7721bf5c 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -19,13 +19,13 @@
*
*/
-#include "common/system.h"
-#include "common/events.h"
-#include "graphics/paletteman.h"
#include "got/gfx/palette.h"
-#include "got/utils/file.h"
+#include "common/events.h"
+#include "common/system.h"
#include "got/got.h"
+#include "got/utils/file.h"
#include "got/vars.h"
+#include "graphics/paletteman.h"
namespace Got {
namespace Gfx {
@@ -35,36 +35,35 @@ namespace Gfx {
static byte saved_palette[PALETTE_SIZE];
Palette63::Palette63(const byte *pal) {
- for (uint i = 0; i < PALETTE_SIZE; ++i)
- _pal[i] = pal[i] << 2;
+ for (uint i = 0; i < PALETTE_SIZE; ++i)
+ _pal[i] = pal[i] << 2;
}
-
void load_palette() {
- if (res_read("PALETTE", saved_palette) < 0)
- error("Cannot Read PALETTE");
+ if (res_read("PALETTE", saved_palette) < 0)
+ error("Cannot Read PALETTE");
- g_system->getPaletteManager()->setPalette(saved_palette, 0, 256);
+ g_system->getPaletteManager()->setPalette(saved_palette, 0, 256);
}
void set_screen_pal() {
- byte pal[3];
-
- xgetpal(pal, 1, _G(scrn).pal_colors[0]);
- xsetpal(251, pal[0], pal[1], pal[2]);
- xgetpal(pal, 1, _G(scrn).pal_colors[1]);
- xsetpal(252, pal[0], pal[1], pal[2]);
- xgetpal(pal, 1, _G(scrn).pal_colors[2]);
- xsetpal(253, pal[0], pal[1], pal[2]);
+ byte pal[3];
+
+ xgetpal(pal, 1, _G(scrn).pal_colors[0]);
+ xsetpal(251, pal[0], pal[1], pal[2]);
+ xgetpal(pal, 1, _G(scrn).pal_colors[1]);
+ xsetpal(252, pal[0], pal[1], pal[2]);
+ xgetpal(pal, 1, _G(scrn).pal_colors[2]);
+ xsetpal(253, pal[0], pal[1], pal[2]);
}
void xsetpal(byte color, byte R, byte G, byte B) {
- byte rgb[3] = { R, G, B };
- g_system->getPaletteManager()->setPalette(rgb, color, 1);
+ byte rgb[3] = {R, G, B};
+ g_system->getPaletteManager()->setPalette(rgb, color, 1);
}
void xsetpal(const byte *pal) {
- g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
+ g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
}
void set_palette(const byte *pal) {
@@ -73,72 +72,72 @@ void set_palette(const byte *pal) {
}
void xgetpal(byte *pal, int num_colrs, int start_index) {
- g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
+ g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
}
void fade_out() {
- byte tempPal[PALETTE_SIZE];
- const byte *srcP;
- byte *destP;
- int count;
- Common::Event evt;
-
- xgetpal(saved_palette, PALETTE_COUNT, 0);
-
- for (int step = FADE_STEPS - 1; step >= 0; --step) {
- // Set each palette RGB proportionately
- for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
- count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
- *destP = *srcP * step / FADE_STEPS;
- }
-
- // Set new palette
- xsetpal(tempPal);
-
- // Use up any pending events and update the screen
- while (g_system->getEventManager()->pollEvent(evt)) {
- if (evt.type == Common::EVENT_QUIT)
- return;
- }
-
- g_events->getScreen()->update();
- g_system->delayMillis(10);
- }
+ byte tempPal[PALETTE_SIZE];
+ const byte *srcP;
+ byte *destP;
+ int count;
+ Common::Event evt;
+
+ xgetpal(saved_palette, PALETTE_COUNT, 0);
+
+ for (int step = FADE_STEPS - 1; step >= 0; --step) {
+ // Set each palette RGB proportionately
+ for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
+ count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
+ *destP = *srcP * step / FADE_STEPS;
+ }
+
+ // Set new palette
+ xsetpal(tempPal);
+
+ // Use up any pending events and update the screen
+ while (g_system->getEventManager()->pollEvent(evt)) {
+ if (evt.type == Common::EVENT_QUIT)
+ return;
+ }
+
+ g_events->getScreen()->update();
+ g_system->delayMillis(10);
+ }
}
void fade_in(const byte *pal) {
- byte tempPal[PALETTE_SIZE];
- const byte *srcP;
- byte *destP;
- int count;
- Common::Event evt;
-
- if (pal)
- Common::copy(pal, pal + PALETTE_SIZE, saved_palette);
-
- // Start with a black palette
- Common::fill(tempPal, tempPal + PALETTE_SIZE, 0);
- xsetpal(tempPal);
-
- for (int step = 1; step <= FADE_STEPS; ++step) {
- // Set each palette RGB proportionately
- for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
- count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
- *destP = *srcP * step / FADE_STEPS;
- }
-
- // Set new palette
- xsetpal(tempPal);
-
- // Use up any pending events and update the screen
- while (g_system->getEventManager()->pollEvent(evt)) {
- if (evt.type == Common::EVENT_QUIT)
- return;
- }
-
- g_events->getScreen()->update();
- g_system->delayMillis(10);
- }
+ byte tempPal[PALETTE_SIZE];
+ const byte *srcP;
+ byte *destP;
+ int count;
+ Common::Event evt;
+
+ if (pal)
+ Common::copy(pal, pal + PALETTE_SIZE, saved_palette);
+
+ // Start with a black palette
+ Common::fill(tempPal, tempPal + PALETTE_SIZE, 0);
+ xsetpal(tempPal);
+
+ for (int step = 1; step <= FADE_STEPS; ++step) {
+ // Set each palette RGB proportionately
+ for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
+ count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
+ *destP = *srcP * step / FADE_STEPS;
+ }
+
+ // Set new palette
+ xsetpal(tempPal);
+
+ // Use up any pending events and update the screen
+ while (g_system->getEventManager()->pollEvent(evt)) {
+ if (evt.type == Common::EVENT_QUIT)
+ return;
+ }
+
+ g_events->getScreen()->update();
+ g_system->delayMillis(10);
+ }
}
} // namespace Gfx
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index d605b668c21..23bb42f906a 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -28,13 +28,13 @@ namespace Got {
namespace Gfx {
struct Palette63 {
- byte _pal[PALETTE_SIZE] = {};
- Palette63() {}
- Palette63(const byte *pal);
+ byte _pal[PALETTE_SIZE] = {};
+ Palette63() {}
+ Palette63(const byte *pal);
- operator const byte *() const {
- return _pal;
- }
+ operator const byte *() const {
+ return _pal;
+ }
};
extern void load_palette();
diff --git a/engines/got/gfx/panel.h b/engines/got/gfx/panel.h
index 335cc1ce3b9..d3027f05fc7 100644
--- a/engines/got/gfx/panel.h
+++ b/engines/got/gfx/panel.h
@@ -22,8 +22,6 @@
#ifndef GOT_GAME_PANEL_H
#define GOT_GAME_PANEL_H
-#include "got/data/defines.h"
-
namespace Got {
extern void boss_status(int health);
Commit: 58f88bcf2996f271c945fad25067a9a338dfd19d
https://github.com/scummvm/scummvm/commit/58f88bcf2996f271c945fad25067a9a338dfd19d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:16-08:00
Commit Message:
GOT: Remove the obsolete panel.h
Changed paths:
R engines/got/gfx/panel.h
engines/got/game/back.cpp
engines/got/game/boss1.cpp
engines/got/game/boss2.cpp
engines/got/game/boss3.cpp
engines/got/game/move_patterns.cpp
engines/got/game/object.cpp
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 6b1d7497820..286f0a6e62d 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -29,7 +29,6 @@
#include "got/game/object.h"
#include "got/game/script.h"
#include "got/gfx/image.h"
-#include "got/gfx/panel.h"
#include "got/vars.h"
namespace Got {
@@ -348,8 +347,6 @@ int actor_speaks(ACTOR *actr, int index, int item) {
_G(exit_flag) = 2;
}
- d_restore();
-
return 1;
}
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 69ed8760b46..88932b91f51 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -27,7 +27,6 @@
#include "got/game/move_patterns.h"
#include "got/game/status.h"
#include "got/gfx/image.h"
-#include "got/gfx/panel.h"
#include "got/sound.h"
#include "got/vars.h"
@@ -200,7 +199,6 @@ void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
_G(actor[3]).health -= 10;
_G(actor[3]).speed_count = 50;
- boss_status(_G(actor[3]).health);
_G(actor[3]).vunerable = 100;
play_sound(BOSS13, true);
_G(actor[3]).next = 1;
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 276323db932..1904d403477 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -26,7 +26,6 @@
#include "got/game/move.h"
#include "got/game/status.h"
#include "got/gfx/image.h"
-#include "got/gfx/panel.h"
#include "got/sound.h"
#include "got/vars.h"
@@ -173,15 +172,15 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
_G(actor[3]).i1 = 1;
_G(actor[3]).i2 = 0;
memset(expf, 0, 60);
- for (rep = 7; rep < MAX_ACTORS; rep++)
+ for (rep = 7; rep < MAX_ACTORS; rep++) {
if (_G(actor[rep]).used)
actor_destroyed(&_G(actor[rep]));
+ }
_G(actor[3]).num_shots = 0;
} else
play_sound(BOSS13, true);
_G(actor[3]).speed_count = 75;
- boss_status(_G(actor[3]).health);
_G(actor[3]).vunerable = 75;
_G(actor[3]).next = 1;
@@ -203,7 +202,6 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
void boss_level2() {
setup_boss(2);
_G(boss_active) = true;
- boss_status(-1);
music_pause();
play_sound(BOSS11, true);
_G(timer_cnt) = 0;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 243c470c643..20d4d43062f 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -26,7 +26,6 @@
#include "got/game/move.h"
#include "got/game/move_patterns.h"
#include "got/game/status.h"
-#include "got/gfx/panel.h"
#include "got/sound.h"
#include "got/vars.h"
@@ -397,8 +396,7 @@ static void check_boss_hit() {
return;
}
- if (_G(actor[3]).magic_hit || _G(actor[4]).magic_hit ||
- _G(actor[5]).magic_hit || _G(actor[6]).magic_hit) {
+ if (_G(actor[3]).magic_hit || _G(actor[4]).magic_hit || _G(actor[5]).magic_hit || _G(actor[6]).magic_hit) {
if (!_G(actor[3]).temp2) {
actor_damaged(&_G(actor[3]), 10);
@@ -409,7 +407,6 @@ static void check_boss_hit() {
_G(actor[3]).speed_count = 50;
- boss_status(_G(actor[3]).health);
_G(actor[3]).vunerable = 50;
play_sound(BOSS13, true);
@@ -449,7 +446,6 @@ static void boss_change_mode() {
if (!_G(boss_intro2)) {
Gfx::Pics loki("FACE18", 262);
execute_script(1003, loki);
- d_restore();
_G(boss_intro2) = true;
}
boss_mode = 0;
@@ -458,7 +454,6 @@ static void boss_change_mode() {
void boss_level3() {
setup_boss(3);
_G(boss_active) = true;
- boss_status(-1);
music_pause();
play_sound(BOSS11, true);
_G(timer_cnt) = 0;
@@ -468,7 +463,6 @@ void boss_level3() {
if (!_G(boss_intro1)) {
Gfx::Pics loki("FACE18", 262);
execute_script(1002, loki);
- d_restore();
_G(boss_intro1) = true;
}
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index f6fb76fc8b1..75f049ecb85 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -29,7 +29,6 @@
#include "got/game/object.h"
#include "got/game/script.h"
#include "got/game/special_tile.h"
-#include "got/gfx/panel.h"
#include "got/vars.h"
namespace Got {
@@ -964,16 +963,13 @@ int special_movement_two(ACTOR *actr) {
if (!sound_playing())
play_sound(ANGEL, false);
_G(thor)->health += 1;
- display_health();
- }
- } else {
- if (_G(thor_info).magic < 150) {
- if (!sound_playing())
- play_sound(ANGEL, false);
- _G(thor_info).magic += 1;
- display_magic();
}
+ } else if (_G(thor_info).magic < 150) {
+ if (!sound_playing())
+ play_sound(ANGEL, false);
+ _G(thor_info).magic += 1;
}
+
return 1;
}
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 72781743447..e2e6be81b8f 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -26,7 +26,6 @@
#include "got/game/move.h"
#include "got/game/status.h"
#include "got/gfx/image.h"
-#include "got/gfx/panel.h"
#include "got/vars.h"
namespace Got {
@@ -134,7 +133,6 @@ void pick_up_object(int p) {
_G(thor_info).inventory |= 64;
_G(thor_info).item = 7;
_G(thor_info).object = _G(object_map[p]) - 11;
- display_item();
_G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
odin_speaks((_G(object_map[p]) - 12) + 501, _G(object_map[p]) - 1);
break;
@@ -157,7 +155,6 @@ void pick_up_object(int p) {
odin_speaks((_G(object_map[p]) - 27) + 516, _G(object_map[p]) - 1);
s = 1;
_G(thor_info).item = _G(object_map[p]) - 26;
- display_item();
add_magic(150);
fill_score(5);
break;
@@ -489,7 +486,6 @@ void delete_object() {
_G(thor_info).inventory &= 0xbf;
_G(thor_info).item = 1;
- display_item();
}
} // namespace Got
diff --git a/engines/got/gfx/panel.h b/engines/got/gfx/panel.h
deleted file mode 100644
index d3027f05fc7..00000000000
--- a/engines/got/gfx/panel.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef GOT_GAME_PANEL_H
-#define GOT_GAME_PANEL_H
-
-namespace Got {
-
-extern void boss_status(int health);
-
-// Dummy functions for displaying on-screen elements
-// that are now handled by the GameContent and GameStatus views
-inline void display_item() {}
-inline void display_health() {}
-inline void display_magic() {}
-inline void d_restore() {}
-inline void boss_status(int health) {}
-
-} // namespace Got
-
-#endif
Commit: 2f2157eb1ff1687d56faa9c796c90c9d55ecb234
https://github.com/scummvm/scummvm/commit/2f2157eb1ff1687d56faa9c796c90c9d55ecb234
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:16-08:00
Commit Message:
GOT: Fix compilation warning
Changed paths:
engines/got/gfx/gfx_pics.cpp
diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index da478e7b6ee..949605b092f 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -91,7 +91,7 @@ GfxPics &GfxPics::operator=(const GfxPics &src) {
clear();
resize(src._size);
- for (int i = 0; i < _size; ++i)
+ for (size_t i = 0; i < _size; ++i)
_array[i].copyFrom(src._array[i]);
return *this;
Commit: c149ea878e4eb00d9239ff02a76375f6a52fc388
https://github.com/scummvm/scummvm/commit/c149ea878e4eb00d9239ff02a76375f6a52fc388
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:16-08:00
Commit Message:
GOT: Change includes in res_archive, code formatting in utils
Changed paths:
engines/got/utils/compression.cpp
engines/got/utils/compression.h
engines/got/utils/file.cpp
engines/got/utils/file.h
engines/got/utils/res_archive.cpp
engines/got/utils/res_archive.h
diff --git a/engines/got/utils/compression.cpp b/engines/got/utils/compression.cpp
index 87483d6696c..790082051c7 100644
--- a/engines/got/utils/compression.cpp
+++ b/engines/got/utils/compression.cpp
@@ -19,61 +19,60 @@
*
*/
+#include "got/utils/compression.h"
#include "common/algorithm.h"
#include "common/endian.h"
-#include "got/utils/compression.h"
namespace Got {
void lzss_decompress(const byte *src, byte *dest, size_t destSize) {
- byte *endP = dest + destSize;
+ byte *endP = dest + destSize;
- for (;;) {
- byte v = *src++;
+ for (;;) {
+ byte v = *src++;
- for (int bits = 8; bits > 0; --bits) {
- if (endP == dest)
- return;
+ for (int bits = 8; bits > 0; --bits) {
+ if (endP == dest)
+ return;
- bool bit = (v & 1) != 0;
- v >>= 1;
- if (bit) {
- *dest++ = *src++;
- } else {
- uint16 offset = READ_LE_UINT16(src);
- src += 2;
- int count = (offset >> 12) + 2;
- offset &= 0xfff;
+ bool bit = (v & 1) != 0;
+ v >>= 1;
+ if (bit) {
+ *dest++ = *src++;
+ } else {
+ uint16 offset = READ_LE_UINT16(src);
+ src += 2;
+ int count = (offset >> 12) + 2;
+ offset &= 0xfff;
- Common::copy(dest - offset, dest - offset + count, dest);
- dest += count;
- }
- }
- }
+ Common::copy(dest - offset, dest - offset + count, dest);
+ dest += count;
+ }
+ }
+ }
}
void rle_decompress(const byte *src, byte *dest, size_t destSize) {
- byte *endP = dest + destSize;
- byte val;
+ byte *endP = dest + destSize;
- for (;;) {
- val = *src++;
+ for (;;) {
+ byte val = *src++;
- if ((val &0x80) != 0) {
- byte rep = *src++;
- val &= 0x7f;
- Common::fill(dest, dest + val, rep);
- dest += val;
- } else if (val > 0) {
- Common::copy(src, src + val, dest);
- src += val;
- dest += val;
- } else {
- break;
- }
- }
+ if ((val & 0x80) != 0) {
+ byte rep = *src++;
+ val &= 0x7f;
+ Common::fill(dest, dest + val, rep);
+ dest += val;
+ } else if (val > 0) {
+ Common::copy(src, src + val, dest);
+ src += val;
+ dest += val;
+ } else {
+ break;
+ }
+ }
- assert(dest == endP);
+ assert(dest == endP);
}
} // namespace Got
diff --git a/engines/got/utils/compression.h b/engines/got/utils/compression.h
index 8ac04d4dead..503346880b5 100644
--- a/engines/got/utils/compression.h
+++ b/engines/got/utils/compression.h
@@ -27,7 +27,7 @@
namespace Got {
/**
- * LXSS decompressor
+ * LZSS decompressor
*/
void lzss_decompress(const byte *src, byte *dest, size_t destSize);
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index eed61089a40..0882f3f0e13 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -26,115 +26,110 @@
namespace Got {
bool File::open(const Common::Path &filename) {
- if (!Common::File::open(filename))
- error("Could not open - %s", filename.baseName().c_str());
- return true;
+ if (!Common::File::open(filename))
+ error("Could not open - %s", filename.baseName().c_str());
+ return true;
}
bool load_actor(int /*file*/, int num) {
- Common::String fname = Common::String::format("ACTOR%d", num);
+ Common::String fname = Common::String::format("ACTOR%d", num);
- if (res_read(fname, _G(tmp_buff), true) < 0)
- return false;
+ if (res_read(fname, _G(tmp_buff), true) < 0)
+ return false;
- //file = file;
- return true;
+ return true;
}
bool load_speech(int index) {
- int cnt;
- char *p;
- char *pm;
- char *sp;
- char tmps[5];
-
- Common::String fname = Common::String::format("SPEAK%d", _G(area));
-
- sp = new char[30000];
- if (!sp)
- return false;
-
- if (res_read(fname, sp) < 0) {
- delete[] sp;
- return 0;
- }
-
- p = sp;
-
- cnt = 0;
- for (;;) {
- if (*p == ':') {
- p++;
- cnt++;
- strncpy(tmps, p, 4);
- tmps[4] = '\0';
-
- if (atoi(tmps) == index) {
- break;
- }
- }
-
- p++;
- cnt++;
- }
-
- while (*p != 10)
- p++;
- p++;
-
- pm = p;
- cnt = 0;
-
- for (;;) {
- if (*p == 13)
- *p = 32;
- if (*p == ':') {
- if ((*(p + 1) == 'E') && (*(p + 2) == 'N') && (*(p + 3) == 'D')) break;
- }
-
- p++;
- cnt++;
-
- if (cnt > 5799) {
- delete[] sp;
- return false;
- }
- }
-
- if (*(p - 1) == 10)
- *(p - 1) = 0;
- *p = 0;
-
- Common::copy(pm, pm + cnt, _G(tmp_buff));
- _G(tmp_buff)[cnt] = 0;
-
- delete[] sp;
- return true;
-}
-
-void setup_filenames(int level) {
+ char tmps[5];
+
+ Common::String fname = Common::String::format("SPEAK%d", _G(area));
+
+ char *sp = new char[30000];
+ if (!sp)
+ return false;
+
+ if (res_read(fname, sp) < 0) {
+ delete[] sp;
+ return false;
+ }
+
+ char *p = sp;
+
+ int cnt = 0;
+ for (;;) {
+ if (*p == ':') {
+ p++;
+ cnt++;
+ strncpy(tmps, p, 4);
+ tmps[4] = '\0';
+
+ if (atoi(tmps) == index) {
+ break;
+ }
+ }
+
+ p++;
+ cnt++;
+ }
+
+ while (*p != 10)
+ p++;
+ p++;
+
+ char *pm = p;
+ cnt = 0;
+
+ for (;;) {
+ if (*p == 13)
+ *p = 32;
+ if (*p == ':') {
+ if ((*(p + 1) == 'E') && (*(p + 2) == 'N') && (*(p + 3) == 'D'))
+ break;
+ }
+
+ p++;
+ cnt++;
+
+ if (cnt > 5799) {
+ delete[] sp;
+ return false;
+ }
+ }
+
+ if (*(p - 1) == 10)
+ *(p - 1) = 0;
+ *p = 0;
+
+ Common::copy(pm, pm + cnt, _G(tmp_buff));
+ _G(tmp_buff)
+ [cnt] = 0;
+
+ delete[] sp;
+ return true;
}
long res_read(const Common::String &name, void *buff, bool failAllowed) {
- Common::File f;
- if (f.open(Common::Path(name))) {
- return f.read(buff, f.size());
- } else {
- if (!failAllowed)
- error("Could not load - %s", name.c_str());
- return -1;
- }
+ Common::File f;
+ if (f.open(Common::Path(name))) {
+ return f.read(buff, f.size());
+ }
+
+ if (!failAllowed)
+ error("Could not load - %s", name.c_str());
+
+ return -1;
}
void *res_falloc_read(const Common::String &name) {
- Common::File f;
- if (f.open(Common::Path(name))) {
- byte *result = (byte *)malloc(f.size());
- f.read(result, f.size());
- return result;
- } else {
- return nullptr;
- }
+ Common::File f;
+ if (f.open(Common::Path(name))) {
+ byte *result = (byte *)malloc(f.size());
+ f.read(result, f.size());
+ return result;
+ }
+
+ return nullptr;
}
} // End of namespace Got
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index c292d0df3fa..fd6f71eb5b7 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -29,19 +29,19 @@ namespace Got {
extern bool load_actor(int, int num);
extern void setup_filenames(int level);
-extern bool load_speech(int index);
+extern bool load_speech(int index);
extern long res_read(const Common::String &name, void *buff,
- bool failAllowed = false);
+ bool failAllowed = false);
extern void *res_falloc_read(const Common::String &name);
class File : public Common::File {
public:
- File() : Common::File() {}
- File(const Common::String &filename) : Common::File() {
- File::open(Common::Path(filename));
- }
+ File() : Common::File() {}
+ File(const Common::String &filename) : Common::File() {
+ File::open(Common::Path(filename));
+ }
- bool open(const Common::Path &filename) override;
+ bool open(const Common::Path &filename) override;
};
} // namespace Got
diff --git a/engines/got/utils/res_archive.cpp b/engines/got/utils/res_archive.cpp
index 66b44e96767..4423a4862c2 100644
--- a/engines/got/utils/res_archive.cpp
+++ b/engines/got/utils/res_archive.cpp
@@ -19,130 +19,129 @@
*
*/
-#include "common/archive.h"
#include "common/file.h"
#include "common/memstream.h"
-#include "got/utils/res_archive.h"
#include "got/utils/compression.h"
+#include "got/utils/res_archive.h"
namespace Got {
static const char *RES_FILENAME = "gotres.dat";
void resInit() {
- ResArchive *a = new ResArchive();
- SearchMan.add("Res", a);
+ ResArchive *a = new ResArchive();
+ SearchMan.add("Res", a);
}
void ResHeader::load(Common::SeekableReadStream *src) {
- char buf[10];
- src->read(buf, 9);
- buf[9] = '\0';
- _name = buf;
-
- _offset = src->readUint32LE();
- _size = src->readUint32LE();
- _originalSize = src->readUint32LE();
- _key = src->readUint16LE();
+ char buf[10];
+ src->read(buf, 9);
+ buf[9] = '\0';
+ _name = buf;
+
+ _offset = src->readUint32LE();
+ _size = src->readUint32LE();
+ _originalSize = src->readUint32LE();
+ _key = src->readUint16LE();
}
ResArchive::ResArchive() {
- Common::File f;
- if (!f.open(RES_FILENAME))
- error("Could not open %s", RES_FILENAME);
-
- // Read in header data and decrypt it
- byte buf[RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE];
- if (f.read(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE) !=
- (RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE))
- error("Could not read in resource headers");
-
- decrypt(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE, 128);
-
- // Load headers
- Common::MemoryReadStream hdrData(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE);
- for (int i = 0; i < RES_MAX_ENTRIES; ++i) {
- ResHeader hdr;
- hdr.load(&hdrData);
- if (!(hdr._offset == 0 && hdr._size == 0))
- _headers.push_back(hdr);
- }
+ Common::File f;
+ if (!f.open(RES_FILENAME))
+ error("Could not open %s", RES_FILENAME);
+
+ // Read in header data and decrypt it
+ byte buf[RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE];
+ if (f.read(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE) !=
+ (RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE))
+ error("Could not read in resource headers");
+
+ decrypt(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE, 128);
+
+ // Load headers
+ Common::MemoryReadStream hdrData(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE);
+ for (int i = 0; i < RES_MAX_ENTRIES; ++i) {
+ ResHeader hdr;
+ hdr.load(&hdrData);
+ if (!(hdr._offset == 0 && hdr._size == 0))
+ _headers.push_back(hdr);
+ }
}
void ResArchive::decrypt(byte *buf, size_t len, byte key) const {
- for (size_t i = 0; i < len; ++i)
- *buf++ ^= key++;
+ for (size_t i = 0; i < len; ++i)
+ *buf++ ^= key++;
}
int ResArchive::indexOf(const Common::String &name) const {
- for (uint i = 0; i < _headers.size(); ++i) {
- if (_headers[i]._name.equalsIgnoreCase(name))
- return i;
- }
+ for (uint i = 0; i < _headers.size(); ++i) {
+ if (_headers[i]._name.equalsIgnoreCase(name))
+ return i;
+ }
- return -1;
+ return -1;
}
bool ResArchive::hasFile(const Common::Path &path) const {
- return indexOf(path.baseName()) != -1;
+ return indexOf(path.baseName()) != -1;
}
int ResArchive::listMembers(Common::ArchiveMemberList &list) const {
- int count = 0;
+ int count = 0;
- for (uint i = 0; i < _headers.size(); ++i) {
- list.push_back(Common::ArchiveMemberList::value_type(
- new Common::GenericArchiveMember(_headers[i]._name, *this)));
- ++count;
- }
+ for (uint i = 0; i < _headers.size(); ++i) {
+ list.push_back(Common::ArchiveMemberList::value_type(
+ new Common::GenericArchiveMember(_headers[i]._name, *this)));
+ ++count;
+ }
- return count;
+ return count;
}
const Common::ArchiveMemberPtr ResArchive::getMember(const Common::Path &path) const {
- if (!hasFile(path))
- return Common::ArchiveMemberPtr();
+ if (!hasFile(path))
+ return Common::ArchiveMemberPtr();
- return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
+ return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
}
Common::SeekableReadStream *ResArchive::createReadStreamForMember(const Common::Path &path) const {
- // Get the index of the header entry for this file
- int hdrIndex = indexOf(path.baseName());
- if (hdrIndex == -1)
- return nullptr;
-
- Common::File f;
- if (!f.open(RES_FILENAME))
- error("Error reading resource");
-
- // Set up buffers
- const ResHeader &hdr = _headers[hdrIndex];
- byte *buf = (byte *)malloc(hdr._size);
-
- f.seek(hdr._offset);
- if (f.read(buf, hdr._size) != hdr._size)
- error("Error reading resource");
-
- // Decrypt if necessary
- if (hdr._key != 0) {
- byte *temp = buf;
- buf = (byte *)malloc(hdr._originalSize);
-
- lzssDecompress(temp, buf);
- free(temp);
- }
-
- return new Common::MemoryReadStream(buf, hdr._originalSize,
- DisposeAfterUse::YES);
+ // Get the index of the header entry for this file
+ int hdrIndex = indexOf(path.baseName());
+ if (hdrIndex == -1)
+ return nullptr;
+
+ Common::File f;
+ if (!f.open(RES_FILENAME))
+ error("Error reading resource");
+
+ // Set up buffers
+ const ResHeader &hdr = _headers[hdrIndex];
+ byte *buf = (byte *)malloc(hdr._size);
+
+ f.seek(hdr._offset);
+ if (f.read(buf, hdr._size) != hdr._size)
+ error("Error reading resource");
+
+ // Decrypt if necessary
+ if (hdr._key != 0) {
+ byte *temp = buf;
+ buf = (byte *)malloc(hdr._originalSize);
+
+ lzssDecompress(temp, buf);
+ free(temp);
+ }
+
+ return new Common::MemoryReadStream(buf, hdr._originalSize,
+ DisposeAfterUse::YES);
}
void ResArchive::lzssDecompress(const byte *src, byte *dest) const {
- uint16 size = READ_LE_UINT16(src);
- assert(READ_LE_UINT16(src + 2) == 1);
- src += 4;
+ uint16 size = READ_LE_UINT16(src);
+ assert(READ_LE_UINT16(src + 2) == 1);
+ src += 4;
- lzss_decompress(src, dest, size);
+ lzss_decompress(src, dest, size);
}
} // namespace Got
diff --git a/engines/got/utils/res_archive.h b/engines/got/utils/res_archive.h
index 0564ed82b6a..bba909c649a 100644
--- a/engines/got/utils/res_archive.h
+++ b/engines/got/utils/res_archive.h
@@ -22,6 +22,7 @@
#ifndef GOT_UTILS_RES_ARCHIVE_H
#define GOT_UTILS_RES_ARCHIVE_H
+#include "common/archive.h"
#include "common/stream.h"
namespace Got {
Commit: 81c0e64973e57b2bb8d735a113ed825b84757cbe
https://github.com/scummvm/scummvm/commit/81c0e64973e57b2bb8d735a113ed825b84757cbe
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT: Remove unused class
Changed paths:
R engines/got/views/dialogs/play_game.cpp
R engines/got/views/dialogs/play_game.h
engines/got/module.mk
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 3a674bc3ccc..1f13935e8da 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -53,7 +53,6 @@ MODULE_OBJS = \
views/dialogs/high_scores.o \
views/dialogs/main_menu.o \
views/dialogs/options_menu.o \
- views/dialogs/play_game.o \
views/dialogs/quit.o \
views/dialogs/quit_game.o \
views/dialogs/save_game.o \
diff --git a/engines/got/views/dialogs/play_game.cpp b/engines/got/views/dialogs/play_game.cpp
deleted file mode 100644
index 1fcab2b80bf..00000000000
--- a/engines/got/views/dialogs/play_game.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "got/views/dialogs/play_game.h"
-#include "got/metaengine.h"
-#include "got/vars.h"
-
-namespace Got {
-namespace Views {
-namespace Dialogs {
-
-void PlayGame::draw() {
- Dialog::draw();
-#ifdef TODO
- // Write the title
- GfxSurface s = getSurface(true);
- int titleStart = (s.w - _title.size() * 8) / 2;
-
- s.print(Common::Point(titleStart, 4), _title, 54);
-#endif
-}
-
-bool PlayGame::msgAction(const ActionMessage &msg) {
- // Don't allow further actions if selection is in progress
-
- switch (msg._action) {
- case KEYBIND_UP:
- play_sound(WOOP,1);
- break;
-
- case KEYBIND_DOWN:
- play_sound(WOOP, 1);
- break;
-
- case KEYBIND_SELECT:
- case KEYBIND_FIRE:
- case KEYBIND_MAGIC:
- break;
-
- case KEYBIND_ESCAPE:
- close();
-
- default:
- break;
- }
-
- return true;
-}
-
-bool PlayGame::tick() {
- return true;
-}
-
-} // namespace Dialogs
-} // namespace Views
-} // namespace Got
diff --git a/engines/got/views/dialogs/play_game.h b/engines/got/views/dialogs/play_game.h
deleted file mode 100644
index 2fa636da3a5..00000000000
--- a/engines/got/views/dialogs/play_game.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef GOT_VIEWS_DIALOGS_PLAY_GAME_H
-#define GOT_VIEWS_DIALOGS_PLAY_GAME_H
-
-#include "graphics/managed_surface.h"
-#include "got/views/dialogs/dialog.h"
-
-namespace Got {
-namespace Views {
-namespace Dialogs {
-
-class PlayGame : public Dialog {
-public:
- PlayGame() : Dialog("PlayGame") {
- }
- virtual ~PlayGame() {
- }
-
- bool msgFocus(const FocusMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
- void draw() override;
- bool tick() override;
-};
-
-} // namespace Dialogs
-} // namespace Views
-} // namespace Got
-
-#endif
Commit: a475bf6d39b58e571ac5c87c2457cc1d7b9d84dc
https://github.com/scummvm/scummvm/commit/a475bf6d39b58e571ac5c87c2457cc1d7b9d84dc
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT: Start working on views (modification of access to global arrays, code formatting)
Changed paths:
engines/got/events.cpp
engines/got/views/dialogs/ask.cpp
engines/got/views/dialogs/ask.h
engines/got/views/dialogs/dialog.cpp
engines/got/views/dialogs/dialog.h
engines/got/views/dialogs/high_scores.cpp
engines/got/views/dialogs/high_scores.h
engines/got/views/dialogs/main_menu.cpp
engines/got/views/dialogs/main_menu.h
engines/got/views/dialogs/options_menu.cpp
engines/got/views/dialogs/options_menu.h
engines/got/views/dialogs/quit.cpp
engines/got/views/dialogs/quit.h
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 9292664fd06..a35feecc97c 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -19,12 +19,12 @@
*
*/
-#include "common/config-manager.h"
-#include "graphics/screen.h"
#include "got/events.h"
-#include "got/got.h"
+#include "common/config-manager.h"
#include "got/gfx/palette.h"
+#include "got/got.h"
#include "got/views/views.h"
+#include "graphics/screen.h"
namespace Got {
@@ -33,500 +33,493 @@ Events *g_events;
// Index and RGB63 values used for palette animation
// like water effects and gems sparkling
static const uint16 PAL_CLR1[] = {
- 0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b
-};
+ 0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b};
static const uint16 PAL_SET1[] = {
- 0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f
-};
+ 0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f};
static const uint16 PAL_CLR2[] = {
- 0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000
-};
+ 0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000};
static const uint16 PAL_SET2[] = {
- 0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727
-};
+ 0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727};
Events::Events() : UIElement("Root", nullptr) {
- g_events = this;
+ g_events = this;
}
Events::~Events() {
- g_events = nullptr;
+ g_events = nullptr;
}
void Events::runGame() {
- uint currTime, nextFrameTime = 0;
- int palCycleCtr = 0;
- _screen = new Graphics::Screen();
- Views::Views views; // Loads all views in the structure
-
- // Set up the initial game view
- int saveSlot = ConfMan.getInt("save_slot");
- if (saveSlot != -1) {
- if (g_engine->loadGameState(saveSlot).getCode() != Common::kNoError)
- saveSlot = -1;
- }
- if (saveSlot == -1)
- addView(isDemo() ? "Game" : "SplashScreen");
-
- // Main game loop
- Common::Event e;
- while (!_views.empty() && !shouldQuit()) {
- while (g_system->getEventManager()->pollEvent(e)) {
- if (e.type == Common::EVENT_QUIT ||
- e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
- _views.clear();
- break;
+ uint nextFrameTime = 0;
+ int palCycleCtr = 0;
+ _screen = new Graphics::Screen();
+ Views::Views views; // Loads all views in the structure
+
+ // Set up the initial game view
+ int saveSlot = ConfMan.getInt("save_slot");
+ if (saveSlot != -1) {
+ if (g_engine->loadGameState(saveSlot).getCode() != Common::kNoError)
+ saveSlot = -1;
+ }
+ if (saveSlot == -1)
+ addView(isDemo() ? "Game" : "SplashScreen");
+
+ // Main game loop
+ Common::Event e;
+ while (!_views.empty() && !shouldQuit()) {
+ while (g_system->getEventManager()->pollEvent(e)) {
+ if (e.type == Common::EVENT_QUIT ||
+ e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
+ _views.clear();
+ break;
} else {
processEvent(e);
}
- }
-
- if (_views.empty())
- break;
+ }
- g_system->delayMillis(10);
+ if (_views.empty())
+ break;
- // Rotate the palette
- if (++palCycleCtr == 2) {
- palCycleCtr = 0;
+ g_system->delayMillis(10);
- bool gameVisible = false;
- for (uint i = 0; i < _views.size() && !gameVisible; ++i)
- gameVisible = _views[i]->_name == "Game";
+ // Rotate the palette
+ if (++palCycleCtr == 2) {
+ palCycleCtr = 0;
- if (gameVisible)
- rotatePalette();
- }
+ bool gameVisible = false;
+ for (uint i = 0; i < _views.size() && !gameVisible; ++i)
+ gameVisible = _views[i]->_name == "Game";
- if ((currTime = g_system->getMillis()) >= nextFrameTime) {
- nextFrameTime = currTime + FRAME_DELAY;
- nextFrame();
- }
- }
+ if (gameVisible)
+ rotatePalette();
+ }
+ uint currTime = g_system->getMillis();
+ if (currTime >= nextFrameTime) {
+ nextFrameTime = currTime + FRAME_DELAY;
+ nextFrame();
+ }
+ }
- delete _screen;
+ delete _screen;
}
void Events::nextFrame() {
- // Update state variables
- _G(rand1) = getRandomNumber(99);
- _G(rand2) = getRandomNumber(99);
- _G(pge) = _G(pge) ^ 1;
- _G(shot_ok) = true;
- _G(magic_cnt)++;
-
- // In demo mode, handle the next key
- if (_G(demo) && focusedView()->getName() == "Game") {
- if (_G(demoKeys).empty()) {
+ // Update state variables
+ _G(rand1) = getRandomNumber(99);
+ _G(rand2) = getRandomNumber(99);
+ _G(pge) = _G(pge) ^ 1;
+ _G(shot_ok) = true;
+ _G(magic_cnt)
+ ++;
+
+ // In demo mode, handle the next key
+ if (_G(demo) && focusedView()->getName() == "Game") {
+ if (_G(demoKeys).empty()) {
_G(demo) = false;
send("TitleBackground", GameMessage("MAIN_MENU"));
return;
- } else {
- processDemoEvent(_G(demoKeys).pop());
- }
- }
+ }
+
+ processDemoEvent(_G(demoKeys).pop());
+ }
- // Check if any script needs resuming
- _G(scripts).runIfResuming();
+ // Check if any script needs resuming
+ _G(scripts).runIfResuming();
- // Do tick action to the views to handle gameplay logic
- tick();
+ // Do tick action to the views to handle gameplay logic
+ tick();
- // Draw the current view's elements as needed, and update screen
- drawElements();
- _screen->update();
+ // Draw the current view's elements as needed, and update screen
+ drawElements();
+ _screen->update();
}
#define LOOP_THRESHOLD 5
void Events::rotatePalette() {
- ++_palLoop;
+ ++_palLoop;
- if (_palLoop > LOOP_THRESHOLD) {
- _palLoop = 0;
- } else {
+ if (_palLoop > LOOP_THRESHOLD) {
+ _palLoop = 0;
+ } else {
const uint16 *entry;
switch (_palLoop) {
- case LOOP_THRESHOLD - 4:
- entry = &PAL_CLR2[_palCnt2];
- break;
- case LOOP_THRESHOLD - 3:
- entry = &PAL_SET2[_palCnt2];
-
- _palCnt2 += 2;
- if (_palCnt2 >= 8)
- _palCnt2 = 0;
- break;
- case LOOP_THRESHOLD - 2:
- entry = &PAL_CLR1[_palCnt1];
- break;
- case LOOP_THRESHOLD - 1:
- entry = &PAL_SET1[_palCnt1];
-
- _palCnt1 += 2;
- if (_palCnt1 >= 8)
- _palCnt1 = 0;
- break;
- default:
- return;
- }
-
- Gfx::xsetpal(entry[0] >> 8, (entry[0] & 0xff) << 2,
- (entry[1] >> 8) << 2, (entry[1] & 0xff) << 2);
- }
+ case LOOP_THRESHOLD - 4:
+ entry = &PAL_CLR2[_palCnt2];
+ break;
+ case LOOP_THRESHOLD - 3:
+ entry = &PAL_SET2[_palCnt2];
+
+ _palCnt2 += 2;
+ if (_palCnt2 >= 8)
+ _palCnt2 = 0;
+ break;
+ case LOOP_THRESHOLD - 2:
+ entry = &PAL_CLR1[_palCnt1];
+ break;
+ case LOOP_THRESHOLD - 1:
+ entry = &PAL_SET1[_palCnt1];
+
+ _palCnt1 += 2;
+ if (_palCnt1 >= 8)
+ _palCnt1 = 0;
+ break;
+ default:
+ return;
+ }
+
+ Gfx::xsetpal(entry[0] >> 8, (entry[0] & 0xff) << 2,
+ (entry[1] >> 8) << 2, (entry[1] & 0xff) << 2);
+ }
}
void Events::processEvent(Common::Event &ev) {
- switch (ev.type) {
- case Common::EVENT_KEYDOWN:
+ switch (ev.type) {
+ case Common::EVENT_KEYDOWN:
if (!_G(demo)) {
if (ev.kbd.keycode < 100)
- _G(key_flag)[ev.kbd.keycode] = true;
+ _G(key_flag[ev.kbd.keycode]) = true;
if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
msgKeypress(KeypressMessage(ev.kbd));
}
- break;
- case Common::EVENT_KEYUP:
- if (!_G(demo) && ev.kbd.keycode < 100)
- _G(key_flag)[ev.kbd.keycode] = false;
- break;
- case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ break;
+ case Common::EVENT_KEYUP:
+ if (!_G(demo) && ev.kbd.keycode < 100)
+ _G(key_flag[ev.kbd.keycode]) = false;
+ break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
if (!_G(demo)) {
- _G(key_flag)[actionToKeyFlag(ev.customType)] = true;
+ _G(key_flag[actionToKeyFlag(ev.customType)]) = true;
msgAction(ActionMessage(ev.customType));
} else if (ev.customType == KEYBIND_ESCAPE) {
// The Escape action will return to main menu from demo
_G(demo) = false;
send("TitleBackground", GameMessage("MAIN_MENU"));
}
- break;
- case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+ break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
if (!_G(demo))
- _G(key_flag)[actionToKeyFlag(ev.customType)] = false;
- break;
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_RBUTTONDOWN:
- case Common::EVENT_MBUTTONDOWN:
+ _G(key_flag[actionToKeyFlag(ev.customType)]) = false;
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_MBUTTONDOWN:
if (!_G(demo))
msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
- break;
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- case Common::EVENT_MBUTTONUP:
+ break;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ case Common::EVENT_MBUTTONUP:
if (!_G(demo))
msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
- break;
- case Common::EVENT_MOUSEMOVE:
+ break;
+ case Common::EVENT_MOUSEMOVE:
if (!_G(demo))
msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
- break;
- default:
- break;
- }
+ break;
+ default:
+ break;
+ }
}
void Events::processDemoEvent(byte ev) {
if (!ev)
return;
- bool flag = ev & 0x80;
- ev &= 0x7f;
-
- int action = -1;
- switch (ev) {
- case 72:
- ev = key_up;
- action = KEYBIND_UP;
- break;
- case 80:
- ev = key_down;
- break;
- case 75:
- ev = key_left;
- break;
- case 77:
- ev = key_right;
- break;
- case 56:
- ev = key_fire;
- action = KEYBIND_FIRE;
- break;
- case 29:
- ev = key_magic;
- action = KEYBIND_MAGIC;
- break;
+ bool flag = ev & 0x80;
+ ev &= 0x7f;
+
+ int action = -1;
+ switch (ev) {
+ case 72:
+ ev = key_up;
+ action = KEYBIND_UP;
+ break;
+ case 80:
+ ev = key_down;
+ break;
+ case 75:
+ ev = key_left;
+ break;
+ case 77:
+ ev = key_right;
+ break;
+ case 56:
+ ev = key_fire;
+ action = KEYBIND_FIRE;
+ break;
+ case 29:
+ ev = key_magic;
+ action = KEYBIND_MAGIC;
+ break;
case 39:
ev = key_select;
action = KEYBIND_SELECT;
break;
- default:
- break;
- }
+ default:
+ break;
+ }
- _G(key_flag)[ev] = flag;
+ _G(key_flag[ev]) = flag;
- if (flag && action != -1)
- msgAction(ActionMessage(action));
+ if (flag && action != -1)
+ msgAction(ActionMessage(action));
}
int Events::actionToKeyFlag(int action) const {
- return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE :
- (int)action;
+ return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE : (int)action;
}
void Events::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
- assert(ui);
- UIElement *priorView = focusedView();
+ assert(ui);
+ UIElement *priorView = focusedView();
- if (fadeOutIn)
- Gfx::fade_out();
+ if (fadeOutIn)
+ Gfx::fade_out();
- if (replaceAllViews) {
- clearViews();
+ if (replaceAllViews) {
+ clearViews();
- } else if (!_views.empty()) {
- priorView->msgUnfocus(UnfocusMessage());
- _views.pop();
- }
+ } else if (!_views.empty()) {
+ priorView->msgUnfocus(UnfocusMessage());
+ _views.pop();
+ }
- // Redraw any prior views to erase the removed view
- for (uint i = 0; i < _views.size(); ++i) {
- _views[i]->redraw();
- _views[i]->draw();
- }
+ // Redraw any prior views to erase the removed view
+ for (uint i = 0; i < _views.size(); ++i) {
+ _views[i]->redraw();
+ _views[i]->draw();
+ }
- // Add the new view
- _views.push(ui);
+ // Add the new view
+ _views.push(ui);
- ui->redraw();
- ui->msgFocus(FocusMessage(priorView));
- ui->draw();
+ ui->redraw();
+ ui->msgFocus(FocusMessage(priorView));
+ ui->draw();
- if (fadeOutIn)
- Gfx::fade_in();
+ if (fadeOutIn)
+ Gfx::fade_in();
}
void Events::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
- replaceView(findView(name), replaceAllViews, fadeOutIn);
+ replaceView(findView(name), replaceAllViews, fadeOutIn);
}
void Events::addView(UIElement *ui) {
- assert(ui);
- UIElement *priorView = focusedView();
+ assert(ui);
+ UIElement *priorView = focusedView();
- if (!_views.empty())
- priorView->msgUnfocus(UnfocusMessage());
+ if (!_views.empty())
+ priorView->msgUnfocus(UnfocusMessage());
- _views.push(ui);
- ui->redraw();
- ui->msgFocus(FocusMessage(priorView));
+ _views.push(ui);
+ ui->redraw();
+ ui->msgFocus(FocusMessage(priorView));
}
void Events::addView(const Common::String &name) {
- addView(findView(name));
+ addView(findView(name));
}
void Events::popView() {
- UIElement *priorView = focusedView();
- priorView->msgUnfocus(UnfocusMessage());
- _views.pop();
+ UIElement *priorView = focusedView();
+ priorView->msgUnfocus(UnfocusMessage());
+ _views.pop();
- for (uint i = 0; i < _views.size(); ++i) {
- _views[i]->redraw();
- _views[i]->draw();
- }
+ for (uint i = 0; i < _views.size(); ++i) {
+ _views[i]->redraw();
+ _views[i]->draw();
+ }
- if (!_views.empty()) {
- UIElement *view = focusedView();
- view->msgFocus(FocusMessage(priorView));
- view->redraw();
- view->draw();
- }
+ if (!_views.empty()) {
+ UIElement *view = focusedView();
+ view->msgFocus(FocusMessage(priorView));
+ view->redraw();
+ view->draw();
+ }
}
void Events::redrawViews() {
- for (uint i = 0; i < _views.size(); ++i) {
- _views[i]->redraw();
- _views[i]->draw();
- }
+ for (uint i = 0; i < _views.size(); ++i) {
+ _views[i]->redraw();
+ _views[i]->draw();
+ }
}
bool Events::isPresent(const Common::String &name) const {
- for (uint i = 0; i < _views.size(); ++i) {
- if (_views[i]->_name == name)
- return true;
- }
+ for (uint i = 0; i < _views.size(); ++i) {
+ if (_views[i]->_name == name)
+ return true;
+ }
- return false;
+ return false;
}
void Events::clearViews() {
- if (!_views.empty())
- focusedView()->msgUnfocus(UnfocusMessage());
+ if (!_views.empty())
+ focusedView()->msgUnfocus(UnfocusMessage());
- _views.clear();
+ _views.clear();
}
void Events::addKeypress(const Common::KeyCode kc) {
- Common::KeyState ks;
- ks.keycode = kc;
- if (kc >= Common::KEYCODE_SPACE && kc <= Common::KEYCODE_TILDE)
- ks.ascii = kc;
+ Common::KeyState ks;
+ ks.keycode = kc;
+ if (kc >= Common::KEYCODE_SPACE && kc <= Common::KEYCODE_TILDE)
+ ks.ascii = kc;
- focusedView()->msgKeypress(KeypressMessage(ks));
+ focusedView()->msgKeypress(KeypressMessage(ks));
}
/*------------------------------------------------------------------------*/
-Bounds::Bounds(Common::Rect &innerBounds) :
- _bounds(0, 0, 320, 240),
- _innerBounds(innerBounds),
- left(_bounds.left), top(_bounds.top),
- right(_bounds.right), bottom(_bounds.bottom) {
+Bounds::Bounds(Common::Rect &innerBounds) : _bounds(0, 0, 320, 240),
+ _innerBounds(innerBounds),
+ left(_bounds.left), top(_bounds.top),
+ right(_bounds.right), bottom(_bounds.bottom) {
}
Bounds &Bounds::operator=(const Common::Rect &r) {
- _bounds = r;
- _innerBounds = r;
- _innerBounds.grow(-_borderSize);
- return *this;
+ _bounds = r;
+ _innerBounds = r;
+ _innerBounds.grow(-_borderSize);
+ return *this;
}
void Bounds::setBorderSize(size_t borderSize) {
- _borderSize = borderSize;
- _innerBounds = *this;
- _innerBounds.grow(-_borderSize);
+ _borderSize = borderSize;
+ _innerBounds = *this;
+ _innerBounds.grow(-_borderSize);
}
/*------------------------------------------------------------------------*/
-UIElement::UIElement(const Common::String &name) :
- _name(name), _parent(g_engine), _bounds(_innerBounds) {
- g_engine->_children.push_back(this);
+UIElement::UIElement(const Common::String &name) : _name(name), _parent(g_engine), _bounds(_innerBounds) {
+ g_engine->_children.push_back(this);
}
-UIElement::UIElement(const Common::String &name, UIElement *uiParent) :
- _name(name), _parent(uiParent),
- _bounds(_innerBounds) {
- if (_parent)
- _parent->_children.push_back(this);
+UIElement::UIElement(const Common::String &name, UIElement *uiParent) : _name(name), _parent(uiParent),
+ _bounds(_innerBounds) {
+ if (_parent)
+ _parent->_children.push_back(this);
}
void UIElement::redraw() {
- _needsRedraw = true;
+ _needsRedraw = true;
- for (size_t i = 0; i < _children.size(); ++i)
- _children[i]->redraw();
+ for (size_t i = 0; i < _children.size(); ++i)
+ _children[i]->redraw();
}
void UIElement::drawElements() {
- if (_needsRedraw) {
- draw();
- _needsRedraw = false;
- }
+ if (_needsRedraw) {
+ draw();
+ _needsRedraw = false;
+ }
- for (size_t i = 0; i < _children.size(); ++i)
- _children[i]->drawElements();
+ for (size_t i = 0; i < _children.size(); ++i)
+ _children[i]->drawElements();
}
UIElement *UIElement::findViewGlobally(const Common::String &name) {
- return g_events->findView(name);
+ return g_events->findView(name);
}
void UIElement::focus() {
- g_events->replaceView(this);
+ g_events->replaceView(this);
}
void UIElement::close() {
- assert(g_events->focusedView() == this);
- g_events->popView();
+ assert(g_events->focusedView() == this);
+ g_events->popView();
}
bool UIElement::isFocused() const {
- return g_events->focusedView() == this;
+ return g_events->focusedView() == this;
}
void UIElement::clearSurface() {
- GfxSurface s = getSurface();
- s.fillRect(Common::Rect(s.w, s.h), 0);
+ GfxSurface s = getSurface();
+ s.fillRect(Common::Rect(s.w, s.h), 0);
}
void UIElement::draw() {
- for (size_t i = 0; i < _children.size(); ++i) {
- _children[i]->draw();
- }
+ for (size_t i = 0; i < _children.size(); ++i) {
+ _children[i]->draw();
+ }
}
bool UIElement::tick() {
- if (_timeoutCtr && --_timeoutCtr == 0) {
- timeout();
- }
+ if (_timeoutCtr && --_timeoutCtr == 0) {
+ timeout();
+ }
- for (size_t i = 0; i < _children.size(); ++i) {
- if (_children[i]->tick())
- return true;
- }
+ for (size_t i = 0; i < _children.size(); ++i) {
+ if (_children[i]->tick())
+ return true;
+ }
- return false;
+ return false;
}
UIElement *UIElement::findView(const Common::String &name) {
- if (_name.equalsIgnoreCase(name))
- return this;
+ if (_name.equalsIgnoreCase(name))
+ return this;
- for (size_t i = 0; i < _children.size(); ++i) {
+ for (size_t i = 0; i < _children.size(); ++i) {
UIElement *result = _children[i]->findView(name);
if (result != nullptr)
- return result;
- }
+ return result;
+ }
- return nullptr;
+ return nullptr;
}
void UIElement::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
- g_events->replaceView(ui, replaceAllViews, fadeOutIn);
+ g_events->replaceView(ui, replaceAllViews, fadeOutIn);
}
void UIElement::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
- g_events->replaceView(name, replaceAllViews, fadeOutIn);
+ g_events->replaceView(name, replaceAllViews, fadeOutIn);
}
void UIElement::addView(UIElement *ui) {
- g_events->addView(ui);
+ g_events->addView(ui);
}
void UIElement::addView(const Common::String &name) {
- g_events->addView(name);
+ g_events->addView(name);
}
void UIElement::addView() {
- g_events->addView(this);
+ g_events->addView(this);
}
GfxSurface UIElement::getSurface(bool innerBounds) const {
- return GfxSurface(*g_events->getScreen(),
- innerBounds ? _innerBounds : _bounds);
+ return GfxSurface(*g_events->getScreen(),
+ innerBounds ? _innerBounds : _bounds);
}
int UIElement::getRandomNumber(int minNumber, int maxNumber) {
- return g_engine->getRandomNumber(maxNumber - minNumber + 1) + minNumber;
+ return g_engine->getRandomNumber(maxNumber - minNumber + 1) + minNumber;
}
int UIElement::getRandomNumber(int maxNumber) {
- return g_engine->getRandomNumber(maxNumber);
+ return g_engine->getRandomNumber(maxNumber);
}
void UIElement::delaySeconds(uint seconds) {
- _timeoutCtr = seconds * FRAME_RATE;
+ _timeoutCtr = seconds * FRAME_RATE;
}
void UIElement::delayFrames(uint frames) {
- _timeoutCtr = frames;
+ _timeoutCtr = frames;
}
void UIElement::timeout() {
- redraw();
+ redraw();
}
} // namespace Got
diff --git a/engines/got/views/dialogs/ask.cpp b/engines/got/views/dialogs/ask.cpp
index 446ba956503..af53ea33c90 100644
--- a/engines/got/views/dialogs/ask.cpp
+++ b/engines/got/views/dialogs/ask.cpp
@@ -30,17 +30,17 @@ Ask::Ask() : SelectOption("Ask") {
}
void Ask::show(const Common::String &title, const Common::StringArray &options) {
- Ask *view = (Ask *)g_events->findView("Ask");
- view->setContent(title, options);
- view->addView();
+ Ask *view = (Ask *)g_events->findView("Ask");
+ view->setContent(title, options);
+ view->addView();
}
void Ask::closed() {
- _G(scripts).setAskResponse(0);
+ _G(scripts).setAskResponse(0);
}
void Ask::selected() {
- _G(scripts).setAskResponse(_selectedItem + 1);
+ _G(scripts).setAskResponse(_selectedItem + 1);
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/ask.h b/engines/got/views/dialogs/ask.h
index 6dfb994418d..cf7401c8d6a 100644
--- a/engines/got/views/dialogs/ask.h
+++ b/engines/got/views/dialogs/ask.h
@@ -30,13 +30,12 @@ namespace Dialogs {
class Ask : public SelectOption {
public:
- Ask();
- virtual ~Ask() {}
+ Ask();
+ virtual ~Ask() {}
- static void show(const Common::String &title,
- const Common::StringArray &options);
- void closed() override;
- void selected() override;
+ static void show(const Common::String &title, const Common::StringArray &options);
+ void closed() override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index b9d79ba3dea..0789808e5a3 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -27,34 +27,34 @@ namespace Views {
namespace Dialogs {
Dialog::Dialog(const Common::String &name) : View(name) {
- _bounds.setBorderSize(16);
+ _bounds.setBorderSize(16);
}
void Dialog::draw() {
- // Clear the inner content first
- GfxSurface s = getSurface(true);
- s.clear(215);
-
- s = getSurface();
- assert((s.w % 16) == 0 && (s.h % 16) == 0);
-
- // Draw four corners
- s.simpleBlitFrom(_G(bgPics)[192], Common::Point(0, 0));
- s.simpleBlitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
- s.simpleBlitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
- s.simpleBlitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
-
- // Draw top/bottom horizontal lines
- for (int x = 16; x < _bounds.width() - 16; x += 16) {
- s.simpleBlitFrom(_G(bgPics)[196], Common::Point(x, 0));
- s.simpleBlitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
- }
-
- // Draw left/right vertical lines
- for (int y = 16; y < _bounds.height() - 16; y += 16) {
- s.simpleBlitFrom(_G(bgPics)[198], Common::Point(0, y));
- s.simpleBlitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
- }
+ // Clear the inner content first
+ GfxSurface s = getSurface(true);
+ s.clear(215);
+
+ s = getSurface();
+ assert((s.w % 16) == 0 && (s.h % 16) == 0);
+
+ // Draw four corners
+ s.simpleBlitFrom(_G(bgPics[192]), Common::Point(0, 0));
+ s.simpleBlitFrom(_G(bgPics[193]), Common::Point(_bounds.width() - 16, 0));
+ s.simpleBlitFrom(_G(bgPics[194]), Common::Point(0, _bounds.height() - 16));
+ s.simpleBlitFrom(_G(bgPics[195]), Common::Point(_bounds.width() - 16, _bounds.height() - 16));
+
+ // Draw top/bottom horizontal lines
+ for (int x = 16; x < _bounds.width() - 16; x += 16) {
+ s.simpleBlitFrom(_G(bgPics[196]), Common::Point(x, 0));
+ s.simpleBlitFrom(_G(bgPics[197]), Common::Point(x, _bounds.height() - 16));
+ }
+
+ // Draw left/right vertical lines
+ for (int y = 16; y < _bounds.height() - 16; y += 16) {
+ s.simpleBlitFrom(_G(bgPics[198]), Common::Point(0, y));
+ s.simpleBlitFrom(_G(bgPics[199]), Common::Point(_bounds.width() - 16, y));
+ }
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index e876a32d6d9..9cd562de363 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -22,7 +22,6 @@
#ifndef GOT_VIEWS_DIALOGS_DIALOG_H
#define GOT_VIEWS_DIALOGS_DIALOG_H
-#include "graphics/managed_surface.h"
#include "got/views/view.h"
namespace Got {
@@ -31,10 +30,10 @@ namespace Dialogs {
class Dialog : public View {
public:
- Dialog(const Common::String &name);
- virtual ~Dialog() {}
+ Dialog(const Common::String &name);
+ virtual ~Dialog() {}
- void draw() override;
+ void draw() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/high_scores.cpp b/engines/got/views/dialogs/high_scores.cpp
index 3c7a3ca1d21..d0f45062999 100644
--- a/engines/got/views/dialogs/high_scores.cpp
+++ b/engines/got/views/dialogs/high_scores.cpp
@@ -29,110 +29,108 @@ namespace Dialogs {
#define TIMEOUT 500
HighScores::HighScores() : Dialog("HighScores") {
- setBounds(Common::Rect(0, 0 + 24, 320, 192 + 24));
+ setBounds(Common::Rect(0, 0 + 24, 320, 192 + 24));
}
void HighScores::draw() {
- // Draw background outside dialog
- GfxSurface s = GfxSurface(*g_events->getScreen(),
- Common::Rect(0, 0, 320, 240));
-
- for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
- for (int yp = 0; yp < 240; yp += 32)
- s.simpleBlitFrom(_G(gfx)[26], Common::Point(xp, yp));
- }
-
- // Draw the dialog frame
- Dialog::draw();
-
- // Clear the inner content first
- s = getSurface(true);
- s.clear(215);
-
- // Draw title
- Common::String title = "High Scores - Part I";
- for (int area = 2; area <= _currentArea; ++area)
- title += 'I';
-
- int titleStart = (s.w - title.size() * 8) / 2;
- s.print(Common::Point(titleStart, 4), title, 54);
-
- for (int i = 0; i < 7; ++i) {
- const HighScore &hs = _G(highScores)._scores[_currentArea - 1][i];
-
- // Draw frames for name and score
- s.frameRect(Common::Rect(10, 20 + i * 18, 210, 20 + i * 18 + 16),
- 206);
- s.frameRect(Common::Rect(220, 20 + i * 18, 280, 20 + i * 18 + 16),
- 206);
-
- // Write out the name and scores
- s.print(Common::Point(15, 24 + i * 18), hs._name, 14);
- Common::String score = Common::String::format("%d", hs._total);
- s.print(Common::Point(275 - (score.size() * 8), 24 + i * 18), score, 14);
- }
+ // Draw background outside dialog
+ GfxSurface s = GfxSurface(*g_events->getScreen(), Common::Rect(0, 0, 320, 240));
+
+ for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+ for (int yp = 0; yp < 240; yp += 32)
+ s.simpleBlitFrom(_G(gfx[26]), Common::Point(xp, yp));
+ }
+
+ // Draw the dialog frame
+ Dialog::draw();
+
+ // Clear the inner content first
+ s = getSurface(true);
+ s.clear(215);
+
+ // Draw title
+ Common::String title = "High Scores - Part I";
+ for (int area = 2; area <= _currentArea; ++area)
+ title += 'I';
+
+ int titleStart = (s.w - title.size() * 8) / 2;
+ s.print(Common::Point(titleStart, 4), title, 54);
+
+ for (int i = 0; i < 7; ++i) {
+ const HighScore &hs = _G(highScores)._scores[_currentArea - 1][i];
+
+ // Draw frames for name and score
+ s.frameRect(Common::Rect(10, 20 + i * 18, 210, 20 + i * 18 + 16),
+ 206);
+ s.frameRect(Common::Rect(220, 20 + i * 18, 280, 20 + i * 18 + 16),
+ 206);
+
+ // Write out the name and scores
+ s.print(Common::Point(15, 24 + i * 18), hs._name, 14);
+ Common::String score = Common::String::format("%d", hs._total);
+ s.print(Common::Point(275 - (score.size() * 8), 24 + i * 18), score, 14);
+ }
}
bool HighScores::msgFocus(const FocusMessage &msg) {
- _currentArea = 1;
- _showAll = true;
- _timeoutCtr = TIMEOUT;
+ _currentArea = 1;
+ _showAll = true;
+ _timeoutCtr = TIMEOUT;
- Gfx::load_palette();
- return true;
+ Gfx::load_palette();
+ return true;
}
bool HighScores::msgGame(const GameMessage &msg) {
- if (msg._name == "HIGH_SCORES") {
- // Finished one of the parts of the game, so just
- // set the view to show only scores for that area
- replaceView("HighScores", true);
- _currentArea = msg._value;
- _showAll = false;
+ if (msg._name == "HIGH_SCORES") {
+ // Finished one of the parts of the game, so just
+ // set the view to show only scores for that area
+ replaceView("HighScores", true);
+ _currentArea = msg._value;
+ _showAll = false;
- draw();
- fadeIn();
+ draw();
+ fadeIn();
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
bool HighScores::msgAction(const ActionMessage &msg) {
- if (msg._action == KEYBIND_ESCAPE) {
- goToMainMenu();
- } else {
- goToNextArea();
-
- }
- return true;
+ if (msg._action == KEYBIND_ESCAPE) {
+ goToMainMenu();
+ } else {
+ goToNextArea();
+ }
+ return true;
}
void HighScores::goToMainMenu() {
- fadeOut();
- send("TitleBackground", GameMessage("MAIN_MENU"));
+ fadeOut();
+ send("TitleBackground", GameMessage("MAIN_MENU"));
}
void HighScores::goToNextArea() {
- if (_showAll && _currentArea < 3) {
- fadeOut();
- ++_currentArea;
- draw();
- fadeIn();
- _timeoutCtr = TIMEOUT;
-
- } else {
- // Done all the areas, so
- goToMainMenu();
- }
+ if (_showAll && _currentArea < 3) {
+ fadeOut();
+ ++_currentArea;
+ draw();
+ fadeIn();
+ _timeoutCtr = TIMEOUT;
+
+ } else {
+ // Done all the areas, so
+ goToMainMenu();
+ }
}
bool HighScores::tick() {
- if (--_timeoutCtr < 0)
- goToNextArea();
+ if (--_timeoutCtr < 0)
+ goToNextArea();
- return true;
+ return true;
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/high_scores.h b/engines/got/views/dialogs/high_scores.h
index e1318929c5b..a6030af38a9 100644
--- a/engines/got/views/dialogs/high_scores.h
+++ b/engines/got/views/dialogs/high_scores.h
@@ -22,7 +22,6 @@
#ifndef GOT_VIEWS_DIALOGS_HIGH_SCORES_H
#define GOT_VIEWS_DIALOGS_HIGH_SCORES_H
-#include "graphics/managed_surface.h"
#include "got/views/dialogs/dialog.h"
namespace Got {
@@ -31,23 +30,23 @@ namespace Dialogs {
class HighScores : public Dialog {
private:
- int _currentArea = 0;
- bool _showAll = false;
- int _timeoutCtr = 0;
+ int _currentArea = 0;
+ bool _showAll = false;
+ int _timeoutCtr = 0;
- void goToMainMenu();
- void goToNextArea();
+ void goToMainMenu();
+ void goToNextArea();
public:
- HighScores();
- virtual ~HighScores() {
- }
-
- void draw() override;
- bool msgFocus(const FocusMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
- bool msgGame(const GameMessage &msg) override;
- bool tick() override;
+ HighScores();
+ virtual ~HighScores() {
+ }
+
+ void draw() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+ bool msgGame(const GameMessage &msg) override;
+ bool tick() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index 741354cd18c..f6f07b79b09 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -27,48 +27,44 @@ namespace Got {
namespace Views {
namespace Dialogs {
-static const char *OPTIONS[] = {
- "Play Game", "Load Game", "High Scores", "Credits", "Demo", "Quit", nullptr
-};
-static const char *OPTIONS_NO_DEMO[] = {
- "Play Game", "Load Game", "High Scores", "Credits", "Quit", nullptr
-};
+static const char *OPTIONS[] = {"Play Game", "Load Game", "High Scores", "Credits", "Demo", "Quit", nullptr};
+static const char *OPTIONS_NO_DEMO[] = {"Play Game", "Load Game", "High Scores", "Credits", "Quit", nullptr};
MainMenu::MainMenu() : SelectOption("MainMenu", "God of Thunder Menu",
- gDebugLevel > 0 ? OPTIONS : OPTIONS_NO_DEMO) {
+ gDebugLevel > 0 ? OPTIONS : OPTIONS_NO_DEMO) {
}
bool MainMenu::msgFocus(const FocusMessage &msg) {
- g_vars->resetEndgameFlags();
- return SelectOption::msgFocus(msg);
+ g_vars->resetEndgameFlags();
+ return SelectOption::msgFocus(msg);
}
void MainMenu::closed() {
- _selectedItem = 4; // Quit game
- selected();
+ _selectedItem = 4; // Quit game
+ selected();
}
void MainMenu::selected() {
- switch (_selectedItem) {
- case 0:
- _G(demo) = false;
- addView("SelectGame");
- break;
+ switch (_selectedItem) {
+ case 0:
+ _G(demo) = false;
+ addView("SelectGame");
+ break;
- case 1:
- if (!g_engine->loadGameDialog())
- addView("SelectGame");
- break;
+ case 1:
+ if (!g_engine->loadGameDialog())
+ addView("SelectGame");
+ break;
- case 2:
- replaceView("HighScores", true, true);
- break;
+ case 2:
+ replaceView("HighScores", true, true);
+ break;
- case 3:
- addView("Credits");
- break;
+ case 3:
+ addView("Credits");
+ break;
- case 4:
+ case 4:
if (gDebugLevel > 0) {
_G(demo) = true;
initialize_game();
@@ -76,15 +72,15 @@ void MainMenu::selected() {
} else {
addView("Quit");
}
- break;
+ break;
- case 5:
- addView("Quit");
- break;
+ case 5:
+ addView("Quit");
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/main_menu.h b/engines/got/views/dialogs/main_menu.h
index c8d06a87e11..0ecc6078928 100644
--- a/engines/got/views/dialogs/main_menu.h
+++ b/engines/got/views/dialogs/main_menu.h
@@ -30,13 +30,12 @@ namespace Dialogs {
class MainMenu : public SelectOption {
public:
- MainMenu();
- virtual ~MainMenu() {
- }
+ MainMenu();
+ virtual ~MainMenu() {}
- bool msgFocus(const FocusMessage &msg) override;
- void closed() override;
- void selected() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ void closed() override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index 1ab7e9ca45c..7432da37735 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -21,52 +21,47 @@
#include "got/views/dialogs/options_menu.h"
#include "got/game/back.h"
-#include "got/gfx/palette.h"
-#include "got/utils/file.h"
#include "got/vars.h"
namespace Got {
namespace Views {
namespace Dialogs {
-static const char *OPTIONS[] = {
- "Sound/Music", "Skill Level", "Save Game", "Load Game",
- "Die", "Turbo Mode", "Help", "Quit", nullptr
-};
+static const char *OPTIONS[] = {"Sound/Music", "Skill Level", "Save Game", "Load Game", "Die", "Turbo Mode", "Help", "Quit", nullptr};
OptionsMenu::OptionsMenu() : SelectOption("OptionsMenu", "Options Menu", OPTIONS) {
}
void OptionsMenu::selected() {
- switch (_selectedItem) {
- case 0:
- addView("SetSound");
- break;
- case 1:
- // skill level
- break;
- case 2:
- g_engine->saveGameDialog();
- break;
- case 3:
- g_engine->loadGameDialog();
- break;
- case 4:
- g_events->send(GameMessage("THOR_DIES"));
- break;
- case 5:
- addView("SelectSlow");
- break;
- case 6:
- // Help
- odin_speaks(2008, -1);
- break;
- case 7:
- addView("QuitGame");
- break;
- default:
- break;
- }
+ switch (_selectedItem) {
+ case 0:
+ addView("SetSound");
+ break;
+ case 1:
+ // skill level
+ break;
+ case 2:
+ g_engine->saveGameDialog();
+ break;
+ case 3:
+ g_engine->loadGameDialog();
+ break;
+ case 4:
+ g_events->send(GameMessage("THOR_DIES"));
+ break;
+ case 5:
+ addView("SelectSlow");
+ break;
+ case 6:
+ // Help
+ odin_speaks(2008, -1);
+ break;
+ case 7:
+ addView("QuitGame");
+ break;
+ default:
+ break;
+ }
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/options_menu.h b/engines/got/views/dialogs/options_menu.h
index b8d40cf8974..b7f782ce3ac 100644
--- a/engines/got/views/dialogs/options_menu.h
+++ b/engines/got/views/dialogs/options_menu.h
@@ -30,11 +30,10 @@ namespace Dialogs {
class OptionsMenu : public SelectOption {
public:
- OptionsMenu();
- virtual ~OptionsMenu() {
- }
+ OptionsMenu();
+ virtual ~OptionsMenu() {}
- void selected() override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/quit.cpp b/engines/got/views/dialogs/quit.cpp
index c324e3c846e..6888cbd83e4 100644
--- a/engines/got/views/dialogs/quit.cpp
+++ b/engines/got/views/dialogs/quit.cpp
@@ -30,20 +30,20 @@ Quit::Quit() : SelectOption("Quit", "Quit Game?", YES_NO) {
}
void Quit::selected() {
- switch (_selectedItem) {
- case 0:
- g_engine->quitGame();
- break;
- case 1:
- addView("MainMenu");
- break;
- default:
- break;
- }
+ switch (_selectedItem) {
+ case 0:
+ g_engine->quitGame();
+ break;
+ case 1:
+ addView("MainMenu");
+ break;
+ default:
+ break;
+ }
}
void Quit::closed() {
- addView("MainMenu");
+ addView("MainMenu");
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/quit.h b/engines/got/views/dialogs/quit.h
index 68771b50e7e..56332fbe884 100644
--- a/engines/got/views/dialogs/quit.h
+++ b/engines/got/views/dialogs/quit.h
@@ -30,12 +30,11 @@ namespace Dialogs {
class Quit : public SelectOption {
public:
- Quit();
- virtual ~Quit() {
- }
+ Quit();
+ virtual ~Quit() {}
- void selected() override;
- void closed() override;
+ void selected() override;
+ void closed() override;
};
} // namespace Dialogs
Commit: b8fe361e47606568674dfc63ca4ff48c01539e7b
https://github.com/scummvm/scummvm/commit/b8fe361e47606568674dfc63ca4ff48c01539e7b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT: Fix handling of slow_mode and _setup.speed
Changed paths:
engines/got/got.cpp
engines/got/vars.cpp
engines/got/views/dialogs/select_slow.cpp
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index b59a23d4190..d974531854a 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -65,7 +65,7 @@ Common::String GotEngine::getGameId() const {
}
Common::Error GotEngine::run() {
- // Initialize 320x240 palleted graphics mode. Note that the original
+ // Initialize 320x240 paletted graphics mode. Note that the original
// main menu/dialogs ran at 320x200, but the game ran at 320x240.
initGraphics(320, 240);
@@ -162,10 +162,8 @@ void GotEngine::savegameLoaded() {
_G(setup).dig_sound = 0;
if (_G(setup).music == 1) {
if (GAME1 == 1 && _G(current_area) == 59) {
-// if (flag)
music_play(5, true);
} else {
- //if (flag)
music_play(_G(level_type), true);
}
} else {
@@ -175,7 +173,7 @@ void GotEngine::savegameLoaded() {
}
_G(game_over) = _G(setup).game_over != 0;
- _G(slow_mode) = _G(setup).speed;
+ _G(slow_mode) = _G(setup).speed != 0;
g_events->replaceView("Game", true);
setup_load();
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index bafd80971d3..a8858454a79 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -67,7 +67,7 @@ void Vars::load() {
if (_sound_flag)
_setup.pc_sound = false;
_setup.scroll_flag = true;
- _setup.speed = _slow_mode;
+ _setup.speed = _slow_mode ? 1 : 0;
_setup.skill = 1;
_tmp_buff = new byte[TMP_SIZE];
diff --git a/engines/got/views/dialogs/select_slow.cpp b/engines/got/views/dialogs/select_slow.cpp
index 2f4a35bd02b..83d63229053 100644
--- a/engines/got/views/dialogs/select_slow.cpp
+++ b/engines/got/views/dialogs/select_slow.cpp
@@ -26,11 +26,7 @@ namespace Got {
namespace Views {
namespace Dialogs {
-static const char *OPTIONS[] = {
- "On (slow computer)",
- "Off (fast computer)",
- nullptr
-};
+static const char *OPTIONS[] = { "On (slow computer)", "Off (fast computer)", nullptr };
SelectSlow::SelectSlow() : SelectOption("SelectSlow", "Fast Mode", OPTIONS) {
}
@@ -38,10 +34,10 @@ SelectSlow::SelectSlow() : SelectOption("SelectSlow", "Fast Mode", OPTIONS) {
void SelectSlow::selected() {
switch (_selectedItem) {
case 0:
- _G(slow_mode) = 1;
+ _G(slow_mode) = true;
break;
case 1:
- _G(slow_mode) = 0;
+ _G(slow_mode) = false;
break;
default:
break;
Commit: a61f1bedf8ed5568ccd7b7017ff3db70ca8147de
https://github.com/scummvm/scummvm/commit/a61f1bedf8ed5568ccd7b7017ff3db70ca8147de
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT: More code formatting in dialogs
Changed paths:
engines/got/views/dialogs/quit_game.cpp
engines/got/views/dialogs/quit_game.h
engines/got/views/dialogs/save_game.cpp
engines/got/views/dialogs/save_game.h
engines/got/views/dialogs/say.cpp
engines/got/views/dialogs/say.h
engines/got/views/dialogs/select_game.cpp
engines/got/views/dialogs/select_game.h
engines/got/views/dialogs/select_item.cpp
engines/got/views/dialogs/select_item.h
engines/got/views/dialogs/select_option.cpp
engines/got/views/dialogs/select_option.h
engines/got/views/dialogs/select_scroll.cpp
engines/got/views/dialogs/select_scroll.h
engines/got/views/dialogs/select_slow.cpp
engines/got/views/dialogs/select_slow.h
engines/got/views/dialogs/set_music.cpp
engines/got/views/dialogs/set_music.h
engines/got/views/dialogs/set_sound.cpp
engines/got/views/dialogs/set_sound.h
diff --git a/engines/got/views/dialogs/quit_game.cpp b/engines/got/views/dialogs/quit_game.cpp
index 1844c483d71..eeea7bd2426 100644
--- a/engines/got/views/dialogs/quit_game.cpp
+++ b/engines/got/views/dialogs/quit_game.cpp
@@ -26,28 +26,26 @@ namespace Got {
namespace Views {
namespace Dialogs {
-static const char *OPTIONS[] = {
- "Continue Game", "Quit to Opening Screen", "Quit to DOS", nullptr
-};
+static const char *OPTIONS[] = { "Continue Game", "Quit to Opening Screen", "Quit to DOS", nullptr };
QuitGame::QuitGame() : SelectOption("QuitGame", "Quit Game?", OPTIONS) {
}
void QuitGame::selected() {
- switch (_selectedItem) {
- case 0:
- break;
- case 1:
- // Prompt for saving game before returning to title
- send("SaveGame", GameMessage("TITLE"));
- break;
- case 2:
- // Prompt for saving game before quitting
- send("SaveGame", GameMessage("QUIT"));
- break;
- default:
- break;
- }
+ switch (_selectedItem) {
+ case 0:
+ break;
+ case 1:
+ // Prompt for saving game before returning to title
+ send("SaveGame", GameMessage("TITLE"));
+ break;
+ case 2:
+ // Prompt for saving game before quitting
+ send("SaveGame", GameMessage("QUIT"));
+ break;
+ default:
+ break;
+ }
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/quit_game.h b/engines/got/views/dialogs/quit_game.h
index a1ac726e4ee..752824d5f0e 100644
--- a/engines/got/views/dialogs/quit_game.h
+++ b/engines/got/views/dialogs/quit_game.h
@@ -30,11 +30,10 @@ namespace Dialogs {
class QuitGame : public SelectOption {
public:
- QuitGame();
- virtual ~QuitGame() {
- }
+ QuitGame();
+ virtual ~QuitGame() {}
- void selected() override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/save_game.cpp b/engines/got/views/dialogs/save_game.cpp
index ff4dc8d10eb..a88e32b96c0 100644
--- a/engines/got/views/dialogs/save_game.cpp
+++ b/engines/got/views/dialogs/save_game.cpp
@@ -30,25 +30,25 @@ SaveGame::SaveGame() : SelectOption("SaveGame", "Save Game?", YES_NO) {
}
bool SaveGame::msgGame(const GameMessage &msg) {
- if (msg._name == "TITLE" || msg._name == "QUIT") {
- _isQuit = msg._name == "QUIT";
- open();
- return true;
- }
+ if (msg._name == "TITLE" || msg._name == "QUIT") {
+ _isQuit = msg._name == "QUIT";
+ open();
+ return true;
+ }
- return false;
+ return false;
}
void SaveGame::selected() {
- if (_selectedItem == 0)
- g_engine->saveGameDialog();
-
- if (_isQuit) {
- g_engine->quitGame();
- } else {
- fadeOut();
- send("TitleBackground", GameMessage("MAIN_MENU"));
- }
+ if (_selectedItem == 0)
+ g_engine->saveGameDialog();
+
+ if (_isQuit) {
+ g_engine->quitGame();
+ } else {
+ fadeOut();
+ send("TitleBackground", GameMessage("MAIN_MENU"));
+ }
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/save_game.h b/engines/got/views/dialogs/save_game.h
index 8f0cf5ebd06..687fdc57414 100644
--- a/engines/got/views/dialogs/save_game.h
+++ b/engines/got/views/dialogs/save_game.h
@@ -30,15 +30,15 @@ namespace Dialogs {
class SaveGame : public SelectOption {
private:
- bool _isQuit = false;
+ bool _isQuit = false;
public:
- SaveGame();
- virtual ~SaveGame() {
- }
+ SaveGame();
+ virtual ~SaveGame() {
+ }
- bool msgGame(const GameMessage &msg) override;
- void selected() override;
+ bool msgGame(const GameMessage &msg) override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index 0a2b74f72d8..c7de7476c3f 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -27,165 +27,163 @@ namespace Views {
namespace Dialogs {
Say::Say() : Dialog("Say") {
- setBounds(Common::Rect(32, 48, 288, 160));
+ setBounds(Common::Rect(32, 48, 288, 160));
}
void Say::show(int item, const Gfx::Pics &speakerIcon, int type) {
- Say *view = (Say *)g_events->findView("Say");
- view->_item = item;
- view->_speakerIcon = speakerIcon;
- view->_type = type;
- view->addView();
+ Say *view = (Say *)g_events->findView("Say");
+ view->_item = item;
+ view->_speakerIcon = speakerIcon;
+ view->_type = type;
+ view->addView();
}
bool Say::msgFocus(const FocusMessage &msg) {
- if (!_type)
- play_sound(WOOP, 1);
+ if (!_type)
+ play_sound(WOOP, 1);
- _content = (const char *)_G(tmp_buff);
- _contentLength = 0;
- _waitForResponse = WAIT_NONE;
- _woopCtr = 0;
- _picIndex = 0;
+ _content = (const char *)_G(tmp_buff);
+ _contentLength = 0;
+ _waitForResponse = WAIT_NONE;
+ _woopCtr = 0;
+ _picIndex = 0;
- return true;
+ return true;
}
bool Say::msgUnfocus(const UnfocusMessage &msg) {
- // Since the Ask dialog is shown by scripts, closing the view
- // starts the calling script running again
- _G(scripts).resume();
- return true;
+ // Since the Ask dialog is shown by scripts, closing the view
+ // starts the calling script running again
+ _G(scripts).resume();
+ return true;
}
void Say::draw() {
- Dialog::draw();
- GfxSurface s = getSurface();
-
- if (_item)
- s.simpleBlitFrom(_G(objects)[_item], Common::Point(160, 17));
-
- const char *p = _content;
- const char *endP = _content + _contentLength;
- int color = 14;
- int x = 20, lc = 0;
- int ch;
-
- while (p < endP) {
- if (*p == '~' && Common::isXDigit(*(p + 1))) {
- p++;
- ch = *p;
- p++;
- if (Common::isDigit(ch))
- ch -= '0';
- else
- ch = toupper(ch) - 'A' + 10;
-
- color = Gfx::DIALOG_COLOR[ch];
- continue;
- }
-
- if (*p == '\n') {
- x = 20;
- lc++;
- if (lc > 4) {
- // Got a full text to display
- if (_waitForResponse == WAIT_NONE)
- _waitForResponse = WAIT_MORE;
- _picIndex = 1;
- break;
- }
-
- p++;
- continue;
- }
-
- s.printChar(*p, x, 35 + (lc * 10), color);
-
- p++;
- x += 8;
- }
-
- s.simpleBlitFrom(_speakerIcon[_picIndex], Common::Point(120, 17));
-
- if (_waitForResponse == WAIT_MORE)
- s.print(Common::Point(184, 86), "More...", 15);
+ Dialog::draw();
+ GfxSurface s = getSurface();
+
+ if (_item)
+ s.simpleBlitFrom(_G(objects)[_item], Common::Point(160, 17));
+
+ const char *p = _content;
+ const char *endP = _content + _contentLength;
+ int color = 14;
+ int x = 20, lc = 0;
+
+ while (p < endP) {
+ if (*p == '~' && Common::isXDigit(*(p + 1))) {
+ p++;
+ int ch = *p;
+ p++;
+ if (Common::isDigit(ch))
+ ch -= '0';
+ else
+ ch = toupper(ch) - 'A' + 10;
+
+ color = Gfx::DIALOG_COLOR[ch];
+ continue;
+ }
+
+ if (*p == '\n') {
+ x = 20;
+ lc++;
+ if (lc > 4) {
+ // Got a full text to display
+ if (_waitForResponse == WAIT_NONE)
+ _waitForResponse = WAIT_MORE;
+ _picIndex = 1;
+ break;
+ }
+
+ p++;
+ continue;
+ }
+
+ s.printChar(*p, x, 35 + (lc * 10), color);
+
+ p++;
+ x += 8;
+ }
+
+ s.simpleBlitFrom(_speakerIcon[_picIndex], Common::Point(120, 17));
+
+ if (_waitForResponse == WAIT_MORE)
+ s.print(Common::Point(184, 86), "More...", 15);
}
bool Say::msgKeypress(const KeypressMessage &msg) {
- if (_waitForResponse == WAIT_DONE) {
- close();
- } else if (_waitForResponse == WAIT_MORE) {
- _waitForResponse = WAIT_NONE;
- _content = _content + _contentLength;
- _contentLength = 0;
- redraw();
- } else {
- showEntirePage();
- redraw();
- }
-
- return false;
+ if (_waitForResponse == WAIT_DONE) {
+ close();
+ } else if (_waitForResponse == WAIT_MORE) {
+ _waitForResponse = WAIT_NONE;
+ _content = _content + _contentLength;
+ _contentLength = 0;
+ redraw();
+ } else {
+ showEntirePage();
+ redraw();
+ }
+
+ return false;
}
bool Say::msgAction(const ActionMessage &msg) {
- if (msg._action == KEYBIND_ESCAPE || _waitForResponse == WAIT_DONE) {
- close();
- } else if (_waitForResponse == WAIT_MORE) {
- _waitForResponse = WAIT_NONE;
- _content = _content + _contentLength;
- _contentLength = 0;
- redraw();
- } else {
- showEntirePage();
- redraw();
- }
-
- return true;
+ if (msg._action == KEYBIND_ESCAPE || _waitForResponse == WAIT_DONE) {
+ close();
+ } else if (_waitForResponse == WAIT_MORE) {
+ _waitForResponse = WAIT_NONE;
+ _content = _content + _contentLength;
+ _contentLength = 0;
+ redraw();
+ } else {
+ showEntirePage();
+ redraw();
+ }
+
+ return true;
}
bool Say::tick() {
- if (_waitForResponse == WAIT_NONE && ++_contentCtr > 1) {
- _contentCtr = 0;
- const char *contentEnd = _content + ++_contentLength;
-
- if (*(contentEnd - 1) == '~' && Common::isXDigit(*contentEnd))
- ++_contentLength;
-
- if (!*contentEnd) {
- // Reached end of text to display
- _waitForResponse = WAIT_DONE;
- _picIndex = 1;
- } else if (++_picIndex > 3) {
- _picIndex = 0;
- }
-
- if (_type) {
- play_sound(WOOP, 1);
- _woopCtr = 0;
- }
-
- redraw();
- }
-
- return true;
+ if (_waitForResponse == WAIT_NONE && ++_contentCtr > 1) {
+ _contentCtr = 0;
+ const char *contentEnd = _content + ++_contentLength;
+
+ if (*(contentEnd - 1) == '~' && Common::isXDigit(*contentEnd))
+ ++_contentLength;
+
+ if (!*contentEnd) {
+ // Reached end of text to display
+ _waitForResponse = WAIT_DONE;
+ _picIndex = 1;
+ } else if (++_picIndex > 3) {
+ _picIndex = 0;
+ }
+
+ if (_type) {
+ play_sound(WOOP, 1);
+ _woopCtr = 0;
+ }
+
+ redraw();
+ }
+
+ return true;
}
void Say::showEntirePage() {
- int lc = 0;
- char c;
-
- for (_contentLength = 0; (c = *(_content + _contentLength)) != 0; ++_contentLength) {
- if (c == '~' && Common::isXDigit(*(_content + _contentLength + 1)))
- ++_contentLength;
- else if (c == '\n') {
- if (++lc > 4)
- break;
- }
- }
+ int lc = 0;
+ char c;
+
+ for (_contentLength = 0; (c = *(_content + _contentLength)) != 0; ++_contentLength) {
+ if (c == '~' && Common::isXDigit(*(_content + _contentLength + 1)))
+ ++_contentLength;
+ else if (c == '\n') {
+ if (++lc > 4)
+ break;
+ }
+ }
}
-
} // namespace Dialogs
} // namespace Views
} // namespace Got
diff --git a/engines/got/views/dialogs/say.h b/engines/got/views/dialogs/say.h
index 0156664fba5..a7a100cecff 100644
--- a/engines/got/views/dialogs/say.h
+++ b/engines/got/views/dialogs/say.h
@@ -22,45 +22,48 @@
#ifndef GOT_VIEWS_DIALOGS_SAY_H
#define GOT_VIEWS_DIALOGS_SAY_H
-#include "got/views/dialogs/dialog.h"
#include "got/gfx/gfx_pics.h"
+#include "got/views/dialogs/dialog.h"
namespace Got {
namespace Views {
namespace Dialogs {
class Say : public Dialog {
- enum WaitResponse {
- WAIT_NONE, WAIT_MORE, WAIT_DONE
- };
+ enum WaitResponse {
+ WAIT_NONE,
+ WAIT_MORE,
+ WAIT_DONE
+ };
+
private:
- Gfx::Pics _speakerIcon;
- int _item = 0;
- int _type = 0;
- int _picIndex = 0;
- const char *_content = nullptr;
- int _contentLength = 0;
- int _woopCtr = 0;
- int _contentCtr = 0;
- WaitResponse _waitForResponse = WAIT_NONE;
+ Gfx::Pics _speakerIcon;
+ int _item = 0;
+ int _type = 0;
+ int _picIndex = 0;
+ const char *_content = nullptr;
+ int _contentLength = 0;
+ int _woopCtr = 0;
+ int _contentCtr = 0;
+ WaitResponse _waitForResponse = WAIT_NONE;
- /**
+ /**
* Advance to showing the entirety of the current page
*/
- void showEntirePage();
+ void showEntirePage();
public:
- Say();
- virtual ~Say() {}
+ Say();
+ virtual ~Say() {}
- static void show(int item, const Gfx::Pics &speakerIcon, int type);
+ static void show(int item, const Gfx::Pics &speakerIcon, int type);
- void draw() override;
- bool msgFocus(const FocusMessage &msg) override;
- bool msgUnfocus(const UnfocusMessage &msg) override;
- bool msgKeypress(const KeypressMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
- bool tick() override;
+ void draw() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgUnfocus(const UnfocusMessage &msg) override;
+ bool msgKeypress(const KeypressMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+ bool tick() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_game.cpp b/engines/got/views/dialogs/select_game.cpp
index c9cc5a955cb..a1e63a54e8c 100644
--- a/engines/got/views/dialogs/select_game.cpp
+++ b/engines/got/views/dialogs/select_game.cpp
@@ -28,26 +28,26 @@ namespace Views {
namespace Dialogs {
static const char *OPTIONS[] = {
- "Part 1: Serpent Surprise!",
- "Part 2: Non-stick Nognir",
- "Part 3: Lookin' for Loki",
- nullptr
+ "Part 1: Serpent Surprise!",
+ "Part 2: Non-stick Nognir",
+ "Part 3: Lookin' for Loki",
+ nullptr
};
SelectGame::SelectGame() : SelectOption("SelectGame", "Play Which Game?", OPTIONS) {
}
void SelectGame::selected() {
- // Select the game area to start from
- g_vars->setArea(_selectedItem + 1);
+ // Select the game area to start from
+ g_vars->setArea(_selectedItem + 1);
- // Switch to the story view for the selected game area
- initialize_game();
- replaceView("Story", true, true);
+ // Switch to the story view for the selected game area
+ initialize_game();
+ replaceView("Story", true, true);
}
void SelectGame::closed() {
- addView("MainMenu");
+ addView("MainMenu");
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_game.h b/engines/got/views/dialogs/select_game.h
index 49b41e6b11b..082855180d9 100644
--- a/engines/got/views/dialogs/select_game.h
+++ b/engines/got/views/dialogs/select_game.h
@@ -30,12 +30,12 @@ namespace Dialogs {
class SelectGame : public SelectOption {
public:
- SelectGame();
- virtual ~SelectGame() {
- }
+ SelectGame();
+ virtual ~SelectGame() {
+ }
- void selected() override;
- void closed() override;
+ void selected() override;
+ void closed() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
index ec773d271f4..066ebfdae10 100644
--- a/engines/got/views/dialogs/select_item.cpp
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -29,135 +29,132 @@ namespace Dialogs {
#define _HRZSP 24
static const char *ITEM_NAMES[] = {
- "Enchanted Apple", "Lightning Power", "Winged Boots",
- "Wind Power", "Amulet of Protection","Thunder Power"
+ "Enchanted Apple", "Lightning Power", "Winged Boots",
+ "Wind Power", "Amulet of Protection", "Thunder Power"
};
SelectItem::SelectItem() : Dialog("SelectItem") {
- setBounds(Common::Rect(56, 48, 264, 160));
+ setBounds(Common::Rect(56, 48, 264, 160));
}
void SelectItem::draw() {
- int b;
- const char *objn;
-
- Dialog::draw();
- GfxSurface s = getSurface();
-
- if (_G(thor_info).inventory == 0) {
- s.print(Common::Point(44, 52), "No Items Found", 14);
- return;
- }
-
- b = 1;
- for (int l = 0; l < 7; l++, b = b << 1) {
- if (_G(thor_info).inventory & b) {
- if (l < 6)
- s.simpleBlitFrom(_G(objects)[l + 26],
- Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
- else
- s.simpleBlitFrom(_G(objects)[_G(thor_info).object + 10],
- Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
- }
- }
-
- if (_selectedItem < 6)
- objn = ITEM_NAMES[_selectedItem];
- else
- objn = _G(thor_info).object_name;
-
- s.print(Common::Point((s.w - (strlen(objn) * 8)) / 2, 66), objn, 12);
- s.frameRect(Common::Rect(26 + (_selectedItem * _HRZSP), 22,
- 43 + (_selectedItem * _HRZSP), 42), 15);
+ Dialog::draw();
+ GfxSurface s = getSurface();
+
+ if (_G(thor_info).inventory == 0) {
+ s.print(Common::Point(44, 52), "No Items Found", 14);
+ return;
+ }
+
+ int b = 1;
+ for (int l = 0; l < 7; l++, b = b << 1) {
+ if (_G(thor_info).inventory & b) {
+ if (l < 6)
+ s.simpleBlitFrom(_G(objects[l + 26]), Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
+ else {
+ int objId = _G(thor_info).object + 10;
+ s.simpleBlitFrom(_G(objects[objId]), Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
+ }
+ }
+ }
+
+ const char *objName;
+ if (_selectedItem < 6)
+ objName = ITEM_NAMES[_selectedItem];
+ else
+ objName = _G(thor_info).object_name;
+
+ s.print(Common::Point((s.w - (strlen(objName) * 8)) / 2, 66), objName, 12);
+ s.frameRect(Common::Rect(26 + (_selectedItem * _HRZSP), 22,
+ 43 + (_selectedItem * _HRZSP), 42),
+ 15);
}
bool SelectItem::msgFocus(const FocusMessage &msg) {
- int b;
-
- if (_G(thor_info).inventory == 0) {
- _selectedItem = -1;
- } else {
- _selectedItem = _G(thor_info).item - 1;
- if (_selectedItem < 1)
- _selectedItem = 0;
-
- b = 1 << _selectedItem;
- for (;;) {
- if (_G(thor_info).inventory & b)
- break;
- if (_selectedItem < 7)
- _selectedItem++;
- else
- _selectedItem = 0;
-
- b = 1 << _selectedItem;
- }
- }
-
- return true;
+ if (_G(thor_info).inventory == 0) {
+ _selectedItem = -1;
+ } else {
+ _selectedItem = _G(thor_info).item - 1;
+ if (_selectedItem < 1)
+ _selectedItem = 0;
+
+ int b = 1 << _selectedItem;
+ for (;;) {
+ if (_G(thor_info).inventory & b)
+ break;
+ if (_selectedItem < 7)
+ _selectedItem++;
+ else
+ _selectedItem = 0;
+
+ b = 1 << _selectedItem;
+ }
+ }
+
+ return true;
}
bool SelectItem::msgAction(const ActionMessage &msg) {
- int b;
-
- if (_G(thor_info).inventory == 0) {
- close();
- return true;
- }
-
- switch (msg._action) {
- case KEYBIND_ESCAPE:
- close();
- break;
-
- case KEYBIND_SELECT:
- case KEYBIND_FIRE:
- case KEYBIND_MAGIC:
- selectItem();
- break;
-
- case KEYBIND_LEFT:
- for (;;) {
- if (_selectedItem > 0)
- _selectedItem--;
- else
- _selectedItem = 8;
-
- b = 1 << _selectedItem;
- if (_G(thor_info).inventory & b)
- break;
- }
-
- play_sound(WOOP, 1);
- redraw();
- break;
-
- case KEYBIND_RIGHT:
- while (1) {
- if (_selectedItem < 9)
- _selectedItem++;
- else
- _selectedItem = 0;
-
- b = 1 << _selectedItem;
- if (_G(thor_info).inventory & b)
- break;
- }
-
- play_sound(WOOP, 1);
- redraw();
- break;
-
- default:
- break;
- }
-
- return true;
+ int b;
+
+ if (_G(thor_info).inventory == 0) {
+ close();
+ return true;
+ }
+
+ switch (msg._action) {
+ case KEYBIND_ESCAPE:
+ close();
+ break;
+
+ case KEYBIND_SELECT:
+ case KEYBIND_FIRE:
+ case KEYBIND_MAGIC:
+ selectItem();
+ break;
+
+ case KEYBIND_LEFT:
+ for (;;) {
+ if (_selectedItem > 0)
+ _selectedItem--;
+ else
+ _selectedItem = 8;
+
+ b = 1 << _selectedItem;
+ if (_G(thor_info).inventory & b)
+ break;
+ }
+
+ play_sound(WOOP, 1);
+ redraw();
+ break;
+
+ case KEYBIND_RIGHT:
+ while (1) {
+ if (_selectedItem < 9)
+ _selectedItem++;
+ else
+ _selectedItem = 0;
+
+ b = 1 << _selectedItem;
+ if (_G(thor_info).inventory & b)
+ break;
+ }
+
+ play_sound(WOOP, 1);
+ redraw();
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
}
void SelectItem::selectItem() {
- _G(thor_info).item = _selectedItem + 1;
- close();
+ _G(thor_info).item = _selectedItem + 1;
+ close();
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_item.h b/engines/got/views/dialogs/select_item.h
index 0487aa51683..4994ec2f8c3 100644
--- a/engines/got/views/dialogs/select_item.h
+++ b/engines/got/views/dialogs/select_item.h
@@ -30,17 +30,17 @@ namespace Dialogs {
class SelectItem : public Dialog {
private:
- int _selectedItem;
+ int _selectedItem;
- void selectItem();
+ void selectItem();
public:
- SelectItem();
- virtual ~SelectItem() {}
+ SelectItem();
+ virtual ~SelectItem() {}
- void draw() override;
- bool msgFocus(const FocusMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
+ void draw() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index a838c71fe16..ffd5df9f4aa 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -31,122 +31,127 @@ const char *ON_OFF[] = { "On", "Off", nullptr };
const char *YES_NO[] = { "Yes", "No", nullptr };
SelectOption::SelectOption(const Common::String &name, const char *title,
- const char *options[]) : Dialog(name) {
- // Set up string array of options
- Common::StringArray optionsArray;
- for (const char **option = options; *option; ++option)
- optionsArray.push_back(*option);
+ const char *options[]) : Dialog(name) {
+ // Set up string array of options
+ Common::StringArray optionsArray;
+ for (const char **option = options; *option; ++option)
+ optionsArray.push_back(*option);
- setContent(title, optionsArray);
+ setContent(title, optionsArray);
}
SelectOption::SelectOption(const Common::String &name) : Dialog(name) {
}
void SelectOption::setContent(const Common::String &title,
- const Common::StringArray &options) {
- _title = title;
- _options = options;
+ const Common::StringArray &options) {
+ _title = title;
+ _options = options;
- // Calculate the bounds for the dialog
- int w, h, x1, y1, x2, y2;
+ // Calculate the bounds for the dialog
+ int w, h, x1, y1, x2, y2;
- w = title.size();
- for (uint i = 0; i < _options.size(); ++i)
- w = MAX(w, (int)_options[i].size());
+ w = title.size();
+ for (uint i = 0; i < _options.size(); ++i)
+ w = MAX(w, (int)_options[i].size());
- if (w & 1)
- w++;
- w = (w * 8) + 32;
+ if (w & 1)
+ w++;
+ w = (w * 8) + 32;
- h = (_options.size() * 16) + 32;
- x1 = (320 - w) / 2;
- x2 = (x1 + w);
- y1 = (192 - h) / 2;
- y2 = (y1 + h);
+ h = (_options.size() * 16) + 32;
+ x1 = (320 - w) / 2;
+ x2 = (x1 + w);
+ y1 = (192 - h) / 2;
+ y2 = (y1 + h);
- _bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
+ _bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
}
void SelectOption::draw() {
- Dialog::draw();
-
- // Write the title
- GfxSurface s = getSurface(true);
- int titleStart = (s.w - _title.size() * 8) / 2;
- s.print(Common::Point(titleStart, 4), _title, 54);
-
- // Write the options
- for (uint i = 0; i < _options.size(); ++i)
- s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
-
- // Draw selection pointer
- if (_smackCtr > 0) {
- // Selecting an item
- int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
- s.simpleBlitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
- } else {
- // Normal animated cursor
- s.simpleBlitFrom(_G(hampic)[_hammerFrame],
- Common::Point(8, 24 + (_selectedItem * 16)));
- }
+ Dialog::draw();
+
+ // Write the title
+ GfxSurface s = getSurface(true);
+ int titleStart = (s.w - _title.size() * 8) / 2;
+ s.print(Common::Point(titleStart, 4), _title, 54);
+
+ // Write the options
+ for (uint i = 0; i < _options.size(); ++i)
+ s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
+
+ // Draw selection pointer
+ if (_smackCtr > 0) {
+ // Selecting an item
+ int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
+ s.simpleBlitFrom(_G(hampic[0]), Common::Point(xp, 24 + (_selectedItem * 16)));
+ } else {
+ // Normal animated cursor
+ s.simpleBlitFrom(_G(hampic[_hammerFrame]), Common::Point(8, 24 + (_selectedItem * 16)));
+ }
+}
+
+bool SelectOption::msgFocus(const FocusMessage &msg) {
+ _selectedItem = 0;
+ _smackCtr = 0;
+ return true;
}
bool SelectOption::msgAction(const ActionMessage &msg) {
- // Don't allow further actions if selection is in progress
- if (_smackCtr != 0)
- return true;
-
- switch (msg._action) {
- case KEYBIND_UP:
- play_sound(WOOP,1);
- if (--_selectedItem < 0)
- _selectedItem = (int)_options.size() - 1;
- break;
-
- case KEYBIND_DOWN:
- play_sound(WOOP, 1);
- if (++_selectedItem >= (int)_options.size())
- _selectedItem = 0;
- break;
-
- case KEYBIND_SELECT:
- case KEYBIND_FIRE:
- case KEYBIND_MAGIC:
- _smackCtr = 1;
- break;
-
- case KEYBIND_ESCAPE:
- _selectedItem = -1;
- close();
- closed();
- break;
-
- default:
- break;
- }
-
- return true;
+ // Don't allow further actions if selection is in progress
+ if (_smackCtr != 0)
+ return true;
+
+ switch (msg._action) {
+ case KEYBIND_UP:
+ play_sound(WOOP, 1);
+ if (--_selectedItem < 0)
+ _selectedItem = (int)_options.size() - 1;
+ break;
+
+ case KEYBIND_DOWN:
+ play_sound(WOOP, 1);
+ if (++_selectedItem >= (int)_options.size())
+ _selectedItem = 0;
+ break;
+
+ case KEYBIND_SELECT:
+ case KEYBIND_FIRE:
+ case KEYBIND_MAGIC:
+ _smackCtr = 1;
+ break;
+
+ case KEYBIND_ESCAPE:
+ _selectedItem = -1;
+ close();
+ closed();
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
}
bool SelectOption::tick() {
- if (++_hammerFrame == 4)
- _hammerFrame = 0;
-
- // Handle animation when an item is selected
- if (_smackCtr != 0) {
- ++_smackCtr;
- if (_smackCtr == 3)
- play_sound(CLANG, 1);
- if (_smackCtr == 6) {
- _smackCtr = 0;
- close();
- selected();
- }
- }
-
- redraw();
- return true;
+ if (++_hammerFrame == 4)
+ _hammerFrame = 0;
+
+ // Handle animation when an item is selected
+ if (_smackCtr != 0) {
+ ++_smackCtr;
+ if (_smackCtr == 3)
+ play_sound(CLANG, 1);
+ if (_smackCtr == 6) {
+ _smackCtr = 0;
+ close();
+ selected();
+ }
+ }
+
+ redraw();
+ return true;
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_option.h b/engines/got/views/dialogs/select_option.h
index cdd2e94e8bb..ee3d75309b5 100644
--- a/engines/got/views/dialogs/select_option.h
+++ b/engines/got/views/dialogs/select_option.h
@@ -22,7 +22,6 @@
#ifndef GOT_VIEWS_DIALOGS_SELECT_OPTION_H
#define GOT_VIEWS_DIALOGS_SELECT_OPTION_H
-#include "graphics/managed_surface.h"
#include "got/views/dialogs/dialog.h"
namespace Got {
@@ -33,36 +32,30 @@ namespace Dialogs {
extern const char *ON_OFF[];
extern const char *YES_NO[];
-
class SelectOption : public Dialog {
private:
- Common::String _title;
- Common::StringArray _options;
- int _hammerFrame = 0;
- int _smackCtr = 0;
+ Common::String _title;
+ Common::StringArray _options;
+ int _hammerFrame = 0;
+ int _smackCtr = 0;
protected:
- int _selectedItem = 0;
+ int _selectedItem = 0;
- void setContent(const Common::String &title,
- const Common::StringArray &options);
- virtual void closed() {}
- virtual void selected() {}
+ void setContent(const Common::String &title,
+ const Common::StringArray &options);
+ virtual void closed() {}
+ virtual void selected() {}
public:
- SelectOption(const Common::String &name, const char *title,
- const char *options[]);
- SelectOption(const Common::String &name);
- virtual ~SelectOption() {}
+ SelectOption(const Common::String &name, const char *title, const char *options[]);
+ SelectOption(const Common::String &name);
+ virtual ~SelectOption() {}
- bool msgFocus(const FocusMessage &msg) override {
- _selectedItem = 0;
- _smackCtr = 0;
- return true;
- }
- bool msgAction(const ActionMessage &msg) override;
- void draw() override;
- bool tick() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+ void draw() override;
+ bool tick() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_scroll.cpp b/engines/got/views/dialogs/select_scroll.cpp
index 044f245f30f..69aadf3f860 100644
--- a/engines/got/views/dialogs/select_scroll.cpp
+++ b/engines/got/views/dialogs/select_scroll.cpp
@@ -30,13 +30,13 @@ SelectScroll::SelectScroll() : SelectOption("SelectScroll", "Scroll Between Scre
}
bool SelectScroll::msgFocus(const FocusMessage &msg) {
- _selectedItem = 1 - _G(setup).scroll_flag;
- return true;
+ _selectedItem = 1 - _G(setup).scroll_flag;
+ return true;
}
void SelectScroll::selected() {
- _G(setup).scroll_flag = (_selectedItem == 0) ? 1 : 0;
- _G(last_setup) = _G(setup);
+ _G(setup).scroll_flag = (_selectedItem == 0) ? 1 : 0;
+ _G(last_setup) = _G(setup);
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_scroll.h b/engines/got/views/dialogs/select_scroll.h
index 042a6a571f7..e1b4c91278e 100644
--- a/engines/got/views/dialogs/select_scroll.h
+++ b/engines/got/views/dialogs/select_scroll.h
@@ -30,12 +30,11 @@ namespace Dialogs {
class SelectScroll : public SelectOption {
public:
- SelectScroll();
- virtual ~SelectScroll() {
- }
+ SelectScroll();
+ virtual ~SelectScroll() {}
- bool msgFocus(const FocusMessage &msg) override;
- void selected() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_slow.cpp b/engines/got/views/dialogs/select_slow.cpp
index 83d63229053..105784bca95 100644
--- a/engines/got/views/dialogs/select_slow.cpp
+++ b/engines/got/views/dialogs/select_slow.cpp
@@ -32,19 +32,19 @@ SelectSlow::SelectSlow() : SelectOption("SelectSlow", "Fast Mode", OPTIONS) {
}
void SelectSlow::selected() {
- switch (_selectedItem) {
- case 0:
- _G(slow_mode) = true;
- break;
- case 1:
- _G(slow_mode) = false;
- break;
- default:
- break;
- }
+ switch (_selectedItem) {
+ case 0:
+ _G(slow_mode) = true;
+ break;
+ case 1:
+ _G(slow_mode) = false;
+ break;
+ default:
+ break;
+ }
- // Next select scrolling
- addView("SelectScroll");
+ // Next select scrolling
+ addView("SelectScroll");
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_slow.h b/engines/got/views/dialogs/select_slow.h
index 76cdf8c93a3..8b119cf0474 100644
--- a/engines/got/views/dialogs/select_slow.h
+++ b/engines/got/views/dialogs/select_slow.h
@@ -30,11 +30,10 @@ namespace Dialogs {
class SelectSlow : public SelectOption {
public:
- SelectSlow();
- virtual ~SelectSlow() {
- }
+ SelectSlow();
+ virtual ~SelectSlow() {}
- void selected() override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_music.cpp b/engines/got/views/dialogs/set_music.cpp
index f968d632274..0f28e973c56 100644
--- a/engines/got/views/dialogs/set_music.cpp
+++ b/engines/got/views/dialogs/set_music.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/config-manager.h"
#include "got/views/dialogs/set_music.h"
+#include "common/config-manager.h"
#include "got/got.h"
namespace Got {
@@ -31,14 +31,14 @@ SetMusic::SetMusic() : SelectOption("SetMusic", "Set Music", ON_OFF) {
}
bool SetMusic::msgFocus(const FocusMessage &msg) {
- _selectedItem = ConfMan.getBool("music_mute") ? 1 : 0;
- return true;
+ _selectedItem = ConfMan.getBool("music_mute") ? 1 : 0;
+ return true;
}
void SetMusic::selected() {
- ConfMan.setBool("music_mute", _selectedItem == 1);
- ConfMan.flushToDisk();
- g_engine->syncSoundSettings();
+ ConfMan.setBool("music_mute", _selectedItem == 1);
+ ConfMan.flushToDisk();
+ g_engine->syncSoundSettings();
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_music.h b/engines/got/views/dialogs/set_music.h
index 23fdd8f883e..68706a48937 100644
--- a/engines/got/views/dialogs/set_music.h
+++ b/engines/got/views/dialogs/set_music.h
@@ -30,12 +30,11 @@ namespace Dialogs {
class SetMusic : public SelectOption {
public:
- SetMusic();
- virtual ~SetMusic() {
- }
+ SetMusic();
+ virtual ~SetMusic() {}
- bool msgFocus(const FocusMessage &msg) override;
- void selected() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ void selected() override;
};
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_sound.cpp b/engines/got/views/dialogs/set_sound.cpp
index 544367ad8d3..b210b8747ff 100644
--- a/engines/got/views/dialogs/set_sound.cpp
+++ b/engines/got/views/dialogs/set_sound.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/config-manager.h"
#include "got/views/dialogs/set_sound.h"
+#include "common/config-manager.h"
#include "got/got.h"
namespace Got {
@@ -31,15 +31,15 @@ SetSound::SetSound() : SelectOption("SetSound", "Set Sound", ON_OFF) {
}
bool SetSound::msgFocus(const FocusMessage &msg) {
- _selectedItem = ConfMan.getBool("sfx_mute") ? 1 : 0;
- return true;
+ _selectedItem = ConfMan.getBool("sfx_mute") ? 1 : 0;
+ return true;
}
void SetSound::selected() {
- ConfMan.setBool("sfx_mute", _selectedItem == 1);
- ConfMan.flushToDisk();
- g_engine->syncSoundSettings();
- addView("SetMusic");
+ ConfMan.setBool("sfx_mute", _selectedItem == 1);
+ ConfMan.flushToDisk();
+ g_engine->syncSoundSettings();
+ addView("SetMusic");
}
} // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_sound.h b/engines/got/views/dialogs/set_sound.h
index b282124f6be..53fb68bfee8 100644
--- a/engines/got/views/dialogs/set_sound.h
+++ b/engines/got/views/dialogs/set_sound.h
@@ -30,12 +30,11 @@ namespace Dialogs {
class SetSound : public SelectOption {
public:
- SetSound();
- virtual ~SetSound() {
- }
+ SetSound();
+ virtual ~SetSound() {}
- bool msgFocus(const FocusMessage &msg) override;
- void selected() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ void selected() override;
};
} // namespace Dialogs
Commit: dd24330482b6860f32965d7a40a3c11102377194
https://github.com/scummvm/scummvm/commit/dd24330482b6860f32965d7a40a3c11102377194
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT : Change access to global arrays in game_content
Changed paths:
engines/got/views/game_content.cpp
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index aafb0e78960..ac3e165f923 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -28,7 +28,6 @@
#include "got/game/move_patterns.h"
#include "got/game/object.h"
#include "got/game/status.h"
-#include "got/gfx/image.h"
#include "got/vars.h"
namespace Got {
@@ -75,28 +74,20 @@ void GameContent::draw() {
switch (_G(transitionDir)) {
case DIR_LEFT:
- win.simpleBlitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),
- Common::Point(0, 0));
- win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),
- Common::Point(_transitionPos, 0));
+ win.simpleBlitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),Common::Point(0, 0));
+ win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),Common::Point(_transitionPos, 0));
break;
case DIR_RIGHT:
- win.simpleBlitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),
- Common::Point(0, 0));
- win.simpleBlitFrom(s, Common::Rect(0, 0, _transitionPos, 192),
- Common::Point(320 - _transitionPos, 0));
+ win.simpleBlitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),Common::Point(0, 0));
+ win.simpleBlitFrom(s, Common::Rect(0, 0, _transitionPos, 192),Common::Point(320 - _transitionPos, 0));
break;
case DIR_UP:
- win.simpleBlitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),
- Common::Point(0, 0));
- win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),
- Common::Point(0, _transitionPos));
+ win.simpleBlitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),Common::Point(0, 0));
+ win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),Common::Point(0, _transitionPos));
break;
case DIR_DOWN:
- win.simpleBlitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),
- Common::Point(0, 0));
- win.simpleBlitFrom(s, Common::Rect(0, 0, 320, _transitionPos),
- Common::Point(0, 192 - _transitionPos));
+ win.simpleBlitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),Common::Point(0, 0));
+ win.simpleBlitFrom(s, Common::Rect(0, 0, 320, _transitionPos),Common::Point(0, 192 - _transitionPos));
break;
case DIR_PHASED:
win.simpleBlitFrom(_surface); // Copy old surface
@@ -122,7 +113,9 @@ bool GameContent::msgGame(const GameMessage &msg) {
_G(gameMode) = MODE_PAUSE;
_pauseCtr = msg._value;
return true;
- } else if (msg._name == "SCORE_INV") {
+ }
+
+ if (msg._name == "SCORE_INV") {
_G(gameMode) = MODE_SCORE_INV;
_pauseCtr = 0;
return true;
@@ -230,8 +223,9 @@ void GameContent::drawBackground(GfxSurface &s) {
for (int x = 0; x < TILES_X; x++) {
if (_G(scrn).icon[y][x] != 0) {
const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
- s.simpleBlitFrom(_G(bgPics)[_G(scrn).bg_color], pt);
- s.simpleBlitFrom(_G(bgPics)[_G(scrn).icon[y][x]], pt);
+ LEVEL screen = _G(scrn);
+ s.simpleBlitFrom(_G(bgPics[screen.bg_color]), pt);
+ s.simpleBlitFrom(_G(bgPics[screen.icon[y][x]]), pt);
}
}
}
@@ -242,16 +236,16 @@ void GameContent::drawObjects(GfxSurface &s) {
for (int x = 0; x < TILES_X; ++x) {
int p = (y * TILES_X) + x;
- if (_G(object_map)[p]) {
- s.simpleBlitFrom(_G(objects)[_G(object_map)[p] - 1],
- Common::Point(x * TILE_SIZE, y * TILE_SIZE));
+ byte currObjId = _G(object_map[p]);
+ if (currObjId) {
+ s.simpleBlitFrom(_G(objects[currObjId - 1]), Common::Point(x * TILE_SIZE, y * TILE_SIZE));
}
}
}
}
void GameContent::drawActors(GfxSurface &s) {
- ACTOR *actor_ptr = &_G(actor)[MAX_ACTORS - 1];
+ ACTOR *actor_ptr = &_G(actor[MAX_ACTORS - 1]);
ACTOR *actor2_storage = nullptr;
for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
@@ -260,8 +254,7 @@ void GameContent::drawActors(GfxSurface &s) {
actor_ptr->last_x[_G(pge)] = actor_ptr->x;
actor_ptr->last_y[_G(pge)] = actor_ptr->y;
- const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir]
- [actor_ptr->frame_sequence[actor_ptr->next]];
+ const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir][actor_ptr->frame_sequence[actor_ptr->next]];
s.simpleBlitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
}
@@ -278,27 +271,26 @@ void GameContent::drawActors(GfxSurface &s) {
}
if (_G(gameMode) == MODE_THOR_DIES && _deathCtr >= DEATH_THRESHOLD)
- s.simpleBlitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
+ s.simpleBlitFrom(_G(objects[10]), Common::Point(_G(thor)->x, _G(thor)->y));
}
void GameContent::drawBossHealth(GfxSurface &s) {
- int i, c;
+ int c;
- int health = _G(actor)[3].health;
+ int health = _G(actor[3]).health;
s.fillRect(Common::Rect(304, 2, 317, 81), 0);
s.fillRect(Common::Rect(305, 3, 316, 80), 28);
s.fillRect(Common::Rect(306, 4, 315, 79), 26);
s.fillRect(Common::Rect(307, 5, 314, 78), 24);
- for (i = 10; i > 0; i--) {
+ for (int i = 10; i > 0; i--) {
if (i * 10 > health)
c = 0;
else
c = 32;
- s.fillRect(Common::Rect(308, 7 + (7 * (10 - i)),
- 313, 13 + (7 * (10 - i))), c);
+ s.fillRect(Common::Rect(308, 7 + (7 * (10 - i)), 313, 13 + (7 * (10 - i))), c);
}
}
@@ -316,9 +308,10 @@ void GameContent::checkThunderShake() {
_G(thunder_flag)--;
if ((_G(thunder_flag) < MAX_ACTORS) && _G(thunder_flag) > 2) {
- if (_G(actor)[_G(thunder_flag)].used) {
- _G(actor)[_G(thunder_flag)].vunerable = 0;
- actor_damaged(&_G(actor)[_G(thunder_flag)], 20);
+ int thunderFl = _G(thunder_flag);
+ if (_G(actor[thunderFl]).used) {
+ _G(actor[thunderFl]).vunerable = 0;
+ actor_damaged(&_G(actor[thunderFl]), 20);
}
}
@@ -350,20 +343,20 @@ void GameContent::checkSwitchFlag() {
void GameContent::checkForItem() {
int thor_pos = _G(thor)->getPos();
- if (_G(object_map)[thor_pos])
+ if (_G(object_map[thor_pos]))
pick_up_object(thor_pos);
}
void GameContent::moveActors() {
for (int i = 0; i < MAX_ACTORS; i++) {
- if (_G(actor)[i].used) {
+ if (_G(actor[i]).used) {
if (_G(hourglass_flag))
- if ((i > 2) && (!_G(pge)) && (!(_G(actor)[i].magic_hurts & LIGHTNING_MAGIC)))
+ if ((i > 2) && (!_G(pge)) && (!(_G(actor[i]).magic_hurts & LIGHTNING_MAGIC)))
continue;
- _G(actor)[i].move_count = _G(actor)[i].num_moves;
- while (_G(actor)[i].move_count--)
- move_actor(&_G(actor)[i]);
+ _G(actor[i]).move_count = _G(actor[i]).num_moves;
+ while (_G(actor[i]).move_count--)
+ move_actor(&_G(actor[i]));
if (i == 0)
set_thor_vars();
@@ -380,7 +373,7 @@ void GameContent::moveActors() {
void GameContent::updateActors() {
for (int i = 0; i < MAX_ACTORS; ++i) {
- ACTOR *actor = &_G(actor)[i];
+ ACTOR *actor = &_G(actor[i]);
if (!actor->used && actor->dead > 0)
actor->dead--;
@@ -392,7 +385,7 @@ void GameContent::checkForBossDead() {
if (_G(boss_dead)) {
for (loop = 3; loop < 7; loop++) {
- if (_G(actor)[loop].used)
+ if (_G(actor[loop]).used)
break;
}
@@ -491,8 +484,8 @@ void GameContent::thorDies() {
// Stop any actors on-screen from moving
for (int li = 0; li < MAX_ACTORS; li++)
- _G(actor)[li].show = 0;
- _G(actor)[2].used = 0;
+ _G(actor[li]).show = 0;
+ _G(actor[2]).used = 0;
// Set the state for showing death animation
_G(gameMode) = MODE_THOR_DIES;
@@ -554,8 +547,8 @@ void GameContent::thorDead() {
_G(tornado_used) = false;
_G(shield_on) = false;
music_resume();
- _G(actor)[1].used = 0;
- _G(actor)[2].used = 0;
+ _G(actor[1]).used = 0;
+ _G(actor[2]).used = 0;
_G(thor)->speed_count = 6;
_G(thor)->used = 1;
@@ -650,7 +643,7 @@ void GameContent::throwLightning() {
_lightningCtr = 20;
for (int i = 0; i < MAX_ACTORS; i++)
- _G(actor)[i].show = 0;
+ _G(actor[i]).show = 0;
play_sound(ELECTRIC, 1);
}
@@ -677,16 +670,16 @@ void GameContent::lightningCountdownDone() {
y = _G(thor)->y + 7;
for (i = 3; i < MAX_ACTORS; i++) {
- if (!_G(actor)[i].used)
+ if (!_G(actor[i]).used)
continue;
- ax = _G(actor)[i].x + (_G(actor)[i].size_x / 2);
- ay = _G(actor)[i].y + (_G(actor)[i].size_y / 2);
+ ax = _G(actor[i]).x + (_G(actor[i]).size_x / 2);
+ ay = _G(actor[i]).y + (_G(actor[i]).size_y / 2);
if ((ABS(ax - x) < 30) && (ABS(ay - y) < 30)) {
- _G(actor)[i].magic_hit = 1;
- _G(actor)[i].vunerable = 0;
- actor_damaged(&_G(actor)[i], 254);
+ _G(actor[i]).magic_hit = 1;
+ _G(actor[i]).vunerable = 0;
+ actor_damaged(&_G(actor[i]), 254);
}
}
}
Commit: 6ec2d60b32cb872749102ab7a37f692c93e3cd23
https://github.com/scummvm/scummvm/commit/6ec2d60b32cb872749102ab7a37f692c93e3cd23
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:17-08:00
Commit Message:
GOT: Remove unimplemented method in game_content
Changed paths:
engines/got/views/game_content.h
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index d4447f0dea5..342858a3e39 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -56,7 +56,6 @@ private:
void updateActors();
void checkForBossDead();
void checkForAreaChange();
- void areaChanged();
void thorDies();
void spinThor();
void thorDead();
Commit: a2ffe428bfe8e53ec5d6a1422515ea036ee75bfa
https://github.com/scummvm/scummvm/commit/a2ffe428bfe8e53ec5d6a1422515ea036ee75bfa
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-13T12:32:18-08:00
Commit Message:
GOT: global array access and code formating in views (partial)
Changed paths:
engines/got/views/credits.cpp
engines/got/views/credits.h
engines/got/views/game.cpp
engines/got/views/game.h
engines/got/views/game_content.cpp
engines/got/views/game_content.h
engines/got/views/game_status.cpp
engines/got/views/game_status.h
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index 5e163b198e3..a088c3f4831 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -31,104 +31,104 @@ namespace Views {
#define CREDIT_TIME (FADE_FRAMES * 2 + DISPLAY_TIME)
bool Credits::msgFocus(const FocusMessage &msg) {
- _delayCtr = 0;
- _frameCtr = 0;
+ _delayCtr = 0;
+ _frameCtr = 0;
- draw();
- Gfx::Palette63 pal = _G(gfx)[41];
- fadeIn(pal);
+ draw();
+ Gfx::Palette63 pal = _G(gfx[41]);
+ fadeIn(pal);
- return true;
+ return true;
}
void Credits::draw() {
- GfxSurface s = getSurface();
+ GfxSurface s = getSurface();
- // Draw scroll background
- const Graphics::ManagedSurface &bg = _G(gfx)[42];
- s.clear(*(const byte *)bg.getPixels());
- s.simpleBlitFrom(bg, Common::Point(0, 24));
+ // Draw scroll background
+ const Graphics::ManagedSurface &bg = _G(gfx[42]);
+ s.clear(*(const byte *)bg.getPixels());
+ s.simpleBlitFrom(bg, Common::Point(0, 24));
- int creditNum = _frameCtr / CREDIT_TIME;
- int subNum = _frameCtr % CREDIT_TIME;
+ int creditNum = _frameCtr / CREDIT_TIME;
+ int subNum = _frameCtr % CREDIT_TIME;
- if (subNum >= (FADE_FRAMES + DISPLAY_TIME)) {
- subNum = (FADE_FRAMES - 1) - (subNum - (FADE_FRAMES + DISPLAY_TIME));
- } else if (subNum >= FADE_FRAMES) {
- subNum = FADE_FRAMES - 1;
- }
+ if (subNum >= (FADE_FRAMES + DISPLAY_TIME)) {
+ subNum = (FADE_FRAMES - 1) - (subNum - (FADE_FRAMES + DISPLAY_TIME));
+ } else if (subNum >= FADE_FRAMES) {
+ subNum = FADE_FRAMES - 1;
+ }
- if (creditNum < CREDITS_COUNT) {
- int gfxNum1 = 43 + creditNum;
- int gfxNum2 = 67 + creditNum;
- int gfxNum3 = 52 + subNum;
- int gfxNum4 = 76 + subNum;
+ if (creditNum < CREDITS_COUNT) {
+ int gfxNum1 = 43 + creditNum;
+ int gfxNum2 = 67 + creditNum;
+ int gfxNum3 = 52 + subNum;
+ int gfxNum4 = 76 + subNum;
- drawCredit(s, gfxNum1, gfxNum3, 16, 40 + 24);
- drawCredit(s, gfxNum2, gfxNum4, 16, 40 + 24);
- }
+ drawCredit(s, gfxNum1, gfxNum3, 16, 40 + 24);
+ drawCredit(s, gfxNum2, gfxNum4, 16, 40 + 24);
+ }
- s.markAllDirty();
+ s.markAllDirty();
}
void Credits::drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y) {
- const Gfx::GraphicChunk &data = _G(gfx)[gfxNum1];
- const Gfx::GraphicChunk &lookup = _G(gfx)[gfxNum2];
- const byte *lines = data._data;
- const byte *lineData = data._data + 2 * data._height;
- byte *dest;
- byte count;
-
- assert(x >= 0 && (x + data._width) <= 320);
- assert(y >= 0 && (y + data._height) <= 200);
-
- for (int yCtr = 0; yCtr < data._height; ++yCtr) {
- dest = (byte *)s.getBasePtr(x, y + yCtr);
- uint16 lineParts = READ_LE_UINT16(lines);
- lines += 2;
-
- if (lineParts == 0)
- // Nothing on line, move to next
- continue;
-
- for (; lineParts > 0; --lineParts) {
- count = *lineData++;
-
- if (count & 0x80) {
- // Shade a range of pixels using lookup table
- count &= 0x7f;
- for (int i = 0; i < count; ++i, ++dest)
- *dest = lookup._data[*dest];
- } else {
- dest += count;
- }
- }
- }
+ const Gfx::GraphicChunk &data = _G(gfx[gfxNum1]);
+ const Gfx::GraphicChunk &lookup = _G(gfx[gfxNum2]);
+ const byte *lines = data._data;
+ const byte *lineData = data._data + 2 * data._height;
+ byte *dest;
+ byte count;
+
+ assert(x >= 0 && (x + data._width) <= 320);
+ assert(y >= 0 && (y + data._height) <= 200);
+
+ for (int yCtr = 0; yCtr < data._height; ++yCtr) {
+ dest = (byte *)s.getBasePtr(x, y + yCtr);
+ uint16 lineParts = READ_LE_UINT16(lines);
+ lines += 2;
+
+ if (lineParts == 0)
+ // Nothing on line, move to next
+ continue;
+
+ for (; lineParts > 0; --lineParts) {
+ count = *lineData++;
+
+ if (count & 0x80) {
+ // Shade a range of pixels using lookup table
+ count &= 0x7f;
+ for (int i = 0; i < count; ++i, ++dest)
+ *dest = lookup._data[*dest];
+ } else {
+ dest += count;
+ }
+ }
+ }
}
bool Credits::tick() {
- if (++_delayCtr >= 3) {
- _delayCtr = 0;
-
- if (_frameCtr == (CREDIT_TIME * CREDITS_COUNT) + 10) {
- replaceView("HighScores", true, true);
- } else {
- ++_frameCtr;
- redraw();
- }
- }
-
- return true;
+ if (++_delayCtr >= 3) {
+ _delayCtr = 0;
+
+ if (_frameCtr == (CREDIT_TIME * CREDITS_COUNT) + 10) {
+ replaceView("HighScores", true, true);
+ } else {
+ ++_frameCtr;
+ redraw();
+ }
+ }
+
+ return true;
}
bool Credits::msgAction(const ActionMessage &msg) {
- if (msg._action == KEYBIND_ESCAPE) {
- fadeOut();
- send("TitleBackground", GameMessage("MAIN_MENU"));
- return true;
- }
+ if (msg._action == KEYBIND_ESCAPE) {
+ fadeOut();
+ send("TitleBackground", GameMessage("MAIN_MENU"));
+ return true;
+ }
- return false;
+ return false;
}
} // namespace Views
diff --git a/engines/got/views/credits.h b/engines/got/views/credits.h
index 781b9f552bd..c7ed40851d9 100644
--- a/engines/got/views/credits.h
+++ b/engines/got/views/credits.h
@@ -29,19 +29,19 @@ namespace Views {
class Credits : public View {
private:
- int _delayCtr = 0;
- int _frameCtr = 0;
+ int _delayCtr = 0;
+ int _frameCtr = 0;
- void drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y);
+ void drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y);
public:
- Credits() : View("Credits") {}
- virtual ~Credits() {}
+ Credits() : View("Credits") {}
+ virtual ~Credits() {}
- bool msgFocus(const FocusMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
- void draw() override;
- bool tick() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+ void draw() override;
+ bool tick() override;
};
} // namespace Views
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 725581c7f24..8bf08672af6 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -21,108 +21,106 @@
#include "got/views/game.h"
#include "got/game/back.h"
-#include "got/game/init.h"
-#include "got/game/move.h"
-#include "got/game/object.h"
-#include "got/metaengine.h"
-#include "got/vars.h"
#include "got/game/boss1.h"
#include "got/game/boss2.h"
#include "got/game/boss3.h"
+#include "got/game/move.h"
+#include "got/metaengine.h"
+#include "got/vars.h"
namespace Got {
namespace Views {
Game::Game() : View("Game") {
- _children.push_back(&_content);
- _children.push_back(&_status);
- _content.setBounds(Common::Rect(0, 0, 320, 240 - 48));
- _status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
+ _children.push_back(&_content);
+ _children.push_back(&_status);
+ _content.setBounds(Common::Rect(0, 0, 320, 240 - 48));
+ _status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
}
bool Game::msgFocus(const FocusMessage &msg) {
- Gfx::load_palette();
- return View::msgFocus(msg);
+ Gfx::load_palette();
+ return View::msgFocus(msg);
}
bool Game::msgKeypress(const KeypressMessage &msg) {
- if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
- return false;
-
- switch (msg.keycode) {
- case Common::KEYCODE_F1:
- odin_speaks(2008, -1);
- return true;
-
- case Common::KEYCODE_f:
- if (gDebugLevel > 0) {
- // Hack used for testing end-game sequence
- if (GAME1 && _G(current_level) == BOSS_LEVEL1)
- closing_sequence1();
- else if (GAME2 && _G(current_level) == BOSS_LEVEL2)
- closing_sequence2();
- else if (GAME3 && _G(current_level) == BOSS_LEVEL3)
- closing_sequence3();
- }
- break;
-
- case Common::KEYCODE_e:
- if (gDebugLevel > 0 && GAME3)
- // Launch endgame screen
- closing_sequence3_3();
- break;
-
- case Common::KEYCODE_s:
- g_engine->saveGameDialog();
- break;
-
- case Common::KEYCODE_l:
- g_engine->loadGameDialog();
- break;
-
- default:
- break;
- }
-
- return false;
+ if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
+ return false;
+
+ switch (msg.keycode) {
+ case Common::KEYCODE_F1:
+ odin_speaks(2008, -1);
+ return true;
+
+ case Common::KEYCODE_f:
+ if (gDebugLevel > 0) {
+ // Hack used for testing end-game sequence
+ if (GAME1 && _G(current_level) == BOSS_LEVEL1)
+ closing_sequence1();
+ else if (GAME2 && _G(current_level) == BOSS_LEVEL2)
+ closing_sequence2();
+ else if (GAME3 && _G(current_level) == BOSS_LEVEL3)
+ closing_sequence3();
+ }
+ break;
+
+ case Common::KEYCODE_e:
+ if (gDebugLevel > 0 && GAME3)
+ // Launch endgame screen
+ closing_sequence3_3();
+ break;
+
+ case Common::KEYCODE_s:
+ g_engine->saveGameDialog();
+ break;
+
+ case Common::KEYCODE_l:
+ g_engine->loadGameDialog();
+ break;
+
+ default:
+ break;
+ }
+
+ return false;
}
bool Game::msgAction(const ActionMessage &msg) {
- if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
- return false;
+ if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
+ return false;
- switch (msg._action) {
- case KEYBIND_FIRE:
- thor_shoots();
- break;
+ switch (msg._action) {
+ case KEYBIND_FIRE:
+ thor_shoots();
+ break;
- case KEYBIND_SELECT:
- select_item();
- return true;
+ case KEYBIND_SELECT:
+ select_item();
+ return true;
- case KEYBIND_THOR_DIES:
- _content.send(GameMessage("THOR_DIES"));
- return true;
+ case KEYBIND_THOR_DIES:
+ _content.send(GameMessage("THOR_DIES"));
+ return true;
- case KEYBIND_ESCAPE:
- addView("OptionsMenu");
- return true;
+ case KEYBIND_ESCAPE:
+ addView("OptionsMenu");
+ return true;
- default:
- break;
- }
+ default:
+ break;
+ }
- return false;
+ return false;
}
bool Game::tick() {
- // There are many things in original game code that can trigger
- // changes on screen, and for simplicity they each no longer have
- // the code that partially updates the screen. Due to this,
- // we set to redraw the screen every frame in case of updates
- redraw();
+ // There are many things in original game code that can trigger
+ // changes on screen, and for simplicity they each no longer have
+ // the code that partially updates the screen. Due to this,
+ // we set to redraw the screen every frame in case of updates
+ redraw();
- return View::tick();
+ return View::tick();
}
} // namespace Views
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 120dcab905c..84002a18d31 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -22,26 +22,26 @@
#ifndef GOT_VIEWS_GAME_H
#define GOT_VIEWS_GAME_H
-#include "got/views/view.h"
#include "got/views/game_content.h"
#include "got/views/game_status.h"
+#include "got/views/view.h"
namespace Got {
namespace Views {
class Game : public View {
private:
- GameContent _content;
- GameStatus _status;
+ GameContent _content;
+ GameStatus _status;
public:
- Game();
- virtual ~Game() {}
+ Game();
+ virtual ~Game() {}
- bool msgFocus(const FocusMessage &msg) override;
- bool msgKeypress(const KeypressMessage &msg) override;
- bool msgAction(const ActionMessage &msg) override;
- bool tick() override;
+ bool msgFocus(const FocusMessage &msg) override;
+ bool msgKeypress(const KeypressMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+ bool tick() override;
};
} // namespace Views
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index ac3e165f923..26eb047ef26 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -38,711 +38,716 @@ namespace Views {
#define DEATH_THRESHOLD (SPIN_COUNT * SPIN_INTERVAL)
GameContent::GameContent() : View("GameContent") {
- _surface.create(320, 192);
+ _surface.create(320, 192);
}
void GameContent::draw() {
- GfxSurface s;
- if (_G(gameMode) == MODE_THUNDER || _G(gameMode) == MODE_AREA_CHANGE) {
- s.create(320, 192);
- } else {
- s = getSurface();
- }
- s.clear();
-
- drawBackground(s);
- drawObjects(s);
- drawActors(s);
-
- if ((GAME1 && _G(current_level) == BOSS_LEVEL1) ||
- (GAME2 && _G(current_level) == BOSS_LEVEL2) ||
- (GAME3 && _G(current_level) == BOSS_LEVEL3))
- drawBossHealth(s);
-
- // If we're shaking the screen, render the content with the shake X/Y
- if (_G(gameMode) == MODE_THUNDER) {
- GfxSurface win = getSurface();
- win.clear();
- win.simpleBlitFrom(s, _moveDelta);
- } else if (_G(gameMode) == MODE_LIGHTNING) {
- drawLightning(s);
-
- } else if (_G(gameMode) == MODE_AREA_CHANGE) {
- // Draw parts of the new scene along with parts of the old one
- // as it's scrolled off-screen
- GfxSurface win = getSurface();
-
- switch (_G(transitionDir)) {
- case DIR_LEFT:
- win.simpleBlitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),Common::Point(0, 0));
- win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),Common::Point(_transitionPos, 0));
- break;
- case DIR_RIGHT:
- win.simpleBlitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),Common::Point(0, 0));
- win.simpleBlitFrom(s, Common::Rect(0, 0, _transitionPos, 192),Common::Point(320 - _transitionPos, 0));
- break;
- case DIR_UP:
- win.simpleBlitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),Common::Point(0, 0));
- win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),Common::Point(0, _transitionPos));
- break;
- case DIR_DOWN:
- win.simpleBlitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),Common::Point(0, 0));
- win.simpleBlitFrom(s, Common::Rect(0, 0, 320, _transitionPos),Common::Point(0, 192 - _transitionPos));
- break;
- case DIR_PHASED:
- win.simpleBlitFrom(_surface); // Copy old surface
-
- // Copy the randomly chosen blocks over from new scene
- for (int i = 0; i < 240; ++i) {
- int x = (i * 16) % 320;
- int y = ((i * 16) / 320) * 16;
- if (_phased[i])
- win.simpleBlitFrom(s, Common::Rect(x, y, x + 16, y + 16), Common::Point(x, y));
- }
- break;
- default:
- break;
- }
- }
+ GfxSurface s;
+ if (_G(gameMode) == MODE_THUNDER || _G(gameMode) == MODE_AREA_CHANGE) {
+ s.create(320, 192);
+ } else {
+ s = getSurface();
+ }
+ s.clear();
+
+ drawBackground(s);
+ drawObjects(s);
+ drawActors(s);
+
+ if ((GAME1 && _G(current_level) == BOSS_LEVEL1) ||
+ (GAME2 && _G(current_level) == BOSS_LEVEL2) ||
+ (GAME3 && _G(current_level) == BOSS_LEVEL3))
+ drawBossHealth(s);
+
+ // If we're shaking the screen, render the content with the shake X/Y
+ if (_G(gameMode) == MODE_THUNDER) {
+ GfxSurface win = getSurface();
+ win.clear();
+ win.simpleBlitFrom(s, _moveDelta);
+ } else if (_G(gameMode) == MODE_LIGHTNING) {
+ drawLightning(s);
+
+ } else if (_G(gameMode) == MODE_AREA_CHANGE) {
+ // Draw parts of the new scene along with parts of the old one
+ // as it's scrolled off-screen
+ GfxSurface win = getSurface();
+
+ switch (_G(transitionDir)) {
+ case DIR_LEFT:
+ win.simpleBlitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192), Common::Point(0, 0));
+ win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192), Common::Point(_transitionPos, 0));
+ break;
+ case DIR_RIGHT:
+ win.simpleBlitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192), Common::Point(0, 0));
+ win.simpleBlitFrom(s, Common::Rect(0, 0, _transitionPos, 192), Common::Point(320 - _transitionPos, 0));
+ break;
+ case DIR_UP:
+ win.simpleBlitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192), Common::Point(0, 0));
+ win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos), Common::Point(0, _transitionPos));
+ break;
+ case DIR_DOWN:
+ win.simpleBlitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192), Common::Point(0, 0));
+ win.simpleBlitFrom(s, Common::Rect(0, 0, 320, _transitionPos), Common::Point(0, 192 - _transitionPos));
+ break;
+ case DIR_PHASED:
+ win.simpleBlitFrom(_surface); // Copy old surface
+
+ // Copy the randomly chosen blocks over from new scene
+ for (int i = 0; i < 240; ++i) {
+ int x = (i * 16) % 320;
+ int y = ((i * 16) / 320) * 16;
+ if (_phased[i])
+ win.simpleBlitFrom(s, Common::Rect(x, y, x + 16, y + 16), Common::Point(x, y));
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
-#define MSG(STR, METHOD) else if (msg._name == STR) { METHOD(); return true; }
+#define MSG(STR, METHOD) \
+ else if (msg._name == STR) { \
+ METHOD(); \
+ return true; \
+ }
bool GameContent::msgGame(const GameMessage &msg) {
- if (msg._name == "PAUSE") {
- _G(gameMode) = MODE_PAUSE;
- _pauseCtr = msg._value;
- return true;
- }
+ if (msg._name == "PAUSE") {
+ _G(gameMode) = MODE_PAUSE;
+ _pauseCtr = msg._value;
+ return true;
+ }
if (msg._name == "SCORE_INV") {
- _G(gameMode) = MODE_SCORE_INV;
- _pauseCtr = 0;
- return true;
- }
- MSG("THROW_LIGHTNING", throwLightning)
- MSG("THOR_DIES", thorDies)
- MSG("CLOSING", closingSequence)
-
- return false;
+ _G(gameMode) = MODE_SCORE_INV;
+ _pauseCtr = 0;
+ return true;
+ }
+ MSG("THROW_LIGHTNING", throwLightning)
+ MSG("THOR_DIES", thorDies)
+ MSG("CLOSING", closingSequence)
+
+ return false;
}
#undef MSG
bool GameContent::tick() {
- checkThunderShake();
-
- switch (_G(gameMode)) {
- case MODE_NORMAL:
- case MODE_THUNDER:
- checkSwitchFlag();
- checkForItem();
- moveActors();
- use_item();
- updateActors();
- checkForBossDead();
- checkForCheats();
-
- if (_G(endgame))
- endgame_movement();
- break;
-
- case MODE_THOR_DIES:
- if (_deathCtr < DEATH_THRESHOLD) {
- spinThor();
- } else if (_deathCtr < DEATH_THRESHOLD + 60) {
- _G(thor)->used = 0;
- ++_deathCtr;
- } else {
- thorDead();
- }
- break;
-
- case MODE_LIGHTNING:
- if (--_lightningCtr == 0) {
- lightningCountdownDone();
- }
- break;
-
- case MODE_PAUSE:
- if (--_pauseCtr == 0)
- _G(gameMode) = MODE_NORMAL;
- break;
-
- case MODE_SCORE_INV:
- if (--_pauseCtr <= 0) {
- _pauseCtr = 2;
-
- if (_G(thor)->health > 0) {
- _G(thor)->health--;
- play_sound(WOOP, 1);
- add_health(-1);
- add_score(10);
-
- } else if (_G(thor_info).magic > 0) {
- _G(thor_info).magic--;
- play_sound(WOOP, 1);
- add_magic(-1);
- add_score(10);
-
- } else if (_G(thor_info).jewels) {
- _G(thor_info).jewels--;
- play_sound(WOOP, 1);
- add_jewels(-1);
- add_score(10);
-
- } else {
- _G(gameMode) = MODE_NORMAL;
- _pauseCtr = 0;
- send(GameMessage("CLOSING"));
- }
- }
- break;
-
- default:
- break;
- }
-
- checkForAreaChange();
-
- // Check for end of game area
- if (_G(end_tile)) {
- _G(end_tile) = false;
- Gfx::fade_out();
-
- // Add name to high scores list if necessary, and then show it
- _G(highScores).add(_G(area), _G(playerName), _G(thor_info).score);
- g_events->send("HighScores", GameMessage("HIGH_SCORES", _G(area)));
- }
-
- return false;
+ checkThunderShake();
+
+ switch (_G(gameMode)) {
+ case MODE_NORMAL:
+ case MODE_THUNDER:
+ checkSwitchFlag();
+ checkForItem();
+ moveActors();
+ use_item();
+ updateActors();
+ checkForBossDead();
+ checkForCheats();
+
+ if (_G(endgame))
+ endgame_movement();
+ break;
+
+ case MODE_THOR_DIES:
+ if (_deathCtr < DEATH_THRESHOLD) {
+ spinThor();
+ } else if (_deathCtr < DEATH_THRESHOLD + 60) {
+ _G(thor)->used = 0;
+ ++_deathCtr;
+ } else {
+ thorDead();
+ }
+ break;
+
+ case MODE_LIGHTNING:
+ if (--_lightningCtr == 0) {
+ lightningCountdownDone();
+ }
+ break;
+
+ case MODE_PAUSE:
+ if (--_pauseCtr == 0)
+ _G(gameMode) = MODE_NORMAL;
+ break;
+
+ case MODE_SCORE_INV:
+ if (--_pauseCtr <= 0) {
+ _pauseCtr = 2;
+
+ if (_G(thor)->health > 0) {
+ _G(thor)->health--;
+ play_sound(WOOP, 1);
+ add_health(-1);
+ add_score(10);
+
+ } else if (_G(thor_info).magic > 0) {
+ _G(thor_info).magic--;
+ play_sound(WOOP, 1);
+ add_magic(-1);
+ add_score(10);
+
+ } else if (_G(thor_info).jewels) {
+ _G(thor_info).jewels--;
+ play_sound(WOOP, 1);
+ add_jewels(-1);
+ add_score(10);
+
+ } else {
+ _G(gameMode) = MODE_NORMAL;
+ _pauseCtr = 0;
+ send(GameMessage("CLOSING"));
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ checkForAreaChange();
+
+ // Check for end of game area
+ if (_G(end_tile)) {
+ _G(end_tile) = false;
+ Gfx::fade_out();
+
+ // Add name to high scores list if necessary, and then show it
+ _G(highScores).add(_G(area), _G(playerName), _G(thor_info).score);
+ g_events->send("HighScores", GameMessage("HIGH_SCORES", _G(area)));
+ }
+
+ return false;
}
void GameContent::drawBackground(GfxSurface &s) {
- for (int y = 0; y < TILES_Y; y++) {
- for (int x = 0; x < TILES_X; x++) {
- if (_G(scrn).icon[y][x] != 0) {
- const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
+ for (int y = 0; y < TILES_Y; y++) {
+ for (int x = 0; x < TILES_X; x++) {
+ if (_G(scrn).icon[y][x] != 0) {
+ const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
LEVEL screen = _G(scrn);
- s.simpleBlitFrom(_G(bgPics[screen.bg_color]), pt);
- s.simpleBlitFrom(_G(bgPics[screen.icon[y][x]]), pt);
- }
- }
- }
+ s.simpleBlitFrom(_G(bgPics[screen.bg_color]), pt);
+ s.simpleBlitFrom(_G(bgPics[screen.icon[y][x]]), pt);
+ }
+ }
+ }
}
void GameContent::drawObjects(GfxSurface &s) {
- for (int y = 0; y < TILES_Y; ++y) {
- for (int x = 0; x < TILES_X; ++x) {
- int p = (y * TILES_X) + x;
-
- byte currObjId = _G(object_map[p]);
- if (currObjId) {
- s.simpleBlitFrom(_G(objects[currObjId - 1]), Common::Point(x * TILE_SIZE, y * TILE_SIZE));
- }
- }
- }
+ for (int y = 0; y < TILES_Y; ++y) {
+ for (int x = 0; x < TILES_X; ++x) {
+ int p = (y * TILES_X) + x;
+
+ byte currObjId = _G(object_map[p]);
+ if (currObjId) {
+ s.simpleBlitFrom(_G(objects[currObjId - 1]), Common::Point(x * TILE_SIZE, y * TILE_SIZE));
+ }
+ }
+ }
}
void GameContent::drawActors(GfxSurface &s) {
- ACTOR *actor_ptr = &_G(actor[MAX_ACTORS - 1]);
- ACTOR *actor2_storage = nullptr;
-
- for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
- // Check for blinking flag
- if (actor_ptr->used && !(actor_ptr->show & 2)) {
- actor_ptr->last_x[_G(pge)] = actor_ptr->x;
- actor_ptr->last_y[_G(pge)] = actor_ptr->y;
-
- const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir][actor_ptr->frame_sequence[actor_ptr->next]];
- s.simpleBlitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
- }
-
- // Move to the next actor
- do {
- --actor_ptr;
- ++actor_num;
-
- if (actor_num == MAX_ACTORS)
- actor_ptr = actor2_storage;
- else if (actor_num == (MAX_ACTORS - 3))
- actor2_storage = actor_ptr;
- } while (actor_num == (MAX_ACTORS - 3));
- }
-
- if (_G(gameMode) == MODE_THOR_DIES && _deathCtr >= DEATH_THRESHOLD)
- s.simpleBlitFrom(_G(objects[10]), Common::Point(_G(thor)->x, _G(thor)->y));
+ ACTOR *actor_ptr = &_G(actor[MAX_ACTORS - 1]);
+ ACTOR *actor2_storage = nullptr;
+
+ for (int actor_num = 0; actor_num <= MAX_ACTORS;) {
+ // Check for blinking flag
+ if (actor_ptr->used && !(actor_ptr->show & 2)) {
+ actor_ptr->last_x[_G(pge)] = actor_ptr->x;
+ actor_ptr->last_y[_G(pge)] = actor_ptr->y;
+
+ const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir][actor_ptr->frame_sequence[actor_ptr->next]];
+ s.simpleBlitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
+ }
+
+ // Move to the next actor
+ do {
+ --actor_ptr;
+ ++actor_num;
+
+ if (actor_num == MAX_ACTORS)
+ actor_ptr = actor2_storage;
+ else if (actor_num == (MAX_ACTORS - 3))
+ actor2_storage = actor_ptr;
+ } while (actor_num == (MAX_ACTORS - 3));
+ }
+
+ if (_G(gameMode) == MODE_THOR_DIES && _deathCtr >= DEATH_THRESHOLD)
+ s.simpleBlitFrom(_G(objects[10]), Common::Point(_G(thor)->x, _G(thor)->y));
}
void GameContent::drawBossHealth(GfxSurface &s) {
- int c;
+ int c;
- int health = _G(actor[3]).health;
+ int health = _G(actor[3]).health;
- s.fillRect(Common::Rect(304, 2, 317, 81), 0);
- s.fillRect(Common::Rect(305, 3, 316, 80), 28);
- s.fillRect(Common::Rect(306, 4, 315, 79), 26);
- s.fillRect(Common::Rect(307, 5, 314, 78), 24);
+ s.fillRect(Common::Rect(304, 2, 317, 81), 0);
+ s.fillRect(Common::Rect(305, 3, 316, 80), 28);
+ s.fillRect(Common::Rect(306, 4, 315, 79), 26);
+ s.fillRect(Common::Rect(307, 5, 314, 78), 24);
- for (int i = 10; i > 0; i--) {
- if (i * 10 > health)
- c = 0;
- else
- c = 32;
+ for (int i = 10; i > 0; i--) {
+ if (i * 10 > health)
+ c = 0;
+ else
+ c = 32;
- s.fillRect(Common::Rect(308, 7 + (7 * (10 - i)), 313, 13 + (7 * (10 - i))), c);
- }
+ s.fillRect(Common::Rect(308, 7 + (7 * (10 - i)), 313, 13 + (7 * (10 - i))), c);
+ }
}
void GameContent::checkThunderShake() {
- if (_G(thunder_flag)) {
- _G(gameMode) = MODE_THUNDER;
+ if (_G(thunder_flag)) {
+ _G(gameMode) = MODE_THUNDER;
- // Introduce a random screen shake by rendering screen 1 pixel offset randomly
- static const int8 DELTA_X[4] = { -1, 1, 0, 0 };
- static const int8 DELTA_Y[4] = { 0, 0, -1, 1 };
- int delta = g_events->getRandomNumber(3);
+ // Introduce a random screen shake by rendering screen 1 pixel offset randomly
+ static const int8 DELTA_X[4] = {-1, 1, 0, 0};
+ static const int8 DELTA_Y[4] = {0, 0, -1, 1};
+ int delta = g_events->getRandomNumber(3);
- _moveDelta.x = DELTA_X[delta];
- _moveDelta.y = DELTA_Y[delta];
+ _moveDelta.x = DELTA_X[delta];
+ _moveDelta.y = DELTA_Y[delta];
- _G(thunder_flag)--;
- if ((_G(thunder_flag) < MAX_ACTORS) && _G(thunder_flag) > 2) {
+ _G(thunder_flag--);
+ if ((_G(thunder_flag) < MAX_ACTORS) && _G(thunder_flag) > 2) {
int thunderFl = _G(thunder_flag);
if (_G(actor[thunderFl]).used) {
_G(actor[thunderFl]).vunerable = 0;
actor_damaged(&_G(actor[thunderFl]), 20);
- }
- }
+ }
+ }
- if (!_G(thunder_flag)) {
- _G(gameMode) = MODE_NORMAL;
- _moveDelta = Common::Point(0, 0);
- }
+ if (!_G(thunder_flag)) {
+ _G(gameMode) = MODE_NORMAL;
+ _moveDelta = Common::Point(0, 0);
+ }
- redraw();
- }
+ redraw();
+ }
}
void GameContent::checkSwitchFlag() {
- if (_G(switch_flag)) {
- switch (_G(switch_flag)) {
- case 1:
- switch_icons();
- break;
- case 2:
- rotate_arrows();
- break;
- default:
- break;
- }
-
- _G(switch_flag) = 0;
- }
+ if (_G(switch_flag)) {
+ switch (_G(switch_flag)) {
+ case 1:
+ switch_icons();
+ break;
+ case 2:
+ rotate_arrows();
+ break;
+ default:
+ break;
+ }
+
+ _G(switch_flag) = 0;
+ }
}
void GameContent::checkForItem() {
- int thor_pos = _G(thor)->getPos();
- if (_G(object_map[thor_pos]))
- pick_up_object(thor_pos);
+ int thor_pos = _G(thor)->getPos();
+ if (_G(object_map[thor_pos]))
+ pick_up_object(thor_pos);
}
void GameContent::moveActors() {
- for (int i = 0; i < MAX_ACTORS; i++) {
- if (_G(actor[i]).used) {
- if (_G(hourglass_flag))
- if ((i > 2) && (!_G(pge)) && (!(_G(actor[i]).magic_hurts & LIGHTNING_MAGIC)))
- continue;
-
- _G(actor[i]).move_count = _G(actor[i]).num_moves;
- while (_G(actor[i]).move_count--)
- move_actor(&_G(actor[i]));
-
- if (i == 0)
- set_thor_vars();
-
- if (_G(new_level) != _G(current_level))
- return;
- }
- }
-
- int thor_pos = _G(thor)->getPos();
- _G(thor)->center_x = thor_pos % 20;
- _G(thor)->center_y = thor_pos / 20;
+ for (int i = 0; i < MAX_ACTORS; i++) {
+ if (_G(actor[i]).used) {
+ if (_G(hourglass_flag))
+ if ((i > 2) && (!_G(pge)) && (!(_G(actor[i]).magic_hurts & LIGHTNING_MAGIC)))
+ continue;
+
+ _G(actor[i]).move_count = _G(actor[i]).num_moves;
+ while (_G(actor[i]).move_count--)
+ move_actor(&_G(actor[i]));
+
+ if (i == 0)
+ set_thor_vars();
+
+ if (_G(new_level) != _G(current_level))
+ return;
+ }
+ }
+
+ int thor_pos = _G(thor)->getPos();
+ _G(thor)->center_x = thor_pos % 20;
+ _G(thor)->center_y = thor_pos / 20;
}
void GameContent::updateActors() {
- for (int i = 0; i < MAX_ACTORS; ++i) {
- ACTOR *actor = &_G(actor[i]);
+ for (int i = 0; i < MAX_ACTORS; ++i) {
+ ACTOR *actor = &_G(actor[i]);
- if (!actor->used && actor->dead > 0)
- actor->dead--;
- }
+ if (!actor->used && actor->dead > 0)
+ actor->dead--;
+ }
}
void GameContent::checkForBossDead() {
- int loop;
-
- if (_G(boss_dead)) {
- for (loop = 3; loop < 7; loop++) {
- if (_G(actor[loop]).used)
- break;
- }
-
- if (loop == 7) {
- _G(boss_dead) = false;
-
- _G(exit_flag) = 0;
-
- if (_G(boss_active)) {
- switch (_G(area)) {
- case 1:
- closing_sequence1();
- break;
- case 2:
- closing_sequence2();
- break;
- case 3:
- closing_sequence3();
- break;
- default:
- break;
- }
-
- _G(boss_active) = false;
- }
- }
- }
+ int loop;
+
+ if (_G(boss_dead)) {
+ for (loop = 3; loop < 7; loop++) {
+ if (_G(actor[loop]).used)
+ break;
+ }
+
+ if (loop == 7) {
+ _G(boss_dead) = false;
+
+ _G(exit_flag) = 0;
+
+ if (_G(boss_active)) {
+ switch (_G(area)) {
+ case 1:
+ closing_sequence1();
+ break;
+ case 2:
+ closing_sequence2();
+ break;
+ case 3:
+ closing_sequence3();
+ break;
+ default:
+ break;
+ }
+
+ _G(boss_active) = false;
+ }
+ }
+ }
}
void GameContent::checkForAreaChange() {
- if (_G(gameMode) == MODE_AREA_CHANGE) {
- // Area transition is already in progress
- switch (_G(transitionDir)) {
- case DIR_LEFT:
- case DIR_RIGHT:
- _transitionPos += 32;
- if (_transitionPos == 320)
- _G(gameMode) = MODE_NORMAL;
- break;
- case DIR_UP:
- case DIR_DOWN:
- _transitionPos += 16;
- if (_transitionPos == 192)
- _G(gameMode) = MODE_NORMAL;
- break;
- case DIR_PHASED:
- _transitionPos += 10;
- if (_transitionPos == 240) {
- _G(gameMode) = MODE_NORMAL;
- Common::fill(_phased, _phased + 240, false);
- } else {
- // The screen is subdivided into 240 16x16 blocks. Picks ones
- // randomly to copy over from the new screen
- for (int i = 0; i < 10; ++i) {
- for (;;) {
- int idx = g_events->getRandomNumber(239);
- if (!_phased[idx]) {
- _phased[idx] = true;
- break;
- }
- }
- }
- }
- break;
-
- default:
- break;
- }
-
- if (_G(gameMode) == MODE_NORMAL) {
- _transitionPos = 0;
- show_level_done();
- }
-
- } else if (_G(new_level) != _G(current_level)) {
- // Area transition beginning
- _G(thor)->show = 0;
- _G(thor)->used = 0;
- _G(hammer)->used = 0;
- _G(tornado_used) = false;
-
- // Draws the old area without Thor, and then save a copy of it.
- // This will be used to scroll old area off-screen as new area scrolls in
- draw();
- _surface.copyFrom(getSurface());
-
- // Set up new level
- _G(thor)->used = 1;
- show_level(_G(new_level));
- }
+ if (_G(gameMode) == MODE_AREA_CHANGE) {
+ // Area transition is already in progress
+ switch (_G(transitionDir)) {
+ case DIR_LEFT:
+ case DIR_RIGHT:
+ _transitionPos += 32;
+ if (_transitionPos == 320)
+ _G(gameMode) = MODE_NORMAL;
+ break;
+ case DIR_UP:
+ case DIR_DOWN:
+ _transitionPos += 16;
+ if (_transitionPos == 192)
+ _G(gameMode) = MODE_NORMAL;
+ break;
+ case DIR_PHASED:
+ _transitionPos += 10;
+ if (_transitionPos == 240) {
+ _G(gameMode) = MODE_NORMAL;
+ Common::fill(_phased, _phased + 240, false);
+ } else {
+ // The screen is subdivided into 240 16x16 blocks. Picks ones
+ // randomly to copy over from the new screen
+ for (int i = 0; i < 10; ++i) {
+ for (;;) {
+ int idx = g_events->getRandomNumber(239);
+ if (!_phased[idx]) {
+ _phased[idx] = true;
+ break;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (_G(gameMode) == MODE_NORMAL) {
+ _transitionPos = 0;
+ show_level_done();
+ }
+
+ } else if (_G(new_level) != _G(current_level)) {
+ // Area transition beginning
+ _G(thor)->show = 0;
+ _G(thor)->used = 0;
+ _G(hammer)->used = 0;
+ _G(tornado_used) = false;
+
+ // Draws the old area without Thor, and then save a copy of it.
+ // This will be used to scroll old area off-screen as new area scrolls in
+ draw();
+ _surface.copyFrom(getSurface());
+
+ // Set up new level
+ _G(thor)->used = 1;
+ show_level(_G(new_level));
+ }
}
void GameContent::thorDies() {
- if (_G(gameMode) == MODE_SCORE_INV)
- return;
+ if (_G(gameMode) == MODE_SCORE_INV)
+ return;
- // Stop any actors on-screen from moving
- for (int li = 0; li < MAX_ACTORS; li++)
- _G(actor[li]).show = 0;
- _G(actor[2]).used = 0;
+ // Stop any actors on-screen from moving
+ for (int li = 0; li < MAX_ACTORS; li++)
+ _G(actor[li]).show = 0;
+ _G(actor[2]).used = 0;
- // Set the state for showing death animation
- _G(gameMode) = MODE_THOR_DIES;
- _deathCtr = 0;
- _G(shield_on) = false;
+ // Set the state for showing death animation
+ _G(gameMode) = MODE_THOR_DIES;
+ _deathCtr = 0;
+ _G(shield_on) = false;
- play_sound(DEAD, 1);
+ play_sound(DEAD, 1);
}
void GameContent::spinThor() {
- static const byte DIRS[] = { 0,2,1,3 };
+ static const byte DIRS[] = {0, 2, 1, 3};
- _G(thor)->dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
- _G(thor)->last_dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
+ _G(thor)->dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
+ _G(thor)->last_dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
- ++_deathCtr;
+ ++_deathCtr;
}
void GameContent::thorDead() {
- int li = _G(thor_info).item;
- int ln = _G(thor_info).inventory;
-
- _G(new_level) = _G(thor_info).last_screen;
- _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
- _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
- if (_G(thor)->x < 1) _G(thor)->x = 1;
- if (_G(thor)->y < 0) _G(thor)->y = 0;
- _G(thor)->last_x[0] = _G(thor)->x;
- _G(thor)->last_x[1] = _G(thor)->x;
- _G(thor)->last_y[0] = _G(thor)->y;
- _G(thor)->last_y[1] = _G(thor)->y;
- _G(thor)->dir = _G(thor_info).last_dir;
- _G(thor)->last_dir = _G(thor_info).last_dir;
- _G(thor)->health = _G(thor_info).last_health;
- _G(thor_info).magic = _G(thor_info).last_magic;
- _G(thor_info).jewels = _G(thor_info).last_jewels;
- _G(thor_info).keys = _G(thor_info).last_keys;
- _G(thor_info).score = _G(thor_info).last_score;
- _G(thor_info).object = _G(thor_info).last_object;
- _G(thor_info).object_name = _G(thor_info).last_object_name;
-
- if (ln == _G(thor_info).last_inventory) {
- _G(thor_info).item = li;
- } else {
- _G(thor_info).item = _G(thor_info).last_item;
- _G(thor_info).inventory = _G(thor_info).last_inventory;
- }
-
- _G(setup) = _G(last_setup);
-
- _G(thor)->num_moves = 1;
- _G(thor)->vunerable = 60;
- _G(thor)->show = 60;
- _G(hourglass_flag) = 0;
- _G(apple_flag) = false;
- _G(bomb_flag) = false;
- _G(thunder_flag) = 0;
- _G(lightning_used) = false;
- _G(tornado_used) = false;
- _G(shield_on) = false;
- music_resume();
- _G(actor[1]).used = 0;
- _G(actor[2]).used = 0;
- _G(thor)->speed_count = 6;
- _G(thor)->used = 1;
-
- // Load saved data for new level back into scrn
- _G(scrn).load(_G(new_level));
-
- _G(gameMode) = MODE_NORMAL;
- _deathCtr = 0;
-
- show_level(_G(new_level));
- set_thor_vars();
+ int li = _G(thor_info).item;
+ int ln = _G(thor_info).inventory;
+
+ _G(new_level) = _G(thor_info).last_screen;
+ _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+ _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+ if (_G(thor)->x < 1)
+ _G(thor)->x = 1;
+ if (_G(thor)->y < 0)
+ _G(thor)->y = 0;
+ _G(thor)->last_x[0] = _G(thor)->x;
+ _G(thor)->last_x[1] = _G(thor)->x;
+ _G(thor)->last_y[0] = _G(thor)->y;
+ _G(thor)->last_y[1] = _G(thor)->y;
+ _G(thor)->dir = _G(thor_info).last_dir;
+ _G(thor)->last_dir = _G(thor_info).last_dir;
+ _G(thor)->health = _G(thor_info).last_health;
+ _G(thor_info).magic = _G(thor_info).last_magic;
+ _G(thor_info).jewels = _G(thor_info).last_jewels;
+ _G(thor_info).keys = _G(thor_info).last_keys;
+ _G(thor_info).score = _G(thor_info).last_score;
+ _G(thor_info).object = _G(thor_info).last_object;
+ _G(thor_info).object_name = _G(thor_info).last_object_name;
+
+ if (ln == _G(thor_info).last_inventory) {
+ _G(thor_info).item = li;
+ } else {
+ _G(thor_info).item = _G(thor_info).last_item;
+ _G(thor_info).inventory = _G(thor_info).last_inventory;
+ }
+
+ _G(setup) = _G(last_setup);
+
+ _G(thor)->num_moves = 1;
+ _G(thor)->vunerable = 60;
+ _G(thor)->show = 60;
+ _G(hourglass_flag) = 0;
+ _G(apple_flag) = false;
+ _G(bomb_flag) = false;
+ _G(thunder_flag) = 0;
+ _G(lightning_used) = false;
+ _G(tornado_used) = false;
+ _G(shield_on) = false;
+ music_resume();
+ _G(actor[1]).used = 0;
+ _G(actor[2]).used = 0;
+ _G(thor)->speed_count = 6;
+ _G(thor)->used = 1;
+
+ // Load saved data for new level back into scrn
+ _G(scrn).load(_G(new_level));
+
+ _G(gameMode) = MODE_NORMAL;
+ _deathCtr = 0;
+
+ show_level(_G(new_level));
+ set_thor_vars();
}
void GameContent::checkForCheats() {
- if (_G(cheats).freezeHealth)
- _G(thor)->health = 150;
- if (_G(cheats).freezeMagic)
- _G(thor_info).magic = 150;
- if (_G(cheats).freezeJewels)
- _G(thor_info).jewels = 999;
+ if (_G(cheats).freezeHealth)
+ _G(thor)->health = 150;
+ if (_G(cheats).freezeMagic)
+ _G(thor_info).magic = 150;
+ if (_G(cheats).freezeJewels)
+ _G(thor_info).jewels = 999;
}
-
void GameContent::placePixel(GfxSurface &s, int dir, int num) {
- switch (dir) {
- case 0:
- _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] +
- (1 - (g_events->getRandomNumber(2)));
- break;
- case 1:
- if (g_events->getRandomNumber(1)) {
- _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
- } else {
- _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
- }
- break;
- case 2:
- _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
- break;
- case 3:
- if (g_events->getRandomNumber(1)) {
- _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
- } else {
- _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
- }
- break;
- case 4:
- _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
- break;
- case 5:
- if (g_events->getRandomNumber(1)) {
- _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
- } else {
- _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
- }
- break;
- case 6:
- _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
- break;
- case 7:
- if (g_events->getRandomNumber(1)) {
- _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
- _pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
- } else {
- _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
- _pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
- }
- break;
- default:
- return;
- }
-
- if (point_within(_pixelX[dir][num], _pixelY[dir][num], 0, 0, 319, 191)) {
- byte *pixel = (byte *)s.getBasePtr(_pixelX[dir][num],
- _pixelY[dir][num]);
- *pixel = _pixelC[dir];
- }
+ switch (dir) {
+ case 0:
+ _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] +
+ (1 - (g_events->getRandomNumber(2)));
+ break;
+ case 1:
+ if (g_events->getRandomNumber(1)) {
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+ } else {
+ _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+ }
+ break;
+ case 2:
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+ break;
+ case 3:
+ if (g_events->getRandomNumber(1)) {
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+ } else {
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+ }
+ break;
+ case 4:
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+ break;
+ case 5:
+ if (g_events->getRandomNumber(1)) {
+ _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+ } else {
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+ }
+ break;
+ case 6:
+ _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+ break;
+ case 7:
+ if (g_events->getRandomNumber(1)) {
+ _pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+ _pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+ } else {
+ _pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+ _pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+ }
+ break;
+ default:
+ return;
+ }
+
+ if (point_within(_pixelX[dir][num], _pixelY[dir][num], 0, 0, 319, 191)) {
+ byte *pixel = (byte *)s.getBasePtr(_pixelX[dir][num],
+ _pixelY[dir][num]);
+ *pixel = _pixelC[dir];
+ }
}
void GameContent::throwLightning() {
- _G(gameMode) = MODE_LIGHTNING;
- _lightningCtr = 20;
+ _G(gameMode) = MODE_LIGHTNING;
+ _lightningCtr = 20;
- for (int i = 0; i < MAX_ACTORS; i++)
- _G(actor[i]).show = 0;
+ for (int i = 0; i < MAX_ACTORS; i++)
+ _G(actor[i]).show = 0;
- play_sound(ELECTRIC, 1);
+ play_sound(ELECTRIC, 1);
}
void GameContent::drawLightning(GfxSurface &s) {
- for (int i = 0; i < 8; i++) {
- _pixelX[i][0] = _G(thor)->x + 7;
- _pixelY[i][0] = _G(thor)->y + 7;
- _pixelC[i] = 14 + g_events->getRandomNumber(1);
- }
-
- for (int r = 0; r < 8; r++) {
- for (int i = 1; i < 25; i++) {
- placePixel(s, r, i);
- }
- }
+ for (int i = 0; i < 8; i++) {
+ _pixelX[i][0] = _G(thor)->x + 7;
+ _pixelY[i][0] = _G(thor)->y + 7;
+ _pixelC[i] = 14 + g_events->getRandomNumber(1);
+ }
+
+ for (int r = 0; r < 8; r++) {
+ for (int i = 1; i < 25; i++) {
+ placePixel(s, r, i);
+ }
+ }
}
void GameContent::lightningCountdownDone() {
- int x, y, i, ax, ay;
- _G(gameMode) = MODE_NORMAL;
+ int x, y, i, ax, ay;
+ _G(gameMode) = MODE_NORMAL;
- x = _G(thor)->x + 7;
- y = _G(thor)->y + 7;
+ x = _G(thor)->x + 7;
+ y = _G(thor)->y + 7;
- for (i = 3; i < MAX_ACTORS; i++) {
- if (!_G(actor[i]).used)
- continue;
+ for (i = 3; i < MAX_ACTORS; i++) {
+ if (!_G(actor[i]).used)
+ continue;
- ax = _G(actor[i]).x + (_G(actor[i]).size_x / 2);
- ay = _G(actor[i]).y + (_G(actor[i]).size_y / 2);
+ ax = _G(actor[i]).x + (_G(actor[i]).size_x / 2);
+ ay = _G(actor[i]).y + (_G(actor[i]).size_y / 2);
- if ((ABS(ax - x) < 30) && (ABS(ay - y) < 30)) {
- _G(actor[i]).magic_hit = 1;
- _G(actor[i]).vunerable = 0;
- actor_damaged(&_G(actor[i]), 254);
- }
- }
+ if ((ABS(ax - x) < 30) && (ABS(ay - y) < 30)) {
+ _G(actor[i]).magic_hit = 1;
+ _G(actor[i]).vunerable = 0;
+ actor_damaged(&_G(actor[i]), 254);
+ }
+ }
}
void GameContent::closingSequence() {
- const int area = _G(area);
-
- switch (++_closingStateCtr) {
- case 1:
- // Convert health/magic/jewels to score
- _G(gameMode) = MODE_SCORE_INV;
- break;
-
- case 2:
- switch (area) {
- case 1:
- closing_sequence1_2();
- break;
- case 2:
- closing_sequence2_2();
- break;
- case 3:
- closing_sequence3_2();
- break;
- default:
- break;
- }
- break;
-
- case 3:
- switch (area) {
- case 1:
- closing_sequence1_3();
- break;
- case 2:
- closing_sequence2_3();
- break;
- case 3:
- closing_sequence3_3();
- break;
- default:
- break;
- }
- break;
-
- case 4:
- _closingStateCtr = 0;
-
- switch (area) {
- case 1:
- closing_sequence1_4();
- break;
- case 2:
- closing_sequence2_4();
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- }
+ const int area = _G(area);
+
+ switch (++_closingStateCtr) {
+ case 1:
+ // Convert health/magic/jewels to score
+ _G(gameMode) = MODE_SCORE_INV;
+ break;
+
+ case 2:
+ switch (area) {
+ case 1:
+ closing_sequence1_2();
+ break;
+ case 2:
+ closing_sequence2_2();
+ break;
+ case 3:
+ closing_sequence3_2();
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 3:
+ switch (area) {
+ case 1:
+ closing_sequence1_3();
+ break;
+ case 2:
+ closing_sequence2_3();
+ break;
+ case 3:
+ closing_sequence3_3();
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 4:
+ _closingStateCtr = 0;
+
+ switch (area) {
+ case 1:
+ closing_sequence1_4();
+ break;
+ case 2:
+ closing_sequence2_4();
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
}
} // namespace Views
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 342858a3e39..605498b6b5f 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -22,55 +22,55 @@
#ifndef GOT_VIEWS_GAME_CONTENT_H
#define GOT_VIEWS_GAME_CONTENT_H
-#include "got/views/view.h"
#include "got/data/defines.h"
+#include "got/views/view.h"
namespace Got {
namespace Views {
class GameContent : public View {
private:
- GfxSurface _surface;
- Common::Point _moveDelta;
- int _transitionPos = 0;
- int _deathCtr = 0;
- bool _phased[240] = {};
- int _lightningCtr = 0;
- int _pixelX[8][25] = {};
- int _pixelY[8][25] = {};
- byte _pixelP[8][25] = {};
- byte _pixelC[8] = {};
- int _pauseCtr = 0;
- int _closingStateCtr = 0;
+ GfxSurface _surface;
+ Common::Point _moveDelta;
+ int _transitionPos = 0;
+ int _deathCtr = 0;
+ bool _phased[240] = {};
+ int _lightningCtr = 0;
+ int _pixelX[8][25] = {};
+ int _pixelY[8][25] = {};
+ byte _pixelP[8][25] = {};
+ byte _pixelC[8] = {};
+ int _pauseCtr = 0;
+ int _closingStateCtr = 0;
- void drawBackground(GfxSurface &s);
- void drawObjects(GfxSurface &s);
- void drawActors(GfxSurface &s);
- void drawBossHealth(GfxSurface &s);
- void drawLightning(GfxSurface &s);
- void placePixel(GfxSurface &s, int dir, int num);
- void checkThunderShake();
- void checkSwitchFlag();
- void checkForItem();
- void moveActors();
- void updateActors();
- void checkForBossDead();
- void checkForAreaChange();
- void thorDies();
- void spinThor();
- void thorDead();
- void checkForCheats();
- void throwLightning();
- void lightningCountdownDone();
- void closingSequence();
+ void drawBackground(GfxSurface &s);
+ void drawObjects(GfxSurface &s);
+ void drawActors(GfxSurface &s);
+ void drawBossHealth(GfxSurface &s);
+ void drawLightning(GfxSurface &s);
+ void placePixel(GfxSurface &s, int dir, int num);
+ void checkThunderShake();
+ void checkSwitchFlag();
+ void checkForItem();
+ void moveActors();
+ void updateActors();
+ void checkForBossDead();
+ void checkForAreaChange();
+ void thorDies();
+ void spinThor();
+ void thorDead();
+ void checkForCheats();
+ void throwLightning();
+ void lightningCountdownDone();
+ void closingSequence();
public:
- GameContent();
- virtual ~GameContent() {}
+ GameContent();
+ virtual ~GameContent() {}
- void draw() override;
- bool msgGame(const GameMessage &msg) override;
- bool tick() override;
+ void draw() override;
+ bool msgGame(const GameMessage &msg) override;
+ bool tick() override;
};
} // namespace Views
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index 14d2ba925e7..e889412f0fb 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -30,109 +30,110 @@ namespace Views {
#define SCORE_INTERVAL 5
void GameStatus::draw() {
- GfxSurface s = getSurface();
-
- // Draw the status background
- const Graphics::ManagedSurface &status = _G(status)[0];
- s.simpleBlitFrom(status);
-
- // Draw the elements
- displayHealth(s);
- displayMagic(s);
- displayJewels(s);
- displayScore(s);
- displayKeys(s);
- displayItem(s);
+ GfxSurface s = getSurface();
+
+ // Draw the status background
+ const Graphics::ManagedSurface &status = _G(status[0]);
+ s.simpleBlitFrom(status);
+
+ // Draw the elements
+ displayHealth(s);
+ displayMagic(s);
+ displayJewels(s);
+ displayScore(s);
+ displayKeys(s);
+ displayItem(s);
}
void GameStatus::displayHealth(GfxSurface &s) {
- int b = 59 + _G(thor)->health;
+ int b = 59 + _G(thor)->health;
- s.fillRect(Common::Rect(59, 8, b, 12), 32);
- s.fillRect(Common::Rect(b, 8, 209, 12), STAT_COLOR);
+ s.fillRect(Common::Rect(59, 8, b, 12), 32);
+ s.fillRect(Common::Rect(b, 8, 209, 12), STAT_COLOR);
}
void GameStatus::displayMagic(GfxSurface &s) {
- int b = 59 + _G(thor_info).magic;
+ int b = 59 + _G(thor_info).magic;
- s.fillRect(Common::Rect(59, 20, b, 24), 96);
- s.fillRect(Common::Rect(b, 20, 209, 24), STAT_COLOR);
+ s.fillRect(Common::Rect(59, 20, b, 24), 96);
+ s.fillRect(Common::Rect(b, 20, 209, 24), STAT_COLOR);
}
void GameStatus::displayJewels(GfxSurface &s) {
- Common::String str = Common::String::format("%d", _G(thor_info).jewels);
- int x;
- if (str.size() == 1)
- x = 70;
- else if (str.size() == 2)
- x = 66;
- else
- x = 62;
-
- s.fillRect(Common::Rect(59, 32, 85, 42), STAT_COLOR);
- s.print(Common::Point(x, 32), str, 14);
+ Common::String str = Common::String::format("%d", _G(thor_info).jewels);
+ int x;
+ if (str.size() == 1)
+ x = 70;
+ else if (str.size() == 2)
+ x = 66;
+ else
+ x = 62;
+
+ s.fillRect(Common::Rect(59, 32, 85, 42), STAT_COLOR);
+ s.print(Common::Point(x, 32), str, 14);
}
void GameStatus::displayScore(GfxSurface &s) {
- Common::String str = Common::String::format("%ld", _G(thor_info).score);
- int x = 276 - (str.size() * 8);
+ Common::String str = Common::String::format("%ld", _G(thor_info).score);
+ int x = 276 - (str.size() * 8);
- s.fillRect(Common::Rect(223, 32, 279, 42), STAT_COLOR);
- s.print(Common::Point(x, 32), str, 14);
+ s.fillRect(Common::Rect(223, 32, 279, 42), STAT_COLOR);
+ s.print(Common::Point(x, 32), str, 14);
}
void GameStatus::displayKeys(GfxSurface &s) {
- Common::String str = Common::String::format("%d", _G(thor_info).keys);
-
- int x;
- if (str.size() == 1)
- x = 150;
- else if (str.size() == 2)
- x = 146;
- else
- x = 142;
-
- s.fillRect(Common::Rect(139, 32, 164, 42), STAT_COLOR);
- s.print(Common::Point(x, 32), str, 14);
+ Common::String str = Common::String::format("%d", _G(thor_info).keys);
+
+ int x;
+ if (str.size() == 1)
+ x = 150;
+ else if (str.size() == 2)
+ x = 146;
+ else
+ x = 142;
+
+ s.fillRect(Common::Rect(139, 32, 164, 42), STAT_COLOR);
+ s.print(Common::Point(x, 32), str, 14);
}
void GameStatus::displayItem(GfxSurface &s) {
- s.fillRect(Common::Rect(280, 8, 296, 24), STAT_COLOR);
-
- if (_G(thor_info).item) {
- if (_G(thor_info).item == 7)
- s.simpleBlitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(280, 8));
- else
- s.simpleBlitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(280, 8));
- }
+ s.fillRect(Common::Rect(280, 8, 296, 24), STAT_COLOR);
+
+ THOR_INFO thorInfo = _G(thor_info);
+ if (thorInfo.item) {
+ if (thorInfo.item == 7)
+ s.simpleBlitFrom(_G(objects[thorInfo.object + 10]), Common::Point(280, 8));
+ else
+ s.simpleBlitFrom(_G(objects[thorInfo.item + 25]), Common::Point(280, 8));
+ }
}
bool GameStatus::msgGame(const GameMessage &msg) {
- if (msg._name == "FILL_SCORE") {
- _G(gameMode) = MODE_ADD_SCORE;
- _scoreCountdown = msg._value * SCORE_INTERVAL;
- _endMessage = msg._stringValue;
- return true;
- }
-
- return false;
+ if (msg._name == "FILL_SCORE") {
+ _G(gameMode) = MODE_ADD_SCORE;
+ _scoreCountdown = msg._value * SCORE_INTERVAL;
+ _endMessage = msg._stringValue;
+ return true;
+ }
+
+ return false;
}
bool GameStatus::tick() {
- if (_scoreCountdown > 0) {
- if ((_scoreCountdown % SCORE_INTERVAL) == 0) {
- _G(sound).play_sound(WOOP, 1);
- add_score(1000);
- }
-
- if (--_scoreCountdown == 0) {
- _G(gameMode) = MODE_NORMAL;
- if (!_endMessage.empty())
- g_events->send(GameMessage(_endMessage));
- }
- }
-
- return false;
+ if (_scoreCountdown > 0) {
+ if ((_scoreCountdown % SCORE_INTERVAL) == 0) {
+ _G(sound).play_sound(WOOP, 1);
+ add_score(1000);
+ }
+
+ if (--_scoreCountdown == 0) {
+ _G(gameMode) = MODE_NORMAL;
+ if (!_endMessage.empty())
+ g_events->send(GameMessage(_endMessage));
+ }
+ }
+
+ return false;
}
} // namespace Views
diff --git a/engines/got/views/game_status.h b/engines/got/views/game_status.h
index eb775d9b81f..d48c2095c97 100644
--- a/engines/got/views/game_status.h
+++ b/engines/got/views/game_status.h
@@ -29,23 +29,23 @@ namespace Views {
class GameStatus : public View {
private:
- int _scoreCountdown = 0;
- Common::String _endMessage;
+ int _scoreCountdown = 0;
+ Common::String _endMessage;
- void displayHealth(GfxSurface &s);
- void displayMagic(GfxSurface &s);
- void displayJewels(GfxSurface &s);
- void displayScore(GfxSurface &s);
- void displayKeys(GfxSurface &s);
- void displayItem(GfxSurface &s);
+ void displayHealth(GfxSurface &s);
+ void displayMagic(GfxSurface &s);
+ void displayJewels(GfxSurface &s);
+ void displayScore(GfxSurface &s);
+ void displayKeys(GfxSurface &s);
+ void displayItem(GfxSurface &s);
public:
- GameStatus() : View("GameStatus") {}
- virtual ~GameStatus() {}
+ GameStatus() : View("GameStatus") {}
+ virtual ~GameStatus() {}
- void draw() override;
- bool msgGame(const GameMessage &msg) override;
- bool tick() override;
+ void draw() override;
+ bool msgGame(const GameMessage &msg) override;
+ bool tick() override;
};
} // namespace Views
More information about the Scummvm-git-logs
mailing list