COMMON: Change Rect and Point to have int32 fields

This commit is contained in:
Paul Gilbert 2021-06-28 20:38:20 -07:00
parent 526a898454
commit 1c3e7fb4e9
53 changed files with 152 additions and 144 deletions

View file

@ -44,15 +44,15 @@ namespace Common {
* Simple class for handling both 2D position and size.
*/
struct Point {
int16 x; /*!< The horizontal position of the point. */
int16 y; /*!< The vertical position of the point. */
int32 x; /*!< The horizontal position of the point. */
int32 y; /*!< The vertical position of the point. */
Point() : x(0), y(0) {}
/**
* Create a point with position defined by @p x1 and @p y1.
*/
Point(int16 x1, int16 y1) : x(x1), y(y1) {}
Point(int32 x1, int32 y1) : x(x1), y(y1) {}
/**
* Determine whether the position of two points is the same.
*/
@ -143,21 +143,21 @@ static inline Point operator*(double multiplier, const Point &p) { return Point(
* When writing code using our Rect class, always keep this principle in mind!
*/
struct Rect {
int16 top, left; /*!< The point at the top left of the rectangle (part of the Rect). */
int16 bottom, right; /*!< The point at the bottom right of the rectangle (not part of the Rect). */
int32 top, left; /*!< The point at the top left of the rectangle (part of the Rect). */
int32 bottom, right; /*!< The point at the bottom right of the rectangle (not part of the Rect). */
Rect() : top(0), left(0), bottom(0), right(0) {}
/**
* Create a rectangle with the top-left corner at position (0, 0) and the given width @p w and height @p h.
*/
Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
Rect(int32 w, int32 h) : top(0), left(0), bottom(h), right(w) {}
/**
* Create a rectangle with the top-left corner at the given position (x1, y1)
* and the bottom-right corner at the position (x2, y2).
*
* The @p x2 value must be greater or equal @p x1 and @p y2 must be greater or equal @p y1.
*/
Rect(int16 x1, int16 y1, int16 x2, int16 y2) : top(y1), left(x1), bottom(y2), right(x2) {
Rect(int32 x1, int32 y1, int32 x2, int32 y2) : top(y1), left(x1), bottom(y2), right(x2) {
assert(isValidRect());
}
/**
@ -173,14 +173,14 @@ struct Rect {
*/
bool operator!=(const Rect &rhs) const { return !equals(rhs); }
int16 width() const { return right - left; } /*!< Return the width of a rectangle. */
int16 height() const { return bottom - top; } /*!< Return the height of a rectangle. */
int32 width() const { return right - left; } /*!< Return the width of a rectangle. */
int32 height() const { return bottom - top; } /*!< Return the height of a rectangle. */
void setWidth(int16 aWidth) { /*!< Set the width to @p aWidth value. */
void setWidth(int32 aWidth) { /*!< Set the width to @p aWidth value. */
right = left + aWidth;
}
void setHeight(int16 aHeight) { /*!< Set the height to @p aHeight value. */
void setHeight(int32 aHeight) { /*!< Set the height to @p aHeight value. */
bottom = top + aHeight;
}
@ -192,7 +192,7 @@ struct Rect {
*
* @return True if the given position is inside this rectangle, false otherwise.
*/
bool contains(int16 x, int16 y) const {
bool contains(int32 x, int32 y) const {
return (left <= x) && (x < right) && (top <= y) && (y < bottom);
}
@ -272,7 +272,7 @@ struct Rect {
*
* @param offset The size to grow by.
*/
void grow(int16 offset) {
void grow(int32 offset) {
top -= offset;
left -= offset;
bottom += offset;
@ -302,7 +302,7 @@ struct Rect {
/**
* Reduce the dimensions of this rectangle by setting max width and max heigth.
*/
void clip(int16 maxw, int16 maxh) {
void clip(int32 maxw, int32 maxh) {
clip(Rect(0, 0, maxw, maxh));
}
@ -326,7 +326,7 @@ struct Rect {
/**
* Move this rectangle to the position defined by @p x, @p y.
*/
void moveTo(int16 x, int16 y) {
void moveTo(int32 x, int32 y) {
bottom += y - top;
right += x - left;
top = y;
@ -336,7 +336,7 @@ struct Rect {
/**
* Move the rectangle by the given delta x and y values.
*/
void translate(int16 dx, int16 dy) {
void translate(int32 dx, int32 dy) {
left += dx; right += dx;
top += dy; bottom += dy;
}
@ -359,7 +359,7 @@ struct Rect {
* Create a rectangle around the given center.
* @note The center point is rounded up and left when given an odd width and height.
*/
static Rect center(int16 cx, int16 cy, int16 w, int16 h) {
static Rect center(int32 cx, int32 cy, int32 w, int32 h) {
int x = cx - w / 2, y = cy - h / 2;
return Rect(x, y, x + w, y + h);
}

View file

@ -67,7 +67,7 @@ void BubbleBox::clearBubbles() {
_vm->_screen->_screenYOff = 0;
Common::Rect r = _bubbles[i];
r.left -= 2;
r.right = MIN(r.right, (int16)_vm->_screen->w);
r.right = MIN(r.right, (int32)_vm->_screen->w);
_vm->_screen->copyBlock(&_vm->_buffer1, r);
}

View file

@ -1026,8 +1026,8 @@ bool BladeRunnerEngine::loadSplash() {
Common::Point BladeRunnerEngine::getMousePos() const {
Common::Point p = _eventMan->getMousePos();
p.x = CLIP(p.x, int16(0), int16(639));
p.y = CLIP(p.y, int16(0), int16(479));
p.x = CLIP(p.x, int32(0), int32(639));
p.y = CLIP(p.y, int32(0), int32(479));
return p;
}

View file

@ -957,10 +957,10 @@ void ESPER::drawPhotoWithGrid(Graphics::Surface &surface) {
}
void ESPER::drawSelection(Graphics::Surface &surface, bool crosshair, int style) {
int left = CLIP(_selection.left, _screen.left, (int16)(_screen.right - 1));
int top = CLIP(_selection.top, _screen.top, (int16)(_screen.bottom - 1));
int right = CLIP(_selection.right, _screen.left, (int16)(_screen.right - 1));
int bottom = CLIP(_selection.bottom, _screen.top, (int16)(_screen.bottom - 1));
int left = CLIP(_selection.left, _screen.left, (int32)(_screen.right - 1));
int top = CLIP(_selection.top, _screen.top, (int32)(_screen.bottom - 1));
int right = CLIP(_selection.right, _screen.left, (int32)(_screen.right - 1));
int bottom = CLIP(_selection.bottom, _screen.top, (int32)(_screen.bottom - 1));
int color = surface.format.RGBToColor(0, 144, 0);
if (style) {

View file

@ -1389,8 +1389,8 @@ bool checkInput(int16 *buttonPtr) {
extern bool manageEvents();
int CruiseEngine::processInput() {
int16 mouseX = 0;
int16 mouseY = 0;
int32 mouseX = 0;
int32 mouseY = 0;
int16 button = 0;
/*if (inputSub1keyboad())
@ -1746,7 +1746,7 @@ bool manageEvents() {
return false;
}
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY) {
void getMouseStatus(int16 *pMouseVar, int32 *pMouseX, int16 *pMouseButton, int32 *pMouseY) {
*pMouseX = currentMouseX;
*pMouseY = currentMouseY;
*pMouseButton = currentMouseButton;
@ -1757,7 +1757,7 @@ void CruiseEngine::mainLoop() {
//int32 t_start,t_left;
//uint32 t_end;
//int32 q=0; /* Dummy */
int16 mouseX, mouseY;
int32 mouseX, mouseY;
int16 mouseButton;
int enableUser = 0;

View file

@ -101,7 +101,7 @@ void getFileExtention(const char *name, char *buffer);
void *allocAndZero(int size);
void freeStuff2();
void mainLoop();
void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
void getMouseStatus(int16 *pMouseVar, int32 *pMouseX, int16 *pMouseButton, int32 *pMouseY);
bool testMask(int x, int y, unsigned char* pData, int stride);
menuElementSubStruct *getSelectedEntryInMenu(menuStruct *pMenu);
void closeAllMenu();

View file

@ -164,8 +164,8 @@ int16 Op_Narrator() {
int16 Op_GetMouseX() {
int16 dummy;
int16 mouseX;
int16 mouseY;
int32 mouseX;
int32 mouseY;
int16 mouseButton;
getMouseStatus(&dummy, &mouseX, &mouseButton, &mouseY);
@ -175,8 +175,8 @@ int16 Op_GetMouseX() {
int16 Op_GetMouseY() {
int16 dummy;
int16 mouseX;
int16 mouseY;
int32 mouseX;
int32 mouseY;
int16 mouseButton;
getMouseStatus(&dummy, &mouseX, &mouseButton, &mouseY);
@ -705,8 +705,8 @@ int16 Op_FadeIn() {
int16 Op_GetMouseButton() {
int16 dummy;
int16 mouseX;
int16 mouseY;
int32 mouseX;
int32 mouseY;
int16 mouseButton;
getMouseStatus(&dummy, &mouseX, &mouseButton, &mouseY);

View file

@ -230,8 +230,8 @@ void gfxModuleData_flipScreen() {
}
void gfxModuleData_addDirtyRect(const Common::Rect &r) {
_vm->_dirtyRects.push_back(Common::Rect( MAX(r.left, (int16)0), MAX(r.top, (int16)0),
MIN(r.right, (int16)320), MIN(r.bottom, (int16)200)));
_vm->_dirtyRects.push_back(Common::Rect( MAX(r.left, (int32)0), MAX(r.top, (int32)0),
MIN(r.right, (int32)320), MIN(r.bottom, (int32)200)));
}
/**

View file

@ -1561,8 +1561,8 @@ void mainDraw(bool waitFl) {
return;
}
} else if ((linkedRelation) && (linkedMsgList)) {
int16 mouseX;
int16 mouseY;
int32 mouseX;
int32 mouseY;
int16 button;
getMouseStatus(&main10, &mouseX, &button, &mouseY);

View file

@ -152,8 +152,8 @@ void updateMenuMouse(int mouseX, int mouseY, menuStruct *pMenu) {
bool manageEvents();
int processMenu(menuStruct *pMenu) {
int16 mouseX;
int16 mouseY;
int32 mouseX;
int32 mouseY;
int16 mouseButton;
int di;
int si;

View file

@ -147,8 +147,8 @@ void Selection::startSelection(const Point &pos) {
return;
}
tx = MIN(pos.x, (int16)_hor);
ty = MIN(pos.y, (int16)_ver);
tx = MIN(pos.x, (int32)_hor);
ty = MIN(pos.y, (int32)_ver);
_select.left = _select.right = _last.x = tx;
_select.top = _select.bottom = _last.y = ty;
@ -167,8 +167,8 @@ void Selection::moveSelection(const Point &pos) {
return;
}
tx = MIN(pos.x, (int16)_hor);
ty = MIN(pos.y, (int16)_ver);
tx = MIN(pos.x, (int32)_hor);
ty = MIN(pos.y, (int32)_ver);
_select.right = _last.x = tx;
_select.bottom = _last.y = ty;

View file

@ -101,8 +101,8 @@ public:
*/
void setSize(const Point &newSize) override {
Window::setSize(newSize);
_curX = CLIP((int16)_curX, _bbox.left, _bbox.right);
_curY = CLIP((int16)_curY, _bbox.top, _bbox.bottom);
_curX = CLIP((int32)_curX, _bbox.left, _bbox.right);
_curY = CLIP((int32)_curY, _bbox.top, _bbox.bottom);
}
/**
@ -110,8 +110,8 @@ public:
*/
void setPosition(const Point &newPos) override {
_bbox.moveTo(newPos);
_curX = CLIP((int16)_curX, _bbox.left, _bbox.right);
_curY = CLIP((int16)_curY, _bbox.top, _bbox.bottom);
_curX = CLIP((int32)_curX, _bbox.left, _bbox.right);
_curY = CLIP((int32)_curY, _bbox.top, _bbox.bottom);
}
/**

View file

@ -1227,10 +1227,10 @@ void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common:
// Move for scrolling offset and adjust to crop on-screen
r.translate(-_scrollPosX, 0);
r.left = MAX(r.left, (int16)0);
r.top = MAX(r.top, (int16)0);
r.right = MIN(r.right, (int16)SCREEN_WIDTH);
r.bottom = MIN(r.bottom, (int16)SCREEN_HEIGHT);
r.left = MAX(r.left, (int32)0);
r.top = MAX(r.top, (int32)0);
r.right = MIN(r.right, (int32)SCREEN_WIDTH);
r.bottom = MIN(r.bottom, (int32)SCREEN_HEIGHT);
// If there's an on-screen portion, display it
if (r.isValidRect())

View file

@ -738,8 +738,8 @@ void Gui::drawDraggedObject() {
ImageAsset *asset = _assets[_draggedObj.id];
// In case of overflow from the right/top
uint w = asset->getWidth() + MIN((int16)0, _draggedObj.pos.x);
uint h = asset->getHeight() + MIN((int16)0, _draggedObj.pos.y);
uint w = asset->getWidth() + MIN((int32)0, _draggedObj.pos.x);
uint h = asset->getHeight() + MIN((int32)0, _draggedObj.pos.y);
// In case of overflow from the bottom/left
if (_draggedObj.pos.x > 0 && _draggedObj.pos.x + w > kScreenWidth) {
@ -766,7 +766,7 @@ void Gui::drawDraggedObject() {
target.x + _draggedSurface.w,
target.y + _draggedSurface.h),
Common::Point(0, 0));
asset->blitInto(&_draggedSurface, MIN((int16)0, _draggedObj.pos.x), MIN((int16)0, _draggedObj.pos.y), kBlitBIC);
asset->blitInto(&_draggedSurface, MIN((int32)0, _draggedObj.pos.x), MIN((int32)0, _draggedObj.pos.y), kBlitBIC);
g_system->copyRectToScreen(
_draggedSurface.getBasePtr(0, 0),

View file

@ -83,7 +83,7 @@ void Camera::camPanTo(int target) {
}
}
bool Camera::camPan(int16 *picture_view, int16 *player_loc, int display_size, int picture_size) {
bool Camera::camPan(int32 *picture_view, int32 *player_loc, int display_size, int picture_size) {
bool panningFl = false;
if (_panAllowedFl) {
Scene &scene = _vm->_game->_scene;

View file

@ -53,7 +53,7 @@ public:
Camera(MADSEngine *vm);
void camPanTo(int target);
bool camPan(int16 *picture_view, int16 *player_loc, int display_size, int picture_size);
bool camPan(int32 *picture_view, int32 *player_loc, int display_size, int picture_size);
void setDefaultPanX();
void setDefaultPanY();
};

View file

@ -342,7 +342,7 @@ void Player::update() {
scene._spriteSlots[slotIndex]._flags = IMG_ERASE;
int newDepth = 1;
int yp = MIN(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
int yp = MIN(_playerPos.y, (int32)(MADS_SCENE_HEIGHT - 1));
for (int idx = 1; idx < DEPTH_BANDS_SIZE; ++idx) {
if (scene._sceneInfo->_depthList[newDepth] >= yp)

View file

@ -46,7 +46,7 @@ typedef uint32 NotificationFlags;
// Mac types.
typedef int16 ResIDType;
typedef int16 CoordType;
typedef int32 CoordType;
enum SlideDirection {
kSlideLeftMask = 1,

View file

@ -80,8 +80,8 @@ void PrinceEngine::changeCursor(uint16 curId) {
case 3:
curSurface = _cursor3->getSurface();
Common::Point mousePos = _system->getEventManager()->getMousePos();
mousePos.x = CLIP(mousePos.x, (int16) 315, (int16) 639);
mousePos.y = CLIP(mousePos.y, (int16) 0, (int16) 170);
mousePos.x = CLIP(mousePos.x, (int32) 315, (int32) 639);
mousePos.y = CLIP(mousePos.y, (int32) 0, (int32) 170);
_system->warpMouse(mousePos.x, mousePos.y);
break;
}

View file

@ -1016,9 +1016,9 @@ void PrinceEngine::mouseWeirdo() {
default:
break;
}
mousePos.x = CLIP(mousePos.x, (int16) 315, (int16) 639);
mousePos.x = CLIP(mousePos.x, (int32) 315, (int32) 639);
_flags->setFlagValue(Flags::MXFLAG, mousePos.x);
mousePos.y = CLIP(mousePos.y, (int16) 0, (int16) 170);
mousePos.y = CLIP(mousePos.y, (int32) 0, (int32) 170);
_flags->setFlagValue(Flags::MYFLAG, mousePos.y);
_system->warpMouse(mousePos.x, mousePos.y);
}

View file

@ -323,8 +323,8 @@ reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan;
if (obj.getSegment()) {
int16 x = readSelectorValue(segMan, obj, SELECTOR(x));
int16 y = readSelectorValue(segMan, obj, SELECTOR(y));
int32 x = readSelectorValue(segMan, obj, SELECTOR(x));
int32 y = readSelectorValue(segMan, obj, SELECTOR(y));
g_sci->_gfxCoordAdjuster->kernelGlobalToLocal(x, y);
@ -341,8 +341,8 @@ reg_t kLocalToGlobal(EngineState *s, int argc, reg_t *argv) {
SegManager *segMan = s->_segMan;
if (obj.getSegment()) {
int16 x = readSelectorValue(segMan, obj, SELECTOR(x));
int16 y = readSelectorValue(segMan, obj, SELECTOR(y));
int32 x = readSelectorValue(segMan, obj, SELECTOR(x));
int32 y = readSelectorValue(segMan, obj, SELECTOR(y));
g_sci->_gfxCoordAdjuster->kernelLocalToGlobal(x, y);

View file

@ -39,13 +39,13 @@ GfxCoordAdjuster16::GfxCoordAdjuster16(GfxPorts *ports)
GfxCoordAdjuster16::~GfxCoordAdjuster16() {
}
void GfxCoordAdjuster16::kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject) {
void GfxCoordAdjuster16::kernelGlobalToLocal(int32 &x, int32 &y, reg_t planeObject) {
Port *curPort = _ports->getPort();
x -= curPort->left;
y -= curPort->top;
}
void GfxCoordAdjuster16::kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject) {
void GfxCoordAdjuster16::kernelLocalToGlobal(int32 &x, int32 &y, reg_t planeObject) {
Port *curPort = _ports->getPort();
x += curPort->left;
y += curPort->top;

View file

@ -40,8 +40,8 @@ public:
GfxCoordAdjuster16(GfxPorts *ports);
~GfxCoordAdjuster16();
void kernelGlobalToLocal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
void kernelGlobalToLocal(int32 &x, int32 &y, reg_t planeObject = NULL_REG);
void kernelLocalToGlobal(int32 &x, int32 &y, reg_t planeObject = NULL_REG);
Common::Rect onControl(Common::Rect rect);
void setCursorPos(Common::Point &pos);

View file

@ -363,8 +363,8 @@ void GfxMenu::drawBar() {
listIterator = _list.begin();
while (listIterator != listEnd) {
listEntry = *listIterator;
int16 textWidth;
int16 textHeight;
int32 textWidth;
int32 textHeight;
if (g_sci->isLanguageRTL()) {
_text16->StringWidth(listEntry->textSplit.c_str(), _text16->GetFontId(), textWidth, textHeight);
_ports->_curPort->curLeft -= textWidth;
@ -383,7 +383,7 @@ void GfxMenu::calculateMenuWidth() {
GuiMenuList::iterator menuIterator;
GuiMenuList::iterator menuEnd = _list.end();
GuiMenuEntry *menuEntry;
int16 dummyHeight;
int32 dummyHeight;
menuIterator = _list.begin();
while (menuIterator != menuEnd) {
@ -400,7 +400,7 @@ void GfxMenu::calculateMenuAndItemWidth() {
GuiMenuItemList::iterator itemIterator;
GuiMenuItemList::iterator itemEnd = _itemList.end();
GuiMenuItemEntry *itemEntry;
int16 dummyHeight;
int32 dummyHeight;
calculateMenuWidth();
@ -1024,8 +1024,8 @@ void GfxMenu::kernelDrawStatus(const char *text, int16 colorPen, int16 colorBack
if (!g_sci->isLanguageRTL()) {
_ports->moveTo(0, 1);
} else {
int16 textWidth;
int16 textHeight;
int32 textWidth;
int32 textHeight;
_text16->StringWidth(text, _text16->GetFontId(), textWidth, textHeight);
_ports->moveTo(_screen->getWidth() - textWidth, 1);
}

View file

@ -43,7 +43,7 @@ struct GuiMenuEntry {
uint16 id;
Common::String text;
Common::String textSplit;
int16 textWidth;
int32 textWidth;
GuiMenuEntry(uint16 curId)
: id(curId), textWidth(0) { }
@ -62,9 +62,9 @@ struct GuiMenuItemEntry {
Common::String text;
Common::String textSplit;
reg_t textVmPtr;
int16 textWidth;
int32 textWidth;
Common::String textRightAligned;
int16 textRightAlignedWidth;
int32 textRightAlignedWidth;
GuiMenuItemEntry(uint16 curMenuId, uint16 curId)
: menuId(curMenuId), id(curId),

View file

@ -82,9 +82,9 @@ void GfxPicture::draw(bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
}
void GfxPicture::reset() {
int16 startY = _ports->getPort()->top;
int16 startX = 0;
int16 x, y;
int32 startY = _ports->getPort()->top;
int32 startX = 0;
int32 x, y;
_screen->vectorAdjustCoordinate(&startX, &startY);
for (y = startY; y < _screen->getHeight(); y++) {
for (x = startX; x < _screen->getWidth(); x++) {
@ -868,11 +868,11 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by
}
// hard borders for filling
int16 borderLeft = curPort->rect.left + curPort->left;
int16 borderTop = curPort->rect.top + curPort->top;
int16 borderRight = curPort->rect.right + curPort->left - 1;
int16 borderBottom = curPort->rect.bottom + curPort->top - 1;
int16 curToLeft, curToRight, a_set, b_set;
int32 borderLeft = curPort->rect.left + curPort->left;
int32 borderTop = curPort->rect.top + curPort->top;
int32 borderRight = curPort->rect.right + curPort->left - 1;
int32 borderBottom = curPort->rect.bottom + curPort->top - 1;
int32 curToLeft, curToRight, a_set, b_set;
// Translate coordinates, if required (needed for Macintosh 480x300)
_screen->vectorAdjustCoordinate(&borderLeft, &borderTop);

View file

@ -980,12 +980,12 @@ struct UpScaledAdjust {
int denominator;
};
void GfxScreen::adjustToUpscaledCoordinates(int16 &y, int16 &x) {
void GfxScreen::adjustToUpscaledCoordinates(int32 &y, int32 &x) {
x = _upscaledWidthMapping[x];
y = _upscaledHeightMapping[y];
}
void GfxScreen::adjustBackUpscaledCoordinates(int16 &y, int16 &x) {
void GfxScreen::adjustBackUpscaledCoordinates(int32 &y, int32 &x) {
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_480x300:
x = (x * 4) / 6;

View file

@ -128,8 +128,8 @@ public:
void scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel = 1);
void adjustToUpscaledCoordinates(int16 &y, int16 &x);
void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
void adjustToUpscaledCoordinates(int32 &y, int32 &x);
void adjustBackUpscaledCoordinates(int32 &y, int32 &x);
void dither(bool addToFlag);
@ -459,7 +459,7 @@ public:
return vectorGetPixel(_controlScreen, x, y);
}
void vectorAdjustCoordinate(int16 *x, int16 *y) {
void vectorAdjustCoordinate(int32 *x, int32 *y) {
switch (_upscaledHires) {
case GFX_SCREEN_UPSCALED_480x300:
*x = (*x * 3) / 2;

View file

@ -367,7 +367,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId
return resultCharCount;
}
void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont) {
void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int32 &textWidth, int32 &textHeight, bool restoreFont) {
uint16 curChar;
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
@ -412,7 +412,7 @@ void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId org
return;
}
void GfxText16::StringWidth(const Common::String &str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight) {
void GfxText16::StringWidth(const Common::String &str, GuiResourceId orgFontId, int32 &textWidth, int32 &textHeight) {
Width(str.c_str(), 0, str.size(), orgFontId, textWidth, textHeight, true);
}
@ -423,12 +423,12 @@ void GfxText16::DrawString(const Common::String &str, GuiResourceId orgFontId, i
Draw(str.c_str(), 0, str.size(), orgFontId, orgPenColor);
}
int16 GfxText16::Size(Common::Rect &rect, const char *text, uint16 languageSplitter, GuiResourceId fontId, int16 maxWidth) {
int16 GfxText16::Size(Common::Rect &rect, const char *text, uint16 languageSplitter, GuiResourceId fontId, int32 maxWidth) {
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
int16 charCount;
int16 maxTextWidth = 0, textWidth;
int16 totalHeight = 0, textHeight;
int32 maxTextWidth = 0, textWidth;
int32 totalHeight = 0, textHeight;
if (fontId != -1)
SetFont(fontId);
@ -538,7 +538,7 @@ void GfxText16::Show(const char *text, int16 from, int16 len, GuiResourceId orgF
// Draws a text in rect.
void GfxText16::Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
int16 textWidth, maxTextWidth, textHeight, charCount;
int32 textWidth, maxTextWidth, textHeight, charCount;
int16 offset = 0;
int16 hline = 0;
GuiResourceId previousFontId = GetFontId();

View file

@ -52,11 +52,11 @@ public:
void ClearChar(int16 chr);
int16 GetLongest(const char *&text, int16 maxWidth, GuiResourceId orgFontId);
void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont);
void StringWidth(const Common::String &str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int32 &textWidth, int32 &textHeight, bool restoreFont);
void StringWidth(const Common::String &str, GuiResourceId orgFontId, int32 &textWidth, int32 &textHeight);
void ShowString(const Common::String &str, GuiResourceId orgFontId, int16 orgPenColor);
void DrawString(const Common::String &str, GuiResourceId orgFontId, int16 orgPenColor);
int16 Size(Common::Rect &rect, const char *text, uint16 textLanguage, GuiResourceId fontId, int16 maxWidth);
int16 Size(Common::Rect &rect, const char *text, uint16 textLanguage, GuiResourceId fontId, int32 maxWidth);
void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
void Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);

View file

@ -462,7 +462,7 @@ void GfxTransitions::straight(int16 number, bool blackoutFlag) {
}
}
void GfxTransitions::scrollCopyOldToScreen(Common::Rect screenRect, int16 x, int16 y) {
void GfxTransitions::scrollCopyOldToScreen(Common::Rect screenRect, int32 x, int32 y) {
if (_screen->getUpscaledHires()) {
_screen->adjustToUpscaledCoordinates(screenRect.top, screenRect.left);
_screen->adjustToUpscaledCoordinates(screenRect.bottom, screenRect.right);

View file

@ -80,7 +80,7 @@ private:
void pixelation(bool blackoutFlag);
void blocks(bool blackoutFlag);
void straight(int16 number, bool blackoutFlag);
void scrollCopyOldToScreen(Common::Rect screenRect, int16 x, int16 y);
void scrollCopyOldToScreen(Common::Rect screenRect, int32 x, int32 y);
void scroll(int16 number);
void verticalRollFromCenter(bool blackoutFlag);
void verticalRollToCenter(bool blackoutFlag);

View file

@ -805,8 +805,8 @@ void GfxView::draw(const Common::Rect &rect, const Common::Rect &clipRect, const
const Palette *palette = _embeddedPal ? &_viewPalette : &_palette->_sysPalette;
const CelInfo *celInfo = getCelInfo(loopNo, celNo);
const SciSpan<const byte> &bitmap = getBitmap(loopNo, celNo);
const int16 celHeight = celInfo->height;
const int16 celWidth = celInfo->width;
const int32 celHeight = celInfo->height;
const int32 celWidth = celInfo->width;
const byte clearKey = celInfo->clearKey;
const byte drawMask = priority > 15 ? GFX_SCREEN_MASK_VISUAL : GFX_SCREEN_MASK_VISUAL|GFX_SCREEN_MASK_PRIORITY;
@ -814,8 +814,8 @@ void GfxView::draw(const Common::Rect &rect, const Common::Rect &clipRect, const
// Merge view palette in...
_palette->set(&_viewPalette, false);
const int16 width = MIN(clipRect.width(), celWidth);
const int16 height = MIN(clipRect.height(), celHeight);
const int32 width = MIN(clipRect.width(), celWidth);
const int32 height = MIN(clipRect.height(), celHeight);
if (!width || !height) {
return;
@ -886,11 +886,11 @@ void GfxView::drawScaled(const Common::Rect &rect, const Common::Rect &clipRect,
createScalingTable(scalingX, celWidth, _screen->getWidth(), scaleX);
createScalingTable(scalingY, celHeight, _screen->getHeight(), scaleY);
int16 scaledWidth = MIN(clipRect.width(), (int16)scalingX.size());
int16 scaledHeight = MIN(clipRect.height(), (int16)scalingY.size());
int32 scaledWidth = MIN(clipRect.width(), (int32)scalingX.size());
int32 scaledHeight = MIN(clipRect.height(), (int32)scalingY.size());
const int16 offsetY = clipRect.top - rect.top;
const int16 offsetX = clipRect.left - rect.left;
const int32 offsetY = clipRect.top - rect.top;
const int32 offsetX = clipRect.left - rect.left;
const byte *bitmapData = bitmap.getUnsafeDataAt(0, celWidth * celHeight);
for (int y = 0; y < scaledHeight; y++) {
@ -930,11 +930,11 @@ void GfxView::createScalingTable(Common::Array<uint16> &table, int16 celSize, ui
}
}
void GfxView::adjustToUpscaledCoordinates(int16 &y, int16 &x) {
void GfxView::adjustToUpscaledCoordinates(int32 &y, int32 &x) {
_screen->adjustToUpscaledCoordinates(y, x);
}
void GfxView::adjustBackUpscaledCoordinates(int16 &y, int16 &x) {
void GfxView::adjustBackUpscaledCoordinates(int32 &y, int32 &x) {
_screen->adjustBackUpscaledCoordinates(y, x);
}

View file

@ -78,8 +78,8 @@ public:
bool isScaleable();
void adjustToUpscaledCoordinates(int16 &y, int16 &x);
void adjustBackUpscaledCoordinates(int16 &y, int16 &x);
void adjustToUpscaledCoordinates(int32 &y, int32 &x);
void adjustBackUpscaledCoordinates(int32 &y, int32 &x);
private:
void initData(GuiResourceId resourceId);

View file

@ -1806,7 +1806,7 @@ AdjustBoxResult Actor_v2::adjustXYToBeInBox(const int dstX, const int dstY) {
AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY) {
const uint thresholdTable[] = { 30, 80, 0 };
AdjustBoxResult abr;
int16 tmpX, tmpY;
int32 tmpX, tmpY;
int tmpDist, bestDist, threshold, numBoxes;
byte flags, bestBox;
int box;

View file

@ -643,7 +643,7 @@ BoxCoords ScummEngine::getBoxCoordinates(int boxnum) {
return *box;
}
int getClosestPtOnBox(const BoxCoords &box, int x, int y, int16& outX, int16& outY) {
int getClosestPtOnBox(const BoxCoords &box, int x, int y, int32 &outX, int32 &outY) {
const Common::Point p(x, y);
Common::Point tmp;
uint dist;

View file

@ -49,7 +49,7 @@ struct BoxCoords { /* Box coordinates */
Common::Point lr;
};
int getClosestPtOnBox(const BoxCoords &box, int x, int y, int16& outX, int16& outY);
int getClosestPtOnBox(const BoxCoords &box, int x, int y, int32 & outX, int32 & outY);
} // End of namespace Scumm

View file

@ -2091,7 +2091,7 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i
bbox[3].x = 0;
bbox[3].y = wizH - 1;
int16 xmin_p, xmax_p, ymin_p, ymax_p;
int32 xmin_p, xmax_p, ymin_p, ymax_p;
xmin_p = ymin_p = (int16)0x7FFF;
xmax_p = ymax_p = (int16)0x8000;
@ -2102,7 +2102,7 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i
ymax_p = MAX(wp[i].y, ymax_p);
}
int16 xmin_b, xmax_b, ymin_b, ymax_b;
int32 xmin_b, xmax_b, ymin_b, ymax_b;
xmin_b = ymin_b = (int16)0x7FFF;
xmax_b = ymax_b = (int16)0x8000;

View file

@ -56,7 +56,7 @@ struct VerbSlot {
bool center;
uint8 prep;
uint16 imgindex;
int16 origLeft;
int32 origLeft;
};
enum VerbsV0 {

View file

@ -154,7 +154,7 @@ void Events::setCursor(CursorId cursorId, const Common::Point &cursorPos, const
s.SHblitFrom(surface, Common::Point(drawPos.x, drawPos.y));
// Draw the cursor image
drawPos = Common::Point(MAX(cursorPt.x, (int16)0), MAX(cursorPt.y, (int16)0));
drawPos = Common::Point(MAX(cursorPt.x, (int32)0), MAX(cursorPt.y, (int32)0));
s.SHtransBlitFrom(cursorImg, Common::Point(drawPos.x, drawPos.y));
// Set up hotspot position for cursor, adjusting for cursor image's position within the surface

View file

@ -204,8 +204,8 @@ void Screen::slamRect(const Common::Rect &r) {
}
}
void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width_, int16 *height_) {
void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, int32 *xp, int32 *yp,
int32 *width_, int32 *height_) {
Common::Point imgPos = pt + frame->_offset;
Common::Rect newBounds(imgPos.x, imgPos.y, imgPos.x + frame->_frame.w, imgPos.y + frame->_frame.h);
Common::Rect oldBounds(*xp, *yp, *xp + *width_, *yp + *height_);
@ -232,8 +232,8 @@ void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, i
*height_ = newBounds.height();
}
void Screen::flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width_, int16 *height_, int scaleVal) {
void Screen::flushScaleImage(ImageFrame *frame, const Common::Point &pt, int32 *xp, int32 *yp,
int32 *width_, int32 *height_, int scaleVal) {
Common::Point imgPos(pt.x + frame->sDrawXOffset(scaleVal), pt.y + frame->sDrawYOffset(scaleVal));
Common::Rect newBounds(imgPos.x, imgPos.y, imgPos.x + frame->sDrawXSize(scaleVal),
imgPos.y + frame->sDrawYSize(scaleVal));

View file

@ -132,15 +132,15 @@ public:
* Copy an image from the back buffer to the screen, taking care of both the
* new area covered by the shape as well as the old area, which must be restored
*/
void flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width, int16 *height);
void flushImage(ImageFrame *frame, const Common::Point &pt, int32 *xp, int32 *yp,
int32 *width, int32 *height);
/**
* Similar to flushImage, this method takes in an extra parameter for the scale proporation,
* which affects the calculated bounds accordingly
*/
void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp,
int16 *width, int16 *height, int scaleVal);
void flushScaleImage(ImageFrame *frame, const Common::Point &pt, int32 *xp, int32 *yp,
int32 *width, int32 *height, int scaleVal);
/**
* Variation of flushImage/flushScaleImage that takes in and updates a rect

View file

@ -46,10 +46,18 @@ static void saveOrLoad(Common::WriteStream &stream, int16 &i) {
stream.writeSint16LE(i);
}
static void saveOrLoad(Common::WriteStream &stream, int32 &i) {
stream.writeSint16LE(i);
}
static void saveOrLoad(Common::ReadStream &stream, int16 &i) {
i = stream.readSint16LE();
}
static void saveOrLoad(Common::ReadStream &stream, int32 &i) {
i = stream.readSint16LE();
}
static void saveOrLoadPtr(Common::WriteStream &stream, int16 *&p, int16 *base) {
int32 offset = (int32)(p - base);
stream.writeSint32LE(offset);

View file

@ -511,7 +511,7 @@ OptionsDialog::OptionsDialog() {
// Set all the buttons to the widest button
GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
int16 btnWidth = 0;
int32 btnWidth = 0;
for (int idx = 0; idx < 6; ++idx)
btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
for (int idx = 0; idx < 6; ++idx)

View file

@ -2841,7 +2841,7 @@ GfxSurface SceneObject::getFrame() {
void SceneObject::reposition() {
if (g_vm->getGameID() == GType_Ringworld2) {
if (!(_flags & OBJFLAG_ZOOMED)) {
setZoom(g_globals->_sceneManager._scene->_zoomPercents[MIN(_position.y, (int16)255)]);
setZoom(g_globals->_sceneManager._scene->_zoomPercents[MIN(_position.y, (int32)255)]);
}
}

View file

@ -282,7 +282,7 @@ OptionsDialog::OptionsDialog() {
// Set all the buttons to the widest button
GfxButton *btnList[6] = {&_btnRestore, &_btnSave, &_btnRestart, &_btnQuit, &_btnSound, &_btnResume};
int16 btnWidth = 0;
int32 btnWidth = 0;
for (int idx = 0; idx < 6; ++idx)
btnWidth = MAX(btnWidth, btnList[idx]->_bounds.width());
for (int idx = 0; idx < 6; ++idx)

View file

@ -144,8 +144,8 @@ void Map::MapBase::shiftViewport(const Point &delta) {
topLeft += delta;
// Shift the viewport, but constraining the map to fill up the screen
topLeft.x = CLIP(topLeft.x, (int16)0, (int16)(width() - _viewportPos._size.x));
topLeft.y = CLIP(topLeft.y, (int16)0, (int16)(height() - _viewportPos._size.y));
topLeft.x = CLIP(topLeft.x, (int32)0, (int32)(width() - _viewportPos._size.x));
topLeft.y = CLIP(topLeft.y, (int32)0, (int32)(height() - _viewportPos._size.y));
}
void Map::MapBase::addWidget(MapWidget *widget) {

View file

@ -156,8 +156,8 @@ void MapBase::shiftViewport(const Point &delta) {
topLeft += delta;
// Shift the viewport, but constraining the map to fill up the screen
topLeft.x = CLIP(topLeft.x, (int16)0, (int16)(width() - _viewportPos._size.x));
topLeft.y = CLIP(topLeft.y, (int16)0, (int16)(height() - _viewportPos._size.y));
topLeft.x = CLIP(topLeft.x, (int32)0, (int32)(width() - _viewportPos._size.x));
topLeft.y = CLIP(topLeft.y, (int32)0, (int32)(height() - _viewportPos._size.y));
}
void MapBase::addWidget(MapWidget *widget) {

View file

@ -195,7 +195,7 @@ bool Design::isPointOpaque(int x, int y) {
return pixel != kColorGreen;
}
void Design::adjustBounds(int16 x, int16 y) {
void Design::adjustBounds(int32 x, int32 y) {
_bounds->right = MAX(x, _bounds->right);
_bounds->bottom = MAX(y, _bounds->bottom);
}

View file

@ -83,7 +83,7 @@ public:
static void drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Graphics::MacPatterns &patterns, byte fillType);
bool isBoundsCalculation() { return _boundsCalculationMode; }
void adjustBounds(int16 x, int16 y);
void adjustBounds(int32 x, int32 y);
private:
byte *_data;

View file

@ -370,7 +370,7 @@ void SpriteDrawer::draw(XSurface &dest, uint16 offset, const Common::Point &pt,
(flags & SPRFLAG_SCENE_CLIPPED) ? SCENE_CLIP_LEFT : clipRect.left, destPos.y);
_destRight = (byte *)dest.getBasePtr(
(flags & SPRFLAG_SCENE_CLIPPED) ? SCENE_CLIP_RIGHT : clipRect.right, destPos.y);
int16 xp = destPos.x;
int32 xp = destPos.x;
lineP = &tempLine[SCREEN_WIDTH];
for (int xCtr = 0; xCtr < width; ++xCtr, ++lineP) {

View file

@ -765,7 +765,7 @@ void MacWindowManager::draw() {
}
adjustDimensions(clip, innerDims, adjWidth, adjHeight);
g_system->copyRectToScreen(w->getWindowSurface()->getBasePtr(MAX(clip.left - innerDims.left, 0), MAX(clip.top - innerDims.top, 0)), w->getWindowSurface()->pitch,MAX(innerDims.left, (int16)0), MAX(innerDims.top, (int16)0), adjWidth, adjHeight);
g_system->copyRectToScreen(w->getWindowSurface()->getBasePtr(MAX(clip.left - innerDims.left, 0), MAX(clip.top - innerDims.top, 0)), w->getWindowSurface()->pitch,MAX(innerDims.left, (int32)0), MAX(innerDims.top, (int32)0), adjWidth, adjHeight);
dirtyRects.push_back(clip);
}

View file

@ -1163,7 +1163,7 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s
dd = kDDSliderDisabled;
Common::Rect r2 = r;
r2.setWidth(MIN((int16)width, r.width()));
r2.setWidth(MIN((int32)width, r.width()));
// r2.top++; r2.bottom--; r2.left++; r2.right--;
if (rtl) {