view and cursor coords for 40d16 on windows

develop
Petr Mrázek 2009-11-12 01:05:07 +00:00
parent 4f279680b5
commit e8e3f9e794
3 changed files with 88 additions and 1 deletions

@ -42,6 +42,11 @@ class API::Private
uint32_t designation_offset;
uint32_t occupancy_offset;
uint32_t window_x_offset;
uint32_t window_y_offset;
uint32_t window_z_offset;
uint32_t cursor_xyz_offset;
uint32_t creature_pos_offset;
uint32_t creature_type_offset;
uint32_t creature_flags1_offset;
@ -80,6 +85,7 @@ class API::Private
bool buildingsInited;
bool vegetationInited;
bool creaturesInited;
bool cursorWindowInited;
bool nameTablesInited;
@ -123,6 +129,7 @@ API::API(const string path_to_xml)
d->creaturesInited = false;
d->buildingsInited = false;
d->vegetationInited = false;
d->cursorWindowInited = false;
d->pm = NULL;
}
@ -153,6 +160,7 @@ bool API::InitMap()
// get the map pointer
map_loc = MreadDWord(map_offset);
//FIXME: very inadequate
if (!map_loc)
{
// bad stuffz happend
@ -1087,3 +1095,59 @@ void API::ReadRaw (const uint32_t &offset, const uint32_t &size, uint8_t *target
{
Mread(offset, size, target);
}
void API::WriteRaw (const uint32_t &offset, const uint32_t &size, uint8_t *source)
{
Mwrite(offset, size, source);
}
bool API::InitViewAndCursor()
{
d->window_x_offset = d->offset_descriptor->getAddress("window_x");
d->window_y_offset = d->offset_descriptor->getAddress("window_x");
d->window_z_offset = d->offset_descriptor->getAddress("window_x");
d->cursor_xyz_offset = d->offset_descriptor->getAddress("cursor_xyz");
if(d->window_x_offset && d->window_y_offset && d->window_z_offset)
{
d->cursorWindowInited = true;
return true;
}
else
{
return false;
}
}
void API::getViewCoords (uint32_t &x, uint32_t &y, uint32_t &z)
{
assert(d->cursorWindowInited);
MreadDWord(d->window_x_offset,x);
MreadDWord(d->window_y_offset,y);
MreadDWord(d->window_z_offset,z);
}
//FIXME: confine writing of coords to map bounds?
void API::setViewCoords (const uint32_t &x, const uint32_t &y, const uint32_t &z)
{
assert(d->cursorWindowInited);
MwriteDWord(d->window_x_offset,x);
MwriteDWord(d->window_y_offset,y);
MwriteDWord(d->window_z_offset,z);
}
void API::getCursorCoords (uint32_t &x, uint32_t &y, uint32_t &z)
{
assert(d->cursorWindowInited);
uint32_t coords[3];
Mread(d->cursor_xyz_offset,3*sizeof(uint32_t),(uint8_t *)coords);
x = coords[0];
y = coords[1];
z = coords[2];
}
//FIXME: confine writing of coords to map bounds?
void API::setCursorCoords (const uint32_t &x, const uint32_t &y, const uint32_t &z)
{
assert(d->cursorWindowInited);
uint32_t coords[3] = {x,y,z};
Mwrite(d->cursor_xyz_offset,3*sizeof(uint32_t),(uint8_t *)coords);
}

@ -171,6 +171,16 @@ public:
void FinishReadCreatures();
void ReadRaw (const uint32_t &offset, const uint32_t &size, uint8_t *target);
void WriteRaw (const uint32_t &offset, const uint32_t &size, uint8_t *source);
bool InitViewAndCursor();
void getViewCoords (uint32_t &x, uint32_t &y, uint32_t &z);
void setViewCoords (const uint32_t &x, const uint32_t &y, const uint32_t &z);
void getCursorCoords (uint32_t &x, uint32_t &y, uint32_t &z);
void setCursorCoords (const uint32_t &x, const uint32_t &y, const uint32_t &z);
};
}
} // namespace DFHack
#endif // SIMPLEAPI_H_INCLUDED

@ -891,6 +891,19 @@
<String name="md5">59ab29021aca9f3c66b1ab102fb3ceea</String>
<!-- map_data = 0x01601D84 -->
<!-- door: 0x8e15d4, no VTable rebase needed -->
<Address name="cursor_xyz">0x009662B4</Address>
<Address name="window_x">0x00DA061C</Address>
<Address name="window_y">0x00DCE6C8</Address>
<Address name="window_z">0x00DCE6A4</Address>
<!--
<belal> for windows d16
<belal> designation x 0x009662B4
<belal> designation y 0x009662B8
<belal> designation z 0x009662BC
<belal> window x 0x00DA061C
<belal> window y 0x00DCE6C8
<belal> window z 0x00DCE6A4
-->
</Entry>
.-"""-.