develop
mizipzor 2010-02-21 00:35:31 +01:00
commit f156dcdc17
4 changed files with 55 additions and 5 deletions

@ -12,7 +12,9 @@ using namespace std;
#include <DFTileTypes.h>
#include <DFHackAPI.h>
#include <DFProcess.h>
#include <DFMemInfo.h>
using namespace DFHack;
#include <sstream>
#include <curses.h>
#include <stdlib.h>
#include <signal.h>
@ -200,9 +202,9 @@ void hexdump (DFHack::API& DF, uint32_t address, uint32_t length, int filenum)
char *buf = new char[reallength];
ofstream myfile;
string name = "hexdump";
name += filenum;
name+= ".txt";
stringstream ss;
ss << "hexdump" << filenum << ".txt";
string name = ss.str();
myfile.open (name.c_str());
@ -297,6 +299,7 @@ main(int argc, char *argv[])
error = "Can't find a map to look at.";
pDF = 0;
finish(0);
#include <DFMemInfo.h>
}
DF.getSize(x_max_a,y_max_a,z_max_a);
@ -328,14 +331,17 @@ main(int argc, char *argv[])
bool dig = false;
bool dump = false;
bool digbit = false;
int vein = 0;
int filenum = 0;
bool dirtybit = false;
uint32_t blockaddr = 0;
// walk the map!
for (;;)
{
dig = false;
dump = false;
digbit = false;
DF.Resume();
int c = getch(); /* refresh, accept single keystroke of input */
clrscr();
@ -372,6 +378,9 @@ main(int argc, char *argv[])
case '-':
vein --;
break;
case 'z':
digbit = true;
break;
default:
break;
}
@ -425,11 +434,17 @@ main(int argc, char *argv[])
blockaddr = DF.getBlockPtr(cursorX+i,cursorY+j,cursorZ);
if(dump)
{
hexdump(DF,blockaddr,0x1DB8,filenum);
hexdump(DF,blockaddr,0x1E00/*0x1DB8*/,filenum);
filenum++;
}
if(dig)
DF.WriteDesignations(cursorX+i,cursorY+j,cursorZ, (uint32_t *) designations);
DF.ReadDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit);
if(digbit)
{
dirtybit = !dirtybit;
DF.WriteDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit);
}
veinVector.clear();
DF.ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector);
}
@ -493,8 +508,12 @@ main(int argc, char *argv[])
cprintf("%s, address 0x%x",className.c_str(),veinVector[vein].address_of);
}
}
uint32_t sptr = blockaddr + p->getDescriptor()->getOffset("block_flags");
gotoxy (0,53);
cprintf("block address 0x%x",blockaddr);
gotoxy (0,54);
cprintf("dirty bit: %d",dirtybit);
wrefresh(stdscr);
}
pDF = 0;

@ -41,6 +41,7 @@ public:
uint32_t tile_type_offset;
uint32_t designation_offset;
uint32_t occupancy_offset;
uint32_t block_flags_offset;
uint32_t biome_stuffs;
uint32_t veinvector;
uint32_t veinsize;
@ -245,6 +246,33 @@ bool API::ReadTileTypes (uint32_t x, uint32_t y, uint32_t z, uint16_t *buffer)
return false;
}
bool API::ReadDirtyBit(uint32_t x, uint32_t y, uint32_t z, bool &dirtybit)
{
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if(addr)
{
uint32_t addr_of_struct = g_pProcess->readDWord(addr);
dirtybit = g_pProcess->readDWord(addr_of_struct) & 1;
return true;
}
return false;
}
bool API::WriteDirtyBit(uint32_t x, uint32_t y, uint32_t z, bool dirtybit)
{
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
if (addr)
{
uint32_t addr_of_struct = g_pProcess->readDWord(addr);
uint32_t dirtydword = g_pProcess->readDWord(addr_of_struct);
dirtydword &= 0xFFFFFFF0;
dirtydword |= dirtybit;
g_pProcess->writeDWord (addr_of_struct, dirtydword);
return true;
}
return false;
}
// 256 * sizeof(uint32_t)
bool API::ReadDesignations (uint32_t x, uint32_t y, uint32_t z, uint32_t *buffer)

@ -141,6 +141,9 @@ namespace DFHack
bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
bool ReadDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool &dirtybit);
bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit);
/// read region offsets of a block
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer); // 16 * sizeof(uint8_t)

@ -765,7 +765,7 @@
<HexValue name="v_vein_size">0x2C</HexValue>
<Offset name="type">0x0082</Offset>
<Offset name="designation">0x0284</Offset>
<Offset name="occupancy">0x0684</Offset>
<Offset name="occupancy">0x0684</Offset>
<Offset name="biome_stuffs">0x1D84</Offset>
<!-- the world and its offsets -->