mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 00:42:24 +00:00
SAGA2: Add command to dump map
This commit is contained in:
parent
7d4d82e994
commit
3cd91d0a29
@ -20,10 +20,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/file.h"
|
||||
#include "graphics/palette.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "image/png.h"
|
||||
|
||||
#include "saga2/saga2.h"
|
||||
#include "saga2/objects.h"
|
||||
#include "saga2/player.h"
|
||||
#include "saga2/mapfeatr.h"
|
||||
#include "saga2/tile.h"
|
||||
|
||||
#include "saga2/console.h"
|
||||
|
||||
@ -33,6 +39,10 @@ namespace Saga2 {
|
||||
|
||||
extern pCMapFeature mapFeatures[];
|
||||
extern GameObject *objectList;
|
||||
extern WorldMapData *mapList;
|
||||
extern int16 currentMapNum;
|
||||
|
||||
void drawMetaTiles(gPixelMap &drawMap);
|
||||
|
||||
Console::Console(Saga2Engine *vm) : GUI::Debugger() {
|
||||
_vm = vm;
|
||||
@ -60,6 +70,8 @@ Console::Console(Saga2Engine *vm) : GUI::Debugger() {
|
||||
registerCmd("list_places", WRAP_METHOD(Console, cmdListPlaces));
|
||||
|
||||
registerCmd("stats", WRAP_METHOD(Console, cmdStats));
|
||||
|
||||
registerCmd("dump_map", WRAP_METHOD(Console, cmdDumpMap));
|
||||
}
|
||||
|
||||
Console::~Console() {
|
||||
@ -224,4 +236,36 @@ bool Console::cmdListPlaces(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Console::cmdDumpMap(int argc, const char **argv) {
|
||||
if (argc != 2)
|
||||
debugPrintf("Usage: %s <Map Size Multiplier>\n", argv[0]);
|
||||
else {
|
||||
gPixelMap drawMap;
|
||||
drawMap.size = _vm->_tileDrawMap.size * atoi(argv[1]);
|
||||
//drawMap.size.x = mapList[currentMapNum].mapHeight;
|
||||
//drawMap.size.y = mapList[currentMapNum].mapHeight;
|
||||
drawMap.data = new uint8[drawMap.bytes()]();
|
||||
drawMetaTiles(drawMap);
|
||||
|
||||
Graphics::Surface sur;
|
||||
sur.create(drawMap.size.x, drawMap.size.y, Graphics::PixelFormat::createFormatCLUT8());
|
||||
sur.setPixels(drawMap.data);
|
||||
|
||||
Common::String pngFile = Common::String::format("%s-mapdump.png", _vm->getMetaEngine()->getName());
|
||||
Common::DumpFile dump;
|
||||
dump.open(pngFile);
|
||||
|
||||
byte palette[256 * 3];
|
||||
g_system->getPaletteManager()->grabPalette(palette, 0, 256);
|
||||
|
||||
Image::writePNG(dump, sur, palette);
|
||||
|
||||
dump.close();
|
||||
|
||||
delete[] drawMap.data;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ private:
|
||||
bool cmdGotoPlace(int argc, const char **argv);
|
||||
|
||||
bool cmdListPlaces(int argc, const char **argv);
|
||||
|
||||
bool cmdDumpMap(int argc, const char **argv);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ void updateFrameCount(void);
|
||||
hResContext *tileRes; // tile resource handle
|
||||
|
||||
void drawPlatform(
|
||||
gPixelMap &drawMap,
|
||||
Platform **pList, // platforms to draw
|
||||
Point16 screenPos, // screen position
|
||||
int16 uOrg, // for TAG search
|
||||
@ -2482,7 +2483,7 @@ TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
|
||||
Map drawing functions
|
||||
* ============================================================================ */
|
||||
|
||||
inline void drawMetaRow(TilePoint coords, Point16 pos) {
|
||||
inline void drawMetaRow(gPixelMap &drawMap, TilePoint coords, Point16 pos) {
|
||||
WorldMapData *curMap = &mapList[currentMapNum];
|
||||
|
||||
int16 uOrg = coords.u * kPlatformWidth,
|
||||
@ -2500,7 +2501,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
|
||||
int16 layerLimit;
|
||||
|
||||
for (;
|
||||
pos.x < g_vm->_tileDrawMap.size.x + kMetaDX;
|
||||
pos.x < drawMap.size.x + kMetaDX;
|
||||
coords.u++,
|
||||
coords.v--,
|
||||
uOrg += kPlatformWidth,
|
||||
@ -2567,7 +2568,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
|
||||
p->highestPixel = kTileHeight * (kPlatformWidth - 1) + kMaxTileHeight * 2 + 64;
|
||||
|
||||
if (pos.y <= 0
|
||||
|| pos.y - p->highestPixel >= g_vm->_tileDrawMap.size.y)
|
||||
|| pos.y - p->highestPixel >= drawMap.size.y)
|
||||
continue;
|
||||
|
||||
*put++ = p;
|
||||
@ -2576,7 +2577,7 @@ inline void drawMetaRow(TilePoint coords, Point16 pos) {
|
||||
*put++ = nullptr;
|
||||
|
||||
if (drawList[0] != nullptr) {
|
||||
drawPlatform(drawList, pos, uOrg, vOrg);
|
||||
drawPlatform(drawMap, drawList, pos, uOrg, vOrg);
|
||||
}
|
||||
// gThread::yield();
|
||||
}
|
||||
@ -2758,7 +2759,7 @@ void buildRoofTable(void) {
|
||||
|
||||
// Draw all visible metatiles
|
||||
|
||||
inline void drawMetaTiles(void) {
|
||||
inline void drawMetaTiles(gPixelMap &drawMap) {
|
||||
Point32 viewPos;
|
||||
Point16 metaPos;
|
||||
TilePoint baseCoords;
|
||||
@ -2803,16 +2804,16 @@ inline void drawMetaTiles(void) {
|
||||
// (replace 256 constant with better value)
|
||||
|
||||
for (;
|
||||
metaPos.y < g_vm->_tileDrawMap.size.y + kMetaTileHeight * 4 ;
|
||||
metaPos.y < drawMap.size.y + kMetaTileHeight * 4 ;
|
||||
baseCoords.u--,
|
||||
baseCoords.v--
|
||||
) {
|
||||
drawMetaRow(baseCoords, metaPos);
|
||||
drawMetaRow(drawMap, baseCoords, metaPos);
|
||||
|
||||
metaPos.y += kMetaDY;
|
||||
metaPos.x -= kMetaDX;
|
||||
|
||||
drawMetaRow(TilePoint(baseCoords.u - 1, baseCoords.v, 0), metaPos);
|
||||
drawMetaRow(drawMap, TilePoint(baseCoords.u - 1, baseCoords.v, 0), metaPos);
|
||||
|
||||
metaPos.y += kMetaDY;
|
||||
metaPos.x += kMetaDX;
|
||||
@ -4402,7 +4403,7 @@ void drawMainDisplay(void) {
|
||||
|
||||
|
||||
// draws tiles to g_vm->_tileDrawMap.data
|
||||
drawMetaTiles();
|
||||
drawMetaTiles(g_vm->_tileDrawMap);
|
||||
|
||||
// Draw sprites onto back buffer
|
||||
drawDisplayList();
|
||||
|
@ -64,13 +64,14 @@ void initTileBanks(void) {
|
||||
}
|
||||
|
||||
void drawPlatform(
|
||||
gPixelMap &drawMap,
|
||||
Platform **pList, // platforms to draw
|
||||
Point16 screenPos, // screen position
|
||||
int16 uOrg, // for TAG search
|
||||
int16 vOrg) { // for TAG search
|
||||
|
||||
int16 right = g_vm->_tileDrawMap.size.x,
|
||||
bottom = g_vm->_tileDrawMap.size.y;
|
||||
int16 right = drawMap.size.x,
|
||||
bottom = drawMap.size.y;
|
||||
|
||||
Point16 tilePos;
|
||||
|
||||
@ -127,7 +128,7 @@ void drawPlatform(
|
||||
int16 y = tilePos.y - h;
|
||||
|
||||
if (ti->attrs.height > 0 && y < bottom + ti->attrs.height - 1) {
|
||||
drawTile(&g_vm->_tileDrawMap, tilePos.x, y, ti->attrs.height, imageData);
|
||||
drawTile(&drawMap, tilePos.x, y, ti->attrs.height, imageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user