Fixes to merged C API and windows SHM.

develop
Petr Mrázek 2010-07-17 01:55:18 +02:00
parent 9bafefbd80
commit 52178e779f
4 changed files with 57 additions and 3 deletions

@ -23,6 +23,7 @@ distribution.
*/
#include "dfhack/DFIntegers.h"
#include "dfhack/DFTileTypes.h"
#include <stdlib.h>
#include "string.h"
#include <vector>

@ -308,7 +308,7 @@ t_frozenliquidvein* Maps_ReadFrozenVeins(DFHackObject* maps, uint32_t x, uint32_
{
if(maps != NULL)
{
if(alloc_frozenliquidvein_callback == NULL)
if(alloc_frozenliquidvein_buffer_callback == NULL)
return NULL;
vector<t_vein> veins;
@ -339,7 +339,7 @@ t_spattervein* Maps_ReadSpatterVeins(DFHackObject* maps, uint32_t x, uint32_t y,
{
if(maps != NULL)
{
if(alloc_spattervein_callback == NULL)
if(alloc_spattervein_buffer_callback == NULL)
return NULL;
vector<t_vein> veins;

@ -42,11 +42,14 @@ struct Position::Private
uint32_t hotkey_xyz_offset;
uint32_t hotkey_size;
uint32_t screen_tiles_ptr_offset;
DFContextShared *d;
Process * owner;
bool Inited;
bool Started;
bool StartedHotkeys;
bool StartedScreen;
};
Position::Position(DFContextShared * d_)
@ -55,7 +58,7 @@ Position::Position(DFContextShared * d_)
d->d = d_;
d->owner = d_->p;
d->Inited = true;
d->StartedHotkeys = d->Started = false;
d->StartedHotkeys = d->Started = d->StartedScreen = false;
memory_info * mem;
try
{
@ -77,6 +80,12 @@ Position::Position(DFContextShared * d_)
d->StartedHotkeys = true;
}
catch(exception &){};
try
{
d->screen_tiles_ptr_offset = mem->getAddress ("screen_tiles_pointer");
d->StartedScreen = true;
}
catch(exception &){};
}
Position::~Position()
@ -161,3 +170,32 @@ bool Position::getWindowSize (int32_t &width, int32_t &height)
return true;
}
/*
bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[])
{
if(!d->Inited) return false;
uint32_t screen_addr;
d->owner->read (d->screen_tiles_ptr_offset, sizeof(uint32_t), (uint8_t *) screen_addr);
uint8_t* tiles = new uint8_t[width*height*4 + 80 + width*height*4];
d->owner->read (screen_addr, (width*height*4 + 80 + width*height*4), (uint8_t *) tiles);
for(int32_t iy=0; iy<height; iy++)
{
for(int32_t ix=0; ix<width; ix++)
{
screen[ix + iy*width].symbol = tiles[iy + ix*height +0];
screen[ix + iy*width].foreground = tiles[iy + ix*height +1];
screen[ix + iy*width].background = tiles[iy + ix*height +2];
screen[ix + iy*width].bright = tiles[iy + ix*height +3];
screen[ix + iy*width].gtile = tiles[width*height*4 + 80 + iy + ix*height +0];
screen[ix + iy*width].grayscale = tiles[width*height*4 + 80 + iy + ix*height +1];
}
}
delete [] tiles;
return true;
}
*/

@ -510,6 +510,20 @@ DFhackCExport void * SDL_DisplayFormat(void *surface)
return _SDL_DisplayFormat(surface);
}
static void * (*_SDL_DisplayFormatAlpha)( void * surface ) = 0;
DFhackCExport void * SDL_DisplayFormatAplha(void *surface)
{
return _SDL_DisplayFormatAlpha(surface);
}
//void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
static void (*_SDL_GetRGBA)(uint32_t pixel, void * fmt, uint8_t * r, uint8_t * g, uint8_t * b, uint8_t *a) = 0;
DFhackCExport void SDL_GetRGBA(uint32_t pixel, void * fmt, uint8_t * r, uint8_t * g, uint8_t * b, uint8_t *a)
{
return _SDL_GetRGBA(pixel, fmt, r, g, b, a);
}
static int (*_SDL_GL_GetAttribute)(int attr, int * value) = 0;
DFhackCExport int SDL_GL_GetAttribute(int attr, int * value)
{
@ -889,6 +903,7 @@ bool FirstCall()
_SDL_EnableUNICODE = (int (*)(int))GetProcAddress(realSDLlib,"SDL_EnableUNICODE");
_SDL_GetVideoSurface = (void*(*)())GetProcAddress(realSDLlib,"SDL_GetVideoSurface");
_SDL_DisplayFormat = (void * (*) (void *))GetProcAddress(realSDLlib,"SDL_DisplayFormat");
_SDL_DisplayFormatAlpha = (void * (*) (void *))GetProcAddress(realSDLlib,"SDL_DisplayFormatAlpha");
_SDL_FreeSurface = (void (*)(void*))GetProcAddress(realSDLlib,"SDL_FreeSurface");
_SDL_GL_GetAttribute = (int (*)(int, int*))GetProcAddress(realSDLlib,"SDL_GL_GetAttribute");
_SDL_GL_SetAttribute = (int (*)(int, int))GetProcAddress(realSDLlib,"SDL_GL_SetAttribute");