TWINE: replaced hardcoded resolution constants with function calls

This commit is contained in:
Martin Gerhardy 2021-01-07 21:17:53 +01:00
parent 4b7dd811a4
commit 3cf6eee18b
16 changed files with 148 additions and 153 deletions

View file

@ -37,7 +37,7 @@ namespace TwinE {
void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) { void Debug::debugFillButton(int32 x, int32 y, int32 width, int32 height, int8 color) {
uint8 *ptr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(x, y); 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 i = 0; i < height; i++) {
for (int32 j = 0; j < width; j++) { 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; _engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % PLASMA_WIDTH * 10 + 6400] = 255;
} }
const int32 textSize = _engine->_text->getTextSize(text); 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); const Common::Rect rect(5, 5, 634, 50);
_engine->_menu->drawBox(rect); _engine->_menu->drawBox(rect);
_engine->copyBlockPhys(rect); _engine->copyBlockPhys(rect);

View file

@ -159,9 +159,9 @@ void Holomap::drawHolomapLocation() {
const int padding = 17; const int padding = 17;
Common::Rect rect; Common::Rect rect;
rect.left = padding - 1; rect.left = padding - 1;
rect.top = SCREEN_HEIGHT - 146; rect.top = _engine->height() - 146;
rect.right = SCREEN_WIDTH - padding; rect.right = _engine->width() - padding;
rect.bottom = SCREEN_HEIGHT - padding; rect.bottom = _engine->height() - padding;
_engine->_menu->drawBox(rect); _engine->_menu->drawBox(rect);
rect.grow(-1); rect.grow(-1);
_engine->_interface->drawTransparentBox(rect, 3); _engine->_interface->drawTransparentBox(rect, 3);
@ -183,12 +183,12 @@ void Holomap::processHolomap() {
_engine->setPalette(_engine->_screens->paletteRGBA); _engine->setPalette(_engine->_screens->paletteRGBA);
loadHolomapGFX(); 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->initTextBank(TextBankId::Inventory_Intro_and_Holomap);
_engine->_text->setFontCrossColor(9); _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(); drawHolomapLocation();
_engine->flip(); _engine->flip();

View file

@ -97,7 +97,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
} }
} }
int32 pitch = SCREEN_WIDTH; int32 pitch = _engine->width();
endWidth -= startWidth; endWidth -= startWidth;
endHeight -= startHeight; endHeight -= startHeight;
if (endHeight < 0) { 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) { void Interface::drawTransparentBox(const Common::Rect &rect, int32 colorAdj) {
const int32 left = MAX((int32)SCREEN_TEXTLIMIT_LEFT, (int32)rect.left); const int32 left = MAX((int32)0, (int32)rect.left);
const int32 top = MAX((int32)SCREEN_TEXTLIMIT_TOP, (int32)rect.top); const int32 top = MAX((int32)0, (int32)rect.top);
const int32 right = MIN((int32)SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right); const int32 right = MIN((int32)(_engine->width() - 1), (int32)rect.right);
const int32 bottom = MIN((int32)SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom); const int32 bottom = MIN((int32)(_engine->height() - 1), (int32)rect.bottom);
if (left > SCREEN_TEXTLIMIT_RIGHT) { if (left > (_engine->width() - 1)) {
return; return;
} }
if (right < SCREEN_TEXTLIMIT_LEFT) { if (right < 0) {
return; return;
} }
if (top > SCREEN_TEXTLIMIT_BOTTOM) { if (top > (_engine->height() - 1)) {
return; return;
} }
if (bottom < SCREEN_TEXTLIMIT_TOP) { if (bottom < 0) {
return; return;
} }
@ -186,10 +186,10 @@ void Interface::drawSplittedBox(const Common::Rect &rect, uint8 colorIndex) {
} }
void Interface::setClip(const Common::Rect &rect) { void Interface::setClip(const Common::Rect &rect) {
textWindow.left = MAX((int32)SCREEN_TEXTLIMIT_LEFT, (int32)rect.left); textWindow.left = MAX((int32)0, (int32)rect.left);
textWindow.top = MAX((int32)SCREEN_TEXTLIMIT_TOP, (int32)rect.top); textWindow.top = MAX((int32)0, (int32)rect.top);
textWindow.right = MIN((int32)SCREEN_TEXTLIMIT_RIGHT, (int32)rect.right); textWindow.right = MIN((int32)(_engine->width() - 1), (int32)rect.right);
textWindow.bottom = MIN((int32)SCREEN_TEXTLIMIT_BOTTOM, (int32)rect.bottom); textWindow.bottom = MIN((int32)(_engine->height() - 1), (int32)rect.bottom);
} }
void Interface::saveClip() { void Interface::saveClip() {
@ -201,10 +201,10 @@ void Interface::loadClip() {
} }
void Interface::resetClip() { void Interface::resetClip() {
textWindow.top = SCREEN_TEXTLIMIT_TOP; textWindow.top = 0;
textWindow.left = SCREEN_TEXTLIMIT_LEFT; textWindow.left = 0;
textWindow.right = SCREEN_TEXTLIMIT_RIGHT; textWindow.right = (_engine->width() - 1);
textWindow.bottom = SCREEN_TEXTLIMIT_BOTTOM; textWindow.bottom = (_engine->height() - 1);
} }
} // namespace TwinE } // namespace TwinE

View file

@ -32,15 +32,6 @@ class ManagedSurface;
namespace TwinE { 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 TwinEEngine;
class Interface { class Interface {

View file

@ -300,7 +300,7 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r
_engine->_text->setFontColor(15); _engine->_text->setFontColor(15);
_engine->_text->setFontParameters(2, 8); _engine->_text->setFontParameters(2, 8);
const int32 textSize = _engine->_text->getTextSize(dialText); 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); _engine->copyBlockPhys(rect);
} }
@ -366,7 +366,7 @@ int16 Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
const char *text = menuSettings->getButtonText(_engine->_text, i); const char *text = menuSettings->getButtonText(_engine->_text, i);
const int32 border = 45; const int32 border = 45;
const int32 mainMenuButtonHeightHalf = 25; 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 (hover) {
if (i == buttonNumber) { if (i == buttonNumber) {
drawButtonGfx(menuSettings, rect, menuItemId, text, hover); drawButtonGfx(menuSettings, rect, menuItemId, text, hover);
@ -921,7 +921,7 @@ void Menu::drawBehaviour(HeroBehaviourType behaviour, int32 angle, bool cantDraw
char dialText[256]; char dialText[256];
_engine->_text->getMenuText(_engine->_actor->getTextIdForBehaviour(), dialText, sizeof(dialText)); _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); _engine->copyBlockPhys(titleRect);
} else { } else {
_engine->_interface->drawSplittedBox(boxRect, 0); _engine->_interface->drawSplittedBox(boxRect, 0);

View file

@ -212,7 +212,7 @@ void MenuOptions::drawSelectableCharacters() {
void MenuOptions::drawPlayerName(int32 centerx, int32 top, int32 type) { void MenuOptions::drawPlayerName(int32 centerx, int32 top, int32 type) {
const int32 left = 10; const int32 left = 10;
const int right = SCREEN_WIDTH - left; const int right = _engine->width() - left;
const int bottom = top + PLASMA_HEIGHT; const int bottom = top + PLASMA_HEIGHT;
const Common::Rect rect(left, top, right, bottom); const Common::Rect rect(left, top, right, bottom);
if (type == 1) { if (type == 1) {
@ -254,9 +254,9 @@ bool MenuOptions::enterPlayerName(int32 textIdx) {
char buffer[256]; char buffer[256];
_engine->_text->getMenuText(textIdx, buffer, sizeof(buffer)); _engine->_text->getMenuText(textIdx, buffer, sizeof(buffer));
_engine->_text->setFontColor(15); _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->_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(); _engine->flip();
Common::fill(&_onScreenKeyboardDirty[0], &_onScreenKeyboardDirty[ARRAYSIZE(_onScreenKeyboardDirty)], 1); Common::fill(&_onScreenKeyboardDirty[0], &_onScreenKeyboardDirty[ARRAYSIZE(_onScreenKeyboardDirty)], 1);

View file

@ -60,7 +60,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) {
rect.left = leftValue; rect.left = leftValue;
rect.top = topValue; rect.top = topValue;
rect.right = rightValue; rect.right = rightValue;
rect.bottom = MIN<int32>(SCREEN_TEXTLIMIT_BOTTOM, bottomValue); rect.bottom = MIN<int32>((_engine->height() - 1), bottomValue);
assert(rect.left <= rect.right); assert(rect.left <= rect.right);
assert(rect.top <= rect.bottom); assert(rect.top <= rect.bottom);
@ -72,7 +72,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) {
rect.left = redrawArea.left; rect.left = redrawArea.left;
rect.top = redrawArea.top; rect.top = redrawArea.top;
rect.right = redrawArea.right; rect.right = redrawArea.right;
rect.bottom = MIN<int32>(SCREEN_TEXTLIMIT_BOTTOM, redrawArea.bottom); rect.bottom = MIN<int32>((_engine->height() - 1), redrawArea.bottom);
assert(rect.left <= rect.right); assert(rect.left <= rect.right);
assert(rect.top <= rect.bottom); 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) { void Redraw::addRedrawArea(int32 left, int32 top, int32 right, int32 bottom) {
if (left < SCREEN_TEXTLIMIT_LEFT) { if (left < 0) {
left = SCREEN_TEXTLIMIT_LEFT; left = 0;
} }
if (top < SCREEN_TEXTLIMIT_TOP) { if (top < 0) {
top = SCREEN_TEXTLIMIT_TOP; top = 0;
} }
if (right >= SCREEN_WIDTH) { if (right >= _engine->width()) {
right = SCREEN_TEXTLIMIT_RIGHT; right = (_engine->width() - 1);
} }
if (bottom >= SCREEN_HEIGHT) { if (bottom >= _engine->height()) {
bottom = SCREEN_TEXTLIMIT_BOTTOM; bottom = (_engine->height() - 1);
} }
if (left > right || top > bottom) { 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); _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 // 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; actor->dynamicFlags.bIsVisible = 1;
} }
continue; continue;
@ -213,8 +213,8 @@ int32 Redraw::fillActorDrawingList(bool bgRedraw) {
// get actor position on screen // get actor position on screen
_engine->_renderer->projectPositionOnScreen(actor->x - _engine->_grid->cameraX, actor->y - _engine->_grid->cameraY, actor->z - _engine->_grid->cameraZ); _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) || 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 < SCREEN_WIDTH + 40 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < SCREEN_HEIGHT + 100)) { ((!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; 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))) { 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); _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].posValue = extra->x - _engine->_grid->cameraX + extra->z - _engine->_grid->cameraZ;
drawList[drawListPos].actorIdx = i; drawList[drawListPos].actorIdx = i;
drawList[drawListPos].type = DrawListType::DrawExtras; drawList[drawListPos].type = DrawListType::DrawExtras;
@ -348,20 +348,20 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
return; return;
} }
if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) { if (renderRect.left < 0) {
renderRect.left = SCREEN_TEXTLIMIT_LEFT; renderRect.left = 0;
} }
if (renderRect.top < SCREEN_TEXTLIMIT_TOP) { if (renderRect.top < 0) {
renderRect.top = SCREEN_TEXTLIMIT_TOP; renderRect.top = 0;
} }
if (renderRect.right >= SCREEN_WIDTH) { if (renderRect.right >= _engine->width()) {
renderRect.right = SCREEN_TEXTLIMIT_RIGHT; renderRect.right = (_engine->width() - 1);
} }
if (renderRect.bottom >= SCREEN_HEIGHT) { if (renderRect.bottom >= _engine->height()) {
renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; renderRect.bottom = (_engine->height() - 1);
} }
_engine->_interface->setClip(renderRect); _engine->_interface->setClip(renderRect);
@ -642,20 +642,20 @@ void Redraw::renderOverlays() {
renderRect.right = overlay->x + (textLength / 2); renderRect.right = overlay->x + (textLength / 2);
renderRect.bottom = overlay->y + textHeight; renderRect.bottom = overlay->y + textHeight;
if (renderRect.left < SCREEN_TEXTLIMIT_LEFT) { if (renderRect.left < 0) {
renderRect.left = SCREEN_TEXTLIMIT_LEFT; renderRect.left = 0;
} }
if (renderRect.top < SCREEN_TEXTLIMIT_TOP) { if (renderRect.top < 0) {
renderRect.top = SCREEN_TEXTLIMIT_TOP; renderRect.top = 0;
} }
if (renderRect.right > SCREEN_TEXTLIMIT_RIGHT) { if (renderRect.right > (_engine->width() - 1)) {
renderRect.right = SCREEN_TEXTLIMIT_RIGHT; renderRect.right = (_engine->width() - 1);
} }
if (renderRect.bottom > SCREEN_TEXTLIMIT_BOTTOM) { if (renderRect.bottom > (_engine->height() - 1)) {
renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; renderRect.bottom = (_engine->height() - 1);
} }
_engine->_interface->setClip(renderRect); _engine->_interface->setClip(renderRect);
@ -788,8 +788,8 @@ void Redraw::zoomScreenScale() {
*dest++ = *src; *dest++ = *src;
*dest++ = *src++; *dest++ = *src++;
} }
//memcpy(dest, dest - SCREEN_WIDTH, SCREEN_WIDTH); //memcpy(dest, dest - _engine->width(), _engine->width());
//dest += SCREEN_WIDTH; //dest += _engine->width();
} }
_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer); _engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
zoomWorkVideoBuffer.free(); zoomWorkVideoBuffer.free();

View file

@ -375,8 +375,8 @@ void Renderer::computeBoundingBox(Vertex *vertices, int32 numVertices, int &vlef
vright = vbottom = SCENE_SIZE_MIN; vright = vbottom = SCENE_SIZE_MIN;
for (int32 i = 0; i < numVertices; i++) { for (int32 i = 0; i < numVertices; i++) {
vertices[i].x = clamp(vertices[i].x, 0, SCREEN_WIDTH - 1); vertices[i].x = clamp(vertices[i].x, 0, _engine->width() - 1);
vertices[i].y = clamp(vertices[i].y, 0, SCREEN_HEIGHT - 1); vertices[i].y = clamp(vertices[i].y, 0, _engine->height() - 1);
const int vertexX = vertices[i].x; const int vertexX = vertices[i].x;
vleft = MIN(vleft, vertexX); vleft = MIN(vleft, vertexX);
vright = MAX(vright, 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; cvalue = (oldVertexParam << 8) + ((vertexParam2 - oldVertexParam) << 8) % vsize;
cdelta = ((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; float slope = (float)hsize / (float)vsize;
slope = up ? -slope : slope; 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 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++) { for (int32 i = 0; i < vsize + 2; i++) {
if (outPtr2 - polyTab2 < ARRAYSIZE(polyTab2)) { 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]; const int16 *ptr1 = &polyTab[vtop];
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
int16 start = ptr1[0]; int16 start = ptr1[0];
int16 stop = ptr1[SCREEN_HEIGHT]; int16 stop = ptr1[_engine->height()];
ptr1++; ptr1++;
int32 hsize = stop - start; int32 hsize = stop - start;
@ -489,7 +489,7 @@ void Renderer::renderPolygonsCopper(uint8 *out, int vtop, int32 vsize, int32 col
start += mask; start += mask;
start = (start & 0xFF00) | ((start & 0xFF) & (uint8)(dx >> 8)); start = (start & 0xFF00) | ((start & 0xFF) & (uint8)(dx >> 8));
start = (start & 0xFF00) | ((start & 0xFF) + (dx & 0xFF)); start = (start & 0xFF00) | ((start & 0xFF) + (dx & 0xFF));
if (j >= 0 && j < SCREEN_WIDTH) { if (j >= 0 && j < _engine->width()) {
out[j] = start & 0xFF; out[j] = start & 0xFF;
} }
mask = (mask << 2) | (mask >> 14); 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++; currentLine++;
} while (--vsize); } while (--vsize);
} }
@ -506,9 +506,9 @@ void Renderer::renderPolygonsBopper(uint8 *out, int vtop, int32 vsize, int32 col
const int16 *ptr1 = &polyTab[vtop]; const int16 *ptr1 = &polyTab[vtop];
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
int16 start = ptr1[0]; int16 start = ptr1[0];
int16 stop = ptr1[SCREEN_HEIGHT]; int16 stop = ptr1[_engine->height()];
ptr1++; ptr1++;
int32 hsize = stop - start; int32 hsize = stop - start;
@ -516,14 +516,14 @@ void Renderer::renderPolygonsBopper(uint8 *out, int vtop, int32 vsize, int32 col
hsize++; hsize++;
for (int32 j = start; j < hsize + start; j++) { for (int32 j = start; j < hsize + start; j++) {
if ((start + (vtop % 1)) & 1) { if ((start + (vtop % 1)) & 1) {
if (j >= 0 && j < SCREEN_WIDTH) { if (j >= 0 && j < _engine->width()) {
out[j] = color; out[j] = color;
} }
} }
} }
} }
} }
out += SCREEN_WIDTH; out += _engine->width();
currentLine++; currentLine++;
} while (--vsize); } while (--vsize);
} }
@ -532,22 +532,22 @@ void Renderer::renderPolygonsFlat(uint8 *out, int vtop, int32 vsize, int32 color
const int16 *ptr1 = &polyTab[vtop]; const int16 *ptr1 = &polyTab[vtop];
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
int16 start = ptr1[0]; int16 start = ptr1[0];
int16 stop = ptr1[SCREEN_HEIGHT]; int16 stop = ptr1[_engine->height()];
ptr1++; ptr1++;
int32 hsize = stop - start; int32 hsize = stop - start;
if (hsize >= 0) { if (hsize >= 0) {
hsize++; hsize++;
for (int32 j = start; j < hsize + start; j++) { for (int32 j = start; j < hsize + start; j++) {
if (j >= 0 && j < SCREEN_WIDTH) { if (j >= 0 && j < _engine->width()) {
out[j] = color; out[j] = color;
} }
} }
} }
} }
out += SCREEN_WIDTH; out += _engine->width();
currentLine++; currentLine++;
} while (--vsize); } while (--vsize);
} }
@ -562,7 +562,7 @@ void Renderer::renderPolygonsTele(uint8 *out, int vtop, int32 vsize, int32 color
int32 hsize; int32 hsize;
while (1) { while (1) {
start = ptr1[0]; start = ptr1[0];
stop = ptr1[SCREEN_HEIGHT]; stop = ptr1[_engine->height()];
ptr1++; ptr1++;
hsize = stop - start; hsize = stop - start;
@ -575,7 +575,7 @@ void Renderer::renderPolygonsTele(uint8 *out, int vtop, int32 vsize, int32 color
color = *(out2 + 1); color = *(out2 + 1);
out += SCREEN_WIDTH; out += _engine->width();
--renderLoop; --renderLoop;
if (!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; --renderLoop;
} while (renderLoop); } while (renderLoop);
@ -639,7 +639,7 @@ void Renderer::renderPolygonsTras(uint8 *out, int vtop, int32 vsize, int32 color
unsigned short int bx; unsigned short int bx;
int16 start = ptr1[0]; int16 start = ptr1[0];
int16 stop = ptr1[SCREEN_HEIGHT]; int16 stop = ptr1[_engine->height()];
ptr1++; ptr1++;
int32 hsize = stop - start; int32 hsize = stop - start;
@ -660,7 +660,7 @@ void Renderer::renderPolygonsTras(uint8 *out, int vtop, int32 vsize, int32 color
out2++; out2++;
} }
} }
out += SCREEN_WIDTH; out += _engine->width();
} while (--vsize); } while (--vsize);
} }
@ -671,9 +671,9 @@ void Renderer::renderPolygonTrame(uint8 *out, int vtop, int32 vsize, int32 color
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
int16 start = ptr1[0]; int16 start = ptr1[0];
int16 stop = ptr1[SCREEN_HEIGHT]; int16 stop = ptr1[_engine->height()];
ptr1++; ptr1++;
int32 hsize = stop - start; 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++; currentLine++;
} while (--vsize); } while (--vsize);
} }
@ -709,20 +709,20 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co
int32 renderLoop = vsize; int32 renderLoop = vsize;
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
uint16 startColor = ptr2[0]; uint16 startColor = ptr2[0];
uint16 stopColor = ptr2[SCREEN_HEIGHT]; uint16 stopColor = ptr2[_engine->height()];
int16 colorSize = stopColor - startColor; int16 colorSize = stopColor - startColor;
int16 stop = ptr1[SCREEN_HEIGHT]; // stop int16 stop = ptr1[_engine->height()]; // stop
int16 start = ptr1[0]; // start int16 start = ptr1[0]; // start
ptr1++; ptr1++;
uint8 *out2 = start + out; uint8 *out2 = start + out;
int32 hsize = stop - start; int32 hsize = stop - start;
//varf2 = ptr2[SCREEN_HEIGHT]; //varf2 = ptr2[_engine->height()];
//varf3 = ptr2[0]; //varf3 = ptr2[0];
ptr2++; ptr2++;
@ -730,28 +730,28 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co
//varf4 = (float)((int32)varf2 - (int32)varf3); //varf4 = (float)((int32)varf2 - (int32)varf3);
if (hsize == 0) { if (hsize == 0) {
if (start >= 0 && start < SCREEN_WIDTH) { if (start >= 0 && start < _engine->width()) {
*out2 = ((startColor + stopColor) / 2) >> 8; // moyenne des 2 couleurs *out2 = ((startColor + stopColor) / 2) >> 8; // moyenne des 2 couleurs
} }
} else if (hsize > 0) { } else if (hsize > 0) {
if (hsize == 1) { if (hsize == 1) {
if (start >= -1 && start < SCREEN_WIDTH - 1) { if (start >= -1 && start < _engine->width() - 1) {
*(out2 + 1) = stopColor >> 8; *(out2 + 1) = stopColor >> 8;
} }
if (start >= 0 && start < SCREEN_WIDTH) { if (start >= 0 && start < _engine->width()) {
*(out2) = startColor >> 8; *(out2) = startColor >> 8;
} }
} else if (hsize == 2) { } else if (hsize == 2) {
if (start >= -2 && start < SCREEN_WIDTH - 2) { if (start >= -2 && start < _engine->width() - 2) {
*(out2 + 2) = stopColor >> 8; *(out2 + 2) = stopColor >> 8;
} }
if (start >= -1 && start < SCREEN_WIDTH - 1) { if (start >= -1 && start < _engine->width() - 1) {
*(out2 + 1) = ((startColor + stopColor) / 2) >> 8; *(out2 + 1) = ((startColor + stopColor) / 2) >> 8;
} }
if (start >= 0 && start < SCREEN_WIDTH) { if (start >= 0 && start < _engine->width()) {
*(out2) = startColor >> 8; *(out2) = startColor >> 8;
} }
} else { } else {
@ -761,7 +761,7 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co
if (hsize % 2) { if (hsize % 2) {
hsize /= 2; hsize /= 2;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = startColor >> 8; *(out2) = startColor >> 8;
} }
out2++; out2++;
@ -772,14 +772,14 @@ void Renderer::renderPolygonsGouraud(uint8 *out, int vtop, int32 vsize, int32 co
} }
do { do {
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = startColor >> 8; *(out2) = startColor >> 8;
} }
currentXPos++; currentXPos++;
startColor += colorSize; startColor += colorSize;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2 + 1) = startColor >> 8; *(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++; currentLine++;
} while (--renderLoop); } while (--renderLoop);
} }
@ -802,22 +802,22 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
int32 currentLine = vtop; int32 currentLine = vtop;
do { do {
if (currentLine >= 0 && currentLine < SCREEN_HEIGHT) { if (currentLine >= 0 && currentLine < _engine->height()) {
int16 stop = ptr1[SCREEN_HEIGHT]; // stop int16 stop = ptr1[_engine->height()]; // stop
int16 start = ptr1[0]; // start int16 start = ptr1[0]; // start
ptr1++; ptr1++;
int32 hsize = stop - start; int32 hsize = stop - start;
if (hsize >= 0) { if (hsize >= 0) {
uint16 startColor = ptr2[0]; uint16 startColor = ptr2[0];
uint16 stopColor = ptr2[SCREEN_HEIGHT]; uint16 stopColor = ptr2[_engine->height()];
int32 currentXPos = start; int32 currentXPos = start;
uint8 *out2 = start + out; uint8 *out2 = start + out;
ptr2++; ptr2++;
if (hsize == 0) { if (hsize == 0) {
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = (uint8)(((startColor + stopColor) / 2) >> 8); *(out2) = (uint8)(((startColor + stopColor) / 2) >> 8);
} }
} else { } else {
@ -829,7 +829,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
currentColor &= 0xFF; currentColor &= 0xFF;
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = currentColor >> 8; *(out2) = currentColor >> 8;
} }
@ -839,7 +839,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
currentColor += startColor; currentColor += startColor;
currentXPos++; currentXPos++;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2 + 1) = currentColor >> 8; *(out2 + 1) = currentColor >> 8;
} }
} else if (hsize == 2) { } else if (hsize == 2) {
@ -851,7 +851,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
colorSize /= 2; colorSize /= 2;
currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = currentColor >> 8; *(out2) = currentColor >> 8;
} }
@ -862,7 +862,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
currentColor &= 0xFF; currentColor &= 0xFF;
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = currentColor >> 8; *(out2) = currentColor >> 8;
} }
@ -872,7 +872,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
currentColor += startColor; currentColor += startColor;
currentXPos++; currentXPos++;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2 + 1) = currentColor >> 8; *(out2 + 1) = currentColor >> 8;
} }
} else { } else {
@ -885,7 +885,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
currentColor &= 0xFF; currentColor &= 0xFF;
currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = currentColor >> 8; *(out2) = currentColor >> 8;
} }
out2++; out2++;
@ -897,7 +897,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
do { do {
currentColor &= 0xFF; currentColor &= 0xFF;
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2) = currentColor >> 8; *(out2) = currentColor >> 8;
} }
currentXPos++; currentXPos++;
@ -905,7 +905,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
startColor += colorSize; startColor += colorSize;
currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF)); currentColor = ((currentColor & (0xFF00)) | ((((currentColor & 0xFF) << (hsize & 0xFF))) & 0xFF));
currentColor += startColor; currentColor += startColor;
if (currentXPos >= 0 && currentXPos < SCREEN_WIDTH) { if (currentXPos >= 0 && currentXPos < _engine->width()) {
*(out2 + 1) = currentColor >> 8; *(out2 + 1) = currentColor >> 8;
} }
currentXPos++; currentXPos++;
@ -916,7 +916,7 @@ void Renderer::renderPolygonsDither(uint8 *out, int vtop, int32 vsize, int32 col
} }
} }
} }
out += SCREEN_WIDTH; out += _engine->width();
currentLine++; currentLine++;
} while (--renderLoop); } while (--renderLoop);
} }

View file

@ -39,7 +39,8 @@
#define POLYGONTYPE_GOURAUD 7 #define POLYGONTYPE_GOURAUD 7
#define POLYGONTYPE_DITHER 8 #define POLYGONTYPE_DITHER 8
#define POLYTABSIZE (SCREEN_HEIGHT * 2) // TODO: this depends on the actual used resolution
#define POLYTABSIZE (SCREEN_WIDTH * 2)
namespace Common { namespace Common {
class MemoryReadStream; class MemoryReadStream;

View file

@ -460,7 +460,7 @@ void GameState::processGameoverAnimation() {
Renderer::prepareIsoModel(gameOverPtr); Renderer::prepareIsoModel(gameOverPtr);
_engine->_sound->stopSamples(); _engine->_sound->stopSamples();
_engine->_music->stopMidiMusic(); // stop fade music _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; int32 startLbaTime = _engine->lbaTime;
_engine->_interface->setClip(rect); _engine->_interface->setClip(rect);

View file

@ -76,7 +76,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
return; return;
} }
int32 offset = -((right - left) - SCREEN_WIDTH) - 1; int32 offset = -((right - left) - _engine->width()) - 1;
right++; right++;
bottom++; bottom++;
@ -619,13 +619,13 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
if (brickPixelPosX < -24) { if (brickPixelPosX < -24) {
return; return;
} }
if (brickPixelPosX >= SCREEN_WIDTH) { if (brickPixelPosX >= _engine->width()) {
return; return;
} }
if (brickPixelPosY < -38) { if (brickPixelPosY < -38) {
return; return;
} }
if (brickPixelPosY >= SCREEN_HEIGHT) { if (brickPixelPosY >= _engine->height()) {
return; return;
} }

View file

@ -82,6 +82,7 @@ struct BrickEntry {
#define BRICK_SIZE 512 #define BRICK_SIZE 512
#define BRICK_HEIGHT 256 #define BRICK_HEIGHT 256
// TODO: this depends on the actual used resolution
#define NUMBRICKENTRIES (1 + (SCREEN_WIDTH + 24) / 24) #define NUMBRICKENTRIES (1 + (SCREEN_WIDTH + 24) / 24)
#define MAXBRICKS 150 #define MAXBRICKS 150

View file

@ -1712,7 +1712,7 @@ static int32 lPROJ_3D(TwinEEngine *engine, LifeScriptContext &ctx) {
engine->flip(); engine->flip();
engine->_scene->changeRoomVar10 = false; 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->setCameraAngle(0, 1500, 0, 25, -128, 0, 13000);
engine->_renderer->setLightVector(896, 950, ANGLE_0); engine->_renderer->setLightVector(896, 950, ANGLE_0);
@ -1741,8 +1741,8 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 textBoxRight = textSize; int32 textBoxRight = textSize;
engine->_text->setFontColor(15); engine->_text->setFontColor(15);
engine->_text->drawText(0, drawVar1, textStr); engine->_text->drawText(0, drawVar1, textStr);
if (textSize > SCREEN_WIDTH - 1) { if (textSize > engine->width() - 1) {
textBoxRight = SCREEN_WIDTH - 1; textBoxRight = engine->width() - 1;
} }
drawVar1 += 40; drawVar1 += 40;
@ -1759,7 +1759,7 @@ static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
*/ */
static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) { static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx) {
drawVar1 = 0; 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->_interface->drawSplittedBox(rect, 0);
engine->copyBlockPhys(rect); engine->copyBlockPhys(rect);
return 0; return 0;

View file

@ -191,7 +191,7 @@ void Text::drawCharacter(int32 x, int32 y, uint8 character) { // drawCharacter
tempX += jump; tempX += jump;
uint8* basePtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY); uint8* basePtr = (uint8 *)_engine->frontVideoBuffer.getBasePtr(tempX, tempY);
for (uint8 i = 0; i < number; i++) { 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; *basePtr = usedColor;
} }
@ -740,11 +740,11 @@ void Text::textClipFull() {
const int32 padding = 8; const int32 padding = 8;
_dialTextBox.left = margin; _dialTextBox.left = margin;
_dialTextBox.top = margin; _dialTextBox.top = margin;
_dialTextBox.right = SCREEN_WIDTH - margin; _dialTextBox.right = _engine->width() - margin;
_dialTextBox.bottom = SCREEN_HEIGHT - margin; _dialTextBox.bottom = _engine->height() - margin;
_dialTextBoxLines = (int32)(_dialTextBox.height() / _lineHeight) - 1; _dialTextBoxLines = (int32)(_dialTextBox.height() / _lineHeight) - 1;
_dialTextBoxMaxX = SCREEN_WIDTH - 2 * margin - 2 * padding; _dialTextBoxMaxX = _engine->width() - 2 * margin - 2 * padding;
} }
void Text::textClipSmall() { void Text::textClipSmall() {
@ -754,11 +754,11 @@ void Text::textClipSmall() {
const int32 textHeight = _dialTextBoxLines * _lineHeight; const int32 textHeight = _dialTextBoxLines * _lineHeight;
_dialTextBox.left = margin; _dialTextBox.left = margin;
_dialTextBox.top = SCREEN_HEIGHT - textHeight - margin - padding; _dialTextBox.top = _engine->height() - textHeight - margin - padding;
_dialTextBox.right = SCREEN_WIDTH - margin; _dialTextBox.right = _engine->width() - margin;
_dialTextBox.bottom = SCREEN_HEIGHT - 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) { void Text::drawAskQuestion(int32 index) {

View file

@ -197,8 +197,10 @@ Common::Error TwinEEngine::run() {
debug("(c) 1994 by Adeline Software International, All Rights Reserved."); debug("(c) 1994 by Adeline Software International, All Rights Reserved.");
syncSoundSettings(); syncSoundSettings();
initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT); const int32 w = 640;
allocVideoMemory(); const int32 h = 480;
initGraphics(w, h);
allocVideoMemory(w, h);
initAll(); initAll();
initEngine(); initEngine();
_sound->stopSamples(); _sound->stopSamples();
@ -304,13 +306,13 @@ void TwinEEngine::autoSave() {
saveGameState(getAutosaveSlot(), _gameState->playerName, true); saveGameState(getAutosaveSlot(), _gameState->playerName, true);
} }
void TwinEEngine::allocVideoMemory() { void TwinEEngine::allocVideoMemory(int32 w, int32 h) {
const Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); 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); workVideoBuffer.create(w, h, format);
frontVideoBuffer.create(SCREEN_WIDTH, SCREEN_HEIGHT, format); frontVideoBuffer.create(w, h, format);
} }
static int getLanguageTypeIndex(const char *languageName) { static int getLanguageTypeIndex(const char *languageName) {
@ -464,8 +466,8 @@ void TwinEEngine::initAll() {
_scene->sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX); _scene->sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX);
_redraw->renderRect.right = SCREEN_TEXTLIMIT_RIGHT; _redraw->renderRect.right = (width() - 1);
_redraw->renderRect.bottom = SCREEN_TEXTLIMIT_BOTTOM; _redraw->renderRect.bottom = (height() - 1);
// Set clip to fullscreen by default, allows main menu to render properly after load // Set clip to fullscreen by default, allows main menu to render properly after load
_interface->resetClip(); _interface->resetClip();
@ -641,7 +643,7 @@ void TwinEEngine::centerScreenOnActor() {
_renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX * BRICK_SIZE), _renderer->projectPositionOnScreen(actor->x - (_grid->newCameraX * BRICK_SIZE),
actor->y - (_grid->newCameraY * BRICK_HEIGHT), actor->y - (_grid->newCameraY * BRICK_HEIGHT),
actor->z - (_grid->newCameraZ * BRICK_SIZE)); 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->newCameraX = ((actor->x + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->x + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraX) / 2;
_grid->newCameraY = actor->y / BRICK_HEIGHT; _grid->newCameraY = actor->y / BRICK_HEIGHT;
_grid->newCameraZ = ((actor->z + BRICK_HEIGHT) / BRICK_SIZE) + (((actor->z + BRICK_HEIGHT) / BRICK_SIZE) - _grid->newCameraZ) / 2; _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); assert(top <= bottom);
int32 width = right - left + 1; int32 width = right - left + 1;
int32 height = bottom - top + 1; int32 height = bottom - top + 1;
if (left + width > SCREEN_WIDTH) { if (left + width > this->width()) {
width = SCREEN_WIDTH - left; width = this->width() - left;
} }
if (top + height > SCREEN_HEIGHT) { if (top + height > this->height()) {
height = SCREEN_HEIGHT - top; height = this->height() - top;
} }
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
return; return;

View file

@ -272,7 +272,7 @@ public:
*/ */
int32 runGameEngine(); int32 runGameEngine();
/** Allocate video memory, both front and back buffers */ /** Allocate video memory, both front and back buffers */
void allocVideoMemory(); void allocVideoMemory(int32 w, int32 h);
/** /**
* @return A random value between [0-max) * @return A random value between [0-max)
*/ */