hexdump accepts length in bytes, hopefully fixed engravings struct

develop
Petr Mrázek 2011-04-03 02:49:03 +02:00
parent e18ade4ea6
commit a68702000d
7 changed files with 30 additions and 24 deletions

@ -56,24 +56,29 @@ length = length in lines. 1 line = 16 bytes
*/
void hexdump (DFHack::Context *DF, uint32_t address, uint32_t length)
{
char *buf = new char[length * 16];
DF->ReadRaw(address, length * 16, (uint8_t *) buf);
for (uint32_t i = 0; i < length; i++)
char *buf = new char[length];
DF->ReadRaw(address, length, (uint8_t *) buf);
int i = 0;
while (i < length)
{
// leading offset
cout << "0x" << hex << setw(8) << address + i*16 << "| ";
// groups
for(int j = 0; j < 4; j++)
if(i%16 == 0)
cout << "0x" << hex << setw(8) << address + i << "| ";
// bytes
for(int k = 0; k < 4; k++)
{
cout << hex << setw(2) << int(static_cast<unsigned char>(buf[i])) << " ";
i++;
if(i == length) break;
}
if(i%16 == 0 || i>= length)
{
cout << endl;
}
else if(i%4 == 0)
{
// bytes
for(int k = 0; k < 4; k++)
{
int idx = i * 16 + j * 4 + k;
cout << hex << setw(2) << int(static_cast<unsigned char>(buf[idx])) << " ";
}
cout << " ";
}
cout << endl;
}
delete buf;
}

@ -23,7 +23,7 @@ namespace DFHack
// 4
int32_t unknownIdx;
// 8
uint32_t quality; // from 0 to 5
uint32_t unknown1;
// C
uint16_t x; /*!< X coordinate */
uint16_t y; /*!< Y coordinate */
@ -37,9 +37,10 @@ namespace DFHack
// 1C
uint32_t type; // possibly an enum, decides what vectors to use for imagery
// 20
uint32_t subtype_idx; // index in a vector kind of deal related to previous value
int16_t subtype_idx; // index in a vector kind of deal related to previous value
uint16_t quality; // from 0 to 5
// 24
uint32_t unknown1;
uint32_t unknown2;
// 28 = length
};
/**

@ -78,7 +78,7 @@ int main (int argc,const char* argv[])
if(typestr == argv[1])
{
//cout << buildingtypes[temp.type] << " 0x" << hex << temp.origin << endl;
//hexdump(DF, temp.origin, 16);
//hexdump(DF, temp.origin, 256);
addresses.push_back(temp.origin);
}
}
@ -116,7 +116,7 @@ int main (int argc,const char* argv[])
{
printf("Custom workshop type %s (%d)\n",custom_workshop_types[custom].c_str(),custom);
}
hexdump(DF,temp.origin,120);
hexdump(DF,temp.origin,120*16);
}
}
}

@ -83,7 +83,7 @@ int main (int numargs, const char ** args)
default:
printf("It is made of something we don't know yet! The material is %s.\n",matstr.c_str());
}
hexdump(DF,con.origin,2);
hexdump(DF,con.origin,32);
}
}
}

@ -51,7 +51,7 @@ int main (int numargs, const char ** args)
printf("Engraving %d/%d/%d @ 0x%x\n", data.x, data.y, data.z, engraved.origin);
// inorganic stuff - we can recognize that
printf("type %d, index %d, character %c\n",data.type, data.subtype_idx, data.display_character);
hexdump(DF,engraved.origin,3);
hexdump(DF,engraved.origin,0x28);
}
}
}
@ -66,7 +66,7 @@ int main (int numargs, const char ** args)
printf("Engraving %d/%d/%d @ 0x%x\n", data.x, data.y, data.z, engraved.origin);
// inorganic stuff - we can recognize that
printf("type %d, index %d, character %c\n",data.type, data.subtype_idx, data.display_character);
hexdump(DF,engraved.origin,2);
hexdump(DF,engraved.origin,0x28);
}
}
}

@ -135,7 +135,7 @@ int main (int numargs, const char ** args)
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
hexdump(DF, splatter[i].address_of,20*16);
cout << endl;
}
}
@ -178,7 +178,7 @@ int main (int numargs, const char ** args)
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
hexdump(DF, splatter[i].address_of,20*16);
cout << endl;
}
}

@ -32,7 +32,7 @@ void print_tree( DFHack::Context * DF , DFHack::t_tree & tree)
}
cout << endl;
printf("Address: 0x%x\n", tree.address);
hexdump(DF,tree.address,13);
hexdump(DF,tree.address,13*16);
}
int main (int numargs, const char ** args)