[Scummvm-git-logs] scummvm master -> f7f20d415c7061e2369a7727a3a7c5f4686ea24d
neuromancer
noreply at scummvm.org
Mon Oct 7 14:36:52 UTC 2024
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
35ed846d72 FREESCAPE: simplified 8 bit title image loading for Space Station Oblivion
3945333766 FREESCAPE: Replaced i,j with x,y in loading Space Station Oblivion title image
ca74a362a7 FREESCAPE: Further simplification of Space Station Oblivion title loading
f7f20d415c Added spaces to comments as requested by bluegr.
Commit: 35ed846d72fae5288e96843a4a7f0211128c3443
https://github.com/scummvm/scummvm/commit/35ed846d72fae5288e96843a4a7f0211128c3443
Author: Steven Don (shd at earthling.net)
Date: 2024-10-07T16:36:47+02:00
Commit Message:
FREESCAPE: simplified 8 bit title image loading for Space Station Oblivion
The processing in DrillerEngine::load8bitTitleImage was rather overcomplicated,
had a few potential off-by-one errors and had superfluous checks instead of
checking for the end-of-line marker. This commit greatly simplifies the
decoding.
Although I've not touched that aspect, I would have preferred the use x,y
instead of i,j for coordinates, and using a for loop rather than a while
countdown.
Changed paths:
engines/freescape/games/driller/dos.cpp
diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index 6b64a0112aa..1e545fe9003 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -155,86 +155,39 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
int i = 0;
int j = 0;
- int command = -1;
- int singlePixelsToProcess = 0;
- bool repeatedPixelsToProcess = false;
file->seek(offset);
while (!file->eos()) {
- assert(i <= 320);
- int pixels = -1;
- int repetition = -1;
-
- if (singlePixelsToProcess == 0 && !repeatedPixelsToProcess) {
- if (command < 0)
- command = file->readByte();
-
- //debug("reading command: %x at %lx", command, file->pos() - 1);
-
- assert(command >= 0x7f);
- singlePixelsToProcess = (0xff - command + 2) * 2;
- //debug("single Pixels to process: %d", singlePixelsToProcess);
-
- repeatedPixelsToProcess = true;
- if (i == 320) {
- j++;
- i = 0;
- }
- command = -1;
- continue;
- }
-
- if (singlePixelsToProcess > 0) {
- singlePixelsToProcess--;
- pixels = file->readByte();
- //debug("reading pixels: %x at %d, %d", pixels, i, j);
- renderPixels8bitTitleImage(surface, i, j, pixels);
- } else if (repeatedPixelsToProcess) {
- repetition = file->readByte() + 1;
- //debug("reading repetition: %x", repetition - 1);
- assert(repetition > 0);
- if (repetition >= 0x80) {
- command = repetition - 1;
- repeatedPixelsToProcess = false;
- continue;
- }
-
- if (i == 320) {
- j++;
- i = 0;
- continue;
+ int command = file->readByte();
+ if (command & 0x80) {
+ //Copy N bytes verbatim
+ int repeat = (0xFF - command + 2) * 2;
+ while (repeat--) {
+ int pixels = file->readByte();
+ renderPixels8bitTitleImage(surface, i, j, pixels);
+ if (i == 320) {
+ i = 0;
+ j++;
+ if (j == 200)
+ return surface;
+ int eol = file->readByte();
+ assert(eol == 2);
+ }
}
-
+ } else {
+ //Repeat 2 bytes of the input N times
+ int repeat = command + 1;
int pixels1 = file->readByte();
- //debug("reading pixels: %x", pixels1);
-
int pixels2 = file->readByte();
- //debug("reading pixels: %x", pixels2);
-
- if (repetition >= 1) {
- while (repetition > 0) {
- repetition--;
-
- if (i == 320) {
- j++;
- i = 0;
- }
-
+ while (repeat--) {
+ renderPixels8bitTitleImage(surface, i, j, pixels1);
+ renderPixels8bitTitleImage(surface, i, j, pixels2);
+ if (i == 320) {
+ i = 0;
+ j++;
if (j == 200)
return surface;
-
- //sdebug("repeating pixels: %x at %d, %d", pixels1, i, j);
- renderPixels8bitTitleImage(surface, i, j, pixels1);
-
- if (i == 320) {
- j++;
- i = 0;
- }
-
- if (j == 200)
- return surface;
-
- //debug("repeating pixels: %x at %d, %d", pixels2, i, j);
- renderPixels8bitTitleImage(surface, i, j, pixels2);
+ int eol = file->readByte();
+ assert(eol == 2);
}
}
}
Commit: 3945333766fab859e825ce2fd289a463d2c4a549
https://github.com/scummvm/scummvm/commit/3945333766fab859e825ce2fd289a463d2c4a549
Author: Steven Don (shd at earthling.net)
Date: 2024-10-07T16:36:47+02:00
Commit Message:
FREESCAPE: Replaced i,j with x,y in loading Space Station Oblivion title image
Changed paths:
engines/freescape/games/driller/dos.cpp
diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index 1e545fe9003..fbed32af6d2 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -112,40 +112,40 @@ uint32 DrillerEngine::getPixel8bitTitleImage(int index) {
return index / 4;
}
-void DrillerEngine::renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &i, int &j, int pixels) {
+void DrillerEngine::renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &x, int &y, int pixels) {
int c1 = pixels >> 4;
int c2 = pixels & 0xf;
- if (i == 320) {
+ if (x == 320) {
return;
}
if (_renderMode == Common::kRenderCGA) {
- surface->setPixel(i, j, getPixel8bitTitleImage(c1 / 4));
- i++;
- if (i == 320) {
+ surface->setPixel(x, y, getPixel8bitTitleImage(c1 / 4));
+ x++;
+ if (x == 320) {
return;
}
}
- surface->setPixel(i, j, getPixel8bitTitleImage(c1));
- i++;
+ surface->setPixel(x, y, getPixel8bitTitleImage(c1));
+ x++;
- if (i == 320) {
+ if (x == 320) {
return;
}
if (_renderMode == Common::kRenderCGA) {
- surface->setPixel(i, j, getPixel8bitTitleImage(c2 / 4));
- i++;
+ surface->setPixel(x, y, getPixel8bitTitleImage(c2 / 4));
+ x++;
- if (i == 320) {
+ if (x == 320) {
return;
}
}
- surface->setPixel(i, j, getPixel8bitTitleImage(c2));
- i++;
+ surface->setPixel(x, y, getPixel8bitTitleImage(c2));
+ x++;
}
Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableReadStream *file, int offset) {
@@ -153,21 +153,21 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
surface->create(_screenW, _screenH, Graphics::PixelFormat::createFormatCLUT8());
surface->fillRect(Common::Rect(0, 0, 320, 200), 0);
- int i = 0;
- int j = 0;
+ int x = 0;
+ int y = 0;
file->seek(offset);
while (!file->eos()) {
int command = file->readByte();
if (command & 0x80) {
- //Copy N bytes verbatim
- int repeat = (0xFF - command + 2) * 2;
+ //Copy 2*N bytes verbatim
+ int repeat = (257 - command) * 2;
while (repeat--) {
int pixels = file->readByte();
- renderPixels8bitTitleImage(surface, i, j, pixels);
- if (i == 320) {
- i = 0;
- j++;
- if (j == 200)
+ renderPixels8bitTitleImage(surface, x, y, pixels);
+ if (x == 320) {
+ x = 0;
+ y++;
+ if (y == 200)
return surface;
int eol = file->readByte();
assert(eol == 2);
@@ -179,12 +179,12 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
int pixels1 = file->readByte();
int pixels2 = file->readByte();
while (repeat--) {
- renderPixels8bitTitleImage(surface, i, j, pixels1);
- renderPixels8bitTitleImage(surface, i, j, pixels2);
- if (i == 320) {
- i = 0;
- j++;
- if (j == 200)
+ renderPixels8bitTitleImage(surface, x, y, pixels1);
+ renderPixels8bitTitleImage(surface, x, y, pixels2);
+ if (x == 320) {
+ y = 0;
+ y++;
+ if (y == 200)
return surface;
int eol = file->readByte();
assert(eol == 2);
Commit: ca74a362a7cc45c2043c990c939235b8d91431b1
https://github.com/scummvm/scummvm/commit/ca74a362a7cc45c2043c990c939235b8d91431b1
Author: Steven Don (shd at earthling.net)
Date: 2024-10-07T16:36:47+02:00
Commit Message:
FREESCAPE: Further simplification of Space Station Oblivion title loading
Changed paths:
engines/freescape/games/driller/dos.cpp
diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index fbed32af6d2..032b95b1291 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -153,41 +153,33 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
surface->create(_screenW, _screenH, Graphics::PixelFormat::createFormatCLUT8());
surface->fillRect(Common::Rect(0, 0, 320, 200), 0);
- int x = 0;
- int y = 0;
file->seek(offset);
- while (!file->eos()) {
- int command = file->readByte();
- if (command & 0x80) {
- //Copy 2*N bytes verbatim
- int repeat = (257 - command) * 2;
- while (repeat--) {
- int pixels = file->readByte();
- renderPixels8bitTitleImage(surface, x, y, pixels);
- if (x == 320) {
- x = 0;
- y++;
- if (y == 200)
- return surface;
- int eol = file->readByte();
- assert(eol == 2);
+ for (int y = 0; y < 200; ++y) {
+ if (file->eos ()) break;
+
+ //Start of line data (0x02) or [premature] end of data (0x00)
+ int sol = file->readByte();
+ if (sol == 0) break;
+ assert(sol == 2);
+
+ int x = 0;
+ while (x < 320) {
+ int command = file->readByte();
+ if (command & 0x80) {
+ //Copy 2*N bytes verbatim
+ int repeat = (257 - command) * 2;
+ for (int i = 0; i < repeat; ++i) {
+ int pixels = file->readByte();
+ renderPixels8bitTitleImage(surface, x, y, pixels);
}
- }
- } else {
- //Repeat 2 bytes of the input N times
- int repeat = command + 1;
- int pixels1 = file->readByte();
- int pixels2 = file->readByte();
- while (repeat--) {
- renderPixels8bitTitleImage(surface, x, y, pixels1);
- renderPixels8bitTitleImage(surface, x, y, pixels2);
- if (x == 320) {
- y = 0;
- y++;
- if (y == 200)
- return surface;
- int eol = file->readByte();
- assert(eol == 2);
+ } else {
+ //Repeat 2 bytes of the input N times
+ int repeat = command + 1;
+ int pixels1 = file->readByte();
+ int pixels2 = file->readByte();
+ for (int i = 0; i < repeat; ++i) {
+ renderPixels8bitTitleImage(surface, x, y, pixels1);
+ renderPixels8bitTitleImage(surface, x, y, pixels2);
}
}
}
@@ -262,7 +254,7 @@ void DrillerEngine::loadAssetsDOSFullGame() {
file.close();
file.open("EGATITLE.RL");
if (file.isOpen()) {
- _title = load8bitTitleImage(&file, 0x1b3);
+ _title = load8bitTitleImage(&file, 0x1b2);
_title->setPalette((byte*)&kEGADefaultPalette, 0, 16);
}
file.close();
@@ -288,7 +280,7 @@ void DrillerEngine::loadAssetsDOSFullGame() {
file.close();
file.open("CGATITLE.RL");
if (file.isOpen()) {
- _title = load8bitTitleImage(&file, 0x1b3);
+ _title = load8bitTitleImage(&file, 0x1b2);
_title->setPalette((byte*)&kCGAPalettePinkBlueWhiteData, 0, 4);
}
file.close();
Commit: f7f20d415c7061e2369a7727a3a7c5f4686ea24d
https://github.com/scummvm/scummvm/commit/f7f20d415c7061e2369a7727a3a7c5f4686ea24d
Author: Steven Don (shd at earthling.net)
Date: 2024-10-07T16:36:47+02:00
Commit Message:
Added spaces to comments as requested by bluegr.
Changed paths:
engines/freescape/games/driller/dos.cpp
diff --git a/engines/freescape/games/driller/dos.cpp b/engines/freescape/games/driller/dos.cpp
index 032b95b1291..89899f3789e 100644
--- a/engines/freescape/games/driller/dos.cpp
+++ b/engines/freescape/games/driller/dos.cpp
@@ -157,7 +157,7 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
for (int y = 0; y < 200; ++y) {
if (file->eos ()) break;
- //Start of line data (0x02) or [premature] end of data (0x00)
+ // Start of line data (0x02) or [premature] end of data (0x00)
int sol = file->readByte();
if (sol == 0) break;
assert(sol == 2);
@@ -166,14 +166,14 @@ Graphics::ManagedSurface *DrillerEngine::load8bitTitleImage(Common::SeekableRead
while (x < 320) {
int command = file->readByte();
if (command & 0x80) {
- //Copy 2*N bytes verbatim
+ // Copy 2*N bytes verbatim
int repeat = (257 - command) * 2;
for (int i = 0; i < repeat; ++i) {
int pixels = file->readByte();
renderPixels8bitTitleImage(surface, x, y, pixels);
}
} else {
- //Repeat 2 bytes of the input N times
+ // Repeat 2 bytes of the input N times
int repeat = command + 1;
int pixels1 = file->readByte();
int pixels2 = file->readByte();
More information about the Scummvm-git-logs
mailing list