[Scummvm-git-logs] scummvm master -> 6c53442d4b02ca53d23b7719cfe2daa176890683
neuromancer
noreply at scummvm.org
Tue Feb 21 15:17:27 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5a52aa987f FREESCAPE: initial implementation of image parsing for title/borders in driller
e30bdac543 FREESCAPE: load title/borders images in driller dos directly from the game data
6c53442d4b FREESCAPE: load title/borders images in driller EGA directly from the game data
Commit: 5a52aa987ffaf5eaca05164ddb1a442de5fe5fe5
https://github.com/scummvm/scummvm/commit/5a52aa987ffaf5eaca05164ddb1a442de5fe5fe5
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-21T16:18:47+01:00
Commit Message:
FREESCAPE: initial implementation of image parsing for title/borders in driller
Changed paths:
engines/freescape/freescape.h
engines/freescape/games/driller.cpp
engines/freescape/loaders/8bitBinaryLoader.cpp
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 6772c476c23..9e876ddf56d 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -164,9 +164,13 @@ public:
void load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors);
Area *load8bitArea(Common::SeekableReadStream *file, uint16 ncolors);
Object *load8bitObject(Common::SeekableReadStream *file);
- void renderPixels8bitImage(Graphics::Surface *surface, int &i, int &j, int pixels);
+ void renderPixels8bitTitleImage(Graphics::Surface *surface, int &i, int &j, int pixels);
+ void renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, int pixels, int color);
+
uint32 getPixel8bitImage(int index);
- Graphics::Surface *load8bitImage(Common::SeekableReadStream *file, int ncolors, int offset);
+ Graphics::Surface *load8bitBinImage(Common::SeekableReadStream *file, int ncolors, int offset);
+ Graphics::Surface *load8bitTitleImage(Common::SeekableReadStream *file, int ncolors, int offset);
+
// Areas
uint16 _startArea;
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index b154dc77ee6..73cc894f7cb 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -663,7 +663,7 @@ void DrillerEngine::loadAssetsFullGame() {
_title->free();
delete _title;
file.open("CGATITLE.RL");
- _title = load8bitImage(&file, 4, 0x1b3);
+ _title = load8bitTitleImage(&file, 4, 0x1b3);
file.close();
file.open("DRILLC.EXE");
@@ -675,7 +675,7 @@ void DrillerEngine::loadAssetsFullGame() {
loadMessagesFixedSize(&file, 0x2585, 14, 20);
load8bitBinary(&file, 0x7bb0, 4);
loadGlobalObjects(&file, 0x1fa2);
- //_border = load8bitImage(&file, 4, 0x261);
+ _border = load8bitBinImage(&file, 4, 0x210);
} else
error("Invalid or unsupported render mode %s for Driller", Common::getRenderModeDescription(_renderMode));
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 7ae1b7cd240..33ac4291d90 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -308,14 +308,14 @@ byte kCGAPalettePinkBlueWhiteData[4][3] = {
uint32 FreescapeEngine::getPixel8bitImage(int index) {
uint8 r, g, b;
if (index < 4) {
- _gfx->readFromPalette(0, r, g, b);
+ _gfx->readFromPalette(index, r, g, b);
return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
}
_gfx->readFromPalette(index / 4, r, g, b);
return _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b);
}
-void FreescapeEngine::renderPixels8bitImage(Graphics::Surface *surface, int &i, int &j, int pixels) {
+void FreescapeEngine::renderPixels8bitTitleImage(Graphics::Surface *surface, int &i, int &j, int pixels) {
int c1 = pixels >> 4;
int c2 = pixels & 0xf;
@@ -323,7 +323,7 @@ void FreescapeEngine::renderPixels8bitImage(Graphics::Surface *surface, int &i,
return;
}
- surface->setPixel(i, j, getPixel8bitImage(c1));
+ surface->setPixel(i, j, getPixel8bitImage(c1 / 4));
i++;
if (i == 320) {
@@ -337,7 +337,7 @@ void FreescapeEngine::renderPixels8bitImage(Graphics::Surface *surface, int &i,
return;
}
- surface->setPixel(i, j, getPixel8bitImage(c2));
+ surface->setPixel(i, j, getPixel8bitImage(c2 / 4));
i++;
if (i == 320) {
@@ -348,7 +348,7 @@ void FreescapeEngine::renderPixels8bitImage(Graphics::Surface *surface, int &i,
i++;
}
-Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *file, int ncolors, int offset) {
+Graphics::Surface *FreescapeEngine::load8bitTitleImage(Common::SeekableReadStream *file, int ncolors, int offset) {
Graphics::Surface *surface = new Graphics::Surface();
assert(ncolors == 4);
_gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
@@ -390,7 +390,7 @@ Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *fi
singlePixelsToProcess--;
pixels = file->readByte();
//debug("reading pixels: %x at %d, %d", pixels, i, j);
- renderPixels8bitImage(surface, i, j, pixels);
+ renderPixels8bitTitleImage(surface, i, j, pixels);
} else if (repeatedPixelsToProcess) {
repetition = file->readByte() + 1;
//debug("reading repetition: %x", repetition - 1);
@@ -426,7 +426,7 @@ Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *fi
return surface;
//sdebug("repeating pixels: %x at %d, %d", pixels1, i, j);
- renderPixels8bitImage(surface, i, j, pixels1);
+ renderPixels8bitTitleImage(surface, i, j, pixels1);
if (i == 320) {
j++;
@@ -437,7 +437,7 @@ Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *fi
return surface;
//debug("repeating pixels: %x at %d, %d", pixels2, i, j);
- renderPixels8bitImage(surface, i, j, pixels2);
+ renderPixels8bitTitleImage(surface, i, j, pixels2);
}
}
}
@@ -446,6 +446,104 @@ Graphics::Surface *FreescapeEngine::load8bitImage(Common::SeekableReadStream *fi
return surface;
}
+void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, int pixels, int color) {
+ if (i >= 320) {
+ //debug("cannot continue, stopping here at row %d!", j);
+ return;
+ }
+
+ int acc = 1 << 7;
+ while (acc > 0) {
+ assert(i < 320);
+ if (acc & pixels)
+ surface->setPixel(i, j, getPixel8bitImage(color));
+ i++;
+ acc = acc >> 1;
+ }
+
+}
+
+Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream *file, int ncolors, int offset) {
+ Graphics::Surface *surface = new Graphics::Surface();
+ assert(ncolors == 4);
+ _gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
+ surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
+ uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
+ surface->fillRect(Common::Rect(0, 0, 320, 200), black);
+
+ file->seek(offset);
+ int imageSize = file->readUint16BE();
+
+ int i = 0;
+ int j = 0;
+ int hPixelsWritten = 0;
+ int color = 1;
+ int command = 0;
+ while (file->pos() <= offset + imageSize) {
+ debug("pos: %lx", file->pos());
+ command = file->readByte();
+
+ color = hPixelsWritten < 320 ? 1 : 2;
+ //debug("command: %x with j: %d", command, j);
+ if (j >= 200)
+ return surface;
+
+ if (command <= 0x7f) {
+ //debug("starting singles at i: %d j: %d", i, j);
+ int start = i;
+ while (command-- >= 0) {
+ int pixels = file->readByte();
+ //debug("single pixels command: %d with pixels: %x", command, pixels);
+ renderPixels8bitBinImage(surface, i, j, pixels, color);
+ }
+ hPixelsWritten = hPixelsWritten + i - start;
+ } else if (command <= 0xff && command >= 0xf0) {
+ int size = 136 - 8*(command - 0xf0);
+ int start = i;
+ int pixels = file->readByte();
+ //debug("starting 0xfX: at i: %d j: %d with pixels: %x", i, j, pixels);
+ while (size > 0) {
+ renderPixels8bitBinImage(surface, i, j, pixels, color);
+ size = size - 8;
+ }
+ hPixelsWritten = hPixelsWritten + i - start;
+ assert(i <= 320);
+ } else if (command <= 0xef && command >= 0xe0) {
+ int size = 264 - 8*(command - 0xe0);
+ int start = i;
+ int pixels = file->readByte();
+ //debug("starting 0xeX: at i: %d j: %d with pixels: %x", i, j, pixels);
+ while (size > 0) {
+ renderPixels8bitBinImage(surface, i, j, pixels, color);
+ size = size - 8;
+ }
+ hPixelsWritten = hPixelsWritten + i - start;
+ } else if (command <= 0xdf && command >= 0xd0) {
+ int size = 272 + 8*(0xdf - command);
+ int start = i;
+ int pixels = file->readByte();
+ while (size > 0) {
+ renderPixels8bitBinImage(surface, i, j, pixels, color);
+ size = size - 8;
+ }
+ hPixelsWritten = hPixelsWritten + i - start;
+ } else {
+ error("unknown command: %x", command);
+ }
+
+ if (i >= 320) {
+ i = 0;
+ if (hPixelsWritten >= 640) {
+ j++;
+ hPixelsWritten = 0;
+ }
+ }
+
+
+ }
+ return surface;
+}
+
Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 ncolors) {
Common::String name;
Commit: e30bdac54358954240e81dfacfc1d1cfe8fbfe91
https://github.com/scummvm/scummvm/commit/e30bdac54358954240e81dfacfc1d1cfe8fbfe91
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-21T16:18:47+01:00
Commit Message:
FREESCAPE: load title/borders images in driller dos directly from the game data
Changed paths:
engines/freescape/games/driller.cpp
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index 73cc894f7cb..c68f09aa60c 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -659,12 +659,15 @@ void DrillerEngine::loadAssetsFullGame() {
load8bitBinary(&file, 0x9b40, 16);
} else if (_renderMode == Common::kRenderCGA) {
- loadBundledImages();
- _title->free();
- delete _title;
+ file.open("SCN1C.DAT");
+ if (file.isOpen()) {
+ _title = load8bitBinImage(&file, 4, 0x0);
+ }
+ file.close();
file.open("CGATITLE.RL");
- _title = load8bitTitleImage(&file, 4, 0x1b3);
-
+ if (file.isOpen()) {
+ _title = load8bitTitleImage(&file, 4, 0x1b3);
+ }
file.close();
file.open("DRILLC.EXE");
Commit: 6c53442d4b02ca53d23b7719cfe2daa176890683
https://github.com/scummvm/scummvm/commit/6c53442d4b02ca53d23b7719cfe2daa176890683
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-02-21T16:18:47+01:00
Commit Message:
FREESCAPE: load title/borders images in driller EGA directly from the game data
Changed paths:
engines/freescape/freescape.h
engines/freescape/games/driller.cpp
engines/freescape/loaders/8bitBinaryLoader.cpp
diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 9e876ddf56d..1e177654887 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -165,11 +165,14 @@ public:
Area *load8bitArea(Common::SeekableReadStream *file, uint16 ncolors);
Object *load8bitObject(Common::SeekableReadStream *file);
void renderPixels8bitTitleImage(Graphics::Surface *surface, int &i, int &j, int pixels);
- void renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, int pixels, int color);
+ void renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
+
+ void renderPixels8bitBinCGAImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
+ void renderPixels8bitBinEGAImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color);
uint32 getPixel8bitImage(int index);
- Graphics::Surface *load8bitBinImage(Common::SeekableReadStream *file, int ncolors, int offset);
- Graphics::Surface *load8bitTitleImage(Common::SeekableReadStream *file, int ncolors, int offset);
+ Graphics::Surface *load8bitBinImage(Common::SeekableReadStream *file, int offset);
+ Graphics::Surface *load8bitTitleImage(Common::SeekableReadStream *file, int offset);
// Areas
diff --git a/engines/freescape/games/driller.cpp b/engines/freescape/games/driller.cpp
index c68f09aa60c..902000f563d 100644
--- a/engines/freescape/games/driller.cpp
+++ b/engines/freescape/games/driller.cpp
@@ -647,7 +647,11 @@ void DrillerEngine::loadAssetsFullGame() {
loadGlobalObjects(&file, 0x1855 - 0x400);
}
} else if (_renderMode == Common::kRenderEGA) {
- loadBundledImages();
+ file.open("SCN1E.DAT");
+ if (file.isOpen()) {
+ _title = load8bitBinImage(&file, 0x0);
+ }
+ file.close();
file.open("DRILLE.EXE");
if (!file.isOpen())
@@ -657,16 +661,16 @@ void DrillerEngine::loadAssetsFullGame() {
loadFonts(&file, 0x99dd);
loadGlobalObjects(&file, 0x3b42);
load8bitBinary(&file, 0x9b40, 16);
-
+ _border = load8bitBinImage(&file, 0x210);
} else if (_renderMode == Common::kRenderCGA) {
file.open("SCN1C.DAT");
if (file.isOpen()) {
- _title = load8bitBinImage(&file, 4, 0x0);
+ _title = load8bitBinImage(&file, 0x0);
}
file.close();
file.open("CGATITLE.RL");
if (file.isOpen()) {
- _title = load8bitTitleImage(&file, 4, 0x1b3);
+ _title = load8bitTitleImage(&file, 0x1b3);
}
file.close();
file.open("DRILLC.EXE");
@@ -678,7 +682,7 @@ void DrillerEngine::loadAssetsFullGame() {
loadMessagesFixedSize(&file, 0x2585, 14, 20);
load8bitBinary(&file, 0x7bb0, 4);
loadGlobalObjects(&file, 0x1fa2);
- _border = load8bitBinImage(&file, 4, 0x210);
+ _border = load8bitBinImage(&file, 0x210);
} else
error("Invalid or unsupported render mode %s for Driller", Common::getRenderModeDescription(_renderMode));
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index 33ac4291d90..1f29750bbff 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -305,6 +305,24 @@ byte kCGAPalettePinkBlueWhiteData[4][3] = {
{0xff, 0xff, 0xff},
};
+byte kEGADefaultPaletteData[16][3] = {
+ {0x00, 0x00, 0x00},
+ {0x00, 0x00, 0xaa},
+ {0x00, 0xaa, 0x00},
+ {0xaa, 0x00, 0x00},
+ {0xaa, 0x00, 0xaa},
+ {0xaa, 0x55, 0x00},
+ {0x55, 0xff, 0x55},
+ {0xff, 0x55, 0x55},
+ {0x12, 0x34, 0x56},
+ {0xff, 0xff, 0x55},
+ {0xff, 0xff, 0xff},
+ {0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00}
+};
+
uint32 FreescapeEngine::getPixel8bitImage(int index) {
uint8 r, g, b;
if (index < 4) {
@@ -348,9 +366,9 @@ void FreescapeEngine::renderPixels8bitTitleImage(Graphics::Surface *surface, int
i++;
}
-Graphics::Surface *FreescapeEngine::load8bitTitleImage(Common::SeekableReadStream *file, int ncolors, int offset) {
+Graphics::Surface *FreescapeEngine::load8bitTitleImage(Common::SeekableReadStream *file, int offset) {
Graphics::Surface *surface = new Graphics::Surface();
- assert(ncolors == 4);
+ assert(_renderMode == Common::kRenderCGA);
_gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
@@ -446,7 +464,7 @@ Graphics::Surface *FreescapeEngine::load8bitTitleImage(Common::SeekableReadStrea
return surface;
}
-void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, int pixels, int color) {
+void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &i, int &j, uint8 pixels, int color) {
if (i >= 320) {
//debug("cannot continue, stopping here at row %d!", j);
return;
@@ -455,18 +473,30 @@ void FreescapeEngine::renderPixels8bitBinImage(Graphics::Surface *surface, int &
int acc = 1 << 7;
while (acc > 0) {
assert(i < 320);
- if (acc & pixels)
- surface->setPixel(i, j, getPixel8bitImage(color));
+ if (acc & pixels) {
+ uint8 r, g, b;
+ uint32 previousPixel = surface->getPixel(i, j);
+ _gfx->_currentPixelFormat.colorToRGB(previousPixel, r, g, b);
+ int previousColor = _gfx->indexFromColor(r, g, b);
+ //debug("index: %d", previousColor + color);
+ _gfx->readFromPalette(previousColor + color, r, g, b);
+ surface->setPixel(i, j, _gfx->_currentPixelFormat.ARGBToColor(0xFF, r, g, b));
+ }
i++;
acc = acc >> 1;
}
}
-Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream *file, int ncolors, int offset) {
+Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream *file, int offset) {
Graphics::Surface *surface = new Graphics::Surface();
- assert(ncolors == 4);
- _gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
+ if (_renderMode == Common::kRenderCGA)
+ _gfx->_palette = (byte *)kCGAPalettePinkBlueWhiteData;
+ else if (_renderMode == Common::kRenderEGA)
+ _gfx->_palette = (byte *)kEGADefaultPaletteData;
+ else
+ error("Invalid render mode: %d", _renderMode);
+
surface->create(_screenW, _screenH, _gfx->_currentPixelFormat);
uint32 black = _gfx->_currentPixelFormat.ARGBToColor(0xFF, 0, 0, 0);
surface->fillRect(Common::Rect(0, 0, 320, 200), black);
@@ -480,10 +510,10 @@ Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream
int color = 1;
int command = 0;
while (file->pos() <= offset + imageSize) {
- debug("pos: %lx", file->pos());
+ //debug("pos: %lx", file->pos());
command = file->readByte();
- color = hPixelsWritten < 320 ? 1 : 2;
+ color = 1 + hPixelsWritten / 320;
//debug("command: %x with j: %d", command, j);
if (j >= 200)
return surface;
@@ -498,33 +528,33 @@ Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream
}
hPixelsWritten = hPixelsWritten + i - start;
} else if (command <= 0xff && command >= 0xf0) {
- int size = 136 - 8*(command - 0xf0);
+ int size = (136 - 8*(command - 0xf0)) / 2;
int start = i;
int pixels = file->readByte();
//debug("starting 0xfX: at i: %d j: %d with pixels: %x", i, j, pixels);
while (size > 0) {
renderPixels8bitBinImage(surface, i, j, pixels, color);
- size = size - 8;
+ size = size - 4;
}
hPixelsWritten = hPixelsWritten + i - start;
assert(i <= 320);
} else if (command <= 0xef && command >= 0xe0) {
- int size = 264 - 8*(command - 0xe0);
+ int size = (264 - 8*(command - 0xe0)) / 2;
int start = i;
int pixels = file->readByte();
//debug("starting 0xeX: at i: %d j: %d with pixels: %x", i, j, pixels);
while (size > 0) {
renderPixels8bitBinImage(surface, i, j, pixels, color);
- size = size - 8;
+ size = size - 4;
}
hPixelsWritten = hPixelsWritten + i - start;
} else if (command <= 0xdf && command >= 0xd0) {
- int size = 272 + 8*(0xdf - command);
+ int size = (272 + 8*(0xdf - command)) / 2;
int start = i;
int pixels = file->readByte();
while (size > 0) {
renderPixels8bitBinImage(surface, i, j, pixels, color);
- size = size - 8;
+ size = size - 4;
}
hPixelsWritten = hPixelsWritten + i - start;
} else {
@@ -533,7 +563,7 @@ Graphics::Surface *FreescapeEngine::load8bitBinImage(Common::SeekableReadStream
if (i >= 320) {
i = 0;
- if (hPixelsWritten >= 640) {
+ if (hPixelsWritten >= (_renderMode == Common::kRenderCGA ? 640 : 1280)) {
j++;
hPixelsWritten = 0;
}
More information about the Scummvm-git-logs
mailing list