From 8c06b0afd0c4ca9fa8f147a40ccd7210250f5a88 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Sat, 2 Jul 2016 19:24:13 +0200 Subject: DM: Add F0097_DUNGEONVIEW_DrawViewport --- engines/dm/dm.cpp | 8 ++++++- engines/dm/dm.h | 4 +++- engines/dm/gfx.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++-------- engines/dm/gfx.h | 28 ++++++++++++++++++---- engines/dm/text.cpp | 4 ++-- 5 files changed, 95 insertions(+), 18 deletions(-) (limited to 'engines/dm') diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index bc4d1c9c3e..ec455c44f0 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -166,8 +166,14 @@ void DMEngine::initializeGame() { warning("MISSING CODE: F0357_COMMAND_DiscardAllInput"); } + void DMEngine::f448_initMemoryManager() + { + warning("STUB FUNCTION"); + for (uint16 i = 0; i < 16; ++i) + _displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i]; + } -void DMEngine::startGame() { + void DMEngine::startGame() { _g331_pressingEye = false; _g332_stopPressingEye = false; _g333_pressingMouth = false; diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 361ff9e423..d439cfadae 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -134,13 +134,15 @@ public: enum { // engine debug channels kDMDebugExample = 1 << 0, - kDMDebugUselessCode = 1 << 1 + kDMDebugUselessCode = 1 << 1, + kDMDebugOftenCalledWarning = 2 << 2 }; class DMEngine : public Engine { void startGame(); // @ F0462_START_StartGame_CPSF void processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE void initializeGame(); // @ F0463_START_InitializeGame_CPSADEF + void f448_initMemoryManager(); // @ F0448_STARTUP1_InitializeMemoryManager_CPSADEF void gameloop(); // @ F0002_MAIN_GameLoop_CPSDF void initArrays(); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index a459109eaf..25d4c46839 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -578,8 +578,7 @@ byte g222_PalChangesCreature_D2[16] = {0, 10, 20, 30, 40, 30, 60, 70, 50, 0, 0, Viewport gDefultViewPort(0, 0, 320, 200); -// TODO: I guessed the numbers -Viewport g296_DungeonViewport(0, 33, 224, 126); // @ G0296_puc_Bitmap_Viewport +Viewport g296_DungeonViewport(0, 33, 224, 136); // @ G0296_puc_Bitmap_Viewport byte g17_PalChangesNoChanges[16] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150}; // @ G0017_auc_Graphic562_PaletteChanges_NoChanges @@ -594,7 +593,7 @@ byte g192_AlcoveOrnIndices[k3_AlcoveOrnCount] = { // @ G0192_auc_Graphic558_Alco DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { - _vgaBuffer = nullptr; + _g348_bitmapScreen = nullptr; _bitmaps = nullptr; _grapItemCount = 0; _packedItemPos = nullptr; @@ -674,12 +673,16 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _g97_bitmapWall_D1LCR_Native = nullptr; _g98_bitmapWall_D0L_Native = nullptr; _g99_bitmapWall_D0R_Native = nullptr; + + _g322_paletteSwitchingEnabled = false; + warning("DUMMY CODE: setting _g304_dungeonViewPaletteIndex"); + _g304_dungeonViewPaletteIndex = 0; } DisplayMan::~DisplayMan() { delete[] _packedItemPos; delete[] _packedBitmaps; - delete[] _vgaBuffer; + delete[] _g348_bitmapScreen; if (_bitmaps) { delete[] _bitmaps[0]; delete[] _bitmaps; @@ -722,8 +725,8 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenWidth = width; _screenHeight = height; delete[] _g74_tmpBitmap; - delete[] _vgaBuffer; - _vgaBuffer = new byte[_screenWidth * _screenHeight]; + delete[] _g348_bitmapScreen; + _g348_bitmapScreen = new byte[_screenWidth * _screenHeight]; clearScreen(k0_ColorBlack); } @@ -943,6 +946,20 @@ void DisplayMan::f461_allocateFlippedWallBitmaps() { _g94_bitmapWall_D0R_Flipped = new byte[32 * 136]; } +void DisplayMan::f565_viewportSetPalette(uint16* middleScreenPalette, uint16* topAndBottomScreen) { + if (middleScreenPalette && topAndBottomScreen) + debugC(kDMDebugOftenCalledWarning, "MISSING CODE: F0508_AMIGA_BuildPaletteChangeCopperList"); + + f566_viewportBlitToScreen(); +} + +void DisplayMan::f566_viewportBlitToScreen() { + warning("MISSING FUNCTIONALITY: using correct colorpalette"); + Box box(0, 33, 223, 135); + + blitToBitmap(_g296_bitmapViewport, k112_byteWidthViewport * 2, 0, 0, _g348_bitmapScreen, k160_byteWidthScreen * 2, box, k255_ColorNoTransparency); +} + void DisplayMan::loadPalette(uint16 *palette) { byte colorPalette[16 * 3]; for (int i = 0; i < 16; ++i) { @@ -1033,7 +1050,7 @@ void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcWidth, uint16 srcHeight void DisplayMan::blitBoxFilledWithMaskedBitmapToScreen(byte* src, byte* mask, byte* tmp, Box& box, int16 lastUnitIndex, int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport& viewport) { - blitBoxFilledWithMaskedBitmap(src, _vgaBuffer, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); + blitBoxFilledWithMaskedBitmap(src, _g348_bitmapScreen, mask, tmp, box, lastUnitIndex, firstUnitIndex, _screenWidth, transparent, xPos, yPos, _screenHeight, height2, viewport); } void DisplayMan::flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height) { @@ -1086,12 +1103,42 @@ byte* DisplayMan::getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int void DisplayMan::updateScreen() { - _vm->_system->copyRectToScreen(_vgaBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight); + _vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight); _vm->_system->updateScreen(); } +void DisplayMan::f97_drawViewport(int16 palSwitchingRequestedState) { + static uint16 *gK10_dungeonViewCurrentPalette; // @ K0010_pui_DungeonViewCurrentPalette + + // ignored code F0510_AMIGA_WaitBottomOfViewPort + if (palSwitchingRequestedState == k2_viewportAsBeforeSleepOrFreezeGame) + palSwitchingRequestedState = _g322_paletteSwitchingEnabled ? 1 : 0; + + if (_g342_refreshDungeonViewPaleteRequested) { + gK10_dungeonViewCurrentPalette = g21_PalDungeonView[_g304_dungeonViewPaletteIndex]; + _g342_refreshDungeonViewPaleteRequested = false; + if (palSwitchingRequestedState == k0_viewportNotDungeonView) { + _g322_paletteSwitchingEnabled = true; + } else { + _g322_paletteSwitchingEnabled = false; + } + } + + if (palSwitchingRequestedState != (_g322_paletteSwitchingEnabled ? 1 : 0)) { + if (palSwitchingRequestedState) { + f565_viewportSetPalette(gK10_dungeonViewCurrentPalette, _g347_paletteTopAndBottomScreen); + _g322_paletteSwitchingEnabled = true; + } else { + f565_viewportSetPalette(_g347_paletteTopAndBottomScreen, _g347_paletteTopAndBottomScreen); + _g322_paletteSwitchingEnabled = false; + } + } else { + f565_viewportSetPalette(nullptr, nullptr); + } +} + byte *DisplayMan::getCurrentVgaBuffer() { - return _vgaBuffer; + return _g348_bitmapScreen; } uint16 DisplayMan::getWidth(uint16 index) { @@ -1685,6 +1732,8 @@ void DisplayMan::loadCurrentMapGraphics() { if (replColorOrdinal) applyCreatureReplColors(10, _vm->ordinalToIndex(replColorOrdinal)); } + + _g342_refreshDungeonViewPaleteRequested = true; } void DisplayMan::applyCreatureReplColors(int replacedColor, int replacementColor) { @@ -2965,7 +3014,7 @@ byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) - memset(_vgaBuffer + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); + memset(_g348_bitmapScreen + y * _screenWidth + box._x1 + viewport._posX, color, sizeof(byte) * width); } void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcWidth, uint16 srcX, uint16 srcY, diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2a30c53978..5efa58aaa2 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -408,13 +408,21 @@ extern Viewport g296_DungeonViewport; #define k15_DoorOrnDestroyedMask 15 // @ C15_DOOR_ORNAMENT_DESTROYED_MASK #define k16_DoorOrnThivesEyeMask 16 // @ C16_DOOR_ORNAMENT_THIEVES_EYE_MASK +#define k0_viewportNotDungeonView 0 // @ C0_VIEWPORT_NOT_DUNGEON_VIEW +#define k1_viewportDungeonView 1 // @ C1_VIEWPORT_DUNGEON_VIEW +#define k2_viewportAsBeforeSleepOrFreezeGame 2 // @ C2_VIEWPORT_AS_BEFORE_SLEEP_OR_FREEZE_GAME + + +#define k112_byteWidthViewport 112 // @ C112_BYTE_WIDTH_VIEWPORT +#define k136_heightViewport 136 // @ C136_HEIGHT_VIEWPORT + +#define k160_byteWidthScreen 160 // @ C160_BYTE_WIDTH_SCREEN +#define k200_heightScreen 200 // @ C200_HEIGHT_SCREEN + class DisplayMan { friend class DM::TextMan; DMEngine *_vm; - uint16 _screenWidth; - uint16 _screenHeight; - byte *_vgaBuffer; /// Related to graphics.dat file uint16 _grapItemCount; // @ G0632_ui_GraphicCount @@ -434,6 +442,9 @@ class DisplayMan { void unpackGraphics(); void loadFNT1intoBitmap(uint16 index, byte *destBitmap); + void f565_viewportSetPalette(uint16 * middleScreenPalette, uint16 * topAndBottomScreen); // @ F0565_VIEWPORT_SetPalette + void f566_viewportBlitToScreen(); // @ F0566_VIEWPORT_BlitToScreen + void drawFloorPitOrStairsBitmapFlippedHorizontally(uint16 nativeIndex, Frame &frame); // @ F0105_DUNGEONVIEW_DrawFloorPitOrStairsBitmapFlippedHorizontally void drawFloorPitOrStairsBitmap(uint16 nativeIndex, Frame &frame); // @ F0104_DUNGEONVIEW_DrawFloorPitOrStairsBitmap void drawWallSetBitmap(byte *bitmap, Frame &f); // @ F0100_DUNGEONVIEW_DrawWallSetBitmap @@ -513,9 +524,17 @@ class DisplayMan { bool _g76_useFlippedWallAndFootprintsBitmap; // @ G0076_B_UseFlippedWallAndFootprintsBitmaps public: + uint16 _screenWidth; + uint16 _screenHeight; + byte *_g348_bitmapScreen; // @ G0348_pl_Bitmap_Screen byte* _g296_bitmapViewport; // @ G0296_puc_Bitmap_Viewport + // some methods use this for a stratchpad, don't make assumptions about content between function calls byte *_g74_tmpBitmap; // @ G0074_puc_Bitmap_Temporary + bool _g322_paletteSwitchingEnabled; // @ G0322_B_PaletteSwitchingEnabled + bool _g342_refreshDungeonViewPaleteRequested; // @ G0342_B_RefreshDungeonViewPaletteRequested + int16 _g304_dungeonViewPaletteIndex; // @ G0304_i_DungeonViewPaletteIndex + uint16 _g347_paletteTopAndBottomScreen[16]; // @ G0347_aui_Palette_TopAndBottomScreen explicit DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -561,7 +580,7 @@ public: int16 firstUnitIndex, int16 destPixelWidth, Color transparent, int16 xPos, int16 yPos, int16 destHeight, int16 height2, Viewport &viewport = g296_DungeonViewport); // @ F0133_VIDEO_BlitBoxFilledWithMaskedBitmap - void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); + void flipBitmapHorizontal(byte *bitmap, uint16 width, uint16 height); // @ F0103_DUNGEONVIEW_DrawDoorFrameBitmapFlippedHorizontally void flipBitmapVertical(byte *bitmap, uint16 width, uint16 height); byte *getExplosionBitmap(uint16 explosionAspIndex, uint16 scale, int16 &returnPixelWidth, int16 &returnHeight); // @ F0114_DUNGEONVIEW_GetExplosionBitmap @@ -570,6 +589,7 @@ public: void clearScreenBox(Color color, Box &box, Viewport &viewport = gDefultViewPort); // @ D24_FillScreenBox, F0550_VIDEO_FillScreenBox void drawDungeon(direction dir, int16 posX, int16 posY); // @ F0128_DUNGEONVIEW_Draw_CPSF void updateScreen(); + void f97_drawViewport(int16 palSwitchingRequestedState); // @ F0097_DUNGEONVIEW_DrawViewport byte* getBitmap(uint16 index); Common::MemoryReadStream getCompressedData(uint16 index); diff --git a/engines/dm/text.cpp b/engines/dm/text.cpp index f526faad88..67ac123a72 100644 --- a/engines/dm/text.cpp +++ b/engines/dm/text.cpp @@ -66,7 +66,7 @@ void TextMan::printTextToBitmap(byte* destBitmap, uint16 destPixelWidth, uint16 } void TextMan::printTextToScreen(uint16 destX, uint16 destY, Color textColor, Color bgColor, const char* text, Viewport &viewport) { - printTextToBitmap(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); + printTextToBitmap(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, _vm->_displayMan->_screenHeight, viewport); } void TextMan::printToViewport(int16 posX, int16 posY, Color textColor, const char* text, Color bgColor) { @@ -82,7 +82,7 @@ void TextMan::printWithTrailingSpaces(byte* destBitmap, int16 destPixelWidth, in } void TextMan::printWithTrailingSpacesToScreen(int16 destX, int16 destY, Color textColor, Color bgColor, const char* text, int16 strLenght, Viewport& viewport) { - printWithTrailingSpaces(_vm->_displayMan->_vgaBuffer, _vm->_displayMan->_screenWidth, destX, destY, + printWithTrailingSpaces(_vm->_displayMan->_g348_bitmapScreen, _vm->_displayMan->_screenWidth, destX, destY, textColor, bgColor, text, strLenght, _vm->_displayMan->_screenHeight, viewport); } -- cgit v1.2.3