Revert "Add a dirty hack to stop flickering on non-synchronizing DF processes."

This reverts commit 3a33e64acc4da7270eef30ef595fc6f82eb72efc.

I guess it's better this way.
develop
Mikko Juola 2010-08-27 18:26:53 +03:00
parent 4197ad064f
commit afdc91265d
1 changed files with 5 additions and 43 deletions

@ -43,11 +43,6 @@ struct Position::Private
uint32_t hotkey_size; uint32_t hotkey_size;
uint32_t screen_tiles_ptr_offset; uint32_t screen_tiles_ptr_offset;
uint32_t last_screen_offset;
uint8_t* tiles;
uint32_t tiles_size;
bool first_read; // used in getScreenTiles
DFContextShared *d; DFContextShared *d;
Process * owner; Process * owner;
@ -62,11 +57,6 @@ Position::Position(DFContextShared * d_)
d = new Private; d = new Private;
d->d = d_; d->d = d_;
d->owner = d_->p; d->owner = d_->p;
d->last_screen_offset = (uint32_t) 0;
d->tiles = (uint8_t*) 0;
d->first_read = true;
d->tiles_size = 0;
d->Inited = true; d->Inited = true;
d->StartedHotkeys = d->Started = d->StartedScreen = false; d->StartedHotkeys = d->Started = d->StartedScreen = false;
memory_info * mem; memory_info * mem;
@ -100,7 +90,6 @@ Position::Position(DFContextShared * d_)
Position::~Position() Position::~Position()
{ {
if (d->tiles) delete[] d->tiles;
delete d; delete d;
} }
@ -187,41 +176,12 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[])
if(!d->Inited) return false; if(!d->Inited) return false;
if(!d->StartedScreen) return false; if(!d->StartedScreen) return false;
/*
To work around flickering without synchronization,
we take advantage of double buffering in DF.
We don't return the buffer currently in use,
but the buffer that was last used. This has much less
chance of being empty or flicker.
*/
uint32_t screen_addr; uint32_t screen_addr;
d->owner->read (d->screen_tiles_ptr_offset, sizeof(uint32_t), (uint8_t *) &screen_addr); d->owner->read (d->screen_tiles_ptr_offset, sizeof(uint32_t), (uint8_t *) &screen_addr);
if (d->first_read)
d->last_screen_offset = screen_addr;
if (d->tiles && width * height * 4 != d->tiles_size)
{
delete[] d->tiles;
d->tiles = (uint8_t*) 0;
}
if (!d->tiles)
{
d->tiles = new uint8_t[width * height * 4];
d->tiles_size = width * height * 4;
}
if (d->last_screen_offset != screen_addr || d->first_read) uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/];
{
d->owner->read (d->last_screen_offset, width*height*4, (uint8_t*) d->tiles);
d->last_screen_offset = screen_addr;
}
d->first_read = false; d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), (uint8_t *) tiles);
const uint8_t* tiles = d->tiles;
for(int32_t iy=0; iy<height; iy++) for(int32_t iy=0; iy<height; iy++)
{ {
@ -236,5 +196,7 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[])
} }
} }
delete [] tiles;
return true; return true;
} }