2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2003-07-28 01:44:38 +00:00
|
|
|
* 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 2
|
|
|
|
* 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, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-28 01:44:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-05-25 15:17:11 +00:00
|
|
|
// high level layer initializing
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 06:28:27 +00:00
|
|
|
// the system supports:
|
|
|
|
// 1 optional background parallax layer
|
|
|
|
// 1 not optional normal backdrop layer
|
|
|
|
// 3 normal sorted layers
|
|
|
|
// up to 2 foreground parallax layers
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "common/rect.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2005-02-27 16:11:19 +00:00
|
|
|
|
2003-10-28 19:51:30 +00:00
|
|
|
#include "sword2/sword2.h"
|
2005-02-27 16:11:19 +00:00
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/logic.h"
|
2005-02-27 16:11:19 +00:00
|
|
|
#include "sword2/mouse.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/resman.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/screen.h"
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
#include "sword2/sound.h"
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
/**
|
|
|
|
* This function is called when entering a new room.
|
|
|
|
* @param res resource id of the normal background layer
|
|
|
|
* @param new_palette 1 for new palette, otherwise 0
|
|
|
|
*/
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
void Screen::initBackground(int32 res, int32 new_palette) {
|
2004-04-07 12:31:32 +00:00
|
|
|
int i;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
assert(res);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2007-01-26 18:21:41 +00:00
|
|
|
_vm->_sound->clearFxQueue(false);
|
2005-02-19 14:02:16 +00:00
|
|
|
waitForFade();
|
2003-09-09 12:14:08 +00:00
|
|
|
|
2006-07-08 20:45:01 +00:00
|
|
|
debug(1, "CHANGED TO LOCATION \"%s\"", _vm->_resman->fetchName(res));
|
2004-09-12 17:10:59 +00:00
|
|
|
|
2007-12-16 09:44:04 +00:00
|
|
|
// We have to clear this. Otherwise, if an exit warps back to the same
|
|
|
|
// room (e.g. the jungle maze), clicking on the same exit again will be
|
|
|
|
// misinterpreted as a double-click, and that only works if we're
|
|
|
|
// actually walking towards that exit. Otherwise, the game would hang.
|
|
|
|
|
|
|
|
_vm->_logic->writeVar(EXIT_CLICK_ID, 0);
|
|
|
|
|
2003-09-26 10:07:18 +00:00
|
|
|
// if last screen was using a shading mask (see below)
|
2003-11-02 17:17:10 +00:00
|
|
|
if (_thisScreen.mask_flag) {
|
2005-02-19 14:02:16 +00:00
|
|
|
if (closeLightMask() != RD_OK)
|
2004-04-07 12:31:32 +00:00
|
|
|
error("Could not close light mask");
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Close the previous screen, if one is open
|
2003-11-02 17:17:10 +00:00
|
|
|
if (_thisScreen.background_layer_id)
|
2005-02-19 14:02:16 +00:00
|
|
|
closeBackgroundLayer();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-11-02 17:17:10 +00:00
|
|
|
_thisScreen.background_layer_id = res;
|
|
|
|
_thisScreen.new_palette = new_palette;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 06:28:27 +00:00
|
|
|
// 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
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
byte *file = _vm->_resman->openResource(_thisScreen.background_layer_id);
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
ScreenHeader screen_head;
|
|
|
|
|
|
|
|
screen_head.read(_vm->fetchScreenHeader(file));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-03-28 13:16:01 +00:00
|
|
|
// set number of special sort layers
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_thisScreen.number_of_layers = screen_head.noLayers;
|
|
|
|
_thisScreen.screen_wide = screen_head.width;
|
|
|
|
_thisScreen.screen_deep = screen_head.height;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
debug(2, "layers=%d width=%d depth=%d", screen_head.noLayers, screen_head.width, screen_head.height);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2011-05-25 15:17:11 +00:00
|
|
|
// initialize the driver back buffer
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
setLocationMetrics(screen_head.width, screen_head.height);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
for (i = 0; i < screen_head.noLayers; i++) {
|
2004-04-07 12:31:32 +00:00
|
|
|
debug(3, "init layer %d", i);
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
LayerHeader layer;
|
|
|
|
|
|
|
|
layer.read(_vm->fetchLayerHeader(file, i));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Add the layer to the sort list. We only provide just enough
|
|
|
|
// information so that it's clear that it's a layer, and where
|
|
|
|
// to sort it in relation to other things in the list.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
_sortList[i].layer_number = i + 1;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_sortList[i].sort_y = layer.y + layer.height;
|
2003-09-17 06:28:27 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// reset scroll offsets
|
|
|
|
_thisScreen.scroll_offset_x = 0;
|
|
|
|
_thisScreen.scroll_offset_y = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (screen_head.width > _screenWide || screen_head.height > _screenDeep) {
|
2004-04-07 12:31:32 +00:00
|
|
|
// The layer is larger than the physical screen. Switch on
|
|
|
|
// scrolling. (2 means first time on screen)
|
2003-11-02 17:17:10 +00:00
|
|
|
_thisScreen.scroll_flag = 2;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Note: if we've already set the player up then we could do
|
2003-09-17 06:28:27 +00:00
|
|
|
// the initial scroll set here
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Calculate the maximum scroll offsets to prevent scrolling
|
|
|
|
// off the edge. The minimum offsets are both 0.
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
_thisScreen.max_scroll_offset_x = screen_head.width - _screenWide;
|
|
|
|
_thisScreen.max_scroll_offset_y = screen_head.height - (_screenDeep - (MENUDEEP * 2));
|
2003-09-17 06:28:27 +00:00
|
|
|
} else {
|
2004-04-07 12:31:32 +00:00
|
|
|
// The later fits on the phyiscal screen. Switch off scrolling.
|
|
|
|
_thisScreen.scroll_flag = 0;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
resetRenderEngine();
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// These are the physical screen coords where the system will try to
|
|
|
|
// maintain George's actual feet coords.
|
|
|
|
|
2003-11-02 17:17:10 +00:00
|
|
|
_thisScreen.feet_x = 320;
|
|
|
|
_thisScreen.feet_y = 340;
|
2003-07-28 01:44:38 +00:00
|
|
|
|
|
|
|
// shading mask
|
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
MultiScreenHeader screenLayerTable;
|
|
|
|
|
|
|
|
screenLayerTable.read(file + ResHeader::size());
|
2003-07-28 01:44:38 +00:00
|
|
|
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (screenLayerTable.maskOffset) {
|
2008-01-28 00:14:17 +00:00
|
|
|
SpriteInfo spriteInfo;
|
2004-04-07 12:31:32 +00:00
|
|
|
|
2003-09-17 06:28:27 +00:00
|
|
|
spriteInfo.x = 0;
|
|
|
|
spriteInfo.y = 0;
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
spriteInfo.w = screen_head.width;
|
|
|
|
spriteInfo.h = screen_head.height;
|
2003-09-17 06:28:27 +00:00
|
|
|
spriteInfo.scale = 0;
|
|
|
|
spriteInfo.scaledWidth = 0;
|
|
|
|
spriteInfo.scaledHeight = 0;
|
|
|
|
spriteInfo.type = 0;
|
|
|
|
spriteInfo.blend = 0;
|
2005-02-19 14:02:16 +00:00
|
|
|
spriteInfo.data = _vm->fetchShadingMask(file);
|
2011-04-14 12:12:27 +00:00
|
|
|
spriteInfo.colorTable = 0;
|
2003-09-17 06:28:27 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
if (openLightMask(&spriteInfo) != RD_OK)
|
2004-04-07 12:31:32 +00:00
|
|
|
error("Could not open light mask");
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-17 06:28:27 +00:00
|
|
|
// so we know to close it later! (see above)
|
2004-04-07 12:31:32 +00:00
|
|
|
_thisScreen.mask_flag = true;
|
2003-09-17 06:28:27 +00:00
|
|
|
} else {
|
|
|
|
// no need to close a mask later
|
2004-04-07 12:31:32 +00:00
|
|
|
_thisScreen.mask_flag = false;
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Background parallax layers
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (screenLayerTable.bg_parallax[i])
|
2011-05-25 15:17:11 +00:00
|
|
|
initializeBackgroundLayer(_vm->fetchBackgroundParallaxLayer(file, i));
|
2004-04-07 12:31:32 +00:00
|
|
|
else
|
2011-05-25 15:17:11 +00:00
|
|
|
initializeBackgroundLayer(NULL);
|
2004-04-07 12:31:32 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Normal backround layer
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2011-05-25 15:17:11 +00:00
|
|
|
initializeBackgroundLayer(_vm->fetchBackgroundLayer(file));
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
// Foreground parallax layers
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2004-04-07 12:31:32 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
if (screenLayerTable.fg_parallax[i])
|
2011-05-25 15:17:11 +00:00
|
|
|
initializeBackgroundLayer(_vm->fetchForegroundParallaxLayer(file, i));
|
2004-04-07 12:31:32 +00:00
|
|
|
else
|
2011-05-25 15:17:11 +00:00
|
|
|
initializeBackgroundLayer(NULL);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2004-04-07 12:31:32 +00:00
|
|
|
|
2005-02-19 14:02:16 +00:00
|
|
|
_vm->_resman->closeResource(_thisScreen.background_layer_id);
|
2003-07-28 01:44:38 +00:00
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
2009-04-07 19:52:46 +00:00
|
|
|
/**
|
|
|
|
* This function is called when entering a new room, PSX edition
|
|
|
|
* @param res resource id of the normal background layer
|
|
|
|
* @param new_palette 1 for new palette, otherwise 0
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Screen::initPsxBackground(int32 res, int32 new_palette) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
assert(res);
|
|
|
|
|
|
|
|
_vm->_sound->clearFxQueue(false);
|
|
|
|
waitForFade();
|
|
|
|
|
|
|
|
debug(1, "CHANGED TO LOCATION \"%s\"", _vm->_resman->fetchName(res));
|
|
|
|
|
|
|
|
_vm->_logic->writeVar(EXIT_CLICK_ID, 0);
|
|
|
|
|
|
|
|
// Close the previous screen, if one is open
|
|
|
|
if (_thisScreen.background_layer_id)
|
|
|
|
closeBackgroundLayer();
|
|
|
|
|
|
|
|
_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
|
|
|
|
|
|
|
|
byte *file = _vm->_resman->openResource(_thisScreen.background_layer_id);
|
|
|
|
ScreenHeader screen_head;
|
|
|
|
|
|
|
|
screen_head.read(_vm->fetchScreenHeader(file));
|
|
|
|
screen_head.height *= 2;
|
|
|
|
|
|
|
|
// set number of special sort layers
|
|
|
|
_thisScreen.number_of_layers = screen_head.noLayers;
|
|
|
|
_thisScreen.screen_wide = screen_head.width;
|
|
|
|
_thisScreen.screen_deep = screen_head.height;
|
|
|
|
|
|
|
|
debug(2, "layers=%d width=%d depth=%d", screen_head.noLayers, screen_head.width, screen_head.height);
|
|
|
|
|
2011-05-25 15:17:11 +00:00
|
|
|
// initialize the driver back buffer
|
2009-04-07 19:52:46 +00:00
|
|
|
setLocationMetrics(screen_head.width, screen_head.height);
|
|
|
|
|
|
|
|
for (i = 0; i < screen_head.noLayers; i++) {
|
|
|
|
debug(3, "init layer %d", i);
|
|
|
|
|
|
|
|
LayerHeader layer;
|
|
|
|
|
|
|
|
layer.read(_vm->fetchLayerHeader(file, i));
|
|
|
|
_sortList[i].layer_number = i + 1;
|
|
|
|
_sortList[i].sort_y = layer.y + layer.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset scroll offsets
|
|
|
|
_thisScreen.scroll_offset_x = 0;
|
|
|
|
_thisScreen.scroll_offset_y = 0;
|
|
|
|
|
|
|
|
if (screen_head.width > _screenWide || screen_head.height > _screenDeep) {
|
|
|
|
_thisScreen.scroll_flag = 2;
|
|
|
|
|
|
|
|
_thisScreen.max_scroll_offset_x = screen_head.width - _screenWide;
|
|
|
|
_thisScreen.max_scroll_offset_y = screen_head.height - (_screenDeep - (MENUDEEP * 2));
|
|
|
|
} else {
|
|
|
|
// The later fits on the phyiscal screen. Switch off scrolling.
|
|
|
|
_thisScreen.scroll_flag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
resetRenderEngine();
|
|
|
|
|
|
|
|
// These are the physical screen coords where the system will try to
|
|
|
|
// maintain George's actual feet coords.
|
|
|
|
|
|
|
|
_thisScreen.feet_x = 320;
|
|
|
|
_thisScreen.feet_y = 340;
|
|
|
|
|
|
|
|
// Background parallax layers
|
2011-05-25 15:17:11 +00:00
|
|
|
initializePsxParallaxLayer(_vm->fetchBackgroundParallaxLayer(file, 0));
|
|
|
|
initializePsxParallaxLayer(NULL);
|
2009-04-07 19:52:46 +00:00
|
|
|
|
|
|
|
// Normal backround layer
|
2011-05-25 15:17:11 +00:00
|
|
|
initializePsxBackgroundLayer(_vm->fetchBackgroundLayer(file));
|
2009-04-07 19:52:46 +00:00
|
|
|
|
|
|
|
// Foreground parallax layers
|
2011-05-25 15:17:11 +00:00
|
|
|
initializePsxParallaxLayer(_vm->fetchForegroundParallaxLayer(file, 1));
|
|
|
|
initializePsxParallaxLayer(NULL);
|
2009-04-07 19:52:46 +00:00
|
|
|
|
|
|
|
_vm->_resman->closeResource(_thisScreen.background_layer_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|