Skip to content

Commit

Permalink
DM: Add partial fix of color palette
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent 37db95c commit 94ba2fd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
6 changes: 3 additions & 3 deletions engines/dm/dm.cpp
Expand Up @@ -246,10 +246,9 @@ uint16 DMEngine::f30_getScaledProduct(uint16 val, uint16 scale, uint16 vale2) {
}

void DMEngine::f463_initializeGame() {
f448_initMemoryManager();
_displayMan->f479_loadGraphics();
_displayMan->f460_initializeGraphicData();
warning(false, "Dummy code in f463_initializeGame, setting palette");
_displayMan->loadPalette(g21_PalDungeonView[0]);
_displayMan->f94_loadFloorSet(k0_FloorSetStone);
_displayMan->f95_loadWallSet(k0_WallSetStone);

Expand Down Expand Up @@ -279,6 +278,7 @@ void DMEngine::f463_initializeGame() {

void DMEngine::f448_initMemoryManager() {
warning(false, "STUB METHOD: f448_initMemoryManager");
_displayMan->f508_buildPaletteChangeCopperList(gK57_PalSwoosh, gK57_PalSwoosh);
for (uint16 i = 0; i < 16; ++i)
_displayMan->_g347_paletteTopAndBottomScreen[i] = g21_PalDungeonView[0][i];
}
Expand Down Expand Up @@ -319,7 +319,7 @@ void DMEngine::f462_startGame() {
_displayMan->D24_fillScreenBox(boxScreenBottom, k0_ColorBlack);
}

warning(false, "TODO: build copper");
_displayMan->f508_buildPaletteChangeCopperList(g21_PalDungeonView[0], _displayMan->_g347_paletteTopAndBottomScreen);
_menuMan->f395_drawMovementArrows();
_championMan->f278_resetDataToStartGame();
_g301_gameTimeTicking = true;
Expand Down
36 changes: 30 additions & 6 deletions engines/dm/gfx.cpp
Expand Up @@ -728,6 +728,10 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {

for (uint16 i = 0; i < 32; i++)
_g345_aui_BlankBuffer[i] = 0;

// HACK
memcpy(_g346_paletteMiddleScreen, g20_PalEntrance, sizeof(uint16) * 16);
memcpy(_g347_paletteTopAndBottomScreen, g20_PalEntrance, sizeof(uint16) * 16);
}

DisplayMan::~DisplayMan() {
Expand Down Expand Up @@ -1210,7 +1214,13 @@ byte* DisplayMan::f114_getExplosionBitmap(uint16 explosionAspIndex, uint16 scale


void DisplayMan::updateScreen() {
// apply copper
warning(false, "Top of the screen color is offset as well"); // loop should start from 320 * 30
for (uint32 i = 0; i < 320 * 170; ++i)
_g348_bitmapScreen[i] += 16;
_vm->_system->copyRectToScreen(_g348_bitmapScreen, _screenWidth, 0, 0, _screenWidth, _screenHeight);
for (uint32 i = 0; i < 320 * 170; ++i) // loop should start from 320 * 30
_g348_bitmapScreen[i] -= 16;
_vm->_console->onFrame();
_vm->_system->updateScreen();
}
Expand Down Expand Up @@ -1719,7 +1729,7 @@ void DisplayMan::f119_drawSquareD2L(Direction dir, int16 posX, int16 posY) {
goto T0119020;
case k2_ElementTypePit:
f104_drawFloorPitOrStairsBitmap(squareAspect[k2_PitInvisibleAspect] ? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice,
g143_FrameFloorPit_D2L);
g143_FrameFloorPit_D2L);
case k5_ElementTypeTeleporter:
case k1_CorridorElemType:
T0119018:
Expand Down Expand Up @@ -1786,7 +1796,7 @@ void DisplayMan::f120_drawSquareD2R(Direction dir, int16 posX, int16 posY) {
goto T0120029;
case k2_ElementTypePit:
f105_drawFloorPitOrStairsBitmapFlippedHorizontally(squareAspect[k2_PitInvisibleAspect]
? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
? k57_FloorPir_Invisible_D2L_GraphicIndice : k51_FloorPit_D2L_GraphicIndice, g145_FrameFloorPit_D2R);
case k5_ElementTypeTeleporter:
case k1_CorridorElemType:
T0120027:
Expand Down Expand Up @@ -2157,9 +2167,6 @@ void DisplayMan::f127_drawSquareD0C(Direction dir, int16 posX, int16 posY) {
}

void DisplayMan::f128_drawDungeon(Direction dir, int16 posX, int16 posY) {
loadPalette(g20_PalEntrance); // dummy code


if (_g297_drawFloorAndCeilingRequested)
f98_drawFloorAndCeiling();
_g578_useByteBoxCoordinates = true;
Expand Down Expand Up @@ -2896,7 +2903,7 @@ void DisplayMan::f115_cthulhu(Thing thingParam, Direction directionParam, int16
byte* paletteChanges;
byte* bitmapGreenAnt;
byte* coordinateSet;
int16 derivedBitmapIndex = - 1;
int16 derivedBitmapIndex = -1;
bool L0135_B_DrawAlcoveObjects;
int16 byteWidth;
int16 heightRedEagle;
Expand Down Expand Up @@ -3675,4 +3682,21 @@ uint16 DisplayMan::f431_getDarkenedColor(uint16 RGBcolor) {
return RGBcolor;
}

void DisplayMan::f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) {
// memcpy(_g347_paletteTopAndBottomScreen, topAndBottom, sizeof(uint16) * 16);
// memcpy(_g346_paletteMiddleScreen, middleScreen, sizeof(uint16) * 16);
byte colorPalette[32 * 3];
for (int i = 0; i < 16; ++i) {
colorPalette[i * 3] = (topAndBottom[i] >> 8) * (256 / 16);
colorPalette[i * 3 + 1] = (topAndBottom[i] >> 4) * (256 / 16);
colorPalette[i * 3 + 2] = topAndBottom[i] * (256 / 16);
}
for (int i = 16; i < 32; ++i) {
colorPalette[i * 3] = (middleScreen[i] >> 8) * (256 / 16);
colorPalette[i * 3 + 1] = (middleScreen[i] >> 4) * (256 / 16);
colorPalette[i * 3 + 2] = middleScreen[i] * (256 / 16);
}
_vm->_system->getPaletteManager()->setPalette(colorPalette, 0, 32);
}

}
3 changes: 1 addition & 2 deletions engines/dm/gfx.h
Expand Up @@ -526,7 +526,6 @@ class DisplayMan {

DMEngine *_vm;

/// Related to graphics.dat file
uint16 _grapItemCount; // @ G0632_ui_GraphicCount
uint32 *_packedItemPos;
byte *_packedBitmaps;
Expand Down Expand Up @@ -751,7 +750,7 @@ class DisplayMan {
void f480_releaseBlock(uint16 index); // @ F0480_CACHE_ReleaseBlock
uint16 f431_getDarkenedColor(uint16 RGBcolor);
void f436_STARTEND_FadeToPalette(uint16 *P0849_pui_Palette) { warning(false, "STUB METHOD: f436_STARTEND_FadeToPalette"); }
void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom) { warning(false, "STUB METHOD: f508_buildPaletteChangeCopperList"); }// @ F0508_AMIGA_BuildPaletteChangeCopperList
void f508_buildPaletteChangeCopperList(uint16* middleScreen, uint16* topAndBottom);
void f136_shadeScreenBox(Box* box, Color color) { warning(false, "STUB METHOD: f136_shadeScreenBox"); } // @ F0136_VIDEO_ShadeScreenBox
};

Expand Down

0 comments on commit 94ba2fd

Please sign in to comment.