diff options
author | WinterGrascph | 2016-05-05 19:49:26 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 18ff2e9940f584041798af670a07c381a02918aa (patch) | |
tree | cf072b8c20ffa9399973ce14d6852b7bc5f1647f | |
parent | cb2bb82b32ade022eb626c6b8cc580abc5b9df8d (diff) | |
download | scummvm-rg350-18ff2e9940f584041798af670a07c381a02918aa.tar.gz scummvm-rg350-18ff2e9940f584041798af670a07c381a02918aa.tar.bz2 scummvm-rg350-18ff2e9940f584041798af670a07c381a02918aa.zip |
DM: Refactor DisplayMan::DrawFrame and Frame POD
-rw-r--r-- | engines/dm/dm.cpp | 4 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 25 | ||||
-rw-r--r-- | engines/dm/gfx.h | 6 |
3 files changed, 22 insertions, 13 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index e30aaced2c..1909b7e84e 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -57,9 +57,9 @@ Common::Error DMEngine::run() { _displayMan->loadGraphics(); _dungeonMan->loadDungeonFile(); - /* _displayMan->loadPalette(palCredits); + /* uint16 width = _displayMan->getImageWidth(1); uint16 height = _displayMan->getImageHeight(1); byte *cleanByteImg0Data = new byte[width * height]; @@ -68,8 +68,8 @@ Common::Error DMEngine::run() { delete[] cleanByteImg0Data; */ - while (true) { + _displayMan->clearScreen(colorBlack); _displayMan->drawDungeon(); _displayMan->updateScreen(); _system->delayMillis(10); diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index e3faf945f8..f441214b82 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -29,16 +29,15 @@ enum GraphicIndice { }; struct Frame { - /* this might have to be removed, depends on if the game uses frames with multiple bitmaps - If so, then GraphIndice enum will have to be moved to be available from outside gfx.cpp*/ - GraphicIndice graphIndice; // srcWidth and srcHeight (present in the original sources) is redundant here, can be deduced from gaphicsIndice + // these coorinates are inclusive boundaries, when blitting you gotta add +1 to srcTo fields uint16 srcFromX, srcToX, srcFromY, srcToY; + uint16 srcWidth, srcHeight; uint16 destX, destY; - Color transparent; }; -Frame ceilingFrame = {CeilingGraphIndice, 0, 223, 0, 28, 0, 0, colorFlesh}; +Frame ceilingFrame = {0, 223, 0, 28, 224, 29, 0, 0}; +Frame floorFrame = {0, 223, 66, 135, 224, 70, 0, 0}; } @@ -61,7 +60,7 @@ void DisplayMan::setUpScreens(uint16 width, uint16 height) { _screenHeight = height; loadPalette(palSwoosh); _vgaBuffer = new byte[_screenWidth * _screenHeight]; - memset(_vgaBuffer, 0, width * height); + clearScreen(colorBlack); } void DisplayMan::loadGraphics() { @@ -205,11 +204,19 @@ uint16 DisplayMan::getImageHeight(uint16 index) { return TOBE2(data[2], data[3]); } -void DisplayMan::drawFrame(Frame &f) { - blitToScreen(_unpackedBitmaps[f.graphIndice], f.srcFromX, f.srcToX, f.srcFromY, f.srcToY, getImageWidth(f.graphIndice), f.destX, f.destY, f.transparent); +void DisplayMan::drawFrameToScreen(byte *bitmap, Frame &f, Color transparent) { + blitToScreen(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, transparent); +} + +void DisplayMan::drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth) { + blitToBitmap(bitmap, f.srcFromX, f.srcToX + 1, f.srcFromY, f.srcToY + 1, f.srcWidth, f.destX, f.destY, destBitmap, destWidth, transparent); } void DisplayMan::drawDungeon() { loadPalette(palDungeonView0); - drawFrame(ceilingFrame); + drawFrameToScreen(_unpackedBitmaps[CeilingGraphIndice], ceilingFrame, colorFlesh); +} + +void DisplayMan::clearScreen(Color color) { + memset(getCurrentVgaBuffer(), color, sizeof(byte) * _screenWidth * _screenHeight); }
\ No newline at end of file diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 3ecffb1aba..e479c6cfc4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -58,7 +58,8 @@ class DisplayMan { byte **_unpackedBitmaps; void unpackGraphics(); - void drawFrame(Frame &f); + inline void drawFrameToScreen(byte *bitmap, Frame &f, Color transparent); + inline void drawFrameToBitMap(byte *bitmap, Frame &f, Color transparent, byte *destBitmap, uint16 destWidth); public: DisplayMan(DMEngine *dmEngine); ~DisplayMan(); @@ -72,10 +73,11 @@ public: void DisplayMan::blitToBitmap(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, int16 srcWidth, uint16 destX, uint16 destY, byte *destBitmap, uint16 destWidth, Color transparent = colorNoTransparency); inline void DisplayMan::blitToScreen(byte *srcBitmap, uint16 srcFromX, uint16 srcToX, uint16 srcFromY, uint16 srcToY, - int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); + int16 srcWidth, uint16 destX, uint16 destY, Color transparent = colorNoTransparency); byte *getCurrentVgaBuffer(); void updateScreen(); void drawDungeon(); + void clearScreen(Color color); }; } |