GRAPHICS: Changed surface classes sizes from uint16 to int16

This commit is contained in:
Paul Gilbert 2021-07-04 17:24:30 -07:00
parent 1c3e7fb4e9
commit baccbedf50
57 changed files with 151 additions and 153 deletions

View file

@ -176,8 +176,8 @@ Surface::Surface()
void Surface::copyRectToTexture(uint x, uint y, uint w, uint h, const void *srcPtr, uint srcPitch) {
Graphics::Surface *dstSurf = getSurface();
assert(x + w <= dstSurf->w);
assert(y + h <= dstSurf->h);
assert(x + w <= (uint)dstSurf->w);
assert(y + h <= (uint)dstSurf->h);
// *sigh* Common::Rect::extend behaves unexpected whenever one of the two
// parameters is an empty rect. Thus, we check whether the current dirty
@ -194,7 +194,7 @@ void Surface::copyRectToTexture(uint x, uint y, uint w, uint h, const void *srcP
const uint pitch = dstSurf->pitch;
const uint bytesPerPixel = dstSurf->format.bytesPerPixel;
if (srcPitch == pitch && x == 0 && w == dstSurf->w) {
if (srcPitch == pitch && x == 0 && w == (uint)dstSurf->w) {
memcpy(dst, src, h * pitch);
} else {
while (h-- > 0) {
@ -257,7 +257,7 @@ void Texture::allocate(uint width, uint height) {
// In case the needed texture dimension changed we will reinitialize the
// texture data buffer.
if (_glTexture.getWidth() != _textureData.w || _glTexture.getHeight() != _textureData.h) {
if (_glTexture.getWidth() != (uint)_textureData.w || _glTexture.getHeight() != (uint)_textureData.h) {
// Create a buffer for the texture data.
_textureData.create(_glTexture.getWidth(), _glTexture.getHeight(), _format);
}
@ -330,7 +330,7 @@ void TextureCLUT8::allocate(uint width, uint height) {
// We only need to reinitialize our CLUT8 surface when the output size
// changed.
if (width == _clut8Data.w && height == _clut8Data.h) {
if (width == (uint)_clut8Data.w && height == (uint)_clut8Data.h) {
return;
}
@ -443,7 +443,7 @@ void FakeTexture::allocate(uint width, uint height) {
// We only need to reinitialize our surface when the output size
// changed.
if (width == _rgbData.w && height == _rgbData.h) {
if (width == (uint)_rgbData.w && height == (uint)_rgbData.h) {
return;
}
@ -604,7 +604,7 @@ void TextureCLUT8GPU::allocate(uint width, uint height) {
// In case the needed texture dimension changed we will reinitialize the
// texture data buffer.
if (_clut8Texture.getWidth() != _clut8Data.w || _clut8Texture.getHeight() != _clut8Data.h) {
if (_clut8Texture.getWidth() != (uint)_clut8Data.w || _clut8Texture.getHeight() != (uint)_clut8Data.h) {
// Create a buffer for the texture data.
_clut8Data.create(_clut8Texture.getWidth(), _clut8Texture.getHeight(), Graphics::PixelFormat::createFormatCLUT8());
}

View file

@ -2281,7 +2281,7 @@ void SurfaceSdlGraphicsManager::displayActivityIconOnOSD(const Graphics::Surface
byte *dst = (byte *) _osdIconSurface->pixels;
const byte *src = (const byte *) icon->getPixels();
for (uint y = 0; y < icon->h; y++) {
for (int y = 0; y < icon->h; y++) {
memcpy(dst, src, icon->w * iconFormat.bytesPerPixel);
src += icon->pitch;
dst += _osdIconSurface->pitch;

View file

@ -34,7 +34,7 @@ BITMAP::BITMAP(Graphics::ManagedSurface *owner) : _owner(owner),
w(owner->w), h(owner->h), pitch(owner->pitch), format(owner->format),
clip(true), ct(0), cl(0), cr(owner->w), cb(owner->h) {
line.resize(h);
for (uint y = 0; y < h; ++y)
for (int y = 0; y < h; ++y)
line[y] = (byte *)_owner->getBasePtr(0, y);
}

View file

@ -33,7 +33,7 @@ class BITMAP {
private:
Graphics::ManagedSurface *_owner;
public:
uint16 &w, &h, &pitch;
int16 &w, &h, &pitch;
Graphics::PixelFormat &format;
bool clip;
int ct, cb, cl, cr;

View file

@ -1206,7 +1206,7 @@ bool SceneViewWindow::pushTransition(Graphics::Surface *curBackground, Graphics:
curBackground->move(-stripSize, 0, curBackground->h);
for (int j = 0; j < curBackground->h; j++)
memcpy(curBackground->getBasePtr(curBackground->w - stripSize, j), newBackground->getBasePtr(i, j), stripSize * newBackground->format.bytesPerPixel);
memcpy(curBackground->getBasePtr(curBackground->w - (int)stripSize, j), newBackground->getBasePtr(i, j), stripSize * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();

View file

@ -541,8 +541,8 @@ void CryOmni3DEngine_Versailles::makeTranslucent(Graphics::Surface &dst,
const byte *srcP = (const byte *) src.getPixels();
byte *dstP = (byte *) dst.getPixels();
for (uint y = 0; y < dst.h; y++) {
for (uint x = 0; x < dst.w; x++) {
for (int y = 0; y < dst.h; y++) {
for (int x = 0; x < dst.w; x++) {
dstP[x] = _transparentPaletteMap[srcP[x]];
}
dstP += dst.pitch;

View file

@ -226,7 +226,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
}
int offset = 0;
if (_surface->w < (pixels.size() / _surface->h))
if (_surface->w < (int)(pixels.size() / _surface->h))
offset = (pixels.size() / _surface->h) - _surface->w;
uint32 color;

View file

@ -118,11 +118,11 @@ void Debugger::saveRawPicture(const RawDecoder &rd, Common::WriteStream &ws) {
Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
Graphics::ManagedSurface destSurface(surface->w, surface->h, format);
for (uint y = 0; y < surface->h; ++y) {
for (int y = 0; y < surface->h; ++y) {
const byte *srcP = (const byte *)surface->getBasePtr(0, y);
uint32 *destP = (uint32 *)destSurface.getBasePtr(0, y);
for (uint x = 0; x < surface->w; ++x, ++srcP, ++destP) {
for (int x = 0; x < surface->w; ++x, ++srcP, ++destP) {
if ((int)*srcP == transColor || (int)*srcP < palStart) {
*destP = format.ARGBToColor(0, 0, 0, 0);
} else {

View file

@ -922,7 +922,7 @@ bool GlkAPI::glk_image_draw_scaled(winid_t win, const Graphics::Surface &image,
if (!win) {
warning("image_draw_scaled: invalid ref");
} else if (g_conf->_graphics) {
if (image.w == width && image.h == height) {
if (image.w == (int16)width && image.h == (int16)height) {
return glk_image_draw(win, image, transColor, xp, yp);
} else {

View file

@ -217,7 +217,7 @@ Picture *Pictures::load(const Common::String &name) {
Picture *Pictures::scale(Picture *src, size_t sx, size_t sy) {
// Check for the presence of an already scaled version of that size
Picture *dst = retrieve(src->_name, true);
if (dst && dst->w == sx && dst->h == sy)
if (dst && (size_t)dst->w == sx && (size_t)dst->h == sy)
return dst;
// Create a new picture of the destination size and rescale the source picture

View file

@ -178,7 +178,7 @@ uint32 MovieManager::drawFrame(uint32 surface_id) {
}
// For access to buffer
uint16 pitch;
int16 pitch;
uint8 *surface_address;
// Lock the surface

View file

@ -6174,7 +6174,7 @@ void OptionsManager::DrawSlideShow() {
// Lock the buffers now so bink has somewhere ot put it's data
uint8 *surface = (uint8 *)surface_manager->Lock_surface(m_mySlotSurface1ID);
uint16 pitch = surface_manager->Get_pitch(m_mySlotSurface1ID);
int16 pitch = surface_manager->Get_pitch(m_mySlotSurface1ID);
uint32 height = surface_manager->Get_height(m_mySlotSurface1ID);
// Screen coordinates

View file

@ -1241,8 +1241,8 @@ void menuCommandsCallback(int action, Common::String &text, void *data) {
void Gui::invertWindowColors(WindowReference winID) {
Graphics::ManagedSurface *srf = findWindow(winID)->getWindowSurface();
for (uint y = 0; y < srf->h; y++) {
for (uint x = 0; x < srf->w; x++) {
for (int y = 0; y < srf->h; y++) {
for (int x = 0; x < srf->w; x++) {
byte p = *(byte *)srf->getBasePtr(x, y);
*(byte *)srf->getBasePtr(x, y) =
(p == kColorWhite) ? kColorBlack : kColorGray80;

View file

@ -462,8 +462,8 @@ void ImageAsset::blitDirect(Graphics::ManagedSurface *target, int ox, int oy, co
uint bmpofs = (y + sy) * rowBytes;
byte pix = 0;
for (uint x = 0; x < w; x++) {
assert(ox + x <= target->w);
assert(oy + y <= target->h);
assert(ox + x <= (uint)target->w);
assert(oy + y <= (uint)target->h);
pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7)));
pix = pix ? kColorBlack : kColorWhite;
*((byte *)target->getBasePtr(ox + x, oy + y)) = pix;
@ -479,8 +479,8 @@ void ImageAsset::blitBIC(Graphics::ManagedSurface *target, int ox, int oy, const
uint bmpofs = (y + sy) * rowBytes;
byte pix = 0;
for (uint x = 0; x < w; x++) {
assert(ox + x <= target->w);
assert(oy + y <= target->h);
assert(ox + x <= (uint)target->w);
assert(oy + y <= (uint)target->h);
pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7)));
if (pix) {
*((byte *)target->getBasePtr(ox + x, oy + y)) = kColorWhite;
@ -497,8 +497,8 @@ void ImageAsset::blitOR(Graphics::ManagedSurface *target, int ox, int oy, const
uint bmpofs = (y + sy) * rowBytes;
byte pix = 0;
for (uint x = 0; x < w; x++) {
assert(ox + x <= target->w);
assert(oy + y <= target->h);
assert(ox + x <= (uint)target->w);
assert(oy + y <= (uint)target->h);
pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7)));
if (pix) {
*((byte *)target->getBasePtr(ox + x, oy + y)) = kColorBlack;
@ -517,8 +517,8 @@ void ImageAsset::blitXOR(Graphics::ManagedSurface *target, int ox, int oy, const
for (uint x = 0; x < w; x++) {
pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7)));
if (pix) { // We need to xor
assert(ox + x <= target->w);
assert(oy + y <= target->h);
assert(ox + x <= (uint)target->w);
assert(oy + y <= (uint)target->h);
byte p = *((byte *)target->getBasePtr(ox + x, oy + y));
*((byte *)target->getBasePtr(ox + x, oy + y)) =
(p == kColorWhite) ? kColorBlack : kColorWhite;
@ -532,10 +532,10 @@ void ImageAsset::calculateSectionToDraw(Graphics::ManagedSurface *target, int &o
calculateSectionInDirection(target->w, bitWidth, ox, sx, w);
calculateSectionInDirection(target->h, bitHeight, oy, sy, h);
assert(w <= target->w);
assert(w <= (uint)target->w);
assert((int)w >= 0);
assert(w <= bitWidth);
assert(h <= target->h);
assert(h <= (uint)target->h);
assert((int)h >= 0);
assert(h <= bitHeight);
}

View file

@ -682,7 +682,7 @@ void Screen::panTransition(MSurface &newScreen, byte *palData, int entrySide,
// uint32 baseTicks, currentTicks;
byte paletteMap[256];
size.x = MIN(newScreen.w, (uint16)MADS_SCREEN_WIDTH);
size.x = MIN(newScreen.w, (int16)MADS_SCREEN_WIDTH);
size.y = newScreen.h;
if (newScreen.h >= MADS_SCREEN_HEIGHT)
size.y = MADS_SCENE_HEIGHT;

View file

@ -818,8 +818,8 @@ void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::Seekab
// Expand the 8 pixels in a byte into a full byte per pixel
for (uint32 i = 0; i < surface->h; i++) {
for (uint x = 0; x < surface->w;) {
for (int i = 0; i < surface->h; i++) {
for (int x = 0; x < surface->w;) {
byte temp = rawStream->readByte();
for (int j = 7; j >= 0 && x < surface->w; j--) {
@ -845,7 +845,7 @@ void DOSBitmap::expandEGAPlanes(Graphics::Surface *surface, Common::SeekableRead
byte *dst = (byte *)surface->getPixels();
for (uint32 i = 0; i < surface->h; i++) {
for (int32 i = 0; i < surface->h; i++) {
uint x = 0;
for (int32 j = 0; j < surface->w / 4; j++) {

View file

@ -139,7 +139,7 @@ Common::Point LBValue::toPoint() const {
case kLBValueString:
{
Common::Point ret;
sscanf(string.c_str(), "%hd , %hd", &ret.x, &ret.y);
sscanf(string.c_str(), "%d , %d", &ret.x, &ret.y);
return ret;
}
case kLBValueInteger:
@ -158,7 +158,7 @@ Common::Rect LBValue::toRect() const {
case kLBValueString:
{
Common::Rect ret;
sscanf(string.c_str(), "%hd , %hd , %hd , %hd", &ret.left, &ret.top, &ret.right, &ret.bottom);
sscanf(string.c_str(), "%d , %d , %d , %d", &ret.left, &ret.top, &ret.right, &ret.bottom);
return ret;
}
case kLBValueInteger:

View file

@ -281,11 +281,11 @@ public:
Graphics::Surface *screen = _system->lockScreen();
uint alpha = elapsed * 255 / _duration;
for (uint y = 0; y < _mainScreen->h; y++) {
for (int y = 0; y < _mainScreen->h; y++) {
uint16 *src1 = (uint16 *) _mainScreen->getBasePtr(0, y);
uint16 *src2 = (uint16 *) _effectScreen->getBasePtr(0, y);
uint16 *dst = (uint16 *) screen->getBasePtr(0, y);
for (uint x = 0; x < _mainScreen->w; x++) {
for (int x = 0; x < _mainScreen->w; x++) {
uint8 r1, g1, b1, r2, g2, b2;
_mainScreen->format.colorToRGB(*src1++, r1, g1, b1);
_effectScreen->format.colorToRGB(*src2++, r2, g2, b2);
@ -715,7 +715,7 @@ void RivenGraphics::updateCredits() {
Graphics::Surface *frame = findImage(_creditsImage)->getSurface();
memcpy(_mainScreen->getBasePtr(124, _mainScreen->h - 1), frame->getBasePtr(0, _creditsPos), frame->pitch);
_creditsPos++;
if (_creditsPos == _mainScreen->h) {
if (_creditsPos == (uint)_mainScreen->h) {
_creditsImage++;
_creditsPos = 0;
}

View file

@ -98,9 +98,9 @@ void Cursor::loadAvailableCursors() {
delete bmpStream;
// Apply the colorkey for transparency
for (uint y = 0; y < surfaceRGBA->h; y++) {
for (int y = 0; y < surfaceRGBA->h; y++) {
byte *pixels = (byte *)(surfaceRGBA->getBasePtr(0, y));
for (uint x = 0; x < surfaceRGBA->w; x++) {
for (int x = 0; x < surfaceRGBA->w; x++) {
byte *r = pixels + 0;
byte *g = pixels + 1;
byte *b = pixels + 2;

View file

@ -281,7 +281,7 @@ void WaterEffect::apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics
uint32 *dstPtr = (uint32 *)dst->getPixels();
byte *maskPtr = (byte *)mask->getPixels();
for (uint y = 0; y < dst->h; y++) {
for (int y = 0; y < dst->h; y++) {
if (!bottomFace) {
uint32 strength = (320 * (9 - y / 64)) / waterEffectAttenuation;
if (strength > 4)
@ -289,7 +289,7 @@ void WaterEffect::apply(Graphics::Surface *src, Graphics::Surface *dst, Graphics
hDisplacement = _horizontalDisplacements[strength];
}
for (uint x = 0; x < dst->w; x++) {
for (int x = 0; x < dst->w; x++) {
int8 maskValue = *maskPtr;
if (maskValue != 0) {
@ -395,8 +395,8 @@ void LavaEffect::applyForFace(uint face, Graphics::Surface *src, Graphics::Surfa
uint32 *dstPtr = (uint32 *)dst->getPixels();
byte *maskPtr = (byte *)mask->surface->getPixels();
for (uint y = 0; y < dst->h; y++) {
for (uint x = 0; x < dst->w; x++) {
for (int y = 0; y < dst->h; y++) {
for (int x = 0; x < dst->w; x++) {
uint8 maskValue = *maskPtr;
if (maskValue != 0) {
@ -524,8 +524,8 @@ void MagnetEffect::apply(Graphics::Surface *src, Graphics::Surface *dst, Graphic
uint32 *dstPtr = (uint32 *)dst->getPixels();
byte *maskPtr = (byte *)mask->getPixels();
for (uint y = 0; y < dst->h; y++) {
for (uint x = 0; x < dst->w; x++) {
for (int y = 0; y < dst->h; y++) {
for (int x = 0; x < dst->w; x++) {
uint8 maskValue = *maskPtr;
if (maskValue != 0) {
@ -778,8 +778,8 @@ void ShieldEffect::applyForFace(uint face, Graphics::Surface *src, Graphics::Sur
uint32 *dstPtr = (uint32 *)dst->getPixels();
byte *maskPtr = (byte *)mask->surface->getPixels();
for (uint y = 0; y < dst->h; y++) {
for (uint x = 0; x < dst->w; x++) {
for (int y = 0; y < dst->h; y++) {
for (int x = 0; x < dst->w; x++) {
uint8 maskValue = *maskPtr;
if (maskValue != 0) {

View file

@ -429,8 +429,8 @@ Graphics::Surface *Menu::createThumbnail(Graphics::Surface *big) {
Graphics::Surface frameSurface = big->getSubArea(frame);
uint32 *dst = (uint32 *)small->getPixels();
for (uint i = 0; i < small->h; i++) {
for (uint j = 0; j < small->w; j++) {
for (int i = 0; i < small->h; i++) {
for (int j = 0; j < small->w; j++) {
uint32 srcX = frameSurface.w * j / small->w;
uint32 srcY = frameSurface.h * i / small->h;
uint32 *src = (uint32 *)frameSurface.getBasePtr(srcX, srcY);

View file

@ -509,9 +509,9 @@ void ProjectorMovie::update() {
float delta = zoom / 10.0 / _frame->w;
// For each pixel in the target image
for (uint i = 0; i < _frame->h; i++) {
for (int i = 0; i < _frame->h; i++) {
byte *dst = (byte *)_frame->getBasePtr(0, i);
for (uint j = 0; j < _frame->w; j++) {
for (int j = 0; j < _frame->w; j++) {
uint8 depth;
uint16 r = 0, g = 0, b = 0;
uint32 srcX = (uint32)(backgroundX + j * delta);

View file

@ -422,7 +422,7 @@ Common::Rect SpotItemFace::getFaceRect() const {
}
void SpotItemFace::draw() {
for (uint i = 0; i < _bitmap->h; i++) {
for (int i = 0; i < _bitmap->h; i++) {
memcpy(_face->_bitmap->getBasePtr(_posX, _posY + i),
_bitmap->getBasePtr(0, i),
_bitmap->w * 4);
@ -433,7 +433,7 @@ void SpotItemFace::draw() {
}
void SpotItemFace::undraw() {
for (uint i = 0; i < _notDrawnBitmap->h; i++) {
for (int i = 0; i < _notDrawnBitmap->h; i++) {
memcpy(_face->_bitmap->getBasePtr(_posX, _posY + i),
_notDrawnBitmap->getBasePtr(0, i),
_notDrawnBitmap->w * 4);

View file

@ -1151,7 +1151,7 @@ void Puzzles::journalSaavedro(int16 move) {
Graphics::Surface *leftBitmap = new Graphics::Surface();
leftBitmap->create(bitmap->w / 2, bitmap->h, Texture::getRGBAPixelFormat());
for (uint i = 0; i < bitmap->h; i++) {
for (int i = 0; i < bitmap->h; i++) {
memcpy(leftBitmap->getBasePtr(0, i),
bitmap->getBasePtr(0, i),
leftBitmap->w * 4);

View file

@ -517,8 +517,8 @@ Graphics::Surface *GameState::resizeThumbnail(Graphics::Surface *big, uint width
small->create(width, height, big->format);
uint32 *dst = (uint32 *)small->getPixels();
for (uint i = 0; i < small->h; i++) {
for (uint j = 0; j < small->w; j++) {
for (int i = 0; i < small->h; i++) {
for (int j = 0; j < small->w; j++) {
uint32 srcX = big->w * j / small->w;
uint32 srcY = big->h * i / small->h;
uint32 *src = (uint32 *)big->getBasePtr(srcX, srcY);

View file

@ -163,13 +163,13 @@ void GraphicsManager::copyToManaged(const Graphics::Surface &src, Graphics::Mana
return;
}
for (uint y = 0; y < src.h; ++y) {
for (int y = 0; y < src.h; ++y) {
if (!doubleSize) {
// Copy single line bottom to top
memcpy(dst.getBasePtr(0, y), src.getBasePtr(0, src.h - y - 1), src.w * src.format.bytesPerPixel);
} else {
// Make four copies of each source pixel
for (uint x = 0; x < src.w; ++x) {
for (int x = 0; x < src.w; ++x) {
switch (src.format.bytesPerPixel) {
case 1: {
const byte *srcP = (const byte *)src.getBasePtr(x, y);

View file

@ -257,7 +257,7 @@ void Viewport::setPreviousFrame() {
}
void Viewport::setVerticalScroll(uint scroll) {
assert(scroll + _drawSurface.h <= _fullFrame.h);
assert((int)scroll + _drawSurface.h <= _fullFrame.h);
Common::Rect sourceBounds = _screenPosition;
sourceBounds.moveTo(0, scroll);

View file

@ -74,8 +74,8 @@ void ScreenFader::setFaderValue(const int32 value) {
// linear fade instead, which looks fairly well, IMO.
Graphics::Surface *screen = g_system->lockScreen();
for (uint y = 0; y < _screen.h; y++) {
for (uint x = 0; x < _screen.w; x++) {
for (int y = 0; y < _screen.h; y++) {
for (int x = 0; x < _screen.w; x++) {
if (_screen.format.bytesPerPixel == 2)
WRITE_UINT16(screen->getBasePtr(x, y), fadePixel(READ_UINT16(_screen.getBasePtr(x, y)), value));
else

View file

@ -83,7 +83,7 @@ void GraphicsMan::draw(Graphics::Surface *screen, const Graphics::Surface *s) {
uint16 w = MIN(screen->w, s->w);
const byte *src = (const byte *)s->getBasePtr(0, 0);
byte *dst = (byte *)screen->getBasePtr(0, 0);
for (uint y = 0; y < s->h; y++) {
for (int y = 0; y < s->h; y++) {
if (y < screen->h) {
memcpy(dst, src, w);
}

View file

@ -180,8 +180,8 @@ enum DragonMoveTypes {
struct PathDirectionData {
int8 direction;
int16 x;
int16 y;
int32 x;
int32 y;
};
struct ActorFrameRange {

View file

@ -131,8 +131,8 @@ void Fonts::setFont(int fontNum) {
// Iterate through the frames to find the widest and tallest font characters
_fontHeight = _widestChar = 0;
for (uint idx = 0; idx < MIN<uint>(_charCount, 128 - 32); ++idx) {
_fontHeight = MAX((uint16)_fontHeight, (*_font)[idx]._frame.h);
_widestChar = MAX((uint16)_widestChar, (*_font)[idx]._frame.w);
_fontHeight = MAX((int16)_fontHeight, (*_font)[idx]._frame.h);
_widestChar = MAX((int16)_widestChar, (*_font)[idx]._frame.w);
}
// Initialize the Y offset table for the extended character set

View file

@ -76,7 +76,7 @@ bool GraphicsManager::loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
// 65535 is the value of AUTOFIT constant in Sludge
if (fracX == 65535) {
nP->wrapS = false;
if (nP->surface.w < _winWidth) {
if (nP->surface.w < (int16)_winWidth) {
fatal("For AUTOFIT parallax backgrounds, the image must be at least as wide as the game window/screen.");
return false;
}
@ -86,7 +86,7 @@ bool GraphicsManager::loadParallax(uint16 v, uint16 fracX, uint16 fracY) {
if (fracY == 65535) {
nP->wrapT = false;
if (nP->surface.h < _winHeight) {
if (nP->surface.h < (int16)_winHeight) {
fatal("For AUTOFIT parallax backgrounds, the image must be at least as tall as the game window/screen.");
return false;
}
@ -357,7 +357,7 @@ bool GraphicsManager::loadLightMap(int v) {
if (!ImgLoader::loadImage(v, "lightmap", g_sludge->_resMan->getData(), &tmp))
return false;
if (tmp.w != _sceneWidth || tmp.h != _sceneHeight) {
if (tmp.w != (int16)_sceneWidth || tmp.h != (int16)_sceneHeight) {
if (_lightMapMode == LIGHTMAPMODE_HOTSPOT) {
return fatal("Light map width and height don't match scene width and height. That is required for lightmaps in HOTSPOT mode.");
} else if (_lightMapMode == LIGHTMAPMODE_PIXEL) {

View file

@ -348,7 +348,7 @@ bool Location::scrollToSmooth(const Common::Point &position, bool followCharacte
Common::Point delta;
if (position.x < _scroll.x) {
delta.x = -scrollStep;
delta.x = -(int)scrollStep;
delta.x = CLIP<int16>(delta.x, position.x - _scroll.x, 0);
} else if (position.x > _scroll.x) {
delta.x = scrollStep;
@ -356,7 +356,7 @@ bool Location::scrollToSmooth(const Common::Point &position, bool followCharacte
}
if (position.y < _scroll.y) {
delta.y = -scrollStep;
delta.y = -(int)scrollStep;
delta.y = CLIP<int16>(delta.y, position.y - _scroll.y, 0);
} else if (position.y > _scroll.y) {
delta.y = scrollStep;

View file

@ -360,8 +360,8 @@ void UserInterface::saveGameScreenThumbnail() {
_gameWindowThumbnail->create(kThumbnailWidth, kThumbnailHeight, big->format);
uint32 *dst = (uint32 *)_gameWindowThumbnail->getPixels();
for (uint i = 0; i < _gameWindowThumbnail->h; i++) {
for (uint j = 0; j < _gameWindowThumbnail->w; j++) {
for (int i = 0; i < _gameWindowThumbnail->h; i++) {
for (int j = 0; j < _gameWindowThumbnail->w; j++) {
uint32 srcX = big->w * j / _gameWindowThumbnail->w;
uint32 srcY = big->h * i / _gameWindowThumbnail->h;
uint32 *src = (uint32 *)big->getBasePtr(srcX, srcY);

View file

@ -74,8 +74,8 @@ void VisualExplodingImage::initFromSurface(const Graphics::Surface *surface, uin
explosionAmplitude.y *= _surface->h / (float)originalHeight;
uint index = 0;
for (uint y = 0; y < _surface->h; y++) {
for (uint x = 0; x < _surface->w; x++, index++) {
for (int y = 0; y < _surface->h; y++) {
for (int x = 0; x < _surface->w; x++, index++) {
_units[index].setPosition(x, y);
_units[index].setExplosionSettings(explosionCenter, explosionAmplitude, _surface->w / (float)originalWidth);
_units[index].setColor(*static_cast<uint32 *>(_surface->getBasePtr(x, y)), _surface->format);

View file

@ -107,11 +107,11 @@ Graphics::Surface *VisualImageXMG::multiplyColorWithAlpha(const Graphics::Surfac
Graphics::Surface *dest = new Graphics::Surface();
dest->create(source->w, source->h, Gfx::Driver::getRGBAPixelFormat());
for (uint y = 0; y < source->h; y++) {
for (int y = 0; y < source->h; y++) {
const uint8 *src = (const uint8 *) source->getBasePtr(0, y);
uint8 *dst = (uint8 *) dest->getBasePtr(0, y);
for (uint x = 0; x < source->w; x++) {
for (int x = 0; x < source->w; x++) {
uint8 a, r, g, b;
r = *src++;
g = *src++;

View file

@ -155,11 +155,11 @@ static float linearToSrgb(float x) {
static void multiplyColorWithAlpha(Graphics::Surface *source) {
assert(source->format == Gfx::Driver::getRGBAPixelFormat());
for (uint y = 0; y < source->h; y++) {
for (int y = 0; y < source->h; y++) {
const uint8 *src = (const uint8 *) source->getBasePtr(0, y);
uint8 *dst = (uint8 *) source->getBasePtr(0, y);
for (uint x = 0; x < source->w; x++) {
for (int x = 0; x < source->w; x++) {
uint8 a, r, g, b;
r = *src++;
g = *src++;
@ -206,11 +206,11 @@ static void blendWithColor(Graphics::Surface *source, const Color &color) {
float sGL = srgbToLinear(color.g / 255.f);
float sBL = srgbToLinear(color.b / 255.f);
for (uint y = 0; y < source->h; y++) {
for (int y = 0; y < source->h; y++) {
const uint8 *src = (const uint8 *) source->getBasePtr(0, y);
uint8 *dst = (uint8 *) source->getBasePtr(0, y);
for (uint x = 0; x < source->w; x++) {
for (int x = 0; x < source->w; x++) {
uint8 a, r, g, b;
r = *src++;
g = *src++;

View file

@ -48,8 +48,8 @@ bool Screenshot::saveToFile(Graphics::Surface *data, Common::WriteStream *stream
stream->writeUint16LE(data->h);
stream->writeByte(THUMBNAIL_VERSION);
for (uint y = 0; y < data->h; y++) {
for (uint x = 0; x < data->w; x++) {
for (int y = 0; y < data->h; y++) {
for (int x = 0; x < data->w; x++) {
// This is only called by createThumbnail below, which
// provides a fake 'surface' with LE data in it.
byte a, r, g, b;

View file

@ -250,7 +250,7 @@ GfxSurface::~GfxSurface() {
assert(disposeAfterUse() == DisposeAfterUse::NO);
}
void GfxSurface::create(uint16 width, uint16 height) {
void GfxSurface::create(int16 width, int16 height) {
free();
_rawSurface.create(width, height);

View file

@ -103,7 +103,7 @@ public:
Graphics::ManagedSurface &lockSurface();
void unlockSurface();
void synchronize(Serializer &s);
void create(uint16 width, uint16 height) override;
void create(int16 width, int16 height) override;
void setBounds(const Rect &bounds);
const Rect &getBounds() const { return _bounds; }

View file

@ -284,15 +284,15 @@ void Image::performTransparencyHack(uint colorValue, uint numFrames,
uint currentFrameIndex, uint haloWidth,
uint haloOpacityIncrementByPixelDistance) {
Common::List<Std::pair<uint, uint> > opaqueXYs;
uint x, y;
int x, y;
byte t_r, t_g, t_b;
_surface->format.colorToRGB(colorValue, t_r, t_g, t_b);
uint frameHeight = _surface->h / numFrames;
int frameHeight = _surface->h / numFrames;
//Min'd so that they never go out of range (>=h)
uint top = MIN(_surface->h, (uint16)(currentFrameIndex * frameHeight));
uint bottom = MIN(_surface->h, (uint16)(top + frameHeight));
int top = MIN(_surface->h, (int16)(currentFrameIndex * frameHeight));
int bottom = MIN(_surface->h, (int16)(top + frameHeight));
for (y = top; y < bottom; y++) {
@ -317,11 +317,11 @@ void Image::performTransparencyHack(uint colorValue, uint numFrames,
ox = xy->first;
oy = xy->second;
int span = int(haloWidth);
uint x_start = MAX(0, ox - span);
uint x_finish = MIN(int(_surface->w), ox + span + 1);
int x_start = MAX(0, ox - span);
int x_finish = MIN(int(_surface->w), ox + span + 1);
for (x = x_start; x < x_finish; ++x) {
uint y_start = MAX(int(top), oy - span);
uint y_finish = MIN(int(bottom), oy + span + 1);
int y_start = MAX(int(top), oy - span);
int y_finish = MIN(int(bottom), oy + span + 1);
for (y = y_start; y < y_finish; ++y) {
int divisor = 1 + span * 2 - abs(int(ox - x)) - abs(int(oy - y));
@ -477,8 +477,8 @@ void Image::dump() {
void Image::drawHighlighted() {
RGBA c;
for (unsigned i = 0; i < _surface->h; i++) {
for (unsigned j = 0; j < _surface->w; j++) {
for (int i = 0; i < _surface->h; i++) {
for (int j = 0; j < _surface->w; j++) {
getPixel(j, i, c.r, c.g, c.b, c.a);
putPixel(j, i, 0xff - c.r, 0xff - c.g, 0xff - c.b, c.a);
}

View file

@ -192,8 +192,8 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
// Some files are true TGA, while others are TGZ
uint32 fileType = file.readUint32BE();
uint32 imageWidth;
uint32 imageHeight;
int imageWidth;
int imageHeight;
Image::TGADecoder tga;
uint16 *buffer;
// All Z-Vision images are in RGB 555
@ -238,9 +238,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
// Flip the width and height if transposed
if (transposed) {
uint16 temp = imageHeight;
imageHeight = imageWidth;
imageWidth = temp;
SWAP(imageWidth, imageHeight);
}
// If the destination internal buffer is the same size as what we're copying into it,
@ -254,10 +252,10 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
if (transposed) {
uint16 *dest = (uint16 *)destination.getPixels();
for (uint32 y = 0; y < imageHeight; ++y) {
for (int y = 0; y < imageHeight; ++y) {
uint32 columnIndex = y * imageWidth;
for (uint32 x = 0; x < imageWidth; ++x) {
for (int x = 0; x < imageWidth; ++x) {
dest[columnIndex + x] = buffer[x * imageHeight + y];
}
}
@ -345,10 +343,10 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa
const uint16 *source = (const uint16 *)surface->getPixels();
uint16 *dest = (uint16 *)tranposedSurface->getPixels();
for (uint32 y = 0; y < tranposedSurface->h; ++y) {
uint32 columnIndex = y * tranposedSurface->w;
for (int y = 0; y < tranposedSurface->h; ++y) {
int columnIndex = y * tranposedSurface->w;
for (uint32 x = 0; x < tranposedSurface->w; ++x) {
for (int x = 0; x < tranposedSurface->w; ++x) {
dest[columnIndex + x] = source[x * surface->w + y];
}
}

View file

@ -137,8 +137,8 @@ bool AnimationEffect::process(uint32 deltaTimeInMillis) {
const Graphics::Surface *frame = _animation->decodeNextFrame();
if (frame) {
uint32 dstw;
uint32 dsth;
int dstw;
int dsth;
if (isPanorama) {
dstw = nod->pos.height();
dsth = nod->pos.width();

View file

@ -1138,9 +1138,9 @@ bool MacMenu::mouseClick(int x, int y) {
uint w = _menustack.back()->bbox.width() + 2;
uint h = _menustack.back()->bbox.height() + 2;
if (x1 + w > _wm->_screenCopy->w)
if (x1 + (int)w > _wm->_screenCopy->w)
w = _wm->_screenCopy->w - 1 - x1;
if (y1 + h > _wm->_screenCopy->h)
if (y1 + (int)h > _wm->_screenCopy->h)
h = _wm->_screenCopy->h - 1 - y1;
g_system->copyRectToScreen(_wm->_screenCopy->getBasePtr(x1, y1), _wm->_screenCopy->pitch, x1, y1, w, h);

View file

@ -656,8 +656,8 @@ void MacWindowManager::loadDesktop() {
void MacWindowManager::drawDesktop() {
if (_desktopBmp) {
for (uint i = 0; i < _desktop->w; ++i) {
for (uint j = 0; j < _desktop->h; ++j) {
for (int i = 0; i < _desktop->w; ++i) {
for (int j = 0; j < _desktop->h; ++j) {
uint32 color = *(uint32 *)_desktopBmp->getBasePtr(i % _desktopBmp->w, j % _desktopBmp->h);
if (_pixelformat.bytesPerPixel == 1) {
byte r, g, b;

View file

@ -144,11 +144,11 @@ void ManagedSurface::setPixels(void *newPixels) {
_innerSurface.setPixels(newPixels);
}
void ManagedSurface::create(uint16 width, uint16 height) {
void ManagedSurface::create(int16 width, int16 height) {
create(width, height, PixelFormat::createFormatCLUT8());
}
void ManagedSurface::create(uint16 width, uint16 height, const PixelFormat &pixelFormat) {
void ManagedSurface::create(int16 width, int16 height, const PixelFormat &pixelFormat) {
free();
_innerSurface.create(width, height, pixelFormat);

View file

@ -99,9 +99,9 @@ public:
*/
bool clip(Common::Rect &srcBounds, Common::Rect &destBounds);
public:
uint16 &w; /*!< Width of the surface rectangle. */
uint16 &h; /*!< Height of the surface rectangle. */
uint16 &pitch; /*!< Pitch of the surface rectangle. See @ref Surface::pitch. */
int16 &w; /*!< Width of the surface rectangle. */
int16 &h; /*!< Height of the surface rectangle. */
int16 &pitch; /*!< Pitch of the surface rectangle. See @ref Surface::pitch. */
PixelFormat &format; /*!< Pixel format of the surface. See @ref PixelFormat. */
public:
/**
@ -249,12 +249,12 @@ public:
/**
* Allocate memory for the pixel data of the surface.
*/
virtual void create(uint16 width, uint16 height);
virtual void create(int16 width, int16 height);
/**
* Allocate memory for the pixel data of the surface.
*/
virtual void create(uint16 width, uint16 height, const PixelFormat &pixelFormat);
virtual void create(int16 width, int16 height, const PixelFormat &pixelFormat);
/**
* Set up the surface as a subsection of another passed parent surface.

View file

@ -290,8 +290,8 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
_cached_colors.clear();
if (palette) {
for (uint i = 0; i < srf->w; ++i) {
for (uint j = 0; j < srf->h; ++j) {
for (int i = 0; i < srf->w; ++i) {
for (int j = 0; j < srf->h; ++j) {
uint32 color = *(uint32*)srf->getBasePtr(i, j);
if (color != transColor) {
*((byte *)target.getBasePtr(i, j)) = closestGrayscale(color, palette, numColors);
@ -299,8 +299,8 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
}
}
} else {
for (uint i = 0; i < srf->w; ++i) {
for (uint j = 0; j < srf->h; ++j) {
for (int i = 0; i < srf->w; ++i) {
for (int j = 0; j < srf->h; ++j) {
uint32 color = *(uint32*)srf->getBasePtr(i, j);
byte a, r, g, b;
_bmp->format.colorToARGB(color, a, r, g, b);

View file

@ -187,8 +187,8 @@ static bool grabScreen565(Graphics::Surface *surf) {
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
}
for (uint y = 0; y < screen->h; ++y) {
for (uint x = 0; x < screen->w; ++x) {
for (int y = 0; y < screen->h; ++y) {
for (int x = 0; x < screen->w; ++x) {
byte r = 0, g = 0, b = 0;
if (screenFormat.bytesPerPixel == 1) {
@ -246,8 +246,8 @@ bool createThumbnail(Graphics::Surface *surf, const uint8 *pixels, int w, int h,
Graphics::Surface screen;
screen.create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
for (uint y = 0; y < screen.h; ++y) {
for (uint x = 0; x < screen.w; ++x) {
for (int y = 0; y < screen.h; ++y) {
for (int x = 0; x < screen.w; ++x) {
byte r, g, b;
r = palette[pixels[y * w + x] * 3];
g = palette[pixels[y * w + x] * 3 + 1];
@ -274,8 +274,8 @@ bool createScreenShot(Graphics::Surface &surf) {
return false;
}
surf.create(screen->w, screen->h, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
for (uint y = 0; y < screen->h; ++y) {
for (uint x = 0; x < screen->w; ++x) {
for (int y = 0; y < screen->h; ++y) {
for (int x = 0; x < screen->w; ++x) {
byte r = 0, g = 0, b = 0, a = 0;
uint32 col = READ_UINT32(screen->getBasePtr(x, y));
screenFormat.colorToARGB(col, a, r, g, b);

View file

@ -63,7 +63,8 @@ void Surface::drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY,
error("Surface::drawThickLine: bytesPerPixel must be 1, 2, or 4");
}
void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
void Surface::create(int16 width, int16 height, const PixelFormat &f) {
assert(width >= 0 && height >= 0);
free();
w = width;
@ -84,7 +85,7 @@ void Surface::free() {
format = PixelFormat();
}
void Surface::init(uint16 width, uint16 height, uint16 newPitch, void *newPixels, const PixelFormat &f) {
void Surface::init(int16 width, int16 height, int16 newPitch, void *newPixels, const PixelFormat &f) {
w = width;
h = height;
pitch = newPitch;
@ -369,8 +370,7 @@ void Surface::flipVertical(const Common::Rect &r) {
delete[] temp;
}
Graphics::Surface *Surface::scale(uint16 newWidth, uint16 newHeight, bool filtering) const {
Graphics::Surface *Surface::scale(int16 newWidth, int16 newHeight, bool filtering) const {
Graphics::Surface *target = new Graphics::Surface();
target->create(newWidth, newHeight, format);

View file

@ -55,19 +55,19 @@ struct Surface {
/**
* Width of the surface.
*/
uint16 w;
int16 w;
/**
* Height of the surface.
*/
uint16 h;
int16 h;
/**
* Number of bytes in a pixel line.
*
* @note This might not equal w * bytesPerPixel.
*/
uint16 pitch;
int16 pitch;
protected:
/**
@ -188,7 +188,7 @@ public:
* @param height Height of the surface object.
* @param format The pixel format to be used by the surface.
*/
void create(uint16 width, uint16 height, const PixelFormat &format);
void create(int16 width, int16 height, const PixelFormat &format);
/**
* Release the memory used by the pixel memory of this surface.
@ -212,7 +212,7 @@ public:
* @param pixels Pixel data.
* @param format Pixel format of the pixel data.
*/
void init(uint16 width, uint16 height, uint16 pitch, void *pixels, const PixelFormat &format);
void init(int16 width, int16 height, int16 pitch, void *pixels, const PixelFormat &format);
/**
* Copy the data from another surface.
@ -402,7 +402,7 @@ public:
* @param newHeight The resulting height.
* @param filtering Whether or not to use bilinear filtering.
*/
Graphics::Surface *scale(uint16 newWidth, uint16 newHeight, bool filtering = false) const;
Graphics::Surface *scale(int16 newWidth, int16 newHeight, bool filtering = false) const;
/**
* @brief Rotoscale function; this returns a transformed version of this surface after rotation and

View file

@ -183,14 +183,14 @@ bool loadThumbnail(Common::SeekableReadStream &in, Graphics::Surface *&thumbnail
switch (header.format.bytesPerPixel) {
case 2: {
uint16 *pixels = (uint16 *)thumbnail->getBasePtr(0, y);
for (uint x = 0; x < thumbnail->w; ++x) {
for (int x = 0; x < thumbnail->w; ++x) {
*pixels++ = in.readUint16BE();
}
} break;
case 4: {
uint32 *pixels = (uint32 *)thumbnail->getBasePtr(0, y);
for (uint x = 0; x < thumbnail->w; ++x) {
for (int x = 0; x < thumbnail->w; ++x) {
*pixels++ = in.readUint32BE();
}
} break;
@ -247,18 +247,18 @@ bool saveThumbnail(Common::WriteStream &out, const Graphics::Surface &thumb) {
out.writeByte(thumb.format.aShift);
// Serialize the pixel data
for (uint y = 0; y < thumb.h; ++y) {
for (int y = 0; y < thumb.h; ++y) {
switch (thumb.format.bytesPerPixel) {
case 2: {
const uint16 *pixels = (const uint16 *)thumb.getBasePtr(0, y);
for (uint x = 0; x < thumb.w; ++x) {
for (int x = 0; x < thumb.w; ++x) {
out.writeUint16BE(*pixels++);
}
} break;
case 4: {
const uint32 *pixels = (const uint32 *)thumb.getBasePtr(0, y);
for (uint x = 0; x < thumb.w; ++x) {
for (int x = 0; x < thumb.w; ++x) {
out.writeUint32BE(*pixels++);
}
} break;

View file

@ -739,7 +739,7 @@ void TransparentSurface::setAlphaMode(AlphaType mode) {
_alphaMode = mode;
}
TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight, bool filtering) const {
TransparentSurface *TransparentSurface::scale(int16 newWidth, int16 newHeight, bool filtering) const {
TransparentSurface *target = new TransparentSurface();

View file

@ -144,7 +144,7 @@ struct TransparentSurface : public Graphics::Surface {
* @param filtering Whether or not to use bilinear filtering.
* @see TransformStruct
*/
TransparentSurface *scale(uint16 newWidth, uint16 newHeight, bool filtering = false) const;
TransparentSurface *scale(int16 newWidth, int16 newHeight, bool filtering = false) const;
/**
* @brief Rotoscale function; this returns a transformed version of this surface after rotation and

View file

@ -334,9 +334,9 @@ void CDToonsDecoder::renderBlock(byte *data, uint dataSize, int destX, int destY
debugN(9, "CDToons renderBlock at (%d, %d), width %d, height %d\n",
destX, destY, width, height);
if (destX + width > _surface->w)
if (destX + (int)width > _surface->w)
width = _surface->w - destX;
if (destY + height > _surface->h)
if (destY + (int)height > _surface->h)
height = _surface->h - destY;
uint skip = 0;

View file

@ -298,7 +298,7 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) {
// Allocate buffer for one scanline
JDIMENSION pitch = cinfo.output_width * _surface.format.bytesPerPixel;
assert(_surface.pitch >= pitch);
assert(_surface.pitch >= (int)pitch);
JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, pitch, 1);
// Go through the image data scanline by scanline

View file

@ -354,7 +354,7 @@ bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const by
Common::Array<const uint8 *> rows;
rows.reserve(surface->h);
for (uint y = 0; y < surface->h; ++y) {
for (int y = 0; y < surface->h; ++y) {
rows.push_back((const uint8 *)surface->getBasePtr(0, y));
}