diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp index ddc47a274fb..66ace9af2ec 100644 --- a/engines/twine/debugger/debug.cpp +++ b/engines/twine/debugger/debug.cpp @@ -37,7 +37,7 @@ namespace TwinE { void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) { uint8 *ptr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y); - const int32 offset = SCREEN_WIDTH - width; + const int32 offset = _engine->width() - width; for (int32 i = 0; i < height; i++) { for (int32 j = 0; j < width; j++) { @@ -406,7 +406,7 @@ void Debug::debugPlasmaWindow(const char *text, int32 color) { _engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % PLASMA_WIDTH * 10 + 6400] = 255; } const int32 textSize = _engine->_text->getTextSize(text); - _engine->_text->drawText((SCREEN_WIDTH / 2) - (textSize / 2), 10, text); + _engine->_text->drawText((_engine->width() / 2) - (textSize / 2), 10, text); const Common::Rect rect(5, 5, 634, 50); _engine->_menu->drawBox(rect); _engine->copyBlockPhys(rect); diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp index 7280d6f7b95..72d6b9fa038 100644 --- a/engines/twine/holomap.cpp +++ b/engines/twine/holomap.cpp @@ -159,9 +159,9 @@ void Holomap::drawHolomapLocation() { const int padding = 17; Common::Rect rect; rect.left = padding - 1; - rect.top = SCREEN_HEIGHT - 146; - rect.right = SCREEN_WIDTH - padding; - rect.bottom = SCREEN_HEIGHT - padding; + rect.top = _engine->height() - 146; + rect.right = _engine->width() - padding; + rect.bottom = _engine->height() - padding; _engine->_menu->drawBox(rect); rect.grow(-1); _engine->_interface->drawTransparentBox(rect, 3); @@ -183,12 +183,12 @@ void Holomap::processHolomap() { _engine->setPalette(_engine->_screens->paletteRGBA); loadHolomapGFX(); - _engine->_renderer->setCameraPosition(SCREEN_WIDTH / 2, 190, 128, 1024, 1024); + _engine->_renderer->setCameraPosition(_engine->width() / 2, 190, 128, 1024, 1024); _engine->_text->initTextBank(TextBankId::Inventory_Intro_and_Holomap); _engine->_text->setFontCrossColor(9); - drawHolomapText(SCREEN_WIDTH / 2, 25, "Holomap"); // TODO: fix the index + drawHolomapText(_engine->width() / 2, 25, "Holomap"); // TODO: fix the index drawHolomapLocation(); _engine->flip(); diff --git a/engines/twine/menu/interface.cpp b/engines/twine/menu/interface.cpp index 9480da26920..d4312a424be 100644 --- a/engines/twine/menu/interface.cpp +++ b/engines/twine/menu/interface.cpp @@ -97,7 +97,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in } } - int32 pitch = SCREEN_WIDTH; + int32 pitch = _engine->width(); endWidth -= startWidth; endHeight -= startHeight; if (endHeight < 0) { @@ -147,21 +147,21 @@ void Interface::blitBox(const Common::Rect &rect, const Graphics::ManagedSurface } void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) { - const int32 left = MAX((int32)SCREEN_TEXTLIMIT_LEFT, (int32)rect.left); - const int32 top = MAX((int32)SCREEN_TEXTLIMIT_TOP, (int32)rect.top); - const int32 right = MIN((int32)SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right); - const int32 bottom = MIN((int32)SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom); + const int32 left = MAX((int32)0, (int32)rect.left); + const int32 top = MAX((int32)0, (int32)rect.top); + const int32 right = MIN((int32)(_engine->width() - 1), (int32)rect.right); + const int32 bottom = MIN((int32)(_engine->height() - 1), (int32)rect.bottom); - if (left > SCREEN_TEXTLIMIT_RIGHT) { + if (left > (_engine->width() - 1)) { return; } - if (right < SCREEN_TEXTLIMIT_LEFT) { + if (right < 0) { return; } - if (top > SCREEN_TEXTLIMIT_BOTTOM) { + if (top > (_engine->height() - 1)) { return; } - if (bottom < SCREEN_TEXTLIMIT_TOP) { + if (bottom < 0) { return; } @@ -186,10 +186,10 @@ void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) { } void Interface::setClip(const Common::Rect &rect) { - textWindow.left = MAX((int32)SCREEN_TEXTLIMIT_LEFT, (int32)rect.left); - textWindow.top = MAX((int32)SCREEN_TEXTLIMIT_TOP, (int32)rect.top); - textWindow.right = MIN((int32)SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right); - textWindow.bottom = MIN((int32)SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom); + textWindow.left = MAX((int32)0, (int32)rect.left); + textWindow.top = MAX((int32)0, (int32)rect.top); + textWindow.right = MIN((int32)(_engine->width() - 1), (int32)rect.right); + textWindow.bottom = MIN((int32)(_engine->height() - 1), (int32)rect.bottom); } void Interface::saveClip() { @@ -201,10 +201,10 @@ void Interface::loadClip() { } void Interface::resetClip() { - textWindow.top = SCREEN_TEXTLIMIT_TOP; - textWindow.left = SCREEN_TEXTLIMIT_LEFT; - textWindow.right = SCREEN_TEXTLIMIT_RIGHT; - textWindow.bottom = SCREEN_TEXTLIMIT_BOTTOM; + textWindow.top = 0; + textWindow.left = 0; + textWindow.right = (_engine->width() - 1); + textWindow.bottom = (_engine->height() - 1); } } // namespace TwinE diff --git a/engines/twine/menu/interface.h b/engines/twine/menu/interface.h index 64065527775..a46589dc4b3 100644 --- a/engines/twine/menu/interface.h +++ b/engines/twine/menu/interface.h @@ -32,15 +32,6 @@ class ManagedSurface; namespace TwinE { -/** Screen top limit to display the texts */ -#define SCREEN_TEXTLIMIT_TOP 0 -/** Screen left limit to display the texts */ -#define SCREEN_TEXTLIMIT_LEFT 0 -/** Screen right limit to display the texts */ -#define SCREEN_TEXTLIMIT_RIGHT (SCREEN_WIDTH - 1) -/** Screen bottom limit to display the texts */ -#define SCREEN_TEXTLIMIT_BOTTOM (SCREEN_HEIGHT - 1) - class TwinEEngine; class Interface { diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp index 21c92f89b74..1a7054d6574 100644 --- a/engines/twine/menu/menu.cpp +++ b/engines/twine/menu/menu.cpp @@ -300,7 +300,7 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r _engine->_text->setFontColor(15); _engine->_text->setFontParameters(2, 8); const int32 textSize = _engine->_text->getTextSize(dialText); - _engine->_text->drawText((SCREEN_WIDTH / 2) - (textSize / 2), rect.top + 7, dialText); + _engine->_text->drawText((_engine->width() / 2) - (textSize / 2), rect.top + 7, dialText); _engine->copyBlockPhys(rect); } @@ -366,7 +366,7 @@ int16 Menu::drawButtons(MenuSettings *menuSettings, bool hover) { const char *text = menuSettings->getButtonText(_engine->_text, i); const int32 border = 45; const int32 mainMenuButtonHeightHalf = 25; - const Common::Rect rect(border, topHeight - mainMenuButtonHeightHalf, SCREEN_WIDTH - border, topHeight + mainMenuButtonHeightHalf); + const Common::Rect rect(border, topHeight - mainMenuButtonHeightHalf, _engine->width() - border, topHeight + mainMenuButtonHeightHalf); if (hover) { if (i == buttonNumber) { drawButtonGfx(menuSettings, rect, menuItemId, text, hover); @@ -921,7 +921,7 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw char dialText[256]; _engine->_text->getMenuText(_engine->_actor->getTextIdForBehaviour(), dialText, sizeof(dialText)); - _engine->_text->drawText(SCREEN_WIDTH / 2 - _engine->_text->getTextSize(dialText) / 2, titleBoxTop + 1, dialText); + _engine->_text->drawText(_engine->width() / 2 - _engine->_text->getTextSize(dialText) / 2, titleBoxTop + 1, dialText); _engine->copyBlockPhys(titleRect); } else { _engine->_interface->drawSplittedBox(boxRect, 0); diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp index 00f3c288ccc..b3b1290cca3 100644 --- a/engines/twine/menu/menuoptions.cpp +++ b/engines/twine/menu/menuoptions.cpp @@ -212,7 +212,7 @@ void MenuOptions::drawSelectableCharacters() { void MenuOptions::drawPlayerName(int32 centerx, int32 top, int32 type) { const int32 left = 10; - const int right = SCREEN_WIDTH - left; + const int right = _engine->width() - left; const int bottom = top + PLASMA_HEIGHT; const Common::Rect rect(left, top, right, bottom); if (type == 1) { @@ -254,9 +254,9 @@ bool MenuOptions::enterPlayerName(int32 textIdx) { char buffer[256]; _engine->_text->getMenuText(textIdx, buffer, sizeof(buffer)); _engine->_text->setFontColor(15); - const int halfScreenWidth = (SCREEN_WIDTH / 2); + const int halfScreenWidth = (_engine->width() / 2); _engine->_text->drawText(halfScreenWidth - (_engine->_text->getTextSize(buffer) / 2), 20, buffer); - _engine->copyBlockPhys(0, 0, SCREEN_WIDTH - 1, 99); + _engine->copyBlockPhys(0, 0, _engine->width() - 1, 99); _engine->flip(); Common::fill(&_onScreenKeyboardDirty[0], &_onScreenKeyboardDirty[ARRAYSIZE(_onScreenKeyboardDirty)], 1); diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp index c8bdbeee896..6c192725980 100644 --- a/engines/twine/renderer/redraw.cpp +++ b/engines/twine/renderer/redraw.cpp @@ -60,7 +60,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) { rect.left = leftValue; rect.top = topValue; rect.right = rightValue; - rect.bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, bottomValue); + rect.bottom = MIN((_engine->height() - 1), bottomValue); assert(rect.left <= rect.right); assert(rect.top <= rect.bottom); @@ -72,7 +72,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) { rect.left = redrawArea.left; rect.top = redrawArea.top; rect.right = redrawArea.right; - rect.bottom = MIN(SCREEN_TEXTLIMIT_BOTTOM, redrawArea.bottom); + rect.bottom = MIN((_engine->height() - 1), redrawArea.bottom); assert(rect.left <= rect.right); assert(rect.top <= rect.bottom); @@ -88,17 +88,17 @@ void Redraw::addRedrawArea(const Common::Rect &rect) { } void Redraw::addRedrawArea(int32 left, int32 top, int32 right, int32 bottom) { - if (left < SCREEN_TEXTLIMIT_LEFT) { - left = SCREEN_TEXTLIMIT_LEFT; + if (left < 0) { + left = 0; } - if (top < SCREEN_TEXTLIMIT_TOP) { - top = SCREEN_TEXTLIMIT_TOP; + if (top < 0) { + top = 0; } - if (right >= SCREEN_WIDTH) { - right = SCREEN_TEXTLIMIT_RIGHT; + if (right >= _engine->width()) { + right = (_engine->width() - 1); } - if (bottom >= SCREEN_HEIGHT) { - bottom = SCREEN_TEXTLIMIT_BOTTOM; + if (bottom >= _engine->height()) { + bottom = (_engine->height() - 1); } if (left > right || top > bottom) { @@ -201,7 +201,7 @@ int32 Redraw::fillActorDrawingList(bool bgRedraw) { _engine->_renderer->projectPositionOnScreen(actor->x - _engine->_grid->cameraX, actor->y - _engine->_grid->cameraY, actor->z - _engine->_grid->cameraZ); // check if actor is visible on screen, otherwise don't display it - if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < SCREEN_WIDTH + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < SCREEN_HEIGHT + 100) { + if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < _engine->width() + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < _engine->height() + 100) { actor->dynamicFlags.bIsVisible = 1; } continue; @@ -213,8 +213,8 @@ int32 Redraw::fillActorDrawingList(bool bgRedraw) { // get actor position on screen _engine->_renderer->projectPositionOnScreen(actor->x - _engine->_grid->cameraX, actor->y - _engine->_grid->cameraY, actor->z - _engine->_grid->cameraZ); - if ((actor->staticFlags.bUsesClipping && _engine->_renderer->projPosX > -112 && _engine->_renderer->projPosX < SCREEN_WIDTH + 112 && _engine->_renderer->projPosY > -50 && _engine->_renderer->projPosY < SCREEN_HEIGHT + 171) || - ((!actor->staticFlags.bUsesClipping) && _engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < SCREEN_WIDTH + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < SCREEN_HEIGHT + 100)) { + if ((actor->staticFlags.bUsesClipping && _engine->_renderer->projPosX > -112 && _engine->_renderer->projPosX < _engine->width() + 112 && _engine->_renderer->projPosY > -50 && _engine->_renderer->projPosY < _engine->height() + 171) || + ((!actor->staticFlags.bUsesClipping) && _engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < _engine->width() + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < _engine->height() + 100)) { int32 tmpVal = actor->z + actor->x - _engine->_grid->cameraX - _engine->_grid->cameraZ; @@ -281,7 +281,7 @@ int32 Redraw::fillExtraDrawingList(int32 drawListPos) { if ((extra->type & ExtraType::TIME_OUT) || (extra->type & ExtraType::FLASH) || (extra->payload.lifeTime + extra->spawnTime - 150 < _engine->lbaTime) || (!((_engine->lbaTime + extra->spawnTime) & 8))) { _engine->_renderer->projectPositionOnScreen(extra->x - _engine->_grid->cameraX, extra->y - _engine->_grid->cameraY, extra->z - _engine->_grid->cameraZ); - if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < SCREEN_WIDTH + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < SCREEN_HEIGHT + 100) { + if (_engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < _engine->width() + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < _engine->height() + 100) { drawList[drawListPos].posValue = extra->x - _engine->_grid->cameraX + extra->z - _engine->_grid->cameraZ; drawList[drawListPos].actorIdx = i; drawList[drawListPos].type = DrawListType::DrawExtras; @@ -348,20 +348,20 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw) return; } - if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) { - renderRect.left = SCREEN_TEXTLIMIT_LEFT; + if (renderRect.left < 0) { + renderRect.left = 0; } - if (renderRect.top < SCREEN_TEXTLIMIT_TOP) { - renderRect.top = SCREEN_TEXTLIMIT_TOP; + if (renderRect.top < 0) { + renderRect.top = 0; } - if (renderRect.right >= SCREEN_WIDTH) { - renderRect.right = SCREEN_TEXTLIMIT_RIGHT; + if (renderRect.right >= _engine->width()) { + renderRect.right = (_engine->width() - 1); } - if (renderRect.bottom >= SCREEN_HEIGHT) { - renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; + if (renderRect.bottom >= _engine->height()) { + renderRect.bottom = (_engine->height() - 1); } _engine->_interface->setClip(renderRect); @@ -642,20 +642,20 @@ void Redraw::renderOverlays() { renderRect.right = overlay->x + (textLength / 2); renderRect.bottom = overlay->y + textHeight; - if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) { - renderRect.left = SCREEN_TEXTLIMIT_LEFT; + if (renderRect.left < 0) { + renderRect.left = 0; } - if (renderRect.top < SCREEN_TEXTLIMIT_TOP) { - renderRect.top = SCREEN_TEXTLIMIT_TOP; + if (renderRect.top < 0) { + renderRect.top = 0; } - if (renderRect.right > SCREEN_TEXTLIMIT_RIGHT) { - renderRect.right = SCREEN_TEXTLIMIT_RIGHT; + if (renderRect.right > (_engine->width() - 1)) { + renderRect.right = (_engine->width() - 1); } - if (renderRect.bottom > SCREEN_TEXTLIMIT_BOTTOM) { - renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; + if (renderRect.bottom > (_engine->height() - 1)) { + renderRect.bottom = (_engine->height() - 1); } _engine->_interface->setClip(renderRect); @@ -788,8 +788,8 @@ void Redraw::zoomScreenScale() { *dest++ = *src; *dest++ = *src++; } - //memcpy(dest, dest - SCREEN_WIDTH, SCREEN_WIDTH); - //dest += SCREEN_WIDTH; + //memcpy(dest, dest - _engine->width(), _engine->width()); + //dest += _engine->width(); } _engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer); zoomWorkVideoBuffer.free(); diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp index 176100f6b27..62b8f8ca33a 100644 --- a/engines/twine/renderer/renderer.cpp +++ b/engines/twine/renderer/renderer.cpp @@ -375,8 +375,8 @@ void Renderer::computeBoundingBox(Vertex *vertices, int32 numVertices, int &vlef vright = vbottom = SCENE_SIZE_MIN; for (int32 i = 0; i < numVertices; i++) { - vertices[i].x = clamp(vertices[i].x, 0, SCREEN_WIDTH - 1); - vertices[i].y = clamp(vertices[i].y, 0, SCREEN_HEIGHT - 1); + vertices[i].x = clamp(vertices[i].x, 0, _engine->width() - 1); + vertices[i].y = clamp(vertices[i].y, 0, _engine->height() - 1); const int vertexX = vertices[i].x; vleft = MIN(vleft, vertexX); vright = MAX(vright, vertexX); @@ -434,7 +434,7 @@ void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 num cvalue = (oldVertexParam << 8) + ((vertexParam2 - oldVertexParam) << 8) % vsize; cdelta = ((vertexParam2 - oldVertexParam) << 8) / vsize; } - int16 *outPtr = &polyTab[ypos + (up ? SCREEN_HEIGHT : 0)]; // outPtr is the output ptr in the renderTab + int16 *outPtr = &polyTab[ypos + (up ? _engine->height() : 0)]; // outPtr is the output ptr in the renderTab float slope = (float)hsize / (float)vsize; slope = up ? -slope : slope; @@ -450,7 +450,7 @@ void Renderer::computePolygons(int16 polyRenderType, Vertex *vertices, int32 num } if (polyRenderType >= POLYGONTYPE_GOURAUD) { // we must compute the color progression - int16 *outPtr2 = &polyTab2[ypos + (up ? SCREEN_HEIGHT : 0)]; + int16 *outPtr2 = &polyTab2[ypos + (up ? _engine->height() : 0)]; for (int32 i = 0; i < vsize + 2; i++) { if (outPtr2 - polyTab2 < ARRAYSIZE(polyTab2)) { @@ -469,9 +469,9 @@ void Renderer::renderPolygonsCopper(uint8 *out, int vtop, int32 vsize, int32 col const int16 *ptr1 = &polyTab[vtop]; int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { + if (currentLine >= 0 && currentLine < _engine->height()) { int16 start = ptr1[0]; - int16 stop = ptr1[SCREEN_HEIGHT]; + int16 stop = ptr1[_engine->height()]; ptr1++; int32 hsize = stop - start; @@ -489,7 +489,7 @@ void Renderer::renderPolygonsCopper(uint8 *out, int vtop, int32 vsize, int32 col start += mask; start = (start & 0xFF00) | ((start & 0xFF) & (uint8)(dx >> 8)); start = (start & 0xFF00) | ((start & 0xFF) + (dx & 0xFF)); - if (j >= 0 && j < SCREEN_WIDTH) { + if (j >= 0 && j < _engine->width()) { out[j] = start & 0xFF; } mask = (mask << 2) | (mask >> 14); @@ -497,7 +497,7 @@ void Renderer::renderPolygonsCopper(uint8 *out, int vtop, int32 vsize, int32 col } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--vsize); } @@ -506,9 +506,9 @@ void Renderer::renderPolygonsBopper(uint8 *out, int vtop, int32 vsize, int32 col const int16 *ptr1 = &polyTab[vtop]; int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { + if (currentLine >= 0 && currentLine < _engine->height()) { int16 start = ptr1[0]; - int16 stop = ptr1[SCREEN_HEIGHT]; + int16 stop = ptr1[_engine->height()]; ptr1++; int32 hsize = stop - start; @@ -516,14 +516,14 @@ void Renderer::renderPolygonsBopper(uint8 *out, int vtop, int32 vsize, int32 col hsize++; for (int32 j = start; j < hsize + start; j++) { if ((start + (vtop % 1)) & 1) { - if (j >= 0 && j < SCREEN_WIDTH) { + if (j >= 0 && j < _engine->width()) { out[j] = color; } } } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--vsize); } @@ -532,22 +532,22 @@ void Renderer::renderPolygonsFlat(uint8 *out, int vtop, int32 vsize, int32 color const int16 *ptr1 = &polyTab[vtop]; int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { + if (currentLine >= 0 && currentLine < _engine->height()) { int16 start = ptr1[0]; - int16 stop = ptr1[SCREEN_HEIGHT]; + int16 stop = ptr1[_engine->height()]; ptr1++; int32 hsize = stop - start; if (hsize >= 0) { hsize++; for (int32 j = start; j < hsize + start; j++) { - if (j >= 0 && j < SCREEN_WIDTH) { + if (j >= 0 && j < _engine->width()) { out[j] = color; } } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--vsize); } @@ -562,7 +562,7 @@ void Renderer::renderPolygonsTele(uint8 *out, int vtop, int32 vsize, int32 color int32 hsize; while (1) { start = ptr1[0]; - stop = ptr1[SCREEN_HEIGHT]; + stop = ptr1[_engine->height()]; ptr1++; hsize = stop - start; @@ -575,7 +575,7 @@ void Renderer::renderPolygonsTele(uint8 *out, int vtop, int32 vsize, int32 color color = *(out2 + 1); - out += SCREEN_WIDTH; + out += _engine->width(); --renderLoop; if (!renderLoop) { @@ -626,7 +626,7 @@ void Renderer::renderPolygonsTele(uint8 *out, int vtop, int32 vsize, int32 color } } - out += SCREEN_WIDTH; + out += _engine->width(); --renderLoop; } while (renderLoop); @@ -639,7 +639,7 @@ void Renderer::renderPolygonsTras(uint8 *out, int vtop, int32 vsize, int32 color unsigned short int bx; int16 start = ptr1[0]; - int16 stop = ptr1[SCREEN_HEIGHT]; + int16 stop = ptr1[_engine->height()]; ptr1++; int32 hsize = stop - start; @@ -660,7 +660,7 @@ void Renderer::renderPolygonsTras(uint8 *out, int vtop, int32 vsize, int32 color out2++; } } - out += SCREEN_WIDTH; + out += _engine->width(); } while (--vsize); } @@ -671,9 +671,9 @@ void Renderer::renderPolygonTrame(uint8 *out, int vtop, int32 vsize, int32 color int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { + if (currentLine >= 0 && currentLine < _engine->height()) { int16 start = ptr1[0]; - int16 stop = ptr1[SCREEN_HEIGHT]; + int16 stop = ptr1[_engine->height()]; ptr1++; int32 hsize = stop - start; @@ -698,7 +698,7 @@ void Renderer::renderPolygonTrame(uint8 *out, int vtop, int32 vsize, int32 color } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--vsize); } @@ -709,20 +709,20 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co int32 renderLoop = vsize; int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { + if (currentLine >= 0 && currentLine < _engine->height()) { uint16 startColor = ptr2[0]; - uint16 stopColor = ptr2[SCREEN_HEIGHT]; + uint16 stopColor = ptr2[_engine->height()]; int16 colorSize = stopColor - startColor; - int16 stop = ptr1[SCREEN_HEIGHT]; // stop + int16 stop = ptr1[_engine->height()]; // stop int16 start = ptr1[0]; // start ptr1++; uint8 *out2 = start + out; int32 hsize = stop - start; - //varf2 = ptr2[SCREEN_HEIGHT]; + //varf2 = ptr2[_engine->height()]; //varf3 = ptr2[0]; ptr2++; @@ -730,28 +730,28 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co //varf4 = (float)((int32)varf2 - (int32)varf3); if (hsize == 0) { - if (start >= 0 && start < SCREEN_WIDTH) { + if (start >= 0 && start < _engine->width()) { *out2 = ((startColor + stopColor) / 2) >> 8; // moyenne des 2 couleurs } } else if (hsize > 0) { if (hsize == 1) { - if (start >= -1 && start < SCREEN_WIDTH - 1) { + if (start >= -1 && start < _engine->width() - 1) { *(out2 + 1) = stopColor >> 8; } - if (start >= 0 && start < SCREEN_WIDTH) { + if (start >= 0 && start < _engine->width()) { *(out2) = startColor >> 8; } } else if (hsize == 2) { - if (start >= -2 && start < SCREEN_WIDTH - 2) { + if (start >= -2 && start < _engine->width() - 2) { *(out2 + 2) = stopColor >> 8; } - if (start >= -1 && start < SCREEN_WIDTH - 1) { + if (start >= -1 && start < _engine->width() - 1) { *(out2 + 1) = ((startColor + stopColor) / 2) >> 8; } - if (start >= 0 && start < SCREEN_WIDTH) { + if (start >= 0 && start < _engine->width()) { *(out2) = startColor >> 8; } } else { @@ -761,7 +761,7 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co if (hsize % 2) { hsize /= 2; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = startColor >> 8; } out2++; @@ -772,14 +772,14 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co } do { - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = startColor >> 8; } currentXPos++; startColor += colorSize; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2 + 1) = startColor >> 8; } @@ -790,7 +790,7 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--renderLoop); } @@ -802,22 +802,22 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col int32 currentLine = vtop; do { - if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { - int16 stop = ptr1[SCREEN_HEIGHT]; // stop + if (currentLine >= 0 && currentLine < _engine->height()) { + int16 stop = ptr1[_engine->height()]; // stop int16 start = ptr1[0]; // start ptr1++; int32 hsize = stop - start; if (hsize >= 0) { uint16 startColor = ptr2[0]; - uint16 stopColor = ptr2[SCREEN_HEIGHT]; + uint16 stopColor = ptr2[_engine->height()]; int32 currentXPos = start; uint8 *out2 = start + out; ptr2++; if (hsize == 0) { - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = (uint8)(((startColor + stopColor) / 2) >> 8); } } else { @@ -829,7 +829,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col currentColor &= 0xFF; currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = currentColor >> 8; } @@ -839,7 +839,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col currentColor += startColor; currentXPos++; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2 + 1) = currentColor >> 8; } } else if (hsize == 2) { @@ -851,7 +851,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col colorSize /= 2; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = currentColor >> 8; } @@ -862,7 +862,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col currentColor &= 0xFF; currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = currentColor >> 8; } @@ -872,7 +872,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col currentColor += startColor; currentXPos++; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2 + 1) = currentColor >> 8; } } else { @@ -885,7 +885,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col currentColor &= 0xFF; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = currentColor >> 8; } out2++; @@ -897,7 +897,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col do { currentColor &= 0xFF; currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2) = currentColor >> 8; } currentXPos++; @@ -905,7 +905,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col startColor += colorSize; currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor += startColor; - if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { + if (currentXPos >= 0 && currentXPos < _engine->width()) { *(out2 + 1) = currentColor >> 8; } currentXPos++; @@ -916,7 +916,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col } } } - out += SCREEN_WIDTH; + out += _engine->width(); currentLine++; } while (--renderLoop); } diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h index ceb9770d98b..c30d69c047f 100644 --- a/engines/twine/renderer/renderer.h +++ b/engines/twine/renderer/renderer.h @@ -39,7 +39,8 @@ #define POLYGONTYPE_GOURAUD 7 #define POLYGONTYPE_DITHER 8 -#define POLYTABSIZE (SCREEN_HEIGHT * 2) +// TODO: this depends on the actual used resolution +#define POLYTABSIZE (SCREEN_WIDTH * 2) namespace Common { class MemoryReadStream; diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp index f509a82cc9e..889fb9bbc98 100644 --- a/engines/twine/scene/gamestate.cpp +++ b/engines/twine/scene/gamestate.cpp @@ -460,7 +460,7 @@ void GameState::processGameoverAnimation() { Renderer::prepareIsoModel(gameOverPtr); _engine->_sound->stopSamples(); _engine->_music->stopMidiMusic(); // stop fade music - _engine->_renderer->setCameraPosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 128, 200, 200); + _engine->_renderer->setCameraPosition(_engine->width() / 2, _engine->height() / 2, 128, 200, 200); int32 startLbaTime = _engine->lbaTime; _engine->_interface->setClip(rect); diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp index bcf611aa1d1..0d58b7afe35 100644 --- a/engines/twine/scene/grid.cpp +++ b/engines/twine/scene/grid.cpp @@ -76,7 +76,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu return; } - int32 offset = -((right - left) - SCREEN_WIDTH) - 1; + int32 offset = -((right - left) - _engine->width()) - 1; right++; bottom++; @@ -619,13 +619,13 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, if (brickPixelPosX < -24) { return; } - if (brickPixelPosX >= SCREEN_WIDTH) { + if (brickPixelPosX >= _engine->width()) { return; } if (brickPixelPosY < -38) { return; } - if (brickPixelPosY >= SCREEN_HEIGHT) { + if (brickPixelPosY >= _engine->height()) { return; } diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h index 3b44890943c..436a8820716 100644 --- a/engines/twine/scene/grid.h +++ b/engines/twine/scene/grid.h @@ -82,6 +82,7 @@ struct BrickEntry { #define BRICK_SIZE 512 #define BRICK_HEIGHT 256 +// TODO: this depends on the actual used resolution #define NUMBRICKENTRIES (1 + (SCREEN_WIDTH + 24) / 24) #define MAXBRICKS 150 diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp index c8832bf857a..249404d811c 100644 --- a/engines/twine/script/script_life_v1.cpp +++ b/engines/twine/script/script_life_v1.cpp @@ -1712,7 +1712,7 @@ static int32 lPROJ_3D(TwinEEngine *engine, LifeScriptContext &ctx) { engine->flip(); engine->_scene->changeRoomVar10 = false; - engine->_renderer->setCameraPosition(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 128, 1024, 1024); + engine->_renderer->setCameraPosition(engine->width() / 2, engine->height() / 2, 128, 1024, 1024); engine->_renderer->setCameraAngle(0, 1500, 0, 25, -128, 0, 13000); engine->_renderer->setLightVector(896, 950, ANGLE_0); @@ -1741,8 +1741,8 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) { int32 textBoxRight = textSize; engine->_text->setFontColor(15); engine->_text->drawText(0, drawVar1, textStr); - if (textSize > SCREEN_WIDTH - 1) { - textBoxRight = SCREEN_WIDTH - 1; + if (textSize > engine->width() - 1) { + textBoxRight = engine->width() - 1; } drawVar1 += 40; @@ -1759,7 +1759,7 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) { */ static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) { drawVar1 = 0; - const Common::Rect rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT / 2); + const Common::Rect rect(0, 0, engine->width() - 1, engine->height() / 2); engine->_interface->drawSplittedBox(rect, 0); engine->copyBlockPhys(rect); return 0; diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp index b7ffdd8e0f6..542705e91d1 100644 --- a/engines/twine/text.cpp +++ b/engines/twine/text.cpp @@ -191,7 +191,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter tempX += jump; uint8* basePtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY); for (uint8 i = 0; i < number; i++) { - if (tempX >= SCREEN_TEXTLIMIT_LEFT && tempX < SCREEN_TEXTLIMIT_RIGHT && tempY >= SCREEN_TEXTLIMIT_TOP && tempY < SCREEN_TEXTLIMIT_BOTTOM) { + if (tempX >= 0 && tempX < (_engine->width() - 1) && tempY >= 0 && tempY < (_engine->height() - 1)) { *basePtr = usedColor; } @@ -740,11 +740,11 @@ void Text::textClipFull() { const int32 padding = 8; _dialTextBox.left = margin; _dialTextBox.top = margin; - _dialTextBox.right = SCREEN_WIDTH - margin; - _dialTextBox.bottom = SCREEN_HEIGHT - margin; + _dialTextBox.right = _engine->width() - margin; + _dialTextBox.bottom = _engine->height() - margin; _dialTextBoxLines = (int32)(_dialTextBox.height() / _lineHeight) - 1; - _dialTextBoxMaxX = SCREEN_WIDTH - 2 * margin - 2 * padding; + _dialTextBoxMaxX = _engine->width() - 2 * margin - 2 * padding; } void Text::textClipSmall() { @@ -754,11 +754,11 @@ void Text::textClipSmall() { const int32 textHeight = _dialTextBoxLines * _lineHeight; _dialTextBox.left = margin; - _dialTextBox.top = SCREEN_HEIGHT - textHeight - margin - padding; - _dialTextBox.right = SCREEN_WIDTH - margin; - _dialTextBox.bottom = SCREEN_HEIGHT - margin; + _dialTextBox.top = _engine->height() - textHeight - margin - padding; + _dialTextBox.right = _engine->width() - margin; + _dialTextBox.bottom = _engine->height() - margin; - _dialTextBoxMaxX = SCREEN_WIDTH - 2 * margin - 2 * padding; + _dialTextBoxMaxX = _engine->width() - 2 * margin - 2 * padding; } void Text::drawAskQuestion(int32 index) { diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp index 0f00d1f1a18..2eec70a76fb 100644 --- a/engines/twine/twine.cpp +++ b/engines/twine/twine.cpp @@ -197,8 +197,10 @@ Common::Error TwinEEngine::run() { debug("(c) 1994 by Adeline Software International, All Rights Reserved."); syncSoundSettings(); - initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT); - allocVideoMemory(); + const int32 w = 640; + const int32 h = 480; + initGraphics(w, h); + allocVideoMemory(w, h); initAll(); initEngine(); _sound->stopSamples(); @@ -304,13 +306,13 @@ void TwinEEngine::autoSave() { saveGameState(getAutosaveSlot(), _gameState->playerName, true); } -void TwinEEngine::allocVideoMemory() { +void TwinEEngine::allocVideoMemory(int32 w, int32 h) { const Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); - imageBuffer.create(640, 480, format); // original lba1 resolution for a lot of images. + imageBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format); // original lba1 resolution for a lot of images. - workVideoBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format); - frontVideoBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format); + workVideoBuffer.create(w, h, format); + frontVideoBuffer.create(w, h, format); } static int getLanguageTypeIndex(const char *languageName) { @@ -464,8 +466,8 @@ void TwinEEngine::initAll() { _scene->sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX); - _redraw->renderRect.right = SCREEN_TEXTLIMIT_RIGHT; - _redraw->renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; + _redraw->renderRect.right = (width() - 1); + _redraw->renderRect.bottom = (height() - 1); // Set clip to fullscreen by default, allows main menu to render properly after load _interface->resetClip(); @@ -641,7 +643,7 @@ void TwinEEngine::centerScreenOnActor() { _renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX * BRICK_SIZE), actor->y - (_grid->newCameraY * BRICK_HEIGHT), actor->z - (_grid->newCameraZ * BRICK_SIZE)); - if (_renderer->projPosX < 80 || _renderer->projPosX >= SCREEN_WIDTH - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= SCREEN_HEIGHT - 50) { + if (_renderer->projPosX < 80 || _renderer->projPosX >= width() - 60 || _renderer->projPosY < 80 || _renderer->projPosY >= height() - 50) { _grid->newCameraX = ((actor->x + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->x + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraX) / 2; _grid->newCameraY = actor->y / BRICK_HEIGHT; _grid->newCameraZ = ((actor->z + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->z + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraZ) / 2; @@ -1037,11 +1039,11 @@ void TwinEEngine::copyBlockPhys(int32 left, int32 top, int32 right, int32 bottom assert(top <= bottom); int32 width = right - left + 1; int32 height = bottom - top + 1; - if (left + width > SCREEN_WIDTH) { - width = SCREEN_WIDTH - left; + if (left + width > this->width()) { + width = this->width() - left; } - if (top + height > SCREEN_HEIGHT) { - height = SCREEN_HEIGHT - top; + if (top + height > this->height()) { + height = this->height() - top; } if (width <= 0 || height <= 0) { return; diff --git a/engines/twine/twine.h b/engines/twine/twine.h index 73ac110a9a0..6bc09370272 100644 --- a/engines/twine/twine.h +++ b/engines/twine/twine.h @@ -272,7 +272,7 @@ public: */ int32 runGameEngine(); /** Allocate video memory, both front and back buffers */ - void allocVideoMemory(); + void allocVideoMemory(int32 w, int32 h); /** * @return A random value between [0-max) */