Skip to content

Commit

Permalink
DM: Refactor DisplayMan::DrawFrame and Frame POD
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterGrascph committed Aug 26, 2016
1 parent cb2bb82 commit 18ff2e9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions engines/dm/dm.cpp
Expand Up @@ -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];
Expand All @@ -68,8 +68,8 @@ Common::Error DMEngine::run() {
delete[] cleanByteImg0Data;
*/


while (true) {
_displayMan->clearScreen(colorBlack);
_displayMan->drawDungeon();
_displayMan->updateScreen();
_system->delayMillis(10);
Expand Down
25 changes: 16 additions & 9 deletions engines/dm/gfx.cpp
Expand Up @@ -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};

}

Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
6 changes: 4 additions & 2 deletions engines/dm/gfx.h
Expand Up @@ -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();
Expand All @@ -72,10 +73,11 @@ class DisplayMan {
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);
};

}
Expand Down

0 comments on commit 18ff2e9

Please sign in to comment.