SCI32: Remove CoordAdjuster32, at least for the moment
This may come back in the future to deduplicate some gfx code, but SCI32 had two different inlined ways of doing coordinate conversions with different rounding methods, so CoordAdjuster32 didn't get used when the graphics system was rewritten. At the moment, SCI32 code uses the mulru/mulinc methods from helper.h for scaling up/down coordinates.
This commit is contained in:
parent
eae6891404
commit
4e1a9be816
18 changed files with 21 additions and 150 deletions
|
@ -37,7 +37,6 @@
|
|||
#include "sci/graphics/cache.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/controls16.h"
|
||||
#include "sci/graphics/coordadjuster.h"
|
||||
#include "sci/graphics/palette.h"
|
||||
#include "sci/graphics/paint16.h"
|
||||
#include "sci/graphics/picture.h"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
GfxCompare::GfxCompare(SegManager *segMan, GfxCache *cache, GfxScreen *screen, GfxCoordAdjuster *coordAdjuster)
|
||||
GfxCompare::GfxCompare(SegManager *segMan, GfxCache *cache, GfxScreen *screen, GfxCoordAdjuster16 *coordAdjuster)
|
||||
: _segMan(segMan), _cache(cache), _screen(screen), _coordAdjuster(coordAdjuster) {
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Screen;
|
|||
*/
|
||||
class GfxCompare {
|
||||
public:
|
||||
GfxCompare(SegManager *segMan, GfxCache *cache, GfxScreen *screen, GfxCoordAdjuster *coordAdjuster);
|
||||
GfxCompare(SegManager *segMan, GfxCache *cache, GfxScreen *screen, GfxCoordAdjuster16 *coordAdjuster);
|
||||
~GfxCompare();
|
||||
|
||||
uint16 kernelOnControl(byte screenMask, const Common::Rect &rect);
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
SegManager *_segMan;
|
||||
GfxCache *_cache;
|
||||
GfxScreen *_screen;
|
||||
GfxCoordAdjuster *_coordAdjuster;
|
||||
GfxCoordAdjuster16 *_coordAdjuster;
|
||||
|
||||
uint16 isOnControl(uint16 screenMask, const Common::Rect &rect);
|
||||
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
GfxCoordAdjuster::GfxCoordAdjuster() {
|
||||
}
|
||||
|
||||
GfxCoordAdjuster16::GfxCoordAdjuster16(GfxPorts *ports)
|
||||
: _ports(ports) {
|
||||
}
|
||||
|
@ -83,53 +80,4 @@ Common::Rect GfxCoordAdjuster16::pictureGetDisplayArea() {
|
|||
return displayArea;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SCI32
|
||||
GfxCoordAdjuster32::GfxCoordAdjuster32(SegManager *segMan)
|
||||
: _segMan(segMan) {
|
||||
_scriptsRunningWidth = 0;
|
||||
_scriptsRunningHeight = 0;
|
||||
}
|
||||
|
||||
GfxCoordAdjuster32::~GfxCoordAdjuster32() {
|
||||
}
|
||||
|
||||
void GfxCoordAdjuster32::kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject) {
|
||||
uint16 planeTop = readSelectorValue(_segMan, planeObject, SELECTOR(top));
|
||||
uint16 planeLeft = readSelectorValue(_segMan, planeObject, SELECTOR(left));
|
||||
|
||||
y -= planeTop;
|
||||
x -= planeLeft;
|
||||
}
|
||||
void GfxCoordAdjuster32::kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject) {
|
||||
uint16 planeTop = readSelectorValue(_segMan, planeObject, SELECTOR(top));
|
||||
uint16 planeLeft = readSelectorValue(_segMan, planeObject, SELECTOR(left));
|
||||
|
||||
x += planeLeft;
|
||||
y += planeTop;
|
||||
}
|
||||
|
||||
void GfxCoordAdjuster32::setScriptsResolution(uint16 width, uint16 height) {
|
||||
_scriptsRunningWidth = width;
|
||||
_scriptsRunningHeight = height;
|
||||
}
|
||||
|
||||
void GfxCoordAdjuster32::fromDisplayToScript(int16 &y, int16 &x) {
|
||||
y = ((y * _scriptsRunningHeight) / g_sci->_gfxScreen->getHeight());
|
||||
x = ((x * _scriptsRunningWidth) / g_sci->_gfxScreen->getWidth());
|
||||
}
|
||||
|
||||
void GfxCoordAdjuster32::fromScriptToDisplay(int16 &y, int16 &x) {
|
||||
y = ((y * g_sci->_gfxScreen->getHeight()) / _scriptsRunningHeight);
|
||||
x = ((x * g_sci->_gfxScreen->getWidth()) / _scriptsRunningWidth);
|
||||
}
|
||||
|
||||
void GfxCoordAdjuster32::pictureSetDisplayArea(Common::Rect displayArea) {
|
||||
_pictureDisplayArea = displayArea;
|
||||
}
|
||||
|
||||
Common::Rect GfxCoordAdjuster32::pictureGetDisplayArea() {
|
||||
return _pictureDisplayArea;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // End of namespace Sci
|
||||
|
|
|
@ -35,27 +35,7 @@ class GfxPorts;
|
|||
* most of the time sci32 doesn't do any coordinate adjustment at all
|
||||
* sci16 does a lot of port adjustment on given coordinates
|
||||
*/
|
||||
class GfxCoordAdjuster {
|
||||
public:
|
||||
GfxCoordAdjuster();
|
||||
virtual ~GfxCoordAdjuster() { }
|
||||
|
||||
virtual void kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject = NULL_REG) { }
|
||||
virtual void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG) { }
|
||||
|
||||
virtual Common::Rect onControl(Common::Rect rect) { return rect; }
|
||||
virtual void setCursorPos(Common::Point &pos) { }
|
||||
virtual void moveCursor(Common::Point &pos) { }
|
||||
|
||||
virtual void setScriptsResolution(uint16 width, uint16 height) { }
|
||||
virtual void fromScriptToDisplay(int16 &y, int16 &x) { }
|
||||
virtual void fromDisplayToScript(int16 &y, int16 &x) { }
|
||||
|
||||
virtual Common::Rect pictureGetDisplayArea() { return Common::Rect(0, 0); }
|
||||
private:
|
||||
};
|
||||
|
||||
class GfxCoordAdjuster16 : public GfxCoordAdjuster {
|
||||
class GfxCoordAdjuster16 {
|
||||
public:
|
||||
GfxCoordAdjuster16(GfxPorts *ports);
|
||||
~GfxCoordAdjuster16();
|
||||
|
@ -73,32 +53,6 @@ private:
|
|||
GfxPorts *_ports;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_SCI32
|
||||
class GfxCoordAdjuster32 : public GfxCoordAdjuster {
|
||||
public:
|
||||
GfxCoordAdjuster32(SegManager *segMan);
|
||||
~GfxCoordAdjuster32();
|
||||
|
||||
void kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
|
||||
void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
|
||||
|
||||
void setScriptsResolution(uint16 width, uint16 height);
|
||||
void fromScriptToDisplay(int16 &y, int16 &x);
|
||||
void fromDisplayToScript(int16 &y, int16 &x);
|
||||
|
||||
void pictureSetDisplayArea(Common::Rect displayArea);
|
||||
Common::Rect pictureGetDisplayArea();
|
||||
|
||||
private:
|
||||
SegManager *_segMan;
|
||||
|
||||
Common::Rect _pictureDisplayArea;
|
||||
|
||||
uint16 _scriptsRunningWidth;
|
||||
uint16 _scriptsRunningHeight;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // End of namespace Sci
|
||||
|
||||
#endif
|
||||
|
|
|
@ -80,7 +80,7 @@ GfxCursor::~GfxCursor() {
|
|||
kernelClearZoomZone();
|
||||
}
|
||||
|
||||
void GfxCursor::init(GfxCoordAdjuster *coordAdjuster, EventManager *event) {
|
||||
void GfxCursor::init(GfxCoordAdjuster16 *coordAdjuster, EventManager *event) {
|
||||
_coordAdjuster = coordAdjuster;
|
||||
_event = event;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen);
|
||||
~GfxCursor();
|
||||
|
||||
void init(GfxCoordAdjuster *coordAdjuster, EventManager *event);
|
||||
void init(GfxCoordAdjuster16 *coordAdjuster, EventManager *event);
|
||||
|
||||
void kernelShow();
|
||||
void kernelHide();
|
||||
|
@ -103,7 +103,7 @@ private:
|
|||
ResourceManager *_resMan;
|
||||
GfxScreen *_screen;
|
||||
GfxPalette *_palette;
|
||||
GfxCoordAdjuster *_coordAdjuster;
|
||||
GfxCoordAdjuster16 *_coordAdjuster;
|
||||
EventManager *_event;
|
||||
|
||||
int _upscaledHires;
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "sci/engine/selector.h"
|
||||
#include "sci/engine/vm.h"
|
||||
#include "sci/graphics/cache.h"
|
||||
#include "sci/graphics/coordadjuster.h"
|
||||
#include "sci/graphics/compare.h"
|
||||
#include "sci/graphics/cursor32.h"
|
||||
#include "sci/graphics/font.h"
|
||||
|
@ -58,7 +57,7 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor) :
|
||||
GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor) :
|
||||
_isHiRes(ConfMan.getBool("enable_high_resolution_graphics")),
|
||||
_palette(palette),
|
||||
_cursor(cursor),
|
||||
|
@ -105,20 +104,6 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
|
|||
// default script width for other games is 320x200
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Nothing in the renderer really uses this. Currently,
|
||||
// the cursor renderer does, and kLocalToGlobal/kGlobalToLocal
|
||||
// do, but in the real engine (1) the cursor is handled in
|
||||
// frameOut, and (2) functions do a very simple lookup of the
|
||||
// plane and arithmetic with the plane's gameRect. In
|
||||
// principle, CoordAdjuster could be reused for
|
||||
// convertGameRectToPlaneRect, but it is not super clear yet
|
||||
// what the benefit would be to do that.
|
||||
_coordAdjuster = (GfxCoordAdjuster32 *)coordAdjuster;
|
||||
|
||||
// TODO: Script resolution is hard-coded per game;
|
||||
// also this must be set or else the engine will crash
|
||||
_coordAdjuster->setScriptsResolution(_currentBuffer.scriptWidth, _currentBuffer.scriptHeight);
|
||||
}
|
||||
|
||||
GfxFrameout::~GfxFrameout() {
|
||||
|
|
|
@ -31,7 +31,6 @@ typedef Common::Array<DrawList> ScreenItemListList;
|
|||
typedef Common::Array<RectList> EraseListList;
|
||||
|
||||
class GfxCursor32;
|
||||
class GfxCoordAdjuster32;
|
||||
class GfxTransitions32;
|
||||
struct PlaneShowStyle;
|
||||
|
||||
|
@ -42,13 +41,12 @@ struct PlaneShowStyle;
|
|||
class GfxFrameout {
|
||||
private:
|
||||
GfxCursor32 *_cursor;
|
||||
GfxCoordAdjuster32 *_coordAdjuster;
|
||||
GfxPalette32 *_palette;
|
||||
ResourceManager *_resMan;
|
||||
SegManager *_segMan;
|
||||
|
||||
public:
|
||||
GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor);
|
||||
GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxPalette32 *palette, GfxTransitions32 *transitions, GfxCursor32 *cursor);
|
||||
~GfxFrameout();
|
||||
|
||||
bool _isHiRes;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
namespace Sci {
|
||||
|
||||
GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, GfxCache *cache, GfxPorts *ports, GfxCoordAdjuster *coordAdjuster, GfxScreen *screen, GfxPalette *palette, GfxTransitions *transitions, AudioPlayer *audio)
|
||||
GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, GfxCache *cache, GfxPorts *ports, GfxCoordAdjuster16 *coordAdjuster, GfxScreen *screen, GfxPalette *palette, GfxTransitions *transitions, AudioPlayer *audio)
|
||||
: _resMan(resMan), _segMan(segMan), _cache(cache), _ports(ports),
|
||||
_coordAdjuster(coordAdjuster), _screen(screen), _palette(palette),
|
||||
_transitions(transitions), _audio(audio), _EGAdrawingVisualize(false) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class GfxView;
|
|||
*/
|
||||
class GfxPaint16 {
|
||||
public:
|
||||
GfxPaint16(ResourceManager *resMan, SegManager *segMan, GfxCache *cache, GfxPorts *ports, GfxCoordAdjuster *coordAdjuster, GfxScreen *screen, GfxPalette *palette, GfxTransitions *transitions, AudioPlayer *audio);
|
||||
GfxPaint16(ResourceManager *resMan, SegManager *segMan, GfxCache *cache, GfxPorts *ports, GfxCoordAdjuster16 *coordAdjuster, GfxScreen *screen, GfxPalette *palette, GfxTransitions *transitions, AudioPlayer *audio);
|
||||
~GfxPaint16();
|
||||
|
||||
void init(GfxAnimate *animate, GfxText16 *text16);
|
||||
|
@ -91,7 +91,7 @@ private:
|
|||
GfxAnimate *_animate;
|
||||
GfxCache *_cache;
|
||||
GfxPorts *_ports;
|
||||
GfxCoordAdjuster *_coordAdjuster;
|
||||
GfxCoordAdjuster16 *_coordAdjuster;
|
||||
GfxScreen *_screen;
|
||||
GfxPalette *_palette;
|
||||
GfxText16 *_text16;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Sci {
|
|||
|
||||
//#define DEBUG_PICTURE_DRAW
|
||||
|
||||
GfxPicture::GfxPicture(ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize)
|
||||
GfxPicture::GfxPicture(ResourceManager *resMan, GfxCoordAdjuster16 *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize)
|
||||
: _resMan(resMan), _coordAdjuster(coordAdjuster), _ports(ports), _screen(screen), _palette(palette), _resourceId(resourceId), _EGAdrawingVisualize(EGAdrawingVisualize) {
|
||||
assert(resourceId != -1);
|
||||
initData(resourceId);
|
||||
|
|
|
@ -38,7 +38,7 @@ enum {
|
|||
class GfxPorts;
|
||||
class GfxScreen;
|
||||
class GfxPalette;
|
||||
class GfxCoordAdjuster;
|
||||
class GfxCoordAdjuster16;
|
||||
class ResourceManager;
|
||||
class Resource;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class Resource;
|
|||
*/
|
||||
class GfxPicture {
|
||||
public:
|
||||
GfxPicture(ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false);
|
||||
GfxPicture(ResourceManager *resMan, GfxCoordAdjuster16 *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false);
|
||||
~GfxPicture();
|
||||
|
||||
GuiResourceId getResourceId();
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
void vectorPatternTexturedCircle(Common::Rect box, byte size, byte color, byte prio, byte control, byte texture);
|
||||
|
||||
ResourceManager *_resMan;
|
||||
GfxCoordAdjuster *_coordAdjuster;
|
||||
GfxCoordAdjuster16 *_coordAdjuster;
|
||||
GfxPorts *_ports;
|
||||
GfxScreen *_screen;
|
||||
GfxPalette *_palette;
|
||||
|
|
|
@ -633,7 +633,7 @@ reg_t GfxText16::allocAndFillReferenceRectArray() {
|
|||
if (rectCount) {
|
||||
reg_t rectArray;
|
||||
byte *rectArrayPtr = g_sci->getEngineState()->_segMan->allocDynmem(4 * 2 * (rectCount + 1), "text code reference rects", &rectArray);
|
||||
GfxCoordAdjuster *coordAdjuster = g_sci->_gfxCoordAdjuster;
|
||||
GfxCoordAdjuster16 *coordAdjuster = g_sci->_gfxCoordAdjuster;
|
||||
for (uint curRect = 0; curRect < rectCount; curRect++) {
|
||||
coordAdjuster->kernelLocalToGlobal(_codeRefRects[curRect].left, _codeRefRects[curRect].top);
|
||||
coordAdjuster->kernelLocalToGlobal(_codeRefRects[curRect].right, _codeRefRects[curRect].bottom);
|
||||
|
|
|
@ -351,18 +351,6 @@ void GfxView::initData(GuiResourceId resourceId) {
|
|||
celData += celSize;
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_SCI32
|
||||
// adjust width/height returned to scripts
|
||||
if (_sci2ScaleRes != SCI_VIEW_NATIVERES_NONE) {
|
||||
for (loopNo = 0; loopNo < _loopCount; loopNo++)
|
||||
for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++)
|
||||
_screen->adjustBackUpscaledCoordinates(_loop[loopNo].cel[celNo].scriptWidth, _loop[loopNo].cel[celNo].scriptHeight, _sci2ScaleRes);
|
||||
} else if ((getSciVersion() >= SCI_VERSION_2_1_EARLY) && (getSciVersion() <= SCI_VERSION_2_1_LATE)) {
|
||||
for (loopNo = 0; loopNo < _loopCount; loopNo++)
|
||||
for (celNo = 0; celNo < _loop[loopNo].celCount; celNo++)
|
||||
_coordAdjuster->fromDisplayToScript(_loop[loopNo].cel[celNo].scriptHeight, _loop[loopNo].cel[celNo].scriptWidth);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -92,7 +92,7 @@ private:
|
|||
void unditherBitmap(byte *bitmap, int16 width, int16 height, byte clearKey);
|
||||
|
||||
ResourceManager *_resMan;
|
||||
GfxCoordAdjuster *_coordAdjuster;
|
||||
GfxCoordAdjuster16 *_coordAdjuster;
|
||||
GfxScreen *_screen;
|
||||
GfxPalette *_palette;
|
||||
|
||||
|
|
|
@ -732,12 +732,11 @@ void SciEngine::initGraphics() {
|
|||
#ifdef ENABLE_SCI32
|
||||
if (getSciVersion() >= SCI_VERSION_2) {
|
||||
// SCI32 graphic objects creation
|
||||
_gfxCoordAdjuster = new GfxCoordAdjuster32(_gamestate->_segMan);
|
||||
_gfxCursor32 = new GfxCursor32();
|
||||
_gfxCompare = new GfxCompare(_gamestate->_segMan, _gfxCache, nullptr, _gfxCoordAdjuster);
|
||||
_gfxPaint32 = new GfxPaint32(_gamestate->_segMan);
|
||||
_gfxTransitions32 = new GfxTransitions32(_gamestate->_segMan);
|
||||
_gfxFrameout = new GfxFrameout(_gamestate->_segMan, _resMan, _gfxCoordAdjuster, _gfxPalette32, _gfxTransitions32, _gfxCursor32);
|
||||
_gfxFrameout = new GfxFrameout(_gamestate->_segMan, _resMan, _gfxPalette32, _gfxTransitions32, _gfxCursor32);
|
||||
_gfxCursor32->init(_gfxFrameout->getCurrentBuffer());
|
||||
_gfxText32 = new GfxText32(_gamestate->_segMan, _gfxCache);
|
||||
_gfxControls32 = new GfxControls32(_gamestate->_segMan, _gfxCache, _gfxText32);
|
||||
|
|
|
@ -75,7 +75,7 @@ class GfxCache;
|
|||
class GfxCompare;
|
||||
class GfxControls16;
|
||||
class GfxControls32;
|
||||
class GfxCoordAdjuster;
|
||||
class GfxCoordAdjuster16;
|
||||
class GfxCursor;
|
||||
class GfxMacIconBar;
|
||||
class GfxMenu;
|
||||
|
@ -369,7 +369,7 @@ public:
|
|||
GfxCompare *_gfxCompare;
|
||||
GfxControls16 *_gfxControls16; // Controls for 16-bit gfx
|
||||
GfxControls32 *_gfxControls32; // Controls for 32-bit gfx
|
||||
GfxCoordAdjuster *_gfxCoordAdjuster;
|
||||
GfxCoordAdjuster16 *_gfxCoordAdjuster;
|
||||
GfxCursor *_gfxCursor;
|
||||
GfxMenu *_gfxMenu; // Menu for 16-bit gfx
|
||||
GfxPalette *_gfxPalette16;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue