aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
Diffstat (limited to 'sword2')
-rw-r--r--sword2/build_display.cpp64
-rw-r--r--sword2/controls.cpp5
-rw-r--r--sword2/debug.cpp30
-rw-r--r--sword2/function.cpp4
-rw-r--r--sword2/layers.cpp57
-rw-r--r--sword2/layers.h6
-rw-r--r--sword2/mouse.cpp84
-rw-r--r--sword2/save_rest.cpp24
-rw-r--r--sword2/scroll.cpp50
-rw-r--r--sword2/speech.cpp41
-rw-r--r--sword2/sword2.cpp4
-rw-r--r--sword2/sword2.h8
12 files changed, 191 insertions, 186 deletions
diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp
index c6ede1aaef..3f24d30278 100644
--- a/sword2/build_display.cpp
+++ b/sword2/build_display.cpp
@@ -42,7 +42,7 @@ void Sword2Engine::buildDisplay(void) {
uint8 *file;
_multiScreenHeader *screenLayerTable;
- if (this_screen.new_palette) {
+ if (_thisScreen.new_palette) {
// start the layer palette fading up
startNewPalette();
@@ -52,9 +52,9 @@ void Sword2Engine::buildDisplay(void) {
}
// there is a valid screen to run
- if (this_screen.background_layer_id) {
+ if (_thisScreen.background_layer_id) {
// set the scroll position
- g_display->setScrollTarget(this_screen.scroll_offset_x, this_screen.scroll_offset_y);
+ g_display->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
// increment the mouse frame
g_display->animateMouse();
@@ -72,44 +72,44 @@ void Sword2Engine::buildDisplay(void) {
// first background parallax + related anims
// open the screen resource
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[0]) {
g_display->renderParallax(FetchBackgroundParallaxLayer(file, 0), 0);
// release the screen resource before cacheing
// the sprites
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
sendBackPar0Frames();
} else {
// release the screen resource
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
// second background parallax + related anims
// open the screen resource
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[1]) {
g_display->renderParallax(FetchBackgroundParallaxLayer(file, 1), 1);
// release the screen resource before cacheing
// the sprites
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
sendBackPar1Frames();
} else {
// release the screen resource
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
// normal backround layer (just the one!)
// open the screen resource
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
g_display->renderParallax(FetchBackgroundLayer(file), 2);
// release the screen resource
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
// sprites & layers
@@ -121,35 +121,35 @@ void Sword2Engine::buildDisplay(void) {
// first foreground parallax + related anims
// open the screen resource
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[0]) {
g_display->renderParallax(FetchForegroundParallaxLayer(file, 0), 3);
// release the screen resource before cacheing
// the sprites
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
sendForePar0Frames();
} else {
// release the screen resource
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
// second foreground parallax + related anims
// open the screen resource
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[1]) {
g_display->renderParallax(FetchForegroundParallaxLayer(file, 1), 4);
// release the screen resource before cacheing
// the sprites
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
sendForePar1Frames();
} else {
// release the screen resource
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
// walkgrid, mouse & player markers & mouse area
@@ -356,7 +356,7 @@ void Sword2Engine::processLayer(uint32 layer_number) {
uint32 current_layer_area = 0;
// file points to 1st byte in the layer file
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
// point to layer header
layer_head = FetchLayerHeader(file,layer_number);
@@ -381,7 +381,7 @@ void Sword2Engine::processLayer(uint32 layer_number) {
_largestLayerArea = current_layer_area;
sprintf(_largestLayerInfo,
"largest layer: %s layer(%d) is %dx%d",
- FetchObjectName(this_screen.background_layer_id),
+ FetchObjectName(_thisScreen.background_layer_id),
layer_number, layer_head->width, layer_head->height);
}
@@ -389,7 +389,7 @@ void Sword2Engine::processLayer(uint32 layer_number) {
if (rv)
error("Driver Error %.8x in Process_layer(%d)", rv, layer_number);
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
void Sword2Engine::processImage(buildit *build_unit) {
@@ -530,7 +530,7 @@ void Sword2Engine::resetRenderLists(void) {
_curBgp1 = 0;
_curBack = 0;
// beginning of sort list is setup with the special sort layers
- _curSort = this_screen.number_of_layers;
+ _curSort = _thisScreen.number_of_layers;
_curFore = 0;
_curFgp0 = 0;
_curFgp1 = 0;
@@ -764,7 +764,7 @@ void Sword2Engine::startNewPalette(void) {
g_display->waitForFade();
// open the screen file
- screenFile = res_man.open(this_screen.background_layer_id);
+ screenFile = res_man.open(_thisScreen.background_layer_id);
g_display->updatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(screenFile));
@@ -774,13 +774,13 @@ void Sword2Engine::startNewPalette(void) {
_lastPaletteRes = 0;
// close screen file
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
// start fade up
g_display->fadeUp();
// reset
- this_screen.new_palette = 0;
+ _thisScreen.new_palette = 0;
}
int32 Logic::fnUpdatePlayerStats(int32 *params) {
@@ -790,15 +790,15 @@ int32 Logic::fnUpdatePlayerStats(int32 *params) {
Object_mega *ob_mega = (Object_mega *) params[0];
- this_screen.player_feet_x = ob_mega->feet_x;
- this_screen.player_feet_y = ob_mega->feet_y;
+ g_sword2->_thisScreen.player_feet_x = ob_mega->feet_x;
+ g_sword2->_thisScreen.player_feet_y = ob_mega->feet_y;
// for the script
PLAYER_FEET_X = ob_mega->feet_x;
PLAYER_FEET_Y = ob_mega->feet_y;
PLAYER_CUR_DIR = ob_mega->current_dir;
- SCROLL_OFFSET_X = this_screen.scroll_offset_x;
+ SCROLL_OFFSET_X = g_sword2->_thisScreen.scroll_offset_x;
debug(5, "fnUpdatePlayerStats: %d %d", ob_mega->feet_x, ob_mega->feet_y);
@@ -901,9 +901,9 @@ void Sword2Engine::setFullPalette(int32 palRes) {
res_man.close(palRes);
} else {
// 0: set palette to current screen palette
- if (this_screen.background_layer_id) {
+ if (_thisScreen.background_layer_id) {
// open the screen file
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
g_display->updatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(file));
g_display->setPalette(0, 256, FetchPalette(file), RDPAL_INSTANT);
@@ -912,7 +912,7 @@ void Sword2Engine::setFullPalette(int32 palRes) {
_lastPaletteRes = 0;
// close screen file
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
} else
error("setFullPalette(0) called, but no current screen available!");
}
@@ -927,13 +927,13 @@ int32 Logic::fnChangeShadows(int32 *params) {
// params: none
// if last screen was using a shading mask (see below)
- if (this_screen.mask_flag) {
+ if (g_sword2->_thisScreen.mask_flag) {
uint32 rv = g_display->closeLightMask();
if (rv)
error("Driver Error %.8x [%s line %u]", rv);
- this_screen.mask_flag = 0;
+ g_sword2->_thisScreen.mask_flag = 0;
}
return IR_CONT;
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index bab8a55943..759745b7a3 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -1473,14 +1473,15 @@ void Gui::restartControl(void) {
// - this is taken from fnInitBackground
// switch on scrolling (2 means first time on screen)
- this_screen.scroll_flag = 2;
+ g_sword2->_thisScreen.scroll_flag = 2;
if (g_logic.processSession())
error("restart 1st cycle failed??");
// So palette not restored immediately after control panel - we want
// to fade up instead!
- this_screen.new_palette = 99;
+
+ g_sword2->_thisScreen.new_palette = 99;
}
void Gui::optionControl(void) {
diff --git a/sword2/debug.cpp b/sword2/debug.cpp
index 098072c06c..2fcbe0fa6c 100644
--- a/sword2/debug.cpp
+++ b/sword2/debug.cpp
@@ -76,7 +76,7 @@ void Debugger::buildDebugText(void) {
/*
// print mouse coords beside mouse-marker, if it's being displayed
if (displayMouseMarker) {
- sprintf(buf, "%d,%d", mousex + this_screen.scroll_offset_x, mousey + this_screen.scroll_offset_y);
+ sprintf(buf, "%d,%d", mousex + _thisScreen.scroll_offset_x, mousey + _thisScreen.scroll_offset_y);
if (mousex>560)
makeDebugTextBlock(buf, mousex - 50, mousey - 15);
else
@@ -187,14 +187,14 @@ void Debugger::buildDebugText(void) {
if (mouse_touching)
sprintf(buf, "mouse %d,%d (id %d: %s)",
- g_display->_mouseX + this_screen.scroll_offset_x,
- g_display->_mouseY + this_screen.scroll_offset_y,
+ g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,
+ g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y,
mouse_touching,
FetchObjectName(mouse_touching));
else
sprintf(buf, "mouse %d,%d (not touching)",
- g_display->_mouseX + this_screen.scroll_offset_x,
- g_display->_mouseY + this_screen.scroll_offset_y);
+ g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x,
+ g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y);
makeDebugTextBlock(buf, 0, 30);
@@ -203,16 +203,16 @@ void Debugger::buildDebugText(void) {
if (_playerGraphic.anim_resource)
sprintf(buf, "player %d,%d %s (%d) #%d/%d",
- this_screen.player_feet_x,
- this_screen.player_feet_y,
+ g_sword2->_thisScreen.player_feet_x,
+ g_sword2->_thisScreen.player_feet_y,
FetchObjectName(_playerGraphic.anim_resource),
_playerGraphic.anim_resource,
_playerGraphic.anim_pc,
_playerGraphicNoFrames);
else
sprintf(buf, "player %d,%d --- %d",
- this_screen.player_feet_x,
- this_screen.player_feet_y,
+ g_sword2->_thisScreen.player_feet_x,
+ g_sword2->_thisScreen.player_feet_y,
_playerGraphic.anim_pc);
makeDebugTextBlock(buf, 0, 45);
@@ -315,12 +315,12 @@ void Debugger::drawDebugGraphics(void) {
// player feet coord marker
if (_displayPlayerMarker)
- plotCrossHair(this_screen.player_feet_x, this_screen.player_feet_y, 215);
+ plotCrossHair(g_sword2->_thisScreen.player_feet_x, g_sword2->_thisScreen.player_feet_y, 215);
// mouse marker & coords
if (_displayMouseMarker)
- plotCrossHair(g_display->_mouseX + this_screen.scroll_offset_x, g_display->_mouseY + this_screen.scroll_offset_y, 215);
+ plotCrossHair(g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x, g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y, 215);
// mouse area rectangle / sprite box rectangle when testing anims
@@ -355,10 +355,10 @@ void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
void Debugger::printCurrentInfo(void) {
// prints general stuff about the screen, etc.
- if (this_screen.background_layer_id) {
- Debug_Printf("background layer id %d\n", this_screen.background_layer_id);
- Debug_Printf("%d wide, %d high\n", this_screen.screen_wide, this_screen.screen_deep);
- Debug_Printf("%d normal layers\n", this_screen.number_of_layers);
+ if (g_sword2->_thisScreen.background_layer_id) {
+ Debug_Printf("background layer id %d\n", g_sword2->_thisScreen.background_layer_id);
+ Debug_Printf("%d wide, %d high\n", g_sword2->_thisScreen.screen_wide, g_sword2->_thisScreen.screen_deep);
+ Debug_Printf("%d normal layers\n", g_sword2->_thisScreen.number_of_layers);
g_logic.examineRunList();
} else
diff --git a/sword2/function.cpp b/sword2/function.cpp
index 472f713092..586253314f 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -26,7 +26,7 @@
#include "sword2/defs.h"
#include "sword2/function.h"
#include "sword2/interpreter.h"
-#include "sword2/layers.h" // for 'this_screen' structure
+#include "sword2/layers.h" // for '_thisScreen' structure
#include "sword2/logic.h"
#include "sword2/protocol.h"
#include "sword2/resman.h"
@@ -372,7 +372,7 @@ int32 Logic::fnResetGlobals(int32 *params) {
// - this is taken from fnInitBackground
// switch on scrolling (2 means first time on screen)
- this_screen.scroll_flag = 2;
+ g_sword2->_thisScreen.scroll_flag = 2;
return IR_CONT;
}
diff --git a/sword2/layers.cpp b/sword2/layers.cpp
index ece894cb59..4e345601b8 100644
--- a/sword2/layers.cpp
+++ b/sword2/layers.cpp
@@ -38,11 +38,6 @@
namespace Sword2 {
-// this_screen describes the current back buffer and its in-game scroll
-// positions, etc.
-
-screen_info this_screen;
-
int32 Logic::fnInitBackground(int32 *params) {
// this screen defines the size of the back buffer
@@ -77,7 +72,7 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
g_display->waitForFade();
// if last screen was using a shading mask (see below)
- if (this_screen.mask_flag) {
+ if (_thisScreen.mask_flag) {
rv = g_display->closeLightMask();
if (rv)
error("Driver Error %.8x", rv);
@@ -86,25 +81,25 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
// New stuff for faster screen drivers
// for drivers: close the previous screen if one is open
- if (this_screen.background_layer_id)
+ if (_thisScreen.background_layer_id)
g_display->closeBackgroundLayer();
- this_screen.background_layer_id = res;
- this_screen.new_palette = new_palette;
+ _thisScreen.background_layer_id = res;
+ _thisScreen.new_palette = new_palette;
// ok, now read the resource and pull out all the normal sort layer
// info/and set them up at the beginning of the sort list - why do it
// each cycle
// file points to 1st byte in the layer file
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screen_head = FetchScreenHeader(file);
//set number of special sort layers
- this_screen.number_of_layers = screen_head->noLayers;
- this_screen.screen_wide = screen_head->width;
- this_screen.screen_deep = screen_head->height;
+ _thisScreen.number_of_layers = screen_head->noLayers;
+ _thisScreen.screen_wide = screen_head->width;
+ _thisScreen.screen_deep = screen_head->height;
debug(5, "res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height);
@@ -133,27 +128,27 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
// if layer is larger than physical screen
if (screen_head->width > g_display->_screenWide || screen_head->height > g_display->_screenDeep) {
// switch on scrolling (2 means first time on screen)
- this_screen.scroll_flag = 2;
+ _thisScreen.scroll_flag = 2;
// note, if we've already set the player up then we could do
// the initial scroll set here
// reset scroll offsets
- this_screen.scroll_offset_x = 0;
- this_screen.scroll_offset_y = 0;
+ _thisScreen.scroll_offset_x = 0;
+ _thisScreen.scroll_offset_y = 0;
// calc max allowed offsets (to prevent scrolling off edge) -
// MOVE TO NEW_SCREEN in GTM_CORE.C !!
// NB. min scroll offsets are both zero
- this_screen.max_scroll_offset_x = screen_head->width - g_display->_screenWide;
+ _thisScreen.max_scroll_offset_x = screen_head->width - g_display->_screenWide;
// 'screenDeep' includes the menu's, so take away 80 pixels
- this_screen.max_scroll_offset_y = screen_head->height - (g_display->_screenDeep - (RDMENU_MENUDEEP * 2));
+ _thisScreen.max_scroll_offset_y = screen_head->height - (g_display->_screenDeep - (RDMENU_MENUDEEP * 2));
} else {
// layer fits on physical screen - scrolling not required
- this_screen.scroll_flag = 0; // switch off scrolling
- this_screen.scroll_offset_x = 0; // reset scroll offsets
- this_screen.scroll_offset_y = 0;
+ _thisScreen.scroll_flag = 0; // switch off scrolling
+ _thisScreen.scroll_offset_x = 0; // reset scroll offsets
+ _thisScreen.scroll_offset_y = 0;
}
// no inter-cycle scroll between new screens (see setScrollTarget in
@@ -162,8 +157,8 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
// these are the physical screen coords where the system
// will try to maintain George's actual feet coords
- this_screen.feet_x = 320;
- this_screen.feet_y = 340;
+ _thisScreen.feet_x = 320;
+ _thisScreen.feet_y = 340;
// shading mask
@@ -187,16 +182,16 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
error("Driver Error %.8x", rv);
// so we know to close it later! (see above)
- this_screen.mask_flag = 1;
+ _thisScreen.mask_flag = 1;
} else {
// no need to close a mask later
- this_screen.mask_flag = 0;
+ _thisScreen.mask_flag = 0;
}
// close the screen file
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
- SetUpBackgroundLayers();
+ setUpBackgroundLayers();
debug(5, "end init");
return 1;
@@ -204,7 +199,7 @@ int32 Sword2Engine::initBackground(int32 res, int32 new_palette) {
// called from fnInitBackground and also from control panel
-void SetUpBackgroundLayers(void) {
+void Sword2Engine::setUpBackgroundLayers(void) {
_multiScreenHeader *screenLayerTable;
_screenHeader *screen_head;
uint8 *file;
@@ -212,11 +207,11 @@ void SetUpBackgroundLayers(void) {
// if we actually have a screen to initialise (in case not called from
// control panel)
- if (this_screen.background_layer_id) {
+ if (_thisScreen.background_layer_id) {
// open resource & set pointers to headers
// file points to 1st byte in the layer file
- file = res_man.open(this_screen.background_layer_id);
+ file = res_man.open(_thisScreen.background_layer_id);
screen_head = FetchScreenHeader(file);
@@ -245,7 +240,7 @@ void SetUpBackgroundLayers(void) {
}
// close the screen file
- res_man.close(this_screen.background_layer_id);
+ res_man.close(_thisScreen.background_layer_id);
}
}
diff --git a/sword2/layers.h b/sword2/layers.h
index b9a9f066e0..0bc625daf0 100644
--- a/sword2/layers.h
+++ b/sword2/layers.h
@@ -46,12 +46,6 @@ typedef struct {
uint8 mask_flag; // Using shading mask
} screen_info;
-extern screen_info this_screen;
-
-// called from control panel (as well as inside fnInitBackground)
-
-void SetUpBackgroundLayers(void);
-
} // End of namespace Sword2
#endif
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 3f96384015..8abccf0dd4 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -40,23 +40,25 @@ namespace Sword2 {
// pointer resource id's
-#define CROSHAIR 18
-#define EXIT0 788
-#define EXIT1 789
-#define EXIT2 790
-#define EXIT3 791
-#define EXIT4 792
-#define EXIT5 793
-#define EXIT6 794
-#define EXIT7 795
-#define EXITDOWN 796
-#define EXITUP 797
-#define MOUTH 787
-#define NORMAL 17
-#define PICKUP 3099
-#define SCROLL_L 1440
-#define SCROLL_R 1441
-#define USE 3100
+enum {
+ CROSHAIR = 18,
+ EXIT0 = 788,
+ EXIT1 = 789,
+ EXIT2 = 790,
+ EXIT3 = 791,
+ EXIT4 = 792,
+ EXIT5 = 793,
+ EXIT6 = 794,
+ EXIT7 = 795,
+ EXITDOWN = 796,
+ EXITUP = 797,
+ MOUTH = 787,
+ NORMAL = 17,
+ PICKUP = 3099,
+ SCROLL_L = 1440,
+ SCROLL_R = 1441,
+ USE = 3100
+};
//the mouse list stuff
@@ -278,7 +280,7 @@ void System_menu_mouse(void) {
// successful restore or restart!
// see RestoreFromBuffer() in save_rest.cpp
- if (this_screen.new_palette != 99) {
+ if (g_sword2->_thisScreen.new_palette != 99) {
// '0' means put back game screen
// palette; see Build_display.cpp
@@ -287,9 +289,9 @@ void System_menu_mouse(void) {
// stop the engine fading in the
// restored screens palette
- this_screen.new_palette = 0;
+ g_sword2->_thisScreen.new_palette = 0;
} else
- this_screen.new_palette = 1;
+ g_sword2->_thisScreen.new_palette = 1;
g_sound->unpauseFx();
@@ -359,8 +361,8 @@ void Drag_mouse(void) {
// these might be required by the action script about
// to be run
- MOUSE_X = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
- MOUSE_Y = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+ MOUSE_X = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+ MOUSE_Y = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
// for scripts to know what's been clicked (21jan97).
// First used for 'room_13_turning_script' in object
@@ -578,8 +580,8 @@ void Normal_mouse(void) {
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
// set both (x1,y1) and (x2,y2) to this point
- g_sword2->_debugger->_rectX1 = g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
- g_sword2->_debugger->_rectY1 = g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+ g_sword2->_debugger->_rectX1 = g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+ g_sword2->_debugger->_rectY1 = g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
g_sword2->_debugger->_draggingRectangle = 1;
}
} else if (g_sword2->_debugger->_draggingRectangle == 1) {
@@ -591,8 +593,8 @@ void Normal_mouse(void) {
g_sword2->_debugger->_draggingRectangle = 2;
} else {
// drag rectangle
- g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
- g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+ g_sword2->_debugger->_rectX2 = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+ g_sword2->_debugger->_rectY2 = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
}
} else {
// currently locked to avoid knocking out of place
@@ -642,8 +644,8 @@ void Normal_mouse(void) {
// these might be required by the action script about
// to be run
- MOUSE_X = (uint32) g_display->_mouseX + this_screen.scroll_offset_x;
- MOUSE_Y = (uint32) g_display->_mouseY + this_screen.scroll_offset_y;
+ MOUSE_X = (uint32) g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x;
+ MOUSE_Y = (uint32) g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y;
// only left button
if (mouse_touching == EXIT_CLICK_ID && (me->buttons & RD_LEFTBUTTONDOWN)) {
@@ -834,10 +836,10 @@ uint32 Check_mouse_list(void) {
// mouse-detection-box
if (mouse_list[j].priority == priority &&
- g_display->_mouseX + this_screen.scroll_offset_x >= mouse_list[j].x1 &&
- g_display->_mouseX + this_screen.scroll_offset_x <= mouse_list[j].x2 &&
- g_display->_mouseY + this_screen.scroll_offset_y >= mouse_list[j].y1 &&
- g_display->_mouseY + this_screen.scroll_offset_y <= mouse_list[j].y2) {
+ g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x >= mouse_list[j].x1 &&
+ g_display->_mouseX + g_sword2->_thisScreen.scroll_offset_x <= mouse_list[j].x2 &&
+ g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y >= mouse_list[j].y1 &&
+ g_display->_mouseY + g_sword2->_thisScreen.scroll_offset_y <= mouse_list[j].y2) {
// record id
mouse_touching = mouse_list[j].id;
@@ -1238,8 +1240,8 @@ int32 Logic::fnInitFloorMouse(int32 *params) {
ob_mouse->x1 = 0;
ob_mouse->y1 = 0;
- ob_mouse->x2 = this_screen.screen_wide - 1;
- ob_mouse->y2 = this_screen.screen_deep - 1;
+ ob_mouse->x2 = g_sword2->_thisScreen.screen_wide - 1;
+ ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
ob_mouse->priority = 9;
ob_mouse->pointer = NORMAL_MOUSE_ID;
@@ -1257,11 +1259,11 @@ int32 Logic::fnSetScrollLeftMouse(int32 *params) {
ob_mouse->x1 = 0;
ob_mouse->y1 = 0;
- ob_mouse->x2 = this_screen.scroll_offset_x + SCROLL_MOUSE_WIDTH;
- ob_mouse->y2 = this_screen.screen_deep - 1;
+ ob_mouse->x2 = g_sword2->_thisScreen.scroll_offset_x + SCROLL_MOUSE_WIDTH;
+ ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
ob_mouse->priority = 0;
- if (this_screen.scroll_offset_x > 0) {
+ if (g_sword2->_thisScreen.scroll_offset_x > 0) {
// not fully scrolled to the left
ob_mouse->pointer = SCROLL_LEFT_MOUSE_ID;
} else {
@@ -1279,13 +1281,13 @@ int32 Logic::fnSetScrollRightMouse(int32 *params) {
// Highest priority
- ob_mouse->x1 = this_screen.scroll_offset_x + g_display->_screenWide - SCROLL_MOUSE_WIDTH;
+ ob_mouse->x1 = g_sword2->_thisScreen.scroll_offset_x + g_display->_screenWide - SCROLL_MOUSE_WIDTH;
ob_mouse->y1 = 0;
- ob_mouse->x2 = this_screen.screen_wide - 1;
- ob_mouse->y2 = this_screen.screen_deep - 1;
+ ob_mouse->x2 = g_sword2->_thisScreen.screen_wide - 1;
+ ob_mouse->y2 = g_sword2->_thisScreen.screen_deep - 1;
ob_mouse->priority = 0;
- if (this_screen.scroll_offset_x < this_screen.max_scroll_offset_x) {
+ if (g_sword2->_thisScreen.scroll_offset_x < g_sword2->_thisScreen.max_scroll_offset_x) {
// not fully scrolled to the right
ob_mouse->pointer = SCROLL_RIGHT_MOUSE_ID;
} else {
diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp
index f239880a2a..8cd6575826 100644
--- a/sword2/save_rest.cpp
+++ b/sword2/save_rest.cpp
@@ -70,8 +70,8 @@ typedef struct {
uint32 varLength; // length of global variables resource
uint32 screenId; // resource id of screen file
uint32 runListId; // resource id of run list
- uint32 feet_x; // copy of this_screen.feet_x
- uint32 feet_y; // copy of this_screen.feet_y
+ uint32 feet_x; // copy of _thisScreen.feet_x
+ uint32 feet_y; // copy of _thisScreen.feet_y
uint32 music_id; // copy of 'looping_music_id'
_object_hub player_hub; // copy of player object's object_hub structure
Object_logic logic; // copy of player character logic structure
@@ -180,14 +180,14 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
g_header.varLength = res_man.fetchLen(1);
// resource id of current screen file
- g_header.screenId = this_screen.background_layer_id;
+ g_header.screenId = g_sword2->_thisScreen.background_layer_id;
// resource id of current run-list
g_header.runListId = g_logic.getRunList();
// those scroll position control things
- g_header.feet_x = this_screen.feet_x;
- g_header.feet_y = this_screen.feet_y;
+ g_header.feet_x = g_sword2->_thisScreen.feet_x;
+ g_header.feet_y = g_sword2->_thisScreen.feet_y;
// id of currently looping music (or zero)
g_header.music_id = looping_music_id;
@@ -423,13 +423,13 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// So palette not restored immediately after control panel - we want to
// fade up instead!
- this_screen.new_palette = 99;
+ g_sword2->_thisScreen.new_palette = 99;
// these need setting after the defaults get set in fnInitBackground
// remember that these can change through the game, so need saving &
// restoring too
- this_screen.feet_x = g_header.feet_x;
- this_screen.feet_y = g_header.feet_y;
+ g_sword2->_thisScreen.feet_x = g_header.feet_x;
+ g_sword2->_thisScreen.feet_y = g_header.feet_y;
// start the new run list
g_logic.expressChangeSession(g_header.runListId);
@@ -437,14 +437,14 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// Force in the new scroll position, so unsightly scroll-catch-up does
// not occur when screen first draws after returning from restore panel
- // set 'this_screen's record of player position
+ // set '_thisScreen's record of player position
// - ready for Set_scrolling()
- this_screen.player_feet_x = g_header.mega.feet_x;
- this_screen.player_feet_y = g_header.mega.feet_y;
+ g_sword2->_thisScreen.player_feet_x = g_header.mega.feet_x;
+ g_sword2->_thisScreen.player_feet_y = g_header.mega.feet_y;
// if this screen is wide, recompute the scroll offsets now
- if (this_screen.scroll_flag)
+ if (g_sword2->_thisScreen.scroll_flag)
Set_scrolling();
// Any music required will be started after we've returned from
diff --git a/sword2/scroll.cpp b/sword2/scroll.cpp
index 8979ebc307..3ae0a82aa2 100644
--- a/sword2/scroll.cpp
+++ b/sword2/scroll.cpp
@@ -18,6 +18,7 @@
*/
#include "stdafx.h"
+#include "sword2/sword2.h"
#include "sword2/driver/driver96.h"
#include "sword2/debug.h"
#include "sword2/defs.h"
@@ -52,51 +53,51 @@ void Set_scrolling(void) {
// if the scroll offsets are being forced in script
if (SCROLL_X || SCROLL_Y) {
// ensure not too far right
- if (this_screen.max_scroll_offset_x > SCROLL_X)
- this_screen.scroll_offset_x = SCROLL_X;
+ if (g_sword2->_thisScreen.max_scroll_offset_x > SCROLL_X)
+ g_sword2->_thisScreen.scroll_offset_x = SCROLL_X;
else
- this_screen.scroll_offset_x = this_screen.max_scroll_offset_x;
+ g_sword2->_thisScreen.scroll_offset_x = g_sword2->_thisScreen.max_scroll_offset_x;
// ensure not too far down
- if (this_screen.max_scroll_offset_y > SCROLL_Y)
- this_screen.scroll_offset_y = SCROLL_Y;
+ if (g_sword2->_thisScreen.max_scroll_offset_y > SCROLL_Y)
+ g_sword2->_thisScreen.scroll_offset_y = SCROLL_Y;
else
- this_screen.scroll_offset_y = this_screen.max_scroll_offset_y;
+ g_sword2->_thisScreen.scroll_offset_y = g_sword2->_thisScreen.max_scroll_offset_y;
} else {
// George's offset from the centre - the desired position
// for him
- offset_x = this_screen.player_feet_x - this_screen.feet_x;
- offset_y = this_screen.player_feet_y - this_screen.feet_y;
+ offset_x = g_sword2->_thisScreen.player_feet_x - g_sword2->_thisScreen.feet_x;
+ offset_y = g_sword2->_thisScreen.player_feet_y - g_sword2->_thisScreen.feet_y;
// prevent scrolling too far left/right/up/down
if (offset_x < 0)
offset_x = 0;
- else if ((uint32) offset_x > this_screen.max_scroll_offset_x)
- offset_x = this_screen.max_scroll_offset_x;
+ else if ((uint32) offset_x > g_sword2->_thisScreen.max_scroll_offset_x)
+ offset_x = g_sword2->_thisScreen.max_scroll_offset_x;
if (offset_y < 0)
offset_y = 0;
- else if ((uint32) offset_y > this_screen.max_scroll_offset_y)
- offset_y = this_screen.max_scroll_offset_y;
+ else if ((uint32) offset_y > g_sword2->_thisScreen.max_scroll_offset_y)
+ offset_y = g_sword2->_thisScreen.max_scroll_offset_y;
// first time on this screen - need absolute scroll
// immediately!
- if (this_screen.scroll_flag == 2) {
+ if (g_sword2->_thisScreen.scroll_flag == 2) {
debug(5, "init scroll");
- this_screen.scroll_offset_x = offset_x;
- this_screen.scroll_offset_y = offset_y;
- this_screen.scroll_flag = 1;
+ g_sword2->_thisScreen.scroll_offset_x = offset_x;
+ g_sword2->_thisScreen.scroll_offset_y = offset_y;
+ g_sword2->_thisScreen.scroll_flag = 1;
} else {
// catch up with required scroll offsets - speed
// depending on distance to catch up (dx and dy) &
// 'SCROLL_FRACTION' used, but limit to certain
// number of pixels per cycle (MAX_SCROLL_DISTANCE)
- dx = this_screen.scroll_offset_x - offset_x;
- dy = this_screen.scroll_offset_y - offset_y;
+ dx = g_sword2->_thisScreen.scroll_offset_x - offset_x;
+ dy = g_sword2->_thisScreen.scroll_offset_y - offset_y;
// current scroll_offset_x is less than the required
// value
@@ -115,7 +116,8 @@ void Set_scrolling(void) {
if (scroll_distance_x > MAX_SCROLL_DISTANCE)
scroll_distance_x = MAX_SCROLL_DISTANCE;
- this_screen.scroll_offset_x += scroll_distance_x; } else if (dx > 0) {
+ g_sword2->_thisScreen.scroll_offset_x += scroll_distance_x;
+ } else if (dx > 0) {
// current scroll_offset_x is greater than
// the required value
// => dec by (fraction of the differnce)
@@ -125,7 +127,7 @@ void Set_scrolling(void) {
if (scroll_distance_x > MAX_SCROLL_DISTANCE)
scroll_distance_x = MAX_SCROLL_DISTANCE;
- this_screen.scroll_offset_x -= scroll_distance_x;
+ g_sword2->_thisScreen.scroll_offset_x -= scroll_distance_x;
}
if (dy < 0) {
@@ -134,14 +136,14 @@ void Set_scrolling(void) {
if (scroll_distance_y > MAX_SCROLL_DISTANCE)
scroll_distance_y = MAX_SCROLL_DISTANCE;
- this_screen.scroll_offset_y += scroll_distance_y;
+ g_sword2->_thisScreen.scroll_offset_y += scroll_distance_y;
} else if (dy > 0) {
scroll_distance_y = 1 + dy / scroll_fraction;
if (scroll_distance_y > MAX_SCROLL_DISTANCE)
scroll_distance_y = MAX_SCROLL_DISTANCE;
- this_screen.scroll_offset_y -= scroll_distance_y;
+ g_sword2->_thisScreen.scroll_offset_y -= scroll_distance_y;
}
}
}
@@ -163,8 +165,8 @@ int32 Logic::fnSetScrollCoordinate(int32 *params) {
// params: 0 feet_x value
// 1 feet_y value
- this_screen.feet_x = params[0];
- this_screen.feet_y = params[1];
+ g_sword2->_thisScreen.feet_x = params[0];
+ g_sword2->_thisScreen.feet_y = params[1];
return IR_CONT;
}
diff --git a/sword2/speech.cpp b/sword2/speech.cpp
index 4831f00e47..4b31618df3 100644
--- a/sword2/speech.cpp
+++ b/sword2/speech.cpp
@@ -41,24 +41,25 @@
namespace Sword2 {
-#define INS_talk 1
-#define INS_anim 2
-#define INS_reverse_anim 3
-#define INS_walk 4
-#define INS_turn 5
-#define INS_face 6
-#define INS_trace 7
-#define INS_no_sprite 8
-#define INS_sort 9
-#define INS_foreground 10
-#define INS_background 11
-#define INS_table_anim 12
-#define INS_reverse_table_anim 13
-#define INS_walk_to_anim 14
-#define INS_set_frame 15
-#define INS_stand_after_anim 16
-
-#define INS_quit 42
+enum {
+ INS_talk = 1,
+ INS_anim = 2,
+ INS_reverse_anim = 3,
+ INS_walk = 4,
+ INS_turn = 5,
+ INS_face = 6,
+ INS_trace = 7,
+ INS_no_sprite = 8,
+ INS_sort = 9,
+ INS_foreground = 10,
+ INS_background = 11,
+ INS_table_anim = 12,
+ INS_reverse_table_anim = 13,
+ INS_walk_to_anim = 14,
+ INS_set_frame = 15,
+ INS_stand_after_anim = 16,
+ INS_quit = 42
+};
// when not playing a wav we calculate the speech time based upon length of
// ascii
@@ -1451,8 +1452,8 @@ void LocateTalker(int32 *params) {
// adjust the text coords for RDSPR_DISPLAYALIGN
- text_x -= this_screen.scroll_offset_x;
- text_y -= this_screen.scroll_offset_y;
+ text_x -= g_sword2->_thisScreen.scroll_offset_x;
+ text_y -= g_sword2->_thisScreen.scroll_offset_y;
// release the anim resource
res_man.close(anim_id);
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 95311fe6fd..bb6a884444 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -161,6 +161,8 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
_totalMasters = 0;
memset(_masterMenuList, 0, sizeof(_masterMenuList));
+
+ memset(&_thisScreen, 0, sizeof(_thisScreen));
}
Sword2Engine::~Sword2Engine() {
@@ -284,7 +286,7 @@ int32 GameCycle(void) {
}
// if this screen is wide, recompute the scroll offsets every cycle
- if (this_screen.scroll_flag)
+ if (g_sword2->_thisScreen.scroll_flag)
Set_scrolling();
Mouse_engine();
diff --git a/sword2/sword2.h b/sword2/sword2.h
index b1e5aa6273..e84b4985a7 100644
--- a/sword2/sword2.h
+++ b/sword2/sword2.h
@@ -29,6 +29,7 @@
#include "sword2/console.h"
#include "sword2/events.h"
#include "sword2/icons.h"
+#include "sword2/layers.h"
#include "sword2/object.h"
#include "sword2/driver/d_sound.h"
#include "sword2/driver/d_draw.h"
@@ -219,6 +220,13 @@ public:
void buildMenu(void);
void buildSystemMenu(void);
+ // _thisScreen describes the current back buffer and its in-game scroll
+ // positions, etc.
+
+ screen_info _thisScreen;
+
+ void setUpBackgroundLayers(void);
+
void errorString(const char *buf_input, char *buf_output);
void initialiseFontResourceFlags(void);
void initialiseFontResourceFlags(uint8 language);