From ca84b2737f6bd1c6c971d5ff7451cfb164afadb8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Sep 2012 21:43:33 +1000 Subject: HOPKINS: Add object loading --- engines/hopkins/graphics.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 engines/hopkins/graphics.cpp (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp new file mode 100644 index 0000000000..01a673f020 --- /dev/null +++ b/engines/hopkins/graphics.cpp @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/system.h" +#include "hopkins/files.h" +#include "hopkins/globals.h" +#include "hopkins/graphics.h" +#include "hopkins/hopkins.h" + +namespace Hopkins { + +int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i ) + objP += READ_LE_UINT32(objP) + 16; + + return READ_LE_UINT16(objP + 4); +} + +int ObjectManager::Get_Hauteur(const byte *objectData, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i) + objP += READ_LE_UINT32(objP) + 16; + + return READ_LE_UINT16(objP + 6); +} + +int ObjectManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i) { + objP += READ_LE_UINT32(objP) + 16; + } + + objP += 4; + int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); + + memcpy(sprite + 3, objP - 4, result + 16); + return result; +} + +byte *ObjectManager::DEL_FICHIER_OBJ() { + GLOBALS.NUM_FICHIER_OBJ = 0; + if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) + GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ); + + byte *result = PTRNUL; + GLOBALS.ADR_FICHIER_OBJ = PTRNUL; + return result; +} + +byte *ObjectManager::CHARGE_SPRITE(const Common::String &file) { + FileManager::DMESS1(); + return FileManager::CHARGE_FICHIER(file); +} + +int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i) { + objP += READ_LE_UINT32(objP) + 16; + } + + objP += 4; + int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); + + memcpy(sprite, objP + 12, result); + return result; +} + +} // End of namespace Hopkins -- cgit v1.2.3 From ecee539bfde463648d69e0330500ab5ad3cde080 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Sep 2012 23:43:35 +1000 Subject: HOPKINS: Implement proper graphics initialisation code --- engines/hopkins/graphics.cpp | 136 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 01a673f020..7b04e1f1ba 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "engines/util.h" #include "hopkins/files.h" #include "hopkins/globals.h" #include "hopkins/graphics.h" @@ -28,9 +29,69 @@ namespace Hopkins { +byte *ObjectManager::CHANGE_OBJET(int objIndex) { + byte *result = ObjectManager::CAPTURE_OBJET(objIndex, 1); + GLOBALS.Bufferobjet = result; + GLOBALS.Nouv_objet = 1; + GLOBALS.OBJET_EN_COURS = objIndex; + return result; +} + +byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) { + byte *result = NULL; + byte *dataP; + + dataP = 0; + int v2 = GLOBALS.ObjetW[objIndex].field0; + int v3 = GLOBALS.ObjetW[objIndex].field1; + + if (mode == 1) + ++v3; + if (v2 != GLOBALS.NUM_FICHIER_OBJ) { + if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) + ObjectManager::DEL_FICHIER_OBJ(); + if (v2 == 1) { + FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR"); + GLOBALS.ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(GLOBALS.NFICHIER); + } + GLOBALS.NUM_FICHIER_OBJ = v2; + } + + int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, v3); + int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, v3); + GLOBALS.OBJL = width; + GLOBALS.OBJH = height; + + switch (mode) { + case 0: + dataP = GLOBALS.dos_malloc2(height * width); + if (dataP == PTRNUL) + error("CAPTURE_OBJET"); + + ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, v3); + break; + + case 1: + ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, v3); + result = GLOBALS.Bufferobjet; + break; + + case 3: + ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, v3); + result = GLOBALS.INVENTAIRE_OBJET; + break; + + default: + result = dataP; + break; + } + + return result; +} + int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) { const byte *objP = objectData + 3; - for (int i = objIndex; i; --i ) + for (int i = objIndex; i; --i) objP += READ_LE_UINT32(objP) + 16; return READ_LE_UINT16(objP + 4); @@ -85,4 +146,77 @@ int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int return result; } +int ObjectManager::AJOUTE_OBJET(int objIndex) { + bool flag = false; + int arrIndex = 0; + do { + ++arrIndex; + if (!GLOBALS.INVENTAIRE[arrIndex]) + flag = true; + if (arrIndex == 32) + flag = true; + } while (!flag); + + GLOBALS.INVENTAIRE[arrIndex] = objIndex; + return arrIndex; +} + +GraphicsManager::GraphicsManager() { + SDL_MODEYES = false; +} + +void GraphicsManager::SET_MODE(int width, int height) { + if (!SDL_MODEYES) { + SDL_ECHELLE = 0; + + if (GLOBALS.XSETMODE == 1) + SDL_ECHELLE = 0; + if (GLOBALS.XSETMODE == 2) + SDL_ECHELLE = 25; + if (GLOBALS.XSETMODE == 3) + SDL_ECHELLE = 50; + if (GLOBALS.XSETMODE == 4) + SDL_ECHELLE = 75; + if (GLOBALS.XSETMODE == 5) + SDL_ECHELLE = GLOBALS.XZOOM; + + int bpp = 8; + if (GLOBALS.XFORCE8 == 1) + bpp = 8; + if (GLOBALS.XFORCE16 == 1) + bpp = 16; + + if (SDL_ECHELLE) { + error("TODO: Implement zooming support"); + //width = Reel_Zoom(a1, SDL_ECHELLE); + //height = Reel_Zoom(a2, SDL_ECHELLE); + } + + if (bpp == 8) + initGraphics(width, height, true); + else { + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + initGraphics(width, height, true, &pixelFormat); + } + + XSCREEN = width; + YSCREEN = height; + + Linear = true; + Winbpp = bpp; + WinScan = width; + + PAL_PIXELS = SD_PIXELS; + nbrligne = width; + + for (int idx = 0; idx < 256; ++idx) { + cmap[idx].r = cmap[idx].g = cmap[idx].b = 0; + } + + SDL_MODEYES = true; + } else { + error("Called SET_MODE multiple times"); + } +} + } // End of namespace Hopkins -- cgit v1.2.3 From 42a09f00b336ce3405ff7558719f07e6f15326aa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Sep 2012 00:12:27 +1000 Subject: HOPKINS: Implemented screen lock, unlock, and clear screen --- engines/hopkins/graphics.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7b04e1f1ba..21c5d6c478 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "common/rect.h" #include "engines/util.h" #include "hopkins/files.h" #include "hopkins/globals.h" @@ -161,10 +162,16 @@ int ObjectManager::AJOUTE_OBJET(int objIndex) { return arrIndex; } +/*------------------------------------------------------------------------*/ + GraphicsManager::GraphicsManager() { SDL_MODEYES = false; } +GraphicsManager::~GraphicsManager() { +} + + void GraphicsManager::SET_MODE(int width, int height) { if (!SDL_MODEYES) { SDL_ECHELLE = 0; @@ -192,13 +199,14 @@ void GraphicsManager::SET_MODE(int width, int height) { //height = Reel_Zoom(a2, SDL_ECHELLE); } - if (bpp == 8) + if (bpp == 8) { initGraphics(width, height, true); - else { + } else { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(width, height, true, &pixelFormat); } + VideoPtr = NULL; XSCREEN = width; YSCREEN = height; @@ -219,4 +227,18 @@ void GraphicsManager::SET_MODE(int width, int height) { } } +void GraphicsManager::DD_Lock() { + VideoPtr = g_system->lockScreen(); +} + +void GraphicsManager::DD_Unlock() { + g_system->unlockScreen(); +} + +void GraphicsManager::Cls_Video() { + assert(VideoPtr); + + VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 97e84b2169e8f3084e568776b1a9561a2df6878e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Sep 2012 19:55:05 +1000 Subject: HOPKINS: Implemented image loading code --- engines/hopkins/graphics.cpp | 710 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 620 insertions(+), 90 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 21c5d6c478..385d9f46e8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "common/file.h" #include "common/rect.h" #include "engines/util.h" #include "hopkins/files.h" @@ -30,6 +31,614 @@ namespace Hopkins { +GraphicsManager::GraphicsManager() { + SDL_MODEYES = false; + MANU_SCROLL = 1; + SPEED_SCROLL = 16; + Agr_x = Agr_y = 0; + Agr_Flag_x = Agr_Flag_y = 0; +} + +GraphicsManager::~GraphicsManager() { +} + + +void GraphicsManager::SET_MODE(int width, int height) { + if (!SDL_MODEYES) { + SDL_ECHELLE = 0; + + if (GLOBALS.XSETMODE == 1) + SDL_ECHELLE = 0; + if (GLOBALS.XSETMODE == 2) + SDL_ECHELLE = 25; + if (GLOBALS.XSETMODE == 3) + SDL_ECHELLE = 50; + if (GLOBALS.XSETMODE == 4) + SDL_ECHELLE = 75; + if (GLOBALS.XSETMODE == 5) + SDL_ECHELLE = GLOBALS.XZOOM; + + int bpp = 8; + if (GLOBALS.XFORCE8 == 1) + bpp = 8; + if (GLOBALS.XFORCE16 == 1) + bpp = 16; + + if (SDL_ECHELLE) { + error("TODO: Implement zooming support"); + //width = Reel_Zoom(width, SDL_ECHELLE); + //height = Reel_Zoom(height, SDL_ECHELLE); + } + + if (bpp == 8) { + initGraphics(width, height, true); + } else { + Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + initGraphics(width, height, true, &pixelFormat); + } + + // Init surfaces + //VESA_SCREEN = dos_malloc2(0x96000u); + //VESA_BUFFER = dos_malloc2(0x96000u); + + VideoPtr = NULL; + XSCREEN = width; + YSCREEN = height; + + Linear = true; + Winbpp = bpp; + WinScan = width; + + PAL_PIXELS = SD_PIXELS; + nbrligne = width; + + for (int idx = 0; idx < 256; ++idx) { + cmap[idx].r = cmap[idx].g = cmap[idx].b = 0; + } + + SDL_MODEYES = true; + } else { + error("Called SET_MODE multiple times"); + } +} + +void GraphicsManager::DD_Lock() { + VideoPtr = g_system->lockScreen(); +} + +void GraphicsManager::DD_Unlock() { + g_system->unlockScreen(); +} + +void GraphicsManager::Cls_Video() { + assert(VideoPtr); + + VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); +} + +void GraphicsManager::LOAD_IMAGE(const Common::String &file) { + Common::String filename = Common::String::format("%s.PCX", file); + CHARGE_ECRAN(filename); + GraphicsManager::INIT_TABLE(165, 170, Palette); +} + +void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { + int v1; + byte *v4; + byte *v5; + Common::File f; + + FileManager::DMESS1(); + + v1 = 1; + if (FileManager::RECHERCHE_CAT(file, 6)) { + FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file); + if (!f.open(GLOBALS.NFICHIER)) + error("CHARGE_ECRAN - %s", file.c_str()); + + f.seek(0, SEEK_END); + f.close(); + v1 = 0; + } + + SCROLL_ECRAN(0); + A_PCXSCREEN_WIDTH_SCREEN_HEIGHT((byte *)VESA_SCREEN.pixels, file, Palette, v1); + + SCROLL = 0; + OLD_SCROLL = 0; + Cls_Pal(); + + if (!DOUBLE_ECRAN) { + souris_max(); + SCANLINE(SCREEN_WIDTH); + GLOBALS.max_x = SCREEN_WIDTH; + DD_Lock(); + Cls_Video(); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } else if (Winbpp == 1) { + if (!SDL_ECHELLE) + m_scroll2((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll2A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } + } else { + SCANLINE(0x500u); + GLOBALS.max_x = SCREEN_WIDTH * 2; + DD_Lock(); + Cls_Video(); + DD_Unlock(); + + if (MANU_SCROLL == 1) { + DD_Lock(); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } + if (Winbpp == 1) { + if (!SDL_ECHELLE) + m_scroll2((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll2A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } + + DD_Unlock(); + } + } + + v4 = (byte *)VESA_BUFFER.pixels; + v5 = (byte *)VESA_SCREEN.pixels; + memcpy(v4, v5, 614396); + + v5 = (byte *)v5 + 614396; + v4 = (byte *)v4 + 614396; + WRITE_LE_UINT16(v4, READ_LE_UINT16(v5)); + *((byte *)v4 + 2) = *((byte *)v5 + 2); +} + +void GraphicsManager::INIT_TABLE(int a1, int a2, byte *a3) { + for (int idx = 0; idx < 256; ++idx) + TABLE_COUL[idx] = idx; + + Trans_bloc(TABLE_COUL, a3, 256, a1, a2); + + for (int idx = 0; idx < 256; ++idx) { + byte v = TABLE_COUL[idx]; + if (v > 27) + TABLE_COUL[idx] = 0; + if (!v) + TABLE_COUL[idx] = 0; + } + + TABLE_COUL[0] = 1; +} + +int GraphicsManager::SCROLL_ECRAN(int amount) { + int result = CLIP(amount, 0, SCREEN_WIDTH); + start_x = result; + ofscroll = result; + SCROLL = result; + return result; +} + +void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, int param2) { + byte *v5; + int v6; + int v7; + int v8; + unsigned int v11; + int v12; + int v13; + int v14; + int v15; + int v16; + int v17; + unsigned int v18; + char v19; + int v20; + bool breakFlag; + + v5 = destP; + v6 = count - 1; + do { + breakFlag = v6; + v7 = *(byte *)v5++; + v8 = (unsigned int)(3 * v7); + + // TODO: Ensure this is the right calculation + v11 = *(byte *)(v8 + srcP) + *(byte *)(v8 + srcP + 1) + + *(byte *)(v8 + srcP + 2); + + v12 = 0; + for (;;) { + v13 = v12 + 1; + if ( v13 == 38 ) + break; + + v20 = v13; + v8 = 3 * v8; + v14 = *(byte *)(v8 + srcP); + v15 = v14; + v14 = *(byte *)(v8 + srcP + 1); + v16 = v14 + v15; + v14 = *(byte *)(v8 + srcP + 2); + v17 = v14 + v16; + v12 = v20; + v18 = param1 + v17; + if (v18 >= v11 && (unsigned int)(v18 - param2) <= v11) { + v19 = v20; + if (!v20) + v19 = 1; + *(byte *)(v5 - 1) = v19; + break; + } + } + + v6 = breakFlag - 1; + } while ( !breakFlag); +} + +// TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder +void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { + int filesize; + signed __int16 v6; + int v7; + __int16 v8; + int v9; + int v10; + int v11; + unsigned __int8 v12; + int v13; + int v14; + char v15; + int v18; + int v19; + int v20; + unsigned int v21; + int v22; + int32 v23; + byte *ptr; + Common::File f; + + // Clear the passed surface + memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + + if (typeFlag) { + FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, "PIC.RES"); + if (!f.open(GLOBALS.NFICHIER)) + error("(nom)Erreur en cours de lecture."); + f.seek(GLOBALS.CAT_POSI); + + v7 = GLOBALS.CAT_TAILLE - 896; + v8 = f.read(HEADER_PCX, 128); + + v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1; + v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1; + if ((READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) { + DOUBLE_ECRAN = false; + } else { + v6 = SCREEN_WIDTH * 2; + DOUBLE_ECRAN = true; + } + if (v20 > SCREEN_HEIGHT) + v20 = SCREEN_HEIGHT; + PCX_L = v6; + PCX_H = v20; + if (v8 == -1) + error("Erreur en cours de lecture."); + } else { + FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file); + if (!f.open(GLOBALS.NFICHIER)) + error("(nom)Erreur en cours de lecture."); + + filesize = f.size(); + int bytesRead = f.read(HEADER_PCX, 128); + if (bytesRead < 128) + error("Erreur en cours de lecture."); + + v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1; + v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1; + if (v6 <= SCREEN_WIDTH) { + DOUBLE_ECRAN = false; + } else { + v6 = SCREEN_WIDTH * 2; + DOUBLE_ECRAN = true; + } + if (v20 > SCREEN_HEIGHT) + v20 = SCREEN_HEIGHT; + PCX_L = v6; + PCX_H = v20; + v7 = filesize - 896; + } + + ptr = GLOBALS.dos_malloc2(0xEE60u); + if (v7 >= 60000) { + v21 = v7 / 60000 + 1; + v23 = 60000 * (v7 / 60000) - v7; + + if (((uint32)v23 & 0x80000000u) != 0) + v23 = -v23; + f.read(ptr, 60000); + v7 = 60000; + } else { + v21 = 1; + v23 = v7; + f.read(ptr, v7); + } + v22 = v21 - 1; + v18 = 0; + v9 = 0; + v10 = 0; + v19 = v6; + + do { + if (v9 == v7) { + v9 = 0; + --v22; + v7 = 60000; + if ( !v22 ) + v7 = v23; + v11 = v10; + f.read(ptr, v7); + v10 = v11; + } + + v12 = *((byte *)ptr + v9++); + if (v12 > 0xC0u) { + v13 = v12 - 192; + if (v9 == v7) { + v9 = 0; + --v22; + v7 = 60000; + if ( v22 == 1 ) + v7 = v23; + v14 = v10; + f.read(ptr, v7); + v10 = v14; + } + v15 = *((byte *)ptr + v9++); + + do { + *((byte *)surface + v10++) = v15; + ++v18; + --v13; + } while (v13); + } else { + *((byte *)surface + v10++) = v12; + ++v18; + } + } while (v18 < v19 * v20); + + if (typeFlag) { + f.seek(GLOBALS.CAT_TAILLE + GLOBALS.CAT_POSI - 768); + } else { + filesize = f.size(); + f.seek(filesize - 768); + } + + if (f.read(palette, PALETTE_SIZE * 3) != (PALETTE_SIZE * 3)) + error("A_PCXSCREEN_WIDTH_SCREEN_HEIGHT"); + + f.close(); + GLOBALS.dos_free2(ptr); +} + +void GraphicsManager::Cls_Pal() { + warning("TODO"); +} +void GraphicsManager::souris_max() { + warning("TODO"); +} + +void GraphicsManager::SCANLINE(int width) { + // Original has no implementatoin +} + +void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { + const byte *v7; + byte *v8; + int v9; + int v10; + byte *v11; + const byte *v12; + unsigned int v13; + + assert(VideoPtr); + v7 = xs + nbrligne2 * ys + surface; + v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; + v9 = height; + do { + v10 = v9; + memcpy((byte *)v8, (const byte *)v7, 4 * (width >> 2)); + v12 = (const byte *)(v7 + 4 * (width >> 2)); + v11 = (byte *)(v8 + 4 * (width >> 2)); + v13 = width - 4 * (width >> 2); + memcpy(v11, v12, v13); + v8 = ((byte *)v11 + v13 + WinScan - width); + v7 = ((byte *)v12 + v13 + nbrligne2 - width); + v9 = v10 - 1; + } while (v10 != 1); +} + +void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { + const byte *v7; + byte *v8; + int v9; + int v10; + int v11; + + assert(VideoPtr); + v7 = (const byte *)(xs + nbrligne2 * ys + surface); + v8 = (byte *)(destX + WinScan * destY + (byte *)VideoPtr->pixels); + v9 = WinScan - SCREEN_WIDTH; + v10 = nbrligne2 - SCREEN_WIDTH; + v11 = height; + + do { + memcpy(v8, v7, SCREEN_WIDTH); + v8 = (byte *)v8 + v9 + SCREEN_WIDTH; + v7 = (const byte *)v7 + v10 + SCREEN_WIDTH; + --v11; + } while (v11); +} + +void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { + const byte *v7; + const byte *v8; + int v9; + int v10; + byte v11; + const byte *v12; + const byte *v13; + + assert(VideoPtr); + v7 = xs + nbrligne2 * ys + surface; + v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; + v9 = height; + Agr_x = 0; + Agr_y = 0; + Agr_Flag_y = 0; + do { + for (;;) { + v13 = v8; + v12 = v7; + v10 = width; + Agr_x = 0; + do { + v11 = *(byte *)v7; + *(byte *)v8++ = *(byte *)v7++; + Agr_x += SDL_ECHELLE; + if ((unsigned int)Agr_x >= 100) { + Agr_x -= 100; + *(byte *)v8++ = v11; + } + --v10; + } while ( v10 ); + + v7 = v12; + v8 = WinScan + v13; + if (Agr_Flag_y) + break; + + Agr_y += SDL_ECHELLE; + if ((unsigned int)Agr_y < 100) + break; + + Agr_y -= 100; + Agr_Flag_y = 1; + } + + Agr_Flag_y = 0; + v7 = nbrligne2 + v12; + --v9; + } while (v9); +} + +void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { + const byte *v7; + const byte *v8; + int v9; + int v10; + const byte *v11; + int v12; + const byte *v13; + const byte *v14; + + assert(VideoPtr); + v7 = xs + nbrligne2 * ys + surface; + v8 = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; + v9 = height; + + do { + v14 = v8; + v13 = v7; + v10 = width; + v12 = v9; + v11 = PAL_PIXELS; + + do { + *(uint16 *)v8 = *(uint16 *)(v11 + 2 * *(byte *)v7++); + v8 += 2; + --v10; + } while (v10); + + v7 = nbrligne2 + v13; + v8 = WinScan + v14; + v9 = v12 - 1; + } while (v12 != 1); +} + +void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { + const byte *v7; + const byte *v8; + int v9; + int v10; + const byte *v11; + int v12; + int v13; + const byte *v14; + const byte *v15; + + assert(VideoPtr); + v7 = xs + nbrligne2 * ys + surface; + v8 = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; + v9 = height; + Agr_x = 0; + Agr_y = 0; + Agr_Flag_y = 0; + + do { + for (;;) { + v15 = v8; + v14 = v7; + v10 = width; + v13 = v9; + v11 = PAL_PIXELS; + Agr_x = 0; + + do { + v12 = *(uint16 *)(v11 + 2 * *(byte *)v7); + *(uint16 *)v8 = v12; + ++v7; + v8 += 2; + Agr_x += SDL_ECHELLE; + if ((unsigned int)Agr_x >= 100) { + Agr_x -= 100; + *(uint16 *)v8 = v12; + v8 += 2; + } + + --v10; + } while (v10); + + v9 = v13; + v7 = v14; + v8 = WinScan + v15; + if (Agr_Flag_y == 1) + break; + + Agr_y += SDL_ECHELLE; + + if ((unsigned int)Agr_y < 100) + break; + + Agr_y -= 100; + Agr_Flag_y = 1; + } + + Agr_Flag_y = 0; + v7 = nbrligne2 + v14; + v9 = v13 - 1; + } while (v13 != 1); +} + +/*------------------------------------------------------------------------*/ + byte *ObjectManager::CHANGE_OBJET(int objIndex) { byte *result = ObjectManager::CAPTURE_OBJET(objIndex, 1); GLOBALS.Bufferobjet = result; @@ -43,23 +652,23 @@ byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) { byte *dataP; dataP = 0; - int v2 = GLOBALS.ObjetW[objIndex].field0; - int v3 = GLOBALS.ObjetW[objIndex].field1; + int val1 = GLOBALS.ObjetW[objIndex].field0; + int val2 = GLOBALS.ObjetW[objIndex].field1; if (mode == 1) - ++v3; - if (v2 != GLOBALS.NUM_FICHIER_OBJ) { + ++val2; + if (val1 != GLOBALS.NUM_FICHIER_OBJ) { if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) ObjectManager::DEL_FICHIER_OBJ(); - if (v2 == 1) { + if (val1 == 1) { FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR"); GLOBALS.ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(GLOBALS.NFICHIER); } - GLOBALS.NUM_FICHIER_OBJ = v2; + GLOBALS.NUM_FICHIER_OBJ = val1; } - int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, v3); - int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, v3); + int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, val2); + int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, val2); GLOBALS.OBJL = width; GLOBALS.OBJH = height; @@ -69,16 +678,16 @@ byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) { if (dataP == PTRNUL) error("CAPTURE_OBJET"); - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, v3); + ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, val2); break; case 1: - ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, v3); + ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, val2); result = GLOBALS.Bufferobjet; break; case 3: - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, v3); + ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, val2); result = GLOBALS.INVENTAIRE_OBJET; break; @@ -162,83 +771,4 @@ int ObjectManager::AJOUTE_OBJET(int objIndex) { return arrIndex; } -/*------------------------------------------------------------------------*/ - -GraphicsManager::GraphicsManager() { - SDL_MODEYES = false; -} - -GraphicsManager::~GraphicsManager() { -} - - -void GraphicsManager::SET_MODE(int width, int height) { - if (!SDL_MODEYES) { - SDL_ECHELLE = 0; - - if (GLOBALS.XSETMODE == 1) - SDL_ECHELLE = 0; - if (GLOBALS.XSETMODE == 2) - SDL_ECHELLE = 25; - if (GLOBALS.XSETMODE == 3) - SDL_ECHELLE = 50; - if (GLOBALS.XSETMODE == 4) - SDL_ECHELLE = 75; - if (GLOBALS.XSETMODE == 5) - SDL_ECHELLE = GLOBALS.XZOOM; - - int bpp = 8; - if (GLOBALS.XFORCE8 == 1) - bpp = 8; - if (GLOBALS.XFORCE16 == 1) - bpp = 16; - - if (SDL_ECHELLE) { - error("TODO: Implement zooming support"); - //width = Reel_Zoom(a1, SDL_ECHELLE); - //height = Reel_Zoom(a2, SDL_ECHELLE); - } - - if (bpp == 8) { - initGraphics(width, height, true); - } else { - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - initGraphics(width, height, true, &pixelFormat); - } - - VideoPtr = NULL; - XSCREEN = width; - YSCREEN = height; - - Linear = true; - Winbpp = bpp; - WinScan = width; - - PAL_PIXELS = SD_PIXELS; - nbrligne = width; - - for (int idx = 0; idx < 256; ++idx) { - cmap[idx].r = cmap[idx].g = cmap[idx].b = 0; - } - - SDL_MODEYES = true; - } else { - error("Called SET_MODE multiple times"); - } -} - -void GraphicsManager::DD_Lock() { - VideoPtr = g_system->lockScreen(); -} - -void GraphicsManager::DD_Unlock() { - g_system->unlockScreen(); -} - -void GraphicsManager::Cls_Video() { - assert(VideoPtr); - - VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); -} - } // End of namespace Hopkins -- cgit v1.2.3 From 8501e1cd85ecdef723599af81f14dbf19cc6e8b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Sep 2012 20:10:32 +1000 Subject: HOPKINS: Added initialisation of graphics manager and globals fields --- engines/hopkins/graphics.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 385d9f46e8..870d947ffe 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -33,8 +33,23 @@ namespace Hopkins { GraphicsManager::GraphicsManager() { SDL_MODEYES = false; + SDL_ECHELLE = 0; + XSCREEN = YSCREEN = 0; + WinScan = 0; + Winbpp = 0; + PAL_PIXELS = NULL; + nbrligne = 0; + Linear = false; + VideoPtr = NULL; + start_x = 0; + ofscroll = 0; + SCROLL = 0; + PCX_L = PCX_H = 0; + DOUBLE_ECRAN = false; + OLD_SCROLL = 0; MANU_SCROLL = 1; SPEED_SCROLL = 16; + nbrligne2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; } @@ -107,6 +122,7 @@ void GraphicsManager::DD_Lock() { } void GraphicsManager::DD_Unlock() { + assert(VideoPtr); g_system->unlockScreen(); } -- cgit v1.2.3 From 56c454fcb5db788ccdb662bc19e1675a72d73f8d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Sep 2012 20:28:04 +1000 Subject: HOPKINS: Fix some obvious crashes in image loading --- engines/hopkins/graphics.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 870d947ffe..ebe01405e0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -55,9 +55,10 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { + VESA_SCREEN.free(); + VESA_BUFFER.free(); } - void GraphicsManager::SET_MODE(int width, int height) { if (!SDL_MODEYES) { SDL_ECHELLE = 0; @@ -85,16 +86,17 @@ void GraphicsManager::SET_MODE(int width, int height) { //height = Reel_Zoom(height, SDL_ECHELLE); } + Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0); + if (bpp == 8) { initGraphics(width, height, true); } else { - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - initGraphics(width, height, true, &pixelFormat); + initGraphics(width, height, true, &pixelFormat16); } // Init surfaces - //VESA_SCREEN = dos_malloc2(0x96000u); - //VESA_BUFFER = dos_malloc2(0x96000u); + VESA_SCREEN.create(SCREEN_WIDTH, SCREEN_HEIGHT, pixelFormat16); + VESA_BUFFER.create(SCREEN_WIDTH, SCREEN_HEIGHT, pixelFormat16); VideoPtr = NULL; XSCREEN = width; @@ -133,7 +135,7 @@ void GraphicsManager::Cls_Video() { } void GraphicsManager::LOAD_IMAGE(const Common::String &file) { - Common::String filename = Common::String::format("%s.PCX", file); + Common::String filename = Common::String::format("%s.PCX", file.c_str()); CHARGE_ECRAN(filename); GraphicsManager::INIT_TABLE(165, 170, Palette); } -- cgit v1.2.3 From 14cd54fc398c312566ea2dec3a91d775f2159f0f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Sep 2012 21:15:09 +1000 Subject: HOPKINS: Add temporary copy of VESA surface to screen, and other bugfixes --- engines/hopkins/graphics.cpp | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ebe01405e0..9b95b3f515 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -21,6 +21,7 @@ */ #include "common/system.h" +#include "graphics/palette.h" #include "common/file.h" #include "common/rect.h" #include "engines/util.h" @@ -109,10 +110,7 @@ void GraphicsManager::SET_MODE(int width, int height) { PAL_PIXELS = SD_PIXELS; nbrligne = width; - for (int idx = 0; idx < 256; ++idx) { - cmap[idx].r = cmap[idx].g = cmap[idx].b = 0; - } - + Common::fill(&cmap[0], &cmap[256 * 3], 0); SDL_MODEYES = true; } else { error("Called SET_MODE multiple times"); @@ -126,6 +124,7 @@ void GraphicsManager::DD_Lock() { void GraphicsManager::DD_Unlock() { assert(VideoPtr); g_system->unlockScreen(); + VideoPtr = NULL; } void GraphicsManager::Cls_Video() { @@ -141,14 +140,12 @@ void GraphicsManager::LOAD_IMAGE(const Common::String &file) { } void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { - int v1; - byte *v4; - byte *v5; + bool flag; Common::File f; FileManager::DMESS1(); - v1 = 1; + flag = true; if (FileManager::RECHERCHE_CAT(file, 6)) { FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file); if (!f.open(GLOBALS.NFICHIER)) @@ -156,11 +153,11 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { f.seek(0, SEEK_END); f.close(); - v1 = 0; + flag = false; } SCROLL_ECRAN(0); - A_PCXSCREEN_WIDTH_SCREEN_HEIGHT((byte *)VESA_SCREEN.pixels, file, Palette, v1); + A_PCXSCREEN_WIDTH_SCREEN_HEIGHT((byte *)VESA_SCREEN.pixels, file, Palette, flag); SCROLL = 0; OLD_SCROLL = 0; @@ -183,6 +180,8 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { else m_scroll2A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } + + DD_Unlock(); } else { SCANLINE(0x500u); GLOBALS.max_x = SCREEN_WIDTH * 2; @@ -209,14 +208,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { } } - v4 = (byte *)VESA_BUFFER.pixels; - v5 = (byte *)VESA_SCREEN.pixels; - memcpy(v4, v5, 614396); - - v5 = (byte *)v5 + 614396; - v4 = (byte *)v4 + 614396; - WRITE_LE_UINT16(v4, READ_LE_UINT16(v5)); - *((byte *)v4 + 2) = *((byte *)v5 + 2); + memcpy((byte *)VESA_BUFFER.pixels, (byte *)VESA_SCREEN.pixels, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::INIT_TABLE(int a1, int a2, byte *a3) { @@ -447,10 +439,17 @@ void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Commo } void GraphicsManager::Cls_Pal() { - warning("TODO"); + if (Winbpp == 2) { + Common::fill(&cmap[0], &cmap[PALETTE_SIZE * 3], 0); + + // TODO: Figure out what this is for + //SD_PIXELS[2 * v0] = SDL_MapRGB(*(_DWORD *)(LinuxScr + 4), 0, 0, 0); + g_system->getPaletteManager()->setPalette(cmap, 0, 256); + } } + void GraphicsManager::souris_max() { - warning("TODO"); + // Original has no implementatoin } void GraphicsManager::SCANLINE(int width) { -- cgit v1.2.3 From 7b15f9ae3c326419bbba13f375762da7fd6d18b1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Sep 2012 20:26:24 +1000 Subject: HOPKINS: Implemented some of the fade methods --- engines/hopkins/graphics.cpp | 235 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 233 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9b95b3f515..7c43d0449f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -53,6 +53,7 @@ GraphicsManager::GraphicsManager() { nbrligne2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; + FADESPD = 15; } GraphicsManager::~GraphicsManager() { @@ -431,7 +432,7 @@ void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Commo f.seek(filesize - 768); } - if (f.read(palette, PALETTE_SIZE * 3) != (PALETTE_SIZE * 3)) + if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE)) error("A_PCXSCREEN_WIDTH_SCREEN_HEIGHT"); f.close(); @@ -440,7 +441,7 @@ void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Commo void GraphicsManager::Cls_Pal() { if (Winbpp == 2) { - Common::fill(&cmap[0], &cmap[PALETTE_SIZE * 3], 0); + Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); // TODO: Figure out what this is for //SD_PIXELS[2 * v0] = SDL_MapRGB(*(_DWORD *)(LinuxScr + 4), 0, 0, 0); @@ -654,6 +655,236 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } while (v13 != 1); } +void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) { + __int16 v3; + int v4; + __int16 v5; + __int16 v6; + char *v7; + __int16 v8; + char *v9; + __int16 v10; + signed __int16 v12; + unsigned __int16 v13; + byte palData[PALETTE_BLOCK_SIZE]; + byte v15[3]; + __int16 v16; + char v17[2]; + char v18[1532]; + + v13 = FADESPD; + v3 = 0; + do { + v4 = v3; + *(&v16 + v4) = 0; + palData[v4] = 0; + ++v3; + } while (v3 < (PALETTE_BLOCK_SIZE)); + + setpal_vga256(palData); + v12 = 0; + + if ((signed __int16)v13 > 0) { + do { + v5 = 0; + do { + if ((unsigned __int8)palData[v5] < *(byte *)(v5 + palette)) { + v6 = *(&v16 + v5) + ((unsigned int)*(byte *)(v5 + palette) << 8) / (signed __int16)v13; + *(&v16 + v5) = v6; + palData[v5] = (v6 >> 8) & 0xff; + } + + if (v15[v5] < *(byte *)(palette + v5 + 1)) { + v7 = &v17[2 * v5]; + v8 = *(uint16 *)v7 + ((unsigned int)*(byte *)(palette + v5 + 1) << 8) / (signed __int16)v13; + *(uint16 *)v7 = v8; + v15[v5] = (v8 >> 8) & 0xff; + } + + if (v15[v5 + 1] < *(byte *)(palette + v5 + 2)) { + v9 = &v18[2 * v5]; + v10 = *(uint16 *)v9 + ((unsigned int)*(byte *)(palette + v5 + 2) << 8) / (signed __int16)v13; + *(uint16 *)v9 = v10; + v15[v5 + 1] = (v10 >> 8) & 0xff; + } + + v5 += 3; + } while (v5 < (PALETTE_BLOCK_SIZE)); + + setpal_vga256(palData); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + else + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + DD_VBL(); + } + + ++v12; + } while (v12 < (signed __int16)v13); + } + + setpal_vga256(palette); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + else + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + DD_VBL(); + } +} + +void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { + __int16 v3; + __int16 v4; + int v5; + signed __int16 v6; + __int16 v7; + int v8; + __int16 v9; + __int16 v10; + __int16 v12; + unsigned __int16 v13; + byte palData[PALETTE_BLOCK_SIZE]; + __int16 v15[PALETTE_BLOCK_SIZE]; + + v13 = v3 = FADESPD; + if (palette) { + v4 = 0; + do { + v5 = v4; + v3 = *(byte *)(v4 + palette); + v3 <<= 8; + v15[v5] = v3; + palData[v5] = *(byte *)(v4++ + palette); + } while (v4 < PALETTE_BLOCK_SIZE); + + setpal_vga256(palData); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + else + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + DD_VBL(); + } + + v6 = 0; + if ((signed __int16)v13 > 0) { + do { + v7 = 0; + do { + v8 = v7; + v9 = v15[v7] - ((unsigned int)*(byte *)(v7 + palette) << 8) / (signed __int16)v13; + v15[v8] = v9; + palData[v8] = (v9 >> 8) & 0xff; + ++v7; + } while (v7 < (PALETTE_BLOCK_SIZE)); + + setpal_vga256(palData); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + else + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + + DD_VBL(); + } + ++v6; + } while ((signed __int16)v13 > v6); + } + + v10 = 0; + do { + palData[v10++] = 0; + } while (v10 < (PALETTE_BLOCK_SIZE)); + + setpal_vga256(palData); + + if (Winbpp == 2) { + if (!SDL_ECHELLE) { + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + return DD_VBL(); + } + goto LABEL_28; + } + } else { + v12 = 0; + do { + palData[v12++] = 0; + } while (v12 < (PALETTE_BLOCK_SIZE)); + + setpal_vga256(palData); + if (Winbpp == 2) { + if (!SDL_ECHELLE) { + m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + return DD_VBL(); + } + +LABEL_28: + m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + return DD_VBL(); + } + } +} + +void GraphicsManager::FADE_INS() { + FADESPD = 1; + fade_in(Palette, 1, (const byte *)VESA_BUFFER.pixels); +} + +void GraphicsManager::FADE_OUTS() { + FADESPD = 1; + fade_out(Palette, 1, (const byte *)VESA_BUFFER.pixels); +} + +void GraphicsManager::FADE_INW() { + FADESPD = 15; + fade_in(Palette, 20, (const byte *)VESA_BUFFER.pixels); +} + +void GraphicsManager::FADE_OUTW() { + FADESPD = 15; + fade_out(Palette, 20, (const byte *)VESA_BUFFER.pixels); +} + +void GraphicsManager::setpal_vga256(const byte *palette) { + CHANGE_PALETTE(palette); +} + +void GraphicsManager::CHANGE_PALETTE(const byte *palette) { + signed int v1; + signed int v2; + int v3; + const byte *v4; + + v1 = 0; + do { + PALPCX[v1] = *(byte *)(palette + v1); + ++v1; + } while (v1 < PALETTE_BLOCK_SIZE); + + v2 = 0; + do { + v3 = 3 * v2; + cmap[v3] = *(byte *)(palette + 3 * v2); + v4 = palette + 3 * v2; + cmap[v3 + 1] = *(byte *)(v4 + 1); + cmap[v3 + 2] = *(byte *)(v4 + 2); + + // TODO: Validate pixel encoding is correct + *(uint16 *)&SD_PIXELS[2 * v2++] = + *(byte *)v4 | (*(byte *)(v4 + 1) << 5) | (*(byte *)(v4 + 2) << 10); + } while (v2 < PALETTE_SIZE); + + g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE); +} + +void GraphicsManager::DD_VBL() { + // TODO: Is this okay here? + g_system->updateScreen(); +} + + /*------------------------------------------------------------------------*/ byte *ObjectManager::CHANGE_OBJET(int objIndex) { -- cgit v1.2.3 From e66ce45d0ab44bcc0e0ce10864da5bf0296cf075 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Sep 2012 21:08:54 +1000 Subject: HOPKINS: Further work and bugfixes on palette processing --- engines/hopkins/graphics.cpp | 261 ++++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 138 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7c43d0449f..2fbf12f76a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -33,6 +33,7 @@ namespace Hopkins { GraphicsManager::GraphicsManager() { + _lockCtr = 0; SDL_MODEYES = false; SDL_ECHELLE = 0; XSCREEN = YSCREEN = 0; @@ -54,6 +55,11 @@ GraphicsManager::GraphicsManager() { Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; FADESPD = 15; + + Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); + Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); + Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); + Common::fill(&Palette[0], &Palette[PALETTE_BLOCK_SIZE], 0); } GraphicsManager::~GraphicsManager() { @@ -88,7 +94,8 @@ void GraphicsManager::SET_MODE(int width, int height) { //height = Reel_Zoom(height, SDL_ECHELLE); } - Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0); + //Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); if (bpp == 8) { initGraphics(width, height, true); @@ -105,8 +112,8 @@ void GraphicsManager::SET_MODE(int width, int height) { YSCREEN = height; Linear = true; - Winbpp = bpp; - WinScan = width; + Winbpp = bpp / 8; + WinScan = width * Winbpp; PAL_PIXELS = SD_PIXELS; nbrligne = width; @@ -119,13 +126,16 @@ void GraphicsManager::SET_MODE(int width, int height) { } void GraphicsManager::DD_Lock() { - VideoPtr = g_system->lockScreen(); + if (_lockCtr++ == 0) + VideoPtr = g_system->lockScreen(); } void GraphicsManager::DD_Unlock() { assert(VideoPtr); - g_system->unlockScreen(); - VideoPtr = NULL; + if (--_lockCtr == 0) { + g_system->unlockScreen(); + VideoPtr = NULL; + } } void GraphicsManager::Cls_Video() { @@ -158,7 +168,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { } SCROLL_ECRAN(0); - A_PCXSCREEN_WIDTH_SCREEN_HEIGHT((byte *)VESA_SCREEN.pixels, file, Palette, flag); + A_PCX640_480((byte *)VESA_SCREEN.pixels, file, Palette, flag); SCROLL = 0; OLD_SCROLL = 0; @@ -184,7 +194,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { DD_Unlock(); } else { - SCANLINE(0x500u); + SCANLINE(SCREEN_WIDTH * 2); GLOBALS.max_x = SCREEN_WIDTH * 2; DD_Lock(); Cls_Video(); @@ -212,11 +222,11 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { memcpy((byte *)VESA_BUFFER.pixels, (byte *)VESA_SCREEN.pixels, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } -void GraphicsManager::INIT_TABLE(int a1, int a2, byte *a3) { +void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { for (int idx = 0; idx < 256; ++idx) TABLE_COUL[idx] = idx; - Trans_bloc(TABLE_COUL, a3, 256, a1, a2); + Trans_bloc(TABLE_COUL, palette, 256, a1, a2); for (int idx = 0; idx < 256; ++idx) { byte v = TABLE_COUL[idx]; @@ -295,7 +305,7 @@ void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, } // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder -void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { +void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { int filesize; signed __int16 v6; int v7; @@ -433,28 +443,27 @@ void GraphicsManager::A_PCXSCREEN_WIDTH_SCREEN_HEIGHT(byte *surface, const Commo } if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE)) - error("A_PCXSCREEN_WIDTH_SCREEN_HEIGHT"); + error("A_PCX640_480"); f.close(); GLOBALS.dos_free2(ptr); } void GraphicsManager::Cls_Pal() { - if (Winbpp == 2) { - Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); + Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); + SD_PIXELS[0] = 0; - // TODO: Figure out what this is for - //SD_PIXELS[2 * v0] = SDL_MapRGB(*(_DWORD *)(LinuxScr + 4), 0, 0, 0); + if (Winbpp == 1) { g_system->getPaletteManager()->setPalette(cmap, 0, 256); } } void GraphicsManager::souris_max() { - // Original has no implementatoin + // Original has no implementation } -void GraphicsManager::SCANLINE(int width) { - // Original has no implementatoin +void GraphicsManager::SCANLINE(int pitch) { + nbrligne = nbrligne2 = pitch; } void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { @@ -557,38 +566,30 @@ void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, } while (v9); } +/** + * Copies data from a 8-bit palette surface into the 16-bit screen + */ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *v7; - const byte *v8; - int v9; - int v10; - const byte *v11; - int v12; - const byte *v13; - const byte *v14; + DD_Lock(); assert(VideoPtr); - v7 = xs + nbrligne2 * ys + surface; - v8 = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; - v9 = height; + const byte *srcP = xs + nbrligne2 * ys + surface; + uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destX * 2 + WinScan * destY); - do { - v14 = v8; - v13 = v7; - v10 = width; - v12 = v9; - v11 = PAL_PIXELS; - - do { - *(uint16 *)v8 = *(uint16 *)(v11 + 2 * *(byte *)v7++); - v8 += 2; - --v10; - } while (v10); - - v7 = nbrligne2 + v13; - v8 = WinScan + v14; - v9 = v12 - 1; - } while (v12 != 1); + for (int yp = 0; yp < height; ++yp) { + // Copy over the line, using the source pixels as lookups into the pixels palette + const byte *lineSrcP = srcP; + uint16 *lineDestP = destP; + + for (int xp = 0; xp < width; ++xp) + *lineDestP++ = PAL_PIXELS[*lineSrcP++]; + + // Move to the start of the next line + srcP += nbrligne2; + destP += WinScan / 2; + } + + DD_Unlock(); } void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { @@ -656,80 +657,62 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) { - __int16 v3; - int v4; - __int16 v5; - __int16 v6; - char *v7; - __int16 v8; - char *v9; - __int16 v10; - signed __int16 v12; - unsigned __int16 v13; - byte palData[PALETTE_BLOCK_SIZE]; - byte v15[3]; - __int16 v16; - char v17[2]; - char v18[1532]; + uint16 palData1[PALETTE_BLOCK_SIZE * 2]; + byte palData2[PALETTE_BLOCK_SIZE]; - v13 = FADESPD; - v3 = 0; - do { - v4 = v3; - *(&v16 + v4) = 0; - palData[v4] = 0; - ++v3; - } while (v3 < (PALETTE_BLOCK_SIZE)); - - setpal_vga256(palData); - v12 = 0; - - if ((signed __int16)v13 > 0) { - do { - v5 = 0; - do { - if ((unsigned __int8)palData[v5] < *(byte *)(v5 + palette)) { - v6 = *(&v16 + v5) + ((unsigned int)*(byte *)(v5 + palette) << 8) / (signed __int16)v13; - *(&v16 + v5) = v6; - palData[v5] = (v6 >> 8) & 0xff; - } + // Initialise temporary palettes + Common::fill(&palData1[0], &palData1[PALETTE_BLOCK_SIZE], 0); + Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0); - if (v15[v5] < *(byte *)(palette + v5 + 1)) { - v7 = &v17[2 * v5]; - v8 = *(uint16 *)v7 + ((unsigned int)*(byte *)(palette + v5 + 1) << 8) / (signed __int16)v13; - *(uint16 *)v7 = v8; - v15[v5] = (v8 >> 8) & 0xff; - } + // Set current palette to black + setpal_vga256(palData2); + + // Loop through fading in the palette + uint16 *pTemp1 = &palData1[2]; + for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) { + uint16 *pTemp2 = &palData1[4]; + + for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { + if (palData2[palOffset] < palette[palOffset]) { + uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD; + palData1[palOffset] = v; + palData2[palOffset] = (v >> 8) & 0xff; + } - if (v15[v5 + 1] < *(byte *)(palette + v5 + 2)) { - v9 = &v18[2 * v5]; - v10 = *(uint16 *)v9 + ((unsigned int)*(byte *)(palette + v5 + 2) << 8) / (signed __int16)v13; - *(uint16 *)v9 = v10; - v15[v5 + 1] = (v10 >> 8) & 0xff; - } + if (palData2[palOffset + 1] < palette[palOffset + 1]) { + uint16 *pDest = &pTemp1[palOffset]; + uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; + *pDest = v; + palData2[palOffset + 1] = (v >> 8) & 0xff; + } - v5 += 3; - } while (v5 < (PALETTE_BLOCK_SIZE)); - - setpal_vga256(palData); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); - else - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); - DD_VBL(); + if (palData2[palOffset + 1] < palette[palOffset + 1]) { + uint16 *pDest = &pTemp2[palOffset]; + uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; + *pDest = v; + palData2[palOffset + 1] = (v >> 8) & 0xff; } + } - ++v12; - } while (v12 < (signed __int16)v13); + setpal_vga256(palData2); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); + } } + // Set the final palette setpal_vga256(palette); + + // Refresh the screen if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } } @@ -762,9 +745,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -783,9 +766,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -802,7 +785,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } goto LABEL_28; @@ -816,12 +799,12 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } LABEL_28: - m_scroll16A(surface, start_x, 0, 640, 480, 0, 0); + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } } @@ -852,31 +835,33 @@ void GraphicsManager::setpal_vga256(const byte *palette) { } void GraphicsManager::CHANGE_PALETTE(const byte *palette) { - signed int v1; - signed int v2; - int v3; - const byte *v4; + // Copy the palette into the PALPCX block +// TODO: Likely either one or both of the destination arrays can be removed, +// since PALPCX is only used in SAVE_IMAGE, and cmap in the original was a RGBA +// array specifically intended just for passing to the SDL palette setter + Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &PALPCX[0]); + Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &cmap[0]); + + const byte *srcP = &palette[0]; + for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { + // TODO: Validate pixel encoding is correct + *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); + } - v1 = 0; - do { - PALPCX[v1] = *(byte *)(palette + v1); - ++v1; - } while (v1 < PALETTE_BLOCK_SIZE); - - v2 = 0; - do { - v3 = 3 * v2; - cmap[v3] = *(byte *)(palette + 3 * v2); - v4 = palette + 3 * v2; - cmap[v3 + 1] = *(byte *)(v4 + 1); - cmap[v3 + 2] = *(byte *)(v4 + 2); + if (Winbpp == 1) + g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE); +} - // TODO: Validate pixel encoding is correct - *(uint16 *)&SD_PIXELS[2 * v2++] = - *(byte *)v4 | (*(byte *)(v4 + 1) << 5) | (*(byte *)(v4 + 2) << 10); - } while (v2 < PALETTE_SIZE); +uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) { + if (Winbpp == 1) { + error("TODO: Support in 8-bit graphics mode"); + } else { + Graphics::PixelFormat format = g_system->getScreenFormat(); - g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE); + return (r >> format.rLoss) << format.rShift + | (g >> format.gLoss) << format.gShift + | (b >> format.bLoss) << format.bShift; + } } void GraphicsManager::DD_VBL() { -- cgit v1.2.3 From ec4c7a8baf5f276914c287f1f777e5f27d98eb0e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Sep 2012 22:55:50 +1000 Subject: HOPKINS: Fix blitting 8-bit images to the screen --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2fbf12f76a..d326598e56 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -582,7 +582,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, uint16 *lineDestP = destP; for (int xp = 0; xp < width; ++xp) - *lineDestP++ = PAL_PIXELS[*lineSrcP++]; + *lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2]; // Move to the start of the next line srcP += nbrligne2; -- cgit v1.2.3 From f1fce64994e687aada097f6293776108bdedcd68 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Sep 2012 10:27:15 +1000 Subject: HOPKINS: Initial implementation of main animation player method --- engines/hopkins/graphics.cpp | 59 +++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d326598e56..9e878cc822 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -55,6 +55,8 @@ GraphicsManager::GraphicsManager() { Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; FADESPD = 15; + FADE_LINUX = 0; + NOLOCK = false; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -63,8 +65,8 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { - VESA_SCREEN.free(); - VESA_BUFFER.free(); + GLOBALS.dos_free2(VESA_SCREEN); + GLOBALS.dos_free2(VESA_BUFFER); } void GraphicsManager::SET_MODE(int width, int height) { @@ -104,8 +106,8 @@ void GraphicsManager::SET_MODE(int width, int height) { } // Init surfaces - VESA_SCREEN.create(SCREEN_WIDTH, SCREEN_HEIGHT, pixelFormat16); - VESA_BUFFER.create(SCREEN_WIDTH, SCREEN_HEIGHT, pixelFormat16); + VESA_SCREEN = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + VESA_BUFFER = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); VideoPtr = NULL; XSCREEN = width; @@ -126,8 +128,10 @@ void GraphicsManager::SET_MODE(int width, int height) { } void GraphicsManager::DD_Lock() { - if (_lockCtr++ == 0) - VideoPtr = g_system->lockScreen(); + if (!NOLOCK) { + if (_lockCtr++ == 0) + VideoPtr = g_system->lockScreen(); + } } void GraphicsManager::DD_Unlock() { @@ -168,7 +172,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { } SCROLL_ECRAN(0); - A_PCX640_480((byte *)VESA_SCREEN.pixels, file, Palette, flag); + A_PCX640_480((byte *)VESA_SCREEN, file, Palette, flag); SCROLL = 0; OLD_SCROLL = 0; @@ -182,14 +186,14 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { Cls_Video(); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } else if (Winbpp == 1) { if (!SDL_ECHELLE) - m_scroll2((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll2A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); @@ -204,22 +208,22 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { DD_Lock(); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } if (Winbpp == 1) { if (!SDL_ECHELLE) - m_scroll2((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll2A((byte *)VESA_SCREEN.pixels, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); } } - memcpy((byte *)VESA_BUFFER.pixels, (byte *)VESA_SCREEN.pixels, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy((byte *)VESA_BUFFER, (byte *)VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { @@ -812,22 +816,22 @@ LABEL_28: void GraphicsManager::FADE_INS() { FADESPD = 1; - fade_in(Palette, 1, (const byte *)VESA_BUFFER.pixels); + fade_in(Palette, 1, (const byte *)VESA_BUFFER); } void GraphicsManager::FADE_OUTS() { FADESPD = 1; - fade_out(Palette, 1, (const byte *)VESA_BUFFER.pixels); + fade_out(Palette, 1, (const byte *)VESA_BUFFER); } void GraphicsManager::FADE_INW() { FADESPD = 15; - fade_in(Palette, 20, (const byte *)VESA_BUFFER.pixels); + fade_in(Palette, 20, (const byte *)VESA_BUFFER); } void GraphicsManager::FADE_OUTW() { FADESPD = 15; - fade_out(Palette, 20, (const byte *)VESA_BUFFER.pixels); + fade_out(Palette, 20, (const byte *)VESA_BUFFER); } void GraphicsManager::setpal_vga256(const byte *palette) { @@ -869,6 +873,21 @@ void GraphicsManager::DD_VBL() { g_system->updateScreen(); } +void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { + warning("TODO: FADE_OUTW_LINUX"); +} + +void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSurface) { + warning("TODO: Copy_WinScan_Vbe3"); +} + +void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { + warning("TODO: Copy_Video_Vbe3"); +} + +void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { + warning("TODO: Copy_Video_Vbe3"); +} /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From d007e0aafe7932899cdf87d6007bf10ebed1cad6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Sep 2012 13:23:46 +1000 Subject: HOPKINS: initial implementation of INTORUN method --- engines/hopkins/graphics.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9e878cc822..26907c235e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -57,6 +57,7 @@ GraphicsManager::GraphicsManager() { FADESPD = 15; FADE_LINUX = 0; NOLOCK = false; + no_scroll = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -838,6 +839,17 @@ void GraphicsManager::setpal_vga256(const byte *palette) { CHANGE_PALETTE(palette); } +void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { + warning("TODO: setpal_vga256_linux"); +} + +void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { + int offset = palIndex * 3; + Palette[offset] = 255 * r / 100; + Palette[offset + 1] = 255 * g / 100; + Palette[offset + 2] = 255 * b / 100; +} + void GraphicsManager::CHANGE_PALETTE(const byte *palette) { // Copy the palette into the PALPCX block // TODO: Likely either one or both of the destination arrays can be removed, @@ -889,6 +901,14 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { warning("TODO: Copy_Video_Vbe3"); } +void GraphicsManager::FIN_VISU() { + warning("TODO: FIN_VISU"); +} + +void GraphicsManager::VISU_ALL() { + warning("TODO: VISU_ALL"); +} + /*------------------------------------------------------------------------*/ byte *ObjectManager::CHANGE_OBJET(int objIndex) { -- cgit v1.2.3 From e02e950a40a5abbef9f53569d99b66af6dc30345 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Sep 2012 21:42:20 +1000 Subject: HOPKINS: Implemented Vbe decoding so introduction now runs --- engines/hopkins/graphics.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 26907c235e..b02a81123f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -898,7 +898,63 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { } void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { - warning("TODO: Copy_Video_Vbe3"); + const byte *srcP = surface; + int destOffset = 0; + assert(VideoPtr); + + for (;;) { + byte srcByte = *srcP; + if (srcByte >= 222) { + if (srcByte == 252) + return; + if (srcByte < 251) { + destOffset += srcByte - 221; + srcByte = *++srcP; + } else if (srcByte == 253) { + destOffset += *(const byte *)(srcP + 1); + srcByte = *(const byte *)(srcP + 2); + srcP += 2; + } else if (srcByte == 254) { + destOffset += READ_LE_UINT16(srcP + 1); + srcByte = *(const byte *)(srcP + 3); + srcP += 3; + } else { + destOffset += READ_LE_UINT32(srcP + 1); + srcByte = *(const byte *)(srcP + 5); + srcP += 5; + } + } + + if (srcByte > 210) { + if (srcByte == 211) { + int pixelCount = *(srcP + 1); + int pixelIndex = *(srcP + 2); + uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2); + uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); + destOffset += pixelCount; + + while (pixelCount--) + *destP++ = pixelValue; + + srcP += 3; + } else { + int pixelCount = srcByte - 211; + int pixelIndex = *(srcP + 1); + uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2); + uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); + destOffset += pixelCount; + + while (pixelCount--) + *destP++ = pixelValue; + + srcP += 2; + } + } else { + *((uint16 *)VideoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte); + ++srcP; + ++destOffset; + } + } } void GraphicsManager::FIN_VISU() { -- cgit v1.2.3 From 0b610c45dff6b715f1f5e3e5161619dc57d19061 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Sep 2012 16:53:21 +1000 Subject: HOPKINS: Implemented rest of main method, with stubs for sub-method calls --- engines/hopkins/graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b02a81123f..f183adee41 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -965,6 +965,10 @@ void GraphicsManager::VISU_ALL() { warning("TODO: VISU_ALL"); } +void GraphicsManager::RESET_SEGMENT_VESA() { + warning("TODO: RESET_SEGMENT_VESA"); +} + /*------------------------------------------------------------------------*/ byte *ObjectManager::CHANGE_OBJET(int objIndex) { -- cgit v1.2.3 From df410953c98ff5ca4a3ef9626d0ae680186378ac Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Sep 2012 18:03:25 +1000 Subject: HOPKINS: Initial implementation of main menu method --- engines/hopkins/graphics.cpp | 134 ------------------------------------------- 1 file changed, 134 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f183adee41..72fbd0319b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -969,138 +969,4 @@ void GraphicsManager::RESET_SEGMENT_VESA() { warning("TODO: RESET_SEGMENT_VESA"); } -/*------------------------------------------------------------------------*/ - -byte *ObjectManager::CHANGE_OBJET(int objIndex) { - byte *result = ObjectManager::CAPTURE_OBJET(objIndex, 1); - GLOBALS.Bufferobjet = result; - GLOBALS.Nouv_objet = 1; - GLOBALS.OBJET_EN_COURS = objIndex; - return result; -} - -byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) { - byte *result = NULL; - byte *dataP; - - dataP = 0; - int val1 = GLOBALS.ObjetW[objIndex].field0; - int val2 = GLOBALS.ObjetW[objIndex].field1; - - if (mode == 1) - ++val2; - if (val1 != GLOBALS.NUM_FICHIER_OBJ) { - if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) - ObjectManager::DEL_FICHIER_OBJ(); - if (val1 == 1) { - FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR"); - GLOBALS.ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(GLOBALS.NFICHIER); - } - GLOBALS.NUM_FICHIER_OBJ = val1; - } - - int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, val2); - int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, val2); - GLOBALS.OBJL = width; - GLOBALS.OBJH = height; - - switch (mode) { - case 0: - dataP = GLOBALS.dos_malloc2(height * width); - if (dataP == PTRNUL) - error("CAPTURE_OBJET"); - - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, val2); - break; - - case 1: - ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, val2); - result = GLOBALS.Bufferobjet; - break; - - case 3: - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, val2); - result = GLOBALS.INVENTAIRE_OBJET; - break; - - default: - result = dataP; - break; - } - - return result; -} - -int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) - objP += READ_LE_UINT32(objP) + 16; - - return READ_LE_UINT16(objP + 4); -} - -int ObjectManager::Get_Hauteur(const byte *objectData, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) - objP += READ_LE_UINT32(objP) + 16; - - return READ_LE_UINT16(objP + 6); -} - -int ObjectManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) { - objP += READ_LE_UINT32(objP) + 16; - } - - objP += 4; - int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); - - memcpy(sprite + 3, objP - 4, result + 16); - return result; -} - -byte *ObjectManager::DEL_FICHIER_OBJ() { - GLOBALS.NUM_FICHIER_OBJ = 0; - if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) - GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ); - - byte *result = PTRNUL; - GLOBALS.ADR_FICHIER_OBJ = PTRNUL; - return result; -} - -byte *ObjectManager::CHARGE_SPRITE(const Common::String &file) { - FileManager::DMESS1(); - return FileManager::CHARGE_FICHIER(file); -} - -int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) { - objP += READ_LE_UINT32(objP) + 16; - } - - objP += 4; - int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); - - memcpy(sprite, objP + 12, result); - return result; -} - -int ObjectManager::AJOUTE_OBJET(int objIndex) { - bool flag = false; - int arrIndex = 0; - do { - ++arrIndex; - if (!GLOBALS.INVENTAIRE[arrIndex]) - flag = true; - if (arrIndex == 32) - flag = true; - } while (!flag); - - GLOBALS.INVENTAIRE[arrIndex] = objIndex; - return arrIndex; -} - } // End of namespace Hopkins -- cgit v1.2.3 From 9900adf18cd88196c949ccbc3033bea5ef58d975 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Sep 2012 21:34:23 +1000 Subject: HOPKINS: Initial implementation of some code that will be needed for cursor display --- engines/hopkins/graphics.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 72fbd0319b..a1a5206fe3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -58,6 +58,7 @@ GraphicsManager::GraphicsManager() { FADE_LINUX = 0; NOLOCK = false; no_scroll = 0; + REDRAW = false; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -70,6 +71,10 @@ GraphicsManager::~GraphicsManager() { GLOBALS.dos_free2(VESA_BUFFER); } +void GraphicsManager::setParent(HopkinsEngine *vm) { + _vm = vm; +} + void GraphicsManager::SET_MODE(int width, int height) { if (!SDL_MODEYES) { SDL_ECHELLE = 0; @@ -182,7 +187,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (!DOUBLE_ECRAN) { souris_max(); SCANLINE(SCREEN_WIDTH); - GLOBALS.max_x = SCREEN_WIDTH; + _vm->_eventsManager.max_x = SCREEN_WIDTH; DD_Lock(); Cls_Video(); if (Winbpp == 2) { @@ -200,7 +205,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { DD_Unlock(); } else { SCANLINE(SCREEN_WIDTH * 2); - GLOBALS.max_x = SCREEN_WIDTH * 2; + _vm->_eventsManager.max_x = SCREEN_WIDTH * 2; DD_Lock(); Cls_Video(); DD_Unlock(); @@ -957,6 +962,14 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { } } +void GraphicsManager::Capture_Mem(byte *a1, void *a2, int a3, int a4, unsigned int a5, int a6) { + warning("TODO: Capture_Mem"); +} + +void GraphicsManager::Sprite_Vesa(byte *a1, byte *a2, int a3, int a4, int a5) { + warning("TODO: Sprite_Vesa"); +} + void GraphicsManager::FIN_VISU() { warning("TODO: FIN_VISU"); } @@ -969,4 +982,46 @@ void GraphicsManager::RESET_SEGMENT_VESA() { warning("TODO: RESET_SEGMENT_VESA"); } +void GraphicsManager::Ajoute_Segment_Vesa(int a1, int a2, int a3, int a4) { + warning("TODO: Ajoute_Segment_Vesa"); +} + +int GraphicsManager::Magic_Number(signed int v) { + int result = v; + + if (!v) + result = 4; + if (result & 1) + ++result; + if (result & 2) + result += 2; + + return result; +} + +void GraphicsManager::Affiche_Segment_Vesa() { + warning("TODO: Affiche_Segment_Vesa"); +} + +void GraphicsManager::CopyAsm(const byte *surface) { + warning("TODO: CopyAsm"); +} + +void GraphicsManager::Restore_Mem(const byte *a1, const byte *a2, int a3, int a4, unsigned int a5, int a6) { + warning("TODO: Restore_Mem"); +} + +int GraphicsManager::Reel_Zoom(int a1, int a2) { + warning("TODO: Reel_Zoom"); + return 0; +} + +void GraphicsManager::AFF_SPRITES() { + warning("TODO: AFF_SPRITES"); +} + +void GraphicsManager::Affiche_Perfect(const byte *a1, const byte *a2, int a3, int a4, int a5, int a6, int a7, int a8) { + warning("TODO: Affice_Perfect"); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 06f83a0775b79b06dbb38bc11c3622122b9ccc3e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Sep 2012 20:54:03 +1000 Subject: HOPKINS: Implemented more blitting/display methods --- engines/hopkins/graphics.cpp | 456 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 427 insertions(+), 29 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a1a5206fe3..23ea17813e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -59,6 +59,13 @@ GraphicsManager::GraphicsManager() { NOLOCK = false; no_scroll = 0; REDRAW = false; + min_x = 0; + min_y = 20; + max_x = SCREEN_WIDTH * 2; + max_y = SCREEN_HEIGHT - 20 * 2; + clip_x = clip_y = 0; + clip_x1 = clip_y1 = 0; + clip_flag = false; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -97,9 +104,8 @@ void GraphicsManager::SET_MODE(int width, int height) { bpp = 16; if (SDL_ECHELLE) { - error("TODO: Implement zooming support"); - //width = Reel_Zoom(width, SDL_ECHELLE); - //height = Reel_Zoom(height, SDL_ECHELLE); + width = Reel_Zoom(width, SDL_ECHELLE); + height = Reel_Zoom(height, SDL_ECHELLE); } //Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0); @@ -187,25 +193,25 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (!DOUBLE_ECRAN) { souris_max(); SCANLINE(SCREEN_WIDTH); - _vm->_eventsManager.max_x = SCREEN_WIDTH; + _vm->_graphicsManager.max_x = SCREEN_WIDTH; DD_Lock(); Cls_Video(); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } else if (Winbpp == 1) { if (!SDL_ECHELLE) - m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); } else { SCANLINE(SCREEN_WIDTH * 2); - _vm->_eventsManager.max_x = SCREEN_WIDTH * 2; + _vm->_graphicsManager.max_x = SCREEN_WIDTH * 2; DD_Lock(); Cls_Video(); DD_Unlock(); @@ -214,22 +220,22 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { DD_Lock(); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } if (Winbpp == 1) { if (!SDL_ECHELLE) - m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); } } - memcpy((byte *)VESA_BUFFER, (byte *)VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(VESA_BUFFER, VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { @@ -737,7 +743,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac __int16 v9; __int16 v10; __int16 v12; - unsigned __int16 v13; + uint16 v13; byte palData[PALETTE_BLOCK_SIZE]; __int16 v15[PALETTE_BLOCK_SIZE]; @@ -845,7 +851,16 @@ void GraphicsManager::setpal_vga256(const byte *palette) { } void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { - warning("TODO: setpal_vga256_linux"); + CHANGE_PALETTE(palette); + + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + + DD_VBL(); + } } void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { @@ -865,7 +880,6 @@ void GraphicsManager::CHANGE_PALETTE(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - // TODO: Validate pixel encoding is correct *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); } @@ -891,15 +905,152 @@ void GraphicsManager::DD_VBL() { } void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { - warning("TODO: FADE_OUTW_LINUX"); + fade_out(Palette, FADESPD, surface); +} + +void GraphicsManager::FADE_INW_LINUX(const byte *surface) { + return fade_in(Palette, FADESPD, surface); } void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSurface) { - warning("TODO: Copy_WinScan_Vbe3"); + int result; + int v3; + int v4; + const byte *v5; + uint8 v6; + int v7; + unsigned int v8; + byte *v9; + int v10; + unsigned int v11; + byte *v12; + + result = 0; + v3 = 0; + v4 = 0; + v5 = sourceSurface; + for (;;) { + v6 = *v5; + if (*(byte *)v5 < 222) + goto Video_Cont3_wVbe; + + if (v6 == 252) + return; + + if (v6 < 251) { + v3 += (unsigned __int8)(*(byte *)v5 + 35); + v6 = *(v5++ + 1); + } else if (v6 == 253) { + v3 += *(v5 + 1); + v6 = *(v5 + 2); + v5 += 2; + } else if (v6 == 254) { + v3 += READ_LE_UINT16(v5 + 1); + v6 = *(v5 + 3); + v5 += 3; + } else { + v3 += READ_LE_UINT32(v5 + 1); + v6 = *(v5 + 5); + v5 += 5; + } + +Video_Cont3_wVbe: + if (v6 > 210) { + if (v6 == 211) { + v7 = v4; + v8 = *(v5 + 1); + result = *(v5 + 2); + v9 = v3 + destSurface; + v3 += v8; + memset(v9, result, v8); + v5 += 3; + v4 = v7; + } else { + v10 = v4; + v11 = *v5 + 45; + result = *(v5 + 1); + v12 = v3 + destSurface; + v3 += v11; + memset(v12, result, v11); + v5 += 2; + v4 = v10; + } + } else { + *(v3 + destSurface) = v6; + ++v5; + ++v3; + } + } } void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { - warning("TODO: Copy_Video_Vbe3"); + int result; // eax@1 + int v2; // ebx@1 + int v3; // ecx@1 + const byte *v4; // esi@1 + uint8 v5; // dl@2 + int v6; // ST00_4@9 + unsigned int v7; // ecx@9 + byte *v8; // edi@9 + int v9; // ST00_4@10 + unsigned int v10; // ecx@10 + byte *v11; // edi@10 + + assert(VideoPtr); + result = 0; + v2 = 0; + v3 = 0; + v4 = surface; + for (;;) { + v5 = *v4; + if (*v4 < 222) + goto Video_Cont3_Vbe; + + if (v5 == 252) + return; + if (v5 < 251) { + v2 += (unsigned __int8)(*v4 + 35); + v5 = *(v4++ + 1); + } else if (v5 == -3) { + v2 += *(v4 + 1); + v5 = *(v4 + 2); + v4 += 2; + } else if (v5 == -2) { + v2 += READ_LE_UINT16(v4 + 1); + v5 = *(v4 + 3); + v4 += 3; + } else { + v2 += READ_LE_UINT32(v4 + 1); + v5 = *(v4 + 5); + v4 += 5; + } +Video_Cont3_Vbe: + if (v5 > 210) { + if (v5 == 211) { + v6 = v3; + v7 = *(v4 + 1); + result = *(v4 + 2); + v8 = v2 + (byte *)VideoPtr->pixels; + v2 += v7; + memset(v8, result, v7); + v4 += 3; + v3 = v6; + } else { + v9 = v3; + v10 = (unsigned __int8)(*v4 + 45); + result = *(v4 + 1); + v11 = (byte *)(v2 + (byte *)VideoPtr->pixels); + v2 += v10; + memset(v11, result, v10); + v4 += 2; + v3 = v9; + } + } else { + *(v2 + (byte *)VideoPtr->pixels) = v5; + ++v4; + ++v2; + } + } } void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { @@ -962,12 +1113,187 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { } } -void GraphicsManager::Capture_Mem(byte *a1, void *a2, int a3, int a4, unsigned int a5, int a6) { - warning("TODO: Capture_Mem"); +void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, unsigned int width, int height) { + const byte *srcP; + byte *destP; + int yCtr; + unsigned int i; + int yTemp; + + srcP = srcSurface + xs + nbrligne2 * ys; + destP = destSurface; + + yCtr = height; + do { + yTemp = yCtr; + if (width & 1) { + memcpy(destP, srcP, width); + srcP += width; + destP += width; + } else if (width & 2) { + for (i = width >> 1; i; --i) { + *(uint16 *)destP = *(uint16 *)srcP; + srcP += 2; + destP = (byte *)destP + 2; + } + } else { + memcpy(destP, srcP, 4 * (width >> 2)); + srcP += 4 * (width >> 2); + destP = (byte *)destP + 4 * (width >> 2); + } + srcP = nbrligne2 + srcP - width; + yCtr = yTemp - 1; + } while (yTemp != 1); } void GraphicsManager::Sprite_Vesa(byte *a1, byte *a2, int a3, int a4, int a5) { - warning("TODO: Sprite_Vesa"); + byte *v5; + int i; + byte *v7; + uint16 v8; + byte *v9; + int v10; + uint16 v11; + uint16 v12; + uint16 v13; + uint16 v14; + byte *v15; + byte *v16; + const byte *v17; + byte *v18; + int v19; + byte *v20; + byte *v21; + int v22; + unsigned int v23; + byte *v24; + const byte *v25; + byte *v26; + byte *v27; + byte *v28; + byte *v29; + int v30; + int v31; + + v5 = a2 + 3; + for (i = a5; i; --i) + v5 += READ_LE_UINT32(v5) + 16; + v10 = 0; + v7 = v5 + 4; + v8 = READ_LE_UINT16(v7); + v9 = v7 + 2; + v10 = READ_LE_UINT16(v9); + clip_x = 0; + clip_y = 0; + clip_flag = false; + clip_x1 = v8; + if ((uint16)(v8 + a3) > v8) { + if ((uint16)a3 < (uint16)(min_x + 300)) { + clip_x = min_x + 300 - a3; + clip_flag = true; + } + if ((uint16)(v10 + (uint16)a4) > (uint16)v10) { + if ((uint16)a4 < (uint16)(min_y + 300)) { + clip_y = min_y + 300 - a4; + clip_flag = true; + } + v11 = max_x + 300; + if ((uint16)a3 < (uint16)(max_x + 300)) { + if ((uint16)(v8 + a3) > v11) { + v12 = v8 + 10 - (v8 + a3 - v11); + if (v12 <= 10) + return; + clip_x1 = v12 - 10; + clip_flag = true; + } + v13 = max_y + 300; + if ((uint16)a4 < (uint16)(max_y + 300)) { + if ((uint16)(v10 + (uint16)a4) > v13) { + v14 = v10 + 10 - (v10 + (uint16)a4 - v13); + if (v14 <= 10) + return; + v10 -= 10; + clip_y1 = v10; + clip_flag = true; + } + v15 = v9 + 6; + v16 = v15 + 4; + v17 = READ_LE_UINT32(v15) + v15 + 4; + v18 = a3 + nbrligne2 * (a4 - 300) - 300 + a1; + v19 = 0; + if (clip_flag) { + do { + v31 = v10; + v29 = v18; + v19 = 0; + while (*v16 != -3) { + if (*v16 == -2) { + v27 = v16 + 1; + v10 = READ_LE_UINT16(v27); + + do { + if (!clip_y && (uint16)v19 >= clip_x && (uint16)v19 < clip_x1) + *v18 = *v17; + ++v17; + ++v18; + ++v19; + --v10; + } while (v10); + + v16 = v27 + 2; + } else { + v26 = v16 + 1; + v10 = *(uint16 *)v26; + v18 += v10; + v19 += v10; + v16 = v26 + 2; + } + } + + if (clip_y) + --clip_y; + v16 += 3; + v18 = nbrligne2 + v29; + v10 = v31 - 1; + } while (v31 != 1); + } else { + do { + v30 = v10; + v28 = v18; + while (*v16 != -3) { + if (*v16 == -2) { + v21 = v16 + 1; + v10 = READ_LE_UINT16(v21); + + v22 = v10; + v23 = (unsigned int)v10 >> 2; + memcpy(v18, v17, 4 * v23); + v25 = (v17 + 4 * v23); + v24 = (v18 + 4 * v23); + v10 = v22 - 4 * v23; + memcpy(v24, v25, v10); + + v17 = v25 + v10; + v18 = v24 + v10; + v10 = 0; + v16 = v21 + 2; + } else { + v20 = v16 + 1; + v10 = READ_LE_UINT16(v20); + v18 += v10; + v16 = v20 + 2; + } + } + + v16 += 3; + v18 = nbrligne2 + v28; + v10 = v30 - 1; + } while (v30 != 1); + } + } + } + } + } } void GraphicsManager::FIN_VISU() { @@ -1004,16 +1330,88 @@ void GraphicsManager::Affiche_Segment_Vesa() { } void GraphicsManager::CopyAsm(const byte *surface) { - warning("TODO: CopyAsm"); + const byte *v1; + byte srcByte; + byte *v3; + signed int v4; + signed int v5; + byte *v6; + byte *v7; + byte *v8; + byte *v9; + const byte *v10; + + assert(VideoPtr); + v1 = surface; + srcByte = 30 * WinScan; + v3 = (byte *)VideoPtr->pixels + 30 * WinScan; + v4 = 200; + do { + v10 = v1; + v9 = v3; + v5 = 320; + + do { + srcByte = *(byte *)v1; + *(byte *)v3 = *(byte *)v1; + v6 = WinScan + v3; + *(byte *)v6 = srcByte; + v7 = v6 - WinScan + 1; + *(byte *)v7 = srcByte; + v8 = WinScan + v7; + *(byte *)v8 = srcByte; + v3 = v8 - WinScan + 1; + ++v1; + --v5; + } while (v5); + + v1 = v10 + 320; + v3 = WinScan + WinScan + v9; + --v4; + } while (v4); +} + +void GraphicsManager::Restore_Mem(byte *a1, const byte *a2, int a3, int a4, unsigned int a5, int a6) { + byte *v6; + int v7; + const byte *v8; + unsigned int i; + int v10; + + v6 = a3 + nbrligne2 * a4 + a1; + v7 = a6; + v8 = a2; + do { + v10 = v7; + if (a5 & 1) { + memcpy(v6, v8, a5); + v8 += a5; + v6 += a5; + } else if (a5 & 2) { + for (i = a5 >> 1; i; --i) { + *(uint16 *)v6 = *(uint16 *)v8; + v8 += 2; + v6 += 2; + } + } else { + memcpy(v6, v8, 4 * (a5 >> 2)); + v8 += 4 * (a5 >> 2); + v6 += 4 * (a5 >> 2); + } + v6 = nbrligne2 + v6 - a5; + v7 = v10 - 1; + } while (v10 != 1); } -void GraphicsManager::Restore_Mem(const byte *a1, const byte *a2, int a3, int a4, unsigned int a5, int a6) { - warning("TODO: Restore_Mem"); +int GraphicsManager::Reel_Zoom(int v, int percentage) { + return Asm_Zoom(v, percentage); } -int GraphicsManager::Reel_Zoom(int a1, int a2) { - warning("TODO: Reel_Zoom"); - return 0; +int GraphicsManager::Asm_Zoom(int v, int percentage) { + if (v) + v += percentage * (long int)v / 100; + + return v; } void GraphicsManager::AFF_SPRITES() { -- cgit v1.2.3 From 3d917112c99ddff23f58a959342b5c95b8d52f9d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Sep 2012 22:02:55 +1000 Subject: HOPKINS: Implemented some BOB methods --- engines/hopkins/graphics.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 23ea17813e..a537ea1db9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1297,11 +1297,33 @@ void GraphicsManager::Sprite_Vesa(byte *a1, byte *a2, int a3, int a4, int a5) { } void GraphicsManager::FIN_VISU() { - warning("TODO: FIN_VISU"); + for (int idx = 1; idx <= 20; ++idx) { + if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + _vm->_objectsManager.BOB_OFF(idx); + } + + _vm->_eventsManager.VBL(); + _vm->_eventsManager.VBL(); + + for (int idx = 1; idx <= 20; ++idx) { + if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + _vm->_objectsManager.BOB_ZERO(idx); + } + + for (int idx = 1; idx <= 29; ++idx) { + _vm->_globals.BL_ANIM[idx].v1 = 0; + } + + for (int idx = 1; idx <= 20; ++idx) { + _vm->_globals.Bqe_Anim[idx].field4 = 0; + } } void GraphicsManager::VISU_ALL() { - warning("TODO: VISU_ALL"); + for (int idx = 1; idx <= 20; ++idx) { + if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + _vm->_objectsManager.BOB_VISU(idx); + } } void GraphicsManager::RESET_SEGMENT_VESA() { -- cgit v1.2.3 From 0ef0ff60993533c58ffec0c02d8c1742b92cc914 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Sep 2012 22:23:07 +1000 Subject: HOPKINS: Implemented some more blitting methods --- engines/hopkins/graphics.cpp | 79 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 14 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a537ea1db9..3785b6ff45 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -984,17 +984,17 @@ Video_Cont3_wVbe: } void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { - int result; // eax@1 - int v2; // ebx@1 - int v3; // ecx@1 - const byte *v4; // esi@1 - uint8 v5; // dl@2 - int v6; // ST00_4@9 - unsigned int v7; // ecx@9 - byte *v8; // edi@9 - int v9; // ST00_4@10 - unsigned int v10; // ecx@10 - byte *v11; // edi@10 + int result; + int v2; + int v3; + const byte *v4; + uint8 v5; + int v6; + unsigned int v7; + byte *v8; + int v9; + unsigned int v10; + byte *v11; assert(VideoPtr); result = 0; @@ -1327,11 +1327,62 @@ void GraphicsManager::VISU_ALL() { } void GraphicsManager::RESET_SEGMENT_VESA() { - warning("TODO: RESET_SEGMENT_VESA"); + int v1; + int v2; + + if (_vm->_globals.NBBLOC > 0) { + v1 = 0; + v2 = _vm->_globals.NBBLOC; + do { + _vm->_globals.BLOC[v1++].field0 = 0; + } while (v1 != v2); + + _vm->_globals.NBBLOC = 0; + } } -void GraphicsManager::Ajoute_Segment_Vesa(int a1, int a2, int a3, int a4) { - warning("TODO: Ajoute_Segment_Vesa"); +void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { + int v4; + int v5; + int16 v6; + int16 v10; + + v4 = x1; + v10 = 1; + if (x2 > max_x) + x2 = max_x; + if (y2 > max_y) + y2 = max_y; + if (x1 < min_x) + v4 = min_x; + if (y1 < min_y) + y1 = min_y; + + v5 = _vm->_globals.NBBLOC; + if (_vm->_globals.NBBLOC > 1) { + + v6 = 0; + do { + BlocItem &bloc = _vm->_globals.BLOC[v6]; + + if (bloc.field0 == 1 + && v4 >= bloc.x1 && x2 <= bloc.x2 + && y1 >= bloc.y1 && y2 <= bloc.y2) + v10 = 0; + ++v6; + v5 = v6; + } while (_vm->_globals.NBBLOC + 1 != v6); + } + + if (v10 == 1) { + BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; + + bloc.field0 = 1; + bloc.x1 = v4; + bloc.x2 = x2; + bloc.y1 = y1; + bloc.y2 = y2; + } } int GraphicsManager::Magic_Number(signed int v) { -- cgit v1.2.3 From 391e3da119b7cf7be8a9422e8fe390a2b5e55398 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Sep 2012 23:30:28 +1000 Subject: HOPKINS: Implemented Affiche_Segment_Vesa and support methods --- engines/hopkins/graphics.cpp | 168 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3785b6ff45..1a22ff42ce 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -66,6 +66,7 @@ GraphicsManager::GraphicsManager() { clip_x = clip_y = 0; clip_x1 = clip_y1 = 0; clip_flag = false; + SDL_NBLOCS = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -672,6 +673,99 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } while (v13 != 1); } +void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { + const byte *v7; + byte *v8; + int v9; + int v10; + byte v11; + byte *v12; + byte *v13; + byte *v14; + byte *v15; + const byte *v16; + int v17; + + assert(VideoPtr); + v7 = xp + 320 * yp + surface; + v8 = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels; + v9 = height; + + do { + v17 = v9; + v10 = width; + v16 = v7; + v15 = v8; + do { + v11 = *v7; + *v8 = *v7; + v12 = WinScan + v8; + *v12 = v11; + v13 = v12 - WinScan + 1; + *v13 = v11; + v14 = WinScan + v13; + *v14 = v11; + ++v7; + v8 = v14 - WinScan + 1; + --v10; + } while (v10); + + v8 = WinScan + WinScan + v15; + v7 = v16 + 320; + v9 = v17 - 1; + } while (v17 != 1); +} + +void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { + const byte *v7; + uint16 *v8; + int v9; + int v10; + int v11; + const byte *v12; + uint16 *v13; + uint16 v14; + uint16 *v15; + int v16; + uint16 *v17; + const byte *v18; + int v19; + + assert(VideoPtr); + v7 = xp + 320 * yp + surface; + v8 = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels); + v9 = height; + v10 = width; + + do { + v19 = v9; + v11 = v10; + v18 = v7; + v17 = v8; + v16 = v10; + v12 = PAL_PIXELS; + + do { + v13 = (uint16 *)(v12 + 2 * *v7); + v14 = *v13; + *v8 = *v13; + *(v8 + 1) = v14; + + v15 = (uint16 *)((byte *)v8 + WinScan); + *v15 = v14; + *(v15 + 1) = v14; + ++v7; + v8 = (uint16 *)((byte *)v15 - WinScan + 4); + --v11; + } while (v11); + + v10 = v16; + v8 = (uint16 *)((byte *)v17 + WinScan * 2); + v7 = v18 + 320; + v9 = v19 - 1; + } while (v19 != 1); +} + void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) { uint16 palData1[PALETTE_BLOCK_SIZE * 2]; byte palData2[PALETTE_BLOCK_SIZE]; @@ -1399,7 +1493,79 @@ int GraphicsManager::Magic_Number(signed int v) { } void GraphicsManager::Affiche_Segment_Vesa() { - warning("TODO: Affiche_Segment_Vesa"); + if (_vm->_globals.NBBLOC == 0) + return; + + _vm->_graphicsManager.SDL_NBLOCS = _vm->_globals.NBBLOC; + + for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { + BlocItem &bloc = _vm->_globals.BLOC[idx]; + Common::Rect &dstRect = dstrect[idx - 1]; + if (bloc.field0 != 1) + continue; + + if (_vm->_eventsManager.CASSE != 0) { + if (Winbpp == 1) { + Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); + } else if (Winbpp == 2) { + Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); + } + + dstRect.left = bloc.x1 * 2; + dstRect.top = bloc.y1 * 2 + 30; + dstRect.setWidth((bloc.x2 - bloc.x1) * 2); + dstRect.setHeight((bloc.y2 - bloc.y1) * 2); + } else if (bloc.x2 > start_x && bloc.x1 < (start_x + SCREEN_WIDTH)) { + if (bloc.x1 < start_x) + bloc.x1 = start_x; + if (bloc.x2 > (start_x + SCREEN_WIDTH)) + bloc.x2 = start_x + SCREEN_WIDTH; + + if (!SDL_ECHELLE) { + // Calculate the bounds + int xp = Magic_Number(bloc.x1) - 4; + if (xp < start_x) + xp = start_x; + int yp = Magic_Number(bloc.y1) - 4; + if (yp < 0) + yp = 0; + int width = Magic_Number(bloc.x2) + 4 - xp; + if (width < 4) + width = 4; + int height = Magic_Number(bloc.y2) + 4 - yp; + if (height < 4) + height = 4; + + if ((xp - start_x + width) > SCREEN_WIDTH) + xp -= 4; + if ((height - yp) > (SCREEN_HEIGHT - 40)) + yp -= 4; + + if (Winbpp == 2) { + m_scroll16A(VESA_BUFFER, xp, yp, width, height, + Reel_Zoom(xp - start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + } else { + m_scroll2A(VESA_BUFFER, xp, yp, width, height, + Reel_Zoom(xp - start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + } + + dstRect.left = Reel_Zoom(xp - start_x, SDL_ECHELLE); + dstRect.top = Reel_Zoom(yp, SDL_ECHELLE); + dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE)); + dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE)); + } else { + if (Winbpp == 2) { + m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, + bloc.x1 - start_x, bloc.y1); + } else { + m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, + bloc.x1 - start_x, bloc.y1); + } + } + } + + _vm->_globals.BLOC[idx].field0 = 0; + } } void GraphicsManager::CopyAsm(const byte *surface) { -- cgit v1.2.3 From fc5d6bfb9976d24147d2e8c073c9ca9e9cc5b8fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Sep 2012 20:54:26 +1000 Subject: HOPKINS: Implemented Affiche_Perfect and support methods --- engines/hopkins/graphics.cpp | 488 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 486 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 1a22ff42ce..788af5a801 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -67,6 +67,11 @@ GraphicsManager::GraphicsManager() { clip_x1 = clip_y1 = 0; clip_flag = false; SDL_NBLOCS = 0; + Red_x = Red_y = 0; + Red = 0; + Largeur = 0; + Compteur_y = 0; + spec_largeur = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); @@ -1653,12 +1658,491 @@ int GraphicsManager::Asm_Zoom(int v, int percentage) { return v; } +int GraphicsManager::Reel_Reduc(int v, int percentage) { + return Asm_Reduc(v, percentage); +} + +int GraphicsManager::Asm_Reduc(int v, int percentage) { + if (v) + v -= percentage * (long int)v / 100; + + return v; +} + void GraphicsManager::AFF_SPRITES() { warning("TODO: AFF_SPRITES"); } -void GraphicsManager::Affiche_Perfect(const byte *a1, const byte *a2, int a3, int a4, int a5, int a6, int a7, int a8) { - warning("TODO: Affice_Perfect"); +void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, int a3, int a4, int a5, int a6, int a7, int a8) { + const byte *v8; + int i; + const byte *v10; + int v11; + int v12; + const byte *v13; + byte *v14; + int v15; + byte *v16; + int v17; + int v18; + int v19; + int v20; + int v21 = 0; + int v22; + int v23; + int v24; + int v25; + int v26; + int v27; + int v28; + byte *v29; + int v30; + int v31; + int v32; + int v33; + int v34; + int v35; + int v36 = 0; + int v37; + int v38; + int v39; + byte *v40; + int v41; + int v42; + const byte *v43; + const byte *v44; + const byte *v45; + const byte *v46; + byte *v47; + byte *v48; + int v49; + int v50; + byte *v51; + unsigned int v52; + byte *v53; + byte *v54; + byte *v55; + int v56; + int v57; + int v58; + int v59; + int v60; + int v61; + int v62; + int v63; + int v64; + int v65; + + v8 = srcData + 3; + for (i = a5; i; --i) + v8 += READ_LE_UINT32(v8) + 16; + + v11 = 0; + v12 = 0; + v10 = v8 + 4; + v11 = *(uint16 *)v10; + v10 += 2; + v12 = *(uint16 *)v10; + v13 = v10 + 10; + clip_x = clip_y = 0; + clip_x1 = clip_y1 = 0; + + if ((unsigned __int16)a3 > min_x) { + if ((unsigned __int16)a3 < (unsigned __int16)(min_x + 300)) + clip_x = min_x + 300 - a3; + if ((unsigned __int16)a4 > min_y) { + if ((unsigned __int16)a4 < (unsigned __int16)(min_y + 300)) + clip_y = min_y + 300 - a4; + if ((unsigned __int16)a3 < (unsigned __int16)(max_x + 300)) { + clip_x1 = max_x + 300 - a3; + if ((unsigned __int16)a4 < (unsigned __int16)(max_y + 300)) { + clip_y1 = max_y + 300 - a4; + v14 = a3 + nbrligne2 * (a4 - 300) - 300 + destSurface; + + if ((uint16)a7) { + Compteur_y = 0; + Agr_x = 0; + Agr_y = 0; + Agr_Flag_y = 0; + Agr_Flag_x = 0; + Largeur = v11; + v20 = Asm_Zoom(v11, a7); + v22 = Asm_Zoom(v21, a7); + + if (a8) { + v29 = v20 + v14; + if (clip_y) { + if ((unsigned __int16)clip_y >= v22) + return; + v61 = v22; + v52 = v20; + v30 = 0; + v31 = (unsigned __int16)clip_y; + + while (Asm_Zoom(v30 + 1, a7) < v31) + ; + v20 = v52; + v13 += Largeur * v30; + v29 += nbrligne2 * (unsigned __int16)clip_y; + v22 = v61 - (unsigned __int16)clip_y; + } + + if (v22 > (unsigned __int16)clip_y1) + v22 = (unsigned __int16)clip_y1; + if (clip_x) { + if ((unsigned __int16)clip_x >= v20) + return; + v20 -= (unsigned __int16)clip_x; + } + + if (v20 > (unsigned __int16)clip_x1) { + v32 = v20 - (unsigned __int16)clip_x1; + v29 -= v32; + v62 = v22; + v33 = 0; + + while (Asm_Zoom(v33 + 1, a7) < v32) + ; + v34 = v33; + v22 = v62; + v13 += v34; + v20 = (unsigned __int16)clip_x1; + } + + do { + for (;;) { + v63 = v22; + v53 = v29; + v46 = v13; + Agr_Flag_x = 0; + Agr_x = 0; + v35 = v20; + + do { + for (;;) { + if (*v13) + *v29 = *v13; + --v29; + ++v13; + if (!Agr_Flag_x) + Agr_x = a7 + Agr_x; + + if ((unsigned __int16)Agr_x < 100) + break; + + Agr_x = Agr_x - 100; + --v13; + Agr_Flag_x = 1; + --v35; + if (!v35) + goto R_Aff_Zoom_Larg_Cont1; + } + + Agr_Flag_x = 0; + --v35; + } while (v35); + +R_Aff_Zoom_Larg_Cont1: + v13 = Largeur + v46; + v29 = nbrligne2 + v53; + ++Compteur_y; + if (!(uint16)Agr_Flag_y) + Agr_y = a7 + Agr_y; + + if ((unsigned __int16)Agr_y < 100) + break; + + Agr_y = Agr_y - 100; + v13 = v46; + Agr_Flag_y = 1; + v22 = v63 - 1; + if (v63 == 1) + return; + } + + Agr_Flag_y = 0; + v22 = v63 - 1; + } while (v63 != 1); + } else { + if (clip_y) { + if ((unsigned __int16)clip_y >= v22) + return; + v58 = v22; + v49 = v20; + v23 = 0; + v24 = (unsigned __int16)clip_y; + + while (Asm_Zoom(v23 + 1, a7) < v24) + ; + v20 = v49; + v13 += Largeur * v23; + v14 += nbrligne2 * (unsigned __int16)clip_y; + v22 = v58 - (unsigned __int16)clip_y; + } + + if (v22 > (unsigned __int16)clip_y1) + v22 = (unsigned __int16)clip_y1; + + if (clip_x) { + if ((unsigned __int16)clip_x >= v20) + return; + v59 = v22; + v50 = v20; + v25 = (unsigned __int16)clip_x; + v26 = 0; + + while (Asm_Zoom(v26 + 1, a7) < v25) + ; + v27 = v26; + v22 = v59; + v13 += v27; + v14 += (unsigned __int16)clip_x; + v20 = v50 - (unsigned __int16)clip_x; + } + + if (v20 > (unsigned __int16)clip_x1) + v20 = (unsigned __int16)clip_x1; + + do { + for (;;) { + v60 = v22; + v51 = v14; + v45 = v13; + v28 = v20; + Agr_Flag_x = 0; + Agr_x = 0; + + do { + for (;;) { + if (*v13) + *v14 = *v13; + ++v14; + ++v13; + + if (!Agr_Flag_x) + Agr_x = a7 + Agr_x; + if ((unsigned __int16)Agr_x < 100) + break; + + Agr_x = Agr_x - 100; + --v13; + Agr_Flag_x = 1; + --v28; + + if (!v28) + goto Aff_Zoom_Larg_Cont1; + } + + Agr_Flag_x = 0; + --v28; + } + while (v28); + +Aff_Zoom_Larg_Cont1: + v13 = Largeur + v45; + v14 = nbrligne2 + v51; + if (!(uint16)Agr_Flag_y) + Agr_y = a7 + Agr_y; + + if ((unsigned __int16)Agr_y < 100) + break; + + Agr_y = Agr_y - 100; + v13 = v45; + Agr_Flag_y = 1; + v22 = v60 - 1; + + if (v60 == 1) + return; + } + + Agr_Flag_y = 0; + v22 = v60 - 1; + } while (v60 != 1); + } + } else if ((uint16)a6) { + Compteur_y = 0; + Red_x = 0; + Red_y = 0; + Largeur = v11; + Red = a6; + + if ((unsigned __int16)a6 < 100) { + v37 = Asm_Reduc(v11, Red); + if (a8) { + v40 = v37 + v14; + + do { + v65 = v36; + v55 = v40; + Red_y = Red + Red_y; + + if ((unsigned __int16)Red_y < 100) { + Red_x = 0; + v41 = Largeur; + v42 = v37; + + do { + Red_x = Red + Red_x; + if (Red_x < 100) { + if (v42 >= clip_x && v42 < clip_x1 && *v13) + *v40 = *v13; + --v40; + ++v13; + --v42; + } else { + Red_x = Red_x - 100; + ++v13; + } + --v41; + } while (v41); + + v36 = v65; + v40 = nbrligne2 + v55; + } else { + Red_y = Red_y - 100; + v13 += Largeur; + } + + --v36; + } while ( v36 ); + } else { + do { + v64 = v36; + v54 = v14; + Red_y = Red + Red_y; + + if ((unsigned __int16)Red_y < 100) { + Red_x = 0; + v38 = Largeur; + v39 = 0; + + do { + Red_x = Red + Red_x; + if ((unsigned __int16)Red_x < 100) { + if (v39 >= clip_x && v39 < clip_x1 && *v13) + *v14 = *v13; + ++v14; + ++v13; + ++v39; + } else { + Red_x = Red_x - 100; + ++v13; + } + + --v38; + } while ( v38 ); + + v36 = v64; + v14 = nbrligne2 + v54; + } else { + Red_y = Red_y - 100; + v13 += Largeur; + } + + --v36; + } while (v36); + } + } + } else { + Largeur = v11; + Compteur_y = 0; + if (a8) { + v16 = v11 + v14; + spec_largeur = v11; + if (clip_y) { + if ((unsigned __int16)clip_y >= (unsigned int)v12) + return; + v13 += v11 * (unsigned __int16)clip_y; + v16 += nbrligne2 * (unsigned __int16)clip_y; + v12 -= (unsigned __int16)clip_y; + } + + v17 = (unsigned __int16)clip_y1; + if (v12 > clip_y1) + v12 = clip_y1; + + v17 = clip_x; + if (clip_x) { + if (v17 >= v11) + return; + v11 -= v17; + } + + if (v11 > (unsigned __int16)clip_x1) { + v18 = v11 - (unsigned __int16)clip_x1; + v13 += v18; + v16 -= v18; + v11 = (unsigned __int16)clip_x1; + } + + do { + v57 = v12; + v48 = v16; + v44 = v13; + v19 = v11; + + do { + if (*v13) + *v16 = *v13; + ++v13; + --v16; + --v19; + } while (v19); + + v13 = spec_largeur + v44; + v16 = nbrligne2 + v48; + v12 = v57 - 1; + } while (v57 != 1); + } else { + spec_largeur = v11; + if (clip_y) { + if ((unsigned __int16)clip_y >= (unsigned int)v12) + return; + + v13 += v11 * (unsigned __int16)clip_y; + v14 += nbrligne2 * (unsigned __int16)clip_y; + v12 -= (unsigned __int16)clip_y; + } + + if (v12 > clip_y1) + v12 = clip_y1; + if (clip_x) { + if ((unsigned __int16)clip_x >= v11) + return; + + v13 += (unsigned __int16)clip_x; + v14 += (unsigned __int16)clip_x; + v11 -= (unsigned __int16)clip_x; + } + + if (v11 > (unsigned __int16)clip_x1) + v11 = (unsigned __int16)clip_x1; + + do { + v56 = v12; + v47 = v14; + v43 = v13; + v15 = v11; + + do { + if (*v13) + *v14 = *v13; + ++v14; + ++v13; + --v15; + } while (v15); + + v13 = spec_largeur + v43; + v14 = nbrligne2 + v47; + v12 = v56 - 1; + } while (v56 != 1); + } + } + } + } + } + } } } // End of namespace Hopkins -- cgit v1.2.3 From 507af7e8a5933903131fa1d9c1ac65ae9e31cfa0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Sep 2012 21:05:19 +1000 Subject: HOPKINS: Moved VBL method from EventsManager to GraphicsManager --- engines/hopkins/graphics.cpp | 244 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 242 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 788af5a801..50c33dddaf 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1401,8 +1401,8 @@ void GraphicsManager::FIN_VISU() { _vm->_objectsManager.BOB_OFF(idx); } - _vm->_eventsManager.VBL(); - _vm->_eventsManager.VBL(); + _vm->_graphicsManager.VBL(); + _vm->_graphicsManager.VBL(); for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals.Bqe_Anim[idx].field4 == 1) @@ -2145,4 +2145,244 @@ Aff_Zoom_Larg_Cont1: } } +void GraphicsManager::VBL() { + int a1 = 0; + signed __int16 v1; + int v2; + int v3; + int v4; + int v5; + int v6; + signed __int16 v7; + int v10; + signed int v11 = 0; + signed int v12 = 0; + int v13 = 0; + unsigned int v14 = 0; + int v15 = 0; + + if (REDRAW) { + DD_Lock(); + if (_vm->_eventsManager.CASSE) { + CopyAsm(VESA_BUFFER); + REDRAW = 0; + } else { + if (_vm->_globals.iRegul == 3) + m_scroll(VESA_BUFFER, ofscroll, 50, SCREEN_WIDTH, 340, 0, 50); + else + m_scroll(VESA_BUFFER, ofscroll, 20, SCREEN_WIDTH, 440, 0, 20); + FileManager::DMESS(); + --REDRAW; + } + DD_Unlock(); + } + + if (_vm->_eventsManager.souris_flag) { + v1 = 20; + if (!_vm->_eventsManager.mouse_linux) + v1 = 10; + v2 = 20; + if (!_vm->_eventsManager.mouse_linux) + v2 = 15; + + v15 = _vm->_eventsManager.souris_x - v1; + a1 = _vm->_eventsManager.souris_y; + v14 = _vm->_eventsManager.souris_sizex; + v13 = _vm->_eventsManager.souris_sizey; + if (_vm->_eventsManager.btsouris == 23) { + v14 = _vm->_globals.OBJL; + v13 = _vm->_globals.OBJH; + goto LABEL_35; + } + + if (_vm->_eventsManager.CASSE) { + if (v15 < min_x) + v15 = min_x; + if (_vm->_eventsManager.souris_y < min_y) + a1 = min_y; + + if (_vm->_eventsManager.souris_sizex + v15 >= max_x) + v14 = _vm->_eventsManager.souris_sizex - (_vm->_eventsManager.souris_sizex + v15 - max_x); + if (a1 + _vm->_eventsManager.souris_sizey < max_y) + goto LABEL_34; + + v3 = a1 + _vm->_eventsManager.souris_sizey - max_y; + } else { + if (v15 < min_x) + v15 = min_x - v1; + v2 = (signed __int16)v2; + if (_vm->_eventsManager.souris_y < min_y - (signed __int16)v2) + a1 = min_y - (signed __int16)v2; + if (_vm->_eventsManager.souris_sizex + v15 >= max_x) + v14 = _vm->_eventsManager.souris_sizex - (_vm->_eventsManager.souris_sizex + v15 - max_x - v1); + if (a1 + _vm->_eventsManager.souris_sizey < v2 + max_y) + goto LABEL_34; + + v3 = v2 + a1 + _vm->_eventsManager.souris_sizey - max_y; + } + + v13 = _vm->_eventsManager.souris_sizey - v3; +LABEL_34: + v12 = v14 + v15; + v11 = a1 + v13; + } +LABEL_35: + + if (!_vm->_globals.PUBEXIT) + AFF_SPRITES(); + if (_vm->_eventsManager.souris_flag != 1) + goto LABEL_54; + if (_vm->_eventsManager.btsouris == 23) + goto LABEL_45; + + if (a1 >= max_y || v15 >= max_x || (signed int)v14 <= 1 || v13 <= 1) { + if (_vm->_eventsManager.btsouris != 23) + goto LABEL_54; + +LABEL_45: + if (a1 < max_y && v15 < max_x) { + if ((signed int)(v14 + v15) > max_x) + v14 -= v14 + v15 - max_x; + if (a1 + v13 > max_y) + v13 -= a1 + v13 - max_y; + + if ((signed int)v14 > 1 && v13 > 1) { + Capture_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); + Affiche_Perfect(VESA_BUFFER, _vm->_globals.Bufferobjet, v15 + 300, a1 + 300, 0, 0, 0, 0); + Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13); + } + } + goto LABEL_54; + } + + Capture_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); + Sprite_Vesa(VESA_BUFFER, _vm->_eventsManager.pointeur_souris, v15 + 300, a1 + 300, _vm->_eventsManager.souris_n); + Ajoute_Segment_Vesa(v15, a1, v12, v11); + +LABEL_54: + _vm->_globals.vitesse = 2; + + do { + for (;;) { + while (_vm->_eventsManager.CASSE || _vm->_globals.iRegul != 1) { + if (_vm->_eventsManager.CASSE != 1) + goto LABEL_63; + + if (_vm->_eventsManager.lItCounter > 1) + goto LABEL_65; + } + + if (_vm->_globals.vitesse != 2) + break; + + if (_vm->_eventsManager.lItCounter > 9) + goto LABEL_65; + } +LABEL_63: + ; + } while (_vm->_globals.iRegul == 3 && _vm->_eventsManager.lItCounter <= 15); + +LABEL_65: + _vm->_globals.vitesse = 2; + _vm->_eventsManager.lItCounter = 0; + + if (DOUBLE_ECRAN != 1 || no_scroll == 1) { + Affiche_Segment_Vesa(); + } else { + if (no_scroll != 2) { + if (_vm->_eventsManager.XMOUSE() > SCROLL + 620) + SCROLL += SPEED_SCROLL; + + if (_vm->_eventsManager.XMOUSE() < SCROLL + 10) + SCROLL -= SPEED_SCROLL; + } + + SCROLL = CLIP(SCROLL, 0, SCREEN_WIDTH); + + if (SDL_ECHELLE) + v4 = Magic_Number(SCROLL); + else + v4 = SCROLL; + + if (OLD_SCROLL == v4) { + Affiche_Segment_Vesa(); + } else { + _vm->_fontManager.TEXTE_OFF(9); + DD_Lock(); + if (SDL_ECHELLE) { + if (Winbpp == 2) { + v5 = Reel_Zoom(20, SDL_ECHELLE); + m_scroll16A(VESA_BUFFER, v4, 20, 640, 440, 0, v5); + } else { + v6 = Reel_Zoom(20, SDL_ECHELLE); + m_scroll2A(VESA_BUFFER, v4, 20, 640, 440, 0, v6); + } + + DD_Unlock(); + dstrect[0].left = Reel_Zoom(0, SDL_ECHELLE); + dstrect[0].top = Reel_Zoom(20, SDL_ECHELLE); + dstrect[0].setWidth(Reel_Zoom(SCREEN_WIDTH, SDL_ECHELLE)); + dstrect[0].setHeight(Reel_Zoom(440, SDL_ECHELLE)); + } else { + if (Winbpp == 2) + m_scroll16(VESA_BUFFER, v4, 20, 640, 440, 0, 20); + else + m_scroll2(VESA_BUFFER, v4, 20, 640, 440, 0, 20); + + DD_Unlock(); + dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 40); + } + + if (!_vm->_globals.BPP_NOAFF) { + // TODO: Useful for future dirty rect processing? +// SDL_UpdateRects(LinuxScr, 1, dstrect); + } + if (_vm->_globals.NBBLOC) { + v7 = 1; + v10 = _vm->_globals.NBBLOC + 1; + + do { + if (_vm->_globals.BLOC[v7].field0 == 1) + _vm->_globals.BLOC[v7].field0 = 0; + ++v7; + } while (v10 != v7); + } + + _vm->_globals.NBBLOC = 0; + start_x = v4; + ofscroll = v4; + SCROLL = v4; + } + + OLD_SCROLL = v4; + start_x = v4; + ofscroll = v4; + } + + _vm->_eventsManager.souris_bb = _vm->_eventsManager.souris_b; + _vm->_eventsManager.souris_b = 0; + if (_vm->_eventsManager.souris_flag == 1) { + if (_vm->_eventsManager.btsouris != 23) { + if (a1 < max_y && v15 < max_x && v14 > 1 && v13 > 1) { + Restore_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); + Ajoute_Segment_Vesa(v15, a1, v12, v11); + goto LABEL_113; + } + + if (_vm->_eventsManager.btsouris != 23) + goto LABEL_113; + } + + if (a1 < max_y && v15 < max_x && v14 > 1 && v13 > 1) { + Restore_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); + Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13); + } + } + +LABEL_113: + + _vm->_soundManager.VERIF_SOUND(); + return _vm->_eventsManager.CONTROLE_MES(); +} + } // End of namespace Hopkins -- cgit v1.2.3 From b6eba95cc1ddbdae511cf05369adb916258290a1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Sep 2012 21:20:07 +1000 Subject: HOPKINS: Minor renaming and bugifxes --- engines/hopkins/graphics.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 50c33dddaf..ca2e40b9fd 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -199,7 +199,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (!DOUBLE_ECRAN) { souris_max(); SCANLINE(SCREEN_WIDTH); - _vm->_graphicsManager.max_x = SCREEN_WIDTH; + max_x = SCREEN_WIDTH; DD_Lock(); Cls_Video(); if (Winbpp == 2) { @@ -217,7 +217,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { DD_Unlock(); } else { SCANLINE(SCREEN_WIDTH * 2); - _vm->_graphicsManager.max_x = SCREEN_WIDTH * 2; + max_x = SCREEN_WIDTH * 2; DD_Lock(); Cls_Video(); DD_Unlock(); @@ -1245,37 +1245,37 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int } while (yTemp != 1); } -void GraphicsManager::Sprite_Vesa(byte *a1, byte *a2, int a3, int a4, int a5) { - byte *v5; +void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int a3, int a4, int spriteIndex) { + const byte *v5; int i; - byte *v7; + const byte *v7; uint16 v8; - byte *v9; + const byte *v9; int v10; uint16 v11; uint16 v12; uint16 v13; uint16 v14; - byte *v15; - byte *v16; + const byte *v15; + const byte *v16; const byte *v17; byte *v18; int v19; - byte *v20; - byte *v21; + const byte *v20; + const byte *v21; int v22; unsigned int v23; byte *v24; const byte *v25; - byte *v26; - byte *v27; + const byte *v26; + const byte *v27; byte *v28; byte *v29; int v30; int v31; - v5 = a2 + 3; - for (i = a5; i; --i) + v5 = spriteData + 3; + for (i = spriteIndex; i; --i) v5 += READ_LE_UINT32(v5) + 16; v10 = 0; v7 = v5 + 4; @@ -1318,7 +1318,7 @@ void GraphicsManager::Sprite_Vesa(byte *a1, byte *a2, int a3, int a4, int a5) { v15 = v9 + 6; v16 = v15 + 4; v17 = READ_LE_UINT32(v15) + v15 + 4; - v18 = a3 + nbrligne2 * (a4 - 300) - 300 + a1; + v18 = a3 + nbrligne2 * (a4 - 300) - 300 + surface; v19 = 0; if (clip_flag) { do { @@ -1401,8 +1401,8 @@ void GraphicsManager::FIN_VISU() { _vm->_objectsManager.BOB_OFF(idx); } - _vm->_graphicsManager.VBL(); - _vm->_graphicsManager.VBL(); + VBL(); + VBL(); for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals.Bqe_Anim[idx].field4 == 1) @@ -1501,7 +1501,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (_vm->_globals.NBBLOC == 0) return; - _vm->_graphicsManager.SDL_NBLOCS = _vm->_globals.NBBLOC; + SDL_NBLOCS = _vm->_globals.NBBLOC; for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { BlocItem &bloc = _vm->_globals.BLOC[idx]; -- cgit v1.2.3 From f20e411734ea67e940218fcd83f0bac7be2b41be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Sep 2012 07:48:21 +1000 Subject: HOPKINS: Rewrite of Sprite_Vesa from scratch --- engines/hopkins/graphics.cpp | 265 ++++++++++++++++++++----------------------- 1 file changed, 125 insertions(+), 140 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ca2e40b9fd..c18fa352ef 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -169,7 +169,7 @@ void GraphicsManager::Cls_Video() { void GraphicsManager::LOAD_IMAGE(const Common::String &file) { Common::String filename = Common::String::format("%s.PCX", file.c_str()); CHARGE_ECRAN(filename); - GraphicsManager::INIT_TABLE(165, 170, Palette); + INIT_TABLE(165, 170, Palette); } void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { @@ -1245,152 +1245,137 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int } while (yTemp != 1); } -void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int a3, int a4, int spriteIndex) { - const byte *v5; - int i; - const byte *v7; - uint16 v8; - const byte *v9; - int v10; - uint16 v11; - uint16 v12; - uint16 v13; - uint16 v14; - const byte *v15; - const byte *v16; - const byte *v17; - byte *v18; - int v19; - const byte *v20; - const byte *v21; - int v22; - unsigned int v23; - byte *v24; - const byte *v25; - const byte *v26; - const byte *v27; - byte *v28; - byte *v29; - int v30; - int v31; - - v5 = spriteData + 3; - for (i = spriteIndex; i; --i) - v5 += READ_LE_UINT32(v5) + 16; - v10 = 0; - v7 = v5 + 4; - v8 = READ_LE_UINT16(v7); - v9 = v7 + 2; - v10 = READ_LE_UINT16(v9); +void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) { + // Get a pointer to the start of the desired sprite + const byte *spriteP = spriteData + 3; + for (int i = spriteIndex; i; --i) + spriteP += READ_LE_UINT32(spriteP) + 16; + clip_x = 0; clip_y = 0; clip_flag = false; - clip_x1 = v8; - if ((uint16)(v8 + a3) > v8) { - if ((uint16)a3 < (uint16)(min_x + 300)) { - clip_x = min_x + 300 - a3; - clip_flag = true; - } - if ((uint16)(v10 + (uint16)a4) > (uint16)v10) { - if ((uint16)a4 < (uint16)(min_y + 300)) { - clip_y = min_y + 300 - a4; - clip_flag = true; - } - v11 = max_x + 300; - if ((uint16)a3 < (uint16)(max_x + 300)) { - if ((uint16)(v8 + a3) > v11) { - v12 = v8 + 10 - (v8 + a3 - v11); - if (v12 <= 10) - return; - clip_x1 = v12 - 10; - clip_flag = true; - } - v13 = max_y + 300; - if ((uint16)a4 < (uint16)(max_y + 300)) { - if ((uint16)(v10 + (uint16)a4) > v13) { - v14 = v10 + 10 - (v10 + (uint16)a4 - v13); - if (v14 <= 10) - return; - v10 -= 10; - clip_y1 = v10; - clip_flag = true; - } - v15 = v9 + 6; - v16 = v15 + 4; - v17 = READ_LE_UINT32(v15) + v15 + 4; - v18 = a3 + nbrligne2 * (a4 - 300) - 300 + surface; - v19 = 0; - if (clip_flag) { - do { - v31 = v10; - v29 = v18; - v19 = 0; - while (*v16 != -3) { - if (*v16 == -2) { - v27 = v16 + 1; - v10 = READ_LE_UINT16(v27); - do { - if (!clip_y && (uint16)v19 >= clip_x && (uint16)v19 < clip_x1) - *v18 = *v17; - ++v17; - ++v18; - ++v19; - --v10; - } while (v10); - - v16 = v27 + 2; - } else { - v26 = v16 + 1; - v10 = *(uint16 *)v26; - v18 += v10; - v19 += v10; - v16 = v26 + 2; - } - } - - if (clip_y) - --clip_y; - v16 += 3; - v18 = nbrligne2 + v29; - v10 = v31 - 1; - } while (v31 != 1); - } else { - do { - v30 = v10; - v28 = v18; - while (*v16 != -3) { - if (*v16 == -2) { - v21 = v16 + 1; - v10 = READ_LE_UINT16(v21); - - v22 = v10; - v23 = (unsigned int)v10 >> 2; - memcpy(v18, v17, 4 * v23); - v25 = (v17 + 4 * v23); - v24 = (v18 + 4 * v23); - v10 = v22 - 4 * v23; - memcpy(v24, v25, v10); - - v17 = v25 + v10; - v18 = v24 + v10; - v10 = 0; - v16 = v21 + 2; - } else { - v20 = v16 + 1; - v10 = READ_LE_UINT16(v20); - v18 += v10; - v16 = v20 + 2; - } - } - - v16 += 3; - v18 = nbrligne2 + v28; - v10 = v30 - 1; - } while (v30 != 1); + spriteP += 4; + int width = READ_LE_UINT16(spriteP); + spriteP += 2; + int height = READ_LE_UINT16(spriteP); + + // Clip X + clip_x1 = width; + if ((xp + width) <= (min_x + 300)) + return; + if (xp < (min_x + 300)) { + clip_x = min_x + 300 - xp; + clip_flag = true; + } + + // Clip Y + // TODO: This is weird, but it's that way in the original. Original game bug? + if ((yp + height) <= height) + return; + if (yp < (min_y + 300)) { + clip_y = min_y + 300 - yp; + clip_flag = true; + } + + // Clip X1 + if (xp >= (max_x + 300)) + return; + if ((xp + width) > (max_x + 300)) { + int xAmount = width + 10 - (xp + width - (max_x + 300)); + if (xAmount <= 10) + return; + + clip_x1 = xAmount - 10; + clip_flag = true; + } + + // Clip Y1 + if (yp >= (max_y + 300)) + return; + if ((yp + height) > (max_y + 300)) { + int yAmount = height + 10 - (yp + height - (max_y + 300)); + if (yAmount <= 10) + return; + + clip_y1 = yAmount - 10; + clip_flag = true; + } + + // Sprite display + + // Set up source + spriteP += 6; + int srcOffset = READ_LE_UINT16(spriteP); + spriteP += 4; + const byte *srcP = spriteP; + spriteP += srcOffset; + + // Set up surface destination + byte *destP = surface + (yp - 300) * nbrligne2 + (xp - 300); + + // Handling for clipped versus non-clipped + if (clip_flag) { + // Clipped version + for (int yc = 0; yc < height; ++yc, destP += nbrligne2) { + byte *tempDestP = destP; + byte byteVal; + int xc = 0; + + // Loop through sequences of bytes to skip or output + while ((byteVal = *srcP) != 253) { + ++srcP; + int width = READ_LE_UINT16(srcP); + + if (byteVal != 254) { + // Skip over output bytes + tempDestP += width; + xc += width; + } else { + // Output byte range + while (width-- > 0) { + // Get the next byte + byteVal = *spriteP; + if (clip_y == 0 && xc >= clip_x && xc < clip_x1) + // Not clipped, so display it + *tempDestP = byteVal; + + // Move to next pixel + xc++; + ++srcP; + ++tempDestP; } } + + srcP += 2; } + + if (clip_y > 0) + --clip_y; + srcP += 3; + } + } else { + // Non-clipped + for (int yc = 0; yc < height; ++yc, destP += nbrligne2) { + byte *tempDestP = destP; + byte byteVal; + + while ((byteVal = *srcP) != 253) { + ++srcP; + int width = READ_LE_UINT16(srcP); + srcP += 2; + + if (byteVal == 254) { + // Copy pixel range + Common::copy(spriteP, spriteP + width, tempDestP); + spriteP += width; + } + + tempDestP += width; + } + + // Skip over control byte and width + srcP += 3; } } } -- cgit v1.2.3 From 1a639302782e35307ee82d4961f7f784fb2fd917 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Sep 2012 09:55:40 +1000 Subject: HOPKINS: Disabled VBL() method code and added ScummVM cursor display. I'm not yet sure whether VBL was only concerned with displaying the cursor, but it had some loops using the lItCounter, so it was causing infinite loops. Whatever else VBL actually does besides cursor display will have to be converted to a more ScummVM friendly implementation. --- engines/hopkins/graphics.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c18fa352ef..aa6f54529c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -114,7 +114,6 @@ void GraphicsManager::SET_MODE(int width, int height) { height = Reel_Zoom(height, SDL_ECHELLE); } - //Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0); Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); if (bpp == 8) { @@ -2131,6 +2130,8 @@ Aff_Zoom_Larg_Cont1: } void GraphicsManager::VBL() { + // Bulk of method currently disabled +/* int a1 = 0; signed __int16 v1; int v2; @@ -2249,6 +2250,10 @@ LABEL_54: do { for (;;) { + // TODO: Figure out the purpose of this loop waiting on lItCounter.. + // maybe it's for cursor animatoin? + _vm->_eventsManager.delay(10); + while (_vm->_eventsManager.CASSE || _vm->_globals.iRegul != 1) { if (_vm->_eventsManager.CASSE != 1) goto LABEL_63; @@ -2365,7 +2370,7 @@ LABEL_65: } LABEL_113: - + */ _vm->_soundManager.VERIF_SOUND(); return _vm->_eventsManager.CONTROLE_MES(); } -- cgit v1.2.3 From 460b4eb17b02dd1bc5653d8f4c7732654bad77ed Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Sep 2012 10:36:18 +1000 Subject: HOPKINS: Implemented AFFICHE_SPEED method --- engines/hopkins/graphics.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index aa6f54529c..b7eb48937c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2375,4 +2375,20 @@ LABEL_113: return _vm->_eventsManager.CONTROLE_MES(); } +void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { + int width, height; + + width = _vm->_objectsManager.Get_Largeur(spriteData, spriteIndex); + height = _vm->_objectsManager.Get_Hauteur(spriteData, spriteIndex); + if (*spriteData == 78) { + Affiche_Perfect(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); + Affiche_Perfect(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); + } else { + Sprite_Vesa(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex); + Sprite_Vesa(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex); + } + if (!_vm->_globals.NO_VISU) + Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 01bcd87ba43482ef5e773fc6abdf3cb0e918bbe5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Sep 2012 10:59:52 +1000 Subject: HOPKINS: Initial implementation of CHOICE_OPTION and AFF_SPRITES --- engines/hopkins/graphics.cpp | 315 +++++++++---------------------------------- 1 file changed, 63 insertions(+), 252 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b7eb48937c..048d07241f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1385,8 +1385,8 @@ void GraphicsManager::FIN_VISU() { _vm->_objectsManager.BOB_OFF(idx); } - VBL(); - VBL(); + _vm->_eventsManager.VBL(); + _vm->_eventsManager.VBL(); for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals.Bqe_Anim[idx].field4 == 1) @@ -1653,10 +1653,6 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { return v; } -void GraphicsManager::AFF_SPRITES() { - warning("TODO: AFF_SPRITES"); -} - void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, int a3, int a4, int a5, int a6, int a7, int a8) { const byte *v8; int i; @@ -2129,252 +2125,6 @@ Aff_Zoom_Larg_Cont1: } } -void GraphicsManager::VBL() { - // Bulk of method currently disabled -/* - int a1 = 0; - signed __int16 v1; - int v2; - int v3; - int v4; - int v5; - int v6; - signed __int16 v7; - int v10; - signed int v11 = 0; - signed int v12 = 0; - int v13 = 0; - unsigned int v14 = 0; - int v15 = 0; - - if (REDRAW) { - DD_Lock(); - if (_vm->_eventsManager.CASSE) { - CopyAsm(VESA_BUFFER); - REDRAW = 0; - } else { - if (_vm->_globals.iRegul == 3) - m_scroll(VESA_BUFFER, ofscroll, 50, SCREEN_WIDTH, 340, 0, 50); - else - m_scroll(VESA_BUFFER, ofscroll, 20, SCREEN_WIDTH, 440, 0, 20); - FileManager::DMESS(); - --REDRAW; - } - DD_Unlock(); - } - - if (_vm->_eventsManager.souris_flag) { - v1 = 20; - if (!_vm->_eventsManager.mouse_linux) - v1 = 10; - v2 = 20; - if (!_vm->_eventsManager.mouse_linux) - v2 = 15; - - v15 = _vm->_eventsManager.souris_x - v1; - a1 = _vm->_eventsManager.souris_y; - v14 = _vm->_eventsManager.souris_sizex; - v13 = _vm->_eventsManager.souris_sizey; - if (_vm->_eventsManager.btsouris == 23) { - v14 = _vm->_globals.OBJL; - v13 = _vm->_globals.OBJH; - goto LABEL_35; - } - - if (_vm->_eventsManager.CASSE) { - if (v15 < min_x) - v15 = min_x; - if (_vm->_eventsManager.souris_y < min_y) - a1 = min_y; - - if (_vm->_eventsManager.souris_sizex + v15 >= max_x) - v14 = _vm->_eventsManager.souris_sizex - (_vm->_eventsManager.souris_sizex + v15 - max_x); - if (a1 + _vm->_eventsManager.souris_sizey < max_y) - goto LABEL_34; - - v3 = a1 + _vm->_eventsManager.souris_sizey - max_y; - } else { - if (v15 < min_x) - v15 = min_x - v1; - v2 = (signed __int16)v2; - if (_vm->_eventsManager.souris_y < min_y - (signed __int16)v2) - a1 = min_y - (signed __int16)v2; - if (_vm->_eventsManager.souris_sizex + v15 >= max_x) - v14 = _vm->_eventsManager.souris_sizex - (_vm->_eventsManager.souris_sizex + v15 - max_x - v1); - if (a1 + _vm->_eventsManager.souris_sizey < v2 + max_y) - goto LABEL_34; - - v3 = v2 + a1 + _vm->_eventsManager.souris_sizey - max_y; - } - - v13 = _vm->_eventsManager.souris_sizey - v3; -LABEL_34: - v12 = v14 + v15; - v11 = a1 + v13; - } -LABEL_35: - - if (!_vm->_globals.PUBEXIT) - AFF_SPRITES(); - if (_vm->_eventsManager.souris_flag != 1) - goto LABEL_54; - if (_vm->_eventsManager.btsouris == 23) - goto LABEL_45; - - if (a1 >= max_y || v15 >= max_x || (signed int)v14 <= 1 || v13 <= 1) { - if (_vm->_eventsManager.btsouris != 23) - goto LABEL_54; - -LABEL_45: - if (a1 < max_y && v15 < max_x) { - if ((signed int)(v14 + v15) > max_x) - v14 -= v14 + v15 - max_x; - if (a1 + v13 > max_y) - v13 -= a1 + v13 - max_y; - - if ((signed int)v14 > 1 && v13 > 1) { - Capture_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); - Affiche_Perfect(VESA_BUFFER, _vm->_globals.Bufferobjet, v15 + 300, a1 + 300, 0, 0, 0, 0); - Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13); - } - } - goto LABEL_54; - } - - Capture_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); - Sprite_Vesa(VESA_BUFFER, _vm->_eventsManager.pointeur_souris, v15 + 300, a1 + 300, _vm->_eventsManager.souris_n); - Ajoute_Segment_Vesa(v15, a1, v12, v11); - -LABEL_54: - _vm->_globals.vitesse = 2; - - do { - for (;;) { - // TODO: Figure out the purpose of this loop waiting on lItCounter.. - // maybe it's for cursor animatoin? - _vm->_eventsManager.delay(10); - - while (_vm->_eventsManager.CASSE || _vm->_globals.iRegul != 1) { - if (_vm->_eventsManager.CASSE != 1) - goto LABEL_63; - - if (_vm->_eventsManager.lItCounter > 1) - goto LABEL_65; - } - - if (_vm->_globals.vitesse != 2) - break; - - if (_vm->_eventsManager.lItCounter > 9) - goto LABEL_65; - } -LABEL_63: - ; - } while (_vm->_globals.iRegul == 3 && _vm->_eventsManager.lItCounter <= 15); - -LABEL_65: - _vm->_globals.vitesse = 2; - _vm->_eventsManager.lItCounter = 0; - - if (DOUBLE_ECRAN != 1 || no_scroll == 1) { - Affiche_Segment_Vesa(); - } else { - if (no_scroll != 2) { - if (_vm->_eventsManager.XMOUSE() > SCROLL + 620) - SCROLL += SPEED_SCROLL; - - if (_vm->_eventsManager.XMOUSE() < SCROLL + 10) - SCROLL -= SPEED_SCROLL; - } - - SCROLL = CLIP(SCROLL, 0, SCREEN_WIDTH); - - if (SDL_ECHELLE) - v4 = Magic_Number(SCROLL); - else - v4 = SCROLL; - - if (OLD_SCROLL == v4) { - Affiche_Segment_Vesa(); - } else { - _vm->_fontManager.TEXTE_OFF(9); - DD_Lock(); - if (SDL_ECHELLE) { - if (Winbpp == 2) { - v5 = Reel_Zoom(20, SDL_ECHELLE); - m_scroll16A(VESA_BUFFER, v4, 20, 640, 440, 0, v5); - } else { - v6 = Reel_Zoom(20, SDL_ECHELLE); - m_scroll2A(VESA_BUFFER, v4, 20, 640, 440, 0, v6); - } - - DD_Unlock(); - dstrect[0].left = Reel_Zoom(0, SDL_ECHELLE); - dstrect[0].top = Reel_Zoom(20, SDL_ECHELLE); - dstrect[0].setWidth(Reel_Zoom(SCREEN_WIDTH, SDL_ECHELLE)); - dstrect[0].setHeight(Reel_Zoom(440, SDL_ECHELLE)); - } else { - if (Winbpp == 2) - m_scroll16(VESA_BUFFER, v4, 20, 640, 440, 0, 20); - else - m_scroll2(VESA_BUFFER, v4, 20, 640, 440, 0, 20); - - DD_Unlock(); - dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 40); - } - - if (!_vm->_globals.BPP_NOAFF) { - // TODO: Useful for future dirty rect processing? -// SDL_UpdateRects(LinuxScr, 1, dstrect); - } - if (_vm->_globals.NBBLOC) { - v7 = 1; - v10 = _vm->_globals.NBBLOC + 1; - - do { - if (_vm->_globals.BLOC[v7].field0 == 1) - _vm->_globals.BLOC[v7].field0 = 0; - ++v7; - } while (v10 != v7); - } - - _vm->_globals.NBBLOC = 0; - start_x = v4; - ofscroll = v4; - SCROLL = v4; - } - - OLD_SCROLL = v4; - start_x = v4; - ofscroll = v4; - } - - _vm->_eventsManager.souris_bb = _vm->_eventsManager.souris_b; - _vm->_eventsManager.souris_b = 0; - if (_vm->_eventsManager.souris_flag == 1) { - if (_vm->_eventsManager.btsouris != 23) { - if (a1 < max_y && v15 < max_x && v14 > 1 && v13 > 1) { - Restore_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); - Ajoute_Segment_Vesa(v15, a1, v12, v11); - goto LABEL_113; - } - - if (_vm->_eventsManager.btsouris != 23) - goto LABEL_113; - } - - if (a1 < max_y && v15 < max_x && v14 > 1 && v13 > 1) { - Restore_Mem(VESA_BUFFER, _vm->_globals.cache_souris, v15, a1, v14, v13); - Ajoute_Segment_Vesa(v15, a1, v14 + v15, a1 + v13); - } - } - -LABEL_113: - */ - _vm->_soundManager.VERIF_SOUND(); - return _vm->_eventsManager.CONTROLE_MES(); -} - void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { int width, height; @@ -2391,4 +2141,65 @@ void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); } +void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int x2, int y2, byte *destSurface, int destX, int destY) { + int top; + int width; + int height; + int v11; + int height2; + int top2; + int left; + + left = x1; + top = y1; + width = x2; + height = y2; + + if (x1 < min_x) { + width = x2 - (min_x - x1); + left = min_x; + } + if (y1 < min_y) { + height = y2 - (min_y - y1); + top = min_y; + } + top2 = top; + if (top + height > max_y) + height = max_y - top; + v11 = left + width; + if (v11 > max_x) + width = max_x - left; + + if (width > 0 && height > 0) { + height2 = height; + Copy_Mem(surface, left, top2, width, height, destSurface, destX, destY); + Ajoute_Segment_Vesa(left, top2, left + width, top2 + height2); + } +} + +void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY) { + const byte *srcP; + byte *destP; + int yp; + int yCurrent; + byte *dest2P; + const byte *src2P; + unsigned int pitch; + + srcP = x1 + nbrligne2 * y1 + srcSurface; + destP = destX + nbrligne2 * destY + destSurface; + yp = height; + do { + yCurrent = yp; + memcpy(destP, srcP, 4 * (width >> 2)); + src2P = (srcP + 4 * (width >> 2)); + dest2P = (destP + 4 * (width >> 2)); + pitch = width - 4 * (width >> 2); + memcpy(dest2P, src2P, pitch); + destP = (dest2P + pitch + nbrligne2 - width); + srcP = (src2P + pitch + nbrligne2 - width); + yp = yCurrent - 1; + } while (yCurrent != 1); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 4f40d98af0faa54922e1321157335001a3457145 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Sep 2012 11:25:21 +1000 Subject: HOPKINS: Fix bug with clipping in Sprite_Vesa --- engines/hopkins/graphics.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 048d07241f..4d8a3b79a5 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1321,32 +1321,22 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, byte byteVal; int xc = 0; - // Loop through sequences of bytes to skip or output while ((byteVal = *srcP) != 253) { ++srcP; int width = READ_LE_UINT16(srcP); + srcP += 2; - if (byteVal != 254) { - // Skip over output bytes - tempDestP += width; - xc += width; - } else { - // Output byte range - while (width-- > 0) { - // Get the next byte - byteVal = *spriteP; + if (byteVal == 254) { + // Copy pixel range + for (int xv = 0; xv < width; ++xv, ++xc, ++spriteP, ++tempDestP) { if (clip_y == 0 && xc >= clip_x && xc < clip_x1) - // Not clipped, so display it - *tempDestP = byteVal; - - // Move to next pixel - xc++; - ++srcP; - ++tempDestP; + *tempDestP = *spriteP; } + } else { + // Skip over bytes + tempDestP += width; + xc += width; } - - srcP += 2; } if (clip_y > 0) -- cgit v1.2.3 From ddb4fdcf12f8a0e09d7f9b5583984edec99325cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Sep 2012 22:13:15 +1000 Subject: HOPKINS: Implementing font methods --- engines/hopkins/graphics.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4d8a3b79a5..d8ad4de283 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2192,4 +2192,53 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } while (yCurrent != 1); } +void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, + int characterIndex, int transColour) { + const byte *v6; + int i; + const byte *v8; + int v9; + int v10; + const byte *v11; + byte *destP; + int v13; + byte v14; + byte *destLineP; + int v16; + + v6 = spriteData + 3; + for (i = characterIndex; i; --i) + v6 += READ_LE_UINT32(v6) + 16; + + v9 = 0; + v10 = 0; + v8 = v6 + 4; + v9 = READ_LE_UINT16(v8); + v8 += 2; + v10 = READ_LE_UINT16(v8); + v11 = v8 + 10; + destP = surface + xp + nbrligne2 * yp; + Largeur = v9; + + do { + v16 = v10; + destLineP = destP; + v13 = v9; + do { + v14 = *v11; + if (*v11) { + if (v14 == (byte)-4) + v14 = transColour; + *destP = v14; + } + + ++destP; + ++v11; + --v13; + } while (v13); + destP = nbrligne2 + destLineP; + v10 = v16 - 1; + } while (v16 != 1); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 7c9ad56aac27ea9dc799abc50314a0cdaa3fe0d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Sep 2012 22:15:59 +1000 Subject: HOPKINS: Implemented many of the previously stubbed methods --- engines/hopkins/graphics.cpp | 133 +++++++++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 43 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d8ad4de283..e1d360e731 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -43,7 +43,7 @@ GraphicsManager::GraphicsManager() { nbrligne = 0; Linear = false; VideoPtr = NULL; - start_x = 0; + _vm->_eventsManager.start_x = 0; ofscroll = 0; SCROLL = 0; PCX_L = PCX_H = 0; @@ -262,7 +262,7 @@ void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { int GraphicsManager::SCROLL_ECRAN(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); - start_x = result; + _vm->_eventsManager.start_x = result; ofscroll = result; SCROLL = result; return result; @@ -325,6 +325,10 @@ void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, } while ( !breakFlag); } +void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { + warning("TODO: Trans_bloc2"); +} + // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { int filesize; @@ -811,9 +815,9 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface setpal_vga256(palData2); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } } @@ -824,9 +828,9 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface // Refresh the screen if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } } @@ -859,9 +863,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -880,9 +884,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -899,7 +903,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } goto LABEL_28; @@ -913,12 +917,12 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } LABEL_28: - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } } @@ -953,9 +957,9 @@ void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surfa if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -1494,17 +1498,17 @@ void GraphicsManager::Affiche_Segment_Vesa() { dstRect.top = bloc.y1 * 2 + 30; dstRect.setWidth((bloc.x2 - bloc.x1) * 2); dstRect.setHeight((bloc.y2 - bloc.y1) * 2); - } else if (bloc.x2 > start_x && bloc.x1 < (start_x + SCREEN_WIDTH)) { - if (bloc.x1 < start_x) - bloc.x1 = start_x; - if (bloc.x2 > (start_x + SCREEN_WIDTH)) - bloc.x2 = start_x + SCREEN_WIDTH; + } else if (bloc.x2 > _vm->_eventsManager.start_x && bloc.x1 < (_vm->_eventsManager.start_x + SCREEN_WIDTH)) { + if (bloc.x1 < _vm->_eventsManager.start_x) + bloc.x1 = _vm->_eventsManager.start_x; + if (bloc.x2 > (_vm->_eventsManager.start_x + SCREEN_WIDTH)) + bloc.x2 = _vm->_eventsManager.start_x + SCREEN_WIDTH; if (!SDL_ECHELLE) { // Calculate the bounds int xp = Magic_Number(bloc.x1) - 4; - if (xp < start_x) - xp = start_x; + if (xp < _vm->_eventsManager.start_x) + xp = _vm->_eventsManager.start_x; int yp = Magic_Number(bloc.y1) - 4; if (yp < 0) yp = 0; @@ -1515,30 +1519,30 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (height < 4) height = 4; - if ((xp - start_x + width) > SCREEN_WIDTH) + if ((xp - _vm->_eventsManager.start_x + width) > SCREEN_WIDTH) xp -= 4; if ((height - yp) > (SCREEN_HEIGHT - 40)) yp -= 4; if (Winbpp == 2) { m_scroll16A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } else { m_scroll2A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } - dstRect.left = Reel_Zoom(xp - start_x, SDL_ECHELLE); + dstRect.left = Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE); dstRect.top = Reel_Zoom(yp, SDL_ECHELLE); dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE)); dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE)); } else { if (Winbpp == 2) { m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - start_x, bloc.y1); + bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); } else { m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - start_x, bloc.y1); + bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); } } } @@ -2131,10 +2135,10 @@ void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); } -void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int x2, int y2, byte *destSurface, int destX, int destY) { +void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { int top; - int width; - int height; + int croppedWidth; + int croppedHeight; int v11; int height2; int top2; @@ -2142,28 +2146,28 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int x2, int y2, left = x1; top = y1; - width = x2; - height = y2; + croppedWidth = width; + croppedHeight = height; if (x1 < min_x) { - width = x2 - (min_x - x1); + croppedWidth = width - (min_x - x1); left = min_x; } if (y1 < min_y) { - height = y2 - (min_y - y1); + croppedHeight = height - (min_y - y1); top = min_y; } top2 = top; - if (top + height > max_y) - height = max_y - top; - v11 = left + width; + if (top + croppedHeight > max_y) + croppedHeight = max_y - top; + v11 = left + croppedWidth; if (v11 > max_x) - width = max_x - left; + croppedWidth = max_x - left; - if (width > 0 && height > 0) { - height2 = height; - Copy_Mem(surface, left, top2, width, height, destSurface, destX, destY); - Ajoute_Segment_Vesa(left, top2, left + width, top2 + height2); + if (croppedWidth > 0 && croppedHeight > 0) { + height2 = croppedHeight; + Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY); + Ajoute_Segment_Vesa(left, top2, left + croppedWidth, top2 + height2); } } @@ -2241,4 +2245,47 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x } while (v16 != 1); } +void GraphicsManager::INI_ECRAN(const Common::String &file) { + warning("TODO: INI_ECRAN"); +} + +void GraphicsManager::INI_ECRAN2(const Common::String &file) { + warning("TODO: INI_ECRAN2"); +} + +void GraphicsManager::NB_SCREEN() { + byte *v0; + const byte *v1; + + if (!_vm->_globals.NECESSAIRE) + INIT_TABLE(50, 65, Palette); + if (nbrligne == SCREEN_WIDTH) + Trans_bloc2(VESA_BUFFER, TABLE_COUL, 307200); + if (nbrligne == 1280) + Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400); + _vm->_graphicsManager.DD_Lock(); + if (Winbpp == 2) { + if (SDL_ECHELLE) + m_scroll16A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } + if (Winbpp == 1) { + if (SDL_ECHELLE) + m_scroll2A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll2(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + } + _vm->_graphicsManager.DD_Unlock(); + + v0 = VESA_SCREEN; + v1 = VESA_BUFFER; + memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu); + v1 = v1 + 614396; + v0 = v0 + 614396; + *v0 = *v1; + *(v0 + 2) = *(v1 + 2); + DD_VBL(); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 92313216dd0b9a42de528ccab02f87d1894dff2c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Sep 2012 09:33:42 +1000 Subject: HOPKINS: Implemented more graphics and object methods --- engines/hopkins/graphics.cpp | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index e1d360e731..dab66f1709 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -965,11 +965,44 @@ void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surfa } } +void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) { + _vm->_graphicsManager.Palette[palIndex * 3] = 255 * r / 100; + _vm->_graphicsManager.Palette[palIndex * 3 + 1] = 255 * g / 100; + _vm->_graphicsManager.Palette[palIndex * 3 + 2] = 255 * b / 100; + + setpal_vga256(Palette); +} + +void GraphicsManager::SETCOLOR2(int palIndex, int r, int g, int b) { + return SETCOLOR(palIndex, r, g, b); +} + void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { - int offset = palIndex * 3; - Palette[offset] = 255 * r / 100; - Palette[offset + 1] = 255 * g / 100; - Palette[offset + 2] = 255 * b / 100; + Palette[palIndex * 3] = 255 * r / 100; + Palette[palIndex * 3 + 1] = 255 * g / 100; + Palette[palIndex * 3 + 2] = 255 * b / 100; +} + +void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { + int rv, gv, bv; + int palOffset; + int v8; + + rv = 255 * r / 100; + gv = 255 * g / 100; + bv = 255 * b / 100; + palOffset = 3 * palIndex; + Palette[palOffset] = 255 * r / 100; + Palette[palOffset + 1] = gv; + Palette[palOffset + 2] = bv; + + v8 = 4 * palIndex; + cmap[v8] = rv; + cmap[v8 + 1] = gv; + cmap[v8 + 2] = bv; + + WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); + g_system->getPaletteManager()->setPalette(cmap, palIndex, 1); } void GraphicsManager::CHANGE_PALETTE(const byte *palette) { -- cgit v1.2.3 From 8fa33e7714fca1aeb80834ee5d97bcfdf8a3efb1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 21:02:39 +1000 Subject: HOPKINS: Implemented more object manager methods --- engines/hopkins/graphics.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index dab66f1709..96d81aa903 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -326,7 +326,17 @@ void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, } void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { - warning("TODO: Trans_bloc2"); + byte *dataP; + int count; + byte dataVal; + + dataP = surface; + count = size - 1; + do { + dataVal = *dataP++; + *(dataP - 1) = *(dataVal + col); + --count; + } while (count); } // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder @@ -2279,11 +2289,85 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x } void GraphicsManager::INI_ECRAN(const Common::String &file) { - warning("TODO: INI_ECRAN"); + OPTI_INI(file, 0); } void GraphicsManager::INI_ECRAN2(const Common::String &file) { - warning("TODO: INI_ECRAN2"); + OPTI_INI(file, 2); +} + +void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { + int v2; + unsigned int v3; + int v6; + unsigned int v9; + signed int v11; + byte *ptr; + Common::String v13; + + v2 = 1; + v3 = 0; + v9 = 0; + // TODO: Set extension as text + v13 = file + ".XXX"; // + #105#110#105; + + ptr = FileManager::RECHERCHE_CAT(v13, 1); + if (PTRNUL == ptr) { + FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + ptr = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + } + if (!a2) { + // 5ODO: Set extension as text + v13 = file + ".XXX"; //#115#112#114; + if (PTRNUL != _vm->_globals.SPRITE_ECRAN) + _vm->_globals.SPRITE_ECRAN = FileManager::LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + if (!_vm->_globals.NOSPRECRAN) { + _vm->_globals.SPRITE_ECRAN = FileManager::RECHERCHE_CAT(v13, 8); + if (_vm->_globals.SPRITE_ECRAN) { + _vm->_globals.CAT_FLAG = 0; + FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + } else { + _vm->_globals.CAT_FLAG = 1; + FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); + } + _vm->_globals.SPRITE_ECRAN = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.CAT_FLAG = 0; + } + } + if (*ptr != 73 || *(ptr + 1) != 78 || *(ptr + 2) != 73) { + error("Erreur, fichier non INI"); + } else { + v11 = 0; + do { + v6 = _vm->_objectsManager.Traduction(ptr + 20 * v2); + if (v6 == 2) + v2 = _vm->_objectsManager.Control_Goto((ptr + 20 * v2)); + if (v6 == 3) + v2 = _vm->_objectsManager.Control_If(ptr, v2); + if (v2 == -1) + error("fonction IFF d‚fectueuse"); + if (v6 == 1 || v6 == 4) + ++v2; + if (!v6 || v6 == 5) + v11 = 1; + } while (v11 != 1); + } + _vm->_globals.dos_free2(ptr); + if (a2 != 1) { + if (PTRNUL != _vm->_globals.COUCOU) + _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); + + v13 = file + ".XXX"; // #114#101#112 + byte *dataP = FileManager::RECHERCHE_CAT(v13, 2); + _vm->_globals.COUCOU = dataP; + if (PTRNUL == dataP) { + FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + dataP = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.COUCOU = dataP; + } + } + _vm->_objectsManager.FORCEZONE = 1; + _vm->_objectsManager.CHANGEVERBE = 0; } void GraphicsManager::NB_SCREEN() { @@ -2320,5 +2404,10 @@ void GraphicsManager::NB_SCREEN() { *(v0 + 2) = *(v1 + 2); DD_VBL(); } - +/* +int GraphicsManager::colision2_ligne(int a1, int a2, int a3, int a4, int a5, int a6) { + warning("TODO: colision2_ligne"); + return 0; +} +*/ } // End of namespace Hopkins -- cgit v1.2.3 From 84e07ae7253217c4b1ad650abdef57ffaa6b0032 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 21:21:09 +1000 Subject: HOPKINS: Changed all __int16 to int --- engines/hopkins/graphics.cpp | 144 +++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 96d81aa903..0fb3fedcad 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -342,13 +342,13 @@ void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { int filesize; - signed __int16 v6; + int v6; int v7; - __int16 v8; + int v8; int v9; int v10; int v11; - unsigned __int8 v12; + byte v12; int v13; int v14; char v15; @@ -846,18 +846,18 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface } void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { - __int16 v3; - __int16 v4; + int v3; + int v4; int v5; - signed __int16 v6; - __int16 v7; + int v6; + int v7; int v8; - __int16 v9; - __int16 v10; - __int16 v12; + int v9; + int v10; + int v12; uint16 v13; byte palData[PALETTE_BLOCK_SIZE]; - __int16 v15[PALETTE_BLOCK_SIZE]; + int v15[PALETTE_BLOCK_SIZE]; v13 = v3 = FADESPD; if (palette) { @@ -880,12 +880,12 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } v6 = 0; - if ((signed __int16)v13 > 0) { + if ((int)v13 > 0) { do { v7 = 0; do { v8 = v7; - v9 = v15[v7] - ((unsigned int)*(byte *)(v7 + palette) << 8) / (signed __int16)v13; + v9 = v15[v7] - ((unsigned int)*(byte *)(v7 + palette) << 8) / (int)v13; v15[v8] = v9; palData[v8] = (v9 >> 8) & 0xff; ++v7; @@ -901,7 +901,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac DD_VBL(); } ++v6; - } while ((signed __int16)v13 > v6); + } while ((int)v13 > v6); } v10 = 0; @@ -1083,7 +1083,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur return; if (v6 < 251) { - v3 += (unsigned __int8)(*(byte *)v5 + 35); + v3 += (byte)(*(byte *)v5 + 35); v6 = *(v5++ + 1); } else if (v6 == 253) { v3 += *(v5 + 1); @@ -1154,7 +1154,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { if (v5 == 252) return; if (v5 < 251) { - v2 += (unsigned __int8)(*v4 + 35); + v2 += (byte)(*v4 + 35); v5 = *(v4++ + 1); } else if (v5 == -3) { v2 += *(v4 + 1); @@ -1182,7 +1182,7 @@ Video_Cont3_Vbe: v3 = v6; } else { v9 = v3; - v10 = (unsigned __int8)(*v4 + 45); + v10 = (byte)(*v4 + 45); result = *(v4 + 1); v11 = (byte *)(v2 + (byte *)VideoPtr->pixels); v2 += v10; @@ -1764,15 +1764,15 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in clip_x = clip_y = 0; clip_x1 = clip_y1 = 0; - if ((unsigned __int16)a3 > min_x) { - if ((unsigned __int16)a3 < (unsigned __int16)(min_x + 300)) + if (a3 > min_x) { + if ((uint)a3 < (uint)(min_x + 300)) clip_x = min_x + 300 - a3; - if ((unsigned __int16)a4 > min_y) { - if ((unsigned __int16)a4 < (unsigned __int16)(min_y + 300)) + if (a4 > min_y) { + if ((uint)a4 < (uint)(min_y + 300)) clip_y = min_y + 300 - a4; - if ((unsigned __int16)a3 < (unsigned __int16)(max_x + 300)) { + if ((uint)a3 < (uint)(max_x + 300)) { clip_x1 = max_x + 300 - a3; - if ((unsigned __int16)a4 < (unsigned __int16)(max_y + 300)) { + if ((uint)a4 < (uint)(max_y + 300)) { clip_y1 = max_y + 300 - a4; v14 = a3 + nbrligne2 * (a4 - 300) - 300 + destSurface; @@ -1789,31 +1789,31 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in if (a8) { v29 = v20 + v14; if (clip_y) { - if ((unsigned __int16)clip_y >= v22) + if (clip_y >= v22) return; v61 = v22; v52 = v20; v30 = 0; - v31 = (unsigned __int16)clip_y; + v31 = (uint)clip_y; while (Asm_Zoom(v30 + 1, a7) < v31) ; v20 = v52; v13 += Largeur * v30; - v29 += nbrligne2 * (unsigned __int16)clip_y; - v22 = v61 - (unsigned __int16)clip_y; + v29 += nbrligne2 * (uint)clip_y; + v22 = v61 - (uint)clip_y; } - if (v22 > (unsigned __int16)clip_y1) - v22 = (unsigned __int16)clip_y1; + if (v22 > clip_y1) + v22 = clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v20) + if (clip_x >= v20) return; - v20 -= (unsigned __int16)clip_x; + v20 -= (uint)clip_x; } - if (v20 > (unsigned __int16)clip_x1) { - v32 = v20 - (unsigned __int16)clip_x1; + if (v20 > clip_x1) { + v32 = v20 - clip_x1; v29 -= v32; v62 = v22; v33 = 0; @@ -1823,7 +1823,7 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in v34 = v33; v22 = v62; v13 += v34; - v20 = (unsigned __int16)clip_x1; + v20 = (uint)clip_x1; } do { @@ -1844,7 +1844,7 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in if (!Agr_Flag_x) Agr_x = a7 + Agr_x; - if ((unsigned __int16)Agr_x < 100) + if ((uint)Agr_x < 100) break; Agr_x = Agr_x - 100; @@ -1866,7 +1866,7 @@ R_Aff_Zoom_Larg_Cont1: if (!(uint16)Agr_Flag_y) Agr_y = a7 + Agr_y; - if ((unsigned __int16)Agr_y < 100) + if ((uint)Agr_y < 100) break; Agr_y = Agr_y - 100; @@ -1882,30 +1882,30 @@ R_Aff_Zoom_Larg_Cont1: } while (v63 != 1); } else { if (clip_y) { - if ((unsigned __int16)clip_y >= v22) + if (clip_y >= v22) return; v58 = v22; v49 = v20; v23 = 0; - v24 = (unsigned __int16)clip_y; + v24 = (uint)clip_y; while (Asm_Zoom(v23 + 1, a7) < v24) ; v20 = v49; v13 += Largeur * v23; - v14 += nbrligne2 * (unsigned __int16)clip_y; - v22 = v58 - (unsigned __int16)clip_y; + v14 += nbrligne2 * (uint)clip_y; + v22 = v58 - (uint)clip_y; } - if (v22 > (unsigned __int16)clip_y1) - v22 = (unsigned __int16)clip_y1; + if (v22 > clip_y1) + v22 = clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v20) + if (clip_x >= v20) return; v59 = v22; v50 = v20; - v25 = (unsigned __int16)clip_x; + v25 = (uint)clip_x; v26 = 0; while (Asm_Zoom(v26 + 1, a7) < v25) @@ -1913,12 +1913,12 @@ R_Aff_Zoom_Larg_Cont1: v27 = v26; v22 = v59; v13 += v27; - v14 += (unsigned __int16)clip_x; - v20 = v50 - (unsigned __int16)clip_x; + v14 += (uint)clip_x; + v20 = v50 - (uint)clip_x; } - if (v20 > (unsigned __int16)clip_x1) - v20 = (unsigned __int16)clip_x1; + if (v20 > clip_x1) + v20 = clip_x1; do { for (;;) { @@ -1938,7 +1938,7 @@ R_Aff_Zoom_Larg_Cont1: if (!Agr_Flag_x) Agr_x = a7 + Agr_x; - if ((unsigned __int16)Agr_x < 100) + if ((uint)Agr_x < 100) break; Agr_x = Agr_x - 100; @@ -1961,7 +1961,7 @@ Aff_Zoom_Larg_Cont1: if (!(uint16)Agr_Flag_y) Agr_y = a7 + Agr_y; - if ((unsigned __int16)Agr_y < 100) + if ((uint)Agr_y < 100) break; Agr_y = Agr_y - 100; @@ -1984,7 +1984,7 @@ Aff_Zoom_Larg_Cont1: Largeur = v11; Red = a6; - if ((unsigned __int16)a6 < 100) { + if ((uint)a6 < 100) { v37 = Asm_Reduc(v11, Red); if (a8) { v40 = v37 + v14; @@ -1994,7 +1994,7 @@ Aff_Zoom_Larg_Cont1: v55 = v40; Red_y = Red + Red_y; - if ((unsigned __int16)Red_y < 100) { + if ((uint)Red_y < 100) { Red_x = 0; v41 = Largeur; v42 = v37; @@ -2029,14 +2029,14 @@ Aff_Zoom_Larg_Cont1: v54 = v14; Red_y = Red + Red_y; - if ((unsigned __int16)Red_y < 100) { + if ((uint)Red_y < 100) { Red_x = 0; v38 = Largeur; v39 = 0; do { Red_x = Red + Red_x; - if ((unsigned __int16)Red_x < 100) { + if ((uint)Red_x < 100) { if (v39 >= clip_x && v39 < clip_x1 && *v13) *v14 = *v13; ++v14; @@ -2068,14 +2068,14 @@ Aff_Zoom_Larg_Cont1: v16 = v11 + v14; spec_largeur = v11; if (clip_y) { - if ((unsigned __int16)clip_y >= (unsigned int)v12) + if ((uint)clip_y >= (unsigned int)v12) return; - v13 += v11 * (unsigned __int16)clip_y; - v16 += nbrligne2 * (unsigned __int16)clip_y; - v12 -= (unsigned __int16)clip_y; + v13 += v11 * (uint)clip_y; + v16 += nbrligne2 * (uint)clip_y; + v12 -= (uint)clip_y; } - v17 = (unsigned __int16)clip_y1; + v17 = (uint)clip_y1; if (v12 > clip_y1) v12 = clip_y1; @@ -2086,11 +2086,11 @@ Aff_Zoom_Larg_Cont1: v11 -= v17; } - if (v11 > (unsigned __int16)clip_x1) { - v18 = v11 - (unsigned __int16)clip_x1; + if (v11 > clip_x1) { + v18 = v11 - clip_x1; v13 += v18; v16 -= v18; - v11 = (unsigned __int16)clip_x1; + v11 = (uint)clip_x1; } do { @@ -2114,27 +2114,27 @@ Aff_Zoom_Larg_Cont1: } else { spec_largeur = v11; if (clip_y) { - if ((unsigned __int16)clip_y >= (unsigned int)v12) + if ((uint)clip_y >= (unsigned int)v12) return; - v13 += v11 * (unsigned __int16)clip_y; - v14 += nbrligne2 * (unsigned __int16)clip_y; - v12 -= (unsigned __int16)clip_y; + v13 += v11 * (uint)clip_y; + v14 += nbrligne2 * (uint)clip_y; + v12 -= (uint)clip_y; } if (v12 > clip_y1) v12 = clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v11) + if (clip_x >= v11) return; - v13 += (unsigned __int16)clip_x; - v14 += (unsigned __int16)clip_x; - v11 -= (unsigned __int16)clip_x; + v13 += (uint)clip_x; + v14 += (uint)clip_x; + v11 -= (uint)clip_x; } - if (v11 > (unsigned __int16)clip_x1) - v11 = (unsigned __int16)clip_x1; + if (v11 > clip_x1) + v11 = clip_x1; do { v56 = v12; -- cgit v1.2.3 From b34091852c2f2994ac82aeb0e0ace8550508eaaa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 21:33:00 +1000 Subject: HOPKINS: Fix casting errors identified by gcc --- engines/hopkins/graphics.cpp | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0fb3fedcad..896a393f35 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -521,8 +521,8 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i v11 = (byte *)(v8 + 4 * (width >> 2)); v13 = width - 4 * (width >> 2); memcpy(v11, v12, v13); - v8 = ((byte *)v11 + v13 + WinScan - width); - v7 = ((byte *)v12 + v13 + nbrligne2 - width); + v8 = v11 + v13 + WinScan - width; + v7 = v12 + v13 + nbrligne2 - width; v9 = v10 - 1; } while (v10 != 1); } @@ -535,28 +535,28 @@ void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int v11; assert(VideoPtr); - v7 = (const byte *)(xs + nbrligne2 * ys + surface); - v8 = (byte *)(destX + WinScan * destY + (byte *)VideoPtr->pixels); + v7 = xs + nbrligne2 * ys + surface; + v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; v9 = WinScan - SCREEN_WIDTH; v10 = nbrligne2 - SCREEN_WIDTH; v11 = height; do { memcpy(v8, v7, SCREEN_WIDTH); - v8 = (byte *)v8 + v9 + SCREEN_WIDTH; - v7 = (const byte *)v7 + v10 + SCREEN_WIDTH; + v8 = v8 + v9 + SCREEN_WIDTH; + v7 = v7 + v10 + SCREEN_WIDTH; --v11; } while (v11); } void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { const byte *v7; - const byte *v8; + byte *v8; int v9; int v10; byte v11; const byte *v12; - const byte *v13; + byte *v13; assert(VideoPtr); v7 = xs + nbrligne2 * ys + surface; @@ -572,12 +572,12 @@ void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, v10 = width; Agr_x = 0; do { - v11 = *(byte *)v7; - *(byte *)v8++ = *(byte *)v7++; + v11 = *v7; + *v8++ = *v7++; Agr_x += SDL_ECHELLE; if ((unsigned int)Agr_x >= 100) { Agr_x -= 100; - *(byte *)v8++ = v11; + *v8++ = v11; } --v10; } while ( v10 ); @@ -864,10 +864,10 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac v4 = 0; do { v5 = v4; - v3 = *(byte *)(v4 + palette); + v3 = *(v4 + palette); v3 <<= 8; v15[v5] = v3; - palData[v5] = *(byte *)(v4++ + palette); + palData[v5] = *(v4++ + palette); } while (v4 < PALETTE_BLOCK_SIZE); setpal_vga256(palData); @@ -885,7 +885,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac v7 = 0; do { v8 = v7; - v9 = v15[v7] - ((unsigned int)*(byte *)(v7 + palette) << 8) / (int)v13; + v9 = v15[v7] - (*(v7 + palette) << 8) / v13; v15[v8] = v9; palData[v8] = (v9 >> 8) & 0xff; ++v7; @@ -1076,14 +1076,14 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur v5 = sourceSurface; for (;;) { v6 = *v5; - if (*(byte *)v5 < 222) + if (*v5 < 222) goto Video_Cont3_wVbe; if (v6 == 252) return; if (v6 < 251) { - v3 += (byte)(*(byte *)v5 + 35); + v3 += *v5 + 35; v6 = *(v5++ + 1); } else if (v6 == 253) { v3 += *(v5 + 1); @@ -1154,7 +1154,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { if (v5 == 252) return; if (v5 < 251) { - v2 += (byte)(*v4 + 35); + v2 += *v4 + 35; v5 = *(v4++ + 1); } else if (v5 == -3) { v2 += *(v4 + 1); @@ -1370,7 +1370,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - int width = READ_LE_UINT16(srcP); + width = READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { @@ -1398,7 +1398,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - int width = READ_LE_UINT16(srcP); + width = READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { @@ -1617,14 +1617,14 @@ void GraphicsManager::CopyAsm(const byte *surface) { v5 = 320; do { - srcByte = *(byte *)v1; - *(byte *)v3 = *(byte *)v1; + srcByte = *v1; + *v3 = *v1; v6 = WinScan + v3; - *(byte *)v6 = srcByte; + *v6 = srcByte; v7 = v6 - WinScan + 1; - *(byte *)v7 = srcByte; + *v7 = srcByte; v8 = WinScan + v7; - *(byte *)v8 = srcByte; + *v8 = srcByte; v3 = v8 - WinScan + 1; ++v1; --v5; -- cgit v1.2.3 From 1f87e4836a3fef4317fe5491ba6b075c8ff9c381 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 21:41:47 +1000 Subject: HOPKINS: Fixed some more castings identified by gcc --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 896a393f35..f99b0a1990 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -656,7 +656,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width Agr_x = 0; do { - v12 = *(uint16 *)(v11 + 2 * *(byte *)v7); + v12 = *(uint16 *)(v11 + 2 * *v7); *(uint16 *)v8 = v12; ++v7; v8 += 2; @@ -1156,11 +1156,11 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { if (v5 < 251) { v2 += *v4 + 35; v5 = *(v4++ + 1); - } else if (v5 == -3) { + } else if (v5 == (byte)-3) { v2 += *(v4 + 1); v5 = *(v4 + 2); v4 += 2; - } else if (v5 == -2) { + } else if (v5 == (byte)-2) { v2 += READ_LE_UINT16(v4 + 1); v5 = *(v4 + 3); v4 += 3; -- cgit v1.2.3 From 7eb6fffdbd6315ad68f424a99c643d8966fcef12 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 22:18:50 +1000 Subject: HOPKINS: Converted many numeric values to character constants --- engines/hopkins/graphics.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f99b0a1990..3ee0d2c115 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2308,17 +2308,15 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { v2 = 1; v3 = 0; v9 = 0; - // TODO: Set extension as text - v13 = file + ".XXX"; // + #105#110#105; + v13 = file + ".ini"; ptr = FileManager::RECHERCHE_CAT(v13, 1); if (PTRNUL == ptr) { FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); ptr = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); } if (!a2) { - // 5ODO: Set extension as text - v13 = file + ".XXX"; //#115#112#114; + v13 = file + ".spr"; if (PTRNUL != _vm->_globals.SPRITE_ECRAN) _vm->_globals.SPRITE_ECRAN = FileManager::LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { @@ -2334,8 +2332,8 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { _vm->_globals.CAT_FLAG = 0; } } - if (*ptr != 73 || *(ptr + 1) != 78 || *(ptr + 2) != 73) { - error("Erreur, fichier non INI"); + if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { + error("Error, file not ini"); } else { v11 = 0; do { @@ -2345,7 +2343,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { if (v6 == 3) v2 = _vm->_objectsManager.Control_If(ptr, v2); if (v2 == -1) - error("fonction IFF d‚fectueuse"); + error("Error, defective IFF"); if (v6 == 1 || v6 == 4) ++v2; if (!v6 || v6 == 5) @@ -2357,7 +2355,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { if (PTRNUL != _vm->_globals.COUCOU) _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); - v13 = file + ".XXX"; // #114#101#112 + v13 = file + ".rep"; byte *dataP = FileManager::RECHERCHE_CAT(v13, 2); _vm->_globals.COUCOU = dataP; if (PTRNUL == dataP) { -- cgit v1.2.3 From c306fe01a6a0bb018caa5d5b2f7ba636c974dbee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 30 Sep 2012 22:41:10 +1000 Subject: HOPKINS: Fixed compilation errors with previously commented out methods --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3ee0d2c115..b4810d3af2 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2402,10 +2402,10 @@ void GraphicsManager::NB_SCREEN() { *(v0 + 2) = *(v1 + 2); DD_VBL(); } -/* -int GraphicsManager::colision2_ligne(int a1, int a2, int a3, int a4, int a5, int a6) { + +int GraphicsManager::colision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6) { warning("TODO: colision2_ligne"); return 0; } -*/ + } // End of namespace Hopkins -- cgit v1.2.3 From 28099ee00d2351a7b86646cc63c90cd953e8032b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 2 Oct 2012 21:44:23 +1000 Subject: HOPKINS: Added new LinesManager class with lots of line methods --- engines/hopkins/graphics.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b4810d3af2..76782cf4d8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2403,9 +2403,4 @@ void GraphicsManager::NB_SCREEN() { DD_VBL(); } -int GraphicsManager::colision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6) { - warning("TODO: colision2_ligne"); - return 0; -} - } // End of namespace Hopkins -- cgit v1.2.3 From bc863bd24194a3578505dd151fc3a981a98dbc45 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Oct 2012 22:15:39 +1000 Subject: HOPKINS: Implemented more stubbed object manager methods --- engines/hopkins/graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 76782cf4d8..38193e62c5 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2403,4 +2403,8 @@ void GraphicsManager::NB_SCREEN() { DD_VBL(); } +void GraphicsManager::SHOW_PALETTE() { + warning("TODO: SHOW_PALETTE"); +} + } // End of namespace Hopkins -- cgit v1.2.3 From a404f86a384dd98881725617be87757920843b18 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 4 Oct 2012 07:27:34 +1000 Subject: HOPKINS: Implemented more previously stubbed object manager methods --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 38193e62c5..787400ae52 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2404,7 +2404,7 @@ void GraphicsManager::NB_SCREEN() { } void GraphicsManager::SHOW_PALETTE() { - warning("TODO: SHOW_PALETTE"); + setpal_vga256(Palette); } } // End of namespace Hopkins -- cgit v1.2.3 From 52166834d5e84c6a20e1782489d6ae0623ae5aaa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Oct 2012 00:55:25 +1000 Subject: HOPKINS: Implemented lots more of the remaining stubbed methods --- engines/hopkins/graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 787400ae52..e4a5c1100d 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2407,4 +2407,8 @@ void GraphicsManager::SHOW_PALETTE() { setpal_vga256(Palette); } +void GraphicsManager::videkey() { + // Empty in original +} + } // End of namespace Hopkins -- cgit v1.2.3 From 86bf409540a6a7767bd57f51c134bf1ff21ae1ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 5 Oct 2012 08:09:09 +1000 Subject: HOPKINS: Implemented sequence player --- engines/hopkins/graphics.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index e4a5c1100d..f54649f976 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1258,6 +1258,39 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { } } +void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { + int v2; + const byte *v3; + unsigned __int8 v4; + + v2 = 0; + v3 = surface; + for (;;) { + v4 = *v3; + if (*v3 < 0xFCu) + goto Video_Cont_Vbe16a; + if (v4 == -4) + return; + if (v4 == -3) { + v2 += *(v3 + 1); + v4 = *(v3 + 2); + v3 += 2; + } else if (v4 == -2) { + v2 += READ_LE_UINT16(v3 + 1); + v4 = *(v3 + 3); + v3 += 3; + } else { + v2 += READ_LE_UINT32(v3 + 1); + v4 = *(v3 + 5); + v3 += 5; + } +Video_Cont_Vbe16a: + WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); + ++v3; + ++v2; + } +} + void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, unsigned int width, int height) { const byte *srcP; byte *destP; @@ -2411,4 +2444,73 @@ void GraphicsManager::videkey() { // Empty in original } +void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { + int result; + int destOffset; + const byte *srcPtr; + byte byteVal; + + result = 0; + destOffset = 0; + srcPtr = src; + while (1) { + byteVal = *srcPtr; + if (*srcPtr < 0xFCu) + goto Video_Cont_wVbe; + if (byteVal == (byte)-4) + return; + if (byteVal == (byte)-3) { + destOffset += *(srcPtr + 1); + byteVal = *(srcPtr + 2); + srcPtr += 2; + } else if (byteVal == (byte)-2) { + destOffset += READ_LE_UINT16(srcPtr + 1); + byteVal = *(srcPtr + 3); + srcPtr += 3; + } else { + destOffset += READ_LE_UINT32(srcPtr + 1); + byteVal = *(srcPtr + 5); + srcPtr += 5; + } +Video_Cont_wVbe: + *(dest + destOffset) = byteVal; + ++srcPtr; + ++destOffset; + } +} + +void GraphicsManager::Copy_Video_Vbe(const byte *src) { + int destOffset; + const byte *srcP; + byte byteVal; + + assert(VideoPtr); + destOffset = 0; + srcP = src; + while (1) { + byteVal = *srcP; + if (*srcP < 0xFCu) + goto Video_Cont_Vbe; + if (byteVal == -4) + return; + if (byteVal == -3) { + destOffset += *(srcP + 1); + byteVal = *(srcP + 2); + srcP += 2; + } else if (byteVal == -2) { + destOffset += READ_LE_UINT16(srcP + 1); + byteVal = *(srcP + 3); + srcP += 3; + } else { + destOffset += READ_LE_UINT32(srcP + 1); + byteVal = *(srcP + 5); + srcP += 5; + } +Video_Cont_Vbe: + *((byte *)VideoPtr->pixels + destOffset) = byteVal; + ++srcP; + ++destOffset; + } +} + } // End of namespace Hopkins -- cgit v1.2.3 From fc9fc47e5f12665e8e24b5f40a05a546ff3666fc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Oct 2012 00:45:07 +1000 Subject: HOPKINS: Implemented stubbed menu methods --- engines/hopkins/graphics.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f54649f976..9a93b8eca9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2513,4 +2513,53 @@ Video_Cont_Vbe: } } +// TODO: Check that v9 doesn't get set anywhere (apart from the current init to zero) +void GraphicsManager::Reduc_Ecran(byte *a1, byte *a2, int a3, int a4, int a5, int a6, int a7) { + byte *v7; + byte *v8; + int v9 = 0; + int v10 = 0; + int v11; + int v12; + byte *v13; + int v14; + + v7 = a3 + nbrligne2 * a4 + a1; + v8 = a2; + Red = a7; + Largeur = a5; + Red_x = 0; + Red_y = 0; + if (a7 < 100) { + Reduc_Ecran_L = Asm_Reduc(a5, Red); + Reduc_Ecran_H = Asm_Reduc(v9, Red); + v11 = Red; + do { + v14 = v10; + v13 = v7; + Red_y += v11; + if ((uint16)Red_y < 0x64u) { + Red_x = 0; + v12 = Largeur; + do { + Red_x += v11; + if ((uint16)Red_x < 0x64u) { + *v8++ = *v7++; + } else { + Red_x = Red_x - 100; + ++v7; + } + --v12; + } while (v12); + v10 = v14; + v7 = nbrligne2 + v13; + } else { + Red_y = Red_y - 100; + v7 += nbrligne2; + } + --v10; + } while (v10); + } +} + } // End of namespace Hopkins -- cgit v1.2.3 From b718039a8a1041b70db56be5c76e876f8c130079 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Oct 2012 00:52:52 +1000 Subject: HOPKINS: Bugfixes for startup manager initialisations --- engines/hopkins/graphics.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9a93b8eca9..64013cd215 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -43,7 +43,6 @@ GraphicsManager::GraphicsManager() { nbrligne = 0; Linear = false; VideoPtr = NULL; - _vm->_eventsManager.start_x = 0; ofscroll = 0; SCROLL = 0; PCX_L = PCX_H = 0; -- cgit v1.2.3 From 575f179f0f3fc62d4173115c141c6641f794c9ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Oct 2012 23:21:10 +1000 Subject: HOPKINS: Converted the file manager from static to a standard manager class --- engines/hopkins/graphics.cpp | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 64013cd215..851768a6b9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -79,8 +79,8 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { - GLOBALS.dos_free2(VESA_SCREEN); - GLOBALS.dos_free2(VESA_BUFFER); + _vm->_globals.dos_free2(VESA_SCREEN); + _vm->_globals.dos_free2(VESA_BUFFER); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -91,21 +91,21 @@ void GraphicsManager::SET_MODE(int width, int height) { if (!SDL_MODEYES) { SDL_ECHELLE = 0; - if (GLOBALS.XSETMODE == 1) + if (_vm->_globals.XSETMODE == 1) SDL_ECHELLE = 0; - if (GLOBALS.XSETMODE == 2) + if (_vm->_globals.XSETMODE == 2) SDL_ECHELLE = 25; - if (GLOBALS.XSETMODE == 3) + if (_vm->_globals.XSETMODE == 3) SDL_ECHELLE = 50; - if (GLOBALS.XSETMODE == 4) + if (_vm->_globals.XSETMODE == 4) SDL_ECHELLE = 75; - if (GLOBALS.XSETMODE == 5) - SDL_ECHELLE = GLOBALS.XZOOM; + if (_vm->_globals.XSETMODE == 5) + SDL_ECHELLE = _vm->_globals.XZOOM; int bpp = 8; - if (GLOBALS.XFORCE8 == 1) + if (_vm->_globals.XFORCE8 == 1) bpp = 8; - if (GLOBALS.XFORCE16 == 1) + if (_vm->_globals.XFORCE16 == 1) bpp = 16; if (SDL_ECHELLE) { @@ -122,8 +122,8 @@ void GraphicsManager::SET_MODE(int width, int height) { } // Init surfaces - VESA_SCREEN = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - VESA_BUFFER = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + VESA_SCREEN = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + VESA_BUFFER = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); VideoPtr = NULL; XSCREEN = width; @@ -174,12 +174,12 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { bool flag; Common::File f; - FileManager::DMESS1(); + _vm->_fileManager.DMESS1(); flag = true; - if (FileManager::RECHERCHE_CAT(file, 6)) { - FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file); - if (!f.open(GLOBALS.NFICHIER)) + if (_vm->_fileManager.RECHERCHE_CAT(file, 6)) { + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + if (!f.open(_vm->_globals.NFICHIER)) error("CHARGE_ECRAN - %s", file.c_str()); f.seek(0, SEEK_END); @@ -364,12 +364,12 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); if (typeFlag) { - FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, "PIC.RES"); - if (!f.open(GLOBALS.NFICHIER)) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES"); + if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); - f.seek(GLOBALS.CAT_POSI); + f.seek(_vm->_globals.CAT_POSI); - v7 = GLOBALS.CAT_TAILLE - 896; + v7 = _vm->_globals.CAT_TAILLE - 896; v8 = f.read(HEADER_PCX, 128); v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1; @@ -387,8 +387,8 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (v8 == -1) error("Erreur en cours de lecture."); } else { - FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file); - if (!f.open(GLOBALS.NFICHIER)) + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); filesize = f.size(); @@ -411,7 +411,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by v7 = filesize - 896; } - ptr = GLOBALS.dos_malloc2(0xEE60u); + ptr = _vm->_globals.dos_malloc2(0xEE60u); if (v7 >= 60000) { v21 = v7 / 60000 + 1; v23 = 60000 * (v7 / 60000) - v7; @@ -470,7 +470,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by } while (v18 < v19 * v20); if (typeFlag) { - f.seek(GLOBALS.CAT_TAILLE + GLOBALS.CAT_POSI - 768); + f.seek(_vm->_globals.CAT_TAILLE + _vm->_globals.CAT_POSI - 768); } else { filesize = f.size(); f.seek(filesize - 768); @@ -480,7 +480,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by error("A_PCX640_480"); f.close(); - GLOBALS.dos_free2(ptr); + _vm->_globals.dos_free2(ptr); } void GraphicsManager::Cls_Pal() { @@ -2342,25 +2342,25 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { v9 = 0; v13 = file + ".ini"; - ptr = FileManager::RECHERCHE_CAT(v13, 1); + ptr = _vm->_fileManager.RECHERCHE_CAT(v13, 1); if (PTRNUL == ptr) { - FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); - ptr = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); } if (!a2) { v13 = file + ".spr"; if (PTRNUL != _vm->_globals.SPRITE_ECRAN) - _vm->_globals.SPRITE_ECRAN = FileManager::LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { - _vm->_globals.SPRITE_ECRAN = FileManager::RECHERCHE_CAT(v13, 8); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(v13, 8); if (_vm->_globals.SPRITE_ECRAN) { _vm->_globals.CAT_FLAG = 0; - FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); } else { _vm->_globals.CAT_FLAG = 1; - FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = 0; } } @@ -2388,11 +2388,11 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); v13 = file + ".rep"; - byte *dataP = FileManager::RECHERCHE_CAT(v13, 2); + byte *dataP = _vm->_fileManager.RECHERCHE_CAT(v13, 2); _vm->_globals.COUCOU = dataP; if (PTRNUL == dataP) { - FileManager::CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); - dataP = FileManager::CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); _vm->_globals.COUCOU = dataP; } } -- cgit v1.2.3 From 7ca9d2100f3fe0b9d23497bbd9c4885f9b3a92b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Oct 2012 21:03:29 +1100 Subject: HOPKINS: Changed PTRNUL from being 0 to an explicitly allocated pointer. Some of the methods explicitly differentiate between having a 0 result for invalid/abort versus PTRNUL return values --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 851768a6b9..04c43c966b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2343,13 +2343,13 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { v13 = file + ".ini"; ptr = _vm->_fileManager.RECHERCHE_CAT(v13, 1); - if (PTRNUL == ptr) { + if (g_PTRNUL == ptr) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); } if (!a2) { v13 = file + ".spr"; - if (PTRNUL != _vm->_globals.SPRITE_ECRAN) + if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(v13, 8); @@ -2384,13 +2384,13 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { } _vm->_globals.dos_free2(ptr); if (a2 != 1) { - if (PTRNUL != _vm->_globals.COUCOU) + if (g_PTRNUL != _vm->_globals.COUCOU) _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); v13 = file + ".rep"; byte *dataP = _vm->_fileManager.RECHERCHE_CAT(v13, 2); _vm->_globals.COUCOU = dataP; - if (PTRNUL == dataP) { + if (g_PTRNUL == dataP) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); _vm->_globals.COUCOU = dataP; -- cgit v1.2.3 From d0487f5d9f8cc481ac6a8d1e1752fbb112cdffc6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Oct 2012 22:33:44 +1100 Subject: HOPKINS: Bugfix to not call core setPalette in 16-bit mode --- engines/hopkins/graphics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 04c43c966b..0761c45149 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1011,7 +1011,9 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { cmap[v8 + 2] = bv; WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); - g_system->getPaletteManager()->setPalette(cmap, palIndex, 1); + + if (Winbpp == 1) + g_system->getPaletteManager()->setPalette(cmap, palIndex, 1); } void GraphicsManager::CHANGE_PALETTE(const byte *palette) { @@ -2343,7 +2345,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { v13 = file + ".ini"; ptr = _vm->_fileManager.RECHERCHE_CAT(v13, 1); - if (g_PTRNUL == ptr) { + if (ptr == g_PTRNUL) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); } -- cgit v1.2.3 From d8dd04130a3ea4018f26467f86a9e0bebe24bf5c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 11 Oct 2012 22:53:59 +1100 Subject: HOPKINS: Implemented missing BOITE function in the font manager --- engines/hopkins/graphics.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0761c45149..9fda73fc95 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2563,4 +2563,22 @@ void GraphicsManager::Reduc_Ecran(byte *a1, byte *a2, int a3, int a4, int a5, in } } +void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int width, byte col) { + memset(surface + xp + nbrligne2 * yp, col, width); +} + +void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, char col) { + byte *v5; + int v6; + + v5 = surface + xp + nbrligne2 * yp; + v6 = height; + do { + *v5 = col; + v5 += nbrligne2; + --v6; + } while (v6); +} + + } // End of namespace Hopkins -- cgit v1.2.3 From 721b619398af28037cc595300052af430b9b31a5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 11 Oct 2012 22:58:04 +1100 Subject: HOPKINS: Added explicit int16 cast to all READ_LE_UINT16 accesses. I've already previously fixed two initialisatoin errors for data reading that expected int's to be 16 bits and signed, so adding the explicit cast everywhere will likely fix other similiar issues. --- engines/hopkins/graphics.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9fda73fc95..4912849344 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -372,9 +372,9 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by v7 = _vm->_globals.CAT_TAILLE - 896; v8 = f.read(HEADER_PCX, 128); - v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1; - v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1; - if ((READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) { + v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1; + v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1; + if (((int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) { DOUBLE_ECRAN = false; } else { v6 = SCREEN_WIDTH * 2; @@ -396,8 +396,8 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (bytesRead < 128) error("Erreur en cours de lecture."); - v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1; - v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1; + v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1; + v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1; if (v6 <= SCREEN_WIDTH) { DOUBLE_ECRAN = false; } else { @@ -1091,7 +1091,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur v6 = *(v5 + 2); v5 += 2; } else if (v6 == 254) { - v3 += READ_LE_UINT16(v5 + 1); + v3 += (int16)READ_LE_UINT16(v5 + 1); v6 = *(v5 + 3); v5 += 3; } else { @@ -1162,7 +1162,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { v5 = *(v4 + 2); v4 += 2; } else if (v5 == (byte)-2) { - v2 += READ_LE_UINT16(v4 + 1); + v2 += (int16)READ_LE_UINT16(v4 + 1); v5 = *(v4 + 3); v4 += 3; } else { @@ -1217,7 +1217,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { srcByte = *(const byte *)(srcP + 2); srcP += 2; } else if (srcByte == 254) { - destOffset += READ_LE_UINT16(srcP + 1); + destOffset += (int16)READ_LE_UINT16(srcP + 1); srcByte = *(const byte *)(srcP + 3); srcP += 3; } else { @@ -1277,7 +1277,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { v4 = *(v3 + 2); v3 += 2; } else if (v4 == -2) { - v2 += READ_LE_UINT16(v3 + 1); + v2 += (int16)READ_LE_UINT16(v3 + 1); v4 = *(v3 + 3); v3 += 3; } else { @@ -1286,7 +1286,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { v3 += 5; } Video_Cont_Vbe16a: - WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); + WRITE_LE_UINT16(v2 + v2 + VideoPtr, (int16)READ_LE_UINT16(PAL_PIXELS + 2 * v4)); ++v3; ++v2; } @@ -1336,9 +1336,9 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, clip_flag = false; spriteP += 4; - int width = READ_LE_UINT16(spriteP); + int width = (int16)READ_LE_UINT16(spriteP); spriteP += 2; - int height = READ_LE_UINT16(spriteP); + int height = (int16)READ_LE_UINT16(spriteP); // Clip X clip_x1 = width; @@ -1386,7 +1386,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Set up source spriteP += 6; - int srcOffset = READ_LE_UINT16(spriteP); + int srcOffset = (int16)READ_LE_UINT16(spriteP); spriteP += 4; const byte *srcP = spriteP; spriteP += srcOffset; @@ -1404,7 +1404,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - width = READ_LE_UINT16(srcP); + width = (int16)READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { @@ -1432,7 +1432,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - width = READ_LE_UINT16(srcP); + width = (int16)READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { @@ -2294,9 +2294,9 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x v9 = 0; v10 = 0; v8 = v6 + 4; - v9 = READ_LE_UINT16(v8); + v9 = (int16)READ_LE_UINT16(v8); v8 += 2; - v10 = READ_LE_UINT16(v8); + v10 = (int16)READ_LE_UINT16(v8); v11 = v8 + 10; destP = surface + xp + nbrligne2 * yp; Largeur = v9; @@ -2465,7 +2465,7 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { byteVal = *(srcPtr + 2); srcPtr += 2; } else if (byteVal == (byte)-2) { - destOffset += READ_LE_UINT16(srcPtr + 1); + destOffset += (int16)READ_LE_UINT16(srcPtr + 1); byteVal = *(srcPtr + 3); srcPtr += 3; } else { @@ -2499,7 +2499,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { byteVal = *(srcP + 2); srcP += 2; } else if (byteVal == -2) { - destOffset += READ_LE_UINT16(srcP + 1); + destOffset += (int16)READ_LE_UINT16(srcP + 1); byteVal = *(srcP + 3); srcP += 3; } else { -- cgit v1.2.3 From 9bf3e363e0f85b23d7ec59333a45db8354cbea66 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 10:23:33 +1100 Subject: HOPKINS: Fixed problems in Affiche_Perfect --- engines/hopkins/graphics.cpp | 767 ++++++++++++++++++++----------------------- 1 file changed, 356 insertions(+), 411 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4912849344..4b4b7f1d58 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1724,25 +1724,25 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { return v; } -void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, int a3, int a4, int a5, int a6, int a7, int a8) { +void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int spriteIndex, int a6, int a7, int a8) { const byte *v8; int i; - const byte *v10; + const byte *v10; int v11; int v12; const byte *v13; byte *v14; - int v15; + int v15; byte *v16; - int v17; + int v17; int v18; - int v19; - int v20; - int v21 = 0; - int v22; + int v19; + int v20; + int v21 = 0; + int v22; int v23; - int v24; - int v25; + int v24; + int v25; int v26; int v27; int v28; @@ -1752,448 +1752,393 @@ void GraphicsManager::Affiche_Perfect(byte *destSurface, const byte *srcData, in int v32; int v33; int v34; - int v35; - int v36 = 0; + int v35; + int v36; int v37; int v38; - int v39; + uint16 v39; byte *v40; int v41; - int v42; - const byte *v43; - const byte *v44; - const byte *v45; - const byte *v46; - byte *v47; - byte *v48; + uint16 v42; + const byte *v43; + const byte *v44; + const byte *v45; + const byte *v46; + byte *v47; + byte *v48; int v49; int v50; byte *v51; - unsigned int v52; - byte *v53; - byte *v54; - byte *v55; - int v56; - int v57; - int v58; - int v59; - int v60; - int v61; - int v62; - int v63; - int v64; - int v65; + int v52; + byte *v53; + byte *v54; + byte *v55; + int v56; + int v57; + int v58; + int v59; + int v60; + int v61; + int v62; + int v63; + int v64; + int v65; v8 = srcData + 3; - for (i = a5; i; --i) + for (i = spriteIndex; i; --i) v8 += READ_LE_UINT32(v8) + 16; - + v11 = 0; v12 = 0; v10 = v8 + 4; - v11 = *(uint16 *)v10; + v11 = (int16)READ_LE_UINT16(v10); v10 += 2; - v12 = *(uint16 *)v10; + v12 = v36 = (int16)READ_LE_UINT16(v10); v13 = v10 + 10; - clip_x = clip_y = 0; - clip_x1 = clip_y1 = 0; - - if (a3 > min_x) { - if ((uint)a3 < (uint)(min_x + 300)) - clip_x = min_x + 300 - a3; - if (a4 > min_y) { - if ((uint)a4 < (uint)(min_y + 300)) - clip_y = min_y + 300 - a4; - if ((uint)a3 < (uint)(max_x + 300)) { - clip_x1 = max_x + 300 - a3; - if ((uint)a4 < (uint)(max_y + 300)) { - clip_y1 = max_y + 300 - a4; - v14 = a3 + nbrligne2 * (a4 - 300) - 300 + destSurface; - - if ((uint16)a7) { - Compteur_y = 0; - Agr_x = 0; - Agr_y = 0; - Agr_Flag_y = 0; - Agr_Flag_x = 0; - Largeur = v11; - v20 = Asm_Zoom(v11, a7); - v22 = Asm_Zoom(v21, a7); - - if (a8) { - v29 = v20 + v14; - if (clip_y) { - if (clip_y >= v22) - return; - v61 = v22; - v52 = v20; - v30 = 0; - v31 = (uint)clip_y; - - while (Asm_Zoom(v30 + 1, a7) < v31) - ; - v20 = v52; - v13 += Largeur * v30; - v29 += nbrligne2 * (uint)clip_y; - v22 = v61 - (uint)clip_y; - } - - if (v22 > clip_y1) - v22 = clip_y1; - if (clip_x) { - if (clip_x >= v20) - return; - v20 -= (uint)clip_x; - } - - if (v20 > clip_x1) { - v32 = v20 - clip_x1; - v29 -= v32; - v62 = v22; - v33 = 0; - - while (Asm_Zoom(v33 + 1, a7) < v32) - ; - v34 = v33; - v22 = v62; - v13 += v34; - v20 = (uint)clip_x1; - } - - do { - for (;;) { - v63 = v22; - v53 = v29; - v46 = v13; - Agr_Flag_x = 0; - Agr_x = 0; - v35 = v20; - - do { - for (;;) { - if (*v13) - *v29 = *v13; - --v29; - ++v13; - if (!Agr_Flag_x) - Agr_x = a7 + Agr_x; - - if ((uint)Agr_x < 100) - break; - - Agr_x = Agr_x - 100; - --v13; - Agr_Flag_x = 1; - --v35; - if (!v35) - goto R_Aff_Zoom_Larg_Cont1; - } - - Agr_Flag_x = 0; - --v35; - } while (v35); - -R_Aff_Zoom_Larg_Cont1: - v13 = Largeur + v46; - v29 = nbrligne2 + v53; - ++Compteur_y; - if (!(uint16)Agr_Flag_y) - Agr_y = a7 + Agr_y; - - if ((uint)Agr_y < 100) - break; - - Agr_y = Agr_y - 100; - v13 = v46; - Agr_Flag_y = 1; - v22 = v63 - 1; - if (v63 == 1) + clip_x = 0; + clip_y = 0; + clip_x1 = 0; + clip_y1 = 0; + if ((unsigned __int16)xp300 > min_x) { + if ((unsigned __int16)xp300 < (unsigned __int16)(min_x + 300)) + clip_x = min_x + 300 - xp300; + if ((unsigned __int16)yp300 > min_y) { + if ((unsigned __int16)yp300 < (unsigned __int16)(min_y + 300)) + clip_y = min_y + 300 - yp300; + if ((unsigned __int16)xp300 < (unsigned __int16)(max_x + 300)) { + clip_x1 = max_x + 300 - xp300; + if ((unsigned __int16)yp300 < (unsigned __int16)(max_y + 300)) { + clip_y1 = max_y + 300 - yp300; + v14 = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; + if (a7) { + Compteur_y = 0; + Agr_x = 0; + Agr_y = 0; + Agr_Flag_y = 0; + Agr_Flag_x = 0; + Largeur = v11; + v20 = Asm_Zoom(v11, a7); + v22 = Asm_Zoom(v21, a7); + if (a8) { + v29 = v20 + v14; + if (clip_y) { + if ((unsigned __int16)clip_y >= v22) return; + v61 = v22; + v52 = v20; + v30 = 0; + v31 = (unsigned __int16)clip_y; + while (Asm_Zoom(v30 + 1, a7) < v31) + ; + v20 = v52; + v13 += Largeur * v30; + v29 += nbrligne2 * (unsigned __int16)clip_y; + v22 = v61 - (unsigned __int16)clip_y; } - - Agr_Flag_y = 0; - v22 = v63 - 1; - } while (v63 != 1); - } else { - if (clip_y) { - if (clip_y >= v22) - return; - v58 = v22; - v49 = v20; - v23 = 0; - v24 = (uint)clip_y; - - while (Asm_Zoom(v23 + 1, a7) < v24) - ; - v20 = v49; - v13 += Largeur * v23; - v14 += nbrligne2 * (uint)clip_y; - v22 = v58 - (uint)clip_y; - } - - if (v22 > clip_y1) - v22 = clip_y1; - - if (clip_x) { - if (clip_x >= v20) - return; - v59 = v22; - v50 = v20; - v25 = (uint)clip_x; - v26 = 0; - - while (Asm_Zoom(v26 + 1, a7) < v25) - ; - v27 = v26; - v22 = v59; - v13 += v27; - v14 += (uint)clip_x; - v20 = v50 - (uint)clip_x; - } - - if (v20 > clip_x1) - v20 = clip_x1; - - do { - for (;;) { - v60 = v22; - v51 = v14; - v45 = v13; - v28 = v20; - Agr_Flag_x = 0; - Agr_x = 0; - - do { - for (;;) { - if (*v13) - *v14 = *v13; - ++v14; - ++v13; - - if (!Agr_Flag_x) - Agr_x = a7 + Agr_x; - if ((uint)Agr_x < 100) - break; - - Agr_x = Agr_x - 100; - --v13; - Agr_Flag_x = 1; - --v28; - - if (!v28) - goto Aff_Zoom_Larg_Cont1; - } - - Agr_Flag_x = 0; - --v28; - } - while (v28); - -Aff_Zoom_Larg_Cont1: - v13 = Largeur + v45; - v14 = nbrligne2 + v51; - if (!(uint16)Agr_Flag_y) - Agr_y = a7 + Agr_y; - - if ((uint)Agr_y < 100) - break; - - Agr_y = Agr_y - 100; - v13 = v45; - Agr_Flag_y = 1; - v22 = v60 - 1; - - if (v60 == 1) + if (v22 > (unsigned __int16)clip_y1) + v22 = (unsigned __int16)clip_y1; + if (clip_x) { + if ((unsigned __int16)clip_x >= v20) return; + v20 -= (unsigned __int16)clip_x; + } + if (v20 > (unsigned __int16)clip_x1) { + v32 = v20 - (unsigned __int16)clip_x1; + v29 -= v32; + v62 = v22; + v33 = 0; + while (Asm_Zoom(v33 + 1, a7) < v32) + ; + v34 = v33; + v22 = v62; + v13 += v34; + v20 = (unsigned __int16)clip_x1; } - - Agr_Flag_y = 0; - v22 = v60 - 1; - } while (v60 != 1); - } - } else if ((uint16)a6) { - Compteur_y = 0; - Red_x = 0; - Red_y = 0; - Largeur = v11; - Red = a6; - - if ((uint)a6 < 100) { - v37 = Asm_Reduc(v11, Red); - if (a8) { - v40 = v37 + v14; - do { - v65 = v36; - v55 = v40; - Red_y = Red + Red_y; - - if ((uint)Red_y < 100) { - Red_x = 0; - v41 = Largeur; - v42 = v37; - + while (1) { + v63 = v22; + v53 = v29; + v46 = v13; + Agr_Flag_x = 0; + Agr_x = 0; + v35 = v20; do { - Red_x = Red + Red_x; - if (Red_x < 100) { - if (v42 >= clip_x && v42 < clip_x1 && *v13) - *v40 = *v13; - --v40; - ++v13; - --v42; - } else { - Red_x = Red_x - 100; + while (1) { + if (*v13) + *v29 = *v13; + --v29; ++v13; + if (!Agr_Flag_x) + Agr_x = a7 + Agr_x; + if ((unsigned __int16)Agr_x < 0x64u) + break; + Agr_x = Agr_x - 100; + --v13; + Agr_Flag_x = 1; + --v35; + if (!v35) + goto R_Aff_Zoom_Larg_Cont1; } - --v41; - } while (v41); - - v36 = v65; - v40 = nbrligne2 + v55; - } else { - Red_y = Red_y - 100; - v13 += Largeur; + Agr_Flag_x = 0; + --v35; + } while (v35); +R_Aff_Zoom_Larg_Cont1: + v13 = Largeur + v46; + v29 = nbrligne2 + v53; + ++Compteur_y; + if (!Agr_Flag_y) + Agr_y = a7 + Agr_y; + if ((unsigned __int16)Agr_y < 0x64u) + break; + Agr_y = Agr_y - 100; + v13 = v46; + Agr_Flag_y = 1; + v22 = v63 - 1; + if (v63 == 1) + return; } - - --v36; - } while ( v36 ); + Agr_Flag_y = 0; + v22 = v63 - 1; + } while (v63 != 1); } else { + if (clip_y) { + if ((unsigned __int16)clip_y >= v22) + return; + v58 = v22; + v49 = v20; + v23 = 0; + v24 = (unsigned __int16)clip_y; + while (Asm_Zoom(v23 + 1, a7) < v24) + ; + v20 = v49; + v13 += Largeur * v23; + v14 += nbrligne2 * (unsigned __int16)clip_y; + v22 = v58 - (unsigned __int16)clip_y; + } + if (v22 > (unsigned __int16)clip_y1) + v22 = (unsigned __int16)clip_y1; + if (clip_x) { + if ((unsigned __int16)clip_x >= v20) + return; + v59 = v22; + v50 = v20; + v25 = (unsigned __int16)clip_x; + v26 = 0; + while (Asm_Zoom(v26 + 1, a7) < v25) + ; + v27 = v26; + v22 = v59; + v13 += v27; + v14 += (unsigned __int16)clip_x; + v20 = v50 - (unsigned __int16)clip_x; + } + if (v20 > (unsigned __int16)clip_x1) + v20 = (unsigned __int16)clip_x1; do { - v64 = v36; - v54 = v14; - Red_y = Red + Red_y; - - if ((uint)Red_y < 100) { - Red_x = 0; - v38 = Largeur; - v39 = 0; - + while (1) { + v60 = v22; + v51 = v14; + v45 = v13; + v28 = v20; + Agr_Flag_x = 0; + Agr_x = 0; do { - Red_x = Red + Red_x; - if ((uint)Red_x < 100) { - if (v39 >= clip_x && v39 < clip_x1 && *v13) + while (1) { + if (*v13) *v14 = *v13; ++v14; ++v13; - ++v39; - } else { - Red_x = Red_x - 100; - ++v13; + if (!Agr_Flag_x) + Agr_x = a7 + Agr_x; + if ((unsigned __int16)Agr_x < 0x64u) + break; + Agr_x = Agr_x - 100; + --v13; + Agr_Flag_x = 1; + --v28; + if (!v28) + goto Aff_Zoom_Larg_Cont1; } - - --v38; - } while ( v38 ); - - v36 = v64; - v14 = nbrligne2 + v54; - } else { - Red_y = Red_y - 100; - v13 += Largeur; + Agr_Flag_x = 0; + --v28; + } while (v28); +Aff_Zoom_Larg_Cont1: + v13 = Largeur + v45; + v14 = nbrligne2 + v51; + if (!Agr_Flag_y) + Agr_y = a7 + Agr_y; + if ((unsigned __int16)Agr_y < 0x64u) + break; + Agr_y = Agr_y - 100; + v13 = v45; + Agr_Flag_y = 1; + v22 = v60 - 1; + if (v60 == 1) + return; } - - --v36; - } while (v36); - } - } - } else { - Largeur = v11; - Compteur_y = 0; - if (a8) { - v16 = v11 + v14; - spec_largeur = v11; - if (clip_y) { - if ((uint)clip_y >= (unsigned int)v12) - return; - v13 += v11 * (uint)clip_y; - v16 += nbrligne2 * (uint)clip_y; - v12 -= (uint)clip_y; - } - - v17 = (uint)clip_y1; - if (v12 > clip_y1) - v12 = clip_y1; - - v17 = clip_x; - if (clip_x) { - if (v17 >= v11) - return; - v11 -= v17; + Agr_Flag_y = 0; + v22 = v60 - 1; + } while (v60 != 1); } - - if (v11 > clip_x1) { - v18 = v11 - clip_x1; - v13 += v18; - v16 -= v18; - v11 = (uint)clip_x1; + } else if (a6) { + Compteur_y = 0; + Red_x = 0; + Red_y = 0; + Largeur = v11; + Red = a6; + if (a6 < 100) { + v37 = Asm_Reduc(v11, Red); + if (a8) { + v40 = v37 + v14; + do { + v65 = v36; + v55 = v40; + Red_y = Red + Red_y; + if ((unsigned __int16)Red_y < 0x64u) { + Red_x = 0; + v41 = Largeur; + v42 = v37; + do { + Red_x = Red + Red_x; + if ((unsigned __int16)Red_x < 0x64u) { + if (v42 >= clip_x && v42 < clip_x1 && *v13) + *v40 = *v13; + --v40; + ++v13; + --v42; + } else { + Red_x = Red_x - 100; + ++v13; + } + --v41; + } while (v41); + v36 = v65; + v40 = nbrligne2 + v55; + } else { + Red_y = Red_y - 100; + v13 += Largeur; + } + --v36; + } while (v36); + } else { + do { + v64 = v36; + v54 = v14; + Red_y = Red + Red_y; + if ((unsigned __int16)Red_y < 0x64u) { + Red_x = 0; + v38 = Largeur; + v39 = 0; + do { + Red_x = Red + Red_x; + if ((unsigned __int16)Red_x < 0x64u) { + if (v39 >= clip_x && v39 < clip_x1 && *v13) + *v14 = *v13; + ++v14; + ++v13; + ++v39; + } else { + Red_x = Red_x - 100; + ++v13; + } + --v38; + } while (v38); + v36 = v64; + v14 = nbrligne2 + v54; + } else { + Red_y = Red_y - 100; + v13 += Largeur; + } + --v36; + } while (v36); + } } - - do { - v57 = v12; - v48 = v16; - v44 = v13; - v19 = v11; - - do { - if (*v13) - *v16 = *v13; - ++v13; - --v16; - --v19; - } while (v19); - - v13 = spec_largeur + v44; - v16 = nbrligne2 + v48; - v12 = v57 - 1; - } while (v57 != 1); } else { - spec_largeur = v11; - if (clip_y) { - if ((uint)clip_y >= (unsigned int)v12) - return; - - v13 += v11 * (uint)clip_y; - v14 += nbrligne2 * (uint)clip_y; - v12 -= (uint)clip_y; - } - - if (v12 > clip_y1) - v12 = clip_y1; - if (clip_x) { - if (clip_x >= v11) - return; - - v13 += (uint)clip_x; - v14 += (uint)clip_x; - v11 -= (uint)clip_x; - } - - if (v11 > clip_x1) - v11 = clip_x1; - - do { - v56 = v12; - v47 = v14; - v43 = v13; - v15 = v11; - + Largeur = v11; + Compteur_y = 0; + if (a8) { + v16 = v11 + v14; + spec_largeur = v11; + if (clip_y) { + if ((unsigned __int16)clip_y >= (unsigned int)v12) + return; + v13 += v11 * (unsigned __int16)clip_y; + v16 += nbrligne2 * (unsigned __int16)clip_y; + v12 -= (unsigned __int16)clip_y; + } + v17 = (unsigned __int16)clip_y1; + if (v12 > clip_y1) + v12 = clip_y1; + v17 = clip_x; + if (clip_x) { + if (v17 >= v11) + return; + v11 -= v17; + } + if (v11 > (unsigned __int16)clip_x1) { + v18 = v11 - (unsigned __int16)clip_x1; + v13 += v18; + v16 -= v18; + v11 = (unsigned __int16)clip_x1; + } do { - if (*v13) - *v14 = *v13; - ++v14; - ++v13; - --v15; - } while (v15); - - v13 = spec_largeur + v43; - v14 = nbrligne2 + v47; - v12 = v56 - 1; - } while (v56 != 1); + v57 = v12; + v48 = v16; + v44 = v13; + v19 = v11; + do { + if (*v13) + *v16 = *v13; + ++v13; + --v16; + --v19; + } while (v19); + v13 = spec_largeur + v44; + v16 = nbrligne2 + v48; + v12 = v57 - 1; + } while (v57 != 1); + } else { + spec_largeur = v11; + if (clip_y) { + if ((unsigned __int16)clip_y >= (unsigned int)v12) + return; + v13 += v11 * (unsigned __int16)clip_y; + v14 += nbrligne2 * (unsigned __int16)clip_y; + v12 -= (unsigned __int16)clip_y; + } + if (v12 > clip_y1) + v12 = clip_y1; + if (clip_x) { + if ((unsigned __int16)clip_x >= v11) + return; + v13 += (unsigned __int16)clip_x; + v14 += (unsigned __int16)clip_x; + v11 -= (unsigned __int16)clip_x; + } + if (v11 > (unsigned __int16)clip_x1) + v11 = (unsigned __int16)clip_x1; + do { + v56 = v12; + v47 = v14; + v43 = v13; + v15 = v11; + do { + if (*v13) + *v14 = *v13; + ++v14; + ++v13; + --v15; + } while (v15); + v13 = spec_largeur + v43; + v14 = nbrligne2 + v47; + v12 = v56 - 1; + } while (v56 != 1); + } } } } } } - } } void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { -- cgit v1.2.3 From 4ec8e71997ef028c3f3601d8d741360ceba4a744 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 13:04:05 +1100 Subject: HOPKINS: Correct video decompression methods --- engines/hopkins/graphics.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4b4b7f1d58..94dee59aac 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1129,7 +1129,7 @@ Video_Cont3_wVbe: } } -void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { +void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { int result; int v2; int v3; @@ -1146,7 +1146,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { result = 0; v2 = 0; v3 = 0; - v4 = surface; + v4 = srcData; for (;;) { v5 = *v4; if (*v4 < 222) @@ -1162,7 +1162,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) { v5 = *(v4 + 2); v4 += 2; } else if (v5 == (byte)-2) { - v2 += (int16)READ_LE_UINT16(v4 + 1); + v2 += READ_LE_UINT16(v4 + 1); v5 = *(v4 + 3); v4 += 3; } else { @@ -1199,8 +1199,8 @@ Video_Cont3_Vbe: } } -void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { - const byte *srcP = surface; +void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { + const byte *srcP = srcData; int destOffset = 0; assert(VideoPtr); @@ -1217,7 +1217,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { srcByte = *(const byte *)(srcP + 2); srcP += 2; } else if (srcByte == 254) { - destOffset += (int16)READ_LE_UINT16(srcP + 1); + destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(const byte *)(srcP + 3); srcP += 3; } else { @@ -1259,13 +1259,13 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) { } } -void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { +void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { int v2; const byte *v3; unsigned __int8 v4; v2 = 0; - v3 = surface; + v3 = srcData; for (;;) { v4 = *v3; if (*v3 < 0xFCu) @@ -1277,7 +1277,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { v4 = *(v3 + 2); v3 += 2; } else if (v4 == -2) { - v2 += (int16)READ_LE_UINT16(v3 + 1); + v2 += READ_LE_UINT16(v3 + 1); v4 = *(v3 + 3); v3 += 3; } else { @@ -1286,7 +1286,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) { v3 += 5; } Video_Cont_Vbe16a: - WRITE_LE_UINT16(v2 + v2 + VideoPtr, (int16)READ_LE_UINT16(PAL_PIXELS + 2 * v4)); + WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); ++v3; ++v2; } @@ -1336,9 +1336,9 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, clip_flag = false; spriteP += 4; - int width = (int16)READ_LE_UINT16(spriteP); + int width = READ_LE_UINT16(spriteP); spriteP += 2; - int height = (int16)READ_LE_UINT16(spriteP); + int height = READ_LE_UINT16(spriteP); // Clip X clip_x1 = width; @@ -1386,7 +1386,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Set up source spriteP += 6; - int srcOffset = (int16)READ_LE_UINT16(spriteP); + int srcOffset = READ_LE_UINT16(spriteP); spriteP += 4; const byte *srcP = spriteP; spriteP += srcOffset; @@ -1404,7 +1404,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - width = (int16)READ_LE_UINT16(srcP); + width = READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { @@ -1432,7 +1432,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, while ((byteVal = *srcP) != 253) { ++srcP; - width = (int16)READ_LE_UINT16(srcP); + width = READ_LE_UINT16(srcP); srcP += 2; if (byteVal == 254) { -- cgit v1.2.3 From cde057a5828ed0e4136436dd2c8628c2141e173f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 16:41:51 +1100 Subject: HOPKINS: Some cleanup to the video frame display and fading methods --- engines/hopkins/graphics.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 94dee59aac..c19ad05540 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1051,15 +1051,17 @@ void GraphicsManager::DD_VBL() { } void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { + assert(surface); fade_out(Palette, FADESPD, surface); } void GraphicsManager::FADE_INW_LINUX(const byte *surface) { - return fade_in(Palette, FADESPD, surface); + assert(surface); + fade_in(Palette, FADESPD, surface); } -void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSurface) { - int result; +void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { + byte v; int v3; int v4; const byte *v5; @@ -1071,10 +1073,9 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur unsigned int v11; byte *v12; - result = 0; v3 = 0; v4 = 0; - v5 = sourceSurface; + v5 = srcData; for (;;) { v6 = *v5; if (*v5 < 222) @@ -1091,7 +1092,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur v6 = *(v5 + 2); v5 += 2; } else if (v6 == 254) { - v3 += (int16)READ_LE_UINT16(v5 + 1); + v3 += READ_LE_UINT16(v5 + 1); v6 = *(v5 + 3); v5 += 3; } else { @@ -1105,19 +1106,19 @@ Video_Cont3_wVbe: if (v6 == 211) { v7 = v4; v8 = *(v5 + 1); - result = *(v5 + 2); + v = *(v5 + 2); v9 = v3 + destSurface; v3 += v8; - memset(v9, result, v8); + memset(v9, v, v8); v5 += 3; v4 = v7; } else { v10 = v4; v11 = *v5 + 45; - result = *(v5 + 1); + v = *(v5 + 1); v12 = v3 + destSurface; v3 += v11; - memset(v12, result, v11); + memset(v12, v, v11); v5 += 2; v4 = v10; } -- cgit v1.2.3 From 1ee3c572f2920c2d334424a68ba1122b4eda3145 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 16:51:44 +1100 Subject: HOPKINS: Fixed Copy_WinScan_Vbe3 method --- engines/hopkins/graphics.cpp | 46 +++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c19ad05540..a5086201a8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1061,37 +1061,37 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { } void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { - byte v; - int v3; - int v4; - const byte *v5; - uint8 v6; - int v7; - unsigned int v8; - byte *v9; + int v; + int v3; + int v4; + const byte *v5; + byte v6; + int v7; + byte v8; + byte *v9; int v10; - unsigned int v11; - byte *v12; + byte v11; + byte *v12; + v = 0; v3 = 0; v4 = 0; v5 = srcData; for (;;) { v6 = *v5; - if (*v5 < 222) + if (*v5 < 0xDEu) goto Video_Cont3_wVbe; - - if (v6 == 252) + if (v6 == (byte)-4) return; - - if (v6 < 251) { - v3 += *v5 + 35; + + if (v6 < 0xFBu) { + v3 += (byte)(*v5 + 35); v6 = *(v5++ + 1); - } else if (v6 == 253) { + } else if (v6 == (byte)-3) { v3 += *(v5 + 1); v6 = *(v5 + 2); v5 += 2; - } else if (v6 == 254) { + } else if (v6 == (byte)-2) { v3 += READ_LE_UINT16(v5 + 1); v6 = *(v5 + 3); v5 += 3; @@ -1100,10 +1100,9 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) v6 = *(v5 + 5); v5 += 5; } - Video_Cont3_wVbe: - if (v6 > 210) { - if (v6 == 211) { + if (v6 > 0xD2u) { + if (v6 == (byte)-45) { v7 = v4; v8 = *(v5 + 1); v = *(v5 + 2); @@ -1114,7 +1113,7 @@ Video_Cont3_wVbe: v4 = v7; } else { v10 = v4; - v11 = *v5 + 45; + v11 = (byte)(*v5 + 45); v = *(v5 + 1); v12 = v3 + destSurface; v3 += v11; @@ -1127,8 +1126,7 @@ Video_Cont3_wVbe: ++v5; ++v3; } - } -} + }} void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { int result; -- cgit v1.2.3 From 756dc956b54ac645feee3427d129789b7b3a3aa5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 18:27:14 +1100 Subject: HOPKINS: Finally implemented VBL cursor method properly --- engines/hopkins/graphics.cpp | 46 +++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a5086201a8..4e240902d2 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1294,16 +1294,16 @@ Video_Cont_Vbe16a: void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, unsigned int width, int height) { const byte *srcP; byte *destP; - int yCtr; + int rowCount; unsigned int i; - int yTemp; + int rowCount2; - srcP = srcSurface + xs + nbrligne2 * ys; + assert(xs <= SCREEN_WIDTH && ys <= SCREEN_HEIGHT); + srcP = xs + nbrligne2 * ys + srcSurface; destP = destSurface; - - yCtr = height; + rowCount = height; do { - yTemp = yCtr; + rowCount2 = rowCount; if (width & 1) { memcpy(destP, srcP, width); srcP += width; @@ -1312,16 +1312,16 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int for (i = width >> 1; i; --i) { *(uint16 *)destP = *(uint16 *)srcP; srcP += 2; - destP = (byte *)destP + 2; + destP += 2; } } else { memcpy(destP, srcP, 4 * (width >> 2)); srcP += 4 * (width >> 2); - destP = (byte *)destP + 4 * (width >> 2); + destP += 4 * (width >> 2); } srcP = nbrligne2 + srcP - width; - yCtr = yTemp - 1; - } while (yTemp != 1); + rowCount = rowCount2 - 1; + } while (rowCount2 != 1); } void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) { @@ -1528,6 +1528,7 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { } if (v10 == 1) { + assert(_vm->_globals.NBBLOC < 50); BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; bloc.field0 = 1; @@ -1556,6 +1557,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { return; SDL_NBLOCS = _vm->_globals.NBBLOC; + DD_Lock(); for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { BlocItem &bloc = _vm->_globals.BLOC[idx]; @@ -1580,7 +1582,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (bloc.x2 > (_vm->_eventsManager.start_x + SCREEN_WIDTH)) bloc.x2 = _vm->_eventsManager.start_x + SCREEN_WIDTH; - if (!SDL_ECHELLE) { + if (SDL_ECHELLE) { // Calculate the bounds int xp = Magic_Number(bloc.x1) - 4; if (xp < _vm->_eventsManager.start_x) @@ -1600,6 +1602,9 @@ void GraphicsManager::Affiche_Segment_Vesa() { if ((height - yp) > (SCREEN_HEIGHT - 40)) yp -= 4; + // WORKAROUND: Original didn't lock the screen for access + DD_Lock(); + if (Winbpp == 2) { m_scroll16A(VESA_BUFFER, xp, yp, width, height, Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); @@ -1608,11 +1613,16 @@ void GraphicsManager::Affiche_Segment_Vesa() { Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } + DD_Unlock(); + dstRect.left = Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE); dstRect.top = Reel_Zoom(yp, SDL_ECHELLE); dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE)); dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE)); } else { + // WORKAROUND: Original didn't lock the screen for access + DD_Lock(); + if (Winbpp == 2) { m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); @@ -1620,11 +1630,25 @@ void GraphicsManager::Affiche_Segment_Vesa() { m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); } + + dstRect.left = bloc.x1 - _vm->_eventsManager.start_x; + dstRect.top = bloc.y1; + dstRect.setWidth(bloc.x2 - bloc.x1); + dstRect.setHeight(bloc.y2 - bloc.y1); + + DD_Unlock(); } } _vm->_globals.BLOC[idx].field0 = 0; } + + _vm->_globals.NBBLOC = 0; + DD_Unlock(); + if (!_vm->_globals.BPP_NOAFF) { +// SDL_UpdateRects(LinuxScr, SDL_NBLOCS, dstrect); + } + SDL_NBLOCS = 0; } void GraphicsManager::CopyAsm(const byte *surface) { -- cgit v1.2.3 From 193686770ce53890807660a35880480b54d9df90 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Oct 2012 19:38:53 +1100 Subject: HOPKINS: Put a TODO in Capture_Mem to clip reading to within the passed surface --- engines/hopkins/graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4e240902d2..b1bce4840f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1298,7 +1298,8 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int unsigned int i; int rowCount2; - assert(xs <= SCREEN_WIDTH && ys <= SCREEN_HEIGHT); + // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within + // the screen, and so thus can read areas outside of the allocated surface buffer srcP = xs + nbrligne2 * ys + srcSurface; destP = destSurface; rowCount = height; -- cgit v1.2.3 From d3945702131bd8e7a36eb9a39ede90819f9acc79 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 15 Oct 2012 20:49:17 +1100 Subject: HOPKINS: Some renaming and cleanup of font structures --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b1bce4840f..3798711a49 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2243,7 +2243,7 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, - int characterIndex, int transColour) { + int characterIndex, int colour) { const byte *v6; int i; const byte *v8; @@ -2278,7 +2278,7 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x v14 = *v11; if (*v11) { if (v14 == (byte)-4) - v14 = transColour; + v14 = colour; *destP = v14; } -- cgit v1.2.3 From b4247f6265e980b65aeb3c97f3c8875892cb8e92 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 20 Oct 2012 18:59:06 +0200 Subject: HOPKINS: Add some translated comments to function names --- engines/hopkins/graphics.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3798711a49..c42ea8cfa0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -158,6 +158,7 @@ void GraphicsManager::DD_Unlock() { } } +// Clear Screen void GraphicsManager::Cls_Video() { assert(VideoPtr); @@ -170,6 +171,7 @@ void GraphicsManager::LOAD_IMAGE(const Common::String &file) { INIT_TABLE(165, 170, Palette); } +// Load Screen void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { bool flag; Common::File f; @@ -259,6 +261,7 @@ void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { TABLE_COUL[0] = 1; } +// Scroll Screen int GraphicsManager::SCROLL_ECRAN(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); _vm->_eventsManager.start_x = result; @@ -483,6 +486,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by _vm->_globals.dos_free2(ptr); } +// Clear Palette void GraphicsManager::Cls_Pal() { Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); SD_PIXELS[0] = 0; @@ -492,6 +496,7 @@ void GraphicsManager::Cls_Pal() { } } +// TODO: Check if it's normal it's defined two times (also in events). void GraphicsManager::souris_max() { // Original has no implementation } @@ -1495,6 +1500,7 @@ void GraphicsManager::RESET_SEGMENT_VESA() { } } +// Add VESA Segment void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { int v4; int v5; @@ -1553,6 +1559,7 @@ int GraphicsManager::Magic_Number(signed int v) { return result; } +// Display VESA Segment void GraphicsManager::Affiche_Segment_Vesa() { if (_vm->_globals.NBBLOC == 0) return; @@ -1748,6 +1755,7 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { return v; } +// Display 'Perfect?' void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int spriteIndex, int a6, int a7, int a8) { const byte *v8; int i; @@ -2165,6 +2173,7 @@ Aff_Zoom_Larg_Cont1: } } +// Display Speed void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { int width, height; @@ -2242,6 +2251,7 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } while (yCurrent != 1); } +// Display Font void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { const byte *v6; @@ -2291,10 +2301,12 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x } while (v16 != 1); } +// Init Screen void GraphicsManager::INI_ECRAN(const Common::String &file) { OPTI_INI(file, 0); } +// Init Screen 2 void GraphicsManager::INI_ECRAN2(const Common::String &file) { OPTI_INI(file, 2); } @@ -2483,6 +2495,7 @@ Video_Cont_Vbe: } } +// Reduce Screen // TODO: Check that v9 doesn't get set anywhere (apart from the current init to zero) void GraphicsManager::Reduc_Ecran(byte *a1, byte *a2, int a3, int a4, int a5, int a6, int a7) { byte *v7; -- cgit v1.2.3 From 247f1616d870e152f75471529bef12ab5ad562b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 21 Oct 2012 18:48:03 +1100 Subject: HOPKINS: Fix the display of on-screen text --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c42ea8cfa0..691781383d 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -61,7 +61,7 @@ GraphicsManager::GraphicsManager() { min_x = 0; min_y = 20; max_x = SCREEN_WIDTH * 2; - max_y = SCREEN_HEIGHT - 20 * 2; + max_y = SCREEN_HEIGHT - 20; clip_x = clip_y = 0; clip_x1 = clip_y1 = 0; clip_flag = false; -- cgit v1.2.3 From 71268b44184cfb9525186f008789cd5e5e2ae298 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 22 Oct 2012 22:31:46 +1100 Subject: HOPKINS: Furhter bugfixes for pathfinding and walking --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 691781383d..feecff9c2c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1756,7 +1756,7 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { } // Display 'Perfect?' -void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int spriteIndex, int a6, int a7, int a8) { +void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8) { const byte *v8; int i; const byte *v10; @@ -1817,7 +1817,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v65; v8 = srcData + 3; - for (i = spriteIndex; i; --i) + for (i = frameIndex; i; --i) v8 += READ_LE_UINT32(v8) + 16; v11 = 0; -- cgit v1.2.3 From dc358dab61b726e74818f15e9e3f2b04974487d5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 22 Oct 2012 23:26:40 +1100 Subject: HOPKINS: Fix gcc identified warnings in graphics.cpp --- engines/hopkins/graphics.cpp | 112 +++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index feecff9c2c..17cf8714cc 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1266,7 +1266,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { int v2; const byte *v3; - unsigned __int8 v4; + byte v4; v2 = 0; v3 = srcData; @@ -1831,15 +1831,15 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp clip_y = 0; clip_x1 = 0; clip_y1 = 0; - if ((unsigned __int16)xp300 > min_x) { - if ((unsigned __int16)xp300 < (unsigned __int16)(min_x + 300)) + if ((uint16)xp300 > min_x) { + if ((uint16)xp300 < (uint16)(min_x + 300)) clip_x = min_x + 300 - xp300; - if ((unsigned __int16)yp300 > min_y) { - if ((unsigned __int16)yp300 < (unsigned __int16)(min_y + 300)) + if ((uint16)yp300 > min_y) { + if ((uint16)yp300 < (uint16)(min_y + 300)) clip_y = min_y + 300 - yp300; - if ((unsigned __int16)xp300 < (unsigned __int16)(max_x + 300)) { + if ((uint16)xp300 < (uint16)(max_x + 300)) { clip_x1 = max_x + 300 - xp300; - if ((unsigned __int16)yp300 < (unsigned __int16)(max_y + 300)) { + if ((uint16)yp300 < (uint16)(max_y + 300)) { clip_y1 = max_y + 300 - yp300; v14 = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; if (a7) { @@ -1854,28 +1854,28 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (a8) { v29 = v20 + v14; if (clip_y) { - if ((unsigned __int16)clip_y >= v22) + if ((uint16)clip_y >= v22) return; v61 = v22; v52 = v20; v30 = 0; - v31 = (unsigned __int16)clip_y; + v31 = (uint16)clip_y; while (Asm_Zoom(v30 + 1, a7) < v31) ; v20 = v52; v13 += Largeur * v30; - v29 += nbrligne2 * (unsigned __int16)clip_y; - v22 = v61 - (unsigned __int16)clip_y; + v29 += nbrligne2 * (uint16)clip_y; + v22 = v61 - (uint16)clip_y; } - if (v22 > (unsigned __int16)clip_y1) - v22 = (unsigned __int16)clip_y1; + if (v22 > (uint16)clip_y1) + v22 = (uint16)clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v20) + if ((uint16)clip_x >= v20) return; - v20 -= (unsigned __int16)clip_x; + v20 -= (uint16)clip_x; } - if (v20 > (unsigned __int16)clip_x1) { - v32 = v20 - (unsigned __int16)clip_x1; + if (v20 > (uint16)clip_x1) { + v32 = v20 - (uint16)clip_x1; v29 -= v32; v62 = v22; v33 = 0; @@ -1884,7 +1884,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v34 = v33; v22 = v62; v13 += v34; - v20 = (unsigned __int16)clip_x1; + v20 = (uint16)clip_x1; } do { while (1) { @@ -1902,7 +1902,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++v13; if (!Agr_Flag_x) Agr_x = a7 + Agr_x; - if ((unsigned __int16)Agr_x < 0x64u) + if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; --v13; @@ -1920,7 +1920,7 @@ R_Aff_Zoom_Larg_Cont1: ++Compteur_y; if (!Agr_Flag_y) Agr_y = a7 + Agr_y; - if ((unsigned __int16)Agr_y < 0x64u) + if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; v13 = v46; @@ -1934,38 +1934,38 @@ R_Aff_Zoom_Larg_Cont1: } while (v63 != 1); } else { if (clip_y) { - if ((unsigned __int16)clip_y >= v22) + if ((uint16)clip_y >= v22) return; v58 = v22; v49 = v20; v23 = 0; - v24 = (unsigned __int16)clip_y; + v24 = (uint16)clip_y; while (Asm_Zoom(v23 + 1, a7) < v24) ; v20 = v49; v13 += Largeur * v23; - v14 += nbrligne2 * (unsigned __int16)clip_y; - v22 = v58 - (unsigned __int16)clip_y; + v14 += nbrligne2 * (uint16)clip_y; + v22 = v58 - (uint16)clip_y; } - if (v22 > (unsigned __int16)clip_y1) - v22 = (unsigned __int16)clip_y1; + if (v22 > (uint16)clip_y1) + v22 = (uint16)clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v20) + if ((uint16)clip_x >= v20) return; v59 = v22; v50 = v20; - v25 = (unsigned __int16)clip_x; + v25 = (uint16)clip_x; v26 = 0; while (Asm_Zoom(v26 + 1, a7) < v25) ; v27 = v26; v22 = v59; v13 += v27; - v14 += (unsigned __int16)clip_x; - v20 = v50 - (unsigned __int16)clip_x; + v14 += (uint16)clip_x; + v20 = v50 - (uint16)clip_x; } - if (v20 > (unsigned __int16)clip_x1) - v20 = (unsigned __int16)clip_x1; + if (v20 > (uint16)clip_x1) + v20 = (uint16)clip_x1; do { while (1) { v60 = v22; @@ -1982,7 +1982,7 @@ R_Aff_Zoom_Larg_Cont1: ++v13; if (!Agr_Flag_x) Agr_x = a7 + Agr_x; - if ((unsigned __int16)Agr_x < 0x64u) + if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; --v13; @@ -1999,7 +1999,7 @@ Aff_Zoom_Larg_Cont1: v14 = nbrligne2 + v51; if (!Agr_Flag_y) Agr_y = a7 + Agr_y; - if ((unsigned __int16)Agr_y < 0x64u) + if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; v13 = v45; @@ -2026,13 +2026,13 @@ Aff_Zoom_Larg_Cont1: v65 = v36; v55 = v40; Red_y = Red + Red_y; - if ((unsigned __int16)Red_y < 0x64u) { + if ((uint16)Red_y < 0x64u) { Red_x = 0; v41 = Largeur; v42 = v37; do { Red_x = Red + Red_x; - if ((unsigned __int16)Red_x < 0x64u) { + if ((uint16)Red_x < 0x64u) { if (v42 >= clip_x && v42 < clip_x1 && *v13) *v40 = *v13; --v40; @@ -2057,13 +2057,13 @@ Aff_Zoom_Larg_Cont1: v64 = v36; v54 = v14; Red_y = Red + Red_y; - if ((unsigned __int16)Red_y < 0x64u) { + if ((uint16)Red_y < 0x64u) { Red_x = 0; v38 = Largeur; v39 = 0; do { Red_x = Red + Red_x; - if ((unsigned __int16)Red_x < 0x64u) { + if ((uint16)Red_x < 0x64u) { if (v39 >= clip_x && v39 < clip_x1 && *v13) *v14 = *v13; ++v14; @@ -2092,13 +2092,13 @@ Aff_Zoom_Larg_Cont1: v16 = v11 + v14; spec_largeur = v11; if (clip_y) { - if ((unsigned __int16)clip_y >= (unsigned int)v12) + if ((uint16)clip_y >= (unsigned int)v12) return; - v13 += v11 * (unsigned __int16)clip_y; - v16 += nbrligne2 * (unsigned __int16)clip_y; - v12 -= (unsigned __int16)clip_y; + v13 += v11 * (uint16)clip_y; + v16 += nbrligne2 * (uint16)clip_y; + v12 -= (uint16)clip_y; } - v17 = (unsigned __int16)clip_y1; + v17 = (uint16)clip_y1; if (v12 > clip_y1) v12 = clip_y1; v17 = clip_x; @@ -2107,11 +2107,11 @@ Aff_Zoom_Larg_Cont1: return; v11 -= v17; } - if (v11 > (unsigned __int16)clip_x1) { - v18 = v11 - (unsigned __int16)clip_x1; + if (v11 > (uint16)clip_x1) { + v18 = v11 - (uint16)clip_x1; v13 += v18; v16 -= v18; - v11 = (unsigned __int16)clip_x1; + v11 = (uint16)clip_x1; } do { v57 = v12; @@ -2132,23 +2132,23 @@ Aff_Zoom_Larg_Cont1: } else { spec_largeur = v11; if (clip_y) { - if ((unsigned __int16)clip_y >= (unsigned int)v12) + if ((uint16)clip_y >= (unsigned int)v12) return; - v13 += v11 * (unsigned __int16)clip_y; - v14 += nbrligne2 * (unsigned __int16)clip_y; - v12 -= (unsigned __int16)clip_y; + v13 += v11 * (uint16)clip_y; + v14 += nbrligne2 * (uint16)clip_y; + v12 -= (uint16)clip_y; } if (v12 > clip_y1) v12 = clip_y1; if (clip_x) { - if ((unsigned __int16)clip_x >= v11) + if ((uint16)clip_x >= v11) return; - v13 += (unsigned __int16)clip_x; - v14 += (unsigned __int16)clip_x; - v11 -= (unsigned __int16)clip_x; + v13 += (uint16)clip_x; + v14 += (uint16)clip_x; + v11 -= (uint16)clip_x; } - if (v11 > (unsigned __int16)clip_x1) - v11 = (unsigned __int16)clip_x1; + if (v11 > (uint16)clip_x1) + v11 = (uint16)clip_x1; do { v56 = v12; v47 = v14; -- cgit v1.2.3 From 434d946849e2bb559fe9e391859348affa6618f3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 22 Oct 2012 23:28:54 +1100 Subject: HOPKINS: Fix gcc identified warnings in lines.cpp --- engines/hopkins/graphics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 17cf8714cc..2ec58a0899 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1274,13 +1274,13 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { v4 = *v3; if (*v3 < 0xFCu) goto Video_Cont_Vbe16a; - if (v4 == -4) + if (v4 == (byte)-4) return; - if (v4 == -3) { + if (v4 == (byte)-3) { v2 += *(v3 + 1); v4 = *(v3 + 2); v3 += 2; - } else if (v4 == -2) { + } else if (v4 == (byte)-2) { v2 += READ_LE_UINT16(v3 + 1); v4 = *(v3 + 3); v3 += 3; @@ -2473,13 +2473,13 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { byteVal = *srcP; if (*srcP < 0xFCu) goto Video_Cont_Vbe; - if (byteVal == -4) + if (byteVal == (byte)-4) return; - if (byteVal == -3) { + if (byteVal == (byte)-3) { destOffset += *(srcP + 1); byteVal = *(srcP + 2); srcP += 2; - } else if (byteVal == -2) { + } else if (byteVal == (byte)-2) { destOffset += (int16)READ_LE_UINT16(srcP + 1); byteVal = *(srcP + 3); srcP += 3; -- cgit v1.2.3 From 1ab3d755b990cbcff7f818f88a19bb1e0aaf90e8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 23 Oct 2012 08:57:16 +1100 Subject: HOPKINS: Fix some uniinitialised data identified by Valgrind --- engines/hopkins/graphics.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2ec58a0899..f68ac8ce2f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -75,7 +75,8 @@ GraphicsManager::GraphicsManager() { Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); - Common::fill(&Palette[0], &Palette[PALETTE_BLOCK_SIZE], 0); + Common::fill(&Palette[0], &Palette[PALETTE_EXT_BLOCK_SIZE], 0); + Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0); } GraphicsManager::~GraphicsManager() { @@ -800,9 +801,9 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface setpal_vga256(palData2); // Loop through fading in the palette - uint16 *pTemp1 = &palData1[2]; + uint16 *pTemp1 = &palData1[1]; for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) { - uint16 *pTemp2 = &palData1[4]; + uint16 *pTemp2 = &palData1[2]; for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { if (palData2[palOffset] < palette[palOffset]) { @@ -818,11 +819,11 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface palData2[palOffset + 1] = (v >> 8) & 0xff; } - if (palData2[palOffset + 1] < palette[palOffset + 1]) { + if (palData2[palOffset + 2] < palette[palOffset + 2]) { uint16 *pDest = &pTemp2[palOffset]; uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; *pDest = v; - palData2[palOffset + 1] = (v >> 8) & 0xff; + palData2[palOffset + 2] = (v >> 8) & 0xff; } } -- cgit v1.2.3 From bf0290f6a43f7310a2bcb5c4ee032c83006865fe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 23 Oct 2012 20:40:19 +1100 Subject: HOPKINS: Moved the script execution code to it's own file --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f68ac8ce2f..31c0cee4a2 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2353,11 +2353,11 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { } else { v11 = 0; do { - v6 = _vm->_objectsManager.Traduction(ptr + 20 * v2); + v6 = _vm->_scriptManager.Traduction(ptr + 20 * v2); if (v6 == 2) - v2 = _vm->_objectsManager.Control_Goto((ptr + 20 * v2)); + v2 = _vm->_scriptManager.Control_Goto((ptr + 20 * v2)); if (v6 == 3) - v2 = _vm->_objectsManager.Control_If(ptr, v2); + v2 = _vm->_scriptManager.Control_If(ptr, v2); if (v2 == -1) error("Error, defective IFF"); if (v6 == 1 || v6 == 4) -- cgit v1.2.3 From 6d2b43ce9c110cbc8db9bd250b846dfe69143ae2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 24 Oct 2012 07:09:12 +1100 Subject: HOPKINS: Fix initialisation of TABLE_COUL data. This fixes the background of message dialogs. --- engines/hopkins/graphics.cpp | 75 ++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 51 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 31c0cee4a2..4495698321 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -73,7 +73,7 @@ GraphicsManager::GraphicsManager() { spec_largeur = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); - Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0); + Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); Common::fill(&Palette[0], &Palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0); @@ -271,61 +271,34 @@ int GraphicsManager::SCROLL_ECRAN(int amount) { return result; } -void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, int param2) { - byte *v5; - int v6; - int v7; - int v8; - unsigned int v11; - int v12; - int v13; - int v14; - int v15; - int v16; - int v17; - unsigned int v18; - char v19; - int v20; - bool breakFlag; +void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { + byte *destPosP; + int palIndex; + int srcOffset; + int col1, col2; - v5 = destP; - v6 = count - 1; - do { - breakFlag = v6; - v7 = *(byte *)v5++; - v8 = (unsigned int)(3 * v7); + destPosP = destP; + for (int idx = 0; idx < count; ++idx) { + palIndex = *(byte *)destPosP++; + srcOffset = 3 * palIndex; + col1 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2); - // TODO: Ensure this is the right calculation - v11 = *(byte *)(v8 + srcP) + *(byte *)(v8 + srcP + 1) - + *(byte *)(v8 + srcP + 2); + for (int idx2 = 0; idx2 < 38; ++idx2) { + srcOffset = 3 * idx2; + col2 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2); - v12 = 0; - for (;;) { - v13 = v12 + 1; - if ( v13 == 38 ) - break; + col2 += minThreshold; + if (col2 < col1) + continue; + + col2 -= maxThreshold; + if (col2 > col1) + continue; - v20 = v13; - v8 = 3 * v8; - v14 = *(byte *)(v8 + srcP); - v15 = v14; - v14 = *(byte *)(v8 + srcP + 1); - v16 = v14 + v15; - v14 = *(byte *)(v8 + srcP + 2); - v17 = v14 + v16; - v12 = v20; - v18 = param1 + v17; - if (v18 >= v11 && (unsigned int)(v18 - param2) <= v11) { - v19 = v20; - if (!v20) - v19 = 1; - *(byte *)(v5 - 1) = v19; - break; - } + *(destPosP - 1) = (idx2 == 0) ? 1 : idx2; + break; } - - v6 = breakFlag - 1; - } while ( !breakFlag); + } } void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { -- cgit v1.2.3 From 9d93fca8d32c5b96e251380babb9af5bf5301d99 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 24 Oct 2012 21:54:54 +1100 Subject: HOPKINS: Manually implemented Reduc_Ecran --- engines/hopkins/graphics.cpp | 64 +++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4495698321..64af872727 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2470,52 +2470,38 @@ Video_Cont_Vbe: } // Reduce Screen -// TODO: Check that v9 doesn't get set anywhere (apart from the current init to zero) -void GraphicsManager::Reduc_Ecran(byte *a1, byte *a2, int a3, int a4, int a5, int a6, int a7) { - byte *v7; - byte *v8; - int v9 = 0; - int v10 = 0; - int v11; - int v12; - byte *v13; - int v14; +void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { + const byte *srcP; + byte *destP; + const byte *lineSrcP; - v7 = a3 + nbrligne2 * a4 + a1; - v8 = a2; - Red = a7; - Largeur = a5; + srcP = xp + nbrligne2 * yp + srcSurface; + destP = destSurface; + Red = zoom; + Largeur = width; Red_x = 0; Red_y = 0; - if (a7 < 100) { - Reduc_Ecran_L = Asm_Reduc(a5, Red); - Reduc_Ecran_H = Asm_Reduc(v9, Red); - v11 = Red; - do { - v14 = v10; - v13 = v7; - Red_y += v11; - if ((uint16)Red_y < 0x64u) { + if (zoom < 100) { + Reduc_Ecran_L = Asm_Reduc(width, Red); + Reduc_Ecran_H = Asm_Reduc(height, Red); + + for (int yCtr = 0; yCtr < Reduc_Ecran_H; ++yCtr, Red_y -= 100, srcP += nbrligne2) { + Red_y += Red; + if (Red_y < 100) { Red_x = 0; - v12 = Largeur; - do { - Red_x += v11; - if ((uint16)Red_x < 0x64u) { - *v8++ = *v7++; + lineSrcP = srcP; + + for (int xCtr = 0; xCtr < Largeur; ++xCtr) { + Red_x += Red; + if (Red_x < 100) { + *destP++ = *lineSrcP++; } else { - Red_x = Red_x - 100; - ++v7; + Red_x -= 100; + ++lineSrcP; } - --v12; - } while (v12); - v10 = v14; - v7 = nbrligne2 + v13; - } else { - Red_y = Red_y - 100; - v7 += nbrligne2; + } } - --v10; - } while (v10); + } } } -- cgit v1.2.3 From c78a92682b9502c8719ce946c3906de2d5d4bf60 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Oct 2012 10:43:31 +1100 Subject: HOPKINS: Renamed fields of VBobItem class --- engines/hopkins/graphics.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 64af872727..d603c63546 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1675,36 +1675,36 @@ void GraphicsManager::CopyAsm(const byte *surface) { } while (v4); } -void GraphicsManager::Restore_Mem(byte *a1, const byte *a2, int a3, int a4, unsigned int a5, int a6) { +void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { byte *v6; int v7; - const byte *v8; + const byte *srcP; unsigned int i; - int v10; + int yCtr; - v6 = a3 + nbrligne2 * a4 + a1; - v7 = a6; - v8 = a2; + v6 = xp + nbrligne2 * yp + destSurface; + v7 = height; + srcP = src; do { - v10 = v7; - if (a5 & 1) { - memcpy(v6, v8, a5); - v8 += a5; - v6 += a5; - } else if (a5 & 2) { - for (i = a5 >> 1; i; --i) { - *(uint16 *)v6 = *(uint16 *)v8; - v8 += 2; + yCtr = v7; + if (width & 1) { + memcpy(v6, srcP, width); + srcP += width; + v6 += width; + } else if (width & 2) { + for (i = width >> 1; i; --i) { + *(uint16 *)v6 = *(uint16 *)srcP; + srcP += 2; v6 += 2; } } else { - memcpy(v6, v8, 4 * (a5 >> 2)); - v8 += 4 * (a5 >> 2); - v6 += 4 * (a5 >> 2); + memcpy(v6, srcP, 4 * (width >> 2)); + srcP += 4 * (width >> 2); + v6 += 4 * (width >> 2); } - v6 = nbrligne2 + v6 - a5; - v7 = v10 - 1; - } while (v10 != 1); + v6 = nbrligne2 + v6 - width; + v7 = yCtr - 1; + } while (yCtr != 1); } int GraphicsManager::Reel_Zoom(int v, int percentage) { -- cgit v1.2.3 From 68495604f2241e941a1be5637bca30f4855708df Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Oct 2012 10:43:08 +1100 Subject: HOPKINS: Fixed Reduc_Ecran method --- engines/hopkins/graphics.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d603c63546..f9505d0372 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2485,7 +2485,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Reduc_Ecran_L = Asm_Reduc(width, Red); Reduc_Ecran_H = Asm_Reduc(height, Red); - for (int yCtr = 0; yCtr < Reduc_Ecran_H; ++yCtr, Red_y -= 100, srcP += nbrligne2) { + for (int yCtr = 0; yCtr < height; ++yCtr, srcP += nbrligne2) { Red_y += Red; if (Red_y < 100) { Red_x = 0; @@ -2500,6 +2500,8 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int ++lineSrcP; } } + } else { + Red_y -= 100; } } } -- cgit v1.2.3 From 54b6f47ad9f22529abd29c08abf217a1e4e70118 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Oct 2012 18:49:41 +1100 Subject: HOPKINS: Bugfix to Copy_Video_Vbe16a --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f9505d0372..ae26c40209 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1264,7 +1264,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { v3 += 5; } Video_Cont_Vbe16a: - WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); + WRITE_LE_UINT16((byte *)VideoPtr->pixels + v2 * 2, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); ++v3; ++v2; } -- cgit v1.2.3 From 58ac9c83ec4ecbaa724eab80ac72e62ec35955c1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 28 Oct 2012 22:10:14 +1100 Subject: HOPKINS: Fixed the type casting in copy video methods --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ae26c40209..ea1d44f442 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2420,7 +2420,7 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { byteVal = *(srcPtr + 2); srcPtr += 2; } else if (byteVal == (byte)-2) { - destOffset += (int16)READ_LE_UINT16(srcPtr + 1); + destOffset += READ_LE_UINT16(srcPtr + 1); byteVal = *(srcPtr + 3); srcPtr += 3; } else { @@ -2454,7 +2454,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { byteVal = *(srcP + 2); srcP += 2; } else if (byteVal == (byte)-2) { - destOffset += (int16)READ_LE_UINT16(srcP + 1); + destOffset += READ_LE_UINT16(srcP + 1); byteVal = *(srcP + 3); srcP += 3; } else { -- cgit v1.2.3 From e99a5c02b59784efc659f5ef77292909f7daf6b0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Oct 2012 00:00:18 +1100 Subject: HOPKINS: Added lots of shouldQuit() checks to the loops in the script code --- engines/hopkins/graphics.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ea1d44f442..519c193235 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2326,7 +2326,10 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { } else { v11 = 0; do { - v6 = _vm->_scriptManager.Traduction(ptr + 20 * v2); + v6 = _vm->_scriptManager.Traduction(ptr + 20 * v2); + if (_vm->shouldQuit()) + return; + if (v6 == 2) v2 = _vm->_scriptManager.Control_Goto((ptr + 20 * v2)); if (v6 == 3) -- cgit v1.2.3 From 9d18e3fa59658a58e46deba75a0a231389ffd2f6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 28 Oct 2012 22:38:34 +0100 Subject: HOPKINS: Replace some 0/1 by false/true for boolean variables --- engines/hopkins/graphics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 519c193235..f24955b9ec 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -104,9 +104,9 @@ void GraphicsManager::SET_MODE(int width, int height) { SDL_ECHELLE = _vm->_globals.XZOOM; int bpp = 8; - if (_vm->_globals.XFORCE8 == 1) + if (_vm->_globals.XFORCE8 == true) bpp = 8; - if (_vm->_globals.XFORCE16 == 1) + if (_vm->_globals.XFORCE16 == true) bpp = 16; if (SDL_ECHELLE) { @@ -1547,7 +1547,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (bloc.field0 != 1) continue; - if (_vm->_eventsManager.CASSE != 0) { + if (_vm->_eventsManager.CASSE != false) { if (Winbpp == 1) { Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); } else if (Winbpp == 2) { @@ -2311,14 +2311,14 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { if (!_vm->_globals.NOSPRECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(v13, 8); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_globals.CAT_FLAG = 0; + _vm->_globals.CAT_FLAG = false; _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); } else { - _vm->_globals.CAT_FLAG = 1; + _vm->_globals.CAT_FLAG = true; _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); } _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - _vm->_globals.CAT_FLAG = 0; + _vm->_globals.CAT_FLAG = false; } } if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { -- cgit v1.2.3 From 39d2ead935ad81052e0a68daafcaa04021caf305 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Oct 2012 09:08:25 +1100 Subject: HOPKINS: Method parameter renames in GraphicsManager class --- engines/hopkins/graphics.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f24955b9ec..bf6a900804 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -245,11 +245,11 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { memcpy(VESA_BUFFER, VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } -void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) { +void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { for (int idx = 0; idx < 256; ++idx) TABLE_COUL[idx] = idx; - Trans_bloc(TABLE_COUL, palette, 256, a1, a2); + Trans_bloc(TABLE_COUL, palette, 256, minIndex, maxIndex); for (int idx = 0; idx < 256; ++idx) { byte v = TABLE_COUL[idx]; @@ -1270,7 +1270,7 @@ Video_Cont_Vbe16a: } } -void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, unsigned int width, int height) { +void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) { const byte *srcP; byte *destP; int rowCount; @@ -2285,7 +2285,7 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { OPTI_INI(file, 2); } -void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { +void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { int v2; unsigned int v3; int v6; @@ -2304,7 +2304,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); } - if (!a2) { + if (!mode) { v13 = file + ".spr"; if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); @@ -2343,7 +2343,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int a2) { } while (v11 != 1); } _vm->_globals.dos_free2(ptr); - if (a2 != 1) { + if (mode != 1) { if (g_PTRNUL != _vm->_globals.COUCOU) _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); @@ -2514,7 +2514,7 @@ void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int wid memset(surface + xp + nbrligne2 * yp, col, width); } -void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, char col) { +void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte col) { byte *v5; int v6; -- cgit v1.2.3 From 3f0b6efe0e6085ab3de5c6658e4c6157bca75797 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Oct 2012 09:10:42 +1100 Subject: HOPKINS: Removed duplicate souris_max method --- engines/hopkins/graphics.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index bf6a900804..01d61d51e9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -198,7 +198,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { Cls_Pal(); if (!DOUBLE_ECRAN) { - souris_max(); + _vm->_eventsManager.souris_max(); SCANLINE(SCREEN_WIDTH); max_x = SCREEN_WIDTH; DD_Lock(); @@ -470,11 +470,6 @@ void GraphicsManager::Cls_Pal() { } } -// TODO: Check if it's normal it's defined two times (also in events). -void GraphicsManager::souris_max() { - // Original has no implementation -} - void GraphicsManager::SCANLINE(int pitch) { nbrligne = nbrligne2 = pitch; } -- cgit v1.2.3 From 32afe8d7bacc50887d4b6e4006aa164b2e67a4a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 30 Oct 2012 22:48:41 +1100 Subject: HOPKINS: Renaming local variables in graphics.cpp --- engines/hopkins/graphics.cpp | 933 +++++++++++++++++++++---------------------- 1 file changed, 457 insertions(+), 476 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 01d61d51e9..d0ec1d6545 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -475,88 +475,88 @@ void GraphicsManager::SCANLINE(int pitch) { } void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *v7; - byte *v8; - int v9; - int v10; - byte *v11; - const byte *v12; - unsigned int v13; + const byte *srcP; + byte *destP; + int yNext; + int yCtr; + byte *dest2P; + const byte *src2P; + unsigned int widthRemaining; assert(VideoPtr); - v7 = xs + nbrligne2 * ys + surface; - v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; - v9 = height; + srcP = xs + nbrligne2 * ys + surface; + destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; + yNext = height; do { - v10 = v9; - memcpy((byte *)v8, (const byte *)v7, 4 * (width >> 2)); - v12 = (const byte *)(v7 + 4 * (width >> 2)); - v11 = (byte *)(v8 + 4 * (width >> 2)); - v13 = width - 4 * (width >> 2); - memcpy(v11, v12, v13); - v8 = v11 + v13 + WinScan - width; - v7 = v12 + v13 + nbrligne2 - width; - v9 = v10 - 1; - } while (v10 != 1); + yCtr = yNext; + memcpy((byte *)destP, (const byte *)srcP, 4 * (width >> 2)); + src2P = (const byte *)(srcP + 4 * (width >> 2)); + dest2P = (byte *)(destP + 4 * (width >> 2)); + widthRemaining = width - 4 * (width >> 2); + memcpy(dest2P, src2P, widthRemaining); + destP = dest2P + widthRemaining + WinScan - width; + srcP = src2P + widthRemaining + nbrligne2 - width; + yNext = yCtr - 1; + } while (yCtr != 1); } void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *v7; - byte *v8; - int v9; - int v10; - int v11; + const byte *srcP; + byte *destP; + int destPitch; + int srcPitch; + int yCtr; assert(VideoPtr); - v7 = xs + nbrligne2 * ys + surface; - v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; - v9 = WinScan - SCREEN_WIDTH; - v10 = nbrligne2 - SCREEN_WIDTH; - v11 = height; + srcP = xs + nbrligne2 * ys + surface; + destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; + destPitch = WinScan - SCREEN_WIDTH; + srcPitch = nbrligne2 - SCREEN_WIDTH; + yCtr = height; do { - memcpy(v8, v7, SCREEN_WIDTH); - v8 = v8 + v9 + SCREEN_WIDTH; - v7 = v7 + v10 + SCREEN_WIDTH; - --v11; - } while (v11); + memcpy(destP, srcP, SCREEN_WIDTH); + destP = destP + destPitch + SCREEN_WIDTH; + srcP = srcP + srcPitch + SCREEN_WIDTH; + --yCtr; + } while (yCtr); } void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *v7; - byte *v8; - int v9; - int v10; - byte v11; - const byte *v12; - byte *v13; + const byte *srcP; + byte *destP; + int yCtr; + int xCtr; + byte srcByte; + const byte *srcCopyP; + byte *destCopyP; assert(VideoPtr); - v7 = xs + nbrligne2 * ys + surface; - v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels; - v9 = height; + srcP = xs + nbrligne2 * ys + surface; + destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; + yCtr = height; Agr_x = 0; Agr_y = 0; Agr_Flag_y = 0; do { for (;;) { - v13 = v8; - v12 = v7; - v10 = width; + destCopyP = destP; + srcCopyP = srcP; + xCtr = width; Agr_x = 0; do { - v11 = *v7; - *v8++ = *v7++; + srcByte = *srcP; + *destP++ = *srcP++; Agr_x += SDL_ECHELLE; if ((unsigned int)Agr_x >= 100) { Agr_x -= 100; - *v8++ = v11; + *destP++ = srcByte; } - --v10; - } while ( v10 ); + --xCtr; + } while ( xCtr ); - v7 = v12; - v8 = WinScan + v13; + srcP = srcCopyP; + destP = WinScan + destCopyP; if (Agr_Flag_y) break; @@ -569,9 +569,9 @@ void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, } Agr_Flag_y = 0; - v7 = nbrligne2 + v12; - --v9; - } while (v9); + srcP = nbrligne2 + srcCopyP; + --yCtr; + } while (yCtr); } /** @@ -600,52 +600,53 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, DD_Unlock(); } +// TODO: See if PAL_PIXELS can be converted to a uint16 array void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *v7; - const byte *v8; - int v9; - int v10; - const byte *v11; - int v12; - int v13; - const byte *v14; - const byte *v15; + const byte *srcP; + const byte *destP; + int yNext; + int xCtr; + const byte *palette; + int pixelWord; + int yCtr; + const byte *srcCopyP; + const byte *destCopyP; assert(VideoPtr); - v7 = xs + nbrligne2 * ys + surface; - v8 = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; - v9 = height; + srcP = xs + nbrligne2 * ys + surface; + destP = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; + yNext = height; Agr_x = 0; Agr_y = 0; Agr_Flag_y = 0; do { for (;;) { - v15 = v8; - v14 = v7; - v10 = width; - v13 = v9; - v11 = PAL_PIXELS; + destCopyP = destP; + srcCopyP = srcP; + xCtr = width; + yCtr = yNext; + palette = PAL_PIXELS; Agr_x = 0; do { - v12 = *(uint16 *)(v11 + 2 * *v7); - *(uint16 *)v8 = v12; - ++v7; - v8 += 2; + pixelWord = *(uint16 *)(palette + 2 * *srcP); + *(uint16 *)destP = pixelWord; + ++srcP; + destP += 2; Agr_x += SDL_ECHELLE; if ((unsigned int)Agr_x >= 100) { Agr_x -= 100; - *(uint16 *)v8 = v12; - v8 += 2; + *(uint16 *)destP = pixelWord; + destP += 2; } - --v10; - } while (v10); + --xCtr; + } while (xCtr); - v9 = v13; - v7 = v14; - v8 = WinScan + v15; + yNext = yCtr; + srcP = srcCopyP; + destP = WinScan + destCopyP; if (Agr_Flag_y == 1) break; @@ -659,102 +660,102 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } Agr_Flag_y = 0; - v7 = nbrligne2 + v14; - v9 = v13 - 1; - } while (v13 != 1); + srcP = nbrligne2 + srcCopyP; + yNext = yCtr - 1; + } while (yCtr != 1); } void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - const byte *v7; - byte *v8; - int v9; - int v10; - byte v11; - byte *v12; - byte *v13; - byte *v14; - byte *v15; - const byte *v16; - int v17; + const byte *srcP; + byte *destP; + int yCount; + int xCount; + byte srcByte; + byte *loopDestP; + byte *loopSrcP; + byte *loopSrc2P; + byte *tempDestP; + const byte *tempSrcP; + int yCtr; assert(VideoPtr); - v7 = xp + 320 * yp + surface; - v8 = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels; - v9 = height; + srcP = xp + 320 * yp + surface; + destP = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels; + yCount = height; do { - v17 = v9; - v10 = width; - v16 = v7; - v15 = v8; + yCtr = yCount; + xCount = width; + tempSrcP = srcP; + tempDestP = destP; do { - v11 = *v7; - *v8 = *v7; - v12 = WinScan + v8; - *v12 = v11; - v13 = v12 - WinScan + 1; - *v13 = v11; - v14 = WinScan + v13; - *v14 = v11; - ++v7; - v8 = v14 - WinScan + 1; - --v10; - } while (v10); + srcByte = *srcP; + *destP = *srcP; + loopDestP = WinScan + destP; + *loopDestP = srcByte; + loopSrcP = loopDestP - WinScan + 1; + *loopSrcP = srcByte; + loopSrc2P = WinScan + loopSrcP; + *loopSrc2P = srcByte; + ++srcP; + destP = loopSrc2P - WinScan + 1; + --xCount; + } while (xCount); - v8 = WinScan + WinScan + v15; - v7 = v16 + 320; - v9 = v17 - 1; - } while (v17 != 1); + destP = WinScan + WinScan + tempDestP; + srcP = tempSrcP + 320; + yCount = yCtr - 1; + } while (yCtr != 1); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - const byte *v7; - uint16 *v8; - int v9; - int v10; - int v11; - const byte *v12; - uint16 *v13; - uint16 v14; - uint16 *v15; - int v16; - uint16 *v17; - const byte *v18; - int v19; + const byte *srcP; + uint16 *destP; + int yCount; + int xCount; + int xCtr; + const byte *palette; + uint16 *tempSrcP; + uint16 srcByte; + uint16 *tempDestP; + int savedXCount; + uint16 *loopDestP; + const byte *loopSrcP; + int yCtr; assert(VideoPtr); - v7 = xp + 320 * yp + surface; - v8 = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels); - v9 = height; - v10 = width; + srcP = xp + 320 * yp + surface; + destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels); + yCount = height; + xCount = width; do { - v19 = v9; - v11 = v10; - v18 = v7; - v17 = v8; - v16 = v10; - v12 = PAL_PIXELS; + yCtr = yCount; + xCtr = xCount; + loopSrcP = srcP; + loopDestP = destP; + savedXCount = xCount; + palette = PAL_PIXELS; do { - v13 = (uint16 *)(v12 + 2 * *v7); - v14 = *v13; - *v8 = *v13; - *(v8 + 1) = v14; + tempSrcP = (uint16 *)(palette + 2 * *srcP); + srcByte = *tempSrcP; + *destP = *tempSrcP; + *(destP + 1) = srcByte; - v15 = (uint16 *)((byte *)v8 + WinScan); - *v15 = v14; - *(v15 + 1) = v14; - ++v7; - v8 = (uint16 *)((byte *)v15 - WinScan + 4); - --v11; - } while (v11); + tempDestP = (uint16 *)((byte *)destP + WinScan); + *tempDestP = srcByte; + *(tempDestP + 1) = srcByte; + ++srcP; + destP = (uint16 *)((byte *)tempDestP - WinScan + 4); + --xCtr; + } while (xCtr); - v10 = v16; - v8 = (uint16 *)((byte *)v17 + WinScan * 2); - v7 = v18 + 320; - v9 = v19 - 1; - } while (v19 != 1); + xCount = savedXCount; + destP = (uint16 *)((byte *)loopDestP + WinScan * 2); + srcP = loopSrcP + 320; + yCount = yCtr - 1; + } while (yCtr != 1); } void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) { @@ -819,29 +820,29 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface } void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { - int v3; - int v4; - int v5; - int v6; - int v7; - int v8; - int v9; - int v10; - int v12; - uint16 v13; + int palByte; + int palIndex; + int palDataIndex; + int palCtr3; + int palCtr4; + int palCtr5; + int palValue; + int palCtr2; + int palCtr1; + uint16 palMax; byte palData[PALETTE_BLOCK_SIZE]; - int v15[PALETTE_BLOCK_SIZE]; + int tempPalette[PALETTE_BLOCK_SIZE]; - v13 = v3 = FADESPD; + palMax = palByte = FADESPD; if (palette) { - v4 = 0; + palIndex = 0; do { - v5 = v4; - v3 = *(v4 + palette); - v3 <<= 8; - v15[v5] = v3; - palData[v5] = *(v4++ + palette); - } while (v4 < PALETTE_BLOCK_SIZE); + palDataIndex = palIndex; + palByte = *(palIndex + palette); + palByte <<= 8; + tempPalette[palDataIndex] = palByte; + palData[palDataIndex] = *(palIndex++ + palette); + } while (palIndex < PALETTE_BLOCK_SIZE); setpal_vga256(palData); if (Winbpp == 2) { @@ -852,17 +853,17 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac DD_VBL(); } - v6 = 0; - if ((int)v13 > 0) { + palCtr3 = 0; + if (palMax > 0) { do { - v7 = 0; + palCtr4 = 0; do { - v8 = v7; - v9 = v15[v7] - (*(v7 + palette) << 8) / v13; - v15[v8] = v9; - palData[v8] = (v9 >> 8) & 0xff; - ++v7; - } while (v7 < (PALETTE_BLOCK_SIZE)); + palCtr5 = palCtr4; + palValue = tempPalette[palCtr4] - (*(palCtr4 + palette) << 8) / palMax; + tempPalette[palCtr5] = palValue; + palData[palCtr5] = (palValue >> 8) & 0xff; + ++palCtr4; + } while (palCtr4 < (PALETTE_BLOCK_SIZE)); setpal_vga256(palData); if (Winbpp == 2) { @@ -873,14 +874,14 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac DD_VBL(); } - ++v6; - } while ((int)v13 > v6); + ++palCtr3; + } while (palMax > palCtr3); } - v10 = 0; + palCtr2 = 0; do { - palData[v10++] = 0; - } while (v10 < (PALETTE_BLOCK_SIZE)); + palData[palCtr2++] = 0; + } while (palCtr2 < (PALETTE_BLOCK_SIZE)); setpal_vga256(palData); @@ -892,10 +893,10 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac goto LABEL_28; } } else { - v12 = 0; + palCtr1 = 0; do { - palData[v12++] = 0; - } while (v12 < (PALETTE_BLOCK_SIZE)); + palData[palCtr1++] = 0; + } while (palCtr1 < (PALETTE_BLOCK_SIZE)); setpal_vga256(palData); if (Winbpp == 2) { @@ -1035,139 +1036,123 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { } void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { - int v; - int v3; - int v4; - const byte *v5; - byte v6; - int v7; - byte v8; - byte *v9; - int v10; - byte v11; - byte *v12; - - v = 0; - v3 = 0; - v4 = 0; - v5 = srcData; + int rleValue; + int destOffset; + const byte *srcP; + byte srcByte; + byte destLen1; + byte *destSlice1P; + byte destLen2; + byte *destSlice2P; + + rleValue = 0; + destOffset = 0; + srcP = srcData; for (;;) { - v6 = *v5; - if (*v5 < 0xDEu) + srcByte = *srcP; + if (*srcP < 0xDEu) goto Video_Cont3_wVbe; - if (v6 == (byte)-4) + if (srcByte == (byte)-4) return; - if (v6 < 0xFBu) { - v3 += (byte)(*v5 + 35); - v6 = *(v5++ + 1); - } else if (v6 == (byte)-3) { - v3 += *(v5 + 1); - v6 = *(v5 + 2); - v5 += 2; - } else if (v6 == (byte)-2) { - v3 += READ_LE_UINT16(v5 + 1); - v6 = *(v5 + 3); - v5 += 3; + if (srcByte < 0xFBu) { + destOffset += (byte)(*srcP + 35); + srcByte = *(srcP++ + 1); + } else if (srcByte == (byte)-3) { + destOffset += *(srcP + 1); + srcByte = *(srcP + 2); + srcP += 2; + } else if (srcByte == (byte)-2) { + destOffset += READ_LE_UINT16(srcP + 1); + srcByte = *(srcP + 3); + srcP += 3; } else { - v3 += READ_LE_UINT32(v5 + 1); - v6 = *(v5 + 5); - v5 += 5; + destOffset += READ_LE_UINT32(srcP + 1); + srcByte = *(srcP + 5); + srcP += 5; } Video_Cont3_wVbe: - if (v6 > 0xD2u) { - if (v6 == (byte)-45) { - v7 = v4; - v8 = *(v5 + 1); - v = *(v5 + 2); - v9 = v3 + destSurface; - v3 += v8; - memset(v9, v, v8); - v5 += 3; - v4 = v7; + if (srcByte > 0xD2u) { + if (srcByte == (byte)-45) { + destLen1 = *(srcP + 1); + rleValue = *(srcP + 2); + destSlice1P = destOffset + destSurface; + destOffset += destLen1; + memset(destSlice1P, rleValue, destLen1); + srcP += 3; } else { - v10 = v4; - v11 = (byte)(*v5 + 45); - v = *(v5 + 1); - v12 = v3 + destSurface; - v3 += v11; - memset(v12, v, v11); - v5 += 2; - v4 = v10; + destLen2 = (byte)(*srcP + 45); + rleValue = *(srcP + 1); + destSlice2P = destOffset + destSurface; + destOffset += destLen2; + memset(destSlice2P, rleValue, destLen2); + srcP += 2; } } else { - *(v3 + destSurface) = v6; - ++v5; - ++v3; + *(destOffset + destSurface) = srcByte; + ++srcP; + ++destOffset; } }} void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { - int result; - int v2; - int v3; - const byte *v4; - uint8 v5; - int v6; - unsigned int v7; - byte *v8; - int v9; - unsigned int v10; - byte *v11; + int rleValue; + int destOffset; + const byte *srcP; + uint8 srcByte; + int destLen1; + byte *destSlice1P; + int destLen2; + byte *destSlice2P; assert(VideoPtr); - result = 0; - v2 = 0; - v3 = 0; - v4 = srcData; + rleValue = 0; + destOffset = 0; + srcP = srcData; for (;;) { - v5 = *v4; - if (*v4 < 222) + srcByte = *srcP; + if (*srcP < 222) goto Video_Cont3_Vbe; - if (v5 == 252) + if (srcByte == 252) return; - if (v5 < 251) { - v2 += *v4 + 35; - v5 = *(v4++ + 1); - } else if (v5 == (byte)-3) { - v2 += *(v4 + 1); - v5 = *(v4 + 2); - v4 += 2; - } else if (v5 == (byte)-2) { - v2 += READ_LE_UINT16(v4 + 1); - v5 = *(v4 + 3); - v4 += 3; + if (srcByte < 251) { + destOffset += *srcP + 35; + srcByte = *(srcP++ + 1); + } else if (srcByte == (byte)-3) { + destOffset += *(srcP + 1); + srcByte = *(srcP + 2); + srcP += 2; + } else if (srcByte == (byte)-2) { + destOffset += READ_LE_UINT16(srcP + 1); + srcByte = *(srcP + 3); + srcP += 3; } else { - v2 += READ_LE_UINT32(v4 + 1); - v5 = *(v4 + 5); - v4 += 5; + destOffset += READ_LE_UINT32(srcP + 1); + srcByte = *(srcP + 5); + srcP += 5; } Video_Cont3_Vbe: - if (v5 > 210) { - if (v5 == 211) { - v6 = v3; - v7 = *(v4 + 1); - result = *(v4 + 2); - v8 = v2 + (byte *)VideoPtr->pixels; - v2 += v7; - memset(v8, result, v7); - v4 += 3; - v3 = v6; + if (srcByte > 210) { + if (srcByte == 211) { + destLen1 = *(srcP + 1); + rleValue = *(srcP + 2); + destSlice1P = destOffset + (byte *)VideoPtr->pixels; + destOffset += destLen1; + memset(destSlice1P, rleValue, destLen1); + srcP += 3; } else { - v9 = v3; - v10 = (byte)(*v4 + 45); - result = *(v4 + 1); - v11 = (byte *)(v2 + (byte *)VideoPtr->pixels); - v2 += v10; - memset(v11, result, v10); - v4 += 2; - v3 = v9; + destLen2 = (byte)(*srcP + 45); + rleValue = *(srcP + 1); + destSlice2P = (byte *)(destOffset + (byte *)VideoPtr->pixels); + destOffset += destLen2; + memset(destSlice2P, rleValue, destLen2); + srcP += 2; } } else { - *(v2 + (byte *)VideoPtr->pixels) = v5; - ++v4; - ++v2; + *(destOffset + (byte *)VideoPtr->pixels) = srcByte; + ++srcP; + ++destOffset; } } } @@ -1233,35 +1218,35 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { - int v2; - const byte *v3; - byte v4; + int destOffset; + const byte *srcP; + byte pixelIndex; - v2 = 0; - v3 = srcData; + destOffset = 0; + srcP = srcData; for (;;) { - v4 = *v3; - if (*v3 < 0xFCu) + pixelIndex = *srcP; + if (*srcP < 0xFCu) goto Video_Cont_Vbe16a; - if (v4 == (byte)-4) + if (pixelIndex == (byte)-4) return; - if (v4 == (byte)-3) { - v2 += *(v3 + 1); - v4 = *(v3 + 2); - v3 += 2; - } else if (v4 == (byte)-2) { - v2 += READ_LE_UINT16(v3 + 1); - v4 = *(v3 + 3); - v3 += 3; + if (pixelIndex == (byte)-3) { + destOffset += *(srcP + 1); + pixelIndex = *(srcP + 2); + srcP += 2; + } else if (pixelIndex == (byte)-2) { + destOffset += READ_LE_UINT16(srcP + 1); + pixelIndex = *(srcP + 3); + srcP += 3; } else { - v2 += READ_LE_UINT32(v3 + 1); - v4 = *(v3 + 5); - v3 += 5; + destOffset += READ_LE_UINT32(srcP + 1); + pixelIndex = *(srcP + 5); + srcP += 5; } Video_Cont_Vbe16a: - WRITE_LE_UINT16((byte *)VideoPtr->pixels + v2 * 2, READ_LE_UINT16(PAL_PIXELS + 2 * v4)); - ++v3; - ++v2; + WRITE_LE_UINT16((byte *)VideoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex)); + ++srcP; + ++destOffset; } } @@ -1269,7 +1254,7 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int const byte *srcP; byte *destP; int rowCount; - unsigned int i; + int i; int rowCount2; // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within @@ -1455,15 +1440,15 @@ void GraphicsManager::VISU_ALL() { } void GraphicsManager::RESET_SEGMENT_VESA() { - int v1; - int v2; + int idx; + int blocCount; if (_vm->_globals.NBBLOC > 0) { - v1 = 0; - v2 = _vm->_globals.NBBLOC; + idx = 0; + blocCount = _vm->_globals.NBBLOC; do { - _vm->_globals.BLOC[v1++].field0 = 0; - } while (v1 != v2); + _vm->_globals.BLOC[idx++].field0 = 0; + } while (idx != blocCount); _vm->_globals.NBBLOC = 0; } @@ -1471,44 +1456,44 @@ void GraphicsManager::RESET_SEGMENT_VESA() { // Add VESA Segment void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { - int v4; - int v5; - int16 v6; - int16 v10; + int tempX; + int blocCount; + int16 blocIndex; + bool addFlag; - v4 = x1; - v10 = 1; + tempX = x1; + addFlag = true; if (x2 > max_x) x2 = max_x; if (y2 > max_y) y2 = max_y; if (x1 < min_x) - v4 = min_x; + tempX = min_x; if (y1 < min_y) y1 = min_y; - v5 = _vm->_globals.NBBLOC; + blocCount = _vm->_globals.NBBLOC; if (_vm->_globals.NBBLOC > 1) { - v6 = 0; + blocIndex = 0; do { - BlocItem &bloc = _vm->_globals.BLOC[v6]; + BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; if (bloc.field0 == 1 - && v4 >= bloc.x1 && x2 <= bloc.x2 + && tempX >= bloc.x1 && x2 <= bloc.x2 && y1 >= bloc.y1 && y2 <= bloc.y2) - v10 = 0; - ++v6; - v5 = v6; - } while (_vm->_globals.NBBLOC + 1 != v6); + addFlag = false; + ++blocIndex; + blocCount = blocIndex; + } while (_vm->_globals.NBBLOC + 1 != blocIndex); } - if (v10 == 1) { + if (addFlag) { assert(_vm->_globals.NBBLOC < 50); BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; bloc.field0 = 1; - bloc.x1 = v4; + bloc.x1 = tempX; bloc.x2 = x2; bloc.y1 = y1; bloc.y2 = y2; @@ -1629,76 +1614,76 @@ void GraphicsManager::Affiche_Segment_Vesa() { } void GraphicsManager::CopyAsm(const byte *surface) { - const byte *v1; + const byte *srcP; byte srcByte; - byte *v3; - signed int v4; - signed int v5; - byte *v6; - byte *v7; - byte *v8; - byte *v9; - const byte *v10; + byte *destP; + int yCtr; + int xCtr; + byte *dest1P; + byte *dest2P; + byte *dest3P; + byte *destPitch; + const byte *srcPitch; assert(VideoPtr); - v1 = surface; + srcP = surface; srcByte = 30 * WinScan; - v3 = (byte *)VideoPtr->pixels + 30 * WinScan; - v4 = 200; + destP = (byte *)VideoPtr->pixels + 30 * WinScan; + yCtr = 200; do { - v10 = v1; - v9 = v3; - v5 = 320; + srcPitch = srcP; + destPitch = destP; + xCtr = 320; do { - srcByte = *v1; - *v3 = *v1; - v6 = WinScan + v3; - *v6 = srcByte; - v7 = v6 - WinScan + 1; - *v7 = srcByte; - v8 = WinScan + v7; - *v8 = srcByte; - v3 = v8 - WinScan + 1; - ++v1; - --v5; - } while (v5); + srcByte = *srcP; + *destP = *srcP; + dest1P = WinScan + destP; + *dest1P = srcByte; + dest2P = dest1P - WinScan + 1; + *dest2P = srcByte; + dest3P = WinScan + dest2P; + *dest3P = srcByte; + destP = dest3P - WinScan + 1; + ++srcP; + --xCtr; + } while (xCtr); - v1 = v10 + 320; - v3 = WinScan + WinScan + v9; - --v4; - } while (v4); + srcP = srcPitch + 320; + destP = WinScan + WinScan + destPitch; + --yCtr; + } while (yCtr); } void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { - byte *v6; - int v7; + byte *destP; + int yNext; const byte *srcP; - unsigned int i; + int i; int yCtr; - v6 = xp + nbrligne2 * yp + destSurface; - v7 = height; + destP = xp + nbrligne2 * yp + destSurface; + yNext = height; srcP = src; do { - yCtr = v7; + yCtr = yNext; if (width & 1) { - memcpy(v6, srcP, width); + memcpy(destP, srcP, width); srcP += width; - v6 += width; + destP += width; } else if (width & 2) { for (i = width >> 1; i; --i) { - *(uint16 *)v6 = *(uint16 *)srcP; + *(uint16 *)destP = *(uint16 *)srcP; srcP += 2; - v6 += 2; + destP += 2; } } else { - memcpy(v6, srcP, 4 * (width >> 2)); + memcpy(destP, srcP, 4 * (width >> 2)); srcP += 4 * (width >> 2); - v6 += 4 * (width >> 2); + destP += 4 * (width >> 2); } - v6 = nbrligne2 + v6 - width; - v7 = yCtr - 1; + destP = nbrligne2 + destP - width; + yNext = yCtr - 1; } while (yCtr != 1); } @@ -2163,7 +2148,7 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int int top; int croppedWidth; int croppedHeight; - int v11; + int xRight; int height2; int top2; int left; @@ -2184,8 +2169,8 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int top2 = top; if (top + croppedHeight > max_y) croppedHeight = max_y - top; - v11 = left + croppedWidth; - if (v11 > max_x) + xRight = left + croppedWidth; + if (xRight > max_x) croppedWidth = max_x - left; if (croppedWidth > 0 && croppedHeight > 0) { @@ -2223,51 +2208,51 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned // Display Font void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { - const byte *v6; + const byte *spriteDataP; int i; - const byte *v8; - int v9; - int v10; - const byte *v11; + const byte *spriteSizeP; + int spriteWidth; + int spriteHeight; + const byte *spritePixelsP; byte *destP; - int v13; - byte v14; + int xCtr; + byte destByte; byte *destLineP; - int v16; + int yCtr; - v6 = spriteData + 3; + spriteDataP = spriteData + 3; for (i = characterIndex; i; --i) - v6 += READ_LE_UINT32(v6) + 16; - - v9 = 0; - v10 = 0; - v8 = v6 + 4; - v9 = (int16)READ_LE_UINT16(v8); - v8 += 2; - v10 = (int16)READ_LE_UINT16(v8); - v11 = v8 + 10; + spriteDataP += READ_LE_UINT32(spriteDataP) + 16; + + spriteWidth = 0; + spriteHeight = 0; + spriteSizeP = spriteDataP + 4; + spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + spriteSizeP += 2; + spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); + spritePixelsP = spriteSizeP + 10; destP = surface + xp + nbrligne2 * yp; - Largeur = v9; + Largeur = spriteWidth; do { - v16 = v10; + yCtr = spriteHeight; destLineP = destP; - v13 = v9; + xCtr = spriteWidth; do { - v14 = *v11; - if (*v11) { - if (v14 == (byte)-4) - v14 = colour; - *destP = v14; + destByte = *spritePixelsP; + if (*spritePixelsP) { + if (destByte == (byte)-4) + destByte = colour; + *destP = destByte; } ++destP; - ++v11; - --v13; - } while (v13); + ++spritePixelsP; + --xCtr; + } while (xCtr); destP = nbrligne2 + destLineP; - v10 = v16 - 1; - } while (v16 != 1); + spriteHeight = yCtr - 1; + } while (yCtr != 1); } // Init Screen @@ -2281,33 +2266,29 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { } void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { - int v2; - unsigned int v3; - int v6; - unsigned int v9; - signed int v11; + int dataOffset; + int dataVal1; + bool doneFlag; byte *ptr; - Common::String v13; + Common::String filename; - v2 = 1; - v3 = 0; - v9 = 0; + dataOffset = 1; - v13 = file + ".ini"; - ptr = _vm->_fileManager.RECHERCHE_CAT(v13, 1); + filename = file + ".ini"; + ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); } if (!mode) { - v13 = file + ".spr"; + filename = file + ".spr"; if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(v13, 8); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); } else { _vm->_globals.CAT_FLAG = true; _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); @@ -2319,34 +2300,34 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { error("Error, file not ini"); } else { - v11 = 0; + doneFlag = false; do { - v6 = _vm->_scriptManager.Traduction(ptr + 20 * v2); + dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset); if (_vm->shouldQuit()) return; - if (v6 == 2) - v2 = _vm->_scriptManager.Control_Goto((ptr + 20 * v2)); - if (v6 == 3) - v2 = _vm->_scriptManager.Control_If(ptr, v2); - if (v2 == -1) + if (dataVal1 == 2) + dataOffset = _vm->_scriptManager.Control_Goto((ptr + 20 * dataOffset)); + if (dataVal1 == 3) + dataOffset = _vm->_scriptManager.Control_If(ptr, dataOffset); + if (dataOffset == -1) error("Error, defective IFF"); - if (v6 == 1 || v6 == 4) - ++v2; - if (!v6 || v6 == 5) - v11 = 1; - } while (v11 != 1); + if (dataVal1 == 1 || dataVal1 == 4) + ++dataOffset; + if (!dataVal1 || dataVal1 == 5) + doneFlag = true; + } while (!doneFlag); } _vm->_globals.dos_free2(ptr); if (mode != 1) { if (g_PTRNUL != _vm->_globals.COUCOU) _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); - v13 = file + ".rep"; - byte *dataP = _vm->_fileManager.RECHERCHE_CAT(v13, 2); + filename = file + ".rep"; + byte *dataP = _vm->_fileManager.RECHERCHE_CAT(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); _vm->_globals.COUCOU = dataP; } @@ -2356,8 +2337,8 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { } void GraphicsManager::NB_SCREEN() { - byte *v0; - const byte *v1; + byte *destP; + const byte *srcP; if (!_vm->_globals.NECESSAIRE) INIT_TABLE(50, 65, Palette); @@ -2380,13 +2361,13 @@ void GraphicsManager::NB_SCREEN() { } _vm->_graphicsManager.DD_Unlock(); - v0 = VESA_SCREEN; - v1 = VESA_BUFFER; + destP = VESA_SCREEN; + srcP = VESA_BUFFER; memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu); - v1 = v1 + 614396; - v0 = v0 + 614396; - *v0 = *v1; - *(v0 + 2) = *(v1 + 2); + srcP = srcP + 614396; + destP = destP + 614396; + *destP = *srcP; + *(destP + 2) = *(srcP + 2); DD_VBL(); } @@ -2510,16 +2491,16 @@ void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int wid } void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte col) { - byte *v5; - int v6; + byte *destP; + int yCtr; - v5 = surface + xp + nbrligne2 * yp; - v6 = height; + destP = surface + xp + nbrligne2 * yp; + yCtr = height; do { - *v5 = col; - v5 += nbrligne2; - --v6; - } while (v6); + *destP = col; + destP += nbrligne2; + --yCtr; + } while (yCtr); } -- cgit v1.2.3 From ef663f95a516d8fe47a245653d418c047361281a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 31 Oct 2012 09:04:29 +1100 Subject: HOPKINS: Variable renaming in Affiche_Perfect --- engines/hopkins/graphics.cpp | 276 +++++++++++++++++++++---------------------- 1 file changed, 138 insertions(+), 138 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d0ec1d6545..718a428ba6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1711,18 +1711,18 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { // Display 'Perfect?' void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8) { - const byte *v8; + const byte *spriteStartP; int i; - const byte *v10; - int v11; - int v12; - const byte *v13; - byte *v14; - int v15; - byte *v16; - int v17; - int v18; - int v19; + const byte *spriteSizeP; + int spriteWidth; + int spriteHeight1; + const byte *spritePixelsP; + byte *dest1P; + int xCtr1; + byte *dest2P; + int xLeft; + int clippedWidth; + int xCtr2; int v20; int v21 = 0; int v22; @@ -1739,19 +1739,19 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v33; int v34; int v35; - int v36; + int spriteHeight2; int v37; int v38; uint16 v39; byte *v40; int v41; uint16 v42; - const byte *v43; - const byte *v44; + const byte *spritePixelsCopyP; + const byte *spritePixelsCopy2P; const byte *v45; const byte *v46; - byte *v47; - byte *v48; + byte *dest1CopyP; + byte *destCopy2P; int v49; int v50; byte *v51; @@ -1759,8 +1759,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp byte *v53; byte *v54; byte *v55; - int v56; - int v57; + int yCtr1; + int yCtr2; int v58; int v59; int v60; @@ -1770,17 +1770,17 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v64; int v65; - v8 = srcData + 3; + spriteStartP = srcData + 3; for (i = frameIndex; i; --i) - v8 += READ_LE_UINT32(v8) + 16; - - v11 = 0; - v12 = 0; - v10 = v8 + 4; - v11 = (int16)READ_LE_UINT16(v10); - v10 += 2; - v12 = v36 = (int16)READ_LE_UINT16(v10); - v13 = v10 + 10; + spriteStartP += READ_LE_UINT32(spriteStartP) + 16; + + spriteWidth = 0; + spriteHeight1 = 0; + spriteSizeP = spriteStartP + 4; + spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + spriteSizeP += 2; + spriteHeight1 = spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); + spritePixelsP = spriteSizeP + 10; clip_x = 0; clip_y = 0; clip_x1 = 0; @@ -1795,18 +1795,18 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp clip_x1 = max_x + 300 - xp300; if ((uint16)yp300 < (uint16)(max_y + 300)) { clip_y1 = max_y + 300 - yp300; - v14 = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; + dest1P = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; if (a7) { Compteur_y = 0; Agr_x = 0; Agr_y = 0; Agr_Flag_y = 0; Agr_Flag_x = 0; - Largeur = v11; - v20 = Asm_Zoom(v11, a7); + Largeur = spriteWidth; + v20 = Asm_Zoom(spriteWidth, a7); v22 = Asm_Zoom(v21, a7); if (a8) { - v29 = v20 + v14; + v29 = v20 + dest1P; if (clip_y) { if ((uint16)clip_y >= v22) return; @@ -1817,7 +1817,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp while (Asm_Zoom(v30 + 1, a7) < v31) ; v20 = v52; - v13 += Largeur * v30; + spritePixelsP += Largeur * v30; v29 += nbrligne2 * (uint16)clip_y; v22 = v61 - (uint16)clip_y; } @@ -1837,29 +1837,29 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ; v34 = v33; v22 = v62; - v13 += v34; + spritePixelsP += v34; v20 = (uint16)clip_x1; } do { while (1) { v63 = v22; v53 = v29; - v46 = v13; + v46 = spritePixelsP; Agr_Flag_x = 0; Agr_x = 0; v35 = v20; do { while (1) { - if (*v13) - *v29 = *v13; + if (*spritePixelsP) + *v29 = *spritePixelsP; --v29; - ++v13; + ++spritePixelsP; if (!Agr_Flag_x) Agr_x = a7 + Agr_x; if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; - --v13; + --spritePixelsP; Agr_Flag_x = 1; --v35; if (!v35) @@ -1869,7 +1869,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp --v35; } while (v35); R_Aff_Zoom_Larg_Cont1: - v13 = Largeur + v46; + spritePixelsP = Largeur + v46; v29 = nbrligne2 + v53; ++Compteur_y; if (!Agr_Flag_y) @@ -1877,7 +1877,7 @@ R_Aff_Zoom_Larg_Cont1: if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; - v13 = v46; + spritePixelsP = v46; Agr_Flag_y = 1; v22 = v63 - 1; if (v63 == 1) @@ -1897,8 +1897,8 @@ R_Aff_Zoom_Larg_Cont1: while (Asm_Zoom(v23 + 1, a7) < v24) ; v20 = v49; - v13 += Largeur * v23; - v14 += nbrligne2 * (uint16)clip_y; + spritePixelsP += Largeur * v23; + dest1P += nbrligne2 * (uint16)clip_y; v22 = v58 - (uint16)clip_y; } if (v22 > (uint16)clip_y1) @@ -1914,8 +1914,8 @@ R_Aff_Zoom_Larg_Cont1: ; v27 = v26; v22 = v59; - v13 += v27; - v14 += (uint16)clip_x; + spritePixelsP += v27; + dest1P += (uint16)clip_x; v20 = v50 - (uint16)clip_x; } if (v20 > (uint16)clip_x1) @@ -1923,23 +1923,23 @@ R_Aff_Zoom_Larg_Cont1: do { while (1) { v60 = v22; - v51 = v14; - v45 = v13; + v51 = dest1P; + v45 = spritePixelsP; v28 = v20; Agr_Flag_x = 0; Agr_x = 0; do { while (1) { - if (*v13) - *v14 = *v13; - ++v14; - ++v13; + if (*spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; if (!Agr_Flag_x) Agr_x = a7 + Agr_x; if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; - --v13; + --spritePixelsP; Agr_Flag_x = 1; --v28; if (!v28) @@ -1949,14 +1949,14 @@ R_Aff_Zoom_Larg_Cont1: --v28; } while (v28); Aff_Zoom_Larg_Cont1: - v13 = Largeur + v45; - v14 = nbrligne2 + v51; + spritePixelsP = Largeur + v45; + dest1P = nbrligne2 + v51; if (!Agr_Flag_y) Agr_y = a7 + Agr_y; if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; - v13 = v45; + spritePixelsP = v45; Agr_Flag_y = 1; v22 = v60 - 1; if (v60 == 1) @@ -1970,14 +1970,14 @@ Aff_Zoom_Larg_Cont1: Compteur_y = 0; Red_x = 0; Red_y = 0; - Largeur = v11; + Largeur = spriteWidth; Red = a6; if (a6 < 100) { - v37 = Asm_Reduc(v11, Red); + v37 = Asm_Reduc(spriteWidth, Red); if (a8) { - v40 = v37 + v14; + v40 = v37 + dest1P; do { - v65 = v36; + v65 = spriteHeight2; v55 = v40; Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { @@ -1987,29 +1987,29 @@ Aff_Zoom_Larg_Cont1: do { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { - if (v42 >= clip_x && v42 < clip_x1 && *v13) - *v40 = *v13; + if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) + *v40 = *spritePixelsP; --v40; - ++v13; + ++spritePixelsP; --v42; } else { Red_x = Red_x - 100; - ++v13; + ++spritePixelsP; } --v41; } while (v41); - v36 = v65; + spriteHeight2 = v65; v40 = nbrligne2 + v55; } else { Red_y = Red_y - 100; - v13 += Largeur; + spritePixelsP += Largeur; } - --v36; - } while (v36); + --spriteHeight2; + } while (spriteHeight2); } else { do { - v64 = v36; - v54 = v14; + v64 = spriteHeight2; + v54 = dest1P; Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { Red_x = 0; @@ -2018,107 +2018,107 @@ Aff_Zoom_Larg_Cont1: do { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { - if (v39 >= clip_x && v39 < clip_x1 && *v13) - *v14 = *v13; - ++v14; - ++v13; + if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; ++v39; } else { Red_x = Red_x - 100; - ++v13; + ++spritePixelsP; } --v38; } while (v38); - v36 = v64; - v14 = nbrligne2 + v54; + spriteHeight2 = v64; + dest1P = nbrligne2 + v54; } else { Red_y = Red_y - 100; - v13 += Largeur; + spritePixelsP += Largeur; } - --v36; - } while (v36); + --spriteHeight2; + } while (spriteHeight2); } } } else { - Largeur = v11; + Largeur = spriteWidth; Compteur_y = 0; if (a8) { - v16 = v11 + v14; - spec_largeur = v11; + dest2P = spriteWidth + dest1P; + spec_largeur = spriteWidth; if (clip_y) { - if ((uint16)clip_y >= (unsigned int)v12) + if ((uint16)clip_y >= (unsigned int)spriteHeight1) return; - v13 += v11 * (uint16)clip_y; - v16 += nbrligne2 * (uint16)clip_y; - v12 -= (uint16)clip_y; + spritePixelsP += spriteWidth * (uint16)clip_y; + dest2P += nbrligne2 * (uint16)clip_y; + spriteHeight1 -= (uint16)clip_y; } - v17 = (uint16)clip_y1; - if (v12 > clip_y1) - v12 = clip_y1; - v17 = clip_x; + xLeft = (uint16)clip_y1; + if (spriteHeight1 > clip_y1) + spriteHeight1 = clip_y1; + xLeft = clip_x; if (clip_x) { - if (v17 >= v11) + if (xLeft >= spriteWidth) return; - v11 -= v17; + spriteWidth -= xLeft; } - if (v11 > (uint16)clip_x1) { - v18 = v11 - (uint16)clip_x1; - v13 += v18; - v16 -= v18; - v11 = (uint16)clip_x1; + if (spriteWidth > (uint16)clip_x1) { + clippedWidth = spriteWidth - (uint16)clip_x1; + spritePixelsP += clippedWidth; + dest2P -= clippedWidth; + spriteWidth = (uint16)clip_x1; } do { - v57 = v12; - v48 = v16; - v44 = v13; - v19 = v11; + yCtr2 = spriteHeight1; + destCopy2P = dest2P; + spritePixelsCopy2P = spritePixelsP; + xCtr2 = spriteWidth; do { - if (*v13) - *v16 = *v13; - ++v13; - --v16; - --v19; - } while (v19); - v13 = spec_largeur + v44; - v16 = nbrligne2 + v48; - v12 = v57 - 1; - } while (v57 != 1); + if (*spritePixelsP) + *dest2P = *spritePixelsP; + ++spritePixelsP; + --dest2P; + --xCtr2; + } while (xCtr2); + spritePixelsP = spec_largeur + spritePixelsCopy2P; + dest2P = nbrligne2 + destCopy2P; + spriteHeight1 = yCtr2 - 1; + } while (yCtr2 != 1); } else { - spec_largeur = v11; + spec_largeur = spriteWidth; if (clip_y) { - if ((uint16)clip_y >= (unsigned int)v12) + if ((uint16)clip_y >= (unsigned int)spriteHeight1) return; - v13 += v11 * (uint16)clip_y; - v14 += nbrligne2 * (uint16)clip_y; - v12 -= (uint16)clip_y; + spritePixelsP += spriteWidth * (uint16)clip_y; + dest1P += nbrligne2 * (uint16)clip_y; + spriteHeight1 -= (uint16)clip_y; } - if (v12 > clip_y1) - v12 = clip_y1; + if (spriteHeight1 > clip_y1) + spriteHeight1 = clip_y1; if (clip_x) { - if ((uint16)clip_x >= v11) + if ((uint16)clip_x >= spriteWidth) return; - v13 += (uint16)clip_x; - v14 += (uint16)clip_x; - v11 -= (uint16)clip_x; + spritePixelsP += (uint16)clip_x; + dest1P += (uint16)clip_x; + spriteWidth -= (uint16)clip_x; } - if (v11 > (uint16)clip_x1) - v11 = (uint16)clip_x1; + if (spriteWidth > (uint16)clip_x1) + spriteWidth = (uint16)clip_x1; do { - v56 = v12; - v47 = v14; - v43 = v13; - v15 = v11; + yCtr1 = spriteHeight1; + dest1CopyP = dest1P; + spritePixelsCopyP = spritePixelsP; + xCtr1 = spriteWidth; do { - if (*v13) - *v14 = *v13; - ++v14; - ++v13; - --v15; - } while (v15); - v13 = spec_largeur + v43; - v14 = nbrligne2 + v47; - v12 = v56 - 1; - } while (v56 != 1); + if (*spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; + --xCtr1; + } while (xCtr1); + spritePixelsP = spec_largeur + spritePixelsCopyP; + dest1P = nbrligne2 + dest1CopyP; + spriteHeight1 = yCtr1 - 1; + } while (yCtr1 != 1); } } } -- cgit v1.2.3 From e9c9b8b428b66968bd8e88eb718061b1c8fd041d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 Nov 2012 22:35:33 +1100 Subject: HOPKINS: Refactoring to show the selected inventory item using ScummVM cursor manager --- engines/hopkins/graphics.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 718a428ba6..72c01c2c37 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1710,7 +1710,7 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { } // Display 'Perfect?' -void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8) { +void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) { const byte *spriteStartP; int i; const byte *spriteSizeP; @@ -1796,16 +1796,16 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if ((uint16)yp300 < (uint16)(max_y + 300)) { clip_y1 = max_y + 300 - yp300; dest1P = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; - if (a7) { + if (zoom2) { Compteur_y = 0; Agr_x = 0; Agr_y = 0; Agr_Flag_y = 0; Agr_Flag_x = 0; Largeur = spriteWidth; - v20 = Asm_Zoom(spriteWidth, a7); - v22 = Asm_Zoom(v21, a7); - if (a8) { + v20 = Asm_Zoom(spriteWidth, zoom2); + v22 = Asm_Zoom(v21, zoom2); + if (modeFlag) { v29 = v20 + dest1P; if (clip_y) { if ((uint16)clip_y >= v22) @@ -1814,7 +1814,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v52 = v20; v30 = 0; v31 = (uint16)clip_y; - while (Asm_Zoom(v30 + 1, a7) < v31) + while (Asm_Zoom(v30 + 1, zoom2) < v31) ; v20 = v52; spritePixelsP += Largeur * v30; @@ -1833,7 +1833,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v29 -= v32; v62 = v22; v33 = 0; - while (Asm_Zoom(v33 + 1, a7) < v32) + while (Asm_Zoom(v33 + 1, zoom2) < v32) ; v34 = v33; v22 = v62; @@ -1855,7 +1855,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp --v29; ++spritePixelsP; if (!Agr_Flag_x) - Agr_x = a7 + Agr_x; + Agr_x = zoom2 + Agr_x; if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; @@ -1873,7 +1873,7 @@ R_Aff_Zoom_Larg_Cont1: v29 = nbrligne2 + v53; ++Compteur_y; if (!Agr_Flag_y) - Agr_y = a7 + Agr_y; + Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; @@ -1894,7 +1894,7 @@ R_Aff_Zoom_Larg_Cont1: v49 = v20; v23 = 0; v24 = (uint16)clip_y; - while (Asm_Zoom(v23 + 1, a7) < v24) + while (Asm_Zoom(v23 + 1, zoom2) < v24) ; v20 = v49; spritePixelsP += Largeur * v23; @@ -1910,7 +1910,7 @@ R_Aff_Zoom_Larg_Cont1: v50 = v20; v25 = (uint16)clip_x; v26 = 0; - while (Asm_Zoom(v26 + 1, a7) < v25) + while (Asm_Zoom(v26 + 1, zoom2) < v25) ; v27 = v26; v22 = v59; @@ -1935,7 +1935,7 @@ R_Aff_Zoom_Larg_Cont1: ++dest1P; ++spritePixelsP; if (!Agr_Flag_x) - Agr_x = a7 + Agr_x; + Agr_x = zoom2 + Agr_x; if ((uint16)Agr_x < 0x64u) break; Agr_x = Agr_x - 100; @@ -1952,7 +1952,7 @@ Aff_Zoom_Larg_Cont1: spritePixelsP = Largeur + v45; dest1P = nbrligne2 + v51; if (!Agr_Flag_y) - Agr_y = a7 + Agr_y; + Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 0x64u) break; Agr_y = Agr_y - 100; @@ -1966,15 +1966,15 @@ Aff_Zoom_Larg_Cont1: v22 = v60 - 1; } while (v60 != 1); } - } else if (a6) { + } else if (zoom1) { Compteur_y = 0; Red_x = 0; Red_y = 0; Largeur = spriteWidth; - Red = a6; - if (a6 < 100) { + Red = zoom1; + if (zoom1 < 100) { v37 = Asm_Reduc(spriteWidth, Red); - if (a8) { + if (modeFlag) { v40 = v37 + dest1P; do { v65 = spriteHeight2; @@ -2042,7 +2042,7 @@ Aff_Zoom_Larg_Cont1: } else { Largeur = spriteWidth; Compteur_y = 0; - if (a8) { + if (modeFlag) { dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; if (clip_y) { -- cgit v1.2.3 From c2a5b4b33962bb60954dba086ebafcc5464359a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 8 Nov 2012 08:29:26 +0100 Subject: HOPKINS: More full version initialization, change 2 variables to boolean --- engines/hopkins/graphics.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 72c01c2c37..3088953315 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -48,8 +48,14 @@ GraphicsManager::GraphicsManager() { PCX_L = PCX_H = 0; DOUBLE_ECRAN = false; OLD_SCROLL = 0; - MANU_SCROLL = 1; - SPEED_SCROLL = 16; + if (_vm->getIsDemo()) { + // CHECKME: Should be 0? + MANU_SCROLL = 1; + SPEED_SCROLL = 16; + } else { + MANU_SCROLL = 0; + SPEED_SCROLL = 32; + } nbrligne2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; -- cgit v1.2.3 From d27056e5eaf7db33ac06b7043212cf2016e8c72c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 8 Nov 2012 20:28:07 +1100 Subject: HOPKINS: Fix crash in GraphicsManager constructor --- engines/hopkins/graphics.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3088953315..2dc4a23a67 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -48,14 +48,7 @@ GraphicsManager::GraphicsManager() { PCX_L = PCX_H = 0; DOUBLE_ECRAN = false; OLD_SCROLL = 0; - if (_vm->getIsDemo()) { - // CHECKME: Should be 0? - MANU_SCROLL = 1; - SPEED_SCROLL = 16; - } else { - MANU_SCROLL = 0; - SPEED_SCROLL = 32; - } + nbrligne2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; @@ -92,6 +85,15 @@ GraphicsManager::~GraphicsManager() { void GraphicsManager::setParent(HopkinsEngine *vm) { _vm = vm; + + if (_vm->getIsDemo()) { + // CHECKME: Should be 0? + MANU_SCROLL = 1; + SPEED_SCROLL = 16; + } else { + MANU_SCROLL = 0; + SPEED_SCROLL = 32; + } } void GraphicsManager::SET_MODE(int width, int height) { -- cgit v1.2.3 From 75eaa297c61553abf8a855c1168bb6b56d47f7bb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 11 Nov 2012 21:33:17 +1100 Subject: HOPKINS: Refactored the PCX decoder to use the existing ScummVM decoder --- engines/hopkins/graphics.cpp | 139 ++++++------------------------------------- 1 file changed, 18 insertions(+), 121 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2dc4a23a67..132e8d88ab 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -22,6 +22,7 @@ #include "common/system.h" #include "graphics/palette.h" +#include "graphics/decoders/pcx.h" #include "common/file.h" #include "common/rect.h" #include "engines/util.h" @@ -325,147 +326,43 @@ void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { - int filesize; - int v6; - int v7; - int v8; - int v9; - int v10; - int v11; - byte v12; - int v13; - int v14; - char v15; - int v18; - int v19; - int v20; - unsigned int v21; - int v22; - int32 v23; - byte *ptr; Common::File f; + Graphics::PCXDecoder pcxDecoder; // Clear the passed surface memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); if (typeFlag) { + // Load PCX from within the PIC resource _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES"); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); f.seek(_vm->_globals.CAT_POSI); - v7 = _vm->_globals.CAT_TAILLE - 896; - v8 = f.read(HEADER_PCX, 128); - - v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1; - v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1; - if (((int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) { - DOUBLE_ECRAN = false; - } else { - v6 = SCREEN_WIDTH * 2; - DOUBLE_ECRAN = true; - } - if (v20 > SCREEN_HEIGHT) - v20 = SCREEN_HEIGHT; - PCX_L = v6; - PCX_H = v20; - if (v8 == -1) - error("Erreur en cours de lecture."); } else { + // Load stand alone PCX file _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); - - filesize = f.size(); - int bytesRead = f.read(HEADER_PCX, 128); - if (bytesRead < 128) - error("Erreur en cours de lecture."); - - v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1; - v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1; - if (v6 <= SCREEN_WIDTH) { - DOUBLE_ECRAN = false; - } else { - v6 = SCREEN_WIDTH * 2; - DOUBLE_ECRAN = true; - } - if (v20 > SCREEN_HEIGHT) - v20 = SCREEN_HEIGHT; - PCX_L = v6; - PCX_H = v20; - v7 = filesize - 896; } - ptr = _vm->_globals.dos_malloc2(0xEE60u); - if (v7 >= 60000) { - v21 = v7 / 60000 + 1; - v23 = 60000 * (v7 / 60000) - v7; - - if (((uint32)v23 & 0x80000000u) != 0) - v23 = -v23; - f.read(ptr, 60000); - v7 = 60000; - } else { - v21 = 1; - v23 = v7; - f.read(ptr, v7); - } - v22 = v21 - 1; - v18 = 0; - v9 = 0; - v10 = 0; - v19 = v6; - - do { - if (v9 == v7) { - v9 = 0; - --v22; - v7 = 60000; - if ( !v22 ) - v7 = v23; - v11 = v10; - f.read(ptr, v7); - v10 = v11; - } + // Decode the PCX + if (!pcxDecoder.loadStream(f)) + error("Error decoding PCX"); - v12 = *((byte *)ptr + v9++); - if (v12 > 0xC0u) { - v13 = v12 - 192; - if (v9 == v7) { - v9 = 0; - --v22; - v7 = 60000; - if ( v22 == 1 ) - v7 = v23; - v14 = v10; - f.read(ptr, v7); - v10 = v14; - } - v15 = *((byte *)ptr + v9++); - - do { - *((byte *)surface + v10++) = v15; - ++v18; - --v13; - } while (v13); - } else { - *((byte *)surface + v10++) = v12; - ++v18; - } - } while (v18 < v19 * v20); - - if (typeFlag) { - f.seek(_vm->_globals.CAT_TAILLE + _vm->_globals.CAT_POSI - 768); - } else { - filesize = f.size(); - f.seek(filesize - 768); - } - - if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE)) - error("A_PCX640_480"); + const Graphics::Surface *s = pcxDecoder.getSurface(); + + // Copy out the dimensions and pixels of the decoded surface + DOUBLE_ECRAN = s->w > SCREEN_WIDTH; + PCX_L = s->w; + PCX_H = s->h; + Common::copy((byte *)s->pixels, (byte *)s->pixels + (s->pitch * s->h), surface); + + // Copy out the palette + const byte *palSrc = pcxDecoder.getPalette(); + Common::copy((byte *)palSrc, (byte *)palSrc + PALETTE_BLOCK_SIZE, palette); f.close(); - _vm->_globals.dos_free2(ptr); } // Clear Palette -- cgit v1.2.3 From db091123ee8f53b0a9cb4ce63f5fee3fc91100fa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 13 Nov 2012 20:25:55 +1100 Subject: HOPKINS: Compilation fixes under gcc --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 132e8d88ab..a455d35f40 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -360,7 +360,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by // Copy out the palette const byte *palSrc = pcxDecoder.getPalette(); - Common::copy((byte *)palSrc, (byte *)palSrc + PALETTE_BLOCK_SIZE, palette); + Common::copy((const byte *)palSrc, (const byte *)palSrc + PALETTE_BLOCK_SIZE, palette); f.close(); } -- cgit v1.2.3 From 6d1db995408f3325824698b330300a0292a49931 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 16 Nov 2012 08:32:40 +0100 Subject: HOPKINS: Remove some magic values, add a safety check in Copy_Video_Vbe16 --- engines/hopkins/graphics.cpp | 53 ++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a455d35f40..8af5792389 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -957,17 +957,17 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) srcByte = *srcP; if (*srcP < 0xDEu) goto Video_Cont3_wVbe; - if (srcByte == (byte)-4) + if (srcByte == kByteStop) return; - if (srcByte < 0xFBu) { + if (srcByte < kSetOffset) { destOffset += (byte)(*srcP + 35); srcByte = *(srcP++ + 1); - } else if (srcByte == (byte)-3) { + } else if (srcByte == k8bVal) { destOffset += *(srcP + 1); srcByte = *(srcP + 2); srcP += 2; - } else if (srcByte == (byte)-2) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(srcP + 3); srcP += 3; @@ -1019,16 +1019,16 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { if (*srcP < 222) goto Video_Cont3_Vbe; - if (srcByte == 252) + if (srcByte == kByteStop) return; - if (srcByte < 251) { + if (srcByte < kSetOffset) { destOffset += *srcP + 35; srcByte = *(srcP++ + 1); - } else if (srcByte == (byte)-3) { + } else if (srcByte == k8bVal) { destOffset += *(srcP + 1); srcByte = *(srcP + 2); srcP += 2; - } else if (srcByte == (byte)-2) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(srcP + 3); srcP += 3; @@ -1070,16 +1070,16 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { for (;;) { byte srcByte = *srcP; if (srcByte >= 222) { - if (srcByte == 252) + if (srcByte == kByteStop) return; - if (srcByte < 251) { + if (srcByte < kSetOffset) { destOffset += srcByte - 221; srcByte = *++srcP; - } else if (srcByte == 253) { + } else if (srcByte == k8bVal) { destOffset += *(const byte *)(srcP + 1); srcByte = *(const byte *)(srcP + 2); srcP += 2; - } else if (srcByte == 254) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(const byte *)(srcP + 3); srcP += 3; @@ -1090,6 +1090,11 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } } + if (destOffset > 640 * 480) { + warning("HACK: Stopping anim, out of bounds - 0x%x %d", srcByte, destOffset); + return; + } + if (srcByte > 210) { if (srcByte == 211) { int pixelCount = *(srcP + 1); @@ -1131,15 +1136,15 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { srcP = srcData; for (;;) { pixelIndex = *srcP; - if (*srcP < 0xFCu) + if (*srcP < kByteStop) goto Video_Cont_Vbe16a; - if (pixelIndex == (byte)-4) + if (pixelIndex == kByteStop) return; - if (pixelIndex == (byte)-3) { + if (pixelIndex == k8bVal) { destOffset += *(srcP + 1); pixelIndex = *(srcP + 2); srcP += 2; - } else if (pixelIndex == (byte)-2) { + } else if (pixelIndex == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); pixelIndex = *(srcP + 3); srcP += 3; @@ -2295,15 +2300,15 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { srcPtr = src; while (1) { byteVal = *srcPtr; - if (*srcPtr < 0xFCu) + if (*srcPtr < kByteStop) goto Video_Cont_wVbe; - if (byteVal == (byte)-4) + if (byteVal == kByteStop) return; - if (byteVal == (byte)-3) { + if (byteVal == k8bVal) { destOffset += *(srcPtr + 1); byteVal = *(srcPtr + 2); srcPtr += 2; - } else if (byteVal == (byte)-2) { + } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcPtr + 1); byteVal = *(srcPtr + 3); srcPtr += 3; @@ -2329,15 +2334,15 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { srcP = src; while (1) { byteVal = *srcP; - if (*srcP < 0xFCu) + if (*srcP < kByteStop) goto Video_Cont_Vbe; - if (byteVal == (byte)-4) + if (byteVal == kByteStop) return; - if (byteVal == (byte)-3) { + if (byteVal == k8bVal) { destOffset += *(srcP + 1); byteVal = *(srcP + 2); srcP += 2; - } else if (byteVal == (byte)-2) { + } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); byteVal = *(srcP + 3); srcP += 3; -- cgit v1.2.3 From 0fdea57c544c8c1bd1c816262d9319367334eb83 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 17 Nov 2012 20:49:07 +1100 Subject: HOPKINS: Lots of code implemented for Hopkin's computer --- engines/hopkins/graphics.cpp | 198 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 192 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8af5792389..10d9e996da 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -181,6 +181,29 @@ void GraphicsManager::LOAD_IMAGE(const Common::String &file) { INIT_TABLE(165, 170, Palette); } + +void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { + SCANLINE(SCREEN_WIDTH); + DD_Lock(); + Cls_Video(); + DD_Unlock(); + _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + A_PCX320(VESA_SCREEN, _vm->_globals.NFICHIER, Palette); + memcpy(VESA_BUFFER, VESA_SCREEN, 0xFA00u); + _vm->_eventsManager.souris_max(); + SCANLINE(320); + max_x = 320; + + DD_Lock(); + if (Winbpp == 1) + CopyAsm(VESA_BUFFER); + if (Winbpp == 2) + CopyAsm16(VESA_BUFFER); + DD_Unlock(); + + FADE_IN_CASSE(); +} + // Load Screen void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { bool flag; @@ -365,6 +388,88 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by f.close(); } +void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte *palette) { + size_t filesize; + int v4; + size_t v5; + int v6; + size_t v7; + int v8; + byte v9; + int v10; + int v11; + char v12; + int v15; + int v16; + int32 v17; + byte *ptr; + Common::File f; + + if (!f.open(file)) + error("File not found - %s", file.c_str()); + + filesize = f.size(); + + f.read(surface, 0x80u); + v4 = filesize - 896; + ptr = _vm->_globals.dos_malloc2(0xFE00u); + if (v4 >= 0xFA00) { + v15 = v4 / 0xFA00 + 1; + v17 = 64000 * (v4 / 0xFA00) - v4; + if (((uint32)v17 & 0x80000000u) != 0) + v17 = -v17; + f.read(ptr, 0xFA00u); + v5 = 64000; + } else { + v15 = 1; + v17 = v4; + f.read(ptr, v4); + v5 = v4; + } + v16 = v15 - 1; + v6 = 0; + v7 = 0; + do { + if (v7 == v5) { + v7 = 0; + --v16; + v5 = 64000; + if (!v16) + v5 = v17; + v8 = v6; + f.read(ptr, v5); + v6 = v8; + } + v9 = *(ptr + v7++); + if (v9 > 0xC0u) { + v10 = v9 - 192; + if (v7 == v5) { + v7 = 0; + --v16; + v5 = 64000; + if (v16 == 1) + v5 = v17; + v11 = v6; + f.read(ptr, v5); + v6 = v11; + } + v12 = *(ptr + v7++); + do { + *(surface + v6++) = v12; + --v10; + } while (v10); + } else { + *(surface + v6++) = v9; + } + } while (v6 <= 0xF9FF); + + f.seek(filesize - 768); + f.read(palette, 0x300u); + f.close(); + + _vm->_globals.dos_free2(ptr); +} + // Clear Palette void GraphicsManager::Cls_Pal() { Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); @@ -855,9 +960,9 @@ void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surfa } void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) { - _vm->_graphicsManager.Palette[palIndex * 3] = 255 * r / 100; - _vm->_graphicsManager.Palette[palIndex * 3 + 1] = 255 * g / 100; - _vm->_graphicsManager.Palette[palIndex * 3 + 2] = 255 * b / 100; + Palette[palIndex * 3] = 255 * r / 100; + Palette[palIndex * 3 + 1] = 255 * g / 100; + Palette[palIndex * 3 + 2] = 255 * b / 100; setpal_vga256(Palette); } @@ -940,6 +1045,30 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { fade_in(Palette, FADESPD, surface); } +void GraphicsManager::FADE_IN_CASSE() { + setpal_vga256(Palette); + if (Winbpp == 2) { + DD_Lock(); + CopyAsm16(VESA_BUFFER); + DD_Unlock(); + } + DD_VBL(); +} + +void GraphicsManager::FADE_OUT_CASSE() { + byte palette[PALETTE_EXT_BLOCK_SIZE]; + + memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); + setpal_vga256(palette); + + if (Winbpp == 2) { + DD_Lock(); + CopyAsm16(VESA_BUFFER); + DD_Unlock(); + } + DD_VBL(); +} + void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { int rleValue; int destOffset; @@ -1523,6 +1652,22 @@ void GraphicsManager::Affiche_Segment_Vesa() { SDL_NBLOCS = 0; } +void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx) { + int height, width; + + width = _vm->_objectsManager.Get_Largeur(objectData, idx); + height = _vm->_objectsManager.Get_Hauteur(objectData, idx); + if (*objectData == 78) { + Affiche_Perfect(VESA_SCREEN, objectData, xp + 300, yp + 300, idx, 0, 0, 0); + Affiche_Perfect(VESA_BUFFER, objectData, xp + 300, yp + 300, idx, 0, 0, 0); + } else { + Sprite_Vesa(VESA_BUFFER, objectData, xp + 300, yp + 300, idx); + Sprite_Vesa(VESA_SCREEN, objectData, xp + 300, yp + 300, idx); + } + if (!_vm->_globals.NO_VISU) + Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); +} + void GraphicsManager::CopyAsm(const byte *surface) { const byte *srcP; byte srcByte; @@ -1565,6 +1710,48 @@ void GraphicsManager::CopyAsm(const byte *surface) { } while (yCtr); } +void GraphicsManager::CopyAsm16(const byte *surface) { + const byte *v1; + byte *v2; + int v3; + signed int v4; + byte *v5; + uint16 *v6; + int v; + uint16 *v8; + int v9; + byte *v10; + const byte *v11; + + assert(VideoPtr); + v1 = surface; + v2 = 30 * WinScan + (byte *)VideoPtr->pixels; + v3 = 200; + do { + v11 = v1; + v10 = v2; + v4 = 320; + v9 = v3; + v5 = PAL_PIXELS; + do { + v = 2 * *v1; + v6 = (uint16 *)(v5 + 2 * *v1); + v = *v6; + *v2 = *v6; + *(v2 + 1) = v; + v8 = (uint16 *)(WinScan + v2); + *v8 = v; + *(v8 + 1) = v; + ++v1; + v2 = (byte *)v8 - WinScan + 4; + --v4; + } while (v4); + v1 = v11 + 320; + v2 = WinScan * 2 + v10; + v3 = v9 - 1; + } while (v9 != 1); +} + void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { byte *destP; int yNext; @@ -2256,7 +2443,7 @@ void GraphicsManager::NB_SCREEN() { Trans_bloc2(VESA_BUFFER, TABLE_COUL, 307200); if (nbrligne == 1280) Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400); - _vm->_graphicsManager.DD_Lock(); + DD_Lock(); if (Winbpp == 2) { if (SDL_ECHELLE) m_scroll16A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); @@ -2269,7 +2456,7 @@ void GraphicsManager::NB_SCREEN() { else m_scroll2(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } - _vm->_graphicsManager.DD_Unlock(); + DD_Unlock(); destP = VESA_SCREEN; srcP = VESA_BUFFER; @@ -2413,5 +2600,4 @@ void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte } while (yCtr); } - } // End of namespace Hopkins -- cgit v1.2.3 From cdbba33e38c341619222b93b3200776a1026304b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 17 Nov 2012 23:09:16 +0100 Subject: HOPKINS: Fix PCX loading when no present in CAT file. --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 10d9e996da..4f0450453b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -212,7 +212,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { _vm->_fileManager.DMESS1(); flag = true; - if (_vm->_fileManager.RECHERCHE_CAT(file, 6)) { + if (_vm->_fileManager.RECHERCHE_CAT(file, 6) == g_PTRNUL) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("CHARGE_ECRAN - %s", file.c_str()); @@ -371,7 +371,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by // Decode the PCX if (!pcxDecoder.loadStream(f)) - error("Error decoding PCX"); + error("Error decoding PCX %s", file.c_str()); const Graphics::Surface *s = pcxDecoder.getSurface(); -- cgit v1.2.3 From 9a996d66d443292f0485ea062a72b62a45cec43e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Nov 2012 15:21:16 +1100 Subject: HOPKINS: Bugfix for crash when walking in the projection room --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4f0450453b..f2d23c7602 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1805,7 +1805,7 @@ int GraphicsManager::Asm_Reduc(int v, int percentage) { return v; } - + // Display 'Perfect?' void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) { const byte *spriteStartP; @@ -1821,7 +1821,6 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int clippedWidth; int xCtr2; int v20; - int v21 = 0; int v22; int v23; int v24; @@ -1901,7 +1900,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_Flag_x = 0; Largeur = spriteWidth; v20 = Asm_Zoom(spriteWidth, zoom2); - v22 = Asm_Zoom(v21, zoom2); + v22 = Asm_Zoom(spriteHeight1, zoom2); if (modeFlag) { v29 = v20 + dest1P; if (clip_y) { @@ -2017,6 +2016,7 @@ R_Aff_Zoom_Larg_Cont1: } if (v20 > (uint16)clip_x1) v20 = (uint16)clip_x1; + do { while (1) { v60 = v22; -- cgit v1.2.3 From 25a311c65b1ea33c242d741971565c2d8b86768b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Nov 2012 20:28:03 +1100 Subject: HOPKINS: Bugfixes for setup of Breakout sub-game --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f2d23c7602..b5985a1f4f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1528,7 +1528,7 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { } if (addFlag) { - assert(_vm->_globals.NBBLOC < 50); + assert(_vm->_globals.NBBLOC < 250); BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; bloc.field0 = 1; -- cgit v1.2.3 From 38acdce7358a92d78faecd618f1905ad5fe8462b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 24 Nov 2012 00:16:44 +0100 Subject: HOPKINS: Fix more CppCheck warnings --- engines/hopkins/graphics.cpp | 213 ++++++++++++++----------------------------- 1 file changed, 69 insertions(+), 144 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b5985a1f4f..29b3631887 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -831,23 +831,15 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { int palByte; - int palIndex; - int palDataIndex; - int palCtr3; - int palCtr4; - int palCtr5; - int palValue; - int palCtr2; - int palCtr1; uint16 palMax; byte palData[PALETTE_BLOCK_SIZE]; int tempPalette[PALETTE_BLOCK_SIZE]; palMax = palByte = FADESPD; if (palette) { - palIndex = 0; + int palIndex = 0; do { - palDataIndex = palIndex; + int palDataIndex = palIndex; palByte = *(palIndex + palette); palByte <<= 8; tempPalette[palDataIndex] = palByte; @@ -863,13 +855,13 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac DD_VBL(); } - palCtr3 = 0; + int palCtr3 = 0; if (palMax > 0) { do { - palCtr4 = 0; + int palCtr4 = 0; do { - palCtr5 = palCtr4; - palValue = tempPalette[palCtr4] - (*(palCtr4 + palette) << 8) / palMax; + int palCtr5 = palCtr4; + int palValue = tempPalette[palCtr4] - (*(palCtr4 + palette) << 8) / palMax; tempPalette[palCtr5] = palValue; palData[palCtr5] = (palValue >> 8) & 0xff; ++palCtr4; @@ -888,10 +880,8 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } while (palMax > palCtr3); } - palCtr2 = 0; - do { - palData[palCtr2++] = 0; - } while (palCtr2 < (PALETTE_BLOCK_SIZE)); + for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) + palData[i] = 0; setpal_vga256(palData); @@ -903,10 +893,8 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac goto LABEL_28; } } else { - palCtr1 = 0; - do { - palData[palCtr1++] = 0; - } while (palCtr1 < (PALETTE_BLOCK_SIZE)); + for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) + palData[i] = 0; setpal_vga256(palData); if (Winbpp == 2) { @@ -1479,15 +1467,9 @@ void GraphicsManager::VISU_ALL() { } void GraphicsManager::RESET_SEGMENT_VESA() { - int idx; - int blocCount; - if (_vm->_globals.NBBLOC > 0) { - idx = 0; - blocCount = _vm->_globals.NBBLOC; - do { - _vm->_globals.BLOC[idx++].field0 = 0; - } while (idx != blocCount); + for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++) + _vm->_globals.BLOC[idx].field0 = 0; _vm->_globals.NBBLOC = 0; } @@ -1497,7 +1479,6 @@ void GraphicsManager::RESET_SEGMENT_VESA() { void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { int tempX; int blocCount; - int16 blocIndex; bool addFlag; tempX = x1; @@ -1514,7 +1495,7 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { blocCount = _vm->_globals.NBBLOC; if (_vm->_globals.NBBLOC > 1) { - blocIndex = 0; + int16 blocIndex = 0; do { BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; @@ -1811,71 +1792,23 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp const byte *spriteStartP; int i; const byte *spriteSizeP; - int spriteWidth; - int spriteHeight1; const byte *spritePixelsP; byte *dest1P; - int xCtr1; byte *dest2P; - int xLeft; - int clippedWidth; - int xCtr2; - int v20; - int v22; - int v23; - int v24; - int v25; - int v26; - int v27; - int v28; byte *v29; - int v30; - int v31; - int v32; - int v33; - int v34; - int v35; - int spriteHeight2; - int v37; - int v38; - uint16 v39; byte *v40; - int v41; - uint16 v42; - const byte *spritePixelsCopyP; - const byte *spritePixelsCopy2P; const byte *v45; const byte *v46; - byte *dest1CopyP; - byte *destCopy2P; - int v49; - int v50; - byte *v51; - int v52; - byte *v53; - byte *v54; - byte *v55; - int yCtr1; - int yCtr2; - int v58; - int v59; - int v60; - int v61; - int v62; - int v63; - int v64; - int v65; spriteStartP = srcData + 3; for (i = frameIndex; i; --i) spriteStartP += READ_LE_UINT32(spriteStartP) + 16; - spriteWidth = 0; - spriteHeight1 = 0; spriteSizeP = spriteStartP + 4; - spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + int spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); spriteSizeP += 2; - spriteHeight1 = spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); + int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); + int spriteHeight1 = spriteHeight2; spritePixelsP = spriteSizeP + 10; clip_x = 0; clip_y = 0; @@ -1899,17 +1832,17 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_Flag_y = 0; Agr_Flag_x = 0; Largeur = spriteWidth; - v20 = Asm_Zoom(spriteWidth, zoom2); - v22 = Asm_Zoom(spriteHeight1, zoom2); + int v20 = Asm_Zoom(spriteWidth, zoom2); + int v22 = Asm_Zoom(spriteHeight1, zoom2); if (modeFlag) { v29 = v20 + dest1P; if (clip_y) { if ((uint16)clip_y >= v22) return; - v61 = v22; - v52 = v20; - v30 = 0; - v31 = (uint16)clip_y; + int v61 = v22; + int v52 = v20; + int v30 = 0; + int v31 = (uint16)clip_y; while (Asm_Zoom(v30 + 1, zoom2) < v31) ; v20 = v52; @@ -1925,25 +1858,26 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v20 -= (uint16)clip_x; } if (v20 > (uint16)clip_x1) { - v32 = v20 - (uint16)clip_x1; + int v32 = v20 - (uint16)clip_x1; v29 -= v32; - v62 = v22; - v33 = 0; + int v62 = v22; + int v33 = 0; while (Asm_Zoom(v33 + 1, zoom2) < v32) ; - v34 = v33; + int v34 = v33; v22 = v62; spritePixelsP += v34; v20 = (uint16)clip_x1; } + int v63; do { while (1) { v63 = v22; - v53 = v29; + byte *v53 = v29; v46 = spritePixelsP; Agr_Flag_x = 0; Agr_x = 0; - v35 = v20; + int v35 = v20; do { while (1) { if (*spritePixelsP) @@ -1986,10 +1920,10 @@ R_Aff_Zoom_Larg_Cont1: if (clip_y) { if ((uint16)clip_y >= v22) return; - v58 = v22; - v49 = v20; - v23 = 0; - v24 = (uint16)clip_y; + int v58 = v22; + int v49 = v20; + int v23 = 0; + int v24 = (uint16)clip_y; while (Asm_Zoom(v23 + 1, zoom2) < v24) ; v20 = v49; @@ -2002,13 +1936,13 @@ R_Aff_Zoom_Larg_Cont1: if (clip_x) { if ((uint16)clip_x >= v20) return; - v59 = v22; - v50 = v20; - v25 = (uint16)clip_x; - v26 = 0; + int v59 = v22; + int v50 = v20; + int v25 = (uint16)clip_x; + int v26 = 0; while (Asm_Zoom(v26 + 1, zoom2) < v25) ; - v27 = v26; + int v27 = v26; v22 = v59; spritePixelsP += v27; dest1P += (uint16)clip_x; @@ -2017,12 +1951,13 @@ R_Aff_Zoom_Larg_Cont1: if (v20 > (uint16)clip_x1) v20 = (uint16)clip_x1; + int v60; do { while (1) { v60 = v22; - v51 = dest1P; + byte *v51 = dest1P; v45 = spritePixelsP; - v28 = v20; + int v28 = v20; Agr_Flag_x = 0; Agr_x = 0; do { @@ -2070,17 +2005,17 @@ Aff_Zoom_Larg_Cont1: Largeur = spriteWidth; Red = zoom1; if (zoom1 < 100) { - v37 = Asm_Reduc(spriteWidth, Red); + int v37 = Asm_Reduc(spriteWidth, Red); if (modeFlag) { v40 = v37 + dest1P; do { - v65 = spriteHeight2; - v55 = v40; + int v65 = spriteHeight2; + byte *v55 = v40; Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { Red_x = 0; - v41 = Largeur; - v42 = v37; + int v41 = Largeur; + int v42 = v37; do { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { @@ -2105,13 +2040,13 @@ Aff_Zoom_Larg_Cont1: } while (spriteHeight2); } else { do { - v64 = spriteHeight2; - v54 = dest1P; + int v64 = spriteHeight2; + byte *v54 = dest1P; Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { Red_x = 0; - v38 = Largeur; - v39 = 0; + int v38 = Largeur; + int v39 = 0; do { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { @@ -2149,7 +2084,7 @@ Aff_Zoom_Larg_Cont1: dest2P += nbrligne2 * (uint16)clip_y; spriteHeight1 -= (uint16)clip_y; } - xLeft = (uint16)clip_y1; + int xLeft = (uint16)clip_y1; if (spriteHeight1 > clip_y1) spriteHeight1 = clip_y1; xLeft = clip_x; @@ -2159,23 +2094,22 @@ Aff_Zoom_Larg_Cont1: spriteWidth -= xLeft; } if (spriteWidth > (uint16)clip_x1) { - clippedWidth = spriteWidth - (uint16)clip_x1; + int clippedWidth = spriteWidth - (uint16)clip_x1; spritePixelsP += clippedWidth; dest2P -= clippedWidth; spriteWidth = (uint16)clip_x1; } + int yCtr2; do { yCtr2 = spriteHeight1; - destCopy2P = dest2P; - spritePixelsCopy2P = spritePixelsP; - xCtr2 = spriteWidth; - do { + byte *destCopy2P = dest2P; + const byte *spritePixelsCopy2P = spritePixelsP; + for (int xCtr2 = spriteWidth; xCtr2; xCtr2--) { if (*spritePixelsP) *dest2P = *spritePixelsP; ++spritePixelsP; --dest2P; - --xCtr2; - } while (xCtr2); + } spritePixelsP = spec_largeur + spritePixelsCopy2P; dest2P = nbrligne2 + destCopy2P; spriteHeight1 = yCtr2 - 1; @@ -2200,18 +2134,17 @@ Aff_Zoom_Larg_Cont1: } if (spriteWidth > (uint16)clip_x1) spriteWidth = (uint16)clip_x1; + int yCtr1; do { yCtr1 = spriteHeight1; - dest1CopyP = dest1P; - spritePixelsCopyP = spritePixelsP; - xCtr1 = spriteWidth; - do { + byte *dest1CopyP = dest1P; + const byte *spritePixelsCopyP = spritePixelsP; + for (int xCtr1 = spriteWidth; xCtr1; xCtr1--) { if (*spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; - --xCtr1; - } while (xCtr1); + } spritePixelsP = spec_largeur + spritePixelsCopyP; dest1P = nbrligne2 + dest1CopyP; spriteHeight1 = yCtr1 - 1; @@ -2246,7 +2179,6 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int int croppedWidth; int croppedHeight; int xRight; - int height2; int top2; int left; @@ -2271,7 +2203,7 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int croppedWidth = max_x - left; if (croppedWidth > 0 && croppedHeight > 0) { - height2 = croppedHeight; + int height2 = croppedHeight; Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY); Ajoute_Segment_Vesa(left, top2, left + croppedWidth, top2 + height2); } @@ -2363,16 +2295,10 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { } void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { - int dataOffset; - int dataVal1; - bool doneFlag; - byte *ptr; - Common::String filename; + int dataOffset = 1; + Common::String filename = file + ".ini"; + byte *ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); - dataOffset = 1; - - filename = file + ".ini"; - ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); if (ptr == g_PTRNUL) { _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); @@ -2397,9 +2323,9 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { error("Error, file not ini"); } else { - doneFlag = false; + bool doneFlag = false; do { - dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset); + int dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset); if (_vm->shouldQuit()) return; @@ -2549,7 +2475,6 @@ Video_Cont_Vbe: void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { const byte *srcP; byte *destP; - const byte *lineSrcP; srcP = xp + nbrligne2 * yp + srcSurface; destP = destSurface; @@ -2565,7 +2490,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Red_y += Red; if (Red_y < 100) { Red_x = 0; - lineSrcP = srcP; + const byte *lineSrcP = srcP; for (int xCtr = 0; xCtr < Largeur; ++xCtr) { Red_x += Red; -- cgit v1.2.3 From fd421b6bae804b29f605f4000bddf613abfd7c5d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 24 Nov 2012 15:32:56 +0100 Subject: HOPKINS: Fix more CppCheck warnings --- engines/hopkins/graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 29b3631887..a5d9768319 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2295,7 +2295,6 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { } void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { - int dataOffset = 1; Common::String filename = file + ".ini"; byte *ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); @@ -2324,6 +2323,8 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { error("Error, file not ini"); } else { bool doneFlag = false; + int dataOffset = 1; + do { int dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset); if (_vm->shouldQuit()) -- cgit v1.2.3 From fc33d2d7625e3a3967f17b0c01f7bdef1e1dec8b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 25 Nov 2012 21:25:14 +1100 Subject: HOPKINS: Replaced many occurrences of 640 with SCREEN_WIDTH --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a5d9768319..3b204ba057 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1207,7 +1207,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } } - if (destOffset > 640 * 480) { + if (destOffset > SCREEN_WIDTH * SCREEN_HEIGHT) { warning("HACK: Stopping anim, out of bounds - 0x%x %d", srcByte, destOffset); return; } -- cgit v1.2.3 From a23813f9a1340654607a647b6a2494e253c4b348 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Dec 2012 10:42:04 +0100 Subject: HOPKINS: Add main code for Win95 demo --- engines/hopkins/graphics.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3b204ba057..697a57cdde 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -88,8 +88,11 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { _vm = vm; if (_vm->getIsDemo()) { + if (_vm->getPlatform() == Common::kPlatformLinux) // CHECKME: Should be 0? - MANU_SCROLL = 1; + MANU_SCROLL = 1; + else + MANU_SCROLL = 0; SPEED_SCROLL = 16; } else { MANU_SCROLL = 0; -- cgit v1.2.3 From f91b1f1129d6be7c70b63e63c0a60640d30a8d2c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 4 Dec 2012 21:36:53 +0100 Subject: HOPKINS: Janitorials: remove some while(1) --- engines/hopkins/graphics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 697a57cdde..35a067cec5 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1874,7 +1874,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp } int v63; do { - while (1) { + for (;;) { v63 = v22; byte *v53 = v29; v46 = spritePixelsP; @@ -1882,7 +1882,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_x = 0; int v35 = v20; do { - while (1) { + for (;;) { if (*spritePixelsP) *v29 = *spritePixelsP; --v29; @@ -1956,7 +1956,7 @@ R_Aff_Zoom_Larg_Cont1: int v60; do { - while (1) { + for (;;) { v60 = v22; byte *v51 = dest1P; v45 = spritePixelsP; @@ -1964,7 +1964,7 @@ R_Aff_Zoom_Larg_Cont1: Agr_Flag_x = 0; Agr_x = 0; do { - while (1) { + for (;;) { if (*spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; @@ -2415,7 +2415,7 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { result = 0; destOffset = 0; srcPtr = src; - while (1) { + for (;;) { byteVal = *srcPtr; if (*srcPtr < kByteStop) goto Video_Cont_wVbe; @@ -2449,7 +2449,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { assert(VideoPtr); destOffset = 0; srcP = src; - while (1) { + for (;;) { byteVal = *srcP; if (*srcP < kByteStop) goto Video_Cont_Vbe; -- cgit v1.2.3 From 1665340fca244d2f0e8e08e0d8426f3b3bf37f79 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 4 Dec 2012 23:29:28 +0100 Subject: HOPKINS: Add MODE_VESA() --- engines/hopkins/graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 35a067cec5..0075fb0830 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2529,4 +2529,8 @@ void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte } while (yCtr); } +void GraphicsManager::MODE_VESA() { + SET_MODE(640, 480); +} + } // End of namespace Hopkins -- cgit v1.2.3 From 867cbbf4ff6ddfca826724a7ff74f44a06e8d044 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 9 Dec 2012 20:22:12 +0100 Subject: HOPKINS: Refactor fileManager --- engines/hopkins/graphics.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0075fb0830..1f734e284c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -190,7 +190,7 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { DD_Lock(); Cls_Video(); DD_Unlock(); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); A_PCX320(VESA_SCREEN, _vm->_globals.NFICHIER, Palette); memcpy(VESA_BUFFER, VESA_SCREEN, 0xFA00u); _vm->_eventsManager.souris_max(); @@ -209,14 +209,11 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { // Load Screen void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { - bool flag; Common::File f; - _vm->_fileManager.DMESS1(); - - flag = true; - if (_vm->_fileManager.RECHERCHE_CAT(file, 6) == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + bool flag = true; + if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("CHARGE_ECRAN - %s", file.c_str()); @@ -360,14 +357,14 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES"); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); f.seek(_vm->_globals.CAT_POSI); } else { // Load stand alone PCX file - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); } @@ -2299,26 +2296,26 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); + byte *ptr = _vm->_fileManager.searchCat(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (!mode) { filename = file + ".spr"; if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + _vm->_globals.SPRITE_ECRAN = _vm->_globals.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(filename, 8); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); } else { _vm->_globals.CAT_FLAG = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = false; } } @@ -2351,11 +2348,11 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); filename = file + ".rep"; - byte *dataP = _vm->_fileManager.RECHERCHE_CAT(filename, 2); + byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); - dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + dataP = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.COUCOU = dataP; } } -- cgit v1.2.3 From 269a6f9caeccc8e311d03d8df9e9aaa84c67224b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Dec 2012 07:54:03 +0100 Subject: HOPKINS: Some more function renaming --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 1f734e284c..38cbcc6126 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1636,8 +1636,8 @@ void GraphicsManager::Affiche_Segment_Vesa() { void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx) { int height, width; - width = _vm->_objectsManager.Get_Largeur(objectData, idx); - height = _vm->_objectsManager.Get_Hauteur(objectData, idx); + width = _vm->_objectsManager.getWidth(objectData, idx); + height = _vm->_objectsManager.getHeight(objectData, idx); if (*objectData == 78) { Affiche_Perfect(VESA_SCREEN, objectData, xp + 300, yp + 300, idx, 0, 0, 0); Affiche_Perfect(VESA_BUFFER, objectData, xp + 300, yp + 300, idx, 0, 0, 0); @@ -2161,8 +2161,8 @@ Aff_Zoom_Larg_Cont1: void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { int width, height; - width = _vm->_objectsManager.Get_Largeur(spriteData, spriteIndex); - height = _vm->_objectsManager.Get_Hauteur(spriteData, spriteIndex); + width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); + height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); if (*spriteData == 78) { Affiche_Perfect(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); Affiche_Perfect(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); -- cgit v1.2.3 From 299fbfc7c7558cd8275b86ef746ba73ea5ecbee2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 11 Dec 2012 01:53:50 +0100 Subject: HOPKINS: Start renaming EventsManager functions --- engines/hopkins/graphics.cpp | 68 +++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 38cbcc6126..0fd0de58dd 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -193,7 +193,6 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); A_PCX320(VESA_SCREEN, _vm->_globals.NFICHIER, Palette); memcpy(VESA_BUFFER, VESA_SCREEN, 0xFA00u); - _vm->_eventsManager.souris_max(); SCANLINE(320); max_x = 320; @@ -230,7 +229,6 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { Cls_Pal(); if (!DOUBLE_ECRAN) { - _vm->_eventsManager.souris_max(); SCANLINE(SCREEN_WIDTH); max_x = SCREEN_WIDTH; DD_Lock(); @@ -297,7 +295,7 @@ void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { // Scroll Screen int GraphicsManager::SCROLL_ECRAN(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); - _vm->_eventsManager.start_x = result; + _vm->_eventsManager._startPos.x = result; ofscroll = result; SCROLL = result; return result; @@ -809,9 +807,9 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface setpal_vga256(palData2); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } } @@ -822,9 +820,9 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface // Refresh the screen if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } } @@ -849,9 +847,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -870,9 +868,9 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -887,7 +885,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } goto LABEL_28; @@ -899,12 +897,12 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); if (Winbpp == 2) { if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } LABEL_28: - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } } @@ -939,9 +937,9 @@ void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surfa if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -1547,7 +1545,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (bloc.field0 != 1) continue; - if (_vm->_eventsManager.CASSE != false) { + if (_vm->_eventsManager._breakoutFl) { if (Winbpp == 1) { Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); } else if (Winbpp == 2) { @@ -1558,17 +1556,17 @@ void GraphicsManager::Affiche_Segment_Vesa() { dstRect.top = bloc.y1 * 2 + 30; dstRect.setWidth((bloc.x2 - bloc.x1) * 2); dstRect.setHeight((bloc.y2 - bloc.y1) * 2); - } else if (bloc.x2 > _vm->_eventsManager.start_x && bloc.x1 < (_vm->_eventsManager.start_x + SCREEN_WIDTH)) { - if (bloc.x1 < _vm->_eventsManager.start_x) - bloc.x1 = _vm->_eventsManager.start_x; - if (bloc.x2 > (_vm->_eventsManager.start_x + SCREEN_WIDTH)) - bloc.x2 = _vm->_eventsManager.start_x + SCREEN_WIDTH; + } else if (bloc.x2 > _vm->_eventsManager._startPos.x && bloc.x1 < (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) { + if (bloc.x1 < _vm->_eventsManager._startPos.x) + bloc.x1 = _vm->_eventsManager._startPos.x; + if (bloc.x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) + bloc.x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; if (SDL_ECHELLE) { // Calculate the bounds int xp = Magic_Number(bloc.x1) - 4; - if (xp < _vm->_eventsManager.start_x) - xp = _vm->_eventsManager.start_x; + if (xp < _vm->_eventsManager._startPos.x) + xp = _vm->_eventsManager._startPos.x; int yp = Magic_Number(bloc.y1) - 4; if (yp < 0) yp = 0; @@ -1579,7 +1577,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (height < 4) height = 4; - if ((xp - _vm->_eventsManager.start_x + width) > SCREEN_WIDTH) + if ((xp - _vm->_eventsManager._startPos.x + width) > SCREEN_WIDTH) xp -= 4; if ((height - yp) > (SCREEN_HEIGHT - 40)) yp -= 4; @@ -1589,15 +1587,15 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (Winbpp == 2) { m_scroll16A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } else { m_scroll2A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } DD_Unlock(); - dstRect.left = Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE); + dstRect.left = Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE); dstRect.top = Reel_Zoom(yp, SDL_ECHELLE); dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE)); dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE)); @@ -1607,13 +1605,13 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (Winbpp == 2) { m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); + bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); } else { m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - _vm->_eventsManager.start_x, bloc.y1); + bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); } - dstRect.left = bloc.x1 - _vm->_eventsManager.start_x; + dstRect.left = bloc.x1 - _vm->_eventsManager._startPos.x; dstRect.top = bloc.y1; dstRect.setWidth(bloc.x2 - bloc.x1); dstRect.setHeight(bloc.y2 - bloc.y1); @@ -2373,15 +2371,15 @@ void GraphicsManager::NB_SCREEN() { DD_Lock(); if (Winbpp == 2) { if (SDL_ECHELLE) - m_scroll16A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll16(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } if (Winbpp == 1) { if (SDL_ECHELLE) - m_scroll2A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else - m_scroll2(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll2(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); -- cgit v1.2.3 From eece86d78e6821638772da0a5198e690c0f08745 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Dec 2012 08:05:04 +0100 Subject: HOPKINS: Homogenization of memory management --- engines/hopkins/graphics.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0fd0de58dd..32b7b62688 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -80,8 +80,8 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { - _vm->_globals.dos_free2(VESA_SCREEN); - _vm->_globals.dos_free2(VESA_BUFFER); + _vm->_globals.freeMemory(VESA_SCREEN); + _vm->_globals.freeMemory(VESA_BUFFER); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -135,8 +135,8 @@ void GraphicsManager::SET_MODE(int width, int height) { } // Init surfaces - VESA_SCREEN = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - VESA_BUFFER = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + VESA_SCREEN = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + VESA_BUFFER = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); VideoPtr = NULL; XSCREEN = width; @@ -410,7 +410,7 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * f.read(surface, 0x80u); v4 = filesize - 896; - ptr = _vm->_globals.dos_malloc2(0xFE00u); + ptr = _vm->_globals.allocMemory(0xFE00u); if (v4 >= 0xFA00) { v15 = v4 / 0xFA00 + 1; v17 = 64000 * (v4 / 0xFA00) - v4; @@ -465,7 +465,7 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * f.read(palette, 0x300u); f.close(); - _vm->_globals.dos_free2(ptr); + _vm->_globals.freeMemory(ptr); } // Clear Palette @@ -2302,8 +2302,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { } if (!mode) { filename = file + ".spr"; - if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) - _vm->_globals.SPRITE_ECRAN = _vm->_globals.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + _vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { @@ -2340,10 +2339,9 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { doneFlag = true; } while (!doneFlag); } - _vm->_globals.dos_free2(ptr); + _vm->_globals.freeMemory(ptr); if (mode != 1) { - if (g_PTRNUL != _vm->_globals.COUCOU) - _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); + _vm->_globals.COUCOU = _vm->_globals.freeMemory(_vm->_globals.COUCOU); filename = file + ".rep"; byte *dataP = _vm->_fileManager.searchCat(filename, 2); -- cgit v1.2.3 From 95025312a7c3b184fef3818ece1f1d55b7fb19d1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 14 Dec 2012 01:49:22 +0100 Subject: HOPKINS: Janitorial - Remove trailing space and double semi columns --- engines/hopkins/graphics.cpp | 290 +++++++++++++++++++++---------------------- 1 file changed, 145 insertions(+), 145 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 32b7b62688..3dbd97a9da 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -91,7 +91,7 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { if (_vm->getPlatform() == Common::kPlatformLinux) // CHECKME: Should be 0? MANU_SCROLL = 1; - else + else MANU_SCROLL = 0; SPEED_SCROLL = 16; } else { @@ -114,7 +114,7 @@ void GraphicsManager::SET_MODE(int width, int height) { SDL_ECHELLE = 75; if (_vm->_globals.XSETMODE == 5) SDL_ECHELLE = _vm->_globals.XZOOM; - + int bpp = 8; if (_vm->_globals.XFORCE8 == true) bpp = 8; @@ -202,7 +202,7 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { if (Winbpp == 2) CopyAsm16(VESA_BUFFER); DD_Unlock(); - + FADE_IN_CASSE(); } @@ -241,7 +241,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { } else if (Winbpp == 1) { if (!SDL_ECHELLE) m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else + else m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } @@ -278,7 +278,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { for (int idx = 0; idx < 256; ++idx) TABLE_COUL[idx] = idx; - + Trans_bloc(TABLE_COUL, palette, 256, minIndex, maxIndex); for (int idx = 0; idx < 256; ++idx) { @@ -320,7 +320,7 @@ void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int m col2 += minThreshold; if (col2 < col1) continue; - + col2 -= maxThreshold; if (col2 > col1) continue; @@ -332,9 +332,9 @@ void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int m } void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { - byte *dataP; - int count; - byte dataVal; + byte *dataP; + int count; + byte dataVal; dataP = surface; count = size - 1; @@ -372,7 +372,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by error("Error decoding PCX %s", file.c_str()); const Graphics::Surface *s = pcxDecoder.getSurface(); - + // Copy out the dimensions and pixels of the decoded surface DOUBLE_ECRAN = s->w > SCREEN_WIDTH; PCX_L = s->w; @@ -382,28 +382,28 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by // Copy out the palette const byte *palSrc = pcxDecoder.getPalette(); Common::copy((const byte *)palSrc, (const byte *)palSrc + PALETTE_BLOCK_SIZE, palette); - + f.close(); } void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte *palette) { - size_t filesize; - int v4; - size_t v5; - int v6; - size_t v7; - int v8; - byte v9; - int v10; - int v11; - char v12; - int v15; - int v16; - int32 v17; - byte *ptr; - Common::File f; - - if (!f.open(file)) + size_t filesize; + int v4; + size_t v5; + int v6; + size_t v7; + int v8; + byte v9; + int v10; + int v11; + char v12; + int v15; + int v16; + int32 v17; + byte *ptr; + Common::File f; + + if (!f.open(file)) error("File not found - %s", file.c_str()); filesize = f.size(); @@ -562,7 +562,7 @@ void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, } --xCtr; } while ( xCtr ); - + srcP = srcCopyP; destP = WinScan + destCopyP; if (Agr_Flag_y) @@ -648,7 +648,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width *(uint16 *)destP = pixelWord; destP += 2; } - + --xCtr; } while (xCtr); @@ -657,12 +657,12 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width destP = WinScan + destCopyP; if (Agr_Flag_y == 1) break; - + Agr_y += SDL_ECHELLE; - + if ((unsigned int)Agr_y < 100) break; - + Agr_y -= 100; Agr_Flag_y = 1; } @@ -679,18 +679,18 @@ void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, i int yCount; int xCount; byte srcByte; - byte *loopDestP; - byte *loopSrcP; - byte *loopSrc2P; - byte *tempDestP; - const byte *tempSrcP; - int yCtr; + byte *loopDestP; + byte *loopSrcP; + byte *loopSrc2P; + byte *tempDestP; + const byte *tempSrcP; + int yCtr; assert(VideoPtr); srcP = xp + 320 * yp + surface; destP = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels; yCount = height; - + do { yCtr = yCount; xCount = width; @@ -709,7 +709,7 @@ void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, i destP = loopSrc2P - WinScan + 1; --xCount; } while (xCount); - + destP = WinScan + WinScan + tempDestP; srcP = tempSrcP + 320; yCount = yCtr - 1; @@ -717,9 +717,9 @@ void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, i } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - const byte *srcP; - uint16 *destP; - int yCount; + const byte *srcP; + uint16 *destP; + int yCount; int xCount; int xCtr; const byte *palette; @@ -736,7 +736,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels); yCount = height; xCount = width; - + do { yCtr = yCount; xCtr = xCount; @@ -744,13 +744,13 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, loopDestP = destP; savedXCount = xCount; palette = PAL_PIXELS; - + do { tempSrcP = (uint16 *)(palette + 2 * *srcP); srcByte = *tempSrcP; *destP = *tempSrcP; *(destP + 1) = srcByte; - + tempDestP = (uint16 *)((byte *)destP + WinScan); *tempDestP = srcByte; *(tempDestP + 1) = srcByte; @@ -758,7 +758,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, destP = (uint16 *)((byte *)tempDestP - WinScan + 4); --xCtr; } while (xCtr); - + xCount = savedXCount; destP = (uint16 *)((byte *)loopDestP + WinScan * 2); srcP = loopSrcP + 320; @@ -776,7 +776,7 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface // Set current palette to black setpal_vga256(palData2); - + // Loop through fading in the palette uint16 *pTemp1 = &palData1[1]; for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) { @@ -791,14 +791,14 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface if (palData2[palOffset + 1] < palette[palOffset + 1]) { uint16 *pDest = &pTemp1[palOffset]; - uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; + uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; *pDest = v; palData2[palOffset + 1] = (v >> 8) & 0xff; } if (palData2[palOffset + 2] < palette[palOffset + 2]) { uint16 *pDest = &pTemp2[palOffset]; - uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; + uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; *pDest = v; palData2[palOffset + 2] = (v >> 8) & 0xff; } @@ -843,7 +843,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac tempPalette[palDataIndex] = palByte; palData[palDataIndex] = *(palIndex++ + palette); } while (palIndex < PALETTE_BLOCK_SIZE); - + setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) @@ -852,7 +852,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } - + int palCtr3 = 0; if (palMax > 0) { do { @@ -864,14 +864,14 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac palData[palCtr5] = (palValue >> 8) & 0xff; ++palCtr4; } while (palCtr4 < (PALETTE_BLOCK_SIZE)); - + setpal_vga256(palData); if (Winbpp == 2) { if (SDL_ECHELLE) m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - + DD_VBL(); } ++palCtr3; @@ -882,7 +882,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac palData[i] = 0; setpal_vga256(palData); - + if (Winbpp == 2) { if (!SDL_ECHELLE) { m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); @@ -934,13 +934,13 @@ void GraphicsManager::setpal_vga256(const byte *palette) { void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { CHANGE_PALETTE(palette); - + if (Winbpp == 2) { if (SDL_ECHELLE) m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - + DD_VBL(); } } @@ -949,7 +949,7 @@ void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) { Palette[palIndex * 3] = 255 * r / 100; Palette[palIndex * 3 + 1] = 255 * g / 100; Palette[palIndex * 3 + 2] = 255 * b / 100; - + setpal_vga256(Palette); } @@ -965,8 +965,8 @@ void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { int rv, gv, bv; - int palOffset; - int v8; + int palOffset; + int v8; rv = 255 * r / 100; gv = 255 * g / 100; @@ -980,9 +980,9 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { cmap[v8] = rv; cmap[v8 + 1] = gv; cmap[v8 + 2] = bv; - + WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); - + if (Winbpp == 1) g_system->getPaletteManager()->setPalette(cmap, palIndex, 1); } @@ -1057,13 +1057,13 @@ void GraphicsManager::FADE_OUT_CASSE() { void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { int rleValue; - int destOffset; - const byte *srcP; + int destOffset; + const byte *srcP; byte srcByte; byte destLen1; - byte *destSlice1P; - byte destLen2; - byte *destSlice2P; + byte *destSlice1P; + byte destLen2; + byte *destSlice2P; rleValue = 0; destOffset = 0; @@ -1133,7 +1133,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { srcByte = *srcP; if (*srcP < 222) goto Video_Cont3_Vbe; - + if (srcByte == kByteStop) return; if (srcByte < kSetOffset) { @@ -1243,9 +1243,9 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { - int destOffset; - const byte *srcP; - byte pixelIndex; + int destOffset; + const byte *srcP; + byte pixelIndex; destOffset = 0; srcP = srcData; @@ -1278,9 +1278,9 @@ Video_Cont_Vbe16a: void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) { const byte *srcP; byte *destP; - int rowCount; + int rowCount; int i; - int rowCount2; + int rowCount2; // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within // the screen, and so thus can read areas outside of the allocated surface buffer @@ -1323,7 +1323,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int width = READ_LE_UINT16(spriteP); spriteP += 2; int height = READ_LE_UINT16(spriteP); - + // Clip X clip_x1 = width; if ((xp + width) <= (min_x + 300)) @@ -1377,7 +1377,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Set up surface destination byte *destP = surface + (yp - 300) * nbrligne2 + (xp - 300); - + // Handling for clipped versus non-clipped if (clip_flag) { // Clipped version @@ -1424,7 +1424,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, Common::copy(spriteP, spriteP + width, tempDestP); spriteP += width; } - + tempDestP += width; } @@ -1468,7 +1468,7 @@ void GraphicsManager::RESET_SEGMENT_VESA() { if (_vm->_globals.NBBLOC > 0) { for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++) _vm->_globals.BLOC[idx].field0 = 0; - + _vm->_globals.NBBLOC = 0; } } @@ -1497,7 +1497,7 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { do { BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; - if (bloc.field0 == 1 + if (bloc.field0 == 1 && tempX >= bloc.x1 && x2 <= bloc.x2 && y1 >= bloc.y1 && y2 <= bloc.y2) addFlag = false; @@ -1505,7 +1505,7 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { blocCount = blocIndex; } while (_vm->_globals.NBBLOC + 1 != blocIndex); } - + if (addFlag) { assert(_vm->_globals.NBBLOC < 250); BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; @@ -1527,7 +1527,7 @@ int GraphicsManager::Magic_Number(signed int v) { ++result; if (result & 2) result += 2; - + return result; } @@ -1544,14 +1544,14 @@ void GraphicsManager::Affiche_Segment_Vesa() { Common::Rect &dstRect = dstrect[idx - 1]; if (bloc.field0 != 1) continue; - + if (_vm->_eventsManager._breakoutFl) { if (Winbpp == 1) { Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); } else if (Winbpp == 2) { Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); } - + dstRect.left = bloc.x1 * 2; dstRect.top = bloc.y1 * 2 + 30; dstRect.setWidth((bloc.x2 - bloc.x1) * 2); @@ -1561,7 +1561,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { bloc.x1 = _vm->_eventsManager._startPos.x; if (bloc.x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) bloc.x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; - + if (SDL_ECHELLE) { // Calculate the bounds int xp = Magic_Number(bloc.x1) - 4; @@ -1586,10 +1586,10 @@ void GraphicsManager::Affiche_Segment_Vesa() { DD_Lock(); if (Winbpp == 2) { - m_scroll16A(VESA_BUFFER, xp, yp, width, height, + m_scroll16A(VESA_BUFFER, xp, yp, width, height, Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } else { - m_scroll2A(VESA_BUFFER, xp, yp, width, height, + m_scroll2A(VESA_BUFFER, xp, yp, width, height, Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); } @@ -1619,7 +1619,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { DD_Unlock(); } } - + _vm->_globals.BLOC[idx].field0 = 0; } @@ -1650,13 +1650,13 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i void GraphicsManager::CopyAsm(const byte *surface) { const byte *srcP; byte srcByte; - byte *destP; + byte *destP; int yCtr; int xCtr; - byte *dest1P; - byte *dest2P; - byte *dest3P; - byte *destPitch; + byte *dest1P; + byte *dest2P; + byte *dest3P; + byte *destPitch; const byte *srcPitch; assert(VideoPtr); @@ -1668,7 +1668,7 @@ void GraphicsManager::CopyAsm(const byte *surface) { srcPitch = srcP; destPitch = destP; xCtr = 320; - + do { srcByte = *srcP; *destP = *srcP; @@ -1682,7 +1682,7 @@ void GraphicsManager::CopyAsm(const byte *surface) { ++srcP; --xCtr; } while (xCtr); - + srcP = srcPitch + 320; destP = WinScan + WinScan + destPitch; --yCtr; @@ -1690,17 +1690,17 @@ void GraphicsManager::CopyAsm(const byte *surface) { } void GraphicsManager::CopyAsm16(const byte *surface) { - const byte *v1; - byte *v2; - int v3; - signed int v4; - byte *v5; - uint16 *v6; - int v; - uint16 *v8; - int v9; - byte *v10; - const byte *v11; + const byte *v1; + byte *v2; + int v3; + signed int v4; + byte *v5; + uint16 *v6; + int v; + uint16 *v8; + int v9; + byte *v10; + const byte *v11; assert(VideoPtr); v1 = surface; @@ -1770,7 +1770,7 @@ int GraphicsManager::Reel_Zoom(int v, int percentage) { int GraphicsManager::Asm_Zoom(int v, int percentage) { if (v) v += percentage * (long int)v / 100; - + return v; } @@ -1781,22 +1781,22 @@ int GraphicsManager::Reel_Reduc(int v, int percentage) { int GraphicsManager::Asm_Reduc(int v, int percentage) { if (v) v -= percentage * (long int)v / 100; - + return v; } - -// Display 'Perfect?' + +// Display 'Perfect?' void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) { - const byte *spriteStartP; - int i; + const byte *spriteStartP; + int i; const byte *spriteSizeP; - const byte *spritePixelsP; - byte *dest1P; - byte *dest2P; - byte *v29; - byte *v40; - const byte *v45; - const byte *v46; + const byte *spritePixelsP; + byte *dest1P; + byte *dest2P; + byte *v29; + byte *v40; + const byte *v45; + const byte *v46; spriteStartP = srcData + 3; for (i = frameIndex; i; --i) @@ -2173,18 +2173,18 @@ void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int } void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { - int top; - int croppedWidth; + int top; + int croppedWidth; int croppedHeight; - int xRight; - int top2; + int xRight; + int top2; int left; left = x1; top = y1; croppedWidth = width; croppedHeight = height; - + if (x1 < min_x) { croppedWidth = width - (min_x - x1); left = min_x; @@ -2208,13 +2208,13 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int } void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY) { - const byte *srcP; - byte *destP; + const byte *srcP; + byte *destP; int yp; int yCurrent; byte *dest2P; const byte *src2P; - unsigned int pitch; + unsigned int pitch; srcP = x1 + nbrligne2 * y1 + srcSurface; destP = destX + nbrligne2 * destY + destSurface; @@ -2233,16 +2233,16 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } // Display Font -void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, +void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { const byte *spriteDataP; - int i; - const byte *spriteSizeP; - int spriteWidth; + int i; + const byte *spriteSizeP; + int spriteWidth; int spriteHeight; const byte *spritePixelsP; byte *destP; - int xCtr; + int xCtr; byte destByte; byte *destLineP; int yCtr; @@ -2272,7 +2272,7 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x destByte = colour; *destP = destByte; } - + ++destP; ++spritePixelsP; --xCtr; @@ -2342,7 +2342,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.freeMemory(ptr); if (mode != 1) { _vm->_globals.COUCOU = _vm->_globals.freeMemory(_vm->_globals.COUCOU); - + filename = file + ".rep"; byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; @@ -2357,7 +2357,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { } void GraphicsManager::NB_SCREEN() { - byte *destP; + byte *destP; const byte *srcP; if (!_vm->_globals.NECESSAIRE) @@ -2380,7 +2380,7 @@ void GraphicsManager::NB_SCREEN() { m_scroll2(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } DD_Unlock(); - + destP = VESA_SCREEN; srcP = VESA_BUFFER; memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu); @@ -2400,10 +2400,10 @@ void GraphicsManager::videkey() { } void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { - int result; - int destOffset; - const byte *srcPtr; - byte byteVal; + int result; + int destOffset; + const byte *srcPtr; + byte byteVal; result = 0; destOffset = 0; @@ -2435,10 +2435,10 @@ Video_Cont_wVbe: } void GraphicsManager::Copy_Video_Vbe(const byte *src) { - int destOffset; - const byte *srcP; - byte byteVal; - + int destOffset; + const byte *srcP; + byte byteVal; + assert(VideoPtr); destOffset = 0; srcP = src; @@ -2470,8 +2470,8 @@ Video_Cont_Vbe: // Reduce Screen void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { - const byte *srcP; - byte *destP; + const byte *srcP; + byte *destP; srcP = xp + nbrligne2 * yp + srcSurface; destP = destSurface; -- cgit v1.2.3 From d7d8c19dae1a8ca586851892da406a3b4025f4c8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 15 Dec 2012 22:46:09 +0100 Subject: HOPKINS: Merge two zoom in and out functions --- engines/hopkins/graphics.cpp | 52 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3dbd97a9da..b28c33450f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -122,8 +122,8 @@ void GraphicsManager::SET_MODE(int width, int height) { bpp = 16; if (SDL_ECHELLE) { - width = Reel_Zoom(width, SDL_ECHELLE); - height = Reel_Zoom(height, SDL_ECHELLE); + width = zoomIn(width, SDL_ECHELLE); + height = zoomIn(height, SDL_ECHELLE); } Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); @@ -1587,18 +1587,18 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (Winbpp == 2) { m_scroll16A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); } else { m_scroll2A(VESA_BUFFER, xp, yp, width, height, - Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE)); + zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); } DD_Unlock(); - dstRect.left = Reel_Zoom(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE); - dstRect.top = Reel_Zoom(yp, SDL_ECHELLE); - dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE)); - dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE)); + dstRect.left = zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE); + dstRect.top = zoomIn(yp, SDL_ECHELLE); + dstRect.setWidth(zoomIn(width, SDL_ECHELLE)); + dstRect.setHeight(zoomIn(height, SDL_ECHELLE)); } else { // WORKAROUND: Original didn't lock the screen for access DD_Lock(); @@ -1763,22 +1763,20 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in } while (yCtr != 1); } -int GraphicsManager::Reel_Zoom(int v, int percentage) { - return Asm_Zoom(v, percentage); -} - -int GraphicsManager::Asm_Zoom(int v, int percentage) { +/** + * Compute the value of a parameter plus a given percentage + */ +int GraphicsManager::zoomIn( int v, int percentage ) { if (v) v += percentage * (long int)v / 100; return v; } -int GraphicsManager::Reel_Reduc(int v, int percentage) { - return Asm_Reduc(v, percentage); -} - -int GraphicsManager::Asm_Reduc(int v, int percentage) { +/** + * Compute the value of a parameter minus a given percentage + */ +int GraphicsManager::zoomOut(int v, int percentage) { if (v) v -= percentage * (long int)v / 100; @@ -1830,8 +1828,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_Flag_y = 0; Agr_Flag_x = 0; Largeur = spriteWidth; - int v20 = Asm_Zoom(spriteWidth, zoom2); - int v22 = Asm_Zoom(spriteHeight1, zoom2); + int v20 = zoomIn(spriteWidth, zoom2); + int v22 = zoomIn(spriteHeight1, zoom2); if (modeFlag) { v29 = v20 + dest1P; if (clip_y) { @@ -1841,7 +1839,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v52 = v20; int v30 = 0; int v31 = (uint16)clip_y; - while (Asm_Zoom(v30 + 1, zoom2) < v31) + while (zoomIn(v30 + 1, zoom2) < v31) ; v20 = v52; spritePixelsP += Largeur * v30; @@ -1860,7 +1858,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v29 -= v32; int v62 = v22; int v33 = 0; - while (Asm_Zoom(v33 + 1, zoom2) < v32) + while (zoomIn(v33 + 1, zoom2) < v32) ; int v34 = v33; v22 = v62; @@ -1922,7 +1920,7 @@ R_Aff_Zoom_Larg_Cont1: int v49 = v20; int v23 = 0; int v24 = (uint16)clip_y; - while (Asm_Zoom(v23 + 1, zoom2) < v24) + while (zoomIn(v23 + 1, zoom2) < v24) ; v20 = v49; spritePixelsP += Largeur * v23; @@ -1938,7 +1936,7 @@ R_Aff_Zoom_Larg_Cont1: int v50 = v20; int v25 = (uint16)clip_x; int v26 = 0; - while (Asm_Zoom(v26 + 1, zoom2) < v25) + while (zoomIn(v26 + 1, zoom2) < v25) ; int v27 = v26; v22 = v59; @@ -2003,7 +2001,7 @@ Aff_Zoom_Larg_Cont1: Largeur = spriteWidth; Red = zoom1; if (zoom1 < 100) { - int v37 = Asm_Reduc(spriteWidth, Red); + int v37 = zoomOut(spriteWidth, Red); if (modeFlag) { v40 = v37 + dest1P; do { @@ -2480,8 +2478,8 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Red_x = 0; Red_y = 0; if (zoom < 100) { - Reduc_Ecran_L = Asm_Reduc(width, Red); - Reduc_Ecran_H = Asm_Reduc(height, Red); + Reduc_Ecran_L = zoomOut(width, Red); + Reduc_Ecran_H = zoomOut(height, Red); for (int yCtr = 0; yCtr < height; ++yCtr, srcP += nbrligne2) { Red_y += Red; -- cgit v1.2.3 From 2d172ab46e76f416b307ae11471a09c979855702 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 15 Dec 2012 23:28:58 +0100 Subject: HOPKINS: Remove all code related to 8b display --- engines/hopkins/graphics.cpp | 294 ++++++++++--------------------------------- 1 file changed, 63 insertions(+), 231 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b28c33450f..e4e1936b21 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -39,7 +39,6 @@ GraphicsManager::GraphicsManager() { SDL_ECHELLE = 0; XSCREEN = YSCREEN = 0; WinScan = 0; - Winbpp = 0; PAL_PIXELS = NULL; nbrligne = 0; Linear = false; @@ -115,24 +114,13 @@ void GraphicsManager::SET_MODE(int width, int height) { if (_vm->_globals.XSETMODE == 5) SDL_ECHELLE = _vm->_globals.XZOOM; - int bpp = 8; - if (_vm->_globals.XFORCE8 == true) - bpp = 8; - if (_vm->_globals.XFORCE16 == true) - bpp = 16; - if (SDL_ECHELLE) { width = zoomIn(width, SDL_ECHELLE); height = zoomIn(height, SDL_ECHELLE); } Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); - - if (bpp == 8) { - initGraphics(width, height, true); - } else { - initGraphics(width, height, true, &pixelFormat16); - } + initGraphics(width, height, true, &pixelFormat16); // Init surfaces VESA_SCREEN = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); @@ -143,8 +131,7 @@ void GraphicsManager::SET_MODE(int width, int height) { YSCREEN = height; Linear = true; - Winbpp = bpp / 8; - WinScan = width * Winbpp; + WinScan = width * 2; // Refactor me PAL_PIXELS = SD_PIXELS; nbrligne = width; @@ -197,10 +184,7 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { max_x = 320; DD_Lock(); - if (Winbpp == 1) - CopyAsm(VESA_BUFFER); - if (Winbpp == 2) - CopyAsm16(VESA_BUFFER); + CopyAsm16(VESA_BUFFER); DD_Unlock(); FADE_IN_CASSE(); @@ -233,17 +217,10 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { max_x = SCREEN_WIDTH; DD_Lock(); Cls_Video(); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } else if (Winbpp == 1) { - if (!SDL_ECHELLE) - m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } + if (SDL_ECHELLE) + m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); } else { @@ -255,19 +232,10 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (MANU_SCROLL == 1) { DD_Lock(); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } - if (Winbpp == 1) { - if (!SDL_ECHELLE) - m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } - + if (SDL_ECHELLE) + m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); } } @@ -472,10 +440,6 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * void GraphicsManager::Cls_Pal() { Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); SD_PIXELS[0] = 0; - - if (Winbpp == 1) { - g_system->getPaletteManager()->setPalette(cmap, 0, 256); - } } void GraphicsManager::SCANLINE(int pitch) { @@ -508,80 +472,6 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i } while (yCtr != 1); } -void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *srcP; - byte *destP; - int destPitch; - int srcPitch; - int yCtr; - - assert(VideoPtr); - srcP = xs + nbrligne2 * ys + surface; - destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; - destPitch = WinScan - SCREEN_WIDTH; - srcPitch = nbrligne2 - SCREEN_WIDTH; - yCtr = height; - - do { - memcpy(destP, srcP, SCREEN_WIDTH); - destP = destP + destPitch + SCREEN_WIDTH; - srcP = srcP + srcPitch + SCREEN_WIDTH; - --yCtr; - } while (yCtr); -} - -void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *srcP; - byte *destP; - int yCtr; - int xCtr; - byte srcByte; - const byte *srcCopyP; - byte *destCopyP; - - assert(VideoPtr); - srcP = xs + nbrligne2 * ys + surface; - destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; - yCtr = height; - Agr_x = 0; - Agr_y = 0; - Agr_Flag_y = 0; - do { - for (;;) { - destCopyP = destP; - srcCopyP = srcP; - xCtr = width; - Agr_x = 0; - do { - srcByte = *srcP; - *destP++ = *srcP++; - Agr_x += SDL_ECHELLE; - if ((unsigned int)Agr_x >= 100) { - Agr_x -= 100; - *destP++ = srcByte; - } - --xCtr; - } while ( xCtr ); - - srcP = srcCopyP; - destP = WinScan + destCopyP; - if (Agr_Flag_y) - break; - - Agr_y += SDL_ECHELLE; - if ((unsigned int)Agr_y < 100) - break; - - Agr_y -= 100; - Agr_Flag_y = 1; - } - - Agr_Flag_y = 0; - srcP = nbrligne2 + srcCopyP; - --yCtr; - } while (yCtr); -} - /** * Copies data from a 8-bit palette surface into the 16-bit screen */ @@ -805,26 +695,22 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface } setpal_vga256(palData2); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); - } - } - - // Set the final palette - setpal_vga256(palette); - - // Refresh the screen - if (Winbpp == 2) { if (SDL_ECHELLE) m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } + + // Set the final palette + setpal_vga256(palette); + + // Refresh the screen + if (SDL_ECHELLE) + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); } void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { @@ -845,13 +731,11 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } while (palIndex < PALETTE_BLOCK_SIZE); setpal_vga256(palData); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); - } + if (SDL_ECHELLE) + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); int palCtr3 = 0; if (palMax > 0) { @@ -866,14 +750,12 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } while (palCtr4 < (PALETTE_BLOCK_SIZE)); setpal_vga256(palData); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + if (SDL_ECHELLE) + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); - } + DD_VBL(); ++palCtr3; } while (palMax > palCtr3); } @@ -883,28 +765,24 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); - if (Winbpp == 2) { - if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } - goto LABEL_28; + if (!SDL_ECHELLE) { + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + return DD_VBL(); } + goto LABEL_28; } else { for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) palData[i] = 0; setpal_vga256(palData); - if (Winbpp == 2) { - if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } - -LABEL_28: - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + if (!SDL_ECHELLE) { + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } + +LABEL_28: + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + return DD_VBL(); } } @@ -934,15 +812,11 @@ void GraphicsManager::setpal_vga256(const byte *palette) { void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { CHANGE_PALETTE(palette); - - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - - DD_VBL(); - } + if (SDL_ECHELLE) + m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); } void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) { @@ -982,9 +856,6 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { cmap[v8 + 2] = bv; WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); - - if (Winbpp == 1) - g_system->getPaletteManager()->setPalette(cmap, palIndex, 1); } void GraphicsManager::CHANGE_PALETTE(const byte *palette) { @@ -999,21 +870,14 @@ void GraphicsManager::CHANGE_PALETTE(const byte *palette) { for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); } - - if (Winbpp == 1) - g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE); } uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) { - if (Winbpp == 1) { - error("TODO: Support in 8-bit graphics mode"); - } else { - Graphics::PixelFormat format = g_system->getScreenFormat(); + Graphics::PixelFormat format = g_system->getScreenFormat(); - return (r >> format.rLoss) << format.rShift - | (g >> format.gLoss) << format.gShift - | (b >> format.bLoss) << format.bShift; - } + return (r >> format.rLoss) << format.rShift + | (g >> format.gLoss) << format.gShift + | (b >> format.bLoss) << format.bShift; } void GraphicsManager::DD_VBL() { @@ -1033,11 +897,9 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { void GraphicsManager::FADE_IN_CASSE() { setpal_vga256(Palette); - if (Winbpp == 2) { - DD_Lock(); - CopyAsm16(VESA_BUFFER); - DD_Unlock(); - } + DD_Lock(); + CopyAsm16(VESA_BUFFER); + DD_Unlock(); DD_VBL(); } @@ -1047,11 +909,9 @@ void GraphicsManager::FADE_OUT_CASSE() { memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); setpal_vga256(palette); - if (Winbpp == 2) { - DD_Lock(); - CopyAsm16(VESA_BUFFER); - DD_Unlock(); - } + DD_Lock(); + CopyAsm16(VESA_BUFFER); + DD_Unlock(); DD_VBL(); } @@ -1546,12 +1406,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { continue; if (_vm->_eventsManager._breakoutFl) { - if (Winbpp == 1) { - Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); - } else if (Winbpp == 2) { - Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); - } - + Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); dstRect.left = bloc.x1 * 2; dstRect.top = bloc.y1 * 2 + 30; dstRect.setWidth((bloc.x2 - bloc.x1) * 2); @@ -1584,15 +1439,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { // WORKAROUND: Original didn't lock the screen for access DD_Lock(); - - if (Winbpp == 2) { - m_scroll16A(VESA_BUFFER, xp, yp, width, height, - zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); - } else { - m_scroll2A(VESA_BUFFER, xp, yp, width, height, - zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); - } - + m_scroll16A(VESA_BUFFER, xp, yp, width, height, zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); DD_Unlock(); dstRect.left = zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE); @@ -1602,14 +1449,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { } else { // WORKAROUND: Original didn't lock the screen for access DD_Lock(); - - if (Winbpp == 2) { - m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); - } else { - m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, - bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); - } + m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); dstRect.left = bloc.x1 - _vm->_eventsManager._startPos.x; dstRect.top = bloc.y1; @@ -2365,18 +2205,10 @@ void GraphicsManager::NB_SCREEN() { if (nbrligne == 1280) Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400); DD_Lock(); - if (Winbpp == 2) { - if (SDL_ECHELLE) - m_scroll16A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } - if (Winbpp == 1) { - if (SDL_ECHELLE) - m_scroll2A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll2(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - } + if (SDL_ECHELLE) + m_scroll16A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + else + m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); destP = VESA_SCREEN; -- cgit v1.2.3 From 3c31d91d97c6f621e7f9bc22e3efe3b8ca38a079 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 16 Dec 2012 00:26:54 +0100 Subject: HOPKINS: Remove zoom, mode, SDL Zoom and fullscreen variables Also remove functions related to the loading of INI files --- engines/hopkins/graphics.cpp | 139 ++++++------------------------------------- 1 file changed, 19 insertions(+), 120 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index e4e1936b21..ddd05a8fd8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -36,7 +36,6 @@ namespace Hopkins { GraphicsManager::GraphicsManager() { _lockCtr = 0; SDL_MODEYES = false; - SDL_ECHELLE = 0; XSCREEN = YSCREEN = 0; WinScan = 0; PAL_PIXELS = NULL; @@ -101,24 +100,6 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { void GraphicsManager::SET_MODE(int width, int height) { if (!SDL_MODEYES) { - SDL_ECHELLE = 0; - - if (_vm->_globals.XSETMODE == 1) - SDL_ECHELLE = 0; - if (_vm->_globals.XSETMODE == 2) - SDL_ECHELLE = 25; - if (_vm->_globals.XSETMODE == 3) - SDL_ECHELLE = 50; - if (_vm->_globals.XSETMODE == 4) - SDL_ECHELLE = 75; - if (_vm->_globals.XSETMODE == 5) - SDL_ECHELLE = _vm->_globals.XZOOM; - - if (SDL_ECHELLE) { - width = zoomIn(width, SDL_ECHELLE); - height = zoomIn(height, SDL_ECHELLE); - } - Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(width, height, true, &pixelFormat16); @@ -217,11 +198,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { max_x = SCREEN_WIDTH; DD_Lock(); Cls_Video(); - if (SDL_ECHELLE) - m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); } else { SCANLINE(SCREEN_WIDTH * 2); @@ -232,10 +209,7 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (MANU_SCROLL == 1) { DD_Lock(); - if (SDL_ECHELLE) - m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); } } @@ -532,7 +506,6 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width *(uint16 *)destP = pixelWord; ++srcP; destP += 2; - Agr_x += SDL_ECHELLE; if ((unsigned int)Agr_x >= 100) { Agr_x -= 100; *(uint16 *)destP = pixelWord; @@ -548,8 +521,6 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width if (Agr_Flag_y == 1) break; - Agr_y += SDL_ECHELLE; - if ((unsigned int)Agr_y < 100) break; @@ -695,10 +666,7 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface } setpal_vga256(palData2); - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -706,10 +674,7 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface setpal_vga256(palette); // Refresh the screen - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -731,10 +696,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } while (palIndex < PALETTE_BLOCK_SIZE); setpal_vga256(palData); - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); int palCtr3 = 0; @@ -750,11 +712,7 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac } while (palCtr4 < (PALETTE_BLOCK_SIZE)); setpal_vga256(palData); - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); ++palCtr3; } while (palMax > palCtr3); @@ -765,23 +723,14 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac setpal_vga256(palData); - if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } - goto LABEL_28; + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + return DD_VBL(); } else { for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) palData[i] = 0; setpal_vga256(palData); - if (!SDL_ECHELLE) { - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } - -LABEL_28: - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } } @@ -812,10 +761,7 @@ void GraphicsManager::setpal_vga256(const byte *palette) { void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { CHANGE_PALETTE(palette); - if (SDL_ECHELLE) - m_scroll16A(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -1378,19 +1324,6 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { } } -int GraphicsManager::Magic_Number(signed int v) { - int result = v; - - if (!v) - result = 4; - if (result & 1) - ++result; - if (result & 2) - result += 2; - - return result; -} - // Display VESA Segment void GraphicsManager::Affiche_Segment_Vesa() { if (_vm->_globals.NBBLOC == 0) @@ -1417,47 +1350,16 @@ void GraphicsManager::Affiche_Segment_Vesa() { if (bloc.x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) bloc.x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; - if (SDL_ECHELLE) { - // Calculate the bounds - int xp = Magic_Number(bloc.x1) - 4; - if (xp < _vm->_eventsManager._startPos.x) - xp = _vm->_eventsManager._startPos.x; - int yp = Magic_Number(bloc.y1) - 4; - if (yp < 0) - yp = 0; - int width = Magic_Number(bloc.x2) + 4 - xp; - if (width < 4) - width = 4; - int height = Magic_Number(bloc.y2) + 4 - yp; - if (height < 4) - height = 4; - - if ((xp - _vm->_eventsManager._startPos.x + width) > SCREEN_WIDTH) - xp -= 4; - if ((height - yp) > (SCREEN_HEIGHT - 40)) - yp -= 4; - - // WORKAROUND: Original didn't lock the screen for access - DD_Lock(); - m_scroll16A(VESA_BUFFER, xp, yp, width, height, zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE), zoomIn(yp, SDL_ECHELLE)); - DD_Unlock(); - - dstRect.left = zoomIn(xp - _vm->_eventsManager._startPos.x, SDL_ECHELLE); - dstRect.top = zoomIn(yp, SDL_ECHELLE); - dstRect.setWidth(zoomIn(width, SDL_ECHELLE)); - dstRect.setHeight(zoomIn(height, SDL_ECHELLE)); - } else { - // WORKAROUND: Original didn't lock the screen for access - DD_Lock(); - m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); + // WORKAROUND: Original didn't lock the screen for access + DD_Lock(); + m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); - dstRect.left = bloc.x1 - _vm->_eventsManager._startPos.x; - dstRect.top = bloc.y1; - dstRect.setWidth(bloc.x2 - bloc.x1); - dstRect.setHeight(bloc.y2 - bloc.y1); + dstRect.left = bloc.x1 - _vm->_eventsManager._startPos.x; + dstRect.top = bloc.y1; + dstRect.setWidth(bloc.x2 - bloc.x1); + dstRect.setHeight(bloc.y2 - bloc.y1); - DD_Unlock(); - } + DD_Unlock(); } _vm->_globals.BLOC[idx].field0 = 0; @@ -2205,10 +2107,7 @@ void GraphicsManager::NB_SCREEN() { if (nbrligne == 1280) Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400); DD_Lock(); - if (SDL_ECHELLE) - m_scroll16A(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - else - m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_Unlock(); destP = VESA_SCREEN; -- cgit v1.2.3 From 0aab5168ce61d51fe0034db3c30247dd23b22813 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 16 Dec 2012 09:56:50 +0100 Subject: HOPKINS: Start renaming ObjectsManager members --- engines/hopkins/graphics.cpp | 47 ++------------------------------------------ 1 file changed, 2 insertions(+), 45 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ddd05a8fd8..27a39059cb 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -534,49 +534,6 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } while (yCtr != 1); } -void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - const byte *srcP; - byte *destP; - int yCount; - int xCount; - byte srcByte; - byte *loopDestP; - byte *loopSrcP; - byte *loopSrc2P; - byte *tempDestP; - const byte *tempSrcP; - int yCtr; - - assert(VideoPtr); - srcP = xp + 320 * yp + surface; - destP = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels; - yCount = height; - - do { - yCtr = yCount; - xCount = width; - tempSrcP = srcP; - tempDestP = destP; - do { - srcByte = *srcP; - *destP = *srcP; - loopDestP = WinScan + destP; - *loopDestP = srcByte; - loopSrcP = loopDestP - WinScan + 1; - *loopSrcP = srcByte; - loopSrc2P = WinScan + loopSrcP; - *loopSrc2P = srcByte; - ++srcP; - destP = loopSrc2P - WinScan + 1; - --xCount; - } while (xCount); - - destP = WinScan + WinScan + tempDestP; - srcP = tempSrcP + 320; - yCount = yCtr - 1; - } while (yCtr != 1); -} - void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { const byte *srcP; uint16 *destP; @@ -2092,8 +2049,8 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.COUCOU = dataP; } } - _vm->_objectsManager.FORCEZONE = 1; - _vm->_objectsManager.CHANGEVERBE = 0; + _vm->_objectsManager._forceZoneFl = true; + _vm->_objectsManager._changeVerbFl = false; } void GraphicsManager::NB_SCREEN() { -- cgit v1.2.3 From e99d5b320a3e2737d0bb6aa9d4c401b2c3116beb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 17 Dec 2012 00:16:49 +0100 Subject: HOPKINS: Renaming of members of Globals and ObjectsManager --- engines/hopkins/graphics.cpp | 51 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 27a39059cb..cb11b4ddb1 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1230,7 +1230,7 @@ void GraphicsManager::VISU_ALL() { void GraphicsManager::RESET_SEGMENT_VESA() { if (_vm->_globals.NBBLOC > 0) { for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++) - _vm->_globals.BLOC[idx].field0 = 0; + _vm->_globals.BLOC[idx]._activeFl = false; _vm->_globals.NBBLOC = 0; } @@ -1260,9 +1260,8 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { do { BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; - if (bloc.field0 == 1 - && tempX >= bloc.x1 && x2 <= bloc.x2 - && y1 >= bloc.y1 && y2 <= bloc.y2) + if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 + && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; ++blocIndex; blocCount = blocIndex; @@ -1273,11 +1272,11 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { assert(_vm->_globals.NBBLOC < 250); BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; - bloc.field0 = 1; - bloc.x1 = tempX; - bloc.x2 = x2; - bloc.y1 = y1; - bloc.y2 = y2; + bloc._activeFl = true; + bloc._x1 = tempX; + bloc._x2 = x2; + bloc._y1 = y1; + bloc._y2 = y2; } } @@ -1292,34 +1291,34 @@ void GraphicsManager::Affiche_Segment_Vesa() { for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { BlocItem &bloc = _vm->_globals.BLOC[idx]; Common::Rect &dstRect = dstrect[idx - 1]; - if (bloc.field0 != 1) + if (!bloc._activeFl) continue; if (_vm->_eventsManager._breakoutFl) { - Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1); - dstRect.left = bloc.x1 * 2; - dstRect.top = bloc.y1 * 2 + 30; - dstRect.setWidth((bloc.x2 - bloc.x1) * 2); - dstRect.setHeight((bloc.y2 - bloc.y1) * 2); - } else if (bloc.x2 > _vm->_eventsManager._startPos.x && bloc.x1 < (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) { - if (bloc.x1 < _vm->_eventsManager._startPos.x) - bloc.x1 = _vm->_eventsManager._startPos.x; - if (bloc.x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) - bloc.x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; + Copy_Vga16(VESA_BUFFER, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1); + dstRect.left = bloc._x1 * 2; + dstRect.top = bloc._y1 * 2 + 30; + dstRect.setWidth((bloc._x2 - bloc._x1) * 2); + dstRect.setHeight((bloc._y2 - bloc._y1) * 2); + } else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) { + if (bloc._x1 < _vm->_eventsManager._startPos.x) + bloc._x1 = _vm->_eventsManager._startPos.x; + if (bloc._x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) + bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access DD_Lock(); - m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1 - _vm->_eventsManager._startPos.x, bloc.y1); + m_scroll16(VESA_BUFFER, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1); - dstRect.left = bloc.x1 - _vm->_eventsManager._startPos.x; - dstRect.top = bloc.y1; - dstRect.setWidth(bloc.x2 - bloc.x1); - dstRect.setHeight(bloc.y2 - bloc.y1); + dstRect.left = bloc._x1 - _vm->_eventsManager._startPos.x; + dstRect.top = bloc._y1; + dstRect.setWidth(bloc._x2 - bloc._x1); + dstRect.setHeight(bloc._y2 - bloc._y1); DD_Unlock(); } - _vm->_globals.BLOC[idx].field0 = 0; + _vm->_globals.BLOC[idx]._activeFl = false; } _vm->_globals.NBBLOC = 0; -- cgit v1.2.3 From fbd2c0e9182cf6a3ff90cf83b47347dfdd4de564 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 18 Dec 2012 00:37:52 +0100 Subject: HOPKINS: Some renaming, rework some loop statements --- engines/hopkins/graphics.cpp | 148 +++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 89 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index cb11b4ddb1..7c630dcf42 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -66,7 +66,7 @@ GraphicsManager::GraphicsManager() { SDL_NBLOCS = 0; Red_x = Red_y = 0; Red = 0; - Largeur = 0; + _width = 0; Compteur_y = 0; spec_largeur = 0; @@ -274,17 +274,13 @@ void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int m } void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { - byte *dataP; - int count; byte dataVal; - dataP = surface; - count = size - 1; - do { + byte *dataP = surface; + for (int count = size - 1; count; count--){ dataVal = *dataP++; *(dataP - 1) = *(dataVal + col); - --count; - } while (count); + } } // TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder @@ -332,12 +328,9 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * size_t filesize; int v4; size_t v5; - int v6; size_t v7; - int v8; byte v9; int v10; - int v11; char v12; int v15; int v16; @@ -367,18 +360,17 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * v5 = v4; } v16 = v15 - 1; - v6 = 0; v7 = 0; - do { + for (int i = 0; i < 64000; i++) { if (v7 == v5) { v7 = 0; --v16; v5 = 64000; if (!v16) v5 = v17; - v8 = v6; +// v8 = i; f.read(ptr, v5); - v6 = v8; +// i = v8; } v9 = *(ptr + v7++); if (v9 > 0xC0u) { @@ -389,22 +381,22 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * v5 = 64000; if (v16 == 1) v5 = v17; - v11 = v6; +// v11 = i; f.read(ptr, v5); - v6 = v11; +// i = v11; } v12 = *(ptr + v7++); do { - *(surface + v6++) = v12; + *(surface + i++) = v12; --v10; } while (v10); } else { - *(surface + v6++) = v9; + *(surface + i++) = v9; } - } while (v6 <= 0xF9FF); + } f.seek(filesize - 768); - f.read(palette, 0x300u); + f.read(palette, 768); f.close(); _vm->_globals.freeMemory(ptr); @@ -643,36 +635,31 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac palMax = palByte = FADESPD; if (palette) { - int palIndex = 0; - do { + for (int palIndex = 0; palIndex < PALETTE_BLOCK_SIZE; palIndex++) { int palDataIndex = palIndex; - palByte = *(palIndex + palette); + palByte = palette[palIndex]; palByte <<= 8; tempPalette[palDataIndex] = palByte; - palData[palDataIndex] = *(palIndex++ + palette); - } while (palIndex < PALETTE_BLOCK_SIZE); + palData[palDataIndex] = palette[palIndex]; + } setpal_vga256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); - int palCtr3 = 0; if (palMax > 0) { - do { - int palCtr4 = 0; - do { + for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { + for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { int palCtr5 = palCtr4; - int palValue = tempPalette[palCtr4] - (*(palCtr4 + palette) << 8) / palMax; + int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; tempPalette[palCtr5] = palValue; palData[palCtr5] = (palValue >> 8) & 0xff; - ++palCtr4; - } while (palCtr4 < (PALETTE_BLOCK_SIZE)); + } setpal_vga256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); - ++palCtr3; - } while (palMax > palCtr3); + } } for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) @@ -1349,8 +1336,6 @@ void GraphicsManager::CopyAsm(const byte *surface) { const byte *srcP; byte srcByte; byte *destP; - int yCtr; - int xCtr; byte *dest1P; byte *dest2P; byte *dest3P; @@ -1361,13 +1346,10 @@ void GraphicsManager::CopyAsm(const byte *surface) { srcP = surface; srcByte = 30 * WinScan; destP = (byte *)VideoPtr->pixels + 30 * WinScan; - yCtr = 200; - do { + for (int yCtr = 200; yCtr != 0; yCtr--) { srcPitch = srcP; destPitch = destP; - xCtr = 320; - - do { + for (int xCtr = 320; xCtr != 0; xCtr--) { srcByte = *srcP; *destP = *srcP; dest1P = WinScan + destP; @@ -1378,20 +1360,17 @@ void GraphicsManager::CopyAsm(const byte *surface) { *dest3P = srcByte; destP = dest3P - WinScan + 1; ++srcP; - --xCtr; - } while (xCtr); + } srcP = srcPitch + 320; destP = WinScan + WinScan + destPitch; - --yCtr; - } while (yCtr); + } } void GraphicsManager::CopyAsm16(const byte *surface) { const byte *v1; byte *v2; int v3; - signed int v4; byte *v5; uint16 *v6; int v; @@ -1407,10 +1386,9 @@ void GraphicsManager::CopyAsm16(const byte *surface) { do { v11 = v1; v10 = v2; - v4 = 320; v9 = v3; v5 = PAL_PIXELS; - do { + for (int v4 = 320; v4; v4--) { v = 2 * *v1; v6 = (uint16 *)(v5 + 2 * *v1); v = *v6; @@ -1421,8 +1399,7 @@ void GraphicsManager::CopyAsm16(const byte *surface) { *(v8 + 1) = v; ++v1; v2 = (byte *)v8 - WinScan + 4; - --v4; - } while (v4); + } v1 = v11 + 320; v2 = WinScan * 2 + v10; v3 = v9 - 1; @@ -1525,7 +1502,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_y = 0; Agr_Flag_y = 0; Agr_Flag_x = 0; - Largeur = spriteWidth; + _width = spriteWidth; int v20 = zoomIn(spriteWidth, zoom2); int v22 = zoomIn(spriteHeight1, zoom2); if (modeFlag) { @@ -1540,7 +1517,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp while (zoomIn(v30 + 1, zoom2) < v31) ; v20 = v52; - spritePixelsP += Largeur * v30; + spritePixelsP += _width * v30; v29 += nbrligne2 * (uint16)clip_y; v22 = v61 - (uint16)clip_y; } @@ -1571,8 +1548,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v46 = spritePixelsP; Agr_Flag_x = 0; Agr_x = 0; - int v35 = v20; - do { + for (int v35 = v20; v35; v35--) { for (;;) { if (*spritePixelsP) *v29 = *spritePixelsP; @@ -1590,10 +1566,9 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp goto R_Aff_Zoom_Larg_Cont1; } Agr_Flag_x = 0; - --v35; - } while (v35); + } R_Aff_Zoom_Larg_Cont1: - spritePixelsP = Largeur + v46; + spritePixelsP = _width + v46; v29 = nbrligne2 + v53; ++Compteur_y; if (!Agr_Flag_y) @@ -1621,7 +1596,7 @@ R_Aff_Zoom_Larg_Cont1: while (zoomIn(v23 + 1, zoom2) < v24) ; v20 = v49; - spritePixelsP += Largeur * v23; + spritePixelsP += _width * v23; dest1P += nbrligne2 * (uint16)clip_y; v22 = v58 - (uint16)clip_y; } @@ -1675,7 +1650,7 @@ R_Aff_Zoom_Larg_Cont1: --v28; } while (v28); Aff_Zoom_Larg_Cont1: - spritePixelsP = Largeur + v45; + spritePixelsP = _width + v45; dest1P = nbrligne2 + v51; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; @@ -1696,7 +1671,7 @@ Aff_Zoom_Larg_Cont1: Compteur_y = 0; Red_x = 0; Red_y = 0; - Largeur = spriteWidth; + _width = spriteWidth; Red = zoom1; if (zoom1 < 100) { int v37 = zoomOut(spriteWidth, Red); @@ -1708,9 +1683,8 @@ Aff_Zoom_Larg_Cont1: Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { Red_x = 0; - int v41 = Largeur; int v42 = v37; - do { + for (int v41 = _width; v41; v41--) { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) @@ -1722,13 +1696,12 @@ Aff_Zoom_Larg_Cont1: Red_x = Red_x - 100; ++spritePixelsP; } - --v41; - } while (v41); + } spriteHeight2 = v65; v40 = nbrligne2 + v55; } else { Red_y = Red_y - 100; - spritePixelsP += Largeur; + spritePixelsP += _width; } --spriteHeight2; } while (spriteHeight2); @@ -1739,9 +1712,8 @@ Aff_Zoom_Larg_Cont1: Red_y = Red + Red_y; if ((uint16)Red_y < 0x64u) { Red_x = 0; - int v38 = Largeur; int v39 = 0; - do { + for (int v38 = _width; v38; v38--) { Red_x = Red + Red_x; if ((uint16)Red_x < 0x64u) { if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) @@ -1753,20 +1725,19 @@ Aff_Zoom_Larg_Cont1: Red_x = Red_x - 100; ++spritePixelsP; } - --v38; - } while (v38); + } spriteHeight2 = v64; dest1P = nbrligne2 + v54; } else { Red_y = Red_y - 100; - spritePixelsP += Largeur; + spritePixelsP += _width; } --spriteHeight2; } while (spriteHeight2); } } } else { - Largeur = spriteWidth; + _width = spriteWidth; Compteur_y = 0; if (modeFlag) { dest2P = spriteWidth + dest1P; @@ -1938,7 +1909,6 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x int spriteHeight; const byte *spritePixelsP; byte *destP; - int xCtr; byte destByte; byte *destLineP; int yCtr; @@ -1955,13 +1925,12 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); spritePixelsP = spriteSizeP + 10; destP = surface + xp + nbrligne2 * yp; - Largeur = spriteWidth; + _width = spriteWidth; do { yCtr = spriteHeight; destLineP = destP; - xCtr = spriteWidth; - do { + for (int xCtr = spriteWidth; xCtr; xCtr--) { destByte = *spritePixelsP; if (*spritePixelsP) { if (destByte == (byte)-4) @@ -1971,8 +1940,7 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x ++destP; ++spritePixelsP; - --xCtr; - } while (xCtr); + } destP = nbrligne2 + destLineP; spriteHeight = yCtr - 1; } while (yCtr != 1); @@ -2161,7 +2129,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int srcP = xp + nbrligne2 * yp + srcSurface; destP = destSurface; Red = zoom; - Largeur = width; + _width = width; Red_x = 0; Red_y = 0; if (zoom < 100) { @@ -2174,7 +2142,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Red_x = 0; const byte *lineSrcP = srcP; - for (int xCtr = 0; xCtr < Largeur; ++xCtr) { + for (int xCtr = 0; xCtr < _width; ++xCtr) { Red_x += Red; if (Red_x < 100) { *destP++ = *lineSrcP++; @@ -2190,21 +2158,23 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int } } -void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int width, byte col) { +/** + * Draw horizontal line + */ +void GraphicsManager::drawHorizontalLine(byte *surface, int xp, int yp, unsigned int width, byte col) { memset(surface + xp + nbrligne2 * yp, col, width); } -void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte col) { - byte *destP; - int yCtr; +/** + * Draw vertical line + */ +void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height, byte col) { + byte *destP = surface + xp + nbrligne2 * yp; - destP = surface + xp + nbrligne2 * yp; - yCtr = height; - do { + for (int yCtr = height; yCtr; yCtr--) { *destP = col; destP += nbrligne2; - --yCtr; - } while (yCtr); + } } void GraphicsManager::MODE_VESA() { -- cgit v1.2.3 From c1aafc9b47f21608c19a686f4eeab243cea036fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 19 Dec 2012 02:15:32 +0100 Subject: HOPKINS: Rename methods in ObjectsManager, Globals and GraphicsManager --- engines/hopkins/graphics.cpp | 249 +++++++++++++++++++++++-------------------- 1 file changed, 132 insertions(+), 117 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7c630dcf42..44c775b660 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -34,14 +34,14 @@ namespace Hopkins { GraphicsManager::GraphicsManager() { - _lockCtr = 0; + _lockCounter = 0; SDL_MODEYES = false; XSCREEN = YSCREEN = 0; WinScan = 0; PAL_PIXELS = NULL; nbrligne = 0; Linear = false; - VideoPtr = NULL; + _videoPtr = NULL; ofscroll = 0; SCROLL = 0; PCX_L = PCX_H = 0; @@ -53,7 +53,7 @@ GraphicsManager::GraphicsManager() { Agr_Flag_x = Agr_Flag_y = 0; FADESPD = 15; FADE_LINUX = 0; - NOLOCK = false; + _skipVideoLockFl = false; no_scroll = 0; REDRAW = false; min_x = 0; @@ -78,8 +78,8 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { - _vm->_globals.freeMemory(VESA_SCREEN); - _vm->_globals.freeMemory(VESA_BUFFER); + _vm->_globals.freeMemory(_vesaScreen); + _vm->_globals.freeMemory(_vesaBuffer); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -88,26 +88,26 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { if (_vm->getIsDemo()) { if (_vm->getPlatform() == Common::kPlatformLinux) // CHECKME: Should be 0? - MANU_SCROLL = 1; + MANU_SCROLL = true; else - MANU_SCROLL = 0; + MANU_SCROLL = false; SPEED_SCROLL = 16; } else { - MANU_SCROLL = 0; + MANU_SCROLL = false; SPEED_SCROLL = 32; } } -void GraphicsManager::SET_MODE(int width, int height) { +void GraphicsManager::setGraphicalMode(int width, int height) { if (!SDL_MODEYES) { Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(width, height, true, &pixelFormat16); // Init surfaces - VESA_SCREEN = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - VESA_BUFFER = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _vesaScreen = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - VideoPtr = NULL; + _videoPtr = NULL; XSCREEN = width; YSCREEN = height; @@ -124,70 +124,84 @@ void GraphicsManager::SET_MODE(int width, int height) { } } -void GraphicsManager::DD_Lock() { - if (!NOLOCK) { - if (_lockCtr++ == 0) - VideoPtr = g_system->lockScreen(); +/** + * (try to) Lock Screen + */ +void GraphicsManager::lockScreen() { + if (!_skipVideoLockFl) { + if (_lockCounter++ == 0) + _videoPtr = g_system->lockScreen(); } } -void GraphicsManager::DD_Unlock() { - assert(VideoPtr); - if (--_lockCtr == 0) { +/** + * (try to) Unlock Screen + */ +void GraphicsManager::unlockScreen() { + assert(_videoPtr); + if (--_lockCounter == 0) { g_system->unlockScreen(); - VideoPtr = NULL; + _videoPtr = NULL; } } -// Clear Screen -void GraphicsManager::Cls_Video() { - assert(VideoPtr); - - VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); +/** + * Clear Screen + */ +void GraphicsManager::clearScreen() { + assert(_videoPtr); + _videoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); } -void GraphicsManager::LOAD_IMAGE(const Common::String &file) { +/** + * Load Image + */ +void GraphicsManager::loadImage(const Common::String &file) { Common::String filename = Common::String::format("%s.PCX", file.c_str()); - CHARGE_ECRAN(filename); + loadScreen(filename); INIT_TABLE(165, 170, Palette); } - -void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { +/** + * Load VGA Image + */ +void GraphicsManager::loadVgaImage(const Common::String &file) { SCANLINE(SCREEN_WIDTH); - DD_Lock(); - Cls_Video(); - DD_Unlock(); + lockScreen(); + clearScreen(); + unlockScreen(); _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); - A_PCX320(VESA_SCREEN, _vm->_globals.NFICHIER, Palette); - memcpy(VESA_BUFFER, VESA_SCREEN, 0xFA00u); + A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, Palette); + memcpy(_vesaBuffer, _vesaScreen, 0xFA00u); SCANLINE(320); max_x = 320; - DD_Lock(); - CopyAsm16(VESA_BUFFER); - DD_Unlock(); + lockScreen(); + CopyAsm16(_vesaBuffer); + unlockScreen(); FADE_IN_CASSE(); } -// Load Screen -void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { +/** + * Load Screen + */ +void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) - error("CHARGE_ECRAN - %s", file.c_str()); + error("loadScreen - %s", file.c_str()); f.seek(0, SEEK_END); f.close(); flag = false; } - SCROLL_ECRAN(0); - A_PCX640_480((byte *)VESA_SCREEN, file, Palette, flag); + scrollScreen(0); + A_PCX640_480((byte *)_vesaScreen, file, Palette, flag); SCROLL = 0; OLD_SCROLL = 0; @@ -196,25 +210,25 @@ void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { if (!DOUBLE_ECRAN) { SCANLINE(SCREEN_WIDTH); max_x = SCREEN_WIDTH; - DD_Lock(); - Cls_Video(); - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_Unlock(); + lockScreen(); + clearScreen(); + m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + unlockScreen(); } else { SCANLINE(SCREEN_WIDTH * 2); max_x = SCREEN_WIDTH * 2; - DD_Lock(); - Cls_Video(); - DD_Unlock(); - - if (MANU_SCROLL == 1) { - DD_Lock(); - m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_Unlock(); + lockScreen(); + clearScreen(); + unlockScreen(); + + if (MANU_SCROLL) { + lockScreen(); + m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + unlockScreen(); } } - memcpy(VESA_BUFFER, VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { @@ -234,13 +248,14 @@ void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { TABLE_COUL[0] = 1; } -// Scroll Screen -int GraphicsManager::SCROLL_ECRAN(int amount) { +/** + * Scroll Screen + */ +void GraphicsManager::scrollScreen(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); _vm->_eventsManager._startPos.x = result; ofscroll = result; SCROLL = result; - return result; } void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { @@ -421,9 +436,9 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i const byte *src2P; unsigned int widthRemaining; - assert(VideoPtr); + assert(_videoPtr); srcP = xs + nbrligne2 * ys + surface; - destP = destX + WinScan * destY + (byte *)VideoPtr->pixels; + destP = destX + WinScan * destY + (byte *)_videoPtr->pixels; yNext = height; do { yCtr = yNext; @@ -442,11 +457,11 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i * Copies data from a 8-bit palette surface into the 16-bit screen */ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - DD_Lock(); + lockScreen(); - assert(VideoPtr); + assert(_videoPtr); const byte *srcP = xs + nbrligne2 * ys + surface; - uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destX * 2 + WinScan * destY); + uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destX * 2 + WinScan * destY); for (int yp = 0; yp < height; ++yp) { // Copy over the line, using the source pixels as lookups into the pixels palette @@ -461,7 +476,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, destP += WinScan / 2; } - DD_Unlock(); + unlockScreen(); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -476,9 +491,9 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width const byte *srcCopyP; const byte *destCopyP; - assert(VideoPtr); + assert(_videoPtr); srcP = xs + nbrligne2 * ys + surface; - destP = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels; + destP = destX + destX + WinScan * destY + (byte *)_videoPtr->pixels; yNext = height; Agr_x = 0; Agr_y = 0; @@ -541,9 +556,9 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, const byte *loopSrcP; int yCtr; - assert(VideoPtr); + assert(_videoPtr); srcP = xp + 320 * yp + surface; - destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels); + destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)_videoPtr->pixels); yCount = height; xCount = width; @@ -681,22 +696,22 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac void GraphicsManager::FADE_INS() { FADESPD = 1; - fade_in(Palette, 1, (const byte *)VESA_BUFFER); + fade_in(Palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTS() { FADESPD = 1; - fade_out(Palette, 1, (const byte *)VESA_BUFFER); + fade_out(Palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_INW() { FADESPD = 15; - fade_in(Palette, 20, (const byte *)VESA_BUFFER); + fade_in(Palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTW() { FADESPD = 15; - fade_out(Palette, 20, (const byte *)VESA_BUFFER); + fade_out(Palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::setpal_vga256(const byte *palette) { @@ -787,9 +802,9 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { void GraphicsManager::FADE_IN_CASSE() { setpal_vga256(Palette); - DD_Lock(); - CopyAsm16(VESA_BUFFER); - DD_Unlock(); + lockScreen(); + CopyAsm16(_vesaBuffer); + unlockScreen(); DD_VBL(); } @@ -799,9 +814,9 @@ void GraphicsManager::FADE_OUT_CASSE() { memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); setpal_vga256(palette); - DD_Lock(); - CopyAsm16(VESA_BUFFER); - DD_Unlock(); + lockScreen(); + CopyAsm16(_vesaBuffer); + unlockScreen(); DD_VBL(); } @@ -875,7 +890,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { int destLen2; byte *destSlice2P; - assert(VideoPtr); + assert(_videoPtr); rleValue = 0; destOffset = 0; srcP = srcData; @@ -907,20 +922,20 @@ Video_Cont3_Vbe: if (srcByte == 211) { destLen1 = *(srcP + 1); rleValue = *(srcP + 2); - destSlice1P = destOffset + (byte *)VideoPtr->pixels; + destSlice1P = destOffset + (byte *)_videoPtr->pixels; destOffset += destLen1; memset(destSlice1P, rleValue, destLen1); srcP += 3; } else { destLen2 = (byte)(*srcP + 45); rleValue = *(srcP + 1); - destSlice2P = (byte *)(destOffset + (byte *)VideoPtr->pixels); + destSlice2P = (byte *)(destOffset + (byte *)_videoPtr->pixels); destOffset += destLen2; memset(destSlice2P, rleValue, destLen2); srcP += 2; } } else { - *(destOffset + (byte *)VideoPtr->pixels) = srcByte; + *(destOffset + (byte *)_videoPtr->pixels) = srcByte; ++srcP; ++destOffset; } @@ -930,7 +945,7 @@ Video_Cont3_Vbe: void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { const byte *srcP = srcData; int destOffset = 0; - assert(VideoPtr); + assert(_videoPtr); for (;;) { byte srcByte = *srcP; @@ -964,7 +979,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { if (srcByte == 211) { int pixelCount = *(srcP + 1); int pixelIndex = *(srcP + 2); - uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2); + uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); destOffset += pixelCount; @@ -975,7 +990,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } else { int pixelCount = srcByte - 211; int pixelIndex = *(srcP + 1); - uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2); + uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); destOffset += pixelCount; @@ -985,7 +1000,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { srcP += 2; } } else { - *((uint16 *)VideoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte); + *((uint16 *)_videoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte); ++srcP; ++destOffset; } @@ -1019,7 +1034,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { srcP += 5; } Video_Cont_Vbe16a: - WRITE_LE_UINT16((byte *)VideoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex)); + WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex)); ++srcP; ++destOffset; } @@ -1273,7 +1288,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { return; SDL_NBLOCS = _vm->_globals.NBBLOC; - DD_Lock(); + lockScreen(); for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { BlocItem &bloc = _vm->_globals.BLOC[idx]; @@ -1282,7 +1297,7 @@ void GraphicsManager::Affiche_Segment_Vesa() { continue; if (_vm->_eventsManager._breakoutFl) { - Copy_Vga16(VESA_BUFFER, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1); + Copy_Vga16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1); dstRect.left = bloc._x1 * 2; dstRect.top = bloc._y1 * 2 + 30; dstRect.setWidth((bloc._x2 - bloc._x1) * 2); @@ -1294,22 +1309,22 @@ void GraphicsManager::Affiche_Segment_Vesa() { bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access - DD_Lock(); - m_scroll16(VESA_BUFFER, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1); + lockScreen(); + m_scroll16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1); dstRect.left = bloc._x1 - _vm->_eventsManager._startPos.x; dstRect.top = bloc._y1; dstRect.setWidth(bloc._x2 - bloc._x1); dstRect.setHeight(bloc._y2 - bloc._y1); - DD_Unlock(); + unlockScreen(); } _vm->_globals.BLOC[idx]._activeFl = false; } _vm->_globals.NBBLOC = 0; - DD_Unlock(); + unlockScreen(); if (!_vm->_globals.BPP_NOAFF) { // SDL_UpdateRects(LinuxScr, SDL_NBLOCS, dstrect); } @@ -1322,11 +1337,11 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i width = _vm->_objectsManager.getWidth(objectData, idx); height = _vm->_objectsManager.getHeight(objectData, idx); if (*objectData == 78) { - Affiche_Perfect(VESA_SCREEN, objectData, xp + 300, yp + 300, idx, 0, 0, 0); - Affiche_Perfect(VESA_BUFFER, objectData, xp + 300, yp + 300, idx, 0, 0, 0); + Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, 0); + Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, 0); } else { - Sprite_Vesa(VESA_BUFFER, objectData, xp + 300, yp + 300, idx); - Sprite_Vesa(VESA_SCREEN, objectData, xp + 300, yp + 300, idx); + Sprite_Vesa(_vesaBuffer, objectData, xp + 300, yp + 300, idx); + Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); } if (!_vm->_globals.NO_VISU) Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); @@ -1342,10 +1357,10 @@ void GraphicsManager::CopyAsm(const byte *surface) { byte *destPitch; const byte *srcPitch; - assert(VideoPtr); + assert(_videoPtr); srcP = surface; srcByte = 30 * WinScan; - destP = (byte *)VideoPtr->pixels + 30 * WinScan; + destP = (byte *)_videoPtr->pixels + 30 * WinScan; for (int yCtr = 200; yCtr != 0; yCtr--) { srcPitch = srcP; destPitch = destP; @@ -1379,9 +1394,9 @@ void GraphicsManager::CopyAsm16(const byte *surface) { byte *v10; const byte *v11; - assert(VideoPtr); + assert(_videoPtr); v1 = surface; - v2 = 30 * WinScan + (byte *)VideoPtr->pixels; + v2 = 30 * WinScan + (byte *)_videoPtr->pixels; v3 = 200; do { v11 = v1; @@ -1829,11 +1844,11 @@ void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); if (*spriteData == 78) { - Affiche_Perfect(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); - Affiche_Perfect(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); + Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); + Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); } else { - Sprite_Vesa(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex); - Sprite_Vesa(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex); + Sprite_Vesa(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex); + Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); } if (!_vm->_globals.NO_VISU) Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); @@ -2027,16 +2042,16 @@ void GraphicsManager::NB_SCREEN() { if (!_vm->_globals.NECESSAIRE) INIT_TABLE(50, 65, Palette); if (nbrligne == SCREEN_WIDTH) - Trans_bloc2(VESA_BUFFER, TABLE_COUL, 307200); + Trans_bloc2(_vesaBuffer, TABLE_COUL, 307200); if (nbrligne == 1280) - Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400); - DD_Lock(); - m_scroll16(VESA_BUFFER, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_Unlock(); - - destP = VESA_SCREEN; - srcP = VESA_BUFFER; - memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu); + Trans_bloc2(_vesaBuffer, TABLE_COUL, 614400); + lockScreen(); + m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + unlockScreen(); + + destP = _vesaScreen; + srcP = _vesaBuffer; + memcpy(_vesaScreen, _vesaBuffer, 0x95FFCu); srcP = srcP + 614396; destP = destP + 614396; *destP = *srcP; @@ -2092,7 +2107,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { const byte *srcP; byte byteVal; - assert(VideoPtr); + assert(_videoPtr); destOffset = 0; srcP = src; for (;;) { @@ -2115,7 +2130,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { srcP += 5; } Video_Cont_Vbe: - *((byte *)VideoPtr->pixels + destOffset) = byteVal; + *((byte *)_videoPtr->pixels + destOffset) = byteVal; ++srcP; ++destOffset; } @@ -2178,7 +2193,7 @@ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height } void GraphicsManager::MODE_VESA() { - SET_MODE(640, 480); + setGraphicalMode(640, 480); } } // End of namespace Hopkins -- cgit v1.2.3 From 076546d41d1454c87317b5e53c2b322865331d92 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 19 Dec 2012 08:00:22 +0100 Subject: HOPKINS: More renaming --- engines/hopkins/graphics.cpp | 123 +++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 62 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 44c775b660..a6992c0b23 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -39,7 +39,7 @@ GraphicsManager::GraphicsManager() { XSCREEN = YSCREEN = 0; WinScan = 0; PAL_PIXELS = NULL; - nbrligne = 0; + _lineNbr = 0; Linear = false; _videoPtr = NULL; ofscroll = 0; @@ -48,7 +48,7 @@ GraphicsManager::GraphicsManager() { DOUBLE_ECRAN = false; OLD_SCROLL = 0; - nbrligne2 = 0; + _lineNbr2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; FADESPD = 15; @@ -115,7 +115,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { WinScan = width * 2; // Refactor me PAL_PIXELS = SD_PIXELS; - nbrligne = width; + _lineNbr = width; Common::fill(&cmap[0], &cmap[256 * 3], 0); SDL_MODEYES = true; @@ -311,7 +311,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES"); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); - f.seek(_vm->_globals.CAT_POSI); + f.seek(_vm->_globals._catalogPos); } else { // Load stand alone PCX file @@ -424,7 +424,7 @@ void GraphicsManager::Cls_Pal() { } void GraphicsManager::SCANLINE(int pitch) { - nbrligne = nbrligne2 = pitch; + _lineNbr = _lineNbr2 = pitch; } void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { @@ -437,7 +437,7 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i unsigned int widthRemaining; assert(_videoPtr); - srcP = xs + nbrligne2 * ys + surface; + srcP = xs + _lineNbr2 * ys + surface; destP = destX + WinScan * destY + (byte *)_videoPtr->pixels; yNext = height; do { @@ -448,7 +448,7 @@ void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, i widthRemaining = width - 4 * (width >> 2); memcpy(dest2P, src2P, widthRemaining); destP = dest2P + widthRemaining + WinScan - width; - srcP = src2P + widthRemaining + nbrligne2 - width; + srcP = src2P + widthRemaining + _lineNbr2 - width; yNext = yCtr - 1; } while (yCtr != 1); } @@ -460,7 +460,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, lockScreen(); assert(_videoPtr); - const byte *srcP = xs + nbrligne2 * ys + surface; + const byte *srcP = xs + _lineNbr2 * ys + surface; uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destX * 2 + WinScan * destY); for (int yp = 0; yp < height; ++yp) { @@ -472,7 +472,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, *lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2]; // Move to the start of the next line - srcP += nbrligne2; + srcP += _lineNbr2; destP += WinScan / 2; } @@ -492,7 +492,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width const byte *destCopyP; assert(_videoPtr); - srcP = xs + nbrligne2 * ys + surface; + srcP = xs + _lineNbr2 * ys + surface; destP = destX + destX + WinScan * destY + (byte *)_videoPtr->pixels; yNext = height; Agr_x = 0; @@ -536,7 +536,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } Agr_Flag_y = 0; - srcP = nbrligne2 + srcCopyP; + srcP = _lineNbr2 + srcCopyP; yNext = yCtr - 1; } while (yCtr != 1); } @@ -1049,7 +1049,7 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within // the screen, and so thus can read areas outside of the allocated surface buffer - srcP = xs + nbrligne2 * ys + srcSurface; + srcP = xs + _lineNbr2 * ys + srcSurface; destP = destSurface; rowCount = height; do { @@ -1069,7 +1069,7 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int srcP += 4 * (width >> 2); destP += 4 * (width >> 2); } - srcP = nbrligne2 + srcP - width; + srcP = _lineNbr2 + srcP - width; rowCount = rowCount2 - 1; } while (rowCount2 != 1); } @@ -1141,12 +1141,12 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, spriteP += srcOffset; // Set up surface destination - byte *destP = surface + (yp - 300) * nbrligne2 + (xp - 300); + byte *destP = surface + (yp - 300) * _lineNbr2 + (xp - 300); // Handling for clipped versus non-clipped if (clip_flag) { // Clipped version - for (int yc = 0; yc < height; ++yc, destP += nbrligne2) { + for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) { byte *tempDestP = destP; byte byteVal; int xc = 0; @@ -1175,7 +1175,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, } } else { // Non-clipped - for (int yc = 0; yc < height; ++yc, destP += nbrligne2) { + for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) { byte *tempDestP = destP; byte byteVal; @@ -1428,7 +1428,7 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in int i; int yCtr; - destP = xp + nbrligne2 * yp + destSurface; + destP = xp + _lineNbr2 * yp + destSurface; yNext = height; srcP = src; do { @@ -1448,7 +1448,7 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in srcP += 4 * (width >> 2); destP += 4 * (width >> 2); } - destP = nbrligne2 + destP - width; + destP = _lineNbr2 + destP - width; yNext = yCtr - 1; } while (yCtr != 1); } @@ -1510,7 +1510,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp clip_x1 = max_x + 300 - xp300; if ((uint16)yp300 < (uint16)(max_y + 300)) { clip_y1 = max_y + 300 - yp300; - dest1P = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface; + dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; if (zoom2) { Compteur_y = 0; Agr_x = 0; @@ -1533,7 +1533,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ; v20 = v52; spritePixelsP += _width * v30; - v29 += nbrligne2 * (uint16)clip_y; + v29 += _lineNbr2 * (uint16)clip_y; v22 = v61 - (uint16)clip_y; } if (v22 > (uint16)clip_y1) @@ -1584,7 +1584,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp } R_Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v46; - v29 = nbrligne2 + v53; + v29 = _lineNbr2 + v53; ++Compteur_y; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; @@ -1612,7 +1612,7 @@ R_Aff_Zoom_Larg_Cont1: ; v20 = v49; spritePixelsP += _width * v23; - dest1P += nbrligne2 * (uint16)clip_y; + dest1P += _lineNbr2 * (uint16)clip_y; v22 = v58 - (uint16)clip_y; } if (v22 > (uint16)clip_y1) @@ -1666,7 +1666,7 @@ R_Aff_Zoom_Larg_Cont1: } while (v28); Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v45; - dest1P = nbrligne2 + v51; + dest1P = _lineNbr2 + v51; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 0x64u) @@ -1713,7 +1713,7 @@ Aff_Zoom_Larg_Cont1: } } spriteHeight2 = v65; - v40 = nbrligne2 + v55; + v40 = _lineNbr2 + v55; } else { Red_y = Red_y - 100; spritePixelsP += _width; @@ -1742,7 +1742,7 @@ Aff_Zoom_Larg_Cont1: } } spriteHeight2 = v64; - dest1P = nbrligne2 + v54; + dest1P = _lineNbr2 + v54; } else { Red_y = Red_y - 100; spritePixelsP += _width; @@ -1761,7 +1761,7 @@ Aff_Zoom_Larg_Cont1: if ((uint16)clip_y >= (unsigned int)spriteHeight1) return; spritePixelsP += spriteWidth * (uint16)clip_y; - dest2P += nbrligne2 * (uint16)clip_y; + dest2P += _lineNbr2 * (uint16)clip_y; spriteHeight1 -= (uint16)clip_y; } int xLeft = (uint16)clip_y1; @@ -1791,7 +1791,7 @@ Aff_Zoom_Larg_Cont1: --dest2P; } spritePixelsP = spec_largeur + spritePixelsCopy2P; - dest2P = nbrligne2 + destCopy2P; + dest2P = _lineNbr2 + destCopy2P; spriteHeight1 = yCtr2 - 1; } while (yCtr2 != 1); } else { @@ -1800,7 +1800,7 @@ Aff_Zoom_Larg_Cont1: if ((uint16)clip_y >= (unsigned int)spriteHeight1) return; spritePixelsP += spriteWidth * (uint16)clip_y; - dest1P += nbrligne2 * (uint16)clip_y; + dest1P += _lineNbr2 * (uint16)clip_y; spriteHeight1 -= (uint16)clip_y; } if (spriteHeight1 > clip_y1) @@ -1826,7 +1826,7 @@ Aff_Zoom_Larg_Cont1: ++spritePixelsP; } spritePixelsP = spec_largeur + spritePixelsCopyP; - dest1P = nbrligne2 + dest1CopyP; + dest1P = _lineNbr2 + dest1CopyP; spriteHeight1 = yCtr1 - 1; } while (yCtr1 != 1); } @@ -1898,8 +1898,8 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned const byte *src2P; unsigned int pitch; - srcP = x1 + nbrligne2 * y1 + srcSurface; - destP = destX + nbrligne2 * destY + destSurface; + srcP = x1 + _lineNbr2 * y1 + srcSurface; + destP = destX + _lineNbr2 * destY + destSurface; yp = height; do { yCurrent = yp; @@ -1908,8 +1908,8 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned dest2P = (destP + 4 * (width >> 2)); pitch = width - 4 * (width >> 2); memcpy(dest2P, src2P, pitch); - destP = (dest2P + pitch + nbrligne2 - width); - srcP = (src2P + pitch + nbrligne2 - width); + destP = (dest2P + pitch + _lineNbr2 - width); + srcP = (src2P + pitch + _lineNbr2 - width); yp = yCurrent - 1; } while (yCurrent != 1); } @@ -1939,7 +1939,7 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x spriteSizeP += 2; spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); spritePixelsP = spriteSizeP + 10; - destP = surface + xp + nbrligne2 * yp; + destP = surface + xp + _lineNbr2 * yp; _width = spriteWidth; do { @@ -1956,7 +1956,7 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x ++destP; ++spritePixelsP; } - destP = nbrligne2 + destLineP; + destP = _lineNbr2 + destLineP; spriteHeight = yCtr - 1; } while (yCtr != 1); } @@ -1985,14 +1985,11 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (!_vm->_globals.NOSPRECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_globals.CAT_FLAG = false; _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); } else { - _vm->_globals.CAT_FLAG = true; _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); } _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); - _vm->_globals.CAT_FLAG = false; } } if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { @@ -2041,9 +2038,9 @@ void GraphicsManager::NB_SCREEN() { if (!_vm->_globals.NECESSAIRE) INIT_TABLE(50, 65, Palette); - if (nbrligne == SCREEN_WIDTH) + if (_lineNbr == SCREEN_WIDTH) Trans_bloc2(_vesaBuffer, TABLE_COUL, 307200); - if (nbrligne == 1280) + else if (_lineNbr == (SCREEN_WIDTH * 2)) Trans_bloc2(_vesaBuffer, TABLE_COUL, 614400); lockScreen(); m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); @@ -2113,23 +2110,25 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { for (;;) { byteVal = *srcP; if (*srcP < kByteStop) - goto Video_Cont_Vbe; - if (byteVal == kByteStop) - return; - if (byteVal == k8bVal) { - destOffset += *(srcP + 1); - byteVal = *(srcP + 2); - srcP += 2; - } else if (byteVal == k16bVal) { - destOffset += READ_LE_UINT16(srcP + 1); - byteVal = *(srcP + 3); - srcP += 3; - } else { - destOffset += READ_LE_UINT32(srcP + 1); - byteVal = *(srcP + 5); - srcP += 5; + break; + else { + if (byteVal == kByteStop) + return; + if (byteVal == k8bVal) { + destOffset += *(srcP + 1); + byteVal = *(srcP + 2); + srcP += 2; + } else if (byteVal == k16bVal) { + destOffset += READ_LE_UINT16(srcP + 1); + byteVal = *(srcP + 3); + srcP += 3; + } else { + destOffset += READ_LE_UINT32(srcP + 1); + byteVal = *(srcP + 5); + srcP += 5; + } } -Video_Cont_Vbe: + *((byte *)_videoPtr->pixels + destOffset) = byteVal; ++srcP; ++destOffset; @@ -2141,7 +2140,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int const byte *srcP; byte *destP; - srcP = xp + nbrligne2 * yp + srcSurface; + srcP = xp + _lineNbr2 * yp + srcSurface; destP = destSurface; Red = zoom; _width = width; @@ -2151,7 +2150,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Reduc_Ecran_L = zoomOut(width, Red); Reduc_Ecran_H = zoomOut(height, Red); - for (int yCtr = 0; yCtr < height; ++yCtr, srcP += nbrligne2) { + for (int yCtr = 0; yCtr < height; ++yCtr, srcP += _lineNbr2) { Red_y += Red; if (Red_y < 100) { Red_x = 0; @@ -2177,22 +2176,22 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int * Draw horizontal line */ void GraphicsManager::drawHorizontalLine(byte *surface, int xp, int yp, unsigned int width, byte col) { - memset(surface + xp + nbrligne2 * yp, col, width); + memset(surface + xp + _lineNbr2 * yp, col, width); } /** * Draw vertical line */ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height, byte col) { - byte *destP = surface + xp + nbrligne2 * yp; + byte *destP = surface + xp + _lineNbr2 * yp; for (int yCtr = height; yCtr; yCtr--) { *destP = col; - destP += nbrligne2; + destP += _lineNbr2; } } -void GraphicsManager::MODE_VESA() { +void GraphicsManager::setModeVesa() { setGraphicalMode(640, 480); } -- cgit v1.2.3 From 2f77e933bab83b2415b623d2b594cee9daf4a2dc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 21 Dec 2012 01:26:11 +0100 Subject: HOPKINS: Remove some hex values --- engines/hopkins/graphics.cpp | 46 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a6992c0b23..793d2fe96c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -172,7 +172,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { unlockScreen(); _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, Palette); - memcpy(_vesaBuffer, _vesaScreen, 0xFA00u); + memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); max_x = 320; @@ -358,15 +358,15 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * filesize = f.size(); - f.read(surface, 0x80u); + f.read(surface, 128); v4 = filesize - 896; - ptr = _vm->_globals.allocMemory(0xFE00u); - if (v4 >= 0xFA00) { - v15 = v4 / 0xFA00 + 1; - v17 = 64000 * (v4 / 0xFA00) - v4; - if (((uint32)v17 & 0x80000000u) != 0) + ptr = _vm->_globals.allocMemory(65024); + if (v4 >= 64000) { + v15 = v4 / 64000 + 1; + v17 = 64000 * (v4 / 64000) - v4; + if (v17 < 0) v17 = -v17; - f.read(ptr, 0xFA00u); + f.read(ptr, 64000); v5 = 64000; } else { v15 = 1; @@ -388,7 +388,7 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * // i = v8; } v9 = *(ptr + v7++); - if (v9 > 0xC0u) { + if (v9 > 192) { v10 = v9 - 192; if (v7 == v5) { v7 = 0; @@ -835,7 +835,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) srcP = srcData; for (;;) { srcByte = *srcP; - if (*srcP < 0xDEu) + if (*srcP < 222) goto Video_Cont3_wVbe; if (srcByte == kByteStop) return; @@ -857,7 +857,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) srcP += 5; } Video_Cont3_wVbe: - if (srcByte > 0xD2u) { + if (srcByte > 210) { if (srcByte == (byte)-45) { destLen1 = *(srcP + 1); rleValue = *(srcP + 2); @@ -1571,7 +1571,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; if (!Agr_Flag_x) Agr_x = zoom2 + Agr_x; - if ((uint16)Agr_x < 0x64u) + if ((uint16)Agr_x < 100) break; Agr_x = Agr_x - 100; --spritePixelsP; @@ -1588,7 +1588,7 @@ R_Aff_Zoom_Larg_Cont1: ++Compteur_y; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; - if ((uint16)Agr_y < 0x64u) + if ((uint16)Agr_y < 100) break; Agr_y = Agr_y - 100; spritePixelsP = v46; @@ -1652,7 +1652,7 @@ R_Aff_Zoom_Larg_Cont1: ++spritePixelsP; if (!Agr_Flag_x) Agr_x = zoom2 + Agr_x; - if ((uint16)Agr_x < 0x64u) + if ((uint16)Agr_x < 100) break; Agr_x = Agr_x - 100; --spritePixelsP; @@ -1669,7 +1669,7 @@ Aff_Zoom_Larg_Cont1: dest1P = _lineNbr2 + v51; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; - if ((uint16)Agr_y < 0x64u) + if ((uint16)Agr_y < 100) break; Agr_y = Agr_y - 100; spritePixelsP = v45; @@ -1696,12 +1696,12 @@ Aff_Zoom_Larg_Cont1: int v65 = spriteHeight2; byte *v55 = v40; Red_y = Red + Red_y; - if ((uint16)Red_y < 0x64u) { + if ((uint16)Red_y < 100) { Red_x = 0; int v42 = v37; for (int v41 = _width; v41; v41--) { Red_x = Red + Red_x; - if ((uint16)Red_x < 0x64u) { + if ((uint16)Red_x < 100) { if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) *v40 = *spritePixelsP; --v40; @@ -1725,12 +1725,12 @@ Aff_Zoom_Larg_Cont1: int v64 = spriteHeight2; byte *v54 = dest1P; Red_y = Red + Red_y; - if ((uint16)Red_y < 0x64u) { + if ((uint16)Red_y < 100) { Red_x = 0; int v39 = 0; for (int v38 = _width; v38; v38--) { Red_x = Red + Red_x; - if ((uint16)Red_x < 0x64u) { + if ((uint16)Red_x < 100) { if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; @@ -2038,17 +2038,19 @@ void GraphicsManager::NB_SCREEN() { if (!_vm->_globals.NECESSAIRE) INIT_TABLE(50, 65, Palette); + if (_lineNbr == SCREEN_WIDTH) - Trans_bloc2(_vesaBuffer, TABLE_COUL, 307200); + Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT); else if (_lineNbr == (SCREEN_WIDTH * 2)) - Trans_bloc2(_vesaBuffer, TABLE_COUL, 614400); + Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT * 2); + lockScreen(); m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); destP = _vesaScreen; srcP = _vesaBuffer; - memcpy(_vesaScreen, _vesaBuffer, 0x95FFCu); + memcpy(_vesaScreen, _vesaBuffer, 614396); srcP = srcP + 614396; destP = destP + 614396; *destP = *srcP; -- cgit v1.2.3 From e44df7732925e42d52e5567185a16839e9ba2cfb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Dec 2012 01:28:31 +0100 Subject: HOPKINS: Remove useless IF statements --- engines/hopkins/graphics.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 793d2fe96c..8ed4c03bc6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -662,19 +662,17 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); - if (palMax > 0) { - for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { - for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { - int palCtr5 = palCtr4; - int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; - tempPalette[palCtr5] = palValue; - palData[palCtr5] = (palValue >> 8) & 0xff; - } - - setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { + for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { + int palCtr5 = palCtr4; + int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; + tempPalette[palCtr5] = palValue; + palData[palCtr5] = (palValue >> 8) & 0xff; } + + setpal_vga256(palData); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); } for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) -- cgit v1.2.3 From 1f987a91ae9e7044fd1f6764d1232109028a8bd8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Dec 2012 19:08:23 +0100 Subject: HOPKINS: Some more renaming. Remove 2 useless palettes --- engines/hopkins/graphics.cpp | 83 ++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 56 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8ed4c03bc6..18f0ec8bef 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -72,8 +72,7 @@ GraphicsManager::GraphicsManager() { Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_EXT_BLOCK_SIZE], 0); - Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); - Common::fill(&Palette[0], &Palette[PALETTE_EXT_BLOCK_SIZE], 0); + Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0); } @@ -117,7 +116,6 @@ void GraphicsManager::setGraphicalMode(int width, int height) { PAL_PIXELS = SD_PIXELS; _lineNbr = width; - Common::fill(&cmap[0], &cmap[256 * 3], 0); SDL_MODEYES = true; } else { error("Called SET_MODE multiple times"); @@ -159,7 +157,7 @@ void GraphicsManager::clearScreen() { void GraphicsManager::loadImage(const Common::String &file) { Common::String filename = Common::String::format("%s.PCX", file.c_str()); loadScreen(filename); - INIT_TABLE(165, 170, Palette); + INIT_TABLE(165, 170, _palette); } /** @@ -171,7 +169,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { clearScreen(); unlockScreen(); _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); - A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, Palette); + A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); max_x = 320; @@ -201,11 +199,11 @@ void GraphicsManager::loadScreen(const Common::String &file) { } scrollScreen(0); - A_PCX640_480((byte *)_vesaScreen, file, Palette, flag); + A_PCX640_480((byte *)_vesaScreen, file, _palette, flag); SCROLL = 0; OLD_SCROLL = 0; - Cls_Pal(); + clearPalette(); if (!DOUBLE_ECRAN) { SCANLINE(SCREEN_WIDTH); @@ -418,8 +416,7 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * } // Clear Palette -void GraphicsManager::Cls_Pal() { - Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0); +void GraphicsManager::clearPalette() { SD_PIXELS[0] = 0; } @@ -694,22 +691,22 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac void GraphicsManager::FADE_INS() { FADESPD = 1; - fade_in(Palette, 1, (const byte *)_vesaBuffer); + fade_in(_palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTS() { FADESPD = 1; - fade_out(Palette, 1, (const byte *)_vesaBuffer); + fade_out(_palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_INW() { FADESPD = 15; - fade_in(Palette, 20, (const byte *)_vesaBuffer); + fade_in(_palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTW() { FADESPD = 15; - fade_out(Palette, 20, (const byte *)_vesaBuffer); + fade_out(_palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::setpal_vga256(const byte *palette) { @@ -722,53 +719,27 @@ void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surfa DD_VBL(); } -void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) { - Palette[palIndex * 3] = 255 * r / 100; - Palette[palIndex * 3 + 1] = 255 * g / 100; - Palette[palIndex * 3 + 2] = 255 * b / 100; - - setpal_vga256(Palette); -} - -void GraphicsManager::SETCOLOR2(int palIndex, int r, int g, int b) { - return SETCOLOR(palIndex, r, g, b); -} - void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { - Palette[palIndex * 3] = 255 * r / 100; - Palette[palIndex * 3 + 1] = 255 * g / 100; - Palette[palIndex * 3 + 2] = 255 * b / 100; + int palOffset = 3 * palIndex; + _palette[palOffset] = 255 * r / 100; + _palette[palOffset + 1] = 255 * g / 100; + _palette[palOffset + 2] = 255 * b / 100; } void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { - int rv, gv, bv; - int palOffset; - int v8; - - rv = 255 * r / 100; - gv = 255 * g / 100; - bv = 255 * b / 100; - palOffset = 3 * palIndex; - Palette[palOffset] = 255 * r / 100; - Palette[palOffset + 1] = gv; - Palette[palOffset + 2] = bv; - - v8 = 4 * palIndex; - cmap[v8] = rv; - cmap[v8 + 1] = gv; - cmap[v8 + 2] = bv; + int rv = 255 * r / 100; + int gv = 255 * g / 100; + int bv = 255 * b / 100; + + int palOffset = 3 * palIndex; + _palette[palOffset] = rv; + _palette[palOffset + 1] = gv; + _palette[palOffset + 2] = bv; WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); } void GraphicsManager::CHANGE_PALETTE(const byte *palette) { - // Copy the palette into the PALPCX block -// TODO: Likely either one or both of the destination arrays can be removed, -// since PALPCX is only used in SAVE_IMAGE, and cmap in the original was a RGBA -// array specifically intended just for passing to the SDL palette setter - Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &PALPCX[0]); - Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &cmap[0]); - const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); @@ -790,16 +761,16 @@ void GraphicsManager::DD_VBL() { void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { assert(surface); - fade_out(Palette, FADESPD, surface); + fade_out(_palette, FADESPD, surface); } void GraphicsManager::FADE_INW_LINUX(const byte *surface) { assert(surface); - fade_in(Palette, FADESPD, surface); + fade_in(_palette, FADESPD, surface); } void GraphicsManager::FADE_IN_CASSE() { - setpal_vga256(Palette); + setpal_vga256(_palette); lockScreen(); CopyAsm16(_vesaBuffer); unlockScreen(); @@ -2035,7 +2006,7 @@ void GraphicsManager::NB_SCREEN() { const byte *srcP; if (!_vm->_globals.NECESSAIRE) - INIT_TABLE(50, 65, Palette); + INIT_TABLE(50, 65, _palette); if (_lineNbr == SCREEN_WIDTH) Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT); @@ -2057,7 +2028,7 @@ void GraphicsManager::NB_SCREEN() { } void GraphicsManager::SHOW_PALETTE() { - setpal_vga256(Palette); + setpal_vga256(_palette); } void GraphicsManager::videkey() { -- cgit v1.2.3 From 3f8085f6542a1ef5a8fd0b1b3588b31114ac28c5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Dec 2012 20:36:08 +0100 Subject: HOPKINS: Some more renaming, remove useless variable --- engines/hopkins/graphics.cpp | 52 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 18f0ec8bef..638a1a2719 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -40,7 +40,6 @@ GraphicsManager::GraphicsManager() { WinScan = 0; PAL_PIXELS = NULL; _lineNbr = 0; - Linear = false; _videoPtr = NULL; ofscroll = 0; SCROLL = 0; @@ -71,9 +70,9 @@ GraphicsManager::GraphicsManager() { spec_largeur = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); - Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_EXT_BLOCK_SIZE], 0); + Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); - Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0); + Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); } GraphicsManager::~GraphicsManager() { @@ -110,7 +109,6 @@ void GraphicsManager::setGraphicalMode(int width, int height) { XSCREEN = width; YSCREEN = height; - Linear = true; WinScan = width * 2; // Refactor me PAL_PIXELS = SD_PIXELS; @@ -157,7 +155,7 @@ void GraphicsManager::clearScreen() { void GraphicsManager::loadImage(const Common::String &file) { Common::String filename = Common::String::format("%s.PCX", file.c_str()); loadScreen(filename); - INIT_TABLE(165, 170, _palette); + initColorTable(165, 170, _palette); } /** @@ -229,21 +227,21 @@ void GraphicsManager::loadScreen(const Common::String &file) { memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } -void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) { +void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) { for (int idx = 0; idx < 256; ++idx) - TABLE_COUL[idx] = idx; + _colorTable[idx] = idx; - Trans_bloc(TABLE_COUL, palette, 256, minIndex, maxIndex); + Trans_bloc(_colorTable, palette, 256, minIndex, maxIndex); for (int idx = 0; idx < 256; ++idx) { - byte v = TABLE_COUL[idx]; + byte v = _colorTable[idx]; if (v > 27) - TABLE_COUL[idx] = 0; + _colorTable[idx] = 0; if (!v) - TABLE_COUL[idx] = 0; + _colorTable[idx] = 0; } - TABLE_COUL[0] = 1; + _colorTable[0] = 1; } /** @@ -588,7 +586,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, } while (yCtr != 1); } -void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) { +void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) { uint16 palData1[PALETTE_BLOCK_SIZE * 2]; byte palData2[PALETTE_BLOCK_SIZE]; @@ -639,7 +637,7 @@ void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface DD_VBL(); } -void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) { +void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { int palByte; uint16 palMax; byte palData[PALETTE_BLOCK_SIZE]; @@ -691,30 +689,30 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac void GraphicsManager::FADE_INS() { FADESPD = 1; - fade_in(_palette, 1, (const byte *)_vesaBuffer); + fadeIn(_palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTS() { - FADESPD = 1; - fade_out(_palette, 1, (const byte *)_vesaBuffer); + FADESPD = 1; + fadeOut(_palette, 1, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_INW() { FADESPD = 15; - fade_in(_palette, 20, (const byte *)_vesaBuffer); + fadeIn(_palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::FADE_OUTW() { FADESPD = 15; - fade_out(_palette, 20, (const byte *)_vesaBuffer); + fadeOut(_palette, 20, (const byte *)_vesaBuffer); } void GraphicsManager::setpal_vga256(const byte *palette) { - CHANGE_PALETTE(palette); + changePalette(palette); } void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { - CHANGE_PALETTE(palette); + changePalette(palette); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); } @@ -739,7 +737,7 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); } -void GraphicsManager::CHANGE_PALETTE(const byte *palette) { +void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); @@ -761,12 +759,12 @@ void GraphicsManager::DD_VBL() { void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { assert(surface); - fade_out(_palette, FADESPD, surface); + fadeOut(_palette, FADESPD, surface); } void GraphicsManager::FADE_INW_LINUX(const byte *surface) { assert(surface); - fade_in(_palette, FADESPD, surface); + fadeIn(_palette, FADESPD, surface); } void GraphicsManager::FADE_IN_CASSE() { @@ -2006,12 +2004,12 @@ void GraphicsManager::NB_SCREEN() { const byte *srcP; if (!_vm->_globals.NECESSAIRE) - INIT_TABLE(50, 65, _palette); + initColorTable(50, 65, _palette); if (_lineNbr == SCREEN_WIDTH) - Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT); + Trans_bloc2(_vesaBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT); else if (_lineNbr == (SCREEN_WIDTH * 2)) - Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT * 2); + Trans_bloc2(_vesaBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); lockScreen(); m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); -- cgit v1.2.3 From 8cce2721177422a65e73c9f178746403c801f242 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Dec 2012 01:43:37 +0100 Subject: HOPKINS: Some more renaming --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 638a1a2719..d4ad9cc30b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1882,7 +1882,7 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } // Display Font -void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, +void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { const byte *spriteDataP; int i; -- cgit v1.2.3 From 4ab60c43c0834d568b7c21ed9b45a2beab9e5815 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Dec 2012 13:32:39 +0100 Subject: HOPKINS: Refactor handleGoto and handleIf, some renaming --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d4ad9cc30b..cb4abd9d9d 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1971,9 +1971,9 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { return; if (dataVal1 == 2) - dataOffset = _vm->_scriptManager.Control_Goto((ptr + 20 * dataOffset)); + dataOffset = _vm->_scriptManager.handleGoto((ptr + 20 * dataOffset)); if (dataVal1 == 3) - dataOffset = _vm->_scriptManager.Control_If(ptr, dataOffset); + dataOffset = _vm->_scriptManager.handleIf(ptr, dataOffset); if (dataOffset == -1) error("Error, defective IFF"); if (dataVal1 == 1 || dataVal1 == 4) -- cgit v1.2.3 From 1c5a6f8c74a794e9a913c9b2c0bebfd59ac0fd9e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Dec 2012 18:24:08 +0100 Subject: HOPKINS: Start refactoring handleOpcode --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index cb4abd9d9d..832f0c97d4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1966,7 +1966,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { int dataOffset = 1; do { - int dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset); + int dataVal1 = _vm->_scriptManager.handleOpcode(ptr + 20 * dataOffset); if (_vm->shouldQuit()) return; -- cgit v1.2.3 From 657dfdaa6d99c7173094f4d85a75ca67ea0c46a4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Dec 2012 02:25:13 +0100 Subject: HOPKINS: Remove useless variable in MenuManager, some renaming --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 832f0c97d4..e83622ab57 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1805,7 +1805,7 @@ Aff_Zoom_Larg_Cont1: } // Display Speed -void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) { +void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex) { int width, height; width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); -- cgit v1.2.3 From 145b593e22c04c9b29d306c39428346fb6205808 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Dec 2012 08:27:32 +0100 Subject: HOPKINS: Some refactoring in OCEAN() --- engines/hopkins/graphics.cpp | 80 ++++---------------------------------------- 1 file changed, 6 insertions(+), 74 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index e83622ab57..fdbffe8456 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -176,7 +176,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { CopyAsm16(_vesaBuffer); unlockScreen(); - FADE_IN_CASSE(); + fadeInBreakout(); } /** @@ -734,17 +734,17 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { _palette[palOffset + 1] = gv; _palette[palOffset + 2] = bv; - WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv)); + WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], mapRGB(rv, gv, bv)); } void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2)); + *(uint16 *)&SD_PIXELS[2 * idx] = mapRGB(*srcP, *(srcP + 1), *(srcP + 2)); } } -uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) { +uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { Graphics::PixelFormat format = g_system->getScreenFormat(); return (r >> format.rLoss) << format.rShift @@ -767,7 +767,7 @@ void GraphicsManager::FADE_INW_LINUX(const byte *surface) { fadeIn(_palette, FADESPD, surface); } -void GraphicsManager::FADE_IN_CASSE() { +void GraphicsManager::fadeInBreakout() { setpal_vga256(_palette); lockScreen(); CopyAsm16(_vesaBuffer); @@ -775,7 +775,7 @@ void GraphicsManager::FADE_IN_CASSE() { DD_VBL(); } -void GraphicsManager::FADE_OUT_CASSE() { +void GraphicsManager::fateOutBreakout() { byte palette[PALETTE_EXT_BLOCK_SIZE]; memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); @@ -845,67 +845,6 @@ Video_Cont3_wVbe: ++srcP; ++destOffset; } - }} - -void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { - int rleValue; - int destOffset; - const byte *srcP; - uint8 srcByte; - int destLen1; - byte *destSlice1P; - int destLen2; - byte *destSlice2P; - - assert(_videoPtr); - rleValue = 0; - destOffset = 0; - srcP = srcData; - for (;;) { - srcByte = *srcP; - if (*srcP < 222) - goto Video_Cont3_Vbe; - - if (srcByte == kByteStop) - return; - if (srcByte < kSetOffset) { - destOffset += *srcP + 35; - srcByte = *(srcP++ + 1); - } else if (srcByte == k8bVal) { - destOffset += *(srcP + 1); - srcByte = *(srcP + 2); - srcP += 2; - } else if (srcByte == k16bVal) { - destOffset += READ_LE_UINT16(srcP + 1); - srcByte = *(srcP + 3); - srcP += 3; - } else { - destOffset += READ_LE_UINT32(srcP + 1); - srcByte = *(srcP + 5); - srcP += 5; - } -Video_Cont3_Vbe: - if (srcByte > 210) { - if (srcByte == 211) { - destLen1 = *(srcP + 1); - rleValue = *(srcP + 2); - destSlice1P = destOffset + (byte *)_videoPtr->pixels; - destOffset += destLen1; - memset(destSlice1P, rleValue, destLen1); - srcP += 3; - } else { - destLen2 = (byte)(*srcP + 45); - rleValue = *(srcP + 1); - destSlice2P = (byte *)(destOffset + (byte *)_videoPtr->pixels); - destOffset += destLen2; - memset(destSlice2P, rleValue, destLen2); - srcP += 2; - } - } else { - *(destOffset + (byte *)_videoPtr->pixels) = srcByte; - ++srcP; - ++destOffset; - } } } @@ -2029,10 +1968,6 @@ void GraphicsManager::SHOW_PALETTE() { setpal_vga256(_palette); } -void GraphicsManager::videkey() { - // Empty in original -} - void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { int result; int destOffset; @@ -2116,9 +2051,6 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int Red_x = 0; Red_y = 0; if (zoom < 100) { - Reduc_Ecran_L = zoomOut(width, Red); - Reduc_Ecran_H = zoomOut(height, Red); - for (int yCtr = 0; yCtr < height; ++yCtr, srcP += _lineNbr2) { Red_y += Red; if (Red_y < 100) { -- cgit v1.2.3 From c9343637902ed94f0a511ff9fa0d1bffe346d5e3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 28 Dec 2012 08:26:27 +0100 Subject: HOPKINS: Some more renaming and refactoring --- engines/hopkins/graphics.cpp | 651 +++++++++++++++++++++---------------------- 1 file changed, 320 insertions(+), 331 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index fdbffe8456..0facdf85d4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -167,7 +167,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { clearScreen(); unlockScreen(); _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); - A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, _palette); + A_PCX320(_vesaScreen, _vm->_globals._curFilename, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); max_x = 320; @@ -188,7 +188,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); - if (!f.open(_vm->_globals.NFICHIER)) + if (!f.open(_vm->_globals._curFilename)) error("loadScreen - %s", file.c_str()); f.seek(0, SEEK_END); @@ -305,14 +305,14 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES"); - if (!f.open(_vm->_globals.NFICHIER)) + if (!f.open(_vm->_globals._curFilename)) error("(nom)Erreur en cours de lecture."); f.seek(_vm->_globals._catalogPos); } else { // Load stand alone PCX file _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); - if (!f.open(_vm->_globals.NFICHIER)) + if (!f.open(_vm->_globals._curFilename)) error("(nom)Erreur en cours de lecture."); } @@ -1406,349 +1406,338 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp clip_y = 0; clip_x1 = 0; clip_y1 = 0; - if ((uint16)xp300 > min_x) { - if ((uint16)xp300 < (uint16)(min_x + 300)) - clip_x = min_x + 300 - xp300; - if ((uint16)yp300 > min_y) { - if ((uint16)yp300 < (uint16)(min_y + 300)) - clip_y = min_y + 300 - yp300; - if ((uint16)xp300 < (uint16)(max_x + 300)) { - clip_x1 = max_x + 300 - xp300; - if ((uint16)yp300 < (uint16)(max_y + 300)) { - clip_y1 = max_y + 300 - yp300; - dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; - if (zoom2) { - Compteur_y = 0; - Agr_x = 0; - Agr_y = 0; - Agr_Flag_y = 0; + if ((xp300 <= min_x) || (yp300 <= min_y) || (xp300 >= max_x + 300) || (yp300 >= max_y + 300)) + return; + + if ((uint16)xp300 < (uint16)(min_x + 300)) + clip_x = min_x + 300 - xp300; + + if ((uint16)yp300 < (uint16)(min_y + 300)) + clip_y = min_y + 300 - yp300; + + clip_x1 = max_x + 300 - xp300; + clip_y1 = max_y + 300 - yp300; + dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; + if (zoom2) { + Compteur_y = 0; + Agr_x = 0; + Agr_y = 0; + Agr_Flag_y = 0; + Agr_Flag_x = 0; + _width = spriteWidth; + int v20 = zoomIn(spriteWidth, zoom2); + int v22 = zoomIn(spriteHeight1, zoom2); + if (modeFlag) { + v29 = v20 + dest1P; + if (clip_y) { + if ((uint16)clip_y >= v22) + return; + int v30 = 0; + while (zoomIn(v30 + 1, zoom2) < (uint16)clip_y) + ; + spritePixelsP += _width * v30; + v29 += _lineNbr2 * (uint16)clip_y; + v22 = v22 - (uint16)clip_y; + } + if (v22 > (uint16)clip_y1) + v22 = (uint16)clip_y1; + if (clip_x) { + if ((uint16)clip_x >= v20) + return; + v20 -= (uint16)clip_x; + } + if (v20 > (uint16)clip_x1) { + int v32 = v20 - (uint16)clip_x1; + v29 -= v32; + int v62 = v22; + int v33 = 0; + while (zoomIn(v33 + 1, zoom2) < v32) + ; + int v34 = v33; + v22 = v62; + spritePixelsP += v34; + v20 = (uint16)clip_x1; + } + int v63; + do { + for (;;) { + v63 = v22; + byte *v53 = v29; + v46 = spritePixelsP; + Agr_Flag_x = 0; + Agr_x = 0; + for (int v35 = v20; v35; v35--) { + for (;;) { + if (*spritePixelsP) + *v29 = *spritePixelsP; + --v29; + ++spritePixelsP; + if (!Agr_Flag_x) + Agr_x = zoom2 + Agr_x; + if ((uint16)Agr_x < 100) + break; + Agr_x = Agr_x - 100; + --spritePixelsP; + Agr_Flag_x = 1; + --v35; + if (!v35) + goto R_Aff_Zoom_Larg_Cont1; + } Agr_Flag_x = 0; - _width = spriteWidth; - int v20 = zoomIn(spriteWidth, zoom2); - int v22 = zoomIn(spriteHeight1, zoom2); - if (modeFlag) { - v29 = v20 + dest1P; - if (clip_y) { - if ((uint16)clip_y >= v22) - return; - int v61 = v22; - int v52 = v20; - int v30 = 0; - int v31 = (uint16)clip_y; - while (zoomIn(v30 + 1, zoom2) < v31) - ; - v20 = v52; - spritePixelsP += _width * v30; - v29 += _lineNbr2 * (uint16)clip_y; - v22 = v61 - (uint16)clip_y; - } - if (v22 > (uint16)clip_y1) - v22 = (uint16)clip_y1; - if (clip_x) { - if ((uint16)clip_x >= v20) - return; - v20 -= (uint16)clip_x; - } - if (v20 > (uint16)clip_x1) { - int v32 = v20 - (uint16)clip_x1; - v29 -= v32; - int v62 = v22; - int v33 = 0; - while (zoomIn(v33 + 1, zoom2) < v32) - ; - int v34 = v33; - v22 = v62; - spritePixelsP += v34; - v20 = (uint16)clip_x1; - } - int v63; - do { - for (;;) { - v63 = v22; - byte *v53 = v29; - v46 = spritePixelsP; - Agr_Flag_x = 0; - Agr_x = 0; - for (int v35 = v20; v35; v35--) { - for (;;) { - if (*spritePixelsP) - *v29 = *spritePixelsP; - --v29; - ++spritePixelsP; - if (!Agr_Flag_x) - Agr_x = zoom2 + Agr_x; - if ((uint16)Agr_x < 100) - break; - Agr_x = Agr_x - 100; - --spritePixelsP; - Agr_Flag_x = 1; - --v35; - if (!v35) - goto R_Aff_Zoom_Larg_Cont1; - } - Agr_Flag_x = 0; - } + } R_Aff_Zoom_Larg_Cont1: - spritePixelsP = _width + v46; - v29 = _lineNbr2 + v53; - ++Compteur_y; - if (!Agr_Flag_y) - Agr_y = zoom2 + Agr_y; - if ((uint16)Agr_y < 100) - break; - Agr_y = Agr_y - 100; - spritePixelsP = v46; - Agr_Flag_y = 1; - v22 = v63 - 1; - if (v63 == 1) - return; - } - Agr_Flag_y = 0; - v22 = v63 - 1; - } while (v63 != 1); - } else { - if (clip_y) { - if ((uint16)clip_y >= v22) - return; - int v58 = v22; - int v49 = v20; - int v23 = 0; - int v24 = (uint16)clip_y; - while (zoomIn(v23 + 1, zoom2) < v24) - ; - v20 = v49; - spritePixelsP += _width * v23; - dest1P += _lineNbr2 * (uint16)clip_y; - v22 = v58 - (uint16)clip_y; - } - if (v22 > (uint16)clip_y1) - v22 = (uint16)clip_y1; - if (clip_x) { - if ((uint16)clip_x >= v20) - return; - int v59 = v22; - int v50 = v20; - int v25 = (uint16)clip_x; - int v26 = 0; - while (zoomIn(v26 + 1, zoom2) < v25) - ; - int v27 = v26; - v22 = v59; - spritePixelsP += v27; - dest1P += (uint16)clip_x; - v20 = v50 - (uint16)clip_x; - } - if (v20 > (uint16)clip_x1) - v20 = (uint16)clip_x1; - - int v60; - do { - for (;;) { - v60 = v22; - byte *v51 = dest1P; - v45 = spritePixelsP; - int v28 = v20; - Agr_Flag_x = 0; - Agr_x = 0; - do { - for (;;) { - if (*spritePixelsP) - *dest1P = *spritePixelsP; - ++dest1P; - ++spritePixelsP; - if (!Agr_Flag_x) - Agr_x = zoom2 + Agr_x; - if ((uint16)Agr_x < 100) - break; - Agr_x = Agr_x - 100; - --spritePixelsP; - Agr_Flag_x = 1; - --v28; - if (!v28) - goto Aff_Zoom_Larg_Cont1; - } - Agr_Flag_x = 0; - --v28; - } while (v28); -Aff_Zoom_Larg_Cont1: - spritePixelsP = _width + v45; - dest1P = _lineNbr2 + v51; - if (!Agr_Flag_y) - Agr_y = zoom2 + Agr_y; - if ((uint16)Agr_y < 100) - break; - Agr_y = Agr_y - 100; - spritePixelsP = v45; - Agr_Flag_y = 1; - v22 = v60 - 1; - if (v60 == 1) - return; - } - Agr_Flag_y = 0; - v22 = v60 - 1; - } while (v60 != 1); + spritePixelsP = _width + v46; + v29 = _lineNbr2 + v53; + ++Compteur_y; + if (!Agr_Flag_y) + Agr_y = zoom2 + Agr_y; + if ((uint16)Agr_y < 100) + break; + Agr_y = Agr_y - 100; + spritePixelsP = v46; + Agr_Flag_y = 1; + v22 = v63 - 1; + if (v63 == 1) + return; + } + Agr_Flag_y = 0; + v22 = v63 - 1; + } while (v63 != 1); + } else { + if (clip_y) { + if ((uint16)clip_y >= v22) + return; + int v58 = v22; + int v49 = v20; + int v23 = 0; + int v24 = (uint16)clip_y; + while (zoomIn(v23 + 1, zoom2) < v24) + ; + v20 = v49; + spritePixelsP += _width * v23; + dest1P += _lineNbr2 * (uint16)clip_y; + v22 = v58 - (uint16)clip_y; + } + if (v22 > (uint16)clip_y1) + v22 = (uint16)clip_y1; + if (clip_x) { + if ((uint16)clip_x >= v20) + return; + int v26 = 0; + while (zoomIn(v26 + 1, zoom2) < (uint16)clip_x) + ; + spritePixelsP += v26; + dest1P += (uint16)clip_x; + v20 = v20 - (uint16)clip_x; + } + if (v20 > (uint16)clip_x1) + v20 = (uint16)clip_x1; + + int v60; + do { + for (;;) { + v60 = v22; + byte *v51 = dest1P; + v45 = spritePixelsP; + int v28 = v20; + Agr_Flag_x = 0; + Agr_x = 0; + do { + for (;;) { + if (*spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; + if (!Agr_Flag_x) + Agr_x = zoom2 + Agr_x; + if ((uint16)Agr_x < 100) + break; + Agr_x = Agr_x - 100; + --spritePixelsP; + Agr_Flag_x = 1; + --v28; + if (!v28) + goto Aff_Zoom_Larg_Cont1; } - } else if (zoom1) { - Compteur_y = 0; + Agr_Flag_x = 0; + --v28; + } while (v28); +Aff_Zoom_Larg_Cont1: + spritePixelsP = _width + v45; + dest1P = _lineNbr2 + v51; + if (!Agr_Flag_y) + Agr_y = zoom2 + Agr_y; + if ((uint16)Agr_y < 100) + break; + Agr_y = Agr_y - 100; + spritePixelsP = v45; + Agr_Flag_y = 1; + v22 = v60 - 1; + if (v60 == 1) + return; + } + Agr_Flag_y = 0; + v22 = v60 - 1; + } while (v60 != 1); + } + } else if (zoom1) { + Compteur_y = 0; + Red_x = 0; + Red_y = 0; + _width = spriteWidth; + Red = zoom1; + if (zoom1 < 100) { + int v37 = zoomOut(spriteWidth, Red); + if (modeFlag) { + v40 = v37 + dest1P; + do { + int v65 = spriteHeight2; + byte *v55 = v40; + Red_y = Red + Red_y; + if ((uint16)Red_y < 100) { Red_x = 0; - Red_y = 0; - _width = spriteWidth; - Red = zoom1; - if (zoom1 < 100) { - int v37 = zoomOut(spriteWidth, Red); - if (modeFlag) { - v40 = v37 + dest1P; - do { - int v65 = spriteHeight2; - byte *v55 = v40; - Red_y = Red + Red_y; - if ((uint16)Red_y < 100) { - Red_x = 0; - int v42 = v37; - for (int v41 = _width; v41; v41--) { - Red_x = Red + Red_x; - if ((uint16)Red_x < 100) { - if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) - *v40 = *spritePixelsP; - --v40; - ++spritePixelsP; - --v42; - } else { - Red_x = Red_x - 100; - ++spritePixelsP; - } - } - spriteHeight2 = v65; - v40 = _lineNbr2 + v55; - } else { - Red_y = Red_y - 100; - spritePixelsP += _width; - } - --spriteHeight2; - } while (spriteHeight2); + int v42 = v37; + for (int v41 = _width; v41; v41--) { + Red_x = Red + Red_x; + if ((uint16)Red_x < 100) { + if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) + *v40 = *spritePixelsP; + --v40; + ++spritePixelsP; + --v42; } else { - do { - int v64 = spriteHeight2; - byte *v54 = dest1P; - Red_y = Red + Red_y; - if ((uint16)Red_y < 100) { - Red_x = 0; - int v39 = 0; - for (int v38 = _width; v38; v38--) { - Red_x = Red + Red_x; - if ((uint16)Red_x < 100) { - if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) - *dest1P = *spritePixelsP; - ++dest1P; - ++spritePixelsP; - ++v39; - } else { - Red_x = Red_x - 100; - ++spritePixelsP; - } - } - spriteHeight2 = v64; - dest1P = _lineNbr2 + v54; - } else { - Red_y = Red_y - 100; - spritePixelsP += _width; - } - --spriteHeight2; - } while (spriteHeight2); + Red_x = Red_x - 100; + ++spritePixelsP; } } + spriteHeight2 = v65; + v40 = _lineNbr2 + v55; } else { - _width = spriteWidth; - Compteur_y = 0; - if (modeFlag) { - dest2P = spriteWidth + dest1P; - spec_largeur = spriteWidth; - if (clip_y) { - if ((uint16)clip_y >= (unsigned int)spriteHeight1) - return; - spritePixelsP += spriteWidth * (uint16)clip_y; - dest2P += _lineNbr2 * (uint16)clip_y; - spriteHeight1 -= (uint16)clip_y; - } - int xLeft = (uint16)clip_y1; - if (spriteHeight1 > clip_y1) - spriteHeight1 = clip_y1; - xLeft = clip_x; - if (clip_x) { - if (xLeft >= spriteWidth) - return; - spriteWidth -= xLeft; - } - if (spriteWidth > (uint16)clip_x1) { - int clippedWidth = spriteWidth - (uint16)clip_x1; - spritePixelsP += clippedWidth; - dest2P -= clippedWidth; - spriteWidth = (uint16)clip_x1; - } - int yCtr2; - do { - yCtr2 = spriteHeight1; - byte *destCopy2P = dest2P; - const byte *spritePixelsCopy2P = spritePixelsP; - for (int xCtr2 = spriteWidth; xCtr2; xCtr2--) { - if (*spritePixelsP) - *dest2P = *spritePixelsP; - ++spritePixelsP; - --dest2P; - } - spritePixelsP = spec_largeur + spritePixelsCopy2P; - dest2P = _lineNbr2 + destCopy2P; - spriteHeight1 = yCtr2 - 1; - } while (yCtr2 != 1); - } else { - spec_largeur = spriteWidth; - if (clip_y) { - if ((uint16)clip_y >= (unsigned int)spriteHeight1) - return; - spritePixelsP += spriteWidth * (uint16)clip_y; - dest1P += _lineNbr2 * (uint16)clip_y; - spriteHeight1 -= (uint16)clip_y; - } - if (spriteHeight1 > clip_y1) - spriteHeight1 = clip_y1; - if (clip_x) { - if ((uint16)clip_x >= spriteWidth) - return; - spritePixelsP += (uint16)clip_x; - dest1P += (uint16)clip_x; - spriteWidth -= (uint16)clip_x; + Red_y = Red_y - 100; + spritePixelsP += _width; + } + --spriteHeight2; + } while (spriteHeight2); + } else { + do { + int v64 = spriteHeight2; + byte *v54 = dest1P; + Red_y = Red + Red_y; + if ((uint16)Red_y < 100) { + Red_x = 0; + int v39 = 0; + for (int v38 = _width; v38; v38--) { + Red_x = Red + Red_x; + if ((uint16)Red_x < 100) { + if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; + ++v39; + } else { + Red_x = Red_x - 100; + ++spritePixelsP; } - if (spriteWidth > (uint16)clip_x1) - spriteWidth = (uint16)clip_x1; - int yCtr1; - do { - yCtr1 = spriteHeight1; - byte *dest1CopyP = dest1P; - const byte *spritePixelsCopyP = spritePixelsP; - for (int xCtr1 = spriteWidth; xCtr1; xCtr1--) { - if (*spritePixelsP) - *dest1P = *spritePixelsP; - ++dest1P; - ++spritePixelsP; - } - spritePixelsP = spec_largeur + spritePixelsCopyP; - dest1P = _lineNbr2 + dest1CopyP; - spriteHeight1 = yCtr1 - 1; - } while (yCtr1 != 1); } + spriteHeight2 = v64; + dest1P = _lineNbr2 + v54; + } else { + Red_y = Red_y - 100; + spritePixelsP += _width; } + --spriteHeight2; + } while (spriteHeight2); + } + } + } else { + _width = spriteWidth; + Compteur_y = 0; + if (modeFlag) { + dest2P = spriteWidth + dest1P; + spec_largeur = spriteWidth; + if (clip_y) { + if ((uint16)clip_y >= (unsigned int)spriteHeight1) + return; + spritePixelsP += spriteWidth * (uint16)clip_y; + dest2P += _lineNbr2 * (uint16)clip_y; + spriteHeight1 -= (uint16)clip_y; + } + int xLeft = (uint16)clip_y1; + if (spriteHeight1 > clip_y1) + spriteHeight1 = clip_y1; + xLeft = clip_x; + if (clip_x) { + if (xLeft >= spriteWidth) + return; + spriteWidth -= xLeft; + } + if (spriteWidth > (uint16)clip_x1) { + int clippedWidth = spriteWidth - (uint16)clip_x1; + spritePixelsP += clippedWidth; + dest2P -= clippedWidth; + spriteWidth = (uint16)clip_x1; + } + int yCtr2; + do { + yCtr2 = spriteHeight1; + byte *destCopy2P = dest2P; + const byte *spritePixelsCopy2P = spritePixelsP; + for (int xCtr2 = spriteWidth; xCtr2; xCtr2--) { + if (*spritePixelsP) + *dest2P = *spritePixelsP; + ++spritePixelsP; + --dest2P; } + spritePixelsP = spec_largeur + spritePixelsCopy2P; + dest2P = _lineNbr2 + destCopy2P; + spriteHeight1 = yCtr2 - 1; + } while (yCtr2 != 1); + } else { + spec_largeur = spriteWidth; + if (clip_y) { + if ((uint16)clip_y >= (unsigned int)spriteHeight1) + return; + spritePixelsP += spriteWidth * (uint16)clip_y; + dest1P += _lineNbr2 * (uint16)clip_y; + spriteHeight1 -= (uint16)clip_y; + } + if (spriteHeight1 > clip_y1) + spriteHeight1 = clip_y1; + if (clip_x) { + if ((uint16)clip_x >= spriteWidth) + return; + spritePixelsP += (uint16)clip_x; + dest1P += (uint16)clip_x; + spriteWidth -= (uint16)clip_x; } + if (spriteWidth > (uint16)clip_x1) + spriteWidth = (uint16)clip_x1; + int yCtr1; + do { + yCtr1 = spriteHeight1; + byte *dest1CopyP = dest1P; + const byte *spritePixelsCopyP = spritePixelsP; + for (int xCtr1 = spriteWidth; xCtr1; xCtr1--) { + if (*spritePixelsP) + *dest1P = *spritePixelsP; + ++dest1P; + ++spritePixelsP; + } + spritePixelsP = spec_largeur + spritePixelsCopyP; + dest1P = _lineNbr2 + dest1CopyP; + spriteHeight1 = yCtr1 - 1; + } while (yCtr1 != 1); } } } -// Display Speed +/** + * Fast Display + */ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex) { - int width, height; + int width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); + int height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); - width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); - height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); if (*spriteData == 78) { Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); @@ -1883,7 +1872,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (ptr == g_PTRNUL) { _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); - ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } if (!mode) { filename = file + ".spr"; @@ -1895,7 +1884,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { } else { _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } } if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { @@ -1930,7 +1919,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); - dataP = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + dataP = _vm->_fileManager.loadFile(_vm->_globals._curFilename); _vm->_globals.COUCOU = dataP; } } -- cgit v1.2.3 From b284338d6778775ab755af487dfd52d05b953e45 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 29 Dec 2012 14:20:34 +0100 Subject: HOPKINS: Some refactoring in ObjectManager, some renaming --- engines/hopkins/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0facdf85d4..455c3c41b9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1107,7 +1107,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, void GraphicsManager::FIN_VISU() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + if (_vm->_globals.Bqe_Anim[idx]._enabledFl) _vm->_objectsManager.BOB_OFF(idx); } @@ -1115,22 +1115,22 @@ void GraphicsManager::FIN_VISU() { _vm->_eventsManager.VBL(); for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + if (_vm->_globals.Bqe_Anim[idx]._enabledFl) _vm->_objectsManager.BOB_ZERO(idx); } for (int idx = 1; idx <= 29; ++idx) { - _vm->_globals.BL_ANIM[idx].v1 = 0; + _vm->_globals._lockedAnims[idx]._enableFl = false; } for (int idx = 1; idx <= 20; ++idx) { - _vm->_globals.Bqe_Anim[idx].field4 = 0; + _vm->_globals.Bqe_Anim[idx]._enabledFl = false; } } void GraphicsManager::VISU_ALL() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx].field4 == 1) + if (_vm->_globals.Bqe_Anim[idx]._enabledFl) _vm->_objectsManager.BOB_VISU(idx); } } -- cgit v1.2.3 From 3629fd80837035f01dbc475593d97593adee7461 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 30 Dec 2012 18:51:47 +0100 Subject: HOPKINS: More renaming, some refactoring in DialogsManager --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 455c3c41b9..abe2abe85b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -89,10 +89,10 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { MANU_SCROLL = true; else MANU_SCROLL = false; - SPEED_SCROLL = 16; + _scrollSpeed = 16; } else { MANU_SCROLL = false; - SPEED_SCROLL = 32; + _scrollSpeed = 32; } } -- cgit v1.2.3 From 17b5a57c6b686a7e1ad12b92c92ab79f8b8035fc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 30 Dec 2012 19:33:53 +0100 Subject: HOPKINS: Remove REDRAW counter, as it's always equal to 0 and therefore useless --- engines/hopkins/graphics.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index abe2abe85b..8264b6ba70 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -54,7 +54,6 @@ GraphicsManager::GraphicsManager() { FADE_LINUX = 0; _skipVideoLockFl = false; no_scroll = 0; - REDRAW = false; min_x = 0; min_y = 20; max_x = SCREEN_WIDTH * 2; -- cgit v1.2.3 From cb363aafd5ed1d912e5b211e06c823307fb00489 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 1 Jan 2013 13:53:07 +0100 Subject: HOPKINS: Refactoring in ObjectsManager, renaming --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8264b6ba70..b7cbd55694 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -41,7 +41,7 @@ GraphicsManager::GraphicsManager() { PAL_PIXELS = NULL; _lineNbr = 0; _videoPtr = NULL; - ofscroll = 0; + _scrollOffset = 0; SCROLL = 0; PCX_L = PCX_H = 0; DOUBLE_ECRAN = false; @@ -249,7 +249,7 @@ void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) void GraphicsManager::scrollScreen(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); _vm->_eventsManager._startPos.x = result; - ofscroll = result; + _scrollOffset = result; SCROLL = result; } -- cgit v1.2.3 From d6f72071a42559299139fd2f162c98c7f01a0b51 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 1 Jan 2013 21:03:24 +0100 Subject: HOPKINS: Some more refactoring and renaming --- engines/hopkins/graphics.cpp | 149 ++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 95 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b7cbd55694..0d4073d67d 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -43,8 +43,7 @@ GraphicsManager::GraphicsManager() { _videoPtr = NULL; _scrollOffset = 0; SCROLL = 0; - PCX_L = PCX_H = 0; - DOUBLE_ECRAN = false; + _largeScreenFl = false; OLD_SCROLL = 0; _lineNbr2 = 0; @@ -196,13 +195,13 @@ void GraphicsManager::loadScreen(const Common::String &file) { } scrollScreen(0); - A_PCX640_480((byte *)_vesaScreen, file, _palette, flag); + A_PCX640_480(_vesaScreen, file, _palette, flag); SCROLL = 0; OLD_SCROLL = 0; clearPalette(); - if (!DOUBLE_ECRAN) { + if (!_largeScreenFl) { SCANLINE(SCREEN_WIDTH); max_x = SCREEN_WIDTH; lockScreen(); @@ -254,20 +253,19 @@ void GraphicsManager::scrollScreen(int amount) { } void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { - byte *destPosP; int palIndex; int srcOffset; int col1, col2; - destPosP = destP; + byte *destPosP = destP; for (int idx = 0; idx < count; ++idx) { - palIndex = *(byte *)destPosP++; + palIndex = *destPosP; srcOffset = 3 * palIndex; - col1 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2); + col1 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; for (int idx2 = 0; idx2 < 38; ++idx2) { srcOffset = 3 * idx2; - col2 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2); + col2 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; col2 += minThreshold; if (col2 < col1) @@ -277,9 +275,10 @@ void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int m if (col2 > col1) continue; - *(destPosP - 1) = (idx2 == 0) ? 1 : idx2; + *destPosP = (idx2 == 0) ? 1 : idx2; break; } + destPosP++; } } @@ -288,12 +287,12 @@ void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { byte *dataP = surface; for (int count = size - 1; count; count--){ - dataVal = *dataP++; - *(dataP - 1) = *(dataVal + col); + dataVal = *dataP; + *dataP = col[dataVal]; + dataP++; } } -// TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { Common::File f; Graphics::PCXDecoder pcxDecoder; @@ -322,9 +321,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by const Graphics::Surface *s = pcxDecoder.getSurface(); // Copy out the dimensions and pixels of the decoded surface - DOUBLE_ECRAN = s->w > SCREEN_WIDTH; - PCX_L = s->w; - PCX_H = s->h; + _largeScreenFl = s->w > SCREEN_WIDTH; Common::copy((byte *)s->pixels, (byte *)s->pixels + (s->pitch * s->h), surface); // Copy out the palette @@ -378,11 +375,9 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * v5 = 64000; if (!v16) v5 = v17; -// v8 = i; f.read(ptr, v5); -// i = v8; } - v9 = *(ptr + v7++); + v9 = ptr[v7++]; if (v9 > 192) { v10 = v9 - 192; if (v7 == v5) { @@ -391,17 +386,15 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * v5 = 64000; if (v16 == 1) v5 = v17; -// v11 = i; f.read(ptr, v5); -// i = v11; } - v12 = *(ptr + v7++); + v12 = ptr[v7++]; do { - *(surface + i++) = v12; + surface[i++] = v12; --v10; } while (v10); } else { - *(surface + i++) = v9; + surface[i++] = v9; } } @@ -421,32 +414,6 @@ void GraphicsManager::SCANLINE(int pitch) { _lineNbr = _lineNbr2 = pitch; } -void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *srcP; - byte *destP; - int yNext; - int yCtr; - byte *dest2P; - const byte *src2P; - unsigned int widthRemaining; - - assert(_videoPtr); - srcP = xs + _lineNbr2 * ys + surface; - destP = destX + WinScan * destY + (byte *)_videoPtr->pixels; - yNext = height; - do { - yCtr = yNext; - memcpy((byte *)destP, (const byte *)srcP, 4 * (width >> 2)); - src2P = (const byte *)(srcP + 4 * (width >> 2)); - dest2P = (byte *)(destP + 4 * (width >> 2)); - widthRemaining = width - 4 * (width >> 2); - memcpy(dest2P, src2P, widthRemaining); - destP = dest2P + widthRemaining + WinScan - width; - srcP = src2P + widthRemaining + _lineNbr2 - width; - yNext = yCtr - 1; - } while (yCtr != 1); -} - /** * Copies data from a 8-bit palette surface into the 16-bit screen */ @@ -807,40 +774,41 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) return; if (srcByte < kSetOffset) { - destOffset += (byte)(*srcP + 35); - srcByte = *(srcP++ + 1); + destOffset += srcP[35]; + srcByte = srcP[1]; + srcP++; } else if (srcByte == k8bVal) { - destOffset += *(srcP + 1); - srcByte = *(srcP + 2); + destOffset += srcP[1]; + srcByte = srcP[2]; srcP += 2; } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); - srcByte = *(srcP + 3); + srcByte = srcP[3]; srcP += 3; } else { destOffset += READ_LE_UINT32(srcP + 1); - srcByte = *(srcP + 5); + srcByte = srcP[5]; srcP += 5; } Video_Cont3_wVbe: if (srcByte > 210) { - if (srcByte == (byte)-45) { - destLen1 = *(srcP + 1); - rleValue = *(srcP + 2); + if (srcByte == -45) { + destLen1 = srcP[1]; + rleValue = srcP[2]; destSlice1P = destOffset + destSurface; destOffset += destLen1; memset(destSlice1P, rleValue, destLen1); srcP += 3; } else { - destLen2 = (byte)(*srcP + 45); - rleValue = *(srcP + 1); + destLen2 = srcP[45]; + rleValue = srcP[1]; destSlice2P = destOffset + destSurface; destOffset += destLen2; memset(destSlice2P, rleValue, destLen2); srcP += 2; } } else { - *(destOffset + destSurface) = srcByte; + destSurface[destOffset] = srcByte; ++srcP; ++destOffset; } @@ -861,16 +829,16 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { destOffset += srcByte - 221; srcByte = *++srcP; } else if (srcByte == k8bVal) { - destOffset += *(const byte *)(srcP + 1); - srcByte = *(const byte *)(srcP + 2); + destOffset += srcP[1]; + srcByte = srcP[2]; srcP += 2; } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); - srcByte = *(const byte *)(srcP + 3); + srcByte = srcP[3]; srcP += 3; } else { destOffset += READ_LE_UINT32(srcP + 1); - srcByte = *(const byte *)(srcP + 5); + srcByte = srcP[5]; srcP += 5; } } @@ -882,8 +850,8 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { if (srcByte > 210) { if (srcByte == 211) { - int pixelCount = *(srcP + 1); - int pixelIndex = *(srcP + 2); + int pixelCount = srcP[1]; + int pixelIndex = srcP[2]; uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); destOffset += pixelCount; @@ -894,7 +862,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { srcP += 3; } else { int pixelCount = srcByte - 211; - int pixelIndex = *(srcP + 1); + int pixelIndex = srcP[1]; uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); destOffset += pixelCount; @@ -926,16 +894,16 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { if (pixelIndex == kByteStop) return; if (pixelIndex == k8bVal) { - destOffset += *(srcP + 1); - pixelIndex = *(srcP + 2); + destOffset += srcP[1]; + pixelIndex = srcP[2]; srcP += 2; } else if (pixelIndex == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); - pixelIndex = *(srcP + 3); + pixelIndex = srcP[3]; srcP += 3; } else { destOffset += READ_LE_UINT32(srcP + 1); - pixelIndex = *(srcP + 5); + pixelIndex = srcP[5]; srcP += 5; } Video_Cont_Vbe16a: @@ -1313,10 +1281,10 @@ void GraphicsManager::CopyAsm16(const byte *surface) { v6 = (uint16 *)(v5 + 2 * *v1); v = *v6; *v2 = *v6; - *(v2 + 1) = v; + v2[1] = v; v8 = (uint16 *)(WinScan + v2); *v8 = v; - *(v8 + 1) = v; + v8[1] = v; ++v1; v2 = (byte *)v8 - WinScan + 4; } @@ -1886,7 +1854,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } } - if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') { + if (ptr[0] != 'I' || ptr[1] != 'N' || ptr[2] != 'I') { error("Error, file not ini"); } else { bool doneFlag = false; @@ -1927,9 +1895,6 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { } void GraphicsManager::NB_SCREEN() { - byte *destP; - const byte *srcP; - if (!_vm->_globals.NECESSAIRE) initColorTable(50, 65, _palette); @@ -1942,13 +1907,7 @@ void GraphicsManager::NB_SCREEN() { m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); - destP = _vesaScreen; - srcP = _vesaBuffer; - memcpy(_vesaScreen, _vesaBuffer, 614396); - srcP = srcP + 614396; - destP = destP + 614396; - *destP = *srcP; - *(destP + 2) = *(srcP + 2); + memcpy(_vesaScreen, _vesaBuffer, 614399); DD_VBL(); } @@ -1972,20 +1931,20 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { if (byteVal == kByteStop) return; if (byteVal == k8bVal) { - destOffset += *(srcPtr + 1); - byteVal = *(srcPtr + 2); + destOffset += srcPtr[1]; + byteVal = srcPtr[2]; srcPtr += 2; } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcPtr + 1); - byteVal = *(srcPtr + 3); + byteVal = srcPtr[3]; srcPtr += 3; } else { destOffset += READ_LE_UINT32(srcPtr + 1); - byteVal = *(srcPtr + 5); + byteVal = srcPtr[5]; srcPtr += 5; } Video_Cont_wVbe: - *(dest + destOffset) = byteVal; + dest[destOffset] = byteVal; ++srcPtr; ++destOffset; } @@ -2007,16 +1966,16 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { if (byteVal == kByteStop) return; if (byteVal == k8bVal) { - destOffset += *(srcP + 1); - byteVal = *(srcP + 2); + destOffset += srcP[1]; + byteVal = srcP[2]; srcP += 2; } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); - byteVal = *(srcP + 3); + byteVal = srcP[3]; srcP += 3; } else { destOffset += READ_LE_UINT32(srcP + 1); - byteVal = *(srcP + 5); + byteVal = srcP[5]; srcP += 5; } } -- cgit v1.2.3 From 682e70623ac864037e9b81b4215202cdece09bed Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 2 Jan 2013 00:57:00 +0100 Subject: HOPKINS: More refactoring and renaming, remove several useless variables --- engines/hopkins/graphics.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0d4073d67d..27d86d21a3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -60,7 +60,6 @@ GraphicsManager::GraphicsManager() { clip_x = clip_y = 0; clip_x1 = clip_y1 = 0; clip_flag = false; - SDL_NBLOCS = 0; Red_x = Red_y = 0; Red = 0; _width = 0; @@ -1112,7 +1111,7 @@ void GraphicsManager::RESET_SEGMENT_VESA() { } // Add VESA Segment -void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { +void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { int tempX; int blocCount; bool addFlag; @@ -1156,11 +1155,10 @@ void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) { } // Display VESA Segment -void GraphicsManager::Affiche_Segment_Vesa() { +void GraphicsManager::displayVesaSegment() { if (_vm->_globals.NBBLOC == 0) return; - SDL_NBLOCS = _vm->_globals.NBBLOC; lockScreen(); for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { @@ -1198,10 +1196,6 @@ void GraphicsManager::Affiche_Segment_Vesa() { _vm->_globals.NBBLOC = 0; unlockScreen(); - if (!_vm->_globals.BPP_NOAFF) { -// SDL_UpdateRects(LinuxScr, SDL_NBLOCS, dstrect); - } - SDL_NBLOCS = 0; } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx) { @@ -1217,7 +1211,7 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); } if (!_vm->_globals.NO_VISU) - Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); + addVesaSegment(xp, yp, xp + width, yp + height); } void GraphicsManager::CopyAsm(const byte *surface) { @@ -1713,7 +1707,7 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); } if (!_vm->_globals.NO_VISU) - Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height); + addVesaSegment(xp, yp, xp + width, yp + height); } void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { @@ -1747,7 +1741,7 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY); - Ajoute_Segment_Vesa(left, top2, left + croppedWidth, top2 + height2); + addVesaSegment(left, top2, left + croppedWidth, top2 + height2); } } -- cgit v1.2.3 From a4b7b29157125ad6240888186dde70ac64ee6088 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 2 Jan 2013 20:12:32 +0100 Subject: HOPKINS: Silence some warnings reported by GCC. Thanks Eriktorbjorn for reporting those --- engines/hopkins/graphics.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 27d86d21a3..0ea89b07bc 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -705,7 +705,7 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - *(uint16 *)&SD_PIXELS[2 * idx] = mapRGB(*srcP, *(srcP + 1), *(srcP + 2)); + WRITE_LE_UINT16(&SD_PIXELS[2 * idx], mapRGB(*srcP, *(srcP + 1), *(srcP + 2))); } } @@ -791,7 +791,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) } Video_Cont3_wVbe: if (srcByte > 210) { - if (srcByte == -45) { + if (srcByte == 211) { destLen1 = srcP[1]; rleValue = srcP[2]; destSlice1P = destOffset + destSurface; @@ -1113,7 +1113,6 @@ void GraphicsManager::RESET_SEGMENT_VESA() { // Add VESA Segment void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { int tempX; - int blocCount; bool addFlag; tempX = x1; @@ -1127,9 +1126,7 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { if (y1 < min_y) y1 = min_y; - blocCount = _vm->_globals.NBBLOC; if (_vm->_globals.NBBLOC > 1) { - int16 blocIndex = 0; do { BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; @@ -1138,7 +1135,6 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; ++blocIndex; - blocCount = blocIndex; } while (_vm->_globals.NBBLOC + 1 != blocIndex); } @@ -1910,12 +1906,10 @@ void GraphicsManager::SHOW_PALETTE() { } void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { - int result; int destOffset; const byte *srcPtr; byte byteVal; - result = 0; destOffset = 0; srcPtr = src; for (;;) { -- cgit v1.2.3 From 3ab4446a1ba6b60f149b10587cacaf4a8f33aedd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 01:33:26 +0100 Subject: HOPKINS: Fix remaining GCC warnings (on behalf of Eriktorbjorn) --- engines/hopkins/graphics.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0ea89b07bc..8650c06f5e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -442,14 +442,14 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, // TODO: See if PAL_PIXELS can be converted to a uint16 array void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { const byte *srcP; - const byte *destP; + byte *destP; int yNext; int xCtr; const byte *palette; int pixelWord; int yCtr; const byte *srcCopyP; - const byte *destCopyP; + byte *destCopyP; assert(_videoPtr); srcP = xs + _lineNbr2 * ys + surface; @@ -469,7 +469,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width Agr_x = 0; do { - pixelWord = *(uint16 *)(palette + 2 * *srcP); + pixelWord = *(const uint16 *)(palette + 2 * *srcP); *(uint16 *)destP = pixelWord; ++srcP; destP += 2; @@ -508,7 +508,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int xCount; int xCtr; const byte *palette; - uint16 *tempSrcP; + const uint16 *tempSrcP; uint16 srcByte; uint16 *tempDestP; int savedXCount; @@ -531,7 +531,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, palette = PAL_PIXELS; do { - tempSrcP = (uint16 *)(palette + 2 * *srcP); + tempSrcP = (const uint16 *)(palette + 2 * *srcP); srcByte = *tempSrcP; *destP = *tempSrcP; *(destP + 1) = srcByte; @@ -932,7 +932,7 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int destP += width; } else if (width & 2) { for (i = width >> 1; i; --i) { - *(uint16 *)destP = *(uint16 *)srcP; + *(uint16 *)destP = *(const uint16 *)srcP; srcP += 2; destP += 2; } @@ -1302,7 +1302,7 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in destP += width; } else if (width & 2) { for (i = width >> 1; i; --i) { - *(uint16 *)destP = *(uint16 *)srcP; + *(uint16 *)destP = *(const uint16 *)srcP; srcP += 2; destP += 2; } -- cgit v1.2.3 From 079994d35c2d366a255c66a8cddd55a6cb5b7150 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 16:30:53 +0100 Subject: HOPKINS: Rewrite fade in, add a delay --- engines/hopkins/graphics.cpp | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8650c06f5e..b6a6501c98 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -552,46 +552,28 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, } void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) { - uint16 palData1[PALETTE_BLOCK_SIZE * 2]; byte palData2[PALETTE_BLOCK_SIZE]; // Initialise temporary palettes - Common::fill(&palData1[0], &palData1[PALETTE_BLOCK_SIZE], 0); Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0); // Set current palette to black setpal_vga256(palData2); // Loop through fading in the palette - uint16 *pTemp1 = &palData1[1]; for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) { - uint16 *pTemp2 = &palData1[2]; - for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { - if (palData2[palOffset] < palette[palOffset]) { - uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD; - palData1[palOffset] = v; - palData2[palOffset] = (v >> 8) & 0xff; - } - - if (palData2[palOffset + 1] < palette[palOffset + 1]) { - uint16 *pDest = &pTemp1[palOffset]; - uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; - *pDest = v; - palData2[palOffset + 1] = (v >> 8) & 0xff; - } - - if (palData2[palOffset + 2] < palette[palOffset + 2]) { - uint16 *pDest = &pTemp2[palOffset]; - uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest; - *pDest = v; - palData2[palOffset + 2] = (v >> 8) & 0xff; - } + palData2[palOffset + 0] = fadeIndex * palette[palOffset + 0] / (FADESPD - 1); + palData2[palOffset + 1] = fadeIndex * palette[palOffset + 1] / (FADESPD - 1); + palData2[palOffset + 2] = fadeIndex * palette[palOffset + 2] / (FADESPD - 1); } setpal_vga256(palData2); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); + + // Added a delay in order to see the fading + _vm->_eventsManager.delay(20); } // Set the final palette -- cgit v1.2.3 From 6976be7438ef842e08c8b4587c7e323d4af21109 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 22:32:22 +0100 Subject: HOPKINS: Rename functions related to fade in/out. Fix a potential issue for short fadings --- engines/hopkins/graphics.cpp | 97 +++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 46 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b6a6501c98..517c496944 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -49,7 +49,7 @@ GraphicsManager::GraphicsManager() { _lineNbr2 = 0; Agr_x = Agr_y = 0; Agr_Flag_x = Agr_Flag_y = 0; - FADESPD = 15; + _fadeDefaultSpeed = 15; FADE_LINUX = 0; _skipVideoLockFl = false; no_scroll = 0; @@ -553,21 +553,26 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) { byte palData2[PALETTE_BLOCK_SIZE]; - - // Initialise temporary palettes + int fadeStep; + if (step > 1) + fadeStep = step; + else + fadeStep = 2; + // Initialize temporary palette Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0); // Set current palette to black setpal_vga256(palData2); // Loop through fading in the palette - for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) { + for (int fadeIndex = 0; fadeIndex < fadeStep; ++fadeIndex) { for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { - palData2[palOffset + 0] = fadeIndex * palette[palOffset + 0] / (FADESPD - 1); - palData2[palOffset + 1] = fadeIndex * palette[palOffset + 1] / (FADESPD - 1); - palData2[palOffset + 2] = fadeIndex * palette[palOffset + 2] / (FADESPD - 1); + palData2[palOffset + 0] = fadeIndex * palette[palOffset + 0] / (fadeStep - 1); + palData2[palOffset + 1] = fadeIndex * palette[palOffset + 1] / (fadeStep - 1); + palData2[palOffset + 2] = fadeIndex * palette[palOffset + 2] / (fadeStep - 1); } + // Set the transition palette and refresh the screen setpal_vga256(palData2); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); @@ -590,7 +595,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface byte palData[PALETTE_BLOCK_SIZE]; int tempPalette[PALETTE_BLOCK_SIZE]; - palMax = palByte = FADESPD; + palMax = palByte = _fadeDefaultSpeed; if (palette) { for (int palIndex = 0; palIndex < PALETTE_BLOCK_SIZE; palIndex++) { int palDataIndex = palIndex; @@ -634,26 +639,56 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } } -void GraphicsManager::FADE_INS() { - FADESPD = 1; +void GraphicsManager::fadeInShort() { + _fadeDefaultSpeed = 1; fadeIn(_palette, 1, (const byte *)_vesaBuffer); } -void GraphicsManager::FADE_OUTS() { - FADESPD = 1; +void GraphicsManager::fadeOutShort() { + _fadeDefaultSpeed = 1; fadeOut(_palette, 1, (const byte *)_vesaBuffer); } -void GraphicsManager::FADE_INW() { - FADESPD = 15; +void GraphicsManager::fadeInLong() { + _fadeDefaultSpeed = 15; fadeIn(_palette, 20, (const byte *)_vesaBuffer); } -void GraphicsManager::FADE_OUTW() { - FADESPD = 15; +void GraphicsManager::fadeOutLong() { + _fadeDefaultSpeed = 15; fadeOut(_palette, 20, (const byte *)_vesaBuffer); } +void GraphicsManager::fadeOutDefaultLength(const byte *surface) { + assert(surface); + fadeOut(_palette, _fadeDefaultSpeed, surface); +} + +void GraphicsManager::fadeInDefaultLength(const byte *surface) { + assert(surface); + fadeIn(_palette, _fadeDefaultSpeed, surface); +} + +void GraphicsManager::fadeInBreakout() { + setpal_vga256(_palette); + lockScreen(); + CopyAsm16(_vesaBuffer); + unlockScreen(); + DD_VBL(); +} + +void GraphicsManager::fateOutBreakout() { + byte palette[PALETTE_EXT_BLOCK_SIZE]; + + memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); + setpal_vga256(palette); + + lockScreen(); + CopyAsm16(_vesaBuffer); + unlockScreen(); + DD_VBL(); +} + void GraphicsManager::setpal_vga256(const byte *palette) { changePalette(palette); } @@ -704,36 +739,6 @@ void GraphicsManager::DD_VBL() { g_system->updateScreen(); } -void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) { - assert(surface); - fadeOut(_palette, FADESPD, surface); -} - -void GraphicsManager::FADE_INW_LINUX(const byte *surface) { - assert(surface); - fadeIn(_palette, FADESPD, surface); -} - -void GraphicsManager::fadeInBreakout() { - setpal_vga256(_palette); - lockScreen(); - CopyAsm16(_vesaBuffer); - unlockScreen(); - DD_VBL(); -} - -void GraphicsManager::fateOutBreakout() { - byte palette[PALETTE_EXT_BLOCK_SIZE]; - - memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); - setpal_vga256(palette); - - lockScreen(); - CopyAsm16(_vesaBuffer); - unlockScreen(); - DD_VBL(); -} - void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { int rleValue; int destOffset; -- cgit v1.2.3 From 0958eaddc5da2beac94b5611f356a67f3d8a0620 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 23:01:00 +0100 Subject: HOPKINS: Rewrite fade out --- engines/hopkins/graphics.cpp | 73 ++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 517c496944..c6af572428 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -551,6 +551,9 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, } while (yCtr != 1); } +/** + * Fade in. the step number is determine by parameter. + */ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) { byte palData2[PALETTE_BLOCK_SIZE]; int fadeStep; @@ -589,44 +592,36 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) DD_VBL(); } +/** + * Fade out. the step number is determine by parameter. + */ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { - int palByte; - uint16 palMax; byte palData[PALETTE_BLOCK_SIZE]; - int tempPalette[PALETTE_BLOCK_SIZE]; + int fadeStep; + if (step > 1) + fadeStep = step; + else + fadeStep = 2; - palMax = palByte = _fadeDefaultSpeed; if (palette) { - for (int palIndex = 0; palIndex < PALETTE_BLOCK_SIZE; palIndex++) { - int palDataIndex = palIndex; - palByte = palette[palIndex]; - palByte <<= 8; - tempPalette[palDataIndex] = palByte; - palData[palDataIndex] = palette[palIndex]; - } - - setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); - - for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { - for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { - int palCtr5 = palCtr4; - int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; - tempPalette[palCtr5] = palValue; - palData[palCtr5] = (palValue >> 8) & 0xff; + for (int f = 0; f < fadeStep; f++) { + for (int32 i = 0; i < 256; i++) { + palData[i * 3 + 0] = (fadeStep - f - 1) * palette[i * 3 + 0] / (fadeStep - 1); + palData[i * 3 + 1] = (fadeStep - f - 1) * palette[i * 3 + 1] / (fadeStep - 1); + palData[i * 3 + 2] = (fadeStep - f - 1) * palette[i * 3 + 2] / (fadeStep - 1); } setpal_vga256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); + + _vm->_eventsManager.delay(100); } for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) palData[i] = 0; setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } else { @@ -639,36 +634,57 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } } +/** + * Short fade in. The step number is 1, the default step number is also set to 1. + */ void GraphicsManager::fadeInShort() { _fadeDefaultSpeed = 1; fadeIn(_palette, 1, (const byte *)_vesaBuffer); } +/** + * Short fade out. The step number is 1, the default step number is also set to 1. + */ void GraphicsManager::fadeOutShort() { _fadeDefaultSpeed = 1; fadeOut(_palette, 1, (const byte *)_vesaBuffer); } +/** + * Long fade in. The step number is 20, the default step number is also set to 15. + */ void GraphicsManager::fadeInLong() { _fadeDefaultSpeed = 15; fadeIn(_palette, 20, (const byte *)_vesaBuffer); } +/** + * Long fade out. The step number is 20, the default step number is also set to 15. + */ void GraphicsManager::fadeOutLong() { _fadeDefaultSpeed = 15; fadeOut(_palette, 20, (const byte *)_vesaBuffer); } -void GraphicsManager::fadeOutDefaultLength(const byte *surface) { +/** + * Fade in. The step number used is the default step number. + */ +void GraphicsManager::fadeInDefaultLength(const byte *surface) { assert(surface); - fadeOut(_palette, _fadeDefaultSpeed, surface); + fadeIn(_palette, _fadeDefaultSpeed, surface); } -void GraphicsManager::fadeInDefaultLength(const byte *surface) { +/** + * Fade out. The step number used is the default step number. + */ +void GraphicsManager::fadeOutDefaultLength(const byte *surface) { assert(surface); - fadeIn(_palette, _fadeDefaultSpeed, surface); + fadeOut(_palette, _fadeDefaultSpeed, surface); } +/** + * Fade in used by for the breakout mini-game + */ void GraphicsManager::fadeInBreakout() { setpal_vga256(_palette); lockScreen(); @@ -677,6 +693,9 @@ void GraphicsManager::fadeInBreakout() { DD_VBL(); } +/** + * Fade out used by for the breakout mini-game + */ void GraphicsManager::fateOutBreakout() { byte palette[PALETTE_EXT_BLOCK_SIZE]; -- cgit v1.2.3 From 9a089929b261e600a753b83bd2393ad7ba23612a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 3 Jan 2013 23:20:54 +0100 Subject: HOPKINS: Simplify a bit more fade out function. Reduce fade out delay time. --- engines/hopkins/graphics.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c6af572428..03181cf8ca 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -604,34 +604,28 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface fadeStep = 2; if (palette) { - for (int f = 0; f < fadeStep; f++) { - for (int32 i = 0; i < 256; i++) { - palData[i * 3 + 0] = (fadeStep - f - 1) * palette[i * 3 + 0] / (fadeStep - 1); - palData[i * 3 + 1] = (fadeStep - f - 1) * palette[i * 3 + 1] / (fadeStep - 1); - palData[i * 3 + 2] = (fadeStep - f - 1) * palette[i * 3 + 2] / (fadeStep - 1); + for (int fadeIndex = 0; fadeIndex < fadeStep; fadeIndex++) { + for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { + palData[palOffset + 0] = (fadeStep - fadeIndex - 1) * palette[palOffset + 0] / (fadeStep - 1); + palData[palOffset + 1] = (fadeStep - fadeIndex - 1) * palette[palOffset + 1] / (fadeStep - 1); + palData[palOffset + 2] = (fadeStep - fadeIndex - 1) * palette[palOffset + 2] / (fadeStep - 1); } setpal_vga256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); - _vm->_eventsManager.delay(100); + _vm->_eventsManager.delay(20); } + } - for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) - palData[i] = 0; - - setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } else { - for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) - palData[i] = 0; + // No initial palette, or end of fading + for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) + palData[i] = 0; - setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); - } + setpal_vga256(palData); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + return DD_VBL(); } /** -- cgit v1.2.3 From 668cba5bea190f7475ee6ed982cd9f028ae74421 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Jan 2013 14:17:51 +0100 Subject: HOPKINS: Fix regressions in d6f72071a42559299139fd2f162c98c7f01a0b51 --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 03181cf8ca..d777517402 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -773,7 +773,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) return; if (srcByte < kSetOffset) { - destOffset += srcP[35]; + destOffset += (byte)(srcP[0] + 35); srcByte = srcP[1]; srcP++; } else if (srcByte == k8bVal) { @@ -799,7 +799,7 @@ Video_Cont3_wVbe: memset(destSlice1P, rleValue, destLen1); srcP += 3; } else { - destLen2 = srcP[45]; + destLen2 = (byte)(srcP[0] + 45); rleValue = srcP[1]; destSlice2P = destOffset + destSurface; destOffset += destLen2; -- cgit v1.2.3 From de2c2b7bdb9b1bd3800576241ab9f320ce03bc9f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Jan 2013 16:43:44 +0100 Subject: HOPKINS: Refactor Copy_WinScan_Vbe3 --- engines/hopkins/graphics.cpp | 53 ++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d777517402..33b8bedaea 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -766,51 +766,42 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) destOffset = 0; srcP = srcData; for (;;) { - srcByte = *srcP; - if (*srcP < 222) - goto Video_Cont3_wVbe; + srcByte = srcP[0]; if (srcByte == kByteStop) return; - - if (srcByte < kSetOffset) { + if (srcByte == 211) { + destLen1 = srcP[1]; + rleValue = srcP[2]; + destSlice1P = destOffset + destSurface; + destOffset += destLen1; + memset(destSlice1P, rleValue, destLen1); + srcP += 3; + } else if (srcByte < 222) { + if (srcByte > 211) { + destLen2 = (byte)(srcP[0] + 45); + rleValue = srcP[1]; + destSlice2P = destOffset + destSurface; + destOffset += destLen2; + memset(destSlice2P, rleValue, destLen2); + srcP += 2; + } else { + destSurface[destOffset] = srcByte; + ++srcP; + ++destOffset; + } + } else if (srcByte < kSetOffset) { destOffset += (byte)(srcP[0] + 35); - srcByte = srcP[1]; srcP++; } else if (srcByte == k8bVal) { destOffset += srcP[1]; - srcByte = srcP[2]; srcP += 2; } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); - srcByte = srcP[3]; srcP += 3; } else { destOffset += READ_LE_UINT32(srcP + 1); - srcByte = srcP[5]; srcP += 5; } -Video_Cont3_wVbe: - if (srcByte > 210) { - if (srcByte == 211) { - destLen1 = srcP[1]; - rleValue = srcP[2]; - destSlice1P = destOffset + destSurface; - destOffset += destLen1; - memset(destSlice1P, rleValue, destLen1); - srcP += 3; - } else { - destLen2 = (byte)(srcP[0] + 45); - rleValue = srcP[1]; - destSlice2P = destOffset + destSurface; - destOffset += destLen2; - memset(destSlice2P, rleValue, destLen2); - srcP += 2; - } - } else { - destSurface[destOffset] = srcByte; - ++srcP; - ++destOffset; - } } } -- cgit v1.2.3 From ccef9fb3ea700663c19870cfe53660fd05320085 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Jan 2013 22:41:11 +0100 Subject: HOPKINS: Remove setModeVesa() --- engines/hopkins/graphics.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 33b8bedaea..f955b91514 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -2018,8 +2018,4 @@ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height } } -void GraphicsManager::setModeVesa() { - setGraphicalMode(640, 480); -} - } // End of namespace Hopkins -- cgit v1.2.3 From e3494642498ec5067d7beef7cc7610873404ddb3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 4 Jan 2013 23:53:54 +0100 Subject: HOPKINS: Fix regression introduced in fbd2c0e9182cf6a3ff90cf83b47347dfdd4de564 --- engines/hopkins/graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f955b91514..734e16ccaa 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -392,8 +392,9 @@ void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte * surface[i++] = v12; --v10; } while (v10); + --i; } else { - surface[i++] = v9; + surface[i] = v9; } } -- cgit v1.2.3 From 3ee199ad7a4cbd4b70064f3546c26e4cc0f4a8db Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Jan 2013 02:19:55 +0100 Subject: HOPKINS: Fix display in breakout game. Get rid of any int16 cast to make sure it's endian safe. --- engines/hopkins/graphics.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 734e16ccaa..8521e3bf53 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1240,40 +1240,25 @@ void GraphicsManager::CopyAsm(const byte *surface) { void GraphicsManager::CopyAsm16(const byte *surface) { const byte *v1; byte *v2; - int v3; - byte *v5; - uint16 *v6; + byte *v6; int v; - uint16 *v8; - int v9; byte *v10; - const byte *v11; assert(_videoPtr); v1 = surface; v2 = 30 * WinScan + (byte *)_videoPtr->pixels; - v3 = 200; - do { - v11 = v1; + for (int y = 200; y; y--) { v10 = v2; - v9 = v3; - v5 = PAL_PIXELS; - for (int v4 = 320; v4; v4--) { + for (int x = 320; x; x--) { v = 2 * *v1; - v6 = (uint16 *)(v5 + 2 * *v1); - v = *v6; - *v2 = *v6; - v2[1] = v; - v8 = (uint16 *)(WinScan + v2); - *v8 = v; - v8[1] = v; + v6 = PAL_PIXELS + v; + v2[0] = v2[2] = v2[WinScan] = v2[WinScan + 2] = v6[0]; + v2[1] = v2[3] = v2[WinScan + 1] = v2[WinScan + 3] = v6[1]; ++v1; - v2 = (byte *)v8 - WinScan + 4; + v2 += 4; } - v1 = v11 + 320; v2 = WinScan * 2 + v10; - v3 = v9 - 1; - } while (v9 != 1); + } } void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { -- cgit v1.2.3 From c9f342f4ce3fd3f1e400d1a9ea35b2e1868119e4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Jan 2013 13:10:58 +0100 Subject: HOPKINS: Remove 8b CopyAsm, rename the 16b one --- engines/hopkins/graphics.cpp | 46 +++++++------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8521e3bf53..5e45098998 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -170,7 +170,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { max_x = 320; lockScreen(); - CopyAsm16(_vesaBuffer); + copy16bToSurfaceScaleX2(_vesaBuffer); unlockScreen(); fadeInBreakout(); @@ -683,7 +683,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { void GraphicsManager::fadeInBreakout() { setpal_vga256(_palette); lockScreen(); - CopyAsm16(_vesaBuffer); + copy16bToSurfaceScaleX2(_vesaBuffer); unlockScreen(); DD_VBL(); } @@ -698,7 +698,7 @@ void GraphicsManager::fateOutBreakout() { setpal_vga256(palette); lockScreen(); - CopyAsm16(_vesaBuffer); + copy16bToSurfaceScaleX2(_vesaBuffer); unlockScreen(); DD_VBL(); } @@ -1202,42 +1202,10 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i addVesaSegment(xp, yp, xp + width, yp + height); } -void GraphicsManager::CopyAsm(const byte *surface) { - const byte *srcP; - byte srcByte; - byte *destP; - byte *dest1P; - byte *dest2P; - byte *dest3P; - byte *destPitch; - const byte *srcPitch; - - assert(_videoPtr); - srcP = surface; - srcByte = 30 * WinScan; - destP = (byte *)_videoPtr->pixels + 30 * WinScan; - for (int yCtr = 200; yCtr != 0; yCtr--) { - srcPitch = srcP; - destPitch = destP; - for (int xCtr = 320; xCtr != 0; xCtr--) { - srcByte = *srcP; - *destP = *srcP; - dest1P = WinScan + destP; - *dest1P = srcByte; - dest2P = dest1P - WinScan + 1; - *dest2P = srcByte; - dest3P = WinScan + dest2P; - *dest3P = srcByte; - destP = dest3P - WinScan + 1; - ++srcP; - } - - srcP = srcPitch + 320; - destP = WinScan + WinScan + destPitch; - } -} - -void GraphicsManager::CopyAsm16(const byte *surface) { +/** + * Copy to surface to video buffer, scale 2x. + */ +void GraphicsManager::copy16bToSurfaceScaleX2(const byte *surface) { const byte *v1; byte *v2; byte *v6; -- cgit v1.2.3 From 45020d301289168d9269c4969dd1489e5e51ef54 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 5 Jan 2013 16:02:25 +0100 Subject: HOPKINS: Refactor copy16bFromSurfaceScaleX2 --- engines/hopkins/graphics.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 5e45098998..3820dbb5c1 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -170,7 +170,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { max_x = 320; lockScreen(); - copy16bToSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); fadeInBreakout(); @@ -683,7 +683,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { void GraphicsManager::fadeInBreakout() { setpal_vga256(_palette); lockScreen(); - copy16bToSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); DD_VBL(); } @@ -698,7 +698,7 @@ void GraphicsManager::fateOutBreakout() { setpal_vga256(palette); lockScreen(); - copy16bToSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); DD_VBL(); } @@ -1203,29 +1203,26 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i } /** - * Copy to surface to video buffer, scale 2x. + * Copy from surface to video buffer, scale 2x. */ -void GraphicsManager::copy16bToSurfaceScaleX2(const byte *surface) { - const byte *v1; - byte *v2; - byte *v6; - int v; - byte *v10; +void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { + byte *palPtr; + int curPixel; assert(_videoPtr); - v1 = surface; - v2 = 30 * WinScan + (byte *)_videoPtr->pixels; + const byte *curSurface = surface; + byte *destPtr = 30 * WinScan + (byte *)_videoPtr->pixels; for (int y = 200; y; y--) { - v10 = v2; + byte *oldDestPtr = destPtr; for (int x = 320; x; x--) { - v = 2 * *v1; - v6 = PAL_PIXELS + v; - v2[0] = v2[2] = v2[WinScan] = v2[WinScan + 2] = v6[0]; - v2[1] = v2[3] = v2[WinScan + 1] = v2[WinScan + 3] = v6[1]; - ++v1; - v2 += 4; + curPixel = 2 * *curSurface; + palPtr = PAL_PIXELS + curPixel; + destPtr[0] = destPtr[2] = destPtr[WinScan] = destPtr[WinScan + 2] = palPtr[0]; + destPtr[1] = destPtr[3] = destPtr[WinScan + 1] = destPtr[WinScan + 3] = palPtr[1]; + ++curSurface; + destPtr += 4; } - v2 = WinScan * 2 + v10; + destPtr = WinScan * 2 + oldDestPtr; } } -- cgit v1.2.3 From 117d99f22b5d90b411055b0657036f2932e6ff82 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Jan 2013 11:33:12 +0100 Subject: HOPKINS: Remove a GOTO in Copy_WinScan_Vbe --- engines/hopkins/graphics.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3820dbb5c1..03617fc08f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1856,24 +1856,23 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { srcPtr = src; for (;;) { byteVal = *srcPtr; - if (*srcPtr < kByteStop) - goto Video_Cont_wVbe; if (byteVal == kByteStop) return; - if (byteVal == k8bVal) { - destOffset += srcPtr[1]; - byteVal = srcPtr[2]; - srcPtr += 2; - } else if (byteVal == k16bVal) { - destOffset += READ_LE_UINT16(srcPtr + 1); - byteVal = srcPtr[3]; - srcPtr += 3; - } else { - destOffset += READ_LE_UINT32(srcPtr + 1); - byteVal = srcPtr[5]; - srcPtr += 5; + if (*srcPtr > kByteStop) { + if (byteVal == k8bVal) { + destOffset += srcPtr[1]; + byteVal = srcPtr[2]; + srcPtr += 2; + } else if (byteVal == k16bVal) { + destOffset += READ_LE_UINT16(srcPtr + 1); + byteVal = srcPtr[3]; + srcPtr += 3; + } else { + destOffset += READ_LE_UINT32(srcPtr + 1); + byteVal = srcPtr[5]; + srcPtr += 5; + } } -Video_Cont_wVbe: dest[destOffset] = byteVal; ++srcPtr; ++destOffset; -- cgit v1.2.3 From a91eaeb4f78608bf511b5d3c39f54646263365aa Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 6 Jan 2013 23:12:34 +0100 Subject: HOPKINS: Remove uint16 casting in m_scroll16 in order to avoid endian issue --- engines/hopkins/graphics.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 03617fc08f..057d120405 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -422,19 +422,22 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destX * 2 + WinScan * destY); + byte *destP = (byte *)_videoPtr->pixels + destX * 2 + WinScan * destY; for (int yp = 0; yp < height; ++yp) { // Copy over the line, using the source pixels as lookups into the pixels palette const byte *lineSrcP = srcP; - uint16 *lineDestP = destP; - - for (int xp = 0; xp < width; ++xp) - *lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2]; + byte *lineDestP = destP; + for (int xp = 0; xp < width; ++xp) { + lineDestP[0] = PAL_PIXELS[lineSrcP[0] * 2]; + lineDestP[1] = PAL_PIXELS[(lineSrcP[0] * 2) + 1]; + lineDestP += 2; + lineSrcP++; + } // Move to the start of the next line srcP += _lineNbr2; - destP += WinScan / 2; + destP += WinScan; } unlockScreen(); -- cgit v1.2.3 From 9b8b1d63318546d9f4196730025ed00abce5ebcc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 00:30:21 +0100 Subject: HOPKINS: Simplify Copy_vga16, get rid of unsafe uint16 casts --- engines/hopkins/graphics.cpp | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 057d120405..48d68aeb8b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -450,14 +450,13 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width int yNext; int xCtr; const byte *palette; - int pixelWord; int yCtr; const byte *srcCopyP; byte *destCopyP; assert(_videoPtr); srcP = xs + _lineNbr2 * ys + surface; - destP = destX + destX + WinScan * destY + (byte *)_videoPtr->pixels; + destP = (byte *)_videoPtr->pixels + destX + destX + WinScan * destY; yNext = height; Agr_x = 0; Agr_y = 0; @@ -473,16 +472,16 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width Agr_x = 0; do { - pixelWord = *(const uint16 *)(palette + 2 * *srcP); - *(uint16 *)destP = pixelWord; - ++srcP; + destP[0] = palette[2 * srcP[0]]; + destP[1] = palette[(2 * srcP[0]) + 1]; destP += 2; if ((unsigned int)Agr_x >= 100) { Agr_x -= 100; - *(uint16 *)destP = pixelWord; + destP[0] = palette[2 * srcP[0]]; + destP[1] = palette[(2 * srcP[0]) + 1]; destP += 2; } - + ++srcP; --xCtr; } while (xCtr); @@ -506,23 +505,18 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - const byte *srcP; - uint16 *destP; int yCount; int xCount; int xCtr; const byte *palette; - const uint16 *tempSrcP; - uint16 srcByte; - uint16 *tempDestP; int savedXCount; - uint16 *loopDestP; + byte *loopDestP; const byte *loopSrcP; int yCtr; assert(_videoPtr); - srcP = xp + 320 * yp + surface; - destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)_videoPtr->pixels); + const byte *srcP = surface + xp + 320 * yp; + byte *destP = (byte *)_videoPtr->pixels + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; yCount = height; xCount = width; @@ -535,21 +529,15 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, palette = PAL_PIXELS; do { - tempSrcP = (const uint16 *)(palette + 2 * *srcP); - srcByte = *tempSrcP; - *destP = *tempSrcP; - *(destP + 1) = srcByte; - - tempDestP = (uint16 *)((byte *)destP + WinScan); - *tempDestP = srcByte; - *(tempDestP + 1) = srcByte; + destP[0] = destP[2] = destP[WinScan] = destP[WinScan + 2] = palette[2 * srcP[0]]; + destP[1] = destP[3] = destP[WinScan + 1] = destP[WinScan + 3] = palette[(2 * srcP[0]) + 1]; ++srcP; - destP = (uint16 *)((byte *)tempDestP - WinScan + 4); + destP += 4; --xCtr; } while (xCtr); xCount = savedXCount; - destP = (uint16 *)((byte *)loopDestP + WinScan * 2); + destP = loopDestP + WinScan * 2; srcP = loopSrcP + 320; yCount = yCtr - 1; } while (yCtr != 1); -- cgit v1.2.3 From b7f5c7ae8d9b7aad15dc9f43f82860f74e4abb00 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 01:03:58 +0100 Subject: HOPKINS: More 16b refactoring --- engines/hopkins/graphics.cpp | 78 ++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 36 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 48d68aeb8b..3c07d5946c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -727,7 +727,7 @@ void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - WRITE_LE_UINT16(&SD_PIXELS[2 * idx], mapRGB(*srcP, *(srcP + 1), *(srcP + 2))); + WRITE_LE_UINT16(&SD_PIXELS[2 * idx], mapRGB(srcP[0], srcP[1], srcP[2])); } } @@ -803,7 +803,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { assert(_videoPtr); for (;;) { - byte srcByte = *srcP; + byte srcByte = srcP[0]; if (srcByte >= 222) { if (srcByte == kByteStop) return; @@ -834,28 +834,34 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { if (srcByte == 211) { int pixelCount = srcP[1]; int pixelIndex = srcP[2]; - uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); - uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); + byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; destOffset += pixelCount; - while (pixelCount--) - *destP++ = pixelValue; + while (pixelCount--) { + destP[0] = PAL_PIXELS[2 * pixelIndex]; + destP[1] = PAL_PIXELS[(2 * pixelIndex) + 1]; + destP += 2; + } srcP += 3; } else { int pixelCount = srcByte - 211; int pixelIndex = srcP[1]; - uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2); - uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex); + byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; destOffset += pixelCount; - while (pixelCount--) - *destP++ = pixelValue; + while (pixelCount--) { + destP[0] = PAL_PIXELS[2 * pixelIndex]; + destP[1] = PAL_PIXELS[(2 * pixelIndex) + 1]; + destP += 2; + } srcP += 2; } } else { - *((uint16 *)_videoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte); + byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + destP[0] = PAL_PIXELS[2 * srcByte]; + destP[1] = PAL_PIXELS[(2 * srcByte) + 1]; ++srcP; ++destOffset; } @@ -863,33 +869,31 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { - int destOffset; - const byte *srcP; - byte pixelIndex; + byte srcByte; + int destOffset = 0; + const byte *srcP = srcData; - destOffset = 0; - srcP = srcData; for (;;) { - pixelIndex = *srcP; - if (*srcP < kByteStop) - goto Video_Cont_Vbe16a; - if (pixelIndex == kByteStop) + srcByte = srcP[0]; + if (srcByte == kByteStop) return; - if (pixelIndex == k8bVal) { - destOffset += srcP[1]; - pixelIndex = srcP[2]; - srcP += 2; - } else if (pixelIndex == k16bVal) { - destOffset += READ_LE_UINT16(srcP + 1); - pixelIndex = srcP[3]; - srcP += 3; - } else { - destOffset += READ_LE_UINT32(srcP + 1); - pixelIndex = srcP[5]; - srcP += 5; + if (srcP[0] > kByteStop) { + if (srcByte == k8bVal) { + destOffset += srcP[1]; + srcByte = srcP[2]; + srcP += 2; + } else if (srcByte == k16bVal) { + destOffset += READ_LE_UINT16(srcP + 1); + srcByte = srcP[3]; + srcP += 3; + } else { + destOffset += READ_LE_UINT32(srcP + 1); + srcByte = srcP[5]; + srcP += 5; + } } -Video_Cont_Vbe16a: - WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex)); + + WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); ++srcP; ++destOffset; } @@ -915,7 +919,8 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int destP += width; } else if (width & 2) { for (i = width >> 1; i; --i) { - *(uint16 *)destP = *(const uint16 *)srcP; + destP[0] = srcP[0]; + destP[1] = srcP[1]; srcP += 2; destP += 2; } @@ -1235,7 +1240,8 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in destP += width; } else if (width & 2) { for (i = width >> 1; i; --i) { - *(uint16 *)destP = *(const uint16 *)srcP; + destP[0] = srcP[0]; + destP[1] = srcP[1]; srcP += 2; destP += 2; } -- cgit v1.2.3 From 7c815f2ca709c68cab5cfdb531e2740f92541794 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 08:02:19 +0100 Subject: HOPKINS: Some refactoring in ComputerManager --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3c07d5946c..88b576ac00 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1739,7 +1739,7 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, for (int xCtr = spriteWidth; xCtr; xCtr--) { destByte = *spritePixelsP; if (*spritePixelsP) { - if (destByte == (byte)-4) + if (destByte == 252) destByte = colour; *destP = destByte; } -- cgit v1.2.3 From b26f25455f642e31762c3ab2fb2e894b93044688 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 08:33:55 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/graphics.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 88b576ac00..d8d44a4641 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -557,7 +557,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0); // Set current palette to black - setpal_vga256(palData2); + setPaletteVGA256(palData2); // Loop through fading in the palette for (int fadeIndex = 0; fadeIndex < fadeStep; ++fadeIndex) { @@ -568,7 +568,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) } // Set the transition palette and refresh the screen - setpal_vga256(palData2); + setPaletteVGA256(palData2); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); @@ -577,7 +577,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) } // Set the final palette - setpal_vga256(palette); + setPaletteVGA256(palette); // Refresh the screen m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); @@ -603,7 +603,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface palData[palOffset + 2] = (fadeStep - fadeIndex - 1) * palette[palOffset + 2] / (fadeStep - 1); } - setpal_vga256(palData); + setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); @@ -615,7 +615,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) palData[i] = 0; - setpal_vga256(palData); + setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); return DD_VBL(); } @@ -672,7 +672,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { * Fade in used by for the breakout mini-game */ void GraphicsManager::fadeInBreakout() { - setpal_vga256(_palette); + setPaletteVGA256(_palette); lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); @@ -686,7 +686,7 @@ void GraphicsManager::fateOutBreakout() { byte palette[PALETTE_EXT_BLOCK_SIZE]; memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); - setpal_vga256(palette); + setPaletteVGA256(palette); lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); @@ -694,11 +694,11 @@ void GraphicsManager::fateOutBreakout() { DD_VBL(); } -void GraphicsManager::setpal_vga256(const byte *palette) { +void GraphicsManager::setPaletteVGA256(const byte *palette) { changePalette(palette); } -void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) { +void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); @@ -1841,7 +1841,7 @@ void GraphicsManager::NB_SCREEN() { } void GraphicsManager::SHOW_PALETTE() { - setpal_vga256(_palette); + setPaletteVGA256(_palette); } void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { -- cgit v1.2.3 From 30eeb9163d43ab3c0cd78dbc9f2b249b58699a0d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 13:24:04 +0200 Subject: HOPKINS: Get rid of more unused/unnecessary globals --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d8d44a4641..828fc2d3ad 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1823,8 +1823,8 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_objectsManager._changeVerbFl = false; } -void GraphicsManager::NB_SCREEN() { - if (!_vm->_globals.NECESSAIRE) +void GraphicsManager::NB_SCREEN(bool initPalette) { + if (initPalette) initColorTable(50, 65, _palette); if (_lineNbr == SCREEN_WIDTH) -- cgit v1.2.3 From bd865d9741878b56a86c1389e66dfdee24ba1e39 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 16:17:27 +0200 Subject: HOPKINS: Remove static game directory configuration options Also, remove the unused VGA folder. This is the first step to remove constructFilename() and associated functions. --- engines/hopkins/graphics.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 828fc2d3ad..f66b4882a8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -163,7 +163,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); clearScreen(); unlockScreen(); - _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename("BUFFER", file); A_PCX320(_vesaScreen, _vm->_globals._curFilename, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); @@ -184,7 +184,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename("BUFFER", file); if (!f.open(_vm->_globals._curFilename)) error("loadScreen - %s", file.c_str()); @@ -301,16 +301,16 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource - _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES"); + _vm->_fileManager.constructFilename("BUFFER", "PIC.RES"); if (!f.open(_vm->_globals._curFilename)) - error("(nom)Erreur en cours de lecture."); + error("Error opening PIC.RES."); f.seek(_vm->_globals._catalogPos); } else { // Load stand alone PCX file - _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename("BUFFER", file); if (!f.open(_vm->_globals._curFilename)) - error("(nom)Erreur en cours de lecture."); + error("Error opening PCX %s.", file.c_str()); } // Decode the PCX @@ -1767,7 +1767,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { byte *ptr = _vm->_fileManager.searchCat(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename("LINK", filename); ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } if (!mode) { @@ -1776,9 +1776,9 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (!_vm->_globals.NOSPRECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename("LINK", filename); } else { - _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); + _vm->_fileManager.constructFilename("LINK", "RES_SLI.RES"); } _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } @@ -1814,7 +1814,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename("LINK", filename); dataP = _vm->_fileManager.loadFile(_vm->_globals._curFilename); _vm->_globals.COUCOU = dataP; } -- cgit v1.2.3 From e57c82f9dae625aec53530e6e1e8e06d6a13b533 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 7 Jan 2013 19:43:24 +0200 Subject: HOPKINS: Get rid of the NOSPRECRAN global variable --- engines/hopkins/graphics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f66b4882a8..0021f3539e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1753,16 +1753,16 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, } // Init Screen -void GraphicsManager::INI_ECRAN(const Common::String &file) { - OPTI_INI(file, 0); +void GraphicsManager::INI_ECRAN(const Common::String &file, bool initializeScreen) { + OPTI_INI(file, 0, initializeScreen); } // Init Screen 2 -void GraphicsManager::INI_ECRAN2(const Common::String &file) { - OPTI_INI(file, 2); +void GraphicsManager::INI_ECRAN2(const Common::String &file, bool initializeScreen) { + OPTI_INI(file, 2, initializeScreen); } -void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { +void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; byte *ptr = _vm->_fileManager.searchCat(filename, 1); @@ -1773,7 +1773,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { if (!mode) { filename = file + ".spr"; _vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN); - if (!_vm->_globals.NOSPRECRAN) { + if (initializeScreen) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { _vm->_fileManager.constructFilename("LINK", filename); -- cgit v1.2.3 From 495ecaafbcf1620901d270a65394ca312f2b5a37 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 7 Jan 2013 23:56:39 +0100 Subject: HOPKINS: Remove global filename and constructFilename --- engines/hopkins/graphics.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0021f3539e..aaf5962cac 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -163,8 +163,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); clearScreen(); unlockScreen(); - _vm->_fileManager.constructFilename("BUFFER", file); - A_PCX320(_vesaScreen, _vm->_globals._curFilename, _palette); + A_PCX320(_vesaScreen, file, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); max_x = 320; @@ -184,8 +183,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { - _vm->_fileManager.constructFilename("BUFFER", file); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open(file)) error("loadScreen - %s", file.c_str()); f.seek(0, SEEK_END); @@ -301,15 +299,12 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource - _vm->_fileManager.constructFilename("BUFFER", "PIC.RES"); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open("PIC.RES")) error("Error opening PIC.RES."); f.seek(_vm->_globals._catalogPos); - } else { // Load stand alone PCX file - _vm->_fileManager.constructFilename("BUFFER", file); - if (!f.open(_vm->_globals._curFilename)) + if (!f.open(file)) error("Error opening PCX %s.", file.c_str()); } @@ -1767,8 +1762,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia byte *ptr = _vm->_fileManager.searchCat(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.constructFilename("LINK", filename); - ptr = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + ptr = _vm->_fileManager.loadFile(filename); } if (!mode) { filename = file + ".spr"; @@ -1776,11 +1770,10 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia if (initializeScreen) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_fileManager.constructFilename("LINK", filename); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(filename); } else { - _vm->_fileManager.constructFilename("LINK", "RES_SLI.RES"); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile("RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals._curFilename); } } if (ptr[0] != 'I' || ptr[1] != 'N' || ptr[2] != 'I') { @@ -1814,8 +1807,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.constructFilename("LINK", filename); - dataP = _vm->_fileManager.loadFile(_vm->_globals._curFilename); + dataP = _vm->_fileManager.loadFile(filename); _vm->_globals.COUCOU = dataP; } } -- cgit v1.2.3 From 2b1b6689086e73b77041ec36a8337f044486ad73 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 8 Jan 2013 13:39:14 +0200 Subject: HOPKINS: Get rid of the NO_VISU global variable --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index aaf5962cac..93c96ab1d9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1177,7 +1177,7 @@ void GraphicsManager::displayVesaSegment() { unlockScreen(); } -void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx) { +void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { int height, width; width = _vm->_objectsManager.getWidth(objectData, idx); @@ -1189,7 +1189,7 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i Sprite_Vesa(_vesaBuffer, objectData, xp + 300, yp + 300, idx); Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); } - if (!_vm->_globals.NO_VISU) + if (addSegment) addVesaSegment(xp, yp, xp + width, yp + height); } @@ -1625,7 +1625,7 @@ Aff_Zoom_Larg_Cont1: /** * Fast Display */ -void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex) { +void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment) { int width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); int height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); @@ -1636,7 +1636,7 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp Sprite_Vesa(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex); Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); } - if (!_vm->_globals.NO_VISU) + if (addSegment) addVesaSegment(xp, yp, xp + width, yp + height); } -- cgit v1.2.3 From 0bf6d54d6bbddcb490aecdeaf6844957ee5faa56 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 9 Jan 2013 08:05:58 +0100 Subject: HOPKINS: Simplify absolute values in LinesManager --- engines/hopkins/graphics.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 93c96ab1d9..2b5eef98d7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -48,7 +48,7 @@ GraphicsManager::GraphicsManager() { _lineNbr2 = 0; Agr_x = Agr_y = 0; - Agr_Flag_x = Agr_Flag_y = 0; + Agr_Flag_x = Agr_Flag_y = false; _fadeDefaultSpeed = 15; FADE_LINUX = 0; _skipVideoLockFl = false; @@ -455,7 +455,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = height; Agr_x = 0; Agr_y = 0; - Agr_Flag_y = 0; + Agr_Flag_y = false; do { for (;;) { @@ -483,17 +483,17 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr; srcP = srcCopyP; destP = WinScan + destCopyP; - if (Agr_Flag_y == 1) + if (Agr_Flag_y) break; if ((unsigned int)Agr_y < 100) break; Agr_y -= 100; - Agr_Flag_y = 1; + Agr_Flag_y = true; } - Agr_Flag_y = 0; + Agr_Flag_y = false; srcP = _lineNbr2 + srcCopyP; yNext = yCtr - 1; } while (yCtr != 1); @@ -1313,8 +1313,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Compteur_y = 0; Agr_x = 0; Agr_y = 0; - Agr_Flag_y = 0; - Agr_Flag_x = 0; + Agr_Flag_y = false; + Agr_Flag_x = false; _width = spriteWidth; int v20 = zoomIn(spriteWidth, zoom2); int v22 = zoomIn(spriteHeight1, zoom2); @@ -1340,12 +1340,10 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (v20 > (uint16)clip_x1) { int v32 = v20 - (uint16)clip_x1; v29 -= v32; - int v62 = v22; int v33 = 0; while (zoomIn(v33 + 1, zoom2) < v32) ; int v34 = v33; - v22 = v62; spritePixelsP += v34; v20 = (uint16)clip_x1; } @@ -1355,7 +1353,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v63 = v22; byte *v53 = v29; v46 = spritePixelsP; - Agr_Flag_x = 0; + Agr_Flag_x = false; Agr_x = 0; for (int v35 = v20; v35; v35--) { for (;;) { @@ -1367,14 +1365,14 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_x = zoom2 + Agr_x; if ((uint16)Agr_x < 100) break; - Agr_x = Agr_x - 100; + Agr_x -= 100; --spritePixelsP; - Agr_Flag_x = 1; + Agr_Flag_x = true; --v35; if (!v35) goto R_Aff_Zoom_Larg_Cont1; } - Agr_Flag_x = 0; + Agr_Flag_x = false; } R_Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v46; @@ -1384,14 +1382,14 @@ R_Aff_Zoom_Larg_Cont1: Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 100) break; - Agr_y = Agr_y - 100; + Agr_y -= 100; spritePixelsP = v46; - Agr_Flag_y = 1; + Agr_Flag_y = true; v22 = v63 - 1; if (v63 == 1) return; } - Agr_Flag_y = 0; + Agr_Flag_y = false; v22 = v63 - 1; } while (v63 != 1); } else { @@ -1431,7 +1429,7 @@ R_Aff_Zoom_Larg_Cont1: byte *v51 = dest1P; v45 = spritePixelsP; int v28 = v20; - Agr_Flag_x = 0; + Agr_Flag_x = false; Agr_x = 0; do { for (;;) { @@ -1445,12 +1443,12 @@ R_Aff_Zoom_Larg_Cont1: break; Agr_x = Agr_x - 100; --spritePixelsP; - Agr_Flag_x = 1; + Agr_Flag_x = true; --v28; if (!v28) goto Aff_Zoom_Larg_Cont1; } - Agr_Flag_x = 0; + Agr_Flag_x = false; --v28; } while (v28); Aff_Zoom_Larg_Cont1: @@ -1462,12 +1460,12 @@ Aff_Zoom_Larg_Cont1: break; Agr_y = Agr_y - 100; spritePixelsP = v45; - Agr_Flag_y = 1; + Agr_Flag_y = true; v22 = v60 - 1; if (v60 == 1) return; } - Agr_Flag_y = 0; + Agr_Flag_y = false; v22 = v60 - 1; } while (v60 != 1); } -- cgit v1.2.3 From b7abcf2bfb9f98330d6d9dae2c25210d14093e3d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 17 Jan 2013 00:18:53 +0100 Subject: HOPKINS: Fix loops on zoom in Affiche_perfect. Thanks fuzzie for the help! --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2b5eef98d7..7f6d7223a7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1324,7 +1324,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if ((uint16)clip_y >= v22) return; int v30 = 0; - while (zoomIn(v30 + 1, zoom2) < (uint16)clip_y) + while (zoomIn(++v30, zoom2) < (uint16)clip_y) ; spritePixelsP += _width * v30; v29 += _lineNbr2 * (uint16)clip_y; @@ -1341,7 +1341,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v32 = v20 - (uint16)clip_x1; v29 -= v32; int v33 = 0; - while (zoomIn(v33 + 1, zoom2) < v32) + while (zoomIn(++v33, zoom2) < v32) ; int v34 = v33; spritePixelsP += v34; @@ -1400,7 +1400,7 @@ R_Aff_Zoom_Larg_Cont1: int v49 = v20; int v23 = 0; int v24 = (uint16)clip_y; - while (zoomIn(v23 + 1, zoom2) < v24) + while (zoomIn(++v23, zoom2) < v24) ; v20 = v49; spritePixelsP += _width * v23; @@ -1413,7 +1413,7 @@ R_Aff_Zoom_Larg_Cont1: if ((uint16)clip_x >= v20) return; int v26 = 0; - while (zoomIn(v26 + 1, zoom2) < (uint16)clip_x) + while (zoomIn(++v26, zoom2) < (uint16)clip_x) ; spritePixelsP += v26; dest1P += (uint16)clip_x; -- cgit v1.2.3 From 523aa825634784d9c25f16ccca118030565a8344 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 00:56:19 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/graphics.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7f6d7223a7..3ad8d95061 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -42,9 +42,9 @@ GraphicsManager::GraphicsManager() { _lineNbr = 0; _videoPtr = NULL; _scrollOffset = 0; - SCROLL = 0; + _scrollPosX = 0; _largeScreenFl = false; - OLD_SCROLL = 0; + _oldScrollPosX = 0; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -52,7 +52,7 @@ GraphicsManager::GraphicsManager() { _fadeDefaultSpeed = 15; FADE_LINUX = 0; _skipVideoLockFl = false; - no_scroll = 0; + _scrollStatus = 0; min_x = 0; min_y = 20; max_x = SCREEN_WIDTH * 2; @@ -82,7 +82,7 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { if (_vm->getIsDemo()) { if (_vm->getPlatform() == Common::kPlatformLinux) - // CHECKME: Should be 0? + // CHECKME: Should be false? MANU_SCROLL = true; else MANU_SCROLL = false; @@ -194,8 +194,8 @@ void GraphicsManager::loadScreen(const Common::String &file) { scrollScreen(0); A_PCX640_480(_vesaScreen, file, _palette, flag); - SCROLL = 0; - OLD_SCROLL = 0; + _scrollPosX = 0; + _oldScrollPosX = 0; clearPalette(); if (!_largeScreenFl) { @@ -246,7 +246,7 @@ void GraphicsManager::scrollScreen(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); _vm->_eventsManager._startPos.x = result; _scrollOffset = result; - SCROLL = result; + _scrollPosX = result; } void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { -- cgit v1.2.3 From 3878138d8f290fc42fa45b80f9a9b03e824d7584 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 11:28:39 +0100 Subject: HOPKINS: Some renaming in GraphicsManager and HopkinsEngine --- engines/hopkins/graphics.cpp | 222 +++++++++++++++++++++---------------------- 1 file changed, 108 insertions(+), 114 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3ad8d95061..8e54bc1cfb 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -35,8 +35,8 @@ namespace Hopkins { GraphicsManager::GraphicsManager() { _lockCounter = 0; - SDL_MODEYES = false; - XSCREEN = YSCREEN = 0; + _initGraphicsFl = false; + _screenWidth = _screenHeight = 0; WinScan = 0; PAL_PIXELS = NULL; _lineNbr = 0; @@ -53,17 +53,16 @@ GraphicsManager::GraphicsManager() { FADE_LINUX = 0; _skipVideoLockFl = false; _scrollStatus = 0; - min_x = 0; - min_y = 20; - max_x = SCREEN_WIDTH * 2; - max_y = SCREEN_HEIGHT - 20; - clip_x = clip_y = 0; + _minX = 0; + _minY = 20; + _maxX = SCREEN_WIDTH * 2; + _maxY = SCREEN_HEIGHT - 20; + _posXClipped = _posYClipped = 0; clip_x1 = clip_y1 = 0; - clip_flag = false; + _clipFl = false; Red_x = Red_y = 0; Red = 0; _width = 0; - Compteur_y = 0; spec_largeur = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); @@ -94,7 +93,7 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { } void GraphicsManager::setGraphicalMode(int width, int height) { - if (!SDL_MODEYES) { + if (!_initGraphicsFl) { Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(width, height, true, &pixelFormat16); @@ -103,17 +102,17 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _videoPtr = NULL; - XSCREEN = width; - YSCREEN = height; + _screenWidth = width; + _screenHeight = height; WinScan = width * 2; // Refactor me PAL_PIXELS = SD_PIXELS; _lineNbr = width; - SDL_MODEYES = true; + _initGraphicsFl = true; } else { - error("Called SET_MODE multiple times"); + error("setGraphicalMode called multiple times"); } } @@ -143,7 +142,7 @@ void GraphicsManager::unlockScreen() { */ void GraphicsManager::clearScreen() { assert(_videoPtr); - _videoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0); + _videoPtr->fillRect(Common::Rect(0, 0, _screenWidth, _screenHeight), 0); } /** @@ -163,10 +162,10 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); clearScreen(); unlockScreen(); - A_PCX320(_vesaScreen, file, _palette); + loadPCX320(_vesaScreen, file, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); SCANLINE(320); - max_x = 320; + _maxX = 320; lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); @@ -192,7 +191,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { } scrollScreen(0); - A_PCX640_480(_vesaScreen, file, _palette, flag); + loadPCX640(_vesaScreen, file, _palette, flag); _scrollPosX = 0; _oldScrollPosX = 0; @@ -200,14 +199,14 @@ void GraphicsManager::loadScreen(const Common::String &file) { if (!_largeScreenFl) { SCANLINE(SCREEN_WIDTH); - max_x = SCREEN_WIDTH; + _maxX = SCREEN_WIDTH; lockScreen(); clearScreen(); m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } else { SCANLINE(SCREEN_WIDTH * 2); - max_x = SCREEN_WIDTH * 2; + _maxX = SCREEN_WIDTH * 2; lockScreen(); clearScreen(); unlockScreen(); @@ -290,7 +289,7 @@ void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { } } -void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { +void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { Common::File f; Graphics::PCXDecoder pcxDecoder; @@ -325,7 +324,7 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by f.close(); } -void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte *palette) { +void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte *palette) { size_t filesize; int v4; size_t v5; @@ -898,7 +897,6 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int const byte *srcP; byte *destP; int rowCount; - int i; int rowCount2; // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within @@ -913,7 +911,7 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int srcP += width; destP += width; } else if (width & 2) { - for (i = width >> 1; i; --i) { + for (int i = width >> 1; i; --i) { destP[0] = srcP[0]; destP[1] = srcP[1]; srcP += 2; @@ -935,9 +933,9 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, for (int i = spriteIndex; i; --i) spriteP += READ_LE_UINT32(spriteP) + 16; - clip_x = 0; - clip_y = 0; - clip_flag = false; + _posXClipped = 0; + _posYClipped = 0; + _clipFl = false; spriteP += 4; int width = READ_LE_UINT16(spriteP); @@ -946,44 +944,44 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Clip X clip_x1 = width; - if ((xp + width) <= (min_x + 300)) + if ((xp + width) <= (_minX + 300)) return; - if (xp < (min_x + 300)) { - clip_x = min_x + 300 - xp; - clip_flag = true; + if (xp < (_minX + 300)) { + _posXClipped = _minX + 300 - xp; + _clipFl = true; } // Clip Y // TODO: This is weird, but it's that way in the original. Original game bug? if ((yp + height) <= height) return; - if (yp < (min_y + 300)) { - clip_y = min_y + 300 - yp; - clip_flag = true; + if (yp < (_minY + 300)) { + _posYClipped = _minY + 300 - yp; + _clipFl = true; } // Clip X1 - if (xp >= (max_x + 300)) + if (xp >= (_maxX + 300)) return; - if ((xp + width) > (max_x + 300)) { - int xAmount = width + 10 - (xp + width - (max_x + 300)); + if ((xp + width) > (_maxX + 300)) { + int xAmount = width + 10 - (xp + width - (_maxX + 300)); if (xAmount <= 10) return; clip_x1 = xAmount - 10; - clip_flag = true; + _clipFl = true; } // Clip Y1 - if (yp >= (max_y + 300)) + if (yp >= (_maxY + 300)) return; - if ((yp + height) > (max_y + 300)) { - int yAmount = height + 10 - (yp + height - (max_y + 300)); + if ((yp + height) > (_maxY + 300)) { + int yAmount = height + 10 - (yp + height - (_maxY + 300)); if (yAmount <= 10) return; clip_y1 = yAmount - 10; - clip_flag = true; + _clipFl = true; } // Sprite display @@ -999,7 +997,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, byte *destP = surface + (yp - 300) * _lineNbr2 + (xp - 300); // Handling for clipped versus non-clipped - if (clip_flag) { + if (_clipFl) { // Clipped version for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) { byte *tempDestP = destP; @@ -1014,7 +1012,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, if (byteVal == 254) { // Copy pixel range for (int xv = 0; xv < width; ++xv, ++xc, ++spriteP, ++tempDestP) { - if (clip_y == 0 && xc >= clip_x && xc < clip_x1) + if (_posYClipped == 0 && xc >= _posXClipped && xc < clip_x1) *tempDestP = *spriteP; } } else { @@ -1024,8 +1022,8 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, } } - if (clip_y > 0) - --clip_y; + if (_posYClipped > 0) + --_posYClipped; srcP += 3; } } else { @@ -1100,14 +1098,14 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { tempX = x1; addFlag = true; - if (x2 > max_x) - x2 = max_x; - if (y2 > max_y) - y2 = max_y; - if (x1 < min_x) - tempX = min_x; - if (y1 < min_y) - y1 = min_y; + if (x2 > _maxX) + x2 = _maxX; + if (y2 > _maxY) + y2 = _maxY; + if (x1 < _minX) + tempX = _minX; + if (y1 < _minY) + y1 = _minY; if (_vm->_globals.NBBLOC > 1) { int16 blocIndex = 0; @@ -1293,24 +1291,23 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); int spriteHeight1 = spriteHeight2; spritePixelsP = spriteSizeP + 10; - clip_x = 0; - clip_y = 0; + _posXClipped = 0; + _posYClipped = 0; clip_x1 = 0; clip_y1 = 0; - if ((xp300 <= min_x) || (yp300 <= min_y) || (xp300 >= max_x + 300) || (yp300 >= max_y + 300)) + if ((xp300 <= _minX) || (yp300 <= _minY) || (xp300 >= _maxX + 300) || (yp300 >= _maxY + 300)) return; - if ((uint16)xp300 < (uint16)(min_x + 300)) - clip_x = min_x + 300 - xp300; + if ((uint16)xp300 < (uint16)(_minX + 300)) + _posXClipped = _minX + 300 - xp300; - if ((uint16)yp300 < (uint16)(min_y + 300)) - clip_y = min_y + 300 - yp300; + if ((uint16)yp300 < (uint16)(_minY + 300)) + _posYClipped = _minY + 300 - yp300; - clip_x1 = max_x + 300 - xp300; - clip_y1 = max_y + 300 - yp300; + clip_x1 = _maxX + 300 - xp300; + clip_y1 = _maxY + 300 - yp300; dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; if (zoom2) { - Compteur_y = 0; Agr_x = 0; Agr_y = 0; Agr_Flag_y = false; @@ -1320,22 +1317,22 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v22 = zoomIn(spriteHeight1, zoom2); if (modeFlag) { v29 = v20 + dest1P; - if (clip_y) { - if ((uint16)clip_y >= v22) + if (_posYClipped) { + if ((uint16)_posYClipped >= v22) return; int v30 = 0; - while (zoomIn(++v30, zoom2) < (uint16)clip_y) + while (zoomIn(++v30, zoom2) < (uint16)_posYClipped) ; spritePixelsP += _width * v30; - v29 += _lineNbr2 * (uint16)clip_y; - v22 = v22 - (uint16)clip_y; + v29 += _lineNbr2 * (uint16)_posYClipped; + v22 = v22 - (uint16)_posYClipped; } if (v22 > (uint16)clip_y1) v22 = (uint16)clip_y1; - if (clip_x) { - if ((uint16)clip_x >= v20) + if (_posXClipped) { + if ((uint16)_posXClipped >= v20) return; - v20 -= (uint16)clip_x; + v20 -= (uint16)_posXClipped; } if (v20 > (uint16)clip_x1) { int v32 = v20 - (uint16)clip_x1; @@ -1377,7 +1374,6 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp R_Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v46; v29 = _lineNbr2 + v53; - ++Compteur_y; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 100) @@ -1393,31 +1389,31 @@ R_Aff_Zoom_Larg_Cont1: v22 = v63 - 1; } while (v63 != 1); } else { - if (clip_y) { - if ((uint16)clip_y >= v22) + if (_posYClipped) { + if ((uint16)_posYClipped >= v22) return; int v58 = v22; int v49 = v20; int v23 = 0; - int v24 = (uint16)clip_y; + int v24 = (uint16)_posYClipped; while (zoomIn(++v23, zoom2) < v24) ; v20 = v49; spritePixelsP += _width * v23; - dest1P += _lineNbr2 * (uint16)clip_y; - v22 = v58 - (uint16)clip_y; + dest1P += _lineNbr2 * (uint16)_posYClipped; + v22 = v58 - (uint16)_posYClipped; } if (v22 > (uint16)clip_y1) v22 = (uint16)clip_y1; - if (clip_x) { - if ((uint16)clip_x >= v20) + if (_posXClipped) { + if ((uint16)_posXClipped >= v20) return; int v26 = 0; - while (zoomIn(++v26, zoom2) < (uint16)clip_x) + while (zoomIn(++v26, zoom2) < (uint16)_posXClipped) ; spritePixelsP += v26; - dest1P += (uint16)clip_x; - v20 = v20 - (uint16)clip_x; + dest1P += (uint16)_posXClipped; + v20 = v20 - (uint16)_posXClipped; } if (v20 > (uint16)clip_x1) v20 = (uint16)clip_x1; @@ -1470,7 +1466,6 @@ Aff_Zoom_Larg_Cont1: } while (v60 != 1); } } else if (zoom1) { - Compteur_y = 0; Red_x = 0; Red_y = 0; _width = spriteWidth; @@ -1489,7 +1484,7 @@ Aff_Zoom_Larg_Cont1: for (int v41 = _width; v41; v41--) { Red_x = Red + Red_x; if ((uint16)Red_x < 100) { - if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP) + if (v42 >= _posXClipped && v42 < clip_x1 && *spritePixelsP) *v40 = *spritePixelsP; --v40; ++spritePixelsP; @@ -1518,7 +1513,7 @@ Aff_Zoom_Larg_Cont1: for (int v38 = _width; v38; v38--) { Red_x = Red + Red_x; if ((uint16)Red_x < 100) { - if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP) + if (v39 >= _posXClipped && v39 < clip_x1 && *spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; @@ -1540,22 +1535,21 @@ Aff_Zoom_Larg_Cont1: } } else { _width = spriteWidth; - Compteur_y = 0; if (modeFlag) { dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; - if (clip_y) { - if ((uint16)clip_y >= (unsigned int)spriteHeight1) + if (_posYClipped) { + if ((uint16)_posYClipped >= (unsigned int)spriteHeight1) return; - spritePixelsP += spriteWidth * (uint16)clip_y; - dest2P += _lineNbr2 * (uint16)clip_y; - spriteHeight1 -= (uint16)clip_y; + spritePixelsP += spriteWidth * (uint16)_posYClipped; + dest2P += _lineNbr2 * (uint16)_posYClipped; + spriteHeight1 -= (uint16)_posYClipped; } int xLeft = (uint16)clip_y1; if (spriteHeight1 > clip_y1) spriteHeight1 = clip_y1; - xLeft = clip_x; - if (clip_x) { + xLeft = _posXClipped; + if (_posXClipped) { if (xLeft >= spriteWidth) return; spriteWidth -= xLeft; @@ -1583,21 +1577,21 @@ Aff_Zoom_Larg_Cont1: } while (yCtr2 != 1); } else { spec_largeur = spriteWidth; - if (clip_y) { - if ((uint16)clip_y >= (unsigned int)spriteHeight1) + if (_posYClipped) { + if ((uint16)_posYClipped >= (unsigned int)spriteHeight1) return; - spritePixelsP += spriteWidth * (uint16)clip_y; - dest1P += _lineNbr2 * (uint16)clip_y; - spriteHeight1 -= (uint16)clip_y; + spritePixelsP += spriteWidth * (uint16)_posYClipped; + dest1P += _lineNbr2 * (uint16)_posYClipped; + spriteHeight1 -= (uint16)_posYClipped; } if (spriteHeight1 > clip_y1) spriteHeight1 = clip_y1; - if (clip_x) { - if ((uint16)clip_x >= spriteWidth) + if (_posXClipped) { + if ((uint16)_posXClipped >= spriteWidth) return; - spritePixelsP += (uint16)clip_x; - dest1P += (uint16)clip_x; - spriteWidth -= (uint16)clip_x; + spritePixelsP += (uint16)_posXClipped; + dest1P += (uint16)_posXClipped; + spriteWidth -= (uint16)_posXClipped; } if (spriteWidth > (uint16)clip_x1) spriteWidth = (uint16)clip_x1; @@ -1651,20 +1645,20 @@ void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int croppedWidth = width; croppedHeight = height; - if (x1 < min_x) { - croppedWidth = width - (min_x - x1); - left = min_x; + if (x1 < _minX) { + croppedWidth = width - (_minX - x1); + left = _minX; } - if (y1 < min_y) { - croppedHeight = height - (min_y - y1); - top = min_y; + if (y1 < _minY) { + croppedHeight = height - (_minY - y1); + top = _minY; } top2 = top; - if (top + croppedHeight > max_y) - croppedHeight = max_y - top; + if (top + croppedHeight > _maxY) + croppedHeight = _maxY - top; xRight = left + croppedWidth; - if (xRight > max_x) - croppedWidth = max_x - left; + if (xRight > _maxX) + croppedWidth = _maxX - left; if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; -- cgit v1.2.3 From db80d0d0df48b8679b209491b164642d95269ad8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 20 Jan 2013 12:33:59 +0100 Subject: HOPKINS: Some more renaming --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 8e54bc1cfb..93f1d01998 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1359,7 +1359,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp --v29; ++spritePixelsP; if (!Agr_Flag_x) - Agr_x = zoom2 + Agr_x; + Agr_x += zoom2; if ((uint16)Agr_x < 100) break; Agr_x -= 100; @@ -1375,7 +1375,7 @@ R_Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v46; v29 = _lineNbr2 + v53; if (!Agr_Flag_y) - Agr_y = zoom2 + Agr_y; + Agr_y += zoom2; if ((uint16)Agr_y < 100) break; Agr_y -= 100; -- cgit v1.2.3 From 704a36d1fb6567cdcbe0b985f745bd6d6c871dcb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 21 Jan 2013 22:25:12 +0100 Subject: HOPKINS: More renaming in ObjectsManager and globals --- engines/hopkins/graphics.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 93f1d01998..bca38038c4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1181,8 +1181,8 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i width = _vm->_objectsManager.getWidth(objectData, idx); height = _vm->_objectsManager.getHeight(objectData, idx); if (*objectData == 78) { - Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, 0); - Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, 0); + Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, false); + Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); } else { Sprite_Vesa(_vesaBuffer, objectData, xp + 300, yp + 300, idx); Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); @@ -1269,7 +1269,7 @@ int GraphicsManager::zoomOut(int v, int percentage) { } // Display 'Perfect?' -void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) { +void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, bool flipFl) { const byte *spriteStartP; int i; const byte *spriteSizeP; @@ -1315,7 +1315,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp _width = spriteWidth; int v20 = zoomIn(spriteWidth, zoom2); int v22 = zoomIn(spriteHeight1, zoom2); - if (modeFlag) { + if (flipFl) { v29 = v20 + dest1P; if (_posYClipped) { if ((uint16)_posYClipped >= v22) @@ -1472,7 +1472,7 @@ Aff_Zoom_Larg_Cont1: Red = zoom1; if (zoom1 < 100) { int v37 = zoomOut(spriteWidth, Red); - if (modeFlag) { + if (flipFl) { v40 = v37 + dest1P; do { int v65 = spriteHeight2; @@ -1535,7 +1535,7 @@ Aff_Zoom_Larg_Cont1: } } else { _width = spriteWidth; - if (modeFlag) { + if (flipFl) { dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; if (_posYClipped) { @@ -1622,8 +1622,8 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp int height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); if (*spriteData == 78) { - Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); - Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0); + Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); + Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); } else { Sprite_Vesa(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex); Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); -- cgit v1.2.3 From 1a3fb10d912ada574423cebe6e4cb818a6009127 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 22 Jan 2013 07:53:59 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/graphics.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index bca38038c4..69ea5b2190 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1632,7 +1632,7 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp addVesaSegment(xp, yp, xp + width, yp + height); } -void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { +void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { int top; int croppedWidth; int croppedHeight; @@ -1824,10 +1824,6 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { DD_VBL(); } -void GraphicsManager::SHOW_PALETTE() { - setPaletteVGA256(_palette); -} - void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { int destOffset; const byte *srcPtr; -- cgit v1.2.3 From 84f7ce6ea3666b3933ea48f29c60b30cce175db3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 27 Jan 2013 01:25:46 +0100 Subject: HOPKINS: Refactor REPONSE --- engines/hopkins/graphics.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 69ea5b2190..3203749cf8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1793,15 +1793,14 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia } _vm->_globals.freeMemory(ptr); if (mode != 1) { - _vm->_globals.COUCOU = _vm->_globals.freeMemory(_vm->_globals.COUCOU); + _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); filename = file + ".rep"; byte *dataP = _vm->_fileManager.searchCat(filename, 2); - _vm->_globals.COUCOU = dataP; - if (g_PTRNUL == dataP) { + if (dataP == g_PTRNUL) dataP = _vm->_fileManager.loadFile(filename); - _vm->_globals.COUCOU = dataP; - } + + _vm->_globals._answerBuffer = dataP; } _vm->_objectsManager._forceZoneFl = true; _vm->_objectsManager._changeVerbFl = false; -- cgit v1.2.3 From 15de07ff74e610510f724cca9c6d155ef376d68a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 30 Jan 2013 08:31:32 +0100 Subject: HOPKINS: Introduce MKTAG24. Make use of MKTAG16 and MKTAG24 --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 3203749cf8..a81ce9db41 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1768,7 +1768,7 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia } } } - if (ptr[0] != 'I' || ptr[1] != 'N' || ptr[2] != 'I') { + if (READ_BE_UINT24(ptr) != MKTAG24('I', 'N', 'I')) { error("Error, file not ini"); } else { bool doneFlag = false; -- cgit v1.2.3 From 9dd09f6c6eff178e6c996f59d95fd9014d9653c8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 31 Jan 2013 07:48:44 +0100 Subject: HOPKINS: Remove some more casts to unsigned int --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a81ce9db41..0aa9d3ff15 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -485,7 +485,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width if (Agr_Flag_y) break; - if ((unsigned int)Agr_y < 100) + if (Agr_y >= 0 && Agr_y < 100) break; Agr_y -= 100; -- cgit v1.2.3 From 4b0e2263402a0f80595a6e910359dd4b062817ac Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Feb 2013 12:15:41 +0100 Subject: HOPKINS: Get rid of a goto in the display code. Remove useless casts (with comments about that). Some renaming. --- engines/hopkins/graphics.cpp | 161 ++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 79 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0aa9d3ff15..36febe17ee 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -944,26 +944,25 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Clip X clip_x1 = width; - if ((xp + width) <= (_minX + 300)) + if ((xp + width) <= _minX + 300) return; - if (xp < (_minX + 300)) { + if (xp < _minX + 300) { _posXClipped = _minX + 300 - xp; _clipFl = true; } // Clip Y - // TODO: This is weird, but it's that way in the original. Original game bug? - if ((yp + height) <= height) + if (yp <= 0) return; - if (yp < (_minY + 300)) { + if (yp < _minY + 300) { _posYClipped = _minY + 300 - yp; _clipFl = true; } // Clip X1 - if (xp >= (_maxX + 300)) + if (xp >= _maxX + 300) return; - if ((xp + width) > (_maxX + 300)) { + if (xp + width > _maxX + 300) { int xAmount = width + 10 - (xp + width - (_maxX + 300)); if (xAmount <= 10) return; @@ -973,13 +972,14 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, } // Clip Y1 - if (yp >= (_maxY + 300)) + if (yp >= _maxY + 300) return; - if ((yp + height) > (_maxY + 300)) { + if (yp + height > _maxY + 300) { int yAmount = height + 10 - (yp + height - (_maxY + 300)); if (yAmount <= 10) return; + // clip_y1 is always positive thanks to the previous check clip_y1 = yAmount - 10; _clipFl = true; } @@ -1298,14 +1298,20 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if ((xp300 <= _minX) || (yp300 <= _minY) || (xp300 >= _maxX + 300) || (yp300 >= _maxY + 300)) return; - if ((uint16)xp300 < (uint16)(_minX + 300)) + // Clipped values are greater or equal to zero, thanks to the previous test + clip_x1 = _maxX + 300 - xp300; + clip_y1 = _maxY + 300 - yp300; + + // _minX is never negative, and should be always 0 + // The previous check insures that xp300 it's always greater to it + // After this check, posXClipped is always positive + if (xp300 < _minX + 300) _posXClipped = _minX + 300 - xp300; - if ((uint16)yp300 < (uint16)(_minY + 300)) + // Ditto. + if (yp300 < _minY + 300) _posYClipped = _minY + 300 - yp300; - clip_x1 = _maxX + 300 - xp300; - clip_y1 = _maxY + 300 - yp300; dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; if (zoom2) { Agr_x = 0; @@ -1313,46 +1319,47 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_Flag_y = false; Agr_Flag_x = false; _width = spriteWidth; - int v20 = zoomIn(spriteWidth, zoom2); - int v22 = zoomIn(spriteHeight1, zoom2); + int zoomedWidth = zoomIn(spriteWidth, zoom2); + int zoomedHeight = zoomIn(spriteHeight1, zoom2); if (flipFl) { - v29 = v20 + dest1P; + v29 = zoomedWidth + dest1P; if (_posYClipped) { - if ((uint16)_posYClipped >= v22) + if (_posYClipped < 0 || _posYClipped >= zoomedHeight) return; int v30 = 0; - while (zoomIn(++v30, zoom2) < (uint16)_posYClipped) + while (zoomIn(++v30, zoom2) < _posYClipped) ; spritePixelsP += _width * v30; - v29 += _lineNbr2 * (uint16)_posYClipped; - v22 = v22 - (uint16)_posYClipped; + v29 += _lineNbr2 * _posYClipped; + zoomedHeight -= _posYClipped; } - if (v22 > (uint16)clip_y1) - v22 = (uint16)clip_y1; + if (zoomedHeight > clip_y1) + zoomedHeight = clip_y1; if (_posXClipped) { - if ((uint16)_posXClipped >= v20) + if (_posXClipped >= zoomedWidth) return; - v20 -= (uint16)_posXClipped; + zoomedWidth -= _posXClipped; } - if (v20 > (uint16)clip_x1) { - int v32 = v20 - (uint16)clip_x1; + if (zoomedWidth > clip_x1) { + int v32 = zoomedWidth - clip_x1; v29 -= v32; int v33 = 0; while (zoomIn(++v33, zoom2) < v32) ; int v34 = v33; spritePixelsP += v34; - v20 = (uint16)clip_x1; + zoomedWidth = clip_x1; } int v63; do { for (;;) { - v63 = v22; + v63 = zoomedHeight; byte *v53 = v29; v46 = spritePixelsP; Agr_Flag_x = false; Agr_x = 0; - for (int v35 = v20; v35; v35--) { + for (int v35 = zoomedWidth; v35; v35--) { + Agr_Flag_x = false; for (;;) { if (*spritePixelsP) *v29 = *spritePixelsP; @@ -1360,18 +1367,16 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; if (!Agr_Flag_x) Agr_x += zoom2; - if ((uint16)Agr_x < 100) + if (Agr_x >= 0 && Agr_x < 100) break; Agr_x -= 100; --spritePixelsP; Agr_Flag_x = true; --v35; if (!v35) - goto R_Aff_Zoom_Larg_Cont1; + break; } - Agr_Flag_x = false; } -R_Aff_Zoom_Larg_Cont1: spritePixelsP = _width + v46; v29 = _lineNbr2 + v53; if (!Agr_Flag_y) @@ -1381,50 +1386,50 @@ R_Aff_Zoom_Larg_Cont1: Agr_y -= 100; spritePixelsP = v46; Agr_Flag_y = true; - v22 = v63 - 1; + zoomedHeight = v63 - 1; if (v63 == 1) return; } Agr_Flag_y = false; - v22 = v63 - 1; + zoomedHeight = v63 - 1; } while (v63 != 1); } else { if (_posYClipped) { - if ((uint16)_posYClipped >= v22) + if (_posYClipped >= zoomedHeight) return; - int v58 = v22; - int v49 = v20; + int v58 = zoomedHeight; + int v49 = zoomedWidth; int v23 = 0; - int v24 = (uint16)_posYClipped; + int v24 = _posYClipped; while (zoomIn(++v23, zoom2) < v24) ; - v20 = v49; + zoomedWidth = v49; spritePixelsP += _width * v23; - dest1P += _lineNbr2 * (uint16)_posYClipped; - v22 = v58 - (uint16)_posYClipped; + dest1P += _lineNbr2 * _posYClipped; + zoomedHeight = v58 - _posYClipped; } - if (v22 > (uint16)clip_y1) - v22 = (uint16)clip_y1; + if (zoomedHeight > clip_y1) + zoomedHeight = clip_y1; if (_posXClipped) { - if ((uint16)_posXClipped >= v20) + if (_posXClipped >= zoomedWidth) return; int v26 = 0; - while (zoomIn(++v26, zoom2) < (uint16)_posXClipped) + while (zoomIn(++v26, zoom2) < _posXClipped) ; spritePixelsP += v26; - dest1P += (uint16)_posXClipped; - v20 = v20 - (uint16)_posXClipped; + dest1P += _posXClipped; + zoomedWidth = zoomedWidth - _posXClipped; } - if (v20 > (uint16)clip_x1) - v20 = (uint16)clip_x1; + if (zoomedWidth > clip_x1) + zoomedWidth = clip_x1; int v60; do { for (;;) { - v60 = v22; + v60 = zoomedHeight; byte *v51 = dest1P; v45 = spritePixelsP; - int v28 = v20; + int v28 = zoomedWidth; Agr_Flag_x = false; Agr_x = 0; do { @@ -1457,12 +1462,12 @@ Aff_Zoom_Larg_Cont1: Agr_y = Agr_y - 100; spritePixelsP = v45; Agr_Flag_y = true; - v22 = v60 - 1; + zoomedHeight = v60 - 1; if (v60 == 1) return; } Agr_Flag_y = false; - v22 = v60 - 1; + zoomedHeight = v60 - 1; } while (v60 != 1); } } else if (zoom1) { @@ -1510,7 +1515,7 @@ Aff_Zoom_Larg_Cont1: if ((uint16)Red_y < 100) { Red_x = 0; int v39 = 0; - for (int v38 = _width; v38; v38--) { + for (int i = _width; i; i--) { Red_x = Red + Red_x; if ((uint16)Red_x < 100) { if (v39 >= _posXClipped && v39 < clip_x1 && *spritePixelsP) @@ -1539,26 +1544,24 @@ Aff_Zoom_Larg_Cont1: dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; if (_posYClipped) { - if ((uint16)_posYClipped >= (unsigned int)spriteHeight1) + if (_posYClipped >= (unsigned int)spriteHeight1) return; - spritePixelsP += spriteWidth * (uint16)_posYClipped; - dest2P += _lineNbr2 * (uint16)_posYClipped; - spriteHeight1 -= (uint16)_posYClipped; + spritePixelsP += spriteWidth * _posYClipped; + dest2P += _lineNbr2 * _posYClipped; + spriteHeight1 -= _posYClipped; } - int xLeft = (uint16)clip_y1; if (spriteHeight1 > clip_y1) spriteHeight1 = clip_y1; - xLeft = _posXClipped; - if (_posXClipped) { - if (xLeft >= spriteWidth) - return; - spriteWidth -= xLeft; - } - if (spriteWidth > (uint16)clip_x1) { - int clippedWidth = spriteWidth - (uint16)clip_x1; + + if (_posXClipped >= spriteWidth) + return; + spriteWidth -= _posXClipped; + + if (spriteWidth > clip_x1) { + int clippedWidth = spriteWidth - clip_x1; spritePixelsP += clippedWidth; dest2P -= clippedWidth; - spriteWidth = (uint16)clip_x1; + spriteWidth = clip_x1; } int yCtr2; do { @@ -1578,23 +1581,23 @@ Aff_Zoom_Larg_Cont1: } else { spec_largeur = spriteWidth; if (_posYClipped) { - if ((uint16)_posYClipped >= (unsigned int)spriteHeight1) + if (_posYClipped >= (unsigned int)spriteHeight1) return; - spritePixelsP += spriteWidth * (uint16)_posYClipped; - dest1P += _lineNbr2 * (uint16)_posYClipped; - spriteHeight1 -= (uint16)_posYClipped; + spritePixelsP += spriteWidth * _posYClipped; + dest1P += _lineNbr2 * _posYClipped; + spriteHeight1 -= _posYClipped; } if (spriteHeight1 > clip_y1) spriteHeight1 = clip_y1; if (_posXClipped) { - if ((uint16)_posXClipped >= spriteWidth) + if (_posXClipped >= spriteWidth) return; - spritePixelsP += (uint16)_posXClipped; - dest1P += (uint16)_posXClipped; - spriteWidth -= (uint16)_posXClipped; + spritePixelsP += _posXClipped; + dest1P += _posXClipped; + spriteWidth -= _posXClipped; } - if (spriteWidth > (uint16)clip_x1) - spriteWidth = (uint16)clip_x1; + if (spriteWidth > clip_x1) + spriteWidth = clip_x1; int yCtr1; do { yCtr1 = spriteHeight1; -- cgit v1.2.3 From 9772426c586c0ac25fd21e9865ac5f2d85217db1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Feb 2013 12:26:21 +0100 Subject: HOPKINS: Fix signness issue, get rid of another GOTO --- engines/hopkins/graphics.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 36febe17ee..bdc2d50cd4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1358,8 +1358,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v46 = spritePixelsP; Agr_Flag_x = false; Agr_x = 0; - for (int v35 = zoomedWidth; v35; v35--) { - Agr_Flag_x = false; + for (int v35 = zoomedWidth; v35; Agr_Flag_x = false, v35--) { for (;;) { if (*spritePixelsP) *v29 = *spritePixelsP; @@ -1429,17 +1428,16 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp v60 = zoomedHeight; byte *v51 = dest1P; v45 = spritePixelsP; - int v28 = zoomedWidth; Agr_Flag_x = false; Agr_x = 0; - do { + for (int v28 = zoomedWidth; v28; Agr_Flag_x = false, v28--) { for (;;) { if (*spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; if (!Agr_Flag_x) - Agr_x = zoom2 + Agr_x; + Agr_x += zoom2; if ((uint16)Agr_x < 100) break; Agr_x = Agr_x - 100; @@ -1447,12 +1445,9 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_Flag_x = true; --v28; if (!v28) - goto Aff_Zoom_Larg_Cont1; + break; } - Agr_Flag_x = false; - --v28; - } while (v28); -Aff_Zoom_Larg_Cont1: + } spritePixelsP = _width + v45; dest1P = _lineNbr2 + v51; if (!Agr_Flag_y) @@ -1544,7 +1539,7 @@ Aff_Zoom_Larg_Cont1: dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; if (_posYClipped) { - if (_posYClipped >= (unsigned int)spriteHeight1) + if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0) return; spritePixelsP += spriteWidth * _posYClipped; dest2P += _lineNbr2 * _posYClipped; @@ -1581,7 +1576,7 @@ Aff_Zoom_Larg_Cont1: } else { spec_largeur = spriteWidth; if (_posYClipped) { - if (_posYClipped >= (unsigned int)spriteHeight1) + if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0) return; spritePixelsP += spriteWidth * _posYClipped; dest1P += _lineNbr2 * _posYClipped; -- cgit v1.2.3 From ea4639c65facbfef049d3581dc1e0f96d5f19dc9 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 2 Feb 2013 12:41:44 +0100 Subject: HOPKINS: Fix Sprite_Vesa() height clipping This fixes some Valgrind warnings on the city overhead map, and also seem to get rid of the bird "droppings" previously left behind in the area beneath the picture. There are things I don't understand about this function, but I hope I didn't break anything. --- engines/hopkins/graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index bdc2d50cd4..5e31f02d48 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -952,6 +952,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, } // Clip Y + clip_y1 = height; if (yp <= 0) return; if (yp < _minY + 300) { @@ -999,7 +1000,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, // Handling for clipped versus non-clipped if (_clipFl) { // Clipped version - for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) { + for (int yc = 0; yc < clip_y1; ++yc, destP += _lineNbr2) { byte *tempDestP = destP; byte byteVal; int xc = 0; -- cgit v1.2.3 From 690405961f73ddbdfc5e07a57f4ca438421856a0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 2 Feb 2013 19:20:58 +0100 Subject: HOPKINS: Some refactoring in GraphicsManager --- engines/hopkins/graphics.cpp | 134 ++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 85 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 5e31f02d48..810a6bf92d 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -469,7 +469,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width destP[0] = palette[2 * srcP[0]]; destP[1] = palette[(2 * srcP[0]) + 1]; destP += 2; - if ((unsigned int)Agr_x >= 100) { + if (Agr_x >= 100) { Agr_x -= 100; destP[0] = palette[2 * srcP[0]]; destP[1] = palette[(2 * srcP[0]) + 1]; @@ -1252,7 +1252,7 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in /** * Compute the value of a parameter plus a given percentage */ -int GraphicsManager::zoomIn( int v, int percentage ) { +int GraphicsManager::zoomIn(int v, int percentage ) { if (v) v += percentage * (long int)v / 100; @@ -1279,8 +1279,6 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp byte *dest2P; byte *v29; byte *v40; - const byte *v45; - const byte *v46; spriteStartP = srcData + 3; for (i = frameIndex; i; --i) @@ -1356,7 +1354,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp for (;;) { v63 = zoomedHeight; byte *v53 = v29; - v46 = spritePixelsP; + const byte *oldSpritePixelsP = spritePixelsP; Agr_Flag_x = false; Agr_x = 0; for (int v35 = zoomedWidth; v35; Agr_Flag_x = false, v35--) { @@ -1377,14 +1375,14 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp break; } } - spritePixelsP = _width + v46; + spritePixelsP = _width + oldSpritePixelsP; v29 = _lineNbr2 + v53; if (!Agr_Flag_y) Agr_y += zoom2; if ((uint16)Agr_y < 100) break; Agr_y -= 100; - spritePixelsP = v46; + spritePixelsP = oldSpritePixelsP; Agr_Flag_y = true; zoomedHeight = v63 - 1; if (v63 == 1) @@ -1397,16 +1395,12 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (_posYClipped) { if (_posYClipped >= zoomedHeight) return; - int v58 = zoomedHeight; - int v49 = zoomedWidth; int v23 = 0; - int v24 = _posYClipped; - while (zoomIn(++v23, zoom2) < v24) + while (zoomIn(++v23, zoom2) < _posYClipped) ; - zoomedWidth = v49; spritePixelsP += _width * v23; dest1P += _lineNbr2 * _posYClipped; - zoomedHeight = v58 - _posYClipped; + zoomedHeight -= _posYClipped; } if (zoomedHeight > clip_y1) zoomedHeight = clip_y1; @@ -1427,8 +1421,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp do { for (;;) { v60 = zoomedHeight; - byte *v51 = dest1P; - v45 = spritePixelsP; + byte *oldDest1P = dest1P; + const byte *oldSpritePixelsP = spritePixelsP; Agr_Flag_x = false; Agr_x = 0; for (int v28 = zoomedWidth; v28; Agr_Flag_x = false, v28--) { @@ -1441,7 +1435,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp Agr_x += zoom2; if ((uint16)Agr_x < 100) break; - Agr_x = Agr_x - 100; + Agr_x -= 100; --spritePixelsP; Agr_Flag_x = true; --v28; @@ -1449,14 +1443,14 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp break; } } - spritePixelsP = _width + v45; - dest1P = _lineNbr2 + v51; + spritePixelsP = _width + oldSpritePixelsP; + dest1P = _lineNbr2 + oldDest1P; if (!Agr_Flag_y) Agr_y = zoom2 + Agr_y; if ((uint16)Agr_y < 100) break; - Agr_y = Agr_y - 100; - spritePixelsP = v45; + Agr_y -= 100; + spritePixelsP = oldSpritePixelsP; Agr_Flag_y = true; zoomedHeight = v60 - 1; if (v60 == 1) @@ -1505,8 +1499,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp } while (spriteHeight2); } else { do { - int v64 = spriteHeight2; - byte *v54 = dest1P; + int oldSpriteHeight = spriteHeight2; + byte *oldDest1P = dest1P; Red_y = Red + Red_y; if ((uint16)Red_y < 100) { Red_x = 0; @@ -1524,8 +1518,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; } } - spriteHeight2 = v64; - dest1P = _lineNbr2 + v54; + spriteHeight2 = oldSpriteHeight; + dest1P = _lineNbr2 + oldDest1P; } else { Red_y = Red_y - 100; spritePixelsP += _width; @@ -1632,17 +1626,12 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp } void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { - int top; - int croppedWidth; - int croppedHeight; int xRight; - int top2; - int left; - left = x1; - top = y1; - croppedWidth = width; - croppedHeight = height; + int left = x1; + int top = y1; + int croppedWidth = width; + int croppedHeight = height; if (x1 < _minX) { croppedWidth = width - (_minX - x1); @@ -1652,7 +1641,7 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width croppedHeight = height - (_minY - y1); top = _minY; } - top2 = top; + int top2 = top; if (top + croppedHeight > _maxY) croppedHeight = _maxY - top; xRight = left + croppedWidth; @@ -1666,18 +1655,15 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width } } -void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY) { - const byte *srcP; - byte *destP; - int yp; +void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, uint16 width, int height, byte *destSurface, int destX, int destY) { int yCurrent; byte *dest2P; const byte *src2P; - unsigned int pitch; + uint16 pitch; - srcP = x1 + _lineNbr2 * y1 + srcSurface; - destP = destX + _lineNbr2 * destY + destSurface; - yp = height; + const byte *srcP = x1 + _lineNbr2 * y1 + srcSurface; + byte *destP = destX + _lineNbr2 * destY + destSurface; + int yp = height; do { yCurrent = yp; memcpy(destP, srcP, 4 * (width >> 2)); @@ -1692,38 +1678,27 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned } // Display Font -void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int yp, - int characterIndex, int colour) { - const byte *spriteDataP; - int i; - const byte *spriteSizeP; - int spriteWidth; - int spriteHeight; - const byte *spritePixelsP; - byte *destP; - byte destByte; - byte *destLineP; - int yCtr; - - spriteDataP = spriteData + 3; - for (i = characterIndex; i; --i) +void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { + const byte *spriteDataP = spriteData + 3; + for (int i = characterIndex; i; --i) spriteDataP += READ_LE_UINT32(spriteDataP) + 16; - spriteWidth = 0; - spriteHeight = 0; - spriteSizeP = spriteDataP + 4; + int spriteWidth = 0; + int spriteHeight = 0; + const byte *spriteSizeP = spriteDataP + 4; spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); spriteSizeP += 2; spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); - spritePixelsP = spriteSizeP + 10; - destP = surface + xp + _lineNbr2 * yp; + const byte *spritePixelsP = spriteSizeP + 10; + byte *destP = surface + xp + _lineNbr2 * yp; _width = spriteWidth; + int yCtr = 0; do { - yCtr = spriteHeight; - destLineP = destP; + int yCtr = spriteHeight; + byte *destLineP = destP; for (int xCtr = spriteWidth; xCtr; xCtr--) { - destByte = *spritePixelsP; + byte destByte = *spritePixelsP; if (*spritePixelsP) { if (destByte == 252) destByte = colour; @@ -1823,14 +1798,10 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { } void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { - int destOffset; - const byte *srcPtr; - byte byteVal; - - destOffset = 0; - srcPtr = src; + int destOffset = 0; + const byte *srcPtr = src; for (;;) { - byteVal = *srcPtr; + byte byteVal = *srcPtr; if (byteVal == kByteStop) return; if (*srcPtr > kByteStop) { @@ -1855,15 +1826,11 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { } void GraphicsManager::Copy_Video_Vbe(const byte *src) { - int destOffset; - const byte *srcP; - byte byteVal; - assert(_videoPtr); - destOffset = 0; - srcP = src; + int destOffset = 0; + const byte *srcP = src; for (;;) { - byteVal = *srcP; + byte byteVal = *srcP; if (*srcP < kByteStop) break; else { @@ -1892,11 +1859,8 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { // Reduce Screen void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { - const byte *srcP; - byte *destP; - - srcP = xp + _lineNbr2 * yp + srcSurface; - destP = destSurface; + const byte *srcP = xp + _lineNbr2 * yp + srcSurface; + byte *destP = destSurface; Red = zoom; _width = width; Red_x = 0; @@ -1927,7 +1891,7 @@ void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int /** * Draw horizontal line */ -void GraphicsManager::drawHorizontalLine(byte *surface, int xp, int yp, unsigned int width, byte col) { +void GraphicsManager::drawHorizontalLine(byte *surface, int xp, int yp, uint16 width, byte col) { memset(surface + xp + _lineNbr2 * yp, col, width); } -- cgit v1.2.3 From 8f300bdc303579e4becc1d8e68bd8774042501b6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 2 Feb 2013 20:26:42 +0100 Subject: HOPKINS: Fix GCC warnings --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 810a6bf92d..b5920e37e6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1505,7 +1505,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if ((uint16)Red_y < 100) { Red_x = 0; int v39 = 0; - for (int i = _width; i; i--) { + for (i = _width; i; i--) { Red_x = Red + Red_x; if ((uint16)Red_x < 100) { if (v39 >= _posXClipped && v39 < clip_x1 && *spritePixelsP) @@ -1693,9 +1693,9 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, byte *destP = surface + xp + _lineNbr2 * yp; _width = spriteWidth; - int yCtr = 0; + int yCtr; do { - int yCtr = spriteHeight; + yCtr = spriteHeight; byte *destLineP = destP; for (int xCtr = spriteWidth; xCtr; xCtr--) { byte destByte = *spritePixelsP; -- cgit v1.2.3 From 6797698af8fe90cd8cbfa02870e38f6ca47f7ca9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 3 Feb 2013 01:25:37 +0100 Subject: HOPKINS: Some more refactoring --- engines/hopkins/graphics.cpp | 86 +++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 53 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b5920e37e6..6318bd1ca8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -249,19 +249,15 @@ void GraphicsManager::scrollScreen(int amount) { } void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { - int palIndex; - int srcOffset; - int col1, col2; - byte *destPosP = destP; for (int idx = 0; idx < count; ++idx) { - palIndex = *destPosP; - srcOffset = 3 * palIndex; - col1 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; + int palIndex = *destPosP; + int srcOffset = 3 * palIndex; + int col1 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; for (int idx2 = 0; idx2 < 38; ++idx2) { srcOffset = 3 * idx2; - col2 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; + int col2 = srcP[srcOffset] + srcP[srcOffset + 1] + srcP[srcOffset + 2]; col2 += minThreshold; if (col2 < col1) @@ -1112,9 +1108,7 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { int16 blocIndex = 0; do { BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; - - if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 - && y1 >= bloc._y1 && y2 <= bloc._y2) + if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; ++blocIndex; } while (_vm->_globals.NBBLOC + 1 != blocIndex); @@ -1151,10 +1145,10 @@ void GraphicsManager::displayVesaSegment() { dstRect.top = bloc._y1 * 2 + 30; dstRect.setWidth((bloc._x2 - bloc._x1) * 2); dstRect.setHeight((bloc._y2 - bloc._y1) * 2); - } else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) { + } else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { if (bloc._x1 < _vm->_eventsManager._startPos.x) bloc._x1 = _vm->_eventsManager._startPos.x; - if (bloc._x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) + if (bloc._x2 > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access @@ -1271,25 +1265,16 @@ int GraphicsManager::zoomOut(int v, int percentage) { // Display 'Perfect?' void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, bool flipFl) { - const byte *spriteStartP; - int i; - const byte *spriteSizeP; - const byte *spritePixelsP; - byte *dest1P; - byte *dest2P; - byte *v29; - byte *v40; - - spriteStartP = srcData + 3; - for (i = frameIndex; i; --i) + const byte *spriteStartP = srcData + 3; + for (int i = frameIndex; i; --i) spriteStartP += READ_LE_UINT32(spriteStartP) + 16; - spriteSizeP = spriteStartP + 4; + const byte *spriteSizeP = spriteStartP + 4; int spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); spriteSizeP += 2; int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); int spriteHeight1 = spriteHeight2; - spritePixelsP = spriteSizeP + 10; + const byte *spritePixelsP = spriteSizeP + 10; _posXClipped = 0; _posYClipped = 0; clip_x1 = 0; @@ -1311,7 +1296,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (yp300 < _minY + 300) _posYClipped = _minY + 300 - yp300; - dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; + byte *dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; if (zoom2) { Agr_x = 0; Agr_y = 0; @@ -1321,7 +1306,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int zoomedWidth = zoomIn(spriteWidth, zoom2); int zoomedHeight = zoomIn(spriteHeight1, zoom2); if (flipFl) { - v29 = zoomedWidth + dest1P; + byte *v29 = zoomedWidth + dest1P; if (_posYClipped) { if (_posYClipped < 0 || _posYClipped >= zoomedHeight) return; @@ -1345,8 +1330,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp int v33 = 0; while (zoomIn(++v33, zoom2) < v32) ; - int v34 = v33; - spritePixelsP += v34; + spritePixelsP += v33; zoomedWidth = clip_x1; } int v63; @@ -1446,7 +1430,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp spritePixelsP = _width + oldSpritePixelsP; dest1P = _lineNbr2 + oldDest1P; if (!Agr_Flag_y) - Agr_y = zoom2 + Agr_y; + Agr_y += zoom2; if ((uint16)Agr_y < 100) break; Agr_y -= 100; @@ -1468,16 +1452,16 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (zoom1 < 100) { int v37 = zoomOut(spriteWidth, Red); if (flipFl) { - v40 = v37 + dest1P; + byte *v40 = v37 + dest1P; do { int v65 = spriteHeight2; byte *v55 = v40; - Red_y = Red + Red_y; + Red_y += Red; if ((uint16)Red_y < 100) { Red_x = 0; int v42 = v37; for (int v41 = _width; v41; v41--) { - Red_x = Red + Red_x; + Red_x += Red; if ((uint16)Red_x < 100) { if (v42 >= _posXClipped && v42 < clip_x1 && *spritePixelsP) *v40 = *spritePixelsP; @@ -1485,14 +1469,14 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; --v42; } else { - Red_x = Red_x - 100; + Red_x -= 100; ++spritePixelsP; } } spriteHeight2 = v65; v40 = _lineNbr2 + v55; } else { - Red_y = Red_y - 100; + Red_y -= 100; spritePixelsP += _width; } --spriteHeight2; @@ -1501,12 +1485,12 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp do { int oldSpriteHeight = spriteHeight2; byte *oldDest1P = dest1P; - Red_y = Red + Red_y; + Red_y += Red; if ((uint16)Red_y < 100) { Red_x = 0; int v39 = 0; - for (i = _width; i; i--) { - Red_x = Red + Red_x; + for (int i = _width; i; i--) { + Red_x += Red; if ((uint16)Red_x < 100) { if (v39 >= _posXClipped && v39 < clip_x1 && *spritePixelsP) *dest1P = *spritePixelsP; @@ -1514,14 +1498,14 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; ++v39; } else { - Red_x = Red_x - 100; + Red_x -= 100; ++spritePixelsP; } } spriteHeight2 = oldSpriteHeight; dest1P = _lineNbr2 + oldDest1P; } else { - Red_y = Red_y - 100; + Red_y -= 100; spritePixelsP += _width; } --spriteHeight2; @@ -1531,7 +1515,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp } else { _width = spriteWidth; if (flipFl) { - dest2P = spriteWidth + dest1P; + byte *dest2P = spriteWidth + dest1P; spec_largeur = spriteWidth; if (_posYClipped) { if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0) @@ -1641,7 +1625,7 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width croppedHeight = height - (_minY - y1); top = _minY; } - int top2 = top; + if (top + croppedHeight > _maxY) croppedHeight = _maxY - top; xRight = left + croppedWidth; @@ -1650,26 +1634,22 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; - Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY); - addVesaSegment(left, top2, left + croppedWidth, top2 + height2); + Copy_Mem(surface, left, top, croppedWidth, croppedHeight, destSurface, destX, destY); + addVesaSegment(left, top, left + croppedWidth, top + height2); } } void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, uint16 width, int height, byte *destSurface, int destX, int destY) { - int yCurrent; - byte *dest2P; - const byte *src2P; - uint16 pitch; - const byte *srcP = x1 + _lineNbr2 * y1 + srcSurface; byte *destP = destX + _lineNbr2 * destY + destSurface; int yp = height; + int yCurrent; do { yCurrent = yp; memcpy(destP, srcP, 4 * (width >> 2)); - src2P = (srcP + 4 * (width >> 2)); - dest2P = (destP + 4 * (width >> 2)); - pitch = width - 4 * (width >> 2); + const byte *src2P = (srcP + 4 * (width >> 2)); + byte *dest2P = (destP + 4 * (width >> 2)); + int pitch = width - 4 * (width >> 2); memcpy(dest2P, src2P, pitch); destP = (dest2P + pitch + _lineNbr2 - width); srcP = (src2P + pitch + _lineNbr2 - width); -- cgit v1.2.3 From 19427ff1769617fc379268f1abceccdf272d2aef Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 5 Feb 2013 00:12:42 +0100 Subject: HOPKINS: Some refactoring in ObjectsManager --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 6318bd1ca8..63bcbf20c8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1060,7 +1060,7 @@ void GraphicsManager::FIN_VISU() { for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals.Bqe_Anim[idx]._enabledFl) - _vm->_objectsManager.BOB_ZERO(idx); + _vm->_objectsManager.resetBob(idx); } for (int idx = 1; idx <= 29; ++idx) { -- cgit v1.2.3 From e96edd8b19835102bcfd44190e1d6733d3322abe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 7 Feb 2013 08:44:22 +0100 Subject: HOPKINS: Misc refactoring and renaming, remove some dead code --- engines/hopkins/graphics.cpp | 91 ++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 58 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 63bcbf20c8..03d79e376e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -45,6 +45,7 @@ GraphicsManager::GraphicsManager() { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; + NBBLOC = 0; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -63,12 +64,16 @@ GraphicsManager::GraphicsManager() { Red_x = Red_y = 0; Red = 0; _width = 0; - spec_largeur = 0; + _specialWidth = 0; Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); + + for (int i = 0; i < 250; ++i) + Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0); + } GraphicsManager::~GraphicsManager() { @@ -923,6 +928,14 @@ void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int } while (rowCount2 != 1); } +/** + * Draws a sprite onto the screen + * @param surface Destination surface + * @param spriteData The raw data for a sprite set + * @param xp X co-ordinate. For some reason, starts from 300 = first column + * @param yp Y co-ordinate. FOr some reason, starts from 300 = top row + * @param spriteIndex Index of the sprite to draw + */ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) { // Get a pointer to the start of the desired sprite const byte *spriteP = spriteData + 3; @@ -1080,12 +1093,10 @@ void GraphicsManager::VISU_ALL() { } void GraphicsManager::RESET_SEGMENT_VESA() { - if (_vm->_globals.NBBLOC > 0) { - for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++) - _vm->_globals.BLOC[idx]._activeFl = false; + for (int idx = 0; idx <= NBBLOC; idx++) + BLOC[idx]._activeFl = false; - _vm->_globals.NBBLOC = 0; - } + NBBLOC = 0; } // Add VESA Segment @@ -1104,19 +1115,15 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { if (y1 < _minY) y1 = _minY; - if (_vm->_globals.NBBLOC > 1) { - int16 blocIndex = 0; - do { - BlocItem &bloc = _vm->_globals.BLOC[blocIndex]; - if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) - addFlag = false; - ++blocIndex; - } while (_vm->_globals.NBBLOC + 1 != blocIndex); - } + for (int blocIndex = 0; blocIndex <= NBBLOC; blocIndex++) { + BlocItem &bloc = BLOC[blocIndex]; + if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) + addFlag = false; + }; if (addFlag) { - assert(_vm->_globals.NBBLOC < 250); - BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC]; + assert(NBBLOC < 250); + BlocItem &bloc = BLOC[++NBBLOC]; bloc._activeFl = true; bloc._x1 = tempX; @@ -1128,13 +1135,13 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { // Display VESA Segment void GraphicsManager::displayVesaSegment() { - if (_vm->_globals.NBBLOC == 0) + if (NBBLOC == 0) return; lockScreen(); - for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) { - BlocItem &bloc = _vm->_globals.BLOC[idx]; + for (int idx = 1; idx <= NBBLOC; ++idx) { + BlocItem &bloc = BLOC[idx]; Common::Rect &dstRect = dstrect[idx - 1]; if (!bloc._activeFl) continue; @@ -1163,10 +1170,10 @@ void GraphicsManager::displayVesaSegment() { unlockScreen(); } - _vm->_globals.BLOC[idx]._activeFl = false; + BLOC[idx]._activeFl = false; } - _vm->_globals.NBBLOC = 0; + NBBLOC = 0; unlockScreen(); } @@ -1516,7 +1523,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp _width = spriteWidth; if (flipFl) { byte *dest2P = spriteWidth + dest1P; - spec_largeur = spriteWidth; + _specialWidth = spriteWidth; if (_posYClipped) { if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0) return; @@ -1548,12 +1555,12 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++spritePixelsP; --dest2P; } - spritePixelsP = spec_largeur + spritePixelsCopy2P; + spritePixelsP = _specialWidth + spritePixelsCopy2P; dest2P = _lineNbr2 + destCopy2P; spriteHeight1 = yCtr2 - 1; } while (yCtr2 != 1); } else { - spec_largeur = spriteWidth; + _specialWidth = spriteWidth; if (_posYClipped) { if (_posYClipped >= spriteHeight1 || spriteHeight1 < 0) return; @@ -1583,7 +1590,7 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp ++dest1P; ++spritePixelsP; } - spritePixelsP = spec_largeur + spritePixelsCopyP; + spritePixelsP = _specialWidth + spritePixelsCopyP; dest1P = _lineNbr2 + dest1CopyP; spriteHeight1 = yCtr1 - 1; } while (yCtr1 != 1); @@ -1805,38 +1812,6 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { } } -void GraphicsManager::Copy_Video_Vbe(const byte *src) { - assert(_videoPtr); - int destOffset = 0; - const byte *srcP = src; - for (;;) { - byte byteVal = *srcP; - if (*srcP < kByteStop) - break; - else { - if (byteVal == kByteStop) - return; - if (byteVal == k8bVal) { - destOffset += srcP[1]; - byteVal = srcP[2]; - srcP += 2; - } else if (byteVal == k16bVal) { - destOffset += READ_LE_UINT16(srcP + 1); - byteVal = srcP[3]; - srcP += 3; - } else { - destOffset += READ_LE_UINT32(srcP + 1); - byteVal = srcP[5]; - srcP += 5; - } - } - - *((byte *)_videoPtr->pixels + destOffset) = byteVal; - ++srcP; - ++destOffset; - } -} - // Reduce Screen void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { const byte *srcP = xp + _lineNbr2 * yp + srcSurface; -- cgit v1.2.3 From 2634c65d2ff4a83f745e9c204372991472eebb30 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Feb 2013 08:04:07 +0100 Subject: HOPKINS: Minor refactoring in GraphicManager --- engines/hopkins/graphics.cpp | 82 +++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 55 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 03d79e376e..221558f592 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -326,27 +326,18 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte } void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte *palette) { - size_t filesize; - int v4; - size_t v5; - size_t v7; - byte v9; - int v10; - char v12; - int v15; - int v16; - int32 v17; - byte *ptr; Common::File f; - if (!f.open(file)) error("File not found - %s", file.c_str()); - filesize = f.size(); + size_t filesize = f.size(); f.read(surface, 128); - v4 = filesize - 896; - ptr = _vm->_globals.allocMemory(65024); + int v4 = filesize - 896; + byte *ptr = _vm->_globals.allocMemory(65024); + size_t v5; + int v15; + int v17; if (v4 >= 64000) { v15 = v4 / 64000 + 1; v17 = 64000 * (v4 / 64000) - v4; @@ -360,8 +351,8 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte f.read(ptr, v4); v5 = v4; } - v16 = v15 - 1; - v7 = 0; + int v16 = v15 - 1; + size_t v7 = 0; for (int i = 0; i < 64000; i++) { if (v7 == v5) { v7 = 0; @@ -371,9 +362,9 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte v5 = v17; f.read(ptr, v5); } - v9 = ptr[v7++]; + byte v9 = ptr[v7++]; if (v9 > 192) { - v10 = v9 - 192; + int v10 = v9 - 192; if (v7 == v5) { v7 = 0; --v16; @@ -382,7 +373,7 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte v5 = v17; f.read(ptr, v5); } - v12 = ptr[v7++]; + char v12 = ptr[v7++]; do { surface[i++] = v12; --v10; @@ -440,9 +431,6 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, // TODO: See if PAL_PIXELS can be converted to a uint16 array void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - const byte *srcP; - byte *destP; - int yNext; int xCtr; const byte *palette; int yCtr; @@ -450,9 +438,9 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width byte *destCopyP; assert(_videoPtr); - srcP = xs + _lineNbr2 * ys + surface; - destP = (byte *)_videoPtr->pixels + destX + destX + WinScan * destY; - yNext = height; + const byte *srcP = xs + _lineNbr2 * ys + surface; + byte *destP = (byte *)_videoPtr->pixels + destX + destX + WinScan * destY; + int yNext = height; Agr_x = 0; Agr_y = 0; Agr_Flag_y = false; @@ -500,8 +488,6 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { - int yCount; - int xCount; int xCtr; const byte *palette; int savedXCount; @@ -512,8 +498,8 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, assert(_videoPtr); const byte *srcP = surface + xp + 320 * yp; byte *destP = (byte *)_videoPtr->pixels + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; - yCount = height; - xCount = width; + int yCount = height; + int xCount = width; do { yCtr = yCount; @@ -740,18 +726,15 @@ void GraphicsManager::DD_VBL() { } void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { - int rleValue; - int destOffset; - const byte *srcP; byte srcByte; byte destLen1; byte *destSlice1P; byte destLen2; byte *destSlice2P; - rleValue = 0; - destOffset = 0; - srcP = srcData; + int rleValue = 0; + int destOffset = 0; + const byte *srcP = srcData; for (;;) { srcByte = srcP[0]; if (srcByte == kByteStop) @@ -1101,11 +1084,8 @@ void GraphicsManager::RESET_SEGMENT_VESA() { // Add VESA Segment void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { - int tempX; - bool addFlag; - - tempX = x1; - addFlag = true; + int tempX = x1; + bool addFlag = true; if (x2 > _maxX) x2 = _maxX; if (y2 > _maxY) @@ -1178,10 +1158,8 @@ void GraphicsManager::displayVesaSegment() { } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { - int height, width; - - width = _vm->_objectsManager.getWidth(objectData, idx); - height = _vm->_objectsManager.getHeight(objectData, idx); + int width = _vm->_objectsManager.getWidth(objectData, idx); + int height = _vm->_objectsManager.getHeight(objectData, idx); if (*objectData == 78) { Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, false); Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); @@ -1218,15 +1196,12 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { } void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { - byte *destP; - int yNext; - const byte *srcP; int i; int yCtr; - destP = xp + _lineNbr2 * yp + destSurface; - yNext = height; - srcP = src; + byte *destP = xp + _lineNbr2 * yp + destSurface; + int yNext = height; + const byte *srcP = src; do { yCtr = yNext; if (width & 1) { @@ -1617,8 +1592,6 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp } void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { - int xRight; - int left = x1; int top = y1; int croppedWidth = width; @@ -1635,8 +1608,7 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width if (top + croppedHeight > _maxY) croppedHeight = _maxY - top; - xRight = left + croppedWidth; - if (xRight > _maxX) + if (left + croppedWidth > _maxX) croppedWidth = _maxX - left; if (croppedWidth > 0 && croppedHeight > 0) { -- cgit v1.2.3 From e47d34f9512bb9b0124bc61547bd854563ac53d2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Feb 2013 08:34:49 +0100 Subject: HOPKINS: Fix transition glitch when skipping animations --- engines/hopkins/graphics.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 221558f592..6834d400fc 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -570,13 +570,8 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) */ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { byte palData[PALETTE_BLOCK_SIZE]; - int fadeStep; - if (step > 1) - fadeStep = step; - else - fadeStep = 2; - - if (palette) { + if ((step > 1) && (palette) && (!_vm->_eventsManager._escKeyFl)) { + int fadeStep = step; for (int fadeIndex = 0; fadeIndex < fadeStep; fadeIndex++) { for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { palData[palOffset + 0] = (fadeStep - fadeIndex - 1) * palette[palOffset + 0] / (fadeStep - 1); -- cgit v1.2.3 From 9223719f2a7ca153ada953fc12a717f9547476d2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 12 Feb 2013 22:19:59 +0100 Subject: HOPKINS: Some renaming in GraphicManager --- engines/hopkins/graphics.cpp | 91 +++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 47 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 6834d400fc..ccdd8adb36 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -333,54 +333,51 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte size_t filesize = f.size(); f.read(surface, 128); - int v4 = filesize - 896; + int imageSize = filesize - 896; byte *ptr = _vm->_globals.allocMemory(65024); - size_t v5; - int v15; - int v17; - if (v4 >= 64000) { - v15 = v4 / 64000 + 1; - v17 = 64000 * (v4 / 64000) - v4; - if (v17 < 0) - v17 = -v17; + size_t curBufSize; + int imageNumb; + int imageDataSize; + if (imageSize >= 64000) { + imageNumb = imageSize / 64000 + 1; + imageDataSize = abs(64000 * (imageSize / 64000) - imageSize); f.read(ptr, 64000); - v5 = 64000; + curBufSize = 64000; } else { - v15 = 1; - v17 = v4; - f.read(ptr, v4); - v5 = v4; + imageNumb = 1; + imageDataSize = imageSize; + f.read(ptr, imageSize); + curBufSize = imageSize; } - int v16 = v15 - 1; - size_t v7 = 0; + imageNumb--; + size_t curByteIdx = 0; for (int i = 0; i < 64000; i++) { - if (v7 == v5) { - v7 = 0; - --v16; - v5 = 64000; - if (!v16) - v5 = v17; - f.read(ptr, v5); + if (curByteIdx == curBufSize) { + curByteIdx = 0; + --imageNumb; + curBufSize = 64000; + if (!imageNumb) + curBufSize = imageDataSize; + f.read(ptr, curBufSize); } - byte v9 = ptr[v7++]; - if (v9 > 192) { - int v10 = v9 - 192; - if (v7 == v5) { - v7 = 0; - --v16; - v5 = 64000; - if (v16 == 1) - v5 = v17; - f.read(ptr, v5); + byte curByte = ptr[curByteIdx++]; + if (curByte > 192) { + int repeatCount = curByte - 192; + if (curByteIdx == curBufSize) { + curByteIdx = 0; + --imageNumb; + curBufSize = 64000; + if (imageNumb == 1) + curBufSize = imageDataSize; + f.read(ptr, curBufSize); } - char v12 = ptr[v7++]; - do { - surface[i++] = v12; - --v10; - } while (v10); + curByte = ptr[curByteIdx++]; + for (; repeatCount; repeatCount--) + surface[i++] = curByte; + --i; } else { - surface[i] = v9; + surface[i] = curByte; } } @@ -1223,21 +1220,21 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in /** * Compute the value of a parameter plus a given percentage */ -int GraphicsManager::zoomIn(int v, int percentage ) { - if (v) - v += percentage * (long int)v / 100; +int GraphicsManager::zoomIn(int val, int percentage ) { + if (val) + val += percentage * (long int)val / 100; - return v; + return val; } /** * Compute the value of a parameter minus a given percentage */ -int GraphicsManager::zoomOut(int v, int percentage) { - if (v) - v -= percentage * (long int)v / 100; +int GraphicsManager::zoomOut(int val, int percentage) { + if (val) + val -= percentage * (long int)val / 100; - return v; + return val; } // Display 'Perfect?' -- cgit v1.2.3 From 84e290eade13bfdff1e866d058af447893bee321 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 15 Feb 2013 22:20:24 +0100 Subject: HOPKINS: Reorder includes --- engines/hopkins/graphics.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ccdd8adb36..61af620769 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -20,16 +20,18 @@ * */ +#include "hopkins/graphics.h" + +#include "hopkins/files.h" +#include "hopkins/globals.h" +#include "hopkins/hopkins.h" + #include "common/system.h" #include "graphics/palette.h" #include "graphics/decoders/pcx.h" #include "common/file.h" #include "common/rect.h" #include "engines/util.h" -#include "hopkins/files.h" -#include "hopkins/globals.h" -#include "hopkins/graphics.h" -#include "hopkins/hopkins.h" namespace Hopkins { -- cgit v1.2.3 From 7428af9a4c612b59cee7f55d867a00464b3dae64 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 Feb 2013 01:37:21 +0100 Subject: HOPKINS: Replace casted READ_LE_UINT16 by the equivalent macro to improve readability --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 61af620769..0e2df5e04a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1246,9 +1246,9 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp spriteStartP += READ_LE_UINT32(spriteStartP) + 16; const byte *spriteSizeP = spriteStartP + 4; - int spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + int spriteWidth = READ_LE_INT16(spriteSizeP); spriteSizeP += 2; - int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); + int spriteHeight2 = READ_LE_INT16(spriteSizeP); int spriteHeight1 = spriteHeight2; const byte *spritePixelsP = spriteSizeP + 10; _posXClipped = 0; @@ -1639,9 +1639,9 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int spriteWidth = 0; int spriteHeight = 0; const byte *spriteSizeP = spriteDataP + 4; - spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + spriteWidth = READ_LE_INT16(spriteSizeP); spriteSizeP += 2; - spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); + spriteHeight = READ_LE_INT16(spriteSizeP); const byte *spritePixelsP = spriteSizeP + 10; byte *destP = surface + xp + _lineNbr2 * yp; _width = spriteWidth; -- cgit v1.2.3 From f92154dbe19ecca876ffcbeca1379c1651812fb0 Mon Sep 17 00:00:00 2001 From: Dreammaster Date: Mon, 18 Feb 2013 23:30:59 -0500 Subject: HOPKINS: Changed WinScan to use actual screen pitch --- engines/hopkins/graphics.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0e2df5e04a..1009b1b3ed 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -112,7 +112,8 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenWidth = width; _screenHeight = height; - WinScan = width * 2; // Refactor me + // Clear the screen pitch. This will be set on the first lockScreen call + WinScan = 0; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -128,9 +129,12 @@ void GraphicsManager::setGraphicalMode(int width, int height) { */ void GraphicsManager::lockScreen() { if (!_skipVideoLockFl) { - if (_lockCounter++ == 0) + if (_lockCounter++ == 0) { _videoPtr = g_system->lockScreen(); - } + if (WinScan == 0) + WinScan = _videoPtr->pitch; + } + } } /** -- cgit v1.2.3 From 5bbdbc0fadf250d14e6b289172c5359cd1179896 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Feb 2013 14:34:43 +0100 Subject: HOPKINS: Misc renaming, some sound refactoring --- engines/hopkins/graphics.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 1009b1b3ed..108cad6f50 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1670,17 +1670,7 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, } while (yCtr != 1); } -// Init Screen -void GraphicsManager::INI_ECRAN(const Common::String &file, bool initializeScreen) { - OPTI_INI(file, 0, initializeScreen); -} - -// Init Screen 2 -void GraphicsManager::INI_ECRAN2(const Common::String &file, bool initializeScreen) { - OPTI_INI(file, 2, initializeScreen); -} - -void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initializeScreen) { +void GraphicsManager::initScreen(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; byte *ptr = _vm->_fileManager.searchCat(filename, 1); @@ -1723,16 +1713,14 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode, bool initia } while (!doneFlag); } _vm->_globals.freeMemory(ptr); - if (mode != 1) { - _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); + _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); - filename = file + ".rep"; - byte *dataP = _vm->_fileManager.searchCat(filename, 2); - if (dataP == g_PTRNUL) - dataP = _vm->_fileManager.loadFile(filename); + filename = file + ".rep"; + byte *dataP = _vm->_fileManager.searchCat(filename, 2); + if (dataP == g_PTRNUL) + dataP = _vm->_fileManager.loadFile(filename); - _vm->_globals._answerBuffer = dataP; - } + _vm->_globals._answerBuffer = dataP; _vm->_objectsManager._forceZoneFl = true; _vm->_objectsManager._changeVerbFl = false; } -- cgit v1.2.3 From f9f6133851b22826f8522b045107563494befad0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Feb 2013 01:23:39 +0100 Subject: HOPKINS: Misc renaming --- engines/hopkins/graphics.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 108cad6f50..890db20f13 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1043,17 +1043,17 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, } } -void GraphicsManager::FIN_VISU() { +void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx]._enabledFl) - _vm->_objectsManager.BOB_OFF(idx); + if (_vm->_globals._animBqe[idx]._enabledFl) + _vm->_objectsManager.hideBob(idx); } _vm->_eventsManager.VBL(); _vm->_eventsManager.VBL(); for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx]._enabledFl) + if (_vm->_globals._animBqe[idx]._enabledFl) _vm->_objectsManager.resetBob(idx); } @@ -1062,14 +1062,14 @@ void GraphicsManager::FIN_VISU() { } for (int idx = 1; idx <= 20; ++idx) { - _vm->_globals.Bqe_Anim[idx]._enabledFl = false; + _vm->_globals._animBqe[idx]._enabledFl = false; } } -void GraphicsManager::VISU_ALL() { +void GraphicsManager::displayAllBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals.Bqe_Anim[idx]._enabledFl) - _vm->_objectsManager.BOB_VISU(idx); + if (_vm->_globals._animBqe[idx]._enabledFl) + _vm->_objectsManager.displayBob(idx); } } -- cgit v1.2.3 From 8457c00457eac275c11bc5023b1ced8441e626b5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Feb 2013 08:30:16 +0100 Subject: HOPKINS: More misc renaming --- engines/hopkins/graphics.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 890db20f13..9429939720 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -723,7 +723,7 @@ void GraphicsManager::DD_VBL() { g_system->updateScreen(); } -void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) { +void GraphicsManager::copyWinscanVbe3(const byte *srcData, byte *destSurface) { byte srcByte; byte destLen1; byte *destSlice1P; @@ -773,7 +773,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) } } -void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { +void GraphicsManager::copyVideoVbe16(const byte *srcData) { const byte *srcP = srcData; int destOffset = 0; assert(_videoPtr); @@ -844,7 +844,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } } -void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { +void GraphicsManager::copyVideoVbe16a(const byte *srcData) { byte srcByte; int destOffset = 0; const byte *srcP = srcData; @@ -875,7 +875,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { } } -void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) { +void GraphicsManager::copySurfaceRect(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) { const byte *srcP; byte *destP; int rowCount; @@ -1073,7 +1073,7 @@ void GraphicsManager::displayAllBob() { } } -void GraphicsManager::RESET_SEGMENT_VESA() { +void GraphicsManager::resetVesaSegment() { for (int idx = 0; idx <= NBBLOC; idx++) BLOC[idx]._activeFl = false; @@ -1193,8 +1193,7 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { } } -void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { - int i; +void GraphicsManager::restoreSurfaceRect(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { int yCtr; byte *destP = xp + _lineNbr2 * yp + destSurface; @@ -1207,7 +1206,7 @@ void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, in srcP += width; destP += width; } else if (width & 2) { - for (i = width >> 1; i; --i) { + for (int i = width >> 1; i; --i) { destP[0] = srcP[0]; destP[1] = srcP[1]; srcP += 2; @@ -1742,7 +1741,7 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { DD_VBL(); } -void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { +void GraphicsManager::copyWinscanVbe(const byte *src, byte *dest) { int destOffset = 0; const byte *srcPtr = src; for (;;) { -- cgit v1.2.3 From 29c664a6966cd333862f2d1d3cd09a182be7f985 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 22 Feb 2013 17:18:44 +0100 Subject: HOPKINS: Implement a more proper function to clear the palette. --- engines/hopkins/graphics.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9429939720..b299082394 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -395,8 +395,14 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte } // Clear Palette +// CHECKME: Some versions of the game don't include it, some contains nothing more than +// than a loop doing nothing, some others just map the last value. While debugging, it +// seems that this function is called once the palette is already cleared, so it would be useless +// This code could most likely be removed. void GraphicsManager::clearPalette() { - SD_PIXELS[0] = 0; + uint16 col0 = mapRGB(0, 0, 0); + for (int i = 0; i < 512; i += 2) + WRITE_LE_UINT16(&SD_PIXELS[i], col0); } void GraphicsManager::SCANLINE(int pitch) { -- cgit v1.2.3 From 317bd9ebd088ed1e0329d14d9571015e31cc8de6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Feb 2013 22:03:38 -0500 Subject: HOPKINS: Beginnings of implementing dirty rect support --- engines/hopkins/graphics.cpp | 96 ++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 39 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b299082394..a339f9799b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -47,7 +47,11 @@ GraphicsManager::GraphicsManager() { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - NBBLOC = 0; + _dirtyRectCount = 0; + _vesaScreen = NULL; + _vesaBuffer = NULL; + _screenBuffer = NULL; + _isPhysicalPtr = false; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -73,14 +77,15 @@ GraphicsManager::GraphicsManager() { Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); - for (int i = 0; i < 250; ++i) - Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0); + for (int i = 0; i < DIRTY_RECTS_SIZE; ++i) + Common::fill((byte *)&_dirtyRects[i], (byte *)&_dirtyRects[i] + sizeof(BlocItem), 0); } GraphicsManager::~GraphicsManager() { _vm->_globals.freeMemory(_vesaScreen); _vm->_globals.freeMemory(_vesaBuffer); + _vm->_globals.freeMemory(_screenBuffer); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -107,14 +112,13 @@ void GraphicsManager::setGraphicalMode(int width, int height) { // Init surfaces _vesaScreen = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _screenBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _videoPtr = NULL; _screenWidth = width; _screenHeight = height; - // Clear the screen pitch. This will be set on the first lockScreen call - WinScan = 0; - + WinScan = width * 2; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -127,12 +131,19 @@ void GraphicsManager::setGraphicalMode(int width, int height) { /** * (try to) Lock Screen */ -void GraphicsManager::lockScreen() { +void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { if (!_skipVideoLockFl) { if (_lockCounter++ == 0) { - _videoPtr = g_system->lockScreen(); - if (WinScan == 0) - WinScan = _videoPtr->pitch; + if (shouldUsePhysicalScreen) { + Graphics::Surface *s = g_system->lockScreen(); + _videoPtr = (byte *)s->pixels; + WinScan = s->pitch; + } else { + _videoPtr = _screenBuffer; + WinScan = _width * 2; + } + + _isPhysicalPtr = shouldUsePhysicalScreen; } } } @@ -143,7 +154,9 @@ void GraphicsManager::lockScreen() { void GraphicsManager::unlockScreen() { assert(_videoPtr); if (--_lockCounter == 0) { - g_system->unlockScreen(); + if (_isPhysicalPtr) + g_system->unlockScreen(); + _videoPtr = NULL; } } @@ -153,7 +166,7 @@ void GraphicsManager::unlockScreen() { */ void GraphicsManager::clearScreen() { assert(_videoPtr); - _videoPtr->fillRect(Common::Rect(0, 0, _screenWidth, _screenHeight), 0); + Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); } /** @@ -395,14 +408,10 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte } // Clear Palette -// CHECKME: Some versions of the game don't include it, some contains nothing more than -// than a loop doing nothing, some others just map the last value. While debugging, it -// seems that this function is called once the palette is already cleared, so it would be useless -// This code could most likely be removed. void GraphicsManager::clearPalette() { - uint16 col0 = mapRGB(0, 0, 0); - for (int i = 0; i < 512; i += 2) - WRITE_LE_UINT16(&SD_PIXELS[i], col0); + // As weird as it sounds, this is what the original Linux executable does, + // and not a full array clear. + SD_PIXELS[0] = 0; } void GraphicsManager::SCANLINE(int pitch) { @@ -417,7 +426,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr->pixels + destX * 2 + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX * 2 + WinScan * destY; for (int yp = 0; yp < height; ++yp) { // Copy over the line, using the source pixels as lookups into the pixels palette @@ -436,6 +445,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); + addVesaSegment(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -448,7 +458,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr->pixels + destX + destX + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX + destX + WinScan * destY; int yNext = height; Agr_x = 0; Agr_y = 0; @@ -494,6 +504,8 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width srcP = _lineNbr2 + srcCopyP; yNext = yCtr - 1; } while (yCtr != 1); + + addVesaSegment(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -506,7 +518,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, assert(_videoPtr); const byte *srcP = surface + xp + 320 * yp; - byte *destP = (byte *)_videoPtr->pixels + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; + byte *destP = (byte *)_videoPtr + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; int yCount = height; int xCount = width; @@ -531,6 +543,8 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, srcP = loopSrcP + 320; yCount = yCtr - 1; } while (yCtr != 1); + + addVesaSegment(xp, yp, xp + width, yp + width); } /** @@ -816,7 +830,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { if (srcByte == 211) { int pixelCount = srcP[1]; int pixelIndex = srcP[2]; - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destOffset += pixelCount; while (pixelCount--) { @@ -829,7 +843,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { } else { int pixelCount = srcByte - 211; int pixelIndex = srcP[1]; - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destOffset += pixelCount; while (pixelCount--) { @@ -841,7 +855,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { srcP += 2; } } else { - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destP[0] = PAL_PIXELS[2 * srcByte]; destP[1] = PAL_PIXELS[(2 * srcByte) + 1]; ++srcP; @@ -875,7 +889,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { } } - WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); + WRITE_LE_UINT16((byte *)_videoPtr + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); ++srcP; ++destOffset; } @@ -1080,10 +1094,10 @@ void GraphicsManager::displayAllBob() { } void GraphicsManager::resetVesaSegment() { - for (int idx = 0; idx <= NBBLOC; idx++) - BLOC[idx]._activeFl = false; + for (int idx = 0; idx <= _dirtyRectCount; idx++) + _dirtyRects[idx]._activeFl = false; - NBBLOC = 0; + _dirtyRectCount = 0; } // Add VESA Segment @@ -1099,15 +1113,15 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { if (y1 < _minY) y1 = _minY; - for (int blocIndex = 0; blocIndex <= NBBLOC; blocIndex++) { - BlocItem &bloc = BLOC[blocIndex]; + for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { + BlocItem &bloc = _dirtyRects[blocIndex]; if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; }; if (addFlag) { - assert(NBBLOC < 250); - BlocItem &bloc = BLOC[++NBBLOC]; + assert(_dirtyRectCount < DIRTY_RECTS_SIZE); + BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; bloc._activeFl = true; bloc._x1 = tempX; @@ -1119,13 +1133,13 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { // Display VESA Segment void GraphicsManager::displayVesaSegment() { - if (NBBLOC == 0) + if (_dirtyRectCount == 0) return; lockScreen(); - for (int idx = 1; idx <= NBBLOC; ++idx) { - BlocItem &bloc = BLOC[idx]; + for (int idx = 1; idx <= _dirtyRectCount; ++idx) { + BlocItem &bloc = _dirtyRects[idx]; Common::Rect &dstRect = dstrect[idx - 1]; if (!bloc._activeFl) continue; @@ -1154,11 +1168,15 @@ void GraphicsManager::displayVesaSegment() { unlockScreen(); } - BLOC[idx]._activeFl = false; + byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); + g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, + dstRect.width(), dstRect.height()); + + _dirtyRects[idx]._activeFl = false; } - NBBLOC = 0; unlockScreen(); + _dirtyRectCount = 0; } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { @@ -1184,7 +1202,7 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { assert(_videoPtr); const byte *curSurface = surface; - byte *destPtr = 30 * WinScan + (byte *)_videoPtr->pixels; + byte *destPtr = 30 * WinScan + (byte *)_videoPtr; for (int y = 200; y; y--) { byte *oldDestPtr = destPtr; for (int x = 320; x; x--) { -- cgit v1.2.3 From b7419454c5416824552afd222af23d0bdfea7cb7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 25 Feb 2013 02:42:35 +0200 Subject: HOPKINS: Rename DD_VBL() -> updateScreen() --- engines/hopkins/graphics.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b299082394..03f27b5752 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -560,7 +560,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Set the transition palette and refresh the screen setPaletteVGA256(palData2); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + updateScreen(); // Added a delay in order to see the fading _vm->_eventsManager.delay(20); @@ -571,7 +571,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Refresh the screen m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + updateScreen(); } /** @@ -590,7 +590,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + updateScreen(); _vm->_eventsManager.delay(20); } @@ -602,7 +602,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); + return updateScreen(); } /** @@ -661,7 +661,7 @@ void GraphicsManager::fadeInBreakout() { lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); - DD_VBL(); + updateScreen(); } /** @@ -676,7 +676,7 @@ void GraphicsManager::fateOutBreakout() { lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); unlockScreen(); - DD_VBL(); + updateScreen(); } void GraphicsManager::setPaletteVGA256(const byte *palette) { @@ -686,7 +686,7 @@ void GraphicsManager::setPaletteVGA256(const byte *palette) { void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + updateScreen(); } void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { @@ -724,7 +724,7 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { | (b >> format.bLoss) << format.bShift; } -void GraphicsManager::DD_VBL() { +void GraphicsManager::updateScreen() { // TODO: Is this okay here? g_system->updateScreen(); } @@ -1744,7 +1744,7 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { unlockScreen(); memcpy(_vesaScreen, _vesaBuffer, 614399); - DD_VBL(); + updateScreen(); } void GraphicsManager::copyWinscanVbe(const byte *src, byte *dest) { -- cgit v1.2.3 From 54924de6cbd07e8b8cb2eb91067a0d31d08b55c8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 25 Feb 2013 22:00:36 -0500 Subject: HOPKINS: Home-screen now displaying correctly with dirty rects --- engines/hopkins/graphics.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a339f9799b..31332324fe 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -118,7 +118,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenWidth = width; _screenHeight = height; - WinScan = width * 2; + WinScan = SCREEN_WIDTH * 2; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -140,7 +140,7 @@ void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { WinScan = s->pitch; } else { _videoPtr = _screenBuffer; - WinScan = _width * 2; + WinScan = SCREEN_WIDTH * 2; } _isPhysicalPtr = shouldUsePhysicalScreen; @@ -203,6 +203,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { */ void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; + assert(!_videoPtr || !_isPhysicalPtr); bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { @@ -242,7 +243,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { } } - memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) { @@ -445,7 +446,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addVesaSegment(xs, ys, xs + width, ys + height); + addDirtyRect(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -505,7 +506,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addVesaSegment(xs, ys, xs + width, ys + width); + addDirtyRect(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -544,7 +545,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addVesaSegment(xp, yp, xp + width, yp + width); + addDirtyRect(xp, yp, xp + width, yp + width); } /** @@ -1101,7 +1102,7 @@ void GraphicsManager::resetVesaSegment() { } // Add VESA Segment -void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { +void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { int tempX = x1; bool addFlag = true; if (x2 > _maxX) @@ -1190,7 +1191,7 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); } if (addSegment) - addVesaSegment(xp, yp, xp + width, yp + height); + addDirtyRect(xp, yp, xp + width, yp + height); } /** @@ -1609,7 +1610,7 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); } if (addSegment) - addVesaSegment(xp, yp, xp + width, yp + height); + addDirtyRect(xp, yp, xp + width, yp + height); } void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { @@ -1635,7 +1636,7 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; Copy_Mem(surface, left, top, croppedWidth, croppedHeight, destSurface, destX, destY); - addVesaSegment(left, top, left + croppedWidth, top + height2); + addDirtyRect(left, top, left + croppedWidth, top + height2); } } -- cgit v1.2.3 From 79062f426ebed125d28c503decf4de11eeb17608 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Feb 2013 23:40:19 +0100 Subject: HOPKINS: Some renaming in GraphicsManager --- engines/hopkins/graphics.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 03f27b5752..ef2e07de31 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -128,13 +128,14 @@ void GraphicsManager::setGraphicalMode(int width, int height) { * (try to) Lock Screen */ void GraphicsManager::lockScreen() { - if (!_skipVideoLockFl) { - if (_lockCounter++ == 0) { - _videoPtr = g_system->lockScreen(); - if (WinScan == 0) - WinScan = _videoPtr->pitch; - } - } + if (_skipVideoLockFl) + return; + + if (_lockCounter++ == 0) { + _videoPtr = g_system->lockScreen(); + if (WinScan == 0) + WinScan = _videoPtr->pitch; + } } /** @@ -169,13 +170,13 @@ void GraphicsManager::loadImage(const Common::String &file) { * Load VGA Image */ void GraphicsManager::loadVgaImage(const Common::String &file) { - SCANLINE(SCREEN_WIDTH); + setScreenWidth(SCREEN_WIDTH); lockScreen(); clearScreen(); unlockScreen(); loadPCX320(_vesaScreen, file, _palette); memcpy(_vesaBuffer, _vesaScreen, 64000); - SCANLINE(320); + setScreenWidth(320); _maxX = 320; lockScreen(); @@ -209,14 +210,14 @@ void GraphicsManager::loadScreen(const Common::String &file) { clearPalette(); if (!_largeScreenFl) { - SCANLINE(SCREEN_WIDTH); + setScreenWidth(SCREEN_WIDTH); _maxX = SCREEN_WIDTH; lockScreen(); clearScreen(); m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } else { - SCANLINE(SCREEN_WIDTH * 2); + setScreenWidth(SCREEN_WIDTH * 2); _maxX = SCREEN_WIDTH * 2; lockScreen(); clearScreen(); @@ -405,7 +406,7 @@ void GraphicsManager::clearPalette() { WRITE_LE_UINT16(&SD_PIXELS[i], col0); } -void GraphicsManager::SCANLINE(int pitch) { +void GraphicsManager::setScreenWidth(int pitch) { _lineNbr = _lineNbr2 = pitch; } @@ -1776,7 +1777,7 @@ void GraphicsManager::copyWinscanVbe(const byte *src, byte *dest) { } // Reduce Screen -void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { +void GraphicsManager::reduceScreenPart(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { const byte *srcP = xp + _lineNbr2 * yp + srcSurface; byte *destP = destSurface; Red = zoom; -- cgit v1.2.3 From 58eefc0833a540213298f75e87222b12831dd1f7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Feb 2013 00:15:54 +0100 Subject: HOPKINS: Get rid of magic values in FilesManager --- engines/hopkins/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ef2e07de31..51c6e2a733 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -193,7 +193,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; bool flag = true; - if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { + if (_vm->_fileManager.searchCat(file, RES_PIC) == g_PTRNUL) { if (!f.open(file)) error("loadScreen - %s", file.c_str()); @@ -1678,7 +1678,7 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, void GraphicsManager::initScreen(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager.searchCat(filename, 1); + byte *ptr = _vm->_fileManager.searchCat(filename, RES_INI); if (ptr == g_PTRNUL) { ptr = _vm->_fileManager.loadFile(filename); @@ -1687,7 +1687,7 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init filename = file + ".spr"; _vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN); if (initializeScreen) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, RES_SLI); if (_vm->_globals.SPRITE_ECRAN) { _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(filename); } else { @@ -1696,7 +1696,7 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init } } if (READ_BE_UINT24(ptr) != MKTAG24('I', 'N', 'I')) { - error("Error, file not ini"); + error("Invalid INI File %s", file); } else { bool doneFlag = false; int dataOffset = 1; @@ -1722,7 +1722,7 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); filename = file + ".rep"; - byte *dataP = _vm->_fileManager.searchCat(filename, 2); + byte *dataP = _vm->_fileManager.searchCat(filename, RES_REP); if (dataP == g_PTRNUL) dataP = _vm->_fileManager.loadFile(filename); -- cgit v1.2.3 From 2168b2e6b52595d0be38c4a738a5e45f5cac6ff4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Feb 2013 00:25:52 +0100 Subject: HOPKINS: Fix bug in previous commit. Thanks Kirben for pointing to it --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 51c6e2a733..31dbcd3d83 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1696,7 +1696,7 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init } } if (READ_BE_UINT24(ptr) != MKTAG24('I', 'N', 'I')) { - error("Invalid INI File %s", file); + error("Invalid INI File %s", file.c_str()); } else { bool doneFlag = false; int dataOffset = 1; -- cgit v1.2.3 From c3bab0aecbb00f55493a0816c217d33dc9359793 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 26 Feb 2013 07:57:30 -0500 Subject: HOPKINS: Cleaned up the addDirtyRect method --- engines/hopkins/graphics.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 31332324fe..ea65ad7432 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1103,29 +1103,25 @@ void GraphicsManager::resetVesaSegment() { // Add VESA Segment void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { - int tempX = x1; bool addFlag = true; - if (x2 > _maxX) - x2 = _maxX; - if (y2 > _maxY) - y2 = _maxY; - if (x1 < _minX) - tempX = _minX; - if (y1 < _minY) - y1 = _minY; + + x1 = CLIP(x1, _minX, _maxX); + y1 = CLIP(y1, _minY, _maxY); + x2 = CLIP(x2, _minX, _maxX); + y2 = CLIP(y2, _minY, _maxY); for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { BlocItem &bloc = _dirtyRects[blocIndex]; - if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) + if (bloc._activeFl && x1 >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; }; - if (addFlag) { + if (addFlag && (x2 > x1) && (y2 > y1)) { assert(_dirtyRectCount < DIRTY_RECTS_SIZE); BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; bloc._activeFl = true; - bloc._x1 = tempX; + bloc._x1 = x1; bloc._x2 = x2; bloc._y1 = y1; bloc._y2 = y2; -- cgit v1.2.3 From d738802bc1d1441fee8bce3881cd5233044305d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 17:30:42 -0500 Subject: HOPKINS: Converted dirty rects to use Common::Array --- engines/hopkins/graphics.cpp | 83 ++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 50 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ea65ad7432..c998a3b011 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -47,7 +47,6 @@ GraphicsManager::GraphicsManager() { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - _dirtyRectCount = 0; _vesaScreen = NULL; _vesaBuffer = NULL; _screenBuffer = NULL; @@ -76,10 +75,6 @@ GraphicsManager::GraphicsManager() { Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); - - for (int i = 0; i < DIRTY_RECTS_SIZE; ++i) - Common::fill((byte *)&_dirtyRects[i], (byte *)&_dirtyRects[i] + sizeof(BlocItem), 0); - } GraphicsManager::~GraphicsManager() { @@ -1095,72 +1090,62 @@ void GraphicsManager::displayAllBob() { } void GraphicsManager::resetVesaSegment() { - for (int idx = 0; idx <= _dirtyRectCount; idx++) - _dirtyRects[idx]._activeFl = false; - - _dirtyRectCount = 0; + _dirtyRects.clear(); } // Add VESA Segment void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { - bool addFlag = true; - x1 = CLIP(x1, _minX, _maxX); y1 = CLIP(y1, _minY, _maxY); x2 = CLIP(x2, _minX, _maxX); y2 = CLIP(y2, _minY, _maxY); - for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { - BlocItem &bloc = _dirtyRects[blocIndex]; - if (bloc._activeFl && x1 >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) - addFlag = false; - }; - - if (addFlag && (x2 > x1) && (y2 > y1)) { - assert(_dirtyRectCount < DIRTY_RECTS_SIZE); - BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; - - bloc._activeFl = true; - bloc._x1 = x1; - bloc._x2 = x2; - bloc._y1 = y1; - bloc._y2 = y2; + Common::Rect newRect(x1, y1, x2, y2); + if (!newRect.isValidRect()) + return; + + // Don't bother adding the rect if it's contained within another existing one + for (uint rectIndex = 0; rectIndex < _dirtyRects.size(); ++rectIndex) { + const Common::Rect &r = _dirtyRects[rectIndex]; + if (r.contains(newRect)) + return; } + + assert(_dirtyRects.size() < DIRTY_RECTS_SIZE); + _dirtyRects.push_back(newRect); } // Display VESA Segment void GraphicsManager::displayVesaSegment() { - if (_dirtyRectCount == 0) + if (_dirtyRects.size() == 0) return; lockScreen(); - for (int idx = 1; idx <= _dirtyRectCount; ++idx) { - BlocItem &bloc = _dirtyRects[idx]; - Common::Rect &dstRect = dstrect[idx - 1]; - if (!bloc._activeFl) - continue; + for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { + Common::Rect &r = _dirtyRects[idx]; + Common::Rect &dstRect = dstrect[idx]; if (_vm->_eventsManager._breakoutFl) { - Copy_Vga16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1); - dstRect.left = bloc._x1 * 2; - dstRect.top = bloc._y1 * 2 + 30; - dstRect.setWidth((bloc._x2 - bloc._x1) * 2); - dstRect.setHeight((bloc._y2 - bloc._y1) * 2); - } else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { - if (bloc._x1 < _vm->_eventsManager._startPos.x) - bloc._x1 = _vm->_eventsManager._startPos.x; - if (bloc._x2 > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) - bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; + Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + dstRect.left = r.left * 2; + dstRect.top = r.top * 2 + 30; + dstRect.setWidth((r.right - r.left) * 2); + dstRect.setHeight((r.bottom - r.top) * 2); + } else if (r.right > _vm->_eventsManager._startPos.x && r.left < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { + if (r.left < _vm->_eventsManager._startPos.x) + r.left = _vm->_eventsManager._startPos.x; + if (r.right > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) + r.right = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access lockScreen(); - m_scroll16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1); + m_scroll16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager._startPos.x, r.top); - dstRect.left = bloc._x1 - _vm->_eventsManager._startPos.x; - dstRect.top = bloc._y1; - dstRect.setWidth(bloc._x2 - bloc._x1); - dstRect.setHeight(bloc._y2 - bloc._y1); + dstRect.left = r.left - _vm->_eventsManager._startPos.x; + dstRect.top = r.top; + dstRect.setWidth(r.right - r.left); + dstRect.setHeight(r.bottom - r.top); unlockScreen(); } @@ -1168,12 +1153,10 @@ void GraphicsManager::displayVesaSegment() { byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, dstRect.width(), dstRect.height()); - - _dirtyRects[idx]._activeFl = false; } unlockScreen(); - _dirtyRectCount = 0; + resetVesaSegment(); } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { -- cgit v1.2.3 From 7c862d586ede81d759eafae831f8fd54684d92bd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 18:56:14 -0500 Subject: HOPKINS: Preparatory work for a refresh rect list --- engines/hopkins/graphics.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c998a3b011..4fe9c4ef39 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -612,7 +612,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); + DD_VBL(); } /** @@ -735,7 +735,10 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { } void GraphicsManager::DD_VBL() { - // TODO: Is this okay here? + // Display any aras of the screen that need refreshing + displayRefreshRects(); + + // Update the screen g_system->updateScreen(); } @@ -1093,7 +1096,11 @@ void GraphicsManager::resetVesaSegment() { _dirtyRects.clear(); } -// Add VESA Segment +void GraphicsManager::resetRefreshRects() { + _refreshRects.clear(); +} + +// Add a game area dirty rectangle void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { x1 = CLIP(x1, _minX, _maxX); y1 = CLIP(y1, _minY, _maxY); @@ -1115,7 +1122,19 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { _dirtyRects.push_back(newRect); } -// Display VESA Segment +// Add a refresh rect +void GraphicsManager::addRefreshRect(const Common::Rect &r) { + // Ensure that an existing dest rectangle doesn't already contain the new one + for (uint idx = 0; idx < _refreshRects.size(); ++idx) { + if (_refreshRects[idx].contains(r)) + return; + } + + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + _refreshRects.push_back(r); +} + +// Draw any game dirty rects onto the screen intermediate surface void GraphicsManager::displayVesaSegment() { if (_dirtyRects.size() == 0) return; @@ -1124,7 +1143,7 @@ void GraphicsManager::displayVesaSegment() { for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; - Common::Rect &dstRect = dstrect[idx]; + Common::Rect dstRect; if (_vm->_eventsManager._breakoutFl) { Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); @@ -1159,6 +1178,19 @@ void GraphicsManager::displayVesaSegment() { resetVesaSegment(); } +void GraphicsManager::displayRefreshRects() { + if (_refreshRects.size() == 0) + return; +/* + for (uint idx = 0; idx < _refreshRects.size(); ++idx) { + const Common::Rect &r = _refreshRects[idx]; + + g_system->copyRectToScreen(_screenBuffer, WinScan,) + } +*/ + resetRefreshRects(); +} + void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { int width = _vm->_objectsManager.getWidth(objectData, idx); int height = _vm->_objectsManager.getHeight(objectData, idx); -- cgit v1.2.3 From 95aca78bcdc42a2765220c2fbd990539168b15b5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 20:40:03 -0500 Subject: HOPKINS: Renamed dirty rect methods --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4fe9c4ef39..75280c48d7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1092,7 +1092,7 @@ void GraphicsManager::displayAllBob() { } } -void GraphicsManager::resetVesaSegment() { +void GraphicsManager::resetDirtyRects() { _dirtyRects.clear(); } @@ -1135,7 +1135,7 @@ void GraphicsManager::addRefreshRect(const Common::Rect &r) { } // Draw any game dirty rects onto the screen intermediate surface -void GraphicsManager::displayVesaSegment() { +void GraphicsManager::displayDirtyRects() { if (_dirtyRects.size() == 0) return; @@ -1175,7 +1175,7 @@ void GraphicsManager::displayVesaSegment() { } unlockScreen(); - resetVesaSegment(); + resetDirtyRects(); } void GraphicsManager::displayRefreshRects() { -- cgit v1.2.3 From 9d8eb97840072ee2c55dabdaf07c05b4db086eea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 20:57:42 -0500 Subject: HOPKINS: Hooked up display code for refresh rects --- engines/hopkins/graphics.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 75280c48d7..c7b6904335 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -162,6 +162,8 @@ void GraphicsManager::unlockScreen() { void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); + if (!_isPhysicalPtr) + addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } /** @@ -1179,15 +1181,14 @@ void GraphicsManager::displayDirtyRects() { } void GraphicsManager::displayRefreshRects() { - if (_refreshRects.size() == 0) - return; -/* + // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; - g_system->copyRectToScreen(_screenBuffer, WinScan,) + byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2); + g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height()); } -*/ + resetRefreshRects(); } -- cgit v1.2.3 From 77eb6f74eb17deda5e629457ca4ec144782fddfe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 21:47:03 -0500 Subject: HOPKINS: Fix to not display dirty rects that are off-screen --- engines/hopkins/graphics.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c7b6904335..0c06ef7f48 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1171,9 +1171,12 @@ void GraphicsManager::displayDirtyRects() { unlockScreen(); } - byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); - g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, - dstRect.width(), dstRect.height()); + // If it's a valid rect, then copy it over + if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) { + byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); + g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, + dstRect.width(), dstRect.height()); + } } unlockScreen(); -- cgit v1.2.3 From 7a7b2b35e2be1e6526d8aeea2576e8c9231aa73c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 22:36:38 -0500 Subject: HOPKINS: Added a debugger command to frame dirty rects --- engines/hopkins/graphics.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0c06ef7f48..540c18f1b4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -51,6 +51,7 @@ GraphicsManager::GraphicsManager() { _vesaBuffer = NULL; _screenBuffer = NULL; _isPhysicalPtr = false; + _showDirtyRects = false; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -1142,6 +1143,13 @@ void GraphicsManager::displayDirtyRects() { return; lockScreen(); + + // Refresh the entire screen + Graphics::Surface *screenSurface = NULL; + if (_showDirtyRects) { + screenSurface = g_system->lockScreen(); + g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; @@ -1176,10 +1184,16 @@ void GraphicsManager::displayDirtyRects() { byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, dstRect.width(), dstRect.height()); + + if (_showDirtyRects) + screenSurface->frameRect(dstRect, 0xffffff); } } unlockScreen(); + if (_showDirtyRects) + g_system->unlockScreen(); + resetDirtyRects(); } -- cgit v1.2.3 From 23badc97357162bfe8de06afc679b459c70d2f27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 4 Mar 2013 07:46:15 +0100 Subject: HOPKINS: Some renaming --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 31dbcd3d83..9f4c910ff3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1056,8 +1056,8 @@ void GraphicsManager::endDisplayBob() { _vm->_objectsManager.hideBob(idx); } - _vm->_eventsManager.VBL(); - _vm->_eventsManager.VBL(); + _vm->_eventsManager.refreshScreenAndEvents(); + _vm->_eventsManager.refreshScreenAndEvents(); for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals._animBqe[idx]._enabledFl) -- cgit v1.2.3 From f93275b3109943a76bd75163d5f4e5bc2cee982c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Mar 2013 09:42:06 -0500 Subject: HOPKINS: Removed usage of g_system->lockScreen --- engines/hopkins/graphics.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 540c18f1b4..ecefe4c73e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -50,7 +50,6 @@ GraphicsManager::GraphicsManager() { _vesaScreen = NULL; _vesaBuffer = NULL; _screenBuffer = NULL; - _isPhysicalPtr = false; _showDirtyRects = false; _lineNbr2 = 0; @@ -127,19 +126,11 @@ void GraphicsManager::setGraphicalMode(int width, int height) { /** * (try to) Lock Screen */ -void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { +void GraphicsManager::lockScreen() { if (!_skipVideoLockFl) { if (_lockCounter++ == 0) { - if (shouldUsePhysicalScreen) { - Graphics::Surface *s = g_system->lockScreen(); - _videoPtr = (byte *)s->pixels; - WinScan = s->pitch; - } else { - _videoPtr = _screenBuffer; - WinScan = SCREEN_WIDTH * 2; - } - - _isPhysicalPtr = shouldUsePhysicalScreen; + _videoPtr = _screenBuffer; + WinScan = SCREEN_WIDTH * 2; } } } @@ -150,9 +141,6 @@ void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { void GraphicsManager::unlockScreen() { assert(_videoPtr); if (--_lockCounter == 0) { - if (_isPhysicalPtr) - g_system->unlockScreen(); - _videoPtr = NULL; } } @@ -163,8 +151,8 @@ void GraphicsManager::unlockScreen() { void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); - if (!_isPhysicalPtr) - addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + + addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } /** @@ -201,7 +189,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { */ void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; - assert(!_videoPtr || !_isPhysicalPtr); + assert(!_videoPtr); bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { @@ -1198,14 +1186,25 @@ void GraphicsManager::displayDirtyRects() { } void GraphicsManager::displayRefreshRects() { + Graphics::Surface *screenSurface = NULL; + if (_showDirtyRects) { + screenSurface = g_system->lockScreen(); + g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2); g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height()); + + if (_showDirtyRects) + screenSurface->frameRect(r, 0xffffff); } + if (_showDirtyRects) + g_system->unlockScreen(); + resetRefreshRects(); } -- cgit v1.2.3 From 188f7efd0584c975e9e5d2ae38752c7217083cb0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Mar 2013 20:58:43 -0500 Subject: HOPKINS: Fix display of screen images using screen fade in --- engines/hopkins/graphics.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ecefe4c73e..d4e1a25e9e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -727,6 +727,7 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { void GraphicsManager::DD_VBL() { // Display any aras of the screen that need refreshing + displayDirtyRects(); displayRefreshRects(); // Update the screen -- cgit v1.2.3 From 83480c5784dd4193fa6b5dd3bb2f7a75ac67715d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Mar 2013 09:46:05 -0500 Subject: HOPKINS: Fix transition between initial version display to intro animation --- engines/hopkins/graphics.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d4e1a25e9e..f3116930a0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -150,11 +150,18 @@ void GraphicsManager::unlockScreen() { */ void GraphicsManager::clearScreen() { assert(_videoPtr); - Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); + Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } +void GraphicsManager::clearVesaScreen() { + warning("clearVesa"); + Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); + Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); + addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); +} + /** * Load Image */ -- cgit v1.2.3 From 55c024494d80b343fc23d8e534153fd9c873f040 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Mar 2013 09:44:46 -0500 Subject: HOPKINS: Fix problem with scrolling not working properly --- engines/hopkins/graphics.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f3116930a0..b5c0660a3a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -152,11 +152,10 @@ void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); - addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } void GraphicsManager::clearVesaScreen() { - warning("clearVesa"); Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); @@ -439,7 +438,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addDirtyRect(xs, ys, xs + width, ys + height); + addRefreshRect(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -499,7 +498,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xs, ys, xs + width, ys + width); + addRefreshRect(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -538,7 +537,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xp, yp, xp + width, yp + width); + addRefreshRect(xp, yp, xp + width, yp + width); } /** @@ -1122,15 +1121,18 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { } // Add a refresh rect -void GraphicsManager::addRefreshRect(const Common::Rect &r) { - // Ensure that an existing dest rectangle doesn't already contain the new one - for (uint idx = 0; idx < _refreshRects.size(); ++idx) { - if (_refreshRects[idx].contains(r)) - return; - } +void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { + x1 = MAX(x1, 0); + y1 = MAX(y1, 0); + x2 = MIN(x2, SCREEN_WIDTH); + y2 = MIN(y2, SCREEN_HEIGHT); - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - _refreshRects.push_back(r); + if ((x2 > x1) && (y2 > y1)) { + Common::Rect r(x1, y1, x2, y2); + + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + _refreshRects.push_back(r); + } } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From 3d06a93be163d9cc99d5c06036408e3020d5e76e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Mar 2013 22:04:41 -0500 Subject: HOPKINS: Merged dirty/refresh rect rect adding into a single method --- engines/hopkins/graphics.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b5c0660a3a..af142ac2c3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1105,19 +1105,8 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { x2 = CLIP(x2, _minX, _maxX); y2 = CLIP(y2, _minY, _maxY); - Common::Rect newRect(x1, y1, x2, y2); - if (!newRect.isValidRect()) - return; - - // Don't bother adding the rect if it's contained within another existing one - for (uint rectIndex = 0; rectIndex < _dirtyRects.size(); ++rectIndex) { - const Common::Rect &r = _dirtyRects[rectIndex]; - if (r.contains(newRect)) - return; - } - - assert(_dirtyRects.size() < DIRTY_RECTS_SIZE); - _dirtyRects.push_back(newRect); + if ((x2 > x1) && (y2 > y1)) + addRectToArray(_dirtyRects, Common::Rect(x1, y1, x2, y2)); } // Add a refresh rect @@ -1127,12 +1116,25 @@ void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { x2 = MIN(x2, SCREEN_WIDTH); y2 = MIN(y2, SCREEN_HEIGHT); - if ((x2 > x1) && (y2 > y1)) { - Common::Rect r(x1, y1, x2, y2); + if ((x2 > x1) && (y2 > y1)) + addRectToArray(_refreshRects, Common::Rect(x1, y1, x2, y2)); +} - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - _refreshRects.push_back(r); +void GraphicsManager::addRectToArray(Common::Array &rects, const Common::Rect &newRect) { + // Scan for an intersection with existing rects + for (uint rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { + Common::Rect &r = rects[rectIndex]; + + if (r.intersects(newRect)) { + // Rect either intersects or is completely inside existing one, so extend existing one as necessary + r.extend(newRect); + return; + } } + + // Ensure that the rect list doesn't get too big, and add the new one in + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + rects.push_back(newRect); } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From e50a7be7defca39b89941a7bade023db87e6bf01 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Mar 2013 22:09:29 -0400 Subject: HOPKINS: Further fix for dirty area display in-game --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index af142ac2c3..bad67603c5 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -438,7 +438,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addRefreshRect(xs, ys, xs + width, ys + height); + addRefreshRect(destX, destY, destX + width, destY + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -498,7 +498,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addRefreshRect(xs, ys, xs + width, ys + width); + addRefreshRect(destX, destY, destX + width, destY + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -537,7 +537,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addRefreshRect(xp, yp, xp + width, yp + width); + addRefreshRect(destX, destY, destX + width, destY + width); } /** -- cgit v1.2.3 From f49fb723dafff9e8b9f213cff785e580c671a3a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Mar 2013 22:15:12 -0400 Subject: HOPKINS: Added a more comprehensive rects merge code --- engines/hopkins/graphics.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index bad67603c5..326571828e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1122,19 +1122,39 @@ void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { void GraphicsManager::addRectToArray(Common::Array &rects, const Common::Rect &newRect) { // Scan for an intersection with existing rects - for (uint rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { + uint rectIndex; + for (rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { Common::Rect &r = rects[rectIndex]; if (r.intersects(newRect)) { // Rect either intersects or is completely inside existing one, so extend existing one as necessary r.extend(newRect); - return; + break; } } + if (rectIndex == rects.size()) { + // Rect not intersecting any existing one, so add it in + assert(rects.size() < DIRTY_RECTS_SIZE); + rects.push_back(newRect); + } + + // Take care of merging the existing rect list. This is done as a separate check even if + // a previous extending above has been done, since the merging of the new rect above may + // result in further rects now able to be merged + + for (int srcIndex = rects.size() - 1; srcIndex > 0; --srcIndex) { + const Common::Rect &srcRect = rects[srcIndex]; - // Ensure that the rect list doesn't get too big, and add the new one in - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - rects.push_back(newRect); + // Loop through all the other rects to see if it intersects them + for (int destIndex = srcIndex - 1; destIndex >= 0; --destIndex) { + if (rects[destIndex].intersects(srcRect)) { + // Found an intersection, so extend the found one, and delete the original + rects[destIndex].extend(srcRect); + rects.remove_at(srcIndex); + break; + } + } + } } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From 408345ebabe803f239e85d32a0627f5ca5c7b46b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Mar 2013 21:43:48 -0400 Subject: HOPKINS: Further cleaned up dirty rect display --- engines/hopkins/graphics.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 326571828e..4041363814 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -185,6 +185,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); + addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); unlockScreen(); fadeInBreakout(); @@ -1165,12 +1166,6 @@ void GraphicsManager::displayDirtyRects() { lockScreen(); // Refresh the entire screen - Graphics::Surface *screenSurface = NULL; - if (_showDirtyRects) { - screenSurface = g_system->lockScreen(); - g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - } - for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; Common::Rect dstRect; @@ -1199,21 +1194,12 @@ void GraphicsManager::displayDirtyRects() { unlockScreen(); } - // If it's a valid rect, then copy it over - if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) { - byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); - g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, - dstRect.width(), dstRect.height()); - - if (_showDirtyRects) - screenSurface->frameRect(dstRect, 0xffffff); - } + // If it's a valid rect, then add it to the list of areas to refresh on the screen + if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) + addRectToArray(_refreshRects, dstRect); } unlockScreen(); - if (_showDirtyRects) - g_system->unlockScreen(); - resetDirtyRects(); } -- cgit v1.2.3 From 39ffd06839531cb9a2e81e9c89b820b6332327d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Mar 2013 22:58:48 -0400 Subject: HOPKINS: Bugfix for refreshing Breakout lives when one is lost --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4041363814..798b350fcd 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -675,7 +675,7 @@ void GraphicsManager::fadeInBreakout() { /** * Fade out used by for the breakout mini-game */ -void GraphicsManager::fateOutBreakout() { +void GraphicsManager::fadeOutBreakout() { byte palette[PALETTE_EXT_BLOCK_SIZE]; memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); -- cgit v1.2.3 From b0ad532a922109c366a14ca877b7844a79f92dfd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 08:05:37 +0100 Subject: HOPKINS: Some renaming in TalkManager and GraphicsManager --- engines/hopkins/graphics.cpp | 252 +++++++++++++++++++++---------------------- 1 file changed, 124 insertions(+), 128 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 09fe2f1f2a..ac3fdb493f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -53,8 +53,8 @@ GraphicsManager::GraphicsManager() { _showDirtyRects = false; _lineNbr2 = 0; - Agr_x = Agr_y = 0; - Agr_Flag_x = Agr_Flag_y = false; + _enlargedX = _enlargedY = 0; + _enlargedXFl = _enlargedYFl = false; _fadeDefaultSpeed = 15; FADE_LINUX = 0; _skipVideoLockFl = false; @@ -66,8 +66,8 @@ GraphicsManager::GraphicsManager() { _posXClipped = _posYClipped = 0; clip_x1 = clip_y1 = 0; _clipFl = false; - Red_x = Red_y = 0; - Red = 0; + _reduceX = _reducedY = 0; + _zoomOutFactor = 0; _width = 0; _specialWidth = 0; @@ -247,9 +247,7 @@ void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) for (int idx = 0; idx < 256; ++idx) { byte v = _colorTable[idx]; - if (v > 27) - _colorTable[idx] = 0; - if (!v) + if (v > 27 || !v) _colorTable[idx] = 0; } @@ -454,9 +452,9 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width const byte *srcP = xs + _lineNbr2 * ys + surface; byte *destP = (byte *)_videoPtr + destX + destX + WinScan * destY; int yNext = height; - Agr_x = 0; - Agr_y = 0; - Agr_Flag_y = false; + _enlargedX = 0; + _enlargedY = 0; + _enlargedYFl = false; do { for (;;) { @@ -465,14 +463,14 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width xCtr = width; yCtr = yNext; palette = PAL_PIXELS; - Agr_x = 0; + _enlargedX = 0; do { destP[0] = palette[2 * srcP[0]]; destP[1] = palette[(2 * srcP[0]) + 1]; destP += 2; - if (Agr_x >= 100) { - Agr_x -= 100; + if (_enlargedX >= 100) { + _enlargedX -= 100; destP[0] = palette[2 * srcP[0]]; destP[1] = palette[(2 * srcP[0]) + 1]; destP += 2; @@ -484,17 +482,17 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr; srcP = srcCopyP; destP = WinScan + destCopyP; - if (Agr_Flag_y) + if (_enlargedYFl) break; - if (Agr_y >= 0 && Agr_y < 100) + if (_enlargedY >= 0 && _enlargedY < 100) break; - Agr_y -= 100; - Agr_Flag_y = true; + _enlargedY -= 100; + _enlargedYFl = true; } - Agr_Flag_y = false; + _enlargedYFl = false; srcP = _lineNbr2 + srcCopyP; yNext = yCtr - 1; } while (yCtr != 1); @@ -1350,23 +1348,23 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp byte *dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface; if (zoom2) { - Agr_x = 0; - Agr_y = 0; - Agr_Flag_y = false; - Agr_Flag_x = false; + _enlargedX = 0; + _enlargedY = 0; + _enlargedYFl = false; + _enlargedXFl = false; _width = spriteWidth; int zoomedWidth = zoomIn(spriteWidth, zoom2); int zoomedHeight = zoomIn(spriteHeight1, zoom2); if (flipFl) { - byte *v29 = zoomedWidth + dest1P; + byte *clippedDestP = zoomedWidth + dest1P; if (_posYClipped) { if (_posYClipped < 0 || _posYClipped >= zoomedHeight) return; - int v30 = 0; - while (zoomIn(++v30, zoom2) < _posYClipped) + int hiddenHeight = 0; + while (zoomIn(++hiddenHeight, zoom2) < _posYClipped) ; - spritePixelsP += _width * v30; - v29 += _lineNbr2 * _posYClipped; + spritePixelsP += _width * hiddenHeight; + clippedDestP += _lineNbr2 * _posYClipped; zoomedHeight -= _posYClipped; } if (zoomedHeight > clip_y1) @@ -1377,64 +1375,64 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp zoomedWidth -= _posXClipped; } if (zoomedWidth > clip_x1) { - int v32 = zoomedWidth - clip_x1; - v29 -= v32; - int v33 = 0; - while (zoomIn(++v33, zoom2) < v32) + int clippedZoomedWidth = zoomedWidth - clip_x1; + clippedDestP -= clippedZoomedWidth; + int closestWidth = 0; + while (zoomIn(++closestWidth, zoom2) < clippedZoomedWidth) ; - spritePixelsP += v33; + spritePixelsP += closestWidth; zoomedWidth = clip_x1; } - int v63; + int curHeight; do { for (;;) { - v63 = zoomedHeight; - byte *v53 = v29; + curHeight = zoomedHeight; + byte *oldDestP = clippedDestP; const byte *oldSpritePixelsP = spritePixelsP; - Agr_Flag_x = false; - Agr_x = 0; - for (int v35 = zoomedWidth; v35; Agr_Flag_x = false, v35--) { + _enlargedXFl = false; + _enlargedX = 0; + for (int i = zoomedWidth; i; _enlargedXFl = false, i--) { for (;;) { if (*spritePixelsP) - *v29 = *spritePixelsP; - --v29; + *clippedDestP = *spritePixelsP; + --clippedDestP; ++spritePixelsP; - if (!Agr_Flag_x) - Agr_x += zoom2; - if (Agr_x >= 0 && Agr_x < 100) + if (!_enlargedXFl) + _enlargedX += zoom2; + if (_enlargedX >= 0 && _enlargedX < 100) break; - Agr_x -= 100; + _enlargedX -= 100; --spritePixelsP; - Agr_Flag_x = true; - --v35; - if (!v35) + _enlargedXFl = true; + --i; + if (!i) break; } } spritePixelsP = _width + oldSpritePixelsP; - v29 = _lineNbr2 + v53; - if (!Agr_Flag_y) - Agr_y += zoom2; - if ((uint16)Agr_y < 100) + clippedDestP = _lineNbr2 + oldDestP; + if (!_enlargedYFl) + _enlargedY += zoom2; + if (_enlargedY >= 0 && _enlargedY < 100) break; - Agr_y -= 100; + _enlargedY -= 100; spritePixelsP = oldSpritePixelsP; - Agr_Flag_y = true; - zoomedHeight = v63 - 1; - if (v63 == 1) + _enlargedYFl = true; + zoomedHeight = curHeight - 1; + if (curHeight == 1) return; } - Agr_Flag_y = false; - zoomedHeight = v63 - 1; - } while (v63 != 1); + _enlargedYFl = false; + zoomedHeight = curHeight - 1; + } while (curHeight != 1); } else { if (_posYClipped) { if (_posYClipped >= zoomedHeight) return; - int v23 = 0; - while (zoomIn(++v23, zoom2) < _posYClipped) + int closerHeight = 0; + while (zoomIn(++closerHeight, zoom2) < _posYClipped) ; - spritePixelsP += _width * v23; + spritePixelsP += _width * closerHeight; dest1P += _lineNbr2 * _posYClipped; zoomedHeight -= _posYClipped; } @@ -1443,92 +1441,90 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp if (_posXClipped) { if (_posXClipped >= zoomedWidth) return; - int v26 = 0; - while (zoomIn(++v26, zoom2) < _posXClipped) + int closerWidth = 0; + while (zoomIn(++closerWidth, zoom2) < _posXClipped) ; - spritePixelsP += v26; + spritePixelsP += closerWidth; dest1P += _posXClipped; zoomedWidth = zoomedWidth - _posXClipped; } if (zoomedWidth > clip_x1) zoomedWidth = clip_x1; - int v60; + int curHeight; do { for (;;) { - v60 = zoomedHeight; + curHeight = zoomedHeight; byte *oldDest1P = dest1P; const byte *oldSpritePixelsP = spritePixelsP; - Agr_Flag_x = false; - Agr_x = 0; - for (int v28 = zoomedWidth; v28; Agr_Flag_x = false, v28--) { + _enlargedXFl = false; + _enlargedX = 0; + for (int i = zoomedWidth; i; _enlargedXFl = false, i--) { for (;;) { if (*spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; - if (!Agr_Flag_x) - Agr_x += zoom2; - if ((uint16)Agr_x < 100) + if (!_enlargedXFl) + _enlargedX += zoom2; + if (_enlargedX >= 0 && _enlargedX < 100) break; - Agr_x -= 100; + _enlargedX -= 100; --spritePixelsP; - Agr_Flag_x = true; - --v28; - if (!v28) + _enlargedXFl = true; + --i; + if (!i) break; } } spritePixelsP = _width + oldSpritePixelsP; dest1P = _lineNbr2 + oldDest1P; - if (!Agr_Flag_y) - Agr_y += zoom2; - if ((uint16)Agr_y < 100) + if (!_enlargedYFl) + _enlargedY += zoom2; + if (_enlargedY >= 0 && _enlargedY < 100) break; - Agr_y -= 100; + _enlargedY -= 100; spritePixelsP = oldSpritePixelsP; - Agr_Flag_y = true; - zoomedHeight = v60 - 1; - if (v60 == 1) + _enlargedYFl = true; + zoomedHeight = curHeight - 1; + if (curHeight == 1) return; } - Agr_Flag_y = false; - zoomedHeight = v60 - 1; - } while (v60 != 1); + _enlargedYFl = false; + zoomedHeight = curHeight - 1; + } while (curHeight != 1); } } else if (zoom1) { - Red_x = 0; - Red_y = 0; + _reduceX = 0; + _reducedY = 0; _width = spriteWidth; - Red = zoom1; + _zoomOutFactor = zoom1; if (zoom1 < 100) { - int v37 = zoomOut(spriteWidth, Red); + int zoomedSpriteWidth = zoomOut(spriteWidth, _zoomOutFactor); if (flipFl) { - byte *v40 = v37 + dest1P; + byte *curDestP = zoomedSpriteWidth + dest1P; do { - int v65 = spriteHeight2; - byte *v55 = v40; - Red_y += Red; - if ((uint16)Red_y < 100) { - Red_x = 0; - int v42 = v37; - for (int v41 = _width; v41; v41--) { - Red_x += Red; - if ((uint16)Red_x < 100) { - if (v42 >= _posXClipped && v42 < clip_x1 && *spritePixelsP) - *v40 = *spritePixelsP; - --v40; + byte *oldDestP = curDestP; + _reducedY += _zoomOutFactor; + if (_reducedY >= 0 && _reducedY < 100) { + _reduceX = 0; + int curWidth = zoomedSpriteWidth; + for (int i = _width; i; i--) { + _reduceX += _zoomOutFactor; + if (_reduceX >= 0 && _reduceX < 100) { + if (curWidth >= _posXClipped && curWidth < clip_x1 && *spritePixelsP) + *curDestP = *spritePixelsP; + --curDestP; ++spritePixelsP; - --v42; + --curWidth; } else { - Red_x -= 100; + _reduceX -= 100; ++spritePixelsP; } } - spriteHeight2 = v65; - v40 = _lineNbr2 + v55; + curDestP = _lineNbr2 + oldDestP; } else { - Red_y -= 100; + _reducedY -= 100; spritePixelsP += _width; } --spriteHeight2; @@ -1537,27 +1533,27 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp do { int oldSpriteHeight = spriteHeight2; byte *oldDest1P = dest1P; - Red_y += Red; - if ((uint16)Red_y < 100) { - Red_x = 0; - int v39 = 0; + _reducedY += _zoomOutFactor; + if (_reducedY >= 0 && _reducedY < 100) { + _reduceX = 0; + int curX = 0; for (int i = _width; i; i--) { - Red_x += Red; - if ((uint16)Red_x < 100) { - if (v39 >= _posXClipped && v39 < clip_x1 && *spritePixelsP) + _reduceX += _zoomOutFactor; + if (_reduceX >= 0 && _reduceX < 100) { + if (curX >= _posXClipped && curX < clip_x1 && *spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; - ++v39; + ++curX; } else { - Red_x -= 100; + _reduceX -= 100; ++spritePixelsP; } } spriteHeight2 = oldSpriteHeight; dest1P = _lineNbr2 + oldDest1P; } else { - Red_y -= 100; + _reducedY -= 100; spritePixelsP += _width; } --spriteHeight2; @@ -1846,28 +1842,28 @@ void GraphicsManager::copyWinscanVbe(const byte *src, byte *dest) { void GraphicsManager::reduceScreenPart(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) { const byte *srcP = xp + _lineNbr2 * yp + srcSurface; byte *destP = destSurface; - Red = zoom; + _zoomOutFactor = zoom; _width = width; - Red_x = 0; - Red_y = 0; + _reduceX = 0; + _reducedY = 0; if (zoom < 100) { for (int yCtr = 0; yCtr < height; ++yCtr, srcP += _lineNbr2) { - Red_y += Red; - if (Red_y < 100) { - Red_x = 0; + _reducedY += _zoomOutFactor; + if (_reducedY < 100) { + _reduceX = 0; const byte *lineSrcP = srcP; for (int xCtr = 0; xCtr < _width; ++xCtr) { - Red_x += Red; - if (Red_x < 100) { + _reduceX += _zoomOutFactor; + if (_reduceX < 100) { *destP++ = *lineSrcP++; } else { - Red_x -= 100; + _reduceX -= 100; ++lineSrcP; } } } else { - Red_y -= 100; + _reducedY -= 100; } } } -- cgit v1.2.3 From db6d7e256bd1a1654002005fec3524ddcd300c75 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 20:40:55 +0100 Subject: HOPKINS: Remove setParent() from EventsManager and Debugger --- engines/hopkins/graphics.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ac3fdb493f..241be7ede0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -259,7 +259,7 @@ void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) */ void GraphicsManager::scrollScreen(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); - _vm->_eventsManager._startPos.x = result; + _vm->_eventsManager->_startPos.x = result; _scrollOffset = result; _scrollPosX = result; } @@ -565,18 +565,18 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Set the transition palette and refresh the screen setPaletteVGA256(palData2); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); // Added a delay in order to see the fading - _vm->_eventsManager.delay(20); + _vm->_eventsManager->delay(20); } // Set the final palette setPaletteVGA256(palette); // Refresh the screen - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -585,7 +585,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) */ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { byte palData[PALETTE_BLOCK_SIZE]; - if ((step > 1) && (palette) && (!_vm->_eventsManager._escKeyFl)) { + if ((step > 1) && (palette) && (!_vm->_eventsManager->_escKeyFl)) { int fadeStep = step; for (int fadeIndex = 0; fadeIndex < fadeStep; fadeIndex++) { for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { @@ -595,10 +595,10 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } setPaletteVGA256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); - _vm->_eventsManager.delay(20); + _vm->_eventsManager->delay(20); } } @@ -607,7 +607,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface palData[i] = 0; setPaletteVGA256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -692,7 +692,7 @@ void GraphicsManager::setPaletteVGA256(const byte *palette) { void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -1067,8 +1067,8 @@ void GraphicsManager::endDisplayBob() { _vm->_objectsManager.hideBob(idx); } - _vm->_eventsManager.refreshScreenAndEvents(); - _vm->_eventsManager.refreshScreenAndEvents(); + _vm->_eventsManager->refreshScreenAndEvents(); + _vm->_eventsManager->refreshScreenAndEvents(); for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals._animBqe[idx]._enabledFl) @@ -1170,23 +1170,23 @@ void GraphicsManager::displayDirtyRects() { Common::Rect &r = _dirtyRects[idx]; Common::Rect dstRect; - if (_vm->_eventsManager._breakoutFl) { + if (_vm->_eventsManager->_breakoutFl) { Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); dstRect.setHeight((r.bottom - r.top) * 2); - } else if (r.right > _vm->_eventsManager._startPos.x && r.left < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { - if (r.left < _vm->_eventsManager._startPos.x) - r.left = _vm->_eventsManager._startPos.x; - if (r.right > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) - r.right = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; + } else if (r.right > _vm->_eventsManager->_startPos.x && r.left < _vm->_eventsManager->_startPos.x + SCREEN_WIDTH) { + if (r.left < _vm->_eventsManager->_startPos.x) + r.left = _vm->_eventsManager->_startPos.x; + if (r.right > _vm->_eventsManager->_startPos.x + SCREEN_WIDTH) + r.right = _vm->_eventsManager->_startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access lockScreen(); - m_scroll16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager._startPos.x, r.top); + m_scroll16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); - dstRect.left = r.left - _vm->_eventsManager._startPos.x; + dstRect.left = r.left - _vm->_eventsManager->_startPos.x; dstRect.top = r.top; dstRect.setWidth(r.right - r.left); dstRect.setHeight(r.bottom - r.top); @@ -1803,7 +1803,7 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { Trans_bloc2(_vesaBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); lockScreen(); - m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(_vesaBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); memcpy(_vesaScreen, _vesaBuffer, 614399); -- cgit v1.2.3 From f2d4151dd7db6eb0bffc4874825b15e22f61a36f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 21:57:28 +0100 Subject: HOPKINS: Remove setParent() from FileManager --- engines/hopkins/graphics.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 241be7ede0..c81e20bdf3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -199,7 +199,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { assert(!_videoPtr); bool flag = true; - if (_vm->_fileManager.searchCat(file, RES_PIC) == g_PTRNUL) { + if (_vm->_fileManager->searchCat(file, RES_PIC) == g_PTRNUL) { if (!f.open(file)) error("loadScreen - %s", file.c_str()); @@ -1740,20 +1740,20 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, void GraphicsManager::initScreen(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager.searchCat(filename, RES_INI); + byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI); if (ptr == g_PTRNUL) { - ptr = _vm->_fileManager.loadFile(filename); + ptr = _vm->_fileManager->loadFile(filename); } if (!mode) { filename = file + ".spr"; _vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN); if (initializeScreen) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, RES_SLI); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->searchCat(filename, RES_SLI); if (_vm->_globals.SPRITE_ECRAN) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(filename); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->loadFile(filename); } else { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile("RES_SLI.RES"); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->loadFile("RES_SLI.RES"); } } } @@ -1784,9 +1784,9 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); filename = file + ".rep"; - byte *dataP = _vm->_fileManager.searchCat(filename, RES_REP); + byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP); if (dataP == g_PTRNUL) - dataP = _vm->_fileManager.loadFile(filename); + dataP = _vm->_fileManager->loadFile(filename); _vm->_globals._answerBuffer = dataP; _vm->_objectsManager._forceZoneFl = true; -- cgit v1.2.3 From 05a2f776a30b33cfcbdf16d5944abc9d4c208ab1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Mar 2013 22:01:03 +0100 Subject: HOPKINS: Rename colour into color --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c81e20bdf3..870599d164 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1703,7 +1703,7 @@ void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, uint16 wi } // Display Font -void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour) { +void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int color) { const byte *spriteDataP = spriteData + 3; for (int i = characterIndex; i; --i) spriteDataP += READ_LE_UINT32(spriteDataP) + 16; @@ -1726,7 +1726,7 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, byte destByte = *spritePixelsP; if (*spritePixelsP) { if (destByte == 252) - destByte = colour; + destByte = color; *destP = destByte; } -- cgit v1.2.3 From 852e65bd02bc1278386d79ca68f81e3d15e9fa43 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 07:27:42 +0100 Subject: HOPKINS: Remove setParent() from Globals --- engines/hopkins/graphics.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 870599d164..4ae251fd49 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -78,9 +78,9 @@ GraphicsManager::GraphicsManager() { } GraphicsManager::~GraphicsManager() { - _vm->_globals.freeMemory(_vesaScreen); - _vm->_globals.freeMemory(_vesaBuffer); - _vm->_globals.freeMemory(_screenBuffer); + _vm->_globals->freeMemory(_vesaScreen); + _vm->_globals->freeMemory(_vesaBuffer); + _vm->_globals->freeMemory(_screenBuffer); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -105,9 +105,9 @@ void GraphicsManager::setGraphicalMode(int width, int height) { initGraphics(width, height, true, &pixelFormat16); // Init surfaces - _vesaScreen = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - _vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - _screenBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _vesaScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _vesaBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _screenBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _videoPtr = NULL; _screenWidth = width; @@ -312,7 +312,7 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte // Load PCX from within the PIC resource if (!f.open("PIC.RES")) error("Error opening PIC.RES."); - f.seek(_vm->_globals._catalogPos); + f.seek(_vm->_globals->_catalogPos); } else { // Load stand alone PCX file if (!f.open(file)) @@ -345,7 +345,7 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte f.read(surface, 128); int imageSize = filesize - 896; - byte *ptr = _vm->_globals.allocMemory(65024); + byte *ptr = _vm->_globals->allocMemory(65024); size_t curBufSize; int imageNumb; int imageDataSize; @@ -396,7 +396,7 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte f.read(palette, 768); f.close(); - _vm->_globals.freeMemory(ptr); + _vm->_globals->freeMemory(ptr); } // Clear Palette @@ -1063,7 +1063,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals._animBqe[idx]._enabledFl) + if (_vm->_globals->_animBqe[idx]._enabledFl) _vm->_objectsManager.hideBob(idx); } @@ -1071,22 +1071,22 @@ void GraphicsManager::endDisplayBob() { _vm->_eventsManager->refreshScreenAndEvents(); for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals._animBqe[idx]._enabledFl) + if (_vm->_globals->_animBqe[idx]._enabledFl) _vm->_objectsManager.resetBob(idx); } for (int idx = 1; idx <= 29; ++idx) { - _vm->_globals._lockedAnims[idx]._enableFl = false; + _vm->_globals->_lockedAnims[idx]._enableFl = false; } for (int idx = 1; idx <= 20; ++idx) { - _vm->_globals._animBqe[idx]._enabledFl = false; + _vm->_globals->_animBqe[idx]._enabledFl = false; } } void GraphicsManager::displayAllBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals._animBqe[idx]._enabledFl) + if (_vm->_globals->_animBqe[idx]._enabledFl) _vm->_objectsManager.displayBob(idx); } } @@ -1747,13 +1747,13 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init } if (!mode) { filename = file + ".spr"; - _vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN); + _vm->_globals->SPRITE_ECRAN = _vm->_globals->freeMemory(_vm->_globals->SPRITE_ECRAN); if (initializeScreen) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->searchCat(filename, RES_SLI); - if (_vm->_globals.SPRITE_ECRAN) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->loadFile(filename); + _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->searchCat(filename, RES_SLI); + if (_vm->_globals->SPRITE_ECRAN) { + _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->loadFile(filename); } else { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager->loadFile("RES_SLI.RES"); + _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->loadFile("RES_SLI.RES"); } } } @@ -1780,15 +1780,15 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init doneFlag = true; } while (!doneFlag); } - _vm->_globals.freeMemory(ptr); - _vm->_globals._answerBuffer = _vm->_globals.freeMemory(_vm->_globals._answerBuffer); + _vm->_globals->freeMemory(ptr); + _vm->_globals->_answerBuffer = _vm->_globals->freeMemory(_vm->_globals->_answerBuffer); filename = file + ".rep"; byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP); if (dataP == g_PTRNUL) dataP = _vm->_fileManager->loadFile(filename); - _vm->_globals._answerBuffer = dataP; + _vm->_globals->_answerBuffer = dataP; _vm->_objectsManager._forceZoneFl = true; _vm->_objectsManager._changeVerbFl = false; } -- cgit v1.2.3 From 6a446ff9d170640bf698f7ef19386050ee4bd9c2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 07:36:06 +0100 Subject: HOPKINS: Remove setParent() from GraphicsManager --- engines/hopkins/graphics.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4ae251fd49..1f8ee4b044 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -35,7 +35,9 @@ namespace Hopkins { -GraphicsManager::GraphicsManager() { +GraphicsManager::GraphicsManager(HopkinsEngine *vm) { + _vm = vm; + _lockCounter = 0; _initGraphicsFl = false; _screenWidth = _screenHeight = 0; @@ -75,20 +77,10 @@ GraphicsManager::GraphicsManager() { Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); -} - -GraphicsManager::~GraphicsManager() { - _vm->_globals->freeMemory(_vesaScreen); - _vm->_globals->freeMemory(_vesaBuffer); - _vm->_globals->freeMemory(_screenBuffer); -} - -void GraphicsManager::setParent(HopkinsEngine *vm) { - _vm = vm; - + if (_vm->getIsDemo()) { if (_vm->getPlatform() == Common::kPlatformLinux) - // CHECKME: Should be false? + // CHECKME: Should be false? MANU_SCROLL = true; else MANU_SCROLL = false; @@ -99,6 +91,12 @@ void GraphicsManager::setParent(HopkinsEngine *vm) { } } +GraphicsManager::~GraphicsManager() { + _vm->_globals->freeMemory(_vesaScreen); + _vm->_globals->freeMemory(_vesaBuffer); + _vm->_globals->freeMemory(_screenBuffer); +} + void GraphicsManager::setGraphicalMode(int width, int height) { if (!_initGraphicsFl) { Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); -- cgit v1.2.3 From c5c7ced5ee2186ace50549ca9e14b70708de5b54 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 07:56:16 +0100 Subject: HOPKINS: Remove setParent() from MenuManager and ObjectsManager --- engines/hopkins/graphics.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 1f8ee4b044..41de90ebb3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1062,7 +1062,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals->_animBqe[idx]._enabledFl) - _vm->_objectsManager.hideBob(idx); + _vm->_objectsManager->hideBob(idx); } _vm->_eventsManager->refreshScreenAndEvents(); @@ -1070,7 +1070,7 @@ void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals->_animBqe[idx]._enabledFl) - _vm->_objectsManager.resetBob(idx); + _vm->_objectsManager->resetBob(idx); } for (int idx = 1; idx <= 29; ++idx) { @@ -1085,7 +1085,7 @@ void GraphicsManager::endDisplayBob() { void GraphicsManager::displayAllBob() { for (int idx = 1; idx <= 20; ++idx) { if (_vm->_globals->_animBqe[idx]._enabledFl) - _vm->_objectsManager.displayBob(idx); + _vm->_objectsManager->displayBob(idx); } } @@ -1225,8 +1225,8 @@ void GraphicsManager::displayRefreshRects() { } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { - int width = _vm->_objectsManager.getWidth(objectData, idx); - int height = _vm->_objectsManager.getHeight(objectData, idx); + int width = _vm->_objectsManager->getWidth(objectData, idx); + int height = _vm->_objectsManager->getHeight(objectData, idx); if (*objectData == 78) { Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, false); Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); @@ -1641,8 +1641,8 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp * Fast Display */ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment) { - int width = _vm->_objectsManager.getWidth(spriteData, spriteIndex); - int height = _vm->_objectsManager.getHeight(spriteData, spriteIndex); + int width = _vm->_objectsManager->getWidth(spriteData, spriteIndex); + int height = _vm->_objectsManager->getHeight(spriteData, spriteIndex); if (*spriteData == 78) { Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); @@ -1787,8 +1787,8 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init dataP = _vm->_fileManager->loadFile(filename); _vm->_globals->_answerBuffer = dataP; - _vm->_objectsManager._forceZoneFl = true; - _vm->_objectsManager._changeVerbFl = false; + _vm->_objectsManager->_forceZoneFl = true; + _vm->_objectsManager->_changeVerbFl = false; } void GraphicsManager::NB_SCREEN(bool initPalette) { -- cgit v1.2.3 From 848841772f765b7b8a990d1dd1237d6189f23aaf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Mar 2013 08:06:10 +0100 Subject: HOPKINS: Remove setParent() from SaveLoadManager and ScriptManager --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 41de90ebb3..9730fba51b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1762,14 +1762,14 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init int dataOffset = 1; do { - int dataVal1 = _vm->_scriptManager.handleOpcode(ptr + 20 * dataOffset); + int dataVal1 = _vm->_scriptManager->handleOpcode(ptr + 20 * dataOffset); if (_vm->shouldQuit()) return; if (dataVal1 == 2) - dataOffset = _vm->_scriptManager.handleGoto((ptr + 20 * dataOffset)); + dataOffset = _vm->_scriptManager->handleGoto((ptr + 20 * dataOffset)); if (dataVal1 == 3) - dataOffset = _vm->_scriptManager.handleIf(ptr, dataOffset); + dataOffset = _vm->_scriptManager->handleIf(ptr, dataOffset); if (dataOffset == -1) error("Error, defective IFF"); if (dataVal1 == 1 || dataVal1 == 4) -- cgit v1.2.3 From b8e504518ea77e8106d7dd8be087c5f51c8dff01 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Mar 2013 18:57:46 +0100 Subject: HOPKINS: Some renaming and refactoring in Globals --- engines/hopkins/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9730fba51b..5c65e59c5e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1745,13 +1745,13 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init } if (!mode) { filename = file + ".spr"; - _vm->_globals->SPRITE_ECRAN = _vm->_globals->freeMemory(_vm->_globals->SPRITE_ECRAN); + _vm->_globals->_levelSpriteBuf = _vm->_globals->freeMemory(_vm->_globals->_levelSpriteBuf); if (initializeScreen) { - _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->searchCat(filename, RES_SLI); - if (_vm->_globals->SPRITE_ECRAN) { - _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->loadFile(filename); + _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI); + if (_vm->_globals->_levelSpriteBuf) { + _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile(filename); } else { - _vm->_globals->SPRITE_ECRAN = _vm->_fileManager->loadFile("RES_SLI.RES"); + _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile("RES_SLI.RES"); } } } -- cgit v1.2.3 From ac338c3517d85156e83884164d378c3bf76851e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Mar 2013 22:56:06 +0100 Subject: HOPKINS: Some more refactoring in Globals --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 5c65e59c5e..14f23ad06a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -310,7 +310,7 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte // Load PCX from within the PIC resource if (!f.open("PIC.RES")) error("Error opening PIC.RES."); - f.seek(_vm->_globals->_catalogPos); + f.seek(_vm->_fileManager->_catalogPos); } else { // Load stand alone PCX file if (!f.open(file)) @@ -1074,7 +1074,7 @@ void GraphicsManager::endDisplayBob() { } for (int idx = 1; idx <= 29; ++idx) { - _vm->_globals->_lockedAnims[idx]._enableFl = false; + _vm->_objectsManager->_lockedAnims[idx]._enableFl = false; } for (int idx = 1; idx <= 20; ++idx) { -- cgit v1.2.3 From 91469d7d386d5eca3f471d0a57cc5bf333212b89 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Mar 2013 08:02:07 +0100 Subject: HOPKINS: More work on Globals --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 14f23ad06a..a0cd39c069 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1061,7 +1061,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals->_animBqe[idx]._enabledFl) + if (_vm->_animationManager->_animBqe[idx]._enabledFl) _vm->_objectsManager->hideBob(idx); } @@ -1069,7 +1069,7 @@ void GraphicsManager::endDisplayBob() { _vm->_eventsManager->refreshScreenAndEvents(); for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals->_animBqe[idx]._enabledFl) + if (_vm->_animationManager->_animBqe[idx]._enabledFl) _vm->_objectsManager->resetBob(idx); } @@ -1078,13 +1078,13 @@ void GraphicsManager::endDisplayBob() { } for (int idx = 1; idx <= 20; ++idx) { - _vm->_globals->_animBqe[idx]._enabledFl = false; + _vm->_animationManager->_animBqe[idx]._enabledFl = false; } } void GraphicsManager::displayAllBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_globals->_animBqe[idx]._enabledFl) + if (_vm->_animationManager->_animBqe[idx]._enabledFl) _vm->_objectsManager->displayBob(idx); } } -- cgit v1.2.3 From 9f9e665d8ececf9a068029daeae0e5d24ccc4cee Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Mar 2013 00:51:35 +0100 Subject: HOPKINS: Fix several Cppcheck warning --- engines/hopkins/graphics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a0cd39c069..2098eee334 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -89,6 +89,8 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { MANU_SCROLL = false; _scrollSpeed = 32; } + + _noFadingFl = false; } GraphicsManager::~GraphicsManager() { -- cgit v1.2.3 From 08db6ea515df120c5a4bfb08027120e3cc79f4c1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Mar 2013 08:10:40 +0100 Subject: HOPKINS: Rename a fading variable --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2098eee334..f4ffa56295 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -58,7 +58,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _enlargedX = _enlargedY = 0; _enlargedXFl = _enlargedYFl = false; _fadeDefaultSpeed = 15; - FADE_LINUX = 0; + _fadingFl = false; _skipVideoLockFl = false; _scrollStatus = 0; _minX = 0; -- cgit v1.2.3 From ccf2f50ceb5f48f2a2e4ce1a88ebef6e8e2ab48a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Mar 2013 08:26:19 +0100 Subject: HOPKINS: Rename GraphicsManager variable --- engines/hopkins/graphics.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f4ffa56295..255a00071f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -41,7 +41,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _lockCounter = 0; _initGraphicsFl = false; _screenWidth = _screenHeight = 0; - WinScan = 0; + _screenLineSize = 0; PAL_PIXELS = NULL; _lineNbr = 0; _videoPtr = NULL; @@ -113,7 +113,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenWidth = width; _screenHeight = height; - WinScan = SCREEN_WIDTH * 2; + _screenLineSize = SCREEN_WIDTH * 2; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -130,7 +130,7 @@ void GraphicsManager::lockScreen() { if (!_skipVideoLockFl) { if (_lockCounter++ == 0) { _videoPtr = _screenBuffer; - WinScan = SCREEN_WIDTH * 2; + _screenLineSize = SCREEN_WIDTH * 2; } } } @@ -151,13 +151,13 @@ void GraphicsManager::unlockScreen() { void GraphicsManager::clearScreen() { assert(_videoPtr); - Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); + Common::fill(_screenBuffer, _screenBuffer + _screenLineSize * _screenHeight, 0); addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } void GraphicsManager::clearVesaScreen() { - Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); - Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); + Common::fill(_vesaScreen, _vesaScreen + _screenLineSize * _screenHeight, 0); + Common::fill(_vesaBuffer, _vesaBuffer + _screenLineSize * _screenHeight, 0); addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } @@ -418,7 +418,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr + destX * 2 + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX * 2 + _screenLineSize * destY; for (int yp = 0; yp < height; ++yp) { // Copy over the line, using the source pixels as lookups into the pixels palette @@ -433,7 +433,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } // Move to the start of the next line srcP += _lineNbr2; - destP += WinScan; + destP += _screenLineSize; } unlockScreen(); @@ -450,7 +450,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr + destX + destX + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX + destX + _screenLineSize * destY; int yNext = height; _enlargedX = 0; _enlargedY = 0; @@ -481,7 +481,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr; srcP = srcCopyP; - destP = WinScan + destCopyP; + destP = _screenLineSize + destCopyP; if (_enlargedYFl) break; @@ -510,7 +510,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, assert(_videoPtr); const byte *srcP = surface + xp + 320 * yp; - byte *destP = (byte *)_videoPtr + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; + byte *destP = (byte *)_videoPtr + 30 * _screenLineSize + destX + destX + destX + destX + _screenLineSize * 2 * destY; int yCount = height; int xCount = width; @@ -523,15 +523,15 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, palette = PAL_PIXELS; do { - destP[0] = destP[2] = destP[WinScan] = destP[WinScan + 2] = palette[2 * srcP[0]]; - destP[1] = destP[3] = destP[WinScan + 1] = destP[WinScan + 3] = palette[(2 * srcP[0]) + 1]; + destP[0] = destP[2] = destP[_screenLineSize] = destP[_screenLineSize + 2] = palette[2 * srcP[0]]; + destP[1] = destP[3] = destP[_screenLineSize + 1] = destP[_screenLineSize + 3] = palette[(2 * srcP[0]) + 1]; ++srcP; destP += 4; --xCtr; } while (xCtr); xCount = savedXCount; - destP = loopDestP + WinScan * 2; + destP = loopDestP + _screenLineSize * 2; srcP = loopSrcP + 320; yCount = yCtr - 1; } while (yCtr != 1); @@ -1207,14 +1207,14 @@ void GraphicsManager::displayRefreshRects() { Graphics::Surface *screenSurface = NULL; if (_showDirtyRects) { screenSurface = g_system->lockScreen(); - g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + g_system->copyRectToScreen(_screenBuffer, _screenLineSize, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; - byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2); - g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height()); + byte *srcP = _screenBuffer + _screenLineSize * r.top + (r.left * 2); + g_system->copyRectToScreen(srcP, _screenLineSize, r.left, r.top, r.width(), r.height()); if (_showDirtyRects) screenSurface->frameRect(r, 0xffffff); @@ -1249,18 +1249,18 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { assert(_videoPtr); const byte *curSurface = surface; - byte *destPtr = 30 * WinScan + (byte *)_videoPtr; + byte *destPtr = 30 * _screenLineSize + (byte *)_videoPtr; for (int y = 200; y; y--) { byte *oldDestPtr = destPtr; for (int x = 320; x; x--) { curPixel = 2 * *curSurface; palPtr = PAL_PIXELS + curPixel; - destPtr[0] = destPtr[2] = destPtr[WinScan] = destPtr[WinScan + 2] = palPtr[0]; - destPtr[1] = destPtr[3] = destPtr[WinScan + 1] = destPtr[WinScan + 3] = palPtr[1]; + destPtr[0] = destPtr[2] = destPtr[_screenLineSize] = destPtr[_screenLineSize + 2] = palPtr[0]; + destPtr[1] = destPtr[3] = destPtr[_screenLineSize + 1] = destPtr[_screenLineSize + 3] = palPtr[1]; ++curSurface; destPtr += 4; } - destPtr = WinScan * 2 + oldDestPtr; + destPtr = _screenLineSize * 2 + oldDestPtr; } } -- cgit v1.2.3 From f8b1a16e3c10580f7945fd36149b6f1d2a277753 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Mar 2013 21:29:02 +0100 Subject: HOPKINS: Remove more dead code, simplify a couple of statements in Copy_Vga16() --- engines/hopkins/graphics.cpp | 68 ++------------------------------------------ 1 file changed, 3 insertions(+), 65 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 255a00071f..589259b203 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -51,7 +51,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _oldScrollPosX = 0; _vesaScreen = NULL; _vesaBuffer = NULL; - _screenBuffer = NULL; + _screenBuffer = g_PTRNUL; _showDirtyRects = false; _lineNbr2 = 0; @@ -440,66 +440,6 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, addRefreshRect(destX, destY, destX + width, destY + height); } -// TODO: See if PAL_PIXELS can be converted to a uint16 array -void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { - int xCtr; - const byte *palette; - int yCtr; - const byte *srcCopyP; - byte *destCopyP; - - assert(_videoPtr); - const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr + destX + destX + _screenLineSize * destY; - int yNext = height; - _enlargedX = 0; - _enlargedY = 0; - _enlargedYFl = false; - - do { - for (;;) { - destCopyP = destP; - srcCopyP = srcP; - xCtr = width; - yCtr = yNext; - palette = PAL_PIXELS; - _enlargedX = 0; - - do { - destP[0] = palette[2 * srcP[0]]; - destP[1] = palette[(2 * srcP[0]) + 1]; - destP += 2; - if (_enlargedX >= 100) { - _enlargedX -= 100; - destP[0] = palette[2 * srcP[0]]; - destP[1] = palette[(2 * srcP[0]) + 1]; - destP += 2; - } - ++srcP; - --xCtr; - } while (xCtr); - - yNext = yCtr; - srcP = srcCopyP; - destP = _screenLineSize + destCopyP; - if (_enlargedYFl) - break; - - if (_enlargedY >= 0 && _enlargedY < 100) - break; - - _enlargedY -= 100; - _enlargedYFl = true; - } - - _enlargedYFl = false; - srcP = _lineNbr2 + srcCopyP; - yNext = yCtr - 1; - } while (yCtr != 1); - - addRefreshRect(destX, destY, destX + width, destY + width); -} - void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { int xCtr; const byte *palette; @@ -1177,10 +1117,8 @@ void GraphicsManager::displayDirtyRects() { dstRect.setWidth((r.right - r.left) * 2); dstRect.setHeight((r.bottom - r.top) * 2); } else if (r.right > _vm->_eventsManager->_startPos.x && r.left < _vm->_eventsManager->_startPos.x + SCREEN_WIDTH) { - if (r.left < _vm->_eventsManager->_startPos.x) - r.left = _vm->_eventsManager->_startPos.x; - if (r.right > _vm->_eventsManager->_startPos.x + SCREEN_WIDTH) - r.right = _vm->_eventsManager->_startPos.x + SCREEN_WIDTH; + r.left = MAX(r.left, _vm->_eventsManager->_startPos.x); + r.right = MIN(r.right, (int16)_vm->_eventsManager->_startPos.x + SCREEN_WIDTH); // WORKAROUND: Original didn't lock the screen for access lockScreen(); -- cgit v1.2.3 From e848ed7bace4af925b399dca0b3ea3cf4b09a0a4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 30 Mar 2013 14:20:18 +0100 Subject: HOPKINS: Rename display buffers --- engines/hopkins/graphics.cpp | 70 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 589259b203..ee2c75cf55 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -49,8 +49,8 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - _vesaScreen = NULL; - _vesaBuffer = NULL; + _backBuffer = NULL; + _frontBuffer = NULL; _screenBuffer = g_PTRNUL; _showDirtyRects = false; @@ -94,8 +94,8 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { } GraphicsManager::~GraphicsManager() { - _vm->_globals->freeMemory(_vesaScreen); - _vm->_globals->freeMemory(_vesaBuffer); + _vm->_globals->freeMemory(_backBuffer); + _vm->_globals->freeMemory(_frontBuffer); _vm->_globals->freeMemory(_screenBuffer); } @@ -105,8 +105,8 @@ void GraphicsManager::setGraphicalMode(int width, int height) { initGraphics(width, height, true, &pixelFormat16); // Init surfaces - _vesaScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); - _vesaBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _backBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _frontBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _screenBuffer = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _videoPtr = NULL; @@ -156,8 +156,8 @@ void GraphicsManager::clearScreen() { } void GraphicsManager::clearVesaScreen() { - Common::fill(_vesaScreen, _vesaScreen + _screenLineSize * _screenHeight, 0); - Common::fill(_vesaBuffer, _vesaBuffer + _screenLineSize * _screenHeight, 0); + Common::fill(_backBuffer, _backBuffer + _screenLineSize * _screenHeight, 0); + Common::fill(_frontBuffer, _frontBuffer + _screenLineSize * _screenHeight, 0); addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } @@ -178,13 +178,13 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); clearScreen(); unlockScreen(); - loadPCX320(_vesaScreen, file, _palette); - memcpy(_vesaBuffer, _vesaScreen, 64000); + loadPCX320(_backBuffer, file, _palette); + memcpy(_frontBuffer, _backBuffer, 64000); setScreenWidth(320); _maxX = 320; lockScreen(); - copy16bFromSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_frontBuffer); addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); unlockScreen(); @@ -209,7 +209,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { } scrollScreen(0); - loadPCX640(_vesaScreen, file, _palette, flag); + loadPCX640(_backBuffer, file, _palette, flag); _scrollPosX = 0; _oldScrollPosX = 0; @@ -220,7 +220,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { _maxX = SCREEN_WIDTH; lockScreen(); clearScreen(); - m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } else { setScreenWidth(SCREEN_WIDTH * 2); @@ -231,12 +231,12 @@ void GraphicsManager::loadScreen(const Common::String &file) { if (MANU_SCROLL) { lockScreen(); - m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } } - memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(_frontBuffer, _backBuffer, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) { @@ -557,7 +557,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface */ void GraphicsManager::fadeInShort() { _fadeDefaultSpeed = 1; - fadeIn(_palette, 1, (const byte *)_vesaBuffer); + fadeIn(_palette, 1, (const byte *)_frontBuffer); } /** @@ -565,7 +565,7 @@ void GraphicsManager::fadeInShort() { */ void GraphicsManager::fadeOutShort() { _fadeDefaultSpeed = 1; - fadeOut(_palette, 1, (const byte *)_vesaBuffer); + fadeOut(_palette, 1, (const byte *)_frontBuffer); } /** @@ -573,7 +573,7 @@ void GraphicsManager::fadeOutShort() { */ void GraphicsManager::fadeInLong() { _fadeDefaultSpeed = 15; - fadeIn(_palette, 20, (const byte *)_vesaBuffer); + fadeIn(_palette, 20, (const byte *)_frontBuffer); } /** @@ -581,7 +581,7 @@ void GraphicsManager::fadeInLong() { */ void GraphicsManager::fadeOutLong() { _fadeDefaultSpeed = 15; - fadeOut(_palette, 20, (const byte *)_vesaBuffer); + fadeOut(_palette, 20, (const byte *)_frontBuffer); } /** @@ -606,7 +606,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { void GraphicsManager::fadeInBreakout() { setPaletteVGA256(_palette); lockScreen(); - copy16bFromSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_frontBuffer); unlockScreen(); updateScreen(); } @@ -621,7 +621,7 @@ void GraphicsManager::fadeOutBreakout() { setPaletteVGA256(palette); lockScreen(); - copy16bFromSurfaceScaleX2(_vesaBuffer); + copy16bFromSurfaceScaleX2(_frontBuffer); unlockScreen(); updateScreen(); } @@ -1111,7 +1111,7 @@ void GraphicsManager::displayDirtyRects() { Common::Rect dstRect; if (_vm->_eventsManager->_breakoutFl) { - Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + Copy_Vga16(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); @@ -1122,7 +1122,7 @@ void GraphicsManager::displayDirtyRects() { // WORKAROUND: Original didn't lock the screen for access lockScreen(); - m_scroll16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); + m_scroll16(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); dstRect.left = r.left - _vm->_eventsManager->_startPos.x; dstRect.top = r.top; @@ -1168,11 +1168,11 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i int width = _vm->_objectsManager->getWidth(objectData, idx); int height = _vm->_objectsManager->getHeight(objectData, idx); if (*objectData == 78) { - Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, false); - Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); + Affiche_Perfect(_backBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); + Affiche_Perfect(_frontBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); } else { - Sprite_Vesa(_vesaBuffer, objectData, xp + 300, yp + 300, idx); - Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); + Sprite_Vesa(_frontBuffer, objectData, xp + 300, yp + 300, idx); + Sprite_Vesa(_backBuffer, objectData, xp + 300, yp + 300, idx); } if (addSegment) addDirtyRect(xp, yp, xp + width, yp + height); @@ -1585,11 +1585,11 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp int height = _vm->_objectsManager->getHeight(spriteData, spriteIndex); if (*spriteData == 78) { - Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); - Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); + Affiche_Perfect(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); + Affiche_Perfect(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); } else { - Sprite_Vesa(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex); - Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); + Sprite_Vesa(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex); + Sprite_Vesa(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex); } if (addSegment) addDirtyRect(xp, yp, xp + width, yp + height); @@ -1736,15 +1736,15 @@ void GraphicsManager::NB_SCREEN(bool initPalette) { initColorTable(50, 65, _palette); if (_lineNbr == SCREEN_WIDTH) - Trans_bloc2(_vesaBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT); + Trans_bloc2(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT); else if (_lineNbr == (SCREEN_WIDTH * 2)) - Trans_bloc2(_vesaBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); + Trans_bloc2(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); lockScreen(); - m_scroll16(_vesaBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + m_scroll16(_frontBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); - memcpy(_vesaScreen, _vesaBuffer, 614399); + memcpy(_backBuffer, _frontBuffer, 614399); updateScreen(); } -- cgit v1.2.3 From bcdd8f43cd126253069a111ecb62c5137ec033ca Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 31 Mar 2013 12:56:12 -0400 Subject: HOPKINS: Refactored use of TEMP.SCR for screen backups to use a memory buffer --- engines/hopkins/graphics.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ee2c75cf55..7eeb5e5b3e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -52,6 +52,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _backBuffer = NULL; _frontBuffer = NULL; _screenBuffer = g_PTRNUL; + _backupScreen = g_PTRNUL; _showDirtyRects = false; _lineNbr2 = 0; @@ -97,6 +98,7 @@ GraphicsManager::~GraphicsManager() { _vm->_globals->freeMemory(_backBuffer); _vm->_globals->freeMemory(_frontBuffer); _vm->_globals->freeMemory(_screenBuffer); + _vm->_globals->freeMemory(_backupScreen); } void GraphicsManager::setGraphicalMode(int width, int height) { @@ -1826,4 +1828,30 @@ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height } } +/** + * Backup the current screen + */ +void GraphicsManager::backupScreen() { + // Allocate a new data block for the screen, if necessary + if (_vm->_graphicsManager->_backupScreen == g_PTRNUL) + _vm->_graphicsManager->_backupScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + + // Backup the screen + Common::copy(_vm->_graphicsManager->_backBuffer, _vm->_graphicsManager->_backBuffer + + SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsManager->_backupScreen); +} + +/** + * Restore a previously backed up screen + */ +void GraphicsManager::restoreScreen() { + assert(_vm->_graphicsManager->_backupScreen != g_PTRNUL); + + // Restore the screen and free the buffer + Common::copy(_vm->_graphicsManager->_backupScreen, _vm->_graphicsManager->_backupScreen + + SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsManager->_backBuffer); + _vm->_globals->freeMemory(_vm->_graphicsManager->_backupScreen); + _backupScreen = g_PTRNUL; +} + } // End of namespace Hopkins -- cgit v1.2.3 From 177df0802a66e34032260755370ac76026576e06 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Apr 2013 08:23:31 +0200 Subject: HOPKINS: Standardize the use of g_PTRNUL --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7eeb5e5b3e..9d1093edf9 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -42,15 +42,15 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _initGraphicsFl = false; _screenWidth = _screenHeight = 0; _screenLineSize = 0; - PAL_PIXELS = NULL; + PAL_PIXELS = g_PTRNUL; _lineNbr = 0; _videoPtr = NULL; _scrollOffset = 0; _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - _backBuffer = NULL; - _frontBuffer = NULL; + _backBuffer = g_PTRNUL; + _frontBuffer = g_PTRNUL; _screenBuffer = g_PTRNUL; _backupScreen = g_PTRNUL; _showDirtyRects = false; -- cgit v1.2.3 From 4b21ec23d0e445d8364bcab5732318734f4c27cc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Apr 2013 23:57:38 +0200 Subject: HOPKINS: Refactor searchCat to remove the use of g_PTRNUL, add a parameter to clarify the result of the function --- engines/hopkins/graphics.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9d1093edf9..a903462ecb 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -201,7 +201,9 @@ void GraphicsManager::loadScreen(const Common::String &file) { assert(!_videoPtr); bool flag = true; - if (_vm->_fileManager->searchCat(file, RES_PIC) == g_PTRNUL) { + bool fileFoundFl = false; + _vm->_fileManager->searchCat(file, RES_PIC, fileFoundFl); + if (!fileFoundFl) { if (!f.open(file)) error("loadScreen - %s", file.c_str()); @@ -1680,17 +1682,21 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, void GraphicsManager::initScreen(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI); + bool fileFoundFl = false; - if (ptr == g_PTRNUL) { + byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI, fileFoundFl); + + if (!fileFoundFl) { ptr = _vm->_fileManager->loadFile(filename); } + if (!mode) { filename = file + ".spr"; _vm->_globals->_levelSpriteBuf = _vm->_globals->freeMemory(_vm->_globals->_levelSpriteBuf); if (initializeScreen) { - _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI); - if (_vm->_globals->_levelSpriteBuf) { + fileFoundFl = false; + _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI, fileFoundFl); + if (!fileFoundFl) { _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile(filename); } else { _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile("RES_SLI.RES"); @@ -1724,8 +1730,9 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_globals->_answerBuffer = _vm->_globals->freeMemory(_vm->_globals->_answerBuffer); filename = file + ".rep"; - byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP); - if (dataP == g_PTRNUL) + fileFoundFl = false; + byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP, fileFoundFl); + if (!fileFoundFl) dataP = _vm->_fileManager->loadFile(filename); _vm->_globals->_answerBuffer = dataP; -- cgit v1.2.3 From e79a51c20894a74ac6ed8914daccfeedbfb28849 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Apr 2013 07:54:45 +0200 Subject: HOPKINS: Remove g_PTRNUL --- engines/hopkins/graphics.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a903462ecb..7a965146e7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -42,17 +42,17 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _initGraphicsFl = false; _screenWidth = _screenHeight = 0; _screenLineSize = 0; - PAL_PIXELS = g_PTRNUL; + PAL_PIXELS = NULL; _lineNbr = 0; _videoPtr = NULL; _scrollOffset = 0; _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - _backBuffer = g_PTRNUL; - _frontBuffer = g_PTRNUL; - _screenBuffer = g_PTRNUL; - _backupScreen = g_PTRNUL; + _backBuffer = NULL; + _frontBuffer = NULL; + _screenBuffer = NULL; + _backupScreen = NULL; _showDirtyRects = false; _lineNbr2 = 0; @@ -1840,7 +1840,7 @@ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height */ void GraphicsManager::backupScreen() { // Allocate a new data block for the screen, if necessary - if (_vm->_graphicsManager->_backupScreen == g_PTRNUL) + if (_vm->_graphicsManager->_backupScreen == NULL) _vm->_graphicsManager->_backupScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); // Backup the screen @@ -1852,13 +1852,13 @@ void GraphicsManager::backupScreen() { * Restore a previously backed up screen */ void GraphicsManager::restoreScreen() { - assert(_vm->_graphicsManager->_backupScreen != g_PTRNUL); + assert(_vm->_graphicsManager->_backupScreen != NULL); // Restore the screen and free the buffer Common::copy(_vm->_graphicsManager->_backupScreen, _vm->_graphicsManager->_backupScreen + SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsManager->_backBuffer); _vm->_globals->freeMemory(_vm->_graphicsManager->_backupScreen); - _backupScreen = g_PTRNUL; + _backupScreen = NULL; } } // End of namespace Hopkins -- cgit v1.2.3 From 2ee8b1e342eca39602b2e5fc8cbdb9f505d49bcb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Apr 2013 01:43:10 +0200 Subject: HOPKINS: Misc cleanup --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 7a965146e7..59adc0e9fc 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1238,7 +1238,7 @@ void GraphicsManager::restoreSurfaceRect(byte *destSurface, const byte *src, int /** * Compute the value of a parameter plus a given percentage */ -int GraphicsManager::zoomIn(int val, int percentage ) { +int GraphicsManager::zoomIn(int val, int percentage) { if (val) val += percentage * (long int)val / 100; @@ -1852,7 +1852,7 @@ void GraphicsManager::backupScreen() { * Restore a previously backed up screen */ void GraphicsManager::restoreScreen() { - assert(_vm->_graphicsManager->_backupScreen != NULL); + assert(_vm->_graphicsManager->_backupScreen); // Restore the screen and free the buffer Common::copy(_vm->_graphicsManager->_backupScreen, _vm->_graphicsManager->_backupScreen + -- cgit v1.2.3 From 89bf72ff5d608b86c6efc413baedff7618f4b44e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Apr 2013 08:17:26 +0200 Subject: HOPKINS: JANITORIAL: Remove trailing spaces and tabs --- engines/hopkins/graphics.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 59adc0e9fc..019d5a5ae8 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -78,7 +78,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); - + if (_vm->getIsDemo()) { if (_vm->getPlatform() == Common::kPlatformLinux) // CHECKME: Should be false? @@ -134,7 +134,7 @@ void GraphicsManager::lockScreen() { _videoPtr = _screenBuffer; _screenLineSize = SCREEN_WIDTH * 2; } - } + } } /** @@ -240,7 +240,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { } } - memcpy(_frontBuffer, _backBuffer, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(_frontBuffer, _backBuffer, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) { @@ -405,7 +405,7 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte // Clear Palette void GraphicsManager::clearPalette() { - // As weird as it sounds, this is what the original Linux executable does, + // As weird as it sounds, this is what the original Linux executable does, // and not a full array clear. SD_PIXELS[0] = 0; } @@ -483,7 +483,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, addRefreshRect(destX, destY, destX + width, destY + width); } -/** +/** * Fade in. the step number is determine by parameter. */ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) { @@ -524,7 +524,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) updateScreen(); } -/** +/** * Fade out. the step number is determine by parameter. */ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { @@ -556,7 +556,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface updateScreen(); } -/** +/** * Short fade in. The step number is 1, the default step number is also set to 1. */ void GraphicsManager::fadeInShort() { @@ -564,7 +564,7 @@ void GraphicsManager::fadeInShort() { fadeIn(_palette, 1, (const byte *)_frontBuffer); } -/** +/** * Short fade out. The step number is 1, the default step number is also set to 1. */ void GraphicsManager::fadeOutShort() { @@ -572,7 +572,7 @@ void GraphicsManager::fadeOutShort() { fadeOut(_palette, 1, (const byte *)_frontBuffer); } -/** +/** * Long fade in. The step number is 20, the default step number is also set to 15. */ void GraphicsManager::fadeInLong() { @@ -580,7 +580,7 @@ void GraphicsManager::fadeInLong() { fadeIn(_palette, 20, (const byte *)_frontBuffer); } -/** +/** * Long fade out. The step number is 20, the default step number is also set to 15. */ void GraphicsManager::fadeOutLong() { @@ -588,7 +588,7 @@ void GraphicsManager::fadeOutLong() { fadeOut(_palette, 20, (const byte *)_frontBuffer); } -/** +/** * Fade in. The step number used is the default step number. */ void GraphicsManager::fadeInDefaultLength(const byte *surface) { @@ -596,7 +596,7 @@ void GraphicsManager::fadeInDefaultLength(const byte *surface) { fadeIn(_palette, _fadeDefaultSpeed, surface); } -/** +/** * Fade out. The step number used is the default step number. */ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { @@ -604,7 +604,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { fadeOut(_palette, _fadeDefaultSpeed, surface); } -/** +/** * Fade in used by for the breakout mini-game */ void GraphicsManager::fadeInBreakout() { @@ -615,7 +615,7 @@ void GraphicsManager::fadeInBreakout() { updateScreen(); } -/** +/** * Fade out used by for the breakout mini-game */ void GraphicsManager::fadeOutBreakout() { @@ -1050,7 +1050,7 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { x2 = CLIP(x2, _minX, _maxX); y2 = CLIP(y2, _minY, _maxY); - if ((x2 > x1) && (y2 > y1)) + if ((x2 > x1) && (y2 > y1)) addRectToArray(_dirtyRects, Common::Rect(x1, y1, x2, y2)); } @@ -1070,7 +1070,7 @@ void GraphicsManager::addRectToArray(Common::Array &rects, const C uint rectIndex; for (rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { Common::Rect &r = rects[rectIndex]; - + if (r.intersects(newRect)) { // Rect either intersects or is completely inside existing one, so extend existing one as necessary r.extend(newRect); @@ -1108,8 +1108,8 @@ void GraphicsManager::displayDirtyRects() { return; lockScreen(); - - // Refresh the entire screen + + // Refresh the entire screen for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; Common::Rect dstRect; -- cgit v1.2.3 From bfe63b71e9f0c2ee5b17022f37d8a189cb19516a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 9 Apr 2013 09:17:11 -0400 Subject: HOPKINS: Renaming some of the remaining graphics methods --- engines/hopkins/graphics.cpp | 85 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 42 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 019d5a5ae8..45ae3414b0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -42,7 +42,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _initGraphicsFl = false; _screenWidth = _screenHeight = 0; _screenLineSize = 0; - PAL_PIXELS = NULL; + _palettePixels = NULL; _lineNbr = 0; _videoPtr = NULL; _scrollOffset = 0; @@ -116,7 +116,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenHeight = height; _screenLineSize = SCREEN_WIDTH * 2; - PAL_PIXELS = SD_PIXELS; + _palettePixels = SD_PIXELS; _lineNbr = width; _initGraphicsFl = true; @@ -430,8 +430,8 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, byte *lineDestP = destP; for (int xp = 0; xp < width; ++xp) { - lineDestP[0] = PAL_PIXELS[lineSrcP[0] * 2]; - lineDestP[1] = PAL_PIXELS[(lineSrcP[0] * 2) + 1]; + lineDestP[0] = _palettePixels[lineSrcP[0] * 2]; + lineDestP[1] = _palettePixels[(lineSrcP[0] * 2) + 1]; lineDestP += 2; lineSrcP++; } @@ -444,7 +444,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, addRefreshRect(destX, destY, destX + width, destY + height); } -void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { +void GraphicsManager::copyTo16Bit(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { int xCtr; const byte *palette; int savedXCount; @@ -464,7 +464,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, loopSrcP = srcP; loopDestP = destP; savedXCount = xCount; - palette = PAL_PIXELS; + palette = _palettePixels; do { destP[0] = destP[2] = destP[_screenLineSize] = destP[_screenLineSize + 2] = palette[2 * srcP[0]]; @@ -640,14 +640,14 @@ void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byt updateScreen(); } -void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) { +void GraphicsManager::setColorPercentage(int palIndex, int r, int g, int b) { int palOffset = 3 * palIndex; _palette[palOffset] = 255 * r / 100; _palette[palOffset + 1] = 255 * g / 100; _palette[palOffset + 2] = 255 * b / 100; } -void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) { +void GraphicsManager::setColorPercentage2(int palIndex, int r, int g, int b) { int rv = 255 * r / 100; int gv = 255 * g / 100; int bv = 255 * b / 100; @@ -776,8 +776,8 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { destOffset += pixelCount; while (pixelCount--) { - destP[0] = PAL_PIXELS[2 * pixelIndex]; - destP[1] = PAL_PIXELS[(2 * pixelIndex) + 1]; + destP[0] = _palettePixels[2 * pixelIndex]; + destP[1] = _palettePixels[(2 * pixelIndex) + 1]; destP += 2; } @@ -789,8 +789,8 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { destOffset += pixelCount; while (pixelCount--) { - destP[0] = PAL_PIXELS[2 * pixelIndex]; - destP[1] = PAL_PIXELS[(2 * pixelIndex) + 1]; + destP[0] = _palettePixels[2 * pixelIndex]; + destP[1] = _palettePixels[(2 * pixelIndex) + 1]; destP += 2; } @@ -798,8 +798,8 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { } } else { byte *destP = (byte *)_videoPtr + destOffset * 2; - destP[0] = PAL_PIXELS[2 * srcByte]; - destP[1] = PAL_PIXELS[(2 * srcByte) + 1]; + destP[0] = _palettePixels[2 * srcByte]; + destP[1] = _palettePixels[(2 * srcByte) + 1]; ++srcP; ++destOffset; } @@ -831,7 +831,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { } } - WRITE_LE_UINT16((byte *)_videoPtr + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); + WRITE_LE_UINT16((byte *)_videoPtr + destOffset * 2, READ_LE_UINT16(_palettePixels + 2 * srcByte)); ++srcP; ++destOffset; } @@ -879,7 +879,7 @@ void GraphicsManager::copySurfaceRect(const byte *srcSurface, byte *destSurface, * @param yp Y co-ordinate. FOr some reason, starts from 300 = top row * @param spriteIndex Index of the sprite to draw */ -void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) { +void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) { // Get a pointer to the start of the desired sprite const byte *spriteP = spriteData + 3; for (int i = spriteIndex; i; --i) @@ -1115,7 +1115,7 @@ void GraphicsManager::displayDirtyRects() { Common::Rect dstRect; if (_vm->_eventsManager->_breakoutFl) { - Copy_Vga16(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + copyTo16Bit(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); @@ -1168,15 +1168,34 @@ void GraphicsManager::displayRefreshRects() { resetRefreshRects(); } -void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { + +/** + * Fast Display of either a compressed or vesa sprite + */ +void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment) { + int width = _vm->_objectsManager->getWidth(spriteData, spriteIndex); + int height = _vm->_objectsManager->getHeight(spriteData, spriteIndex); + + if (*spriteData == 78) { + drawCompressedSprite(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); + drawCompressedSprite(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); + } else { + drawVesaSprite(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex); + drawVesaSprite(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex); + } + if (addSegment) + addDirtyRect(xp, yp, xp + width, yp + height); +} + +void GraphicsManager::fastDisplay2(const byte *objectData, int xp, int yp, int idx, bool addSegment) { int width = _vm->_objectsManager->getWidth(objectData, idx); int height = _vm->_objectsManager->getHeight(objectData, idx); if (*objectData == 78) { - Affiche_Perfect(_backBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); - Affiche_Perfect(_frontBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); + drawCompressedSprite(_backBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); + drawCompressedSprite(_frontBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); } else { - Sprite_Vesa(_frontBuffer, objectData, xp + 300, yp + 300, idx); - Sprite_Vesa(_backBuffer, objectData, xp + 300, yp + 300, idx); + drawVesaSprite(_frontBuffer, objectData, xp + 300, yp + 300, idx); + drawVesaSprite(_backBuffer, objectData, xp + 300, yp + 300, idx); } if (addSegment) addDirtyRect(xp, yp, xp + width, yp + height); @@ -1196,7 +1215,7 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { byte *oldDestPtr = destPtr; for (int x = 320; x; x--) { curPixel = 2 * *curSurface; - palPtr = PAL_PIXELS + curPixel; + palPtr = _palettePixels + curPixel; destPtr[0] = destPtr[2] = destPtr[_screenLineSize] = destPtr[_screenLineSize + 2] = palPtr[0]; destPtr[1] = destPtr[3] = destPtr[_screenLineSize + 1] = destPtr[_screenLineSize + 3] = palPtr[1]; ++curSurface; @@ -1256,7 +1275,7 @@ int GraphicsManager::zoomOut(int val, int percentage) { } // Display 'Perfect?' -void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, bool flipFl) { +void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, bool flipFl) { const byte *spriteStartP = srcData + 3; for (int i = frameIndex; i; --i) spriteStartP += READ_LE_UINT32(spriteStartP) + 16; @@ -1581,24 +1600,6 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp } } -/** - * Fast Display - */ -void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment) { - int width = _vm->_objectsManager->getWidth(spriteData, spriteIndex); - int height = _vm->_objectsManager->getHeight(spriteData, spriteIndex); - - if (*spriteData == 78) { - Affiche_Perfect(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); - Affiche_Perfect(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); - } else { - Sprite_Vesa(_frontBuffer, spriteData, xp + 300, yp + 300, spriteIndex); - Sprite_Vesa(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex); - } - if (addSegment) - addDirtyRect(xp, yp, xp + width, yp + height); -} - void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { int left = x1; int top = y1; -- cgit v1.2.3 From 260a6bbc24ef45af5cb6f52a6dfe7330aea542c1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 9 Apr 2013 09:47:48 -0400 Subject: HOPKINS: Renamed remaining GraphicsManager methods --- engines/hopkins/graphics.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 45ae3414b0..c545c983d7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -224,7 +224,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { _maxX = SCREEN_WIDTH; lockScreen(); clearScreen(); - m_scroll16(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } else { setScreenWidth(SCREEN_WIDTH * 2); @@ -235,7 +235,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { if (MANU_SCROLL) { lockScreen(); - m_scroll16(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } } @@ -247,7 +247,7 @@ void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) for (int idx = 0; idx < 256; ++idx) _colorTable[idx] = idx; - Trans_bloc(_colorTable, palette, 256, minIndex, maxIndex); + translateSurface(_colorTable, palette, 256, minIndex, maxIndex); for (int idx = 0; idx < 256; ++idx) { byte v = _colorTable[idx]; @@ -268,7 +268,7 @@ void GraphicsManager::scrollScreen(int amount) { _scrollPosX = result; } -void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { +void GraphicsManager::translateSurface(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) { byte *destPosP = destP; for (int idx = 0; idx < count; ++idx) { int palIndex = *destPosP; @@ -294,7 +294,7 @@ void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int m } } -void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) { +void GraphicsManager::fillSurface(byte *surface, byte *col, int size) { byte dataVal; byte *dataP = surface; @@ -417,7 +417,7 @@ void GraphicsManager::setScreenWidth(int pitch) { /** * Copies data from a 8-bit palette surface into the 16-bit screen */ -void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { +void GraphicsManager::copy16BitRect(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { lockScreen(); assert(_videoPtr); @@ -444,7 +444,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, addRefreshRect(destX, destY, destX + width, destY + height); } -void GraphicsManager::copyTo16Bit(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { +void GraphicsManager::copy8BitRect(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { int xCtr; const byte *palette; int savedXCount; @@ -509,7 +509,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Set the transition palette and refresh the screen setPaletteVGA256(palData2); - m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); // Added a delay in order to see the fading @@ -520,7 +520,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) setPaletteVGA256(palette); // Refresh the screen - m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -539,7 +539,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } setPaletteVGA256(palData); - m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); _vm->_eventsManager->delay(20); @@ -551,7 +551,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface palData[i] = 0; setPaletteVGA256(palData); - m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -636,7 +636,7 @@ void GraphicsManager::setPaletteVGA256(const byte *palette) { void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); - m_scroll16(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -1115,7 +1115,7 @@ void GraphicsManager::displayDirtyRects() { Common::Rect dstRect; if (_vm->_eventsManager->_breakoutFl) { - copyTo16Bit(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + copy8BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); @@ -1126,7 +1126,7 @@ void GraphicsManager::displayDirtyRects() { // WORKAROUND: Original didn't lock the screen for access lockScreen(); - m_scroll16(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); + copy16BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); dstRect.left = r.left - _vm->_eventsManager->_startPos.x; dstRect.top = r.top; @@ -1622,12 +1622,12 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; - Copy_Mem(surface, left, top, croppedWidth, croppedHeight, destSurface, destX, destY); + copyRect(surface, left, top, croppedWidth, croppedHeight, destSurface, destX, destY); addDirtyRect(left, top, left + croppedWidth, top + height2); } } -void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, uint16 width, int height, byte *destSurface, int destX, int destY) { +void GraphicsManager::copyRect(const byte *srcSurface, int x1, int y1, uint16 width, int height, byte *destSurface, int destX, int destY) { const byte *srcP = x1 + _lineNbr2 * y1 + srcSurface; byte *destP = destX + _lineNbr2 * destY + destSurface; int yp = height; @@ -1741,17 +1741,17 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_objectsManager->_changeVerbFl = false; } -void GraphicsManager::NB_SCREEN(bool initPalette) { +void GraphicsManager::displayScreen(bool initPalette) { if (initPalette) initColorTable(50, 65, _palette); if (_lineNbr == SCREEN_WIDTH) - Trans_bloc2(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT); + fillSurface(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT); else if (_lineNbr == (SCREEN_WIDTH * 2)) - Trans_bloc2(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); + fillSurface(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); lockScreen(); - m_scroll16(_frontBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(_frontBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); memcpy(_backBuffer, _frontBuffer, 614399); -- cgit v1.2.3 From 55938b39755f2bac9fa180aa3f646fa8041b059c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 10:27:06 +0200 Subject: HOPKINS: Make engine less verbose by reducing some object names --- engines/hopkins/graphics.cpp | 104 +++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c545c983d7..49ff2df189 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -202,7 +202,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { bool flag = true; bool fileFoundFl = false; - _vm->_fileManager->searchCat(file, RES_PIC, fileFoundFl); + _vm->_fileIO->searchCat(file, RES_PIC, fileFoundFl); if (!fileFoundFl) { if (!f.open(file)) error("loadScreen - %s", file.c_str()); @@ -263,7 +263,7 @@ void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) */ void GraphicsManager::scrollScreen(int amount) { int result = CLIP(amount, 0, SCREEN_WIDTH); - _vm->_eventsManager->_startPos.x = result; + _vm->_events->_startPos.x = result; _scrollOffset = result; _scrollPosX = result; } @@ -316,7 +316,7 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte // Load PCX from within the PIC resource if (!f.open("PIC.RES")) error("Error opening PIC.RES."); - f.seek(_vm->_fileManager->_catalogPos); + f.seek(_vm->_fileIO->_catalogPos); } else { // Load stand alone PCX file if (!f.open(file)) @@ -509,18 +509,18 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Set the transition palette and refresh the screen setPaletteVGA256(palData2); - copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); // Added a delay in order to see the fading - _vm->_eventsManager->delay(20); + _vm->_events->delay(20); } // Set the final palette setPaletteVGA256(palette); // Refresh the screen - copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -529,7 +529,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) */ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface) { byte palData[PALETTE_BLOCK_SIZE]; - if ((step > 1) && (palette) && (!_vm->_eventsManager->_escKeyFl)) { + if ((step > 1) && (palette) && (!_vm->_events->_escKeyFl)) { int fadeStep = step; for (int fadeIndex = 0; fadeIndex < fadeStep; fadeIndex++) { for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) { @@ -539,10 +539,10 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } setPaletteVGA256(palData); - copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); - _vm->_eventsManager->delay(20); + _vm->_events->delay(20); } } @@ -551,7 +551,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface palData[i] = 0; setPaletteVGA256(palData); - copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -636,7 +636,7 @@ void GraphicsManager::setPaletteVGA256(const byte *palette) { void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); - copy16BitRect(surface, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -1007,31 +1007,31 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int void GraphicsManager::endDisplayBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_animationManager->_animBqe[idx]._enabledFl) - _vm->_objectsManager->hideBob(idx); + if (_vm->_animMan->_animBqe[idx]._enabledFl) + _vm->_objectsMan->hideBob(idx); } - _vm->_eventsManager->refreshScreenAndEvents(); - _vm->_eventsManager->refreshScreenAndEvents(); + _vm->_events->refreshScreenAndEvents(); + _vm->_events->refreshScreenAndEvents(); for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_animationManager->_animBqe[idx]._enabledFl) - _vm->_objectsManager->resetBob(idx); + if (_vm->_animMan->_animBqe[idx]._enabledFl) + _vm->_objectsMan->resetBob(idx); } for (int idx = 1; idx <= 29; ++idx) { - _vm->_objectsManager->_lockedAnims[idx]._enableFl = false; + _vm->_objectsMan->_lockedAnims[idx]._enableFl = false; } for (int idx = 1; idx <= 20; ++idx) { - _vm->_animationManager->_animBqe[idx]._enabledFl = false; + _vm->_animMan->_animBqe[idx]._enabledFl = false; } } void GraphicsManager::displayAllBob() { for (int idx = 1; idx <= 20; ++idx) { - if (_vm->_animationManager->_animBqe[idx]._enabledFl) - _vm->_objectsManager->displayBob(idx); + if (_vm->_animMan->_animBqe[idx]._enabledFl) + _vm->_objectsMan->displayBob(idx); } } @@ -1114,21 +1114,21 @@ void GraphicsManager::displayDirtyRects() { Common::Rect &r = _dirtyRects[idx]; Common::Rect dstRect; - if (_vm->_eventsManager->_breakoutFl) { + if (_vm->_events->_breakoutFl) { copy8BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); dstRect.setHeight((r.bottom - r.top) * 2); - } else if (r.right > _vm->_eventsManager->_startPos.x && r.left < _vm->_eventsManager->_startPos.x + SCREEN_WIDTH) { - r.left = MAX(r.left, _vm->_eventsManager->_startPos.x); - r.right = MIN(r.right, (int16)_vm->_eventsManager->_startPos.x + SCREEN_WIDTH); + } else if (r.right > _vm->_events->_startPos.x && r.left < _vm->_events->_startPos.x + SCREEN_WIDTH) { + r.left = MAX(r.left, _vm->_events->_startPos.x); + r.right = MIN(r.right, (int16)_vm->_events->_startPos.x + SCREEN_WIDTH); // WORKAROUND: Original didn't lock the screen for access lockScreen(); - copy16BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager->_startPos.x, r.top); + copy16BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_events->_startPos.x, r.top); - dstRect.left = r.left - _vm->_eventsManager->_startPos.x; + dstRect.left = r.left - _vm->_events->_startPos.x; dstRect.top = r.top; dstRect.setWidth(r.right - r.left); dstRect.setHeight(r.bottom - r.top); @@ -1173,8 +1173,8 @@ void GraphicsManager::displayRefreshRects() { * Fast Display of either a compressed or vesa sprite */ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment) { - int width = _vm->_objectsManager->getWidth(spriteData, spriteIndex); - int height = _vm->_objectsManager->getHeight(spriteData, spriteIndex); + int width = _vm->_objectsMan->getWidth(spriteData, spriteIndex); + int height = _vm->_objectsMan->getHeight(spriteData, spriteIndex); if (*spriteData == 78) { drawCompressedSprite(_backBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, false); @@ -1188,8 +1188,8 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp } void GraphicsManager::fastDisplay2(const byte *objectData, int xp, int yp, int idx, bool addSegment) { - int width = _vm->_objectsManager->getWidth(objectData, idx); - int height = _vm->_objectsManager->getHeight(objectData, idx); + int width = _vm->_objectsMan->getWidth(objectData, idx); + int height = _vm->_objectsMan->getHeight(objectData, idx); if (*objectData == 78) { drawCompressedSprite(_backBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); drawCompressedSprite(_frontBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, false); @@ -1685,10 +1685,10 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init Common::String filename = file + ".ini"; bool fileFoundFl = false; - byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI, fileFoundFl); + byte *ptr = _vm->_fileIO->searchCat(filename, RES_INI, fileFoundFl); if (!fileFoundFl) { - ptr = _vm->_fileManager->loadFile(filename); + ptr = _vm->_fileIO->loadFile(filename); } if (!mode) { @@ -1696,11 +1696,11 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_globals->_levelSpriteBuf = _vm->_globals->freeMemory(_vm->_globals->_levelSpriteBuf); if (initializeScreen) { fileFoundFl = false; - _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI, fileFoundFl); + _vm->_globals->_levelSpriteBuf = _vm->_fileIO->searchCat(filename, RES_SLI, fileFoundFl); if (!fileFoundFl) { - _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile(filename); + _vm->_globals->_levelSpriteBuf = _vm->_fileIO->loadFile(filename); } else { - _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile("RES_SLI.RES"); + _vm->_globals->_levelSpriteBuf = _vm->_fileIO->loadFile("RES_SLI.RES"); } } } @@ -1711,14 +1711,14 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init int dataOffset = 1; do { - int dataVal1 = _vm->_scriptManager->handleOpcode(ptr + 20 * dataOffset); + int dataVal1 = _vm->_script->handleOpcode(ptr + 20 * dataOffset); if (_vm->shouldQuit()) return; if (dataVal1 == 2) - dataOffset = _vm->_scriptManager->handleGoto((ptr + 20 * dataOffset)); + dataOffset = _vm->_script->handleGoto((ptr + 20 * dataOffset)); if (dataVal1 == 3) - dataOffset = _vm->_scriptManager->handleIf(ptr, dataOffset); + dataOffset = _vm->_script->handleIf(ptr, dataOffset); if (dataOffset == -1) error("Error, defective IFF"); if (dataVal1 == 1 || dataVal1 == 4) @@ -1732,13 +1732,13 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init filename = file + ".rep"; fileFoundFl = false; - byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP, fileFoundFl); + byte *dataP = _vm->_fileIO->searchCat(filename, RES_REP, fileFoundFl); if (!fileFoundFl) - dataP = _vm->_fileManager->loadFile(filename); + dataP = _vm->_fileIO->loadFile(filename); _vm->_globals->_answerBuffer = dataP; - _vm->_objectsManager->_forceZoneFl = true; - _vm->_objectsManager->_changeVerbFl = false; + _vm->_objectsMan->_forceZoneFl = true; + _vm->_objectsMan->_changeVerbFl = false; } void GraphicsManager::displayScreen(bool initPalette) { @@ -1751,7 +1751,7 @@ void GraphicsManager::displayScreen(bool initPalette) { fillSurface(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); lockScreen(); - copy16BitRect(_frontBuffer, _vm->_eventsManager->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + copy16BitRect(_frontBuffer, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); memcpy(_backBuffer, _frontBuffer, 614399); @@ -1841,24 +1841,24 @@ void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height */ void GraphicsManager::backupScreen() { // Allocate a new data block for the screen, if necessary - if (_vm->_graphicsManager->_backupScreen == NULL) - _vm->_graphicsManager->_backupScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + if (_vm->_graphicsMan->_backupScreen == NULL) + _vm->_graphicsMan->_backupScreen = _vm->_globals->allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); // Backup the screen - Common::copy(_vm->_graphicsManager->_backBuffer, _vm->_graphicsManager->_backBuffer + - SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsManager->_backupScreen); + Common::copy(_vm->_graphicsMan->_backBuffer, _vm->_graphicsMan->_backBuffer + + SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsMan->_backupScreen); } /** * Restore a previously backed up screen */ void GraphicsManager::restoreScreen() { - assert(_vm->_graphicsManager->_backupScreen); + assert(_vm->_graphicsMan->_backupScreen); // Restore the screen and free the buffer - Common::copy(_vm->_graphicsManager->_backupScreen, _vm->_graphicsManager->_backupScreen + - SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsManager->_backBuffer); - _vm->_globals->freeMemory(_vm->_graphicsManager->_backupScreen); + Common::copy(_vm->_graphicsMan->_backupScreen, _vm->_graphicsMan->_backupScreen + + SCREEN_WIDTH * 2 * SCREEN_HEIGHT, _vm->_graphicsMan->_backBuffer); + _vm->_globals->freeMemory(_vm->_graphicsMan->_backupScreen); _backupScreen = NULL; } -- cgit v1.2.3 From 1ac0c06bf61818bc37e96c9dd1a82f027f313ca5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 12:25:36 +0200 Subject: HOPKINS: Reduce the use of lockScreen() and unlockScreen() by adding them in clearScreen() --- engines/hopkins/graphics.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 49ff2df189..5637cd7d77 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -151,10 +151,12 @@ void GraphicsManager::unlockScreen() { * Clear Screen */ void GraphicsManager::clearScreen() { + lockScreen(); assert(_videoPtr); Common::fill(_screenBuffer, _screenBuffer + _screenLineSize * _screenHeight, 0); addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + unlockScreen(); } void GraphicsManager::clearVesaScreen() { @@ -177,9 +179,7 @@ void GraphicsManager::loadImage(const Common::String &file) { */ void GraphicsManager::loadVgaImage(const Common::String &file) { setScreenWidth(SCREEN_WIDTH); - lockScreen(); clearScreen(); - unlockScreen(); loadPCX320(_backBuffer, file, _palette); memcpy(_frontBuffer, _backBuffer, 64000); setScreenWidth(320); @@ -222,16 +222,14 @@ void GraphicsManager::loadScreen(const Common::String &file) { if (!_largeScreenFl) { setScreenWidth(SCREEN_WIDTH); _maxX = SCREEN_WIDTH; - lockScreen(); clearScreen(); + lockScreen(); copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); unlockScreen(); } else { setScreenWidth(SCREEN_WIDTH * 2); _maxX = SCREEN_WIDTH * 2; - lockScreen(); clearScreen(); - unlockScreen(); if (MANU_SCROLL) { lockScreen(); -- cgit v1.2.3 From 1b081457c944d3a0b72d8d22b085aaa4787a9a0b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 12:51:13 +0200 Subject: HOPKINS: Remove some useless lockScreen() and unlockScreen() around copy16BitRect() --- engines/hopkins/graphics.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 5637cd7d77..6d366217d1 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -223,19 +223,15 @@ void GraphicsManager::loadScreen(const Common::String &file) { setScreenWidth(SCREEN_WIDTH); _maxX = SCREEN_WIDTH; clearScreen(); - lockScreen(); + copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - unlockScreen(); } else { setScreenWidth(SCREEN_WIDTH * 2); _maxX = SCREEN_WIDTH * 2; clearScreen(); - if (MANU_SCROLL) { - lockScreen(); + if (MANU_SCROLL) copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - unlockScreen(); - } } memcpy(_frontBuffer, _backBuffer, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); @@ -1122,16 +1118,12 @@ void GraphicsManager::displayDirtyRects() { r.left = MAX(r.left, _vm->_events->_startPos.x); r.right = MIN(r.right, (int16)_vm->_events->_startPos.x + SCREEN_WIDTH); - // WORKAROUND: Original didn't lock the screen for access - lockScreen(); copy16BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_events->_startPos.x, r.top); dstRect.left = r.left - _vm->_events->_startPos.x; dstRect.top = r.top; dstRect.setWidth(r.right - r.left); dstRect.setHeight(r.bottom - r.top); - - unlockScreen(); } // If it's a valid rect, then add it to the list of areas to refresh on the screen @@ -1748,10 +1740,7 @@ void GraphicsManager::displayScreen(bool initPalette) { else if (_lineNbr == (SCREEN_WIDTH * 2)) fillSurface(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); - lockScreen(); copy16BitRect(_frontBuffer, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - unlockScreen(); - memcpy(_backBuffer, _frontBuffer, 614399); updateScreen(); } -- cgit v1.2.3 From 094a0617ac88148be291ffdff412cd515ed34ac8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 12:55:20 +0200 Subject: HOPKINS: Add lockScreen() and unlockScreen() in copy16bFromSurfaceScaleX2() --- engines/hopkins/graphics.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 6d366217d1..50620e3f29 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -185,10 +185,8 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { setScreenWidth(320); _maxX = 320; - lockScreen(); copy16bFromSurfaceScaleX2(_frontBuffer); addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - unlockScreen(); fadeInBreakout(); } @@ -603,9 +601,7 @@ void GraphicsManager::fadeOutDefaultLength(const byte *surface) { */ void GraphicsManager::fadeInBreakout() { setPaletteVGA256(_palette); - lockScreen(); copy16bFromSurfaceScaleX2(_frontBuffer); - unlockScreen(); updateScreen(); } @@ -617,10 +613,7 @@ void GraphicsManager::fadeOutBreakout() { memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); setPaletteVGA256(palette); - - lockScreen(); copy16bFromSurfaceScaleX2(_frontBuffer); - unlockScreen(); updateScreen(); } @@ -1198,6 +1191,8 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { byte *palPtr; int curPixel; + lockScreen(); + assert(_videoPtr); const byte *curSurface = surface; byte *destPtr = 30 * _screenLineSize + (byte *)_videoPtr; @@ -1213,6 +1208,8 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { } destPtr = _screenLineSize * 2 + oldDestPtr; } + + unlockScreen(); } void GraphicsManager::restoreSurfaceRect(byte *destSurface, const byte *src, int xp, int yp, int width, int height) { -- cgit v1.2.3 From bccb460e36120d3555684ef13b23e00a367a8eb7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 12:59:39 +0200 Subject: HOPKINS: Add lockScreen() and unlockScreen() in copyVideoVbe16() --- engines/hopkins/graphics.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 50620e3f29..2a29b351b6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -725,6 +725,8 @@ void GraphicsManager::copyWinscanVbe3(const byte *srcData, byte *destSurface) { void GraphicsManager::copyVideoVbe16(const byte *srcData) { const byte *srcP = srcData; int destOffset = 0; + + lockScreen(); assert(_videoPtr); for (;;) { @@ -791,6 +793,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { ++destOffset; } } + unlockScreen(); } void GraphicsManager::copyVideoVbe16a(const byte *srcData) { -- cgit v1.2.3 From 9149f363a6abd493550ae13aa12aa087c668bba3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 13:03:53 +0200 Subject: HOPKINS: Finish lock/unlockScreen() cleanup. Set them as private. --- engines/hopkins/graphics.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 2a29b351b6..b58c2c3544 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -801,6 +801,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { int destOffset = 0; const byte *srcP = srcData; + lockScreen(); for (;;) { srcByte = srcP[0]; if (srcByte == kByteStop) @@ -825,6 +826,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { ++srcP; ++destOffset; } + unlockScreen(); } void GraphicsManager::copySurfaceRect(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) { -- cgit v1.2.3 From 531b3cb37660e21abfba79fe80450c63e04245f4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Apr 2013 18:16:21 +0200 Subject: HOPKINS: Fix crash when skipping intro animations (regression in one of the lock/unlock commits) --- engines/hopkins/graphics.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b58c2c3544..f7d69ff1f2 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -733,7 +733,8 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { byte srcByte = srcP[0]; if (srcByte >= 222) { if (srcByte == kByteStop) - return; + break; + if (srcByte < kSetOffset) { destOffset += srcByte - 221; srcByte = *++srcP; @@ -754,7 +755,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { if (destOffset > SCREEN_WIDTH * SCREEN_HEIGHT) { warning("HACK: Stopping anim, out of bounds - 0x%x %d", srcByte, destOffset); - return; + break; } if (srcByte > 210) { @@ -805,7 +806,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { for (;;) { srcByte = srcP[0]; if (srcByte == kByteStop) - return; + break; if (srcP[0] > kByteStop) { if (srcByte == k8bVal) { destOffset += srcP[1]; -- cgit v1.2.3 From cdefd6428fd9fcaeeb68ba23ff7b55ebf08ba301 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 13 Apr 2013 23:24:13 +0200 Subject: HOPKINS: Apply a couple of renamings suggested by wjp --- engines/hopkins/graphics.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f7d69ff1f2..eca4d1d98c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -222,14 +222,14 @@ void GraphicsManager::loadScreen(const Common::String &file) { _maxX = SCREEN_WIDTH; clearScreen(); - copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } else { setScreenWidth(SCREEN_WIDTH * 2); _maxX = SCREEN_WIDTH * 2; clearScreen(); if (MANU_SCROLL) - copy16BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } memcpy(_frontBuffer, _backBuffer, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); @@ -409,7 +409,7 @@ void GraphicsManager::setScreenWidth(int pitch) { /** * Copies data from a 8-bit palette surface into the 16-bit screen */ -void GraphicsManager::copy16BitRect(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { +void GraphicsManager::display8BitRect(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) { lockScreen(); assert(_videoPtr); @@ -436,7 +436,7 @@ void GraphicsManager::copy16BitRect(const byte *surface, int xs, int ys, int wid addRefreshRect(destX, destY, destX + width, destY + height); } -void GraphicsManager::copy8BitRect(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { +void GraphicsManager::displayScaled8BitRect(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { int xCtr; const byte *palette; int savedXCount; @@ -501,7 +501,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) // Set the transition palette and refresh the screen setPaletteVGA256(palData2); - copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); // Added a delay in order to see the fading @@ -512,7 +512,7 @@ void GraphicsManager::fadeIn(const byte *palette, int step, const byte *surface) setPaletteVGA256(palette); // Refresh the screen - copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -531,7 +531,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface } setPaletteVGA256(palData); - copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); _vm->_events->delay(20); @@ -543,7 +543,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface palData[i] = 0; setPaletteVGA256(palData); - copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -623,7 +623,7 @@ void GraphicsManager::setPaletteVGA256(const byte *palette) { void GraphicsManager::setPaletteVGA256WithRefresh(const byte *palette, const byte *surface) { changePalette(palette); - copy16BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(surface, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); updateScreen(); } @@ -1108,7 +1108,7 @@ void GraphicsManager::displayDirtyRects() { Common::Rect dstRect; if (_vm->_events->_breakoutFl) { - copy8BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + displayScaled8BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); dstRect.left = r.left * 2; dstRect.top = r.top * 2 + 30; dstRect.setWidth((r.right - r.left) * 2); @@ -1117,7 +1117,7 @@ void GraphicsManager::displayDirtyRects() { r.left = MAX(r.left, _vm->_events->_startPos.x); r.right = MIN(r.right, (int16)_vm->_events->_startPos.x + SCREEN_WIDTH); - copy16BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_events->_startPos.x, r.top); + display8BitRect(_frontBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_events->_startPos.x, r.top); dstRect.left = r.left - _vm->_events->_startPos.x; dstRect.top = r.top; @@ -1743,7 +1743,7 @@ void GraphicsManager::displayScreen(bool initPalette) { else if (_lineNbr == (SCREEN_WIDTH * 2)) fillSurface(_frontBuffer, _colorTable, SCREEN_WIDTH * SCREEN_HEIGHT * 2); - copy16BitRect(_frontBuffer, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + display8BitRect(_frontBuffer, _vm->_events->_startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); memcpy(_backBuffer, _frontBuffer, 614399); updateScreen(); } -- cgit v1.2.3 From ceab6a71d35b6d9b0bf738a81289b6d50aad30a4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Apr 2013 14:21:05 -0400 Subject: HOPKINS: Renamed remaining fields of GraphicsManager class --- engines/hopkins/graphics.cpp | 82 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index eca4d1d98c..15788338db 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -67,14 +67,14 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _maxX = SCREEN_WIDTH * 2; _maxY = SCREEN_HEIGHT - 20; _posXClipped = _posYClipped = 0; - clip_x1 = clip_y1 = 0; + _clipX1 = _clipY1 = 0; _clipFl = false; _reduceX = _reducedY = 0; _zoomOutFactor = 0; _width = 0; _specialWidth = 0; - Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0); + Common::fill(&_paletteBuffer[0], &_paletteBuffer[PALETTE_SIZE * 2], 0); Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); @@ -82,12 +82,12 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { if (_vm->getIsDemo()) { if (_vm->getPlatform() == Common::kPlatformLinux) // CHECKME: Should be false? - MANU_SCROLL = true; + _manualScroll = true; else - MANU_SCROLL = false; + _manualScroll = false; _scrollSpeed = 16; } else { - MANU_SCROLL = false; + _manualScroll = false; _scrollSpeed = 32; } @@ -116,7 +116,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenHeight = height; _screenLineSize = SCREEN_WIDTH * 2; - _palettePixels = SD_PIXELS; + _palettePixels = _paletteBuffer; _lineNbr = width; _initGraphicsFl = true; @@ -228,7 +228,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { _maxX = SCREEN_WIDTH * 2; clearScreen(); - if (MANU_SCROLL) + if (_manualScroll) display8BitRect(_backBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } @@ -399,7 +399,7 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte void GraphicsManager::clearPalette() { // As weird as it sounds, this is what the original Linux executable does, // and not a full array clear. - SD_PIXELS[0] = 0; + _paletteBuffer[0] = 0; } void GraphicsManager::setScreenWidth(int pitch) { @@ -644,13 +644,13 @@ void GraphicsManager::setColorPercentage2(int palIndex, int r, int g, int b) { _palette[palOffset + 1] = gv; _palette[palOffset + 2] = bv; - WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], mapRGB(rv, gv, bv)); + WRITE_LE_UINT16(&_paletteBuffer[2 * palIndex], mapRGB(rv, gv, bv)); } void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - WRITE_LE_UINT16(&SD_PIXELS[2 * idx], mapRGB(srcP[0], srcP[1], srcP[2])); + WRITE_LE_UINT16(&_paletteBuffer[2 * idx], mapRGB(srcP[0], srcP[1], srcP[2])); } } @@ -888,7 +888,7 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int int height = READ_LE_UINT16(spriteP); // Clip X - clip_x1 = width; + _clipX1 = width; if ((xp + width) <= _minX + 300) return; if (xp < _minX + 300) { @@ -897,7 +897,7 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int } // Clip Y - clip_y1 = height; + _clipY1 = height; if (yp <= 0) return; if (yp < _minY + 300) { @@ -913,7 +913,7 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int if (xAmount <= 10) return; - clip_x1 = xAmount - 10; + _clipX1 = xAmount - 10; _clipFl = true; } @@ -925,8 +925,8 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int if (yAmount <= 10) return; - // clip_y1 is always positive thanks to the previous check - clip_y1 = yAmount - 10; + // _clipY1 is always positive thanks to the previous check + _clipY1 = yAmount - 10; _clipFl = true; } @@ -945,7 +945,7 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int // Handling for clipped versus non-clipped if (_clipFl) { // Clipped version - for (int yc = 0; yc < clip_y1; ++yc, destP += _lineNbr2) { + for (int yc = 0; yc < _clipY1; ++yc, destP += _lineNbr2) { byte *tempDestP = destP; byte byteVal; int xc = 0; @@ -958,7 +958,7 @@ void GraphicsManager::drawVesaSprite(byte *surface, const byte *spriteData, int if (byteVal == 254) { // Copy pixel range for (int xv = 0; xv < width; ++xv, ++xc, ++spriteP, ++tempDestP) { - if (_posYClipped == 0 && xc >= _posXClipped && xc < clip_x1) + if (_posYClipped == 0 && xc >= _posXClipped && xc < _clipX1) *tempDestP = *spriteP; } } else { @@ -1281,14 +1281,14 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i const byte *spritePixelsP = spriteSizeP + 10; _posXClipped = 0; _posYClipped = 0; - clip_x1 = 0; - clip_y1 = 0; + _clipX1 = 0; + _clipY1 = 0; if ((xp300 <= _minX) || (yp300 <= _minY) || (xp300 >= _maxX + 300) || (yp300 >= _maxY + 300)) return; // Clipped values are greater or equal to zero, thanks to the previous test - clip_x1 = _maxX + 300 - xp300; - clip_y1 = _maxY + 300 - yp300; + _clipX1 = _maxX + 300 - xp300; + _clipY1 = _maxY + 300 - yp300; // _minX is never negative, and should be always 0 // The previous check insures that xp300 it's always greater to it @@ -1321,21 +1321,21 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i clippedDestP += _lineNbr2 * _posYClipped; zoomedHeight -= _posYClipped; } - if (zoomedHeight > clip_y1) - zoomedHeight = clip_y1; + if (zoomedHeight > _clipY1) + zoomedHeight = _clipY1; if (_posXClipped) { if (_posXClipped >= zoomedWidth) return; zoomedWidth -= _posXClipped; } - if (zoomedWidth > clip_x1) { - int clippedZoomedWidth = zoomedWidth - clip_x1; + if (zoomedWidth > _clipX1) { + int clippedZoomedWidth = zoomedWidth - _clipX1; clippedDestP -= clippedZoomedWidth; int closestWidth = 0; while (zoomIn(++closestWidth, zoom2) < clippedZoomedWidth) ; spritePixelsP += closestWidth; - zoomedWidth = clip_x1; + zoomedWidth = _clipX1; } int curHeight; do { @@ -1390,8 +1390,8 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i dest1P += _lineNbr2 * _posYClipped; zoomedHeight -= _posYClipped; } - if (zoomedHeight > clip_y1) - zoomedHeight = clip_y1; + if (zoomedHeight > _clipY1) + zoomedHeight = _clipY1; if (_posXClipped) { if (_posXClipped >= zoomedWidth) return; @@ -1402,8 +1402,8 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i dest1P += _posXClipped; zoomedWidth = zoomedWidth - _posXClipped; } - if (zoomedWidth > clip_x1) - zoomedWidth = clip_x1; + if (zoomedWidth > _clipX1) + zoomedWidth = _clipX1; int curHeight; do { @@ -1466,7 +1466,7 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i for (int i = _width; i; i--) { _reduceX += _zoomOutFactor; if (_reduceX >= 0 && _reduceX < 100) { - if (curWidth >= _posXClipped && curWidth < clip_x1 && *spritePixelsP) + if (curWidth >= _posXClipped && curWidth < _clipX1 && *spritePixelsP) *curDestP = *spritePixelsP; --curDestP; ++spritePixelsP; @@ -1494,7 +1494,7 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i for (int i = _width; i; i--) { _reduceX += _zoomOutFactor; if (_reduceX >= 0 && _reduceX < 100) { - if (curX >= _posXClipped && curX < clip_x1 && *spritePixelsP) + if (curX >= _posXClipped && curX < _clipX1 && *spritePixelsP) *dest1P = *spritePixelsP; ++dest1P; ++spritePixelsP; @@ -1526,18 +1526,18 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i dest2P += _lineNbr2 * _posYClipped; spriteHeight1 -= _posYClipped; } - if (spriteHeight1 > clip_y1) - spriteHeight1 = clip_y1; + if (spriteHeight1 > _clipY1) + spriteHeight1 = _clipY1; if (_posXClipped >= spriteWidth) return; spriteWidth -= _posXClipped; - if (spriteWidth > clip_x1) { - int clippedWidth = spriteWidth - clip_x1; + if (spriteWidth > _clipX1) { + int clippedWidth = spriteWidth - _clipX1; spritePixelsP += clippedWidth; dest2P -= clippedWidth; - spriteWidth = clip_x1; + spriteWidth = _clipX1; } int yCtr2; do { @@ -1563,8 +1563,8 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i dest1P += _lineNbr2 * _posYClipped; spriteHeight1 -= _posYClipped; } - if (spriteHeight1 > clip_y1) - spriteHeight1 = clip_y1; + if (spriteHeight1 > _clipY1) + spriteHeight1 = _clipY1; if (_posXClipped) { if (_posXClipped >= spriteWidth) return; @@ -1572,8 +1572,8 @@ void GraphicsManager::drawCompressedSprite(byte *surface, const byte *srcData, i dest1P += _posXClipped; spriteWidth -= _posXClipped; } - if (spriteWidth > clip_x1) - spriteWidth = clip_x1; + if (spriteWidth > _clipX1) + spriteWidth = _clipX1; int yCtr1; do { yCtr1 = spriteHeight1; -- cgit v1.2.3 From 4b086b46b2e19f7f593b287655d8fc1417146636 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Wed, 17 Apr 2013 12:24:16 +0200 Subject: HOPKINS: fix palette writes on BE --- engines/hopkins/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 15788338db..f978a5803f 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -644,13 +644,13 @@ void GraphicsManager::setColorPercentage2(int palIndex, int r, int g, int b) { _palette[palOffset + 1] = gv; _palette[palOffset + 2] = bv; - WRITE_LE_UINT16(&_paletteBuffer[2 * palIndex], mapRGB(rv, gv, bv)); + WRITE_UINT16(&_paletteBuffer[2 * palIndex], mapRGB(rv, gv, bv)); } void GraphicsManager::changePalette(const byte *palette) { const byte *srcP = &palette[0]; for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) { - WRITE_LE_UINT16(&_paletteBuffer[2 * idx], mapRGB(srcP[0], srcP[1], srcP[2])); + WRITE_UINT16(&_paletteBuffer[2 * idx], mapRGB(srcP[0], srcP[1], srcP[2])); } } -- cgit v1.2.3 From b2d5b403053623517b857598ce8ba1d8bdccc047 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Apr 2013 08:24:52 +0200 Subject: HOPKINS: Enlarge _lockedAnims array to avoid potential out of bound access. CID 1004012 --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f978a5803f..c2c8b426e6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1012,7 +1012,7 @@ void GraphicsManager::endDisplayBob() { _vm->_objectsMan->resetBob(idx); } - for (int idx = 1; idx <= 29; ++idx) { + for (int idx = 1; idx < 36; ++idx) { _vm->_objectsMan->_lockedAnims[idx]._enableFl = false; } -- cgit v1.2.3 From 369f886477407f3b91aeaf5a0aae4c65c5d45bea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 10 May 2013 17:33:03 +1000 Subject: HOPKINS: Added a zones debugger command --- engines/hopkins/graphics.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c2c8b426e6..aa71b2c4c0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -73,6 +73,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _zoomOutFactor = 0; _width = 0; _specialWidth = 0; + _showZones = false; Common::fill(&_paletteBuffer[0], &_paletteBuffer[PALETTE_SIZE * 2], 0); Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); @@ -663,11 +664,14 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { } void GraphicsManager::updateScreen() { - // TODO: Is this okay here? // Display any aras of the screen that need refreshing displayDirtyRects(); displayRefreshRects(); + // Extra checks for debug information + if (_showZones) + displayZones(); + // Update the screen g_system->updateScreen(); } @@ -1140,6 +1144,7 @@ void GraphicsManager::displayRefreshRects() { screenSurface = g_system->lockScreen(); g_system->copyRectToScreen(_screenBuffer, _screenLineSize, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } + // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; @@ -1157,6 +1162,50 @@ void GraphicsManager::displayRefreshRects() { resetRefreshRects(); } +/** + * Display any zones for the current room + */ +void GraphicsManager::displayZones() { + Graphics::Surface *screenSurface = g_system->lockScreen(); + + for (int bobZoneId = 0; bobZoneId <= 48; bobZoneId++) { + int bobId = _vm->_linesMan->_bobZone[bobZoneId]; + if (bobId) { + // Get the rectangle for the zone + Common::Rect r(_vm->_objectsMan->_bob[bobId]._oldX, _vm->_objectsMan->_bob[bobId]._oldY, + _vm->_objectsMan->_bob[bobId]._oldX + _vm->_objectsMan->_bob[bobId]._oldWidth, + _vm->_objectsMan->_bob[bobId]._oldY + _vm->_objectsMan->_bob[bobId]._oldHeight); + + displayDebugRect(screenSurface, r); + } + } + + for (int squareZoneId = 0; squareZoneId <= 99; squareZoneId++) { + if (_vm->_linesMan->_zone[squareZoneId]._enabledFl && _vm->_linesMan->_squareZone[squareZoneId]._enabledFl) { + Common::Rect r(_vm->_linesMan->_squareZone[squareZoneId]._left, _vm->_linesMan->_squareZone[squareZoneId]._top, + _vm->_linesMan->_squareZone[squareZoneId]._right, _vm->_linesMan->_squareZone[squareZoneId]._bottom); + + displayDebugRect(screenSurface, r); + } + } + + g_system->unlockScreen(); +} + +void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect) { + Common::Rect r = srcRect; + + // Move for scrolling offset and adjust to crop on-screen + r.translate(-_scrollPosX, 0); + r.left = MAX(r.left, (int16)0); + r.top = MAX(r.top, (int16)0); + r.right = MIN(r.right, (int16)SCREEN_WIDTH); + r.bottom = MIN(r.bottom, (int16)SCREEN_HEIGHT); + + // If there's an on-screen portion, display it + if (r.isValidRect()) + surface->frameRect(r, 0xffffff); +} /** * Fast Display of either a compressed or vesa sprite -- cgit v1.2.3 From 1f509f13b238789499a869e5a0946b26f53c630b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 12 May 2013 18:44:52 +0200 Subject: HOPKINS: Use different colors for displaying hotspot zones --- engines/hopkins/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index aa71b2c4c0..636bdb40ce 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1176,7 +1176,7 @@ void GraphicsManager::displayZones() { _vm->_objectsMan->_bob[bobId]._oldX + _vm->_objectsMan->_bob[bobId]._oldWidth, _vm->_objectsMan->_bob[bobId]._oldY + _vm->_objectsMan->_bob[bobId]._oldHeight); - displayDebugRect(screenSurface, r); + displayDebugRect(screenSurface, r, 0xff0000); } } @@ -1185,14 +1185,14 @@ void GraphicsManager::displayZones() { Common::Rect r(_vm->_linesMan->_squareZone[squareZoneId]._left, _vm->_linesMan->_squareZone[squareZoneId]._top, _vm->_linesMan->_squareZone[squareZoneId]._right, _vm->_linesMan->_squareZone[squareZoneId]._bottom); - displayDebugRect(screenSurface, r); + displayDebugRect(screenSurface, r, 0x00ff00); } } g_system->unlockScreen(); } -void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect) { +void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect, uint32 color) { Common::Rect r = srcRect; // Move for scrolling offset and adjust to crop on-screen @@ -1204,7 +1204,7 @@ void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common: // If there's an on-screen portion, display it if (r.isValidRect()) - surface->frameRect(r, 0xffffff); + surface->frameRect(r, color); } /** -- cgit v1.2.3 From d6d3c6a13c2c830029872040a76783d84166c238 Mon Sep 17 00:00:00 2001 From: sylvaintv Date: Mon, 13 May 2013 00:04:55 +0200 Subject: HOPKINS : Added a lines debugger command --- engines/hopkins/graphics.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 636bdb40ce..ebc5cfa8da 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -74,6 +74,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) { _width = 0; _specialWidth = 0; _showZones = false; + _showLines = false; Common::fill(&_paletteBuffer[0], &_paletteBuffer[PALETTE_SIZE * 2], 0); Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); @@ -672,6 +673,9 @@ void GraphicsManager::updateScreen() { if (_showZones) displayZones(); + if (_showLines) + displayLines(); + // Update the screen g_system->updateScreen(); } @@ -1192,6 +1196,31 @@ void GraphicsManager::displayZones() { g_system->unlockScreen(); } +/** + * Display any zones for the current room + */ +void GraphicsManager::displayLines() { + Graphics::Surface *screenSurface = g_system->lockScreen(); + + uint16* pixels = (uint16*)screenSurface->pixels; + + for (int lineIndex = 0; lineIndex < _vm->_linesMan->_linesNumb; lineIndex++) { + int i = 0; + do { + int x = _vm->_linesMan->_lineItem[lineIndex]._lineData[i] - _scrollPosX; + int y = _vm->_linesMan->_lineItem[lineIndex]._lineData[i+1]; + if (x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT) { + pixels[ y * screenSurface->w + x ] = 0xffff; + } + i += 2; + } + while(_vm->_linesMan->_lineItem[lineIndex]._lineData[i] != -1); + } + + g_system->unlockScreen(); +} + + void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect, uint32 color) { Common::Rect r = srcRect; -- cgit v1.2.3