[Scummvm-git-logs] scummvm master -> 0e8d774df725168a94b7eb5917a7c2716d82bec6
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Tue Aug 4 02:54:31 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0e8d774df7 ULTIMA8: Implement GameMapGump::dumpMap debugger command
Commit: 0e8d774df725168a94b7eb5917a7c2716d82bec6
https://github.com/scummvm/scummvm/commit/0e8d774df725168a94b7eb5917a7c2716d82bec6
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2020-08-03T21:53:39-05:00
Commit Message:
ULTIMA8: Implement GameMapGump::dumpMap debugger command
Changed paths:
engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
engines/ultima/ultima8/misc/debugger.cpp
diff --git a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
index 46a5a33d0c..8a16a95109 100644
--- a/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
+++ b/engines/ultima/ultima8/graphics/base_soft_render_surface.cpp
@@ -221,6 +221,7 @@ BaseSoftRenderSurface::BaseSoftRenderSurface(int w, int h) :
_rttTex->w = _width;
_rttTex->h = _height;
_rttTex->_format = TEX_FMT_NATIVE;
+ _rttTex->format = RenderSurface::getPixelFormat();
_rttTex->pitch = _pitch;
_rttTex->CalcLOG2s();
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 0c4f611105..70dd789030 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "image/png.h"
+#include "image/bmp.h"
#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/ultima8.h"
#include "ultima/ultima8/audio/audio_process.h"
@@ -42,6 +44,7 @@
#include "ultima/ultima8/misc/util.h"
#include "ultima/ultima8/usecode/uc_machine.h"
#include "ultima/ultima8/usecode/bit_set.h"
+#include "ultima/ultima8/world/camera_process.h"
#include "ultima/ultima8/world/world.h"
#include "ultima/ultima8/world/camera_process.h"
#include "ultima/ultima8/world/get_object.h"
@@ -735,14 +738,13 @@ bool Debugger::cmdToggleHighlightItems(int argc, const char **argv) {
}
bool Debugger::cmdDumpMap(int argc, const char **argv) {
-#ifdef TODO
- // We only support 32 bits per pixel for now
- if (RenderSurface::_format.s_bpp != 32) return;
-
// Save because we're going to potentially break the game by enlarging
// the fast area and available object IDs.
- Std::string savefile = "@save/dumpmap";
- Ultima8Engine::get_instance()->saveGame(savefile, "Pre-dumpMap save");
+ int slot = Ultima8Engine::get_instance()->getAutosaveSlot();
+ if (!Ultima8Engine::get_instance()->saveGame(slot, "Pre-dumpMap save")) {
+ debugPrintf("Could not dump map: pre-dumpMap save failed\n");
+ return false;
+ }
// Increase number of available object IDs.
ObjectManager::get_instance()->allow64kObjects();
@@ -786,7 +788,9 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
}
}
- if (right == -16384) return;
+ if (right == -16384) {
+ return false;
+ }
// camera height
bot += camheight;
@@ -800,41 +804,33 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
// Buffer Size
int32 bwidth = awidth;
- int32 bheight = 256;
+ //int32 bheight = 256;
+
+ // Original version of this command wrote the image out in rows to save memory
+ // This version can only write out a full texture
+ int32 bheight = aheight;
// Tile size
int32 twidth = bwidth / 8;
- int32 theight = bheight;
-
+ int32 theight = 256;
- Debugger *g = new Debugger(0, 0, twidth, theight);
+ GameMapGump *g = new GameMapGump(0, 0, twidth, theight);
// HACK: Setting both INVISIBLE and TRANSPARENT flags on the Avatar
// will make him completely invisible.
getMainActor()->setFlag(Item::FLG_INVISIBLE);
getMainActor()->setExtFlag(Item::EXT_TRANSPARENT);
- World::get_instance()->getCurrentMap()->setWholeMapFast();
+
+ CurrentMap *currentMap = World::get_instance()->getCurrentMap();
+ currentMap->setWholeMapFast();
RenderSurface *s = RenderSurface::CreateSecondaryRenderSurface(bwidth,
bheight);
- Texture *t = s->GetSurfaceAsTexture();
- // clear buffer
- Std::memset(t->buffer, 0, 4 * bwidth * bheight);
-
- // Write tga header
- Std::string filename = "@home/mapdump";
- char buf[32];
- sprintf(buf, "%02d", World::get_instance()->getCurrentMap()->getNum());
- filename += buf;
- filename += ".png";
- Common::WriteStream *ws = FileSystem::get_instance()->WriteFile(filename);
- Std::string pngcomment = "Map ";
- pngcomment += buf;
- pngcomment += ", dumped by Pentagram.";
+ Texture *t = s->GetSurfaceAsTexture();
+ //t->clear();
- PNGWriter *pngw = new PNGWriter(ws);
- pngw->init(awidth, aheight, pngcomment);
+ debugPrintf("Rendering map...\n");
// Now render the map
for (int32 y = 0; y < aheight; y += theight) {
@@ -846,45 +842,58 @@ bool Debugger::cmdDumpMap(int argc, const char **argv) {
int32 wy = ey * 4 - ex * 2;
s->SetOrigin(x, y % bheight);
- CameraProcess::SetCameraProcess(
- new CameraProcess(wx + 4 * camheight, wy + 4 * camheight, camheight));
+ CameraProcess::SetCameraProcess(new CameraProcess(wx + 4 * camheight, wy + 4 * camheight, camheight));
g->Paint(s, 256, false);
}
// Write out the current buffer
- if (((y + theight) % bheight) == 0) {
- for (int i = 0; i < bwidth * bheight; ++i) {
- // Convert to correct pixel format
- uint8 r, g, b;
- UNPACK_RGB8(t->buffer[i], r, g, b);
- uint8 *buf = reinterpret_cast<uint8 *>(&t->buffer[i]);
- buf[0] = b;
- buf[1] = g;
- buf[2] = r;
- buf[3] = 0xFF;
- }
-
- pngw->writeRows(bheight, t);
+ //if (((y + theight) % bheight) == 0) {
+ // for (int i = 0; i < bwidth * bheight; ++i) {
+ // // Convert to correct pixel format
+ // uint8 r, g, b;
+ // UNPACK_RGB8(t->buffer[i], r, g, b);
+ // uint8 *buf = reinterpret_cast<uint8 *>(&t->buffer[i]);
+ // buf[0] = b;
+ // buf[1] = g;
+ // buf[2] = r;
+ // buf[3] = 0xFF;
+ // }
+
+ // pngw->writeRows(bheight, t);
+
+ // // clear buffer for next set
+ // t->clear();
+ //}
+ }
+
+#ifdef USE_PNG
+ Std::string filename = Common::String::format("map_%02d.png", currentMap->getNum());
+#else
+ Std::string filename = Common::String::format("map_%02d.bmp", currentMap->getNum());
+#endif
- // clear buffer for next set
- Std::memset(t->buffer, 0, 4 * bwidth * bheight);
- }
+ Common::DumpFile dumpFile;
+ bool result = dumpFile.open(filename);
+ if (result) {
+#ifdef USE_PNG
+ result = Image::writePNG(dumpFile, *t);
+#else
+ result = Image::writeBMP(dumpFile, *t);
+#endif
}
- pngw->finish();
- delete pngw;
-
- delete ws;
+ if (result) {
+ debugPrintf("Map dumped: %s\n", filename.c_str());
+ } else {
+ debugPrintf("Could not write file: %s\n", filename.c_str());
+ }
delete g;
delete s;
// Reload
- Ultima8Engine::get_instance()->loadGame(savefile);
-
- debugPrintf("Map dumped\n");
-#endif
+ Ultima8Engine::get_instance()->loadGameState(slot);
return false;
}
More information about the Scummvm-git-logs
mailing list