From b87752a954a9e8fa6cbc78809806701ed68e4902 Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Mon, 16 Aug 2010 10:09:33 +0300 Subject: [PATCH 1/9] Some changes to make CMake behave when dfhack is used as a submodule. Doesn't still quite make it behave but at least a bit. --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a03f7d6cc..ff96265da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,16 @@ cmake_minimum_required(VERSION 2.6) SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules) SET ( DFHACK_VERSION "0.4.1.0-dev" ) +# Set this to project source dir. When dfhack is used +# as a submodule, CMAKE_SOURCE_DIR is not pointing to +# the root where this particular CMakeLists.txt file sits. +SET(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}) + +# Reset compiler flags. +# (Dfterm2 uses -D_UNICODE but dfhack doesn't compile with it, +# breaking dfhack when used as a submodule) +SET(COMPILE_DEFINITIONS "") + # disable warning, autosearch if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -43,4 +53,4 @@ add_subdirectory (library/shm) add_subdirectory (tools/examples) add_subdirectory (tools/playground) add_subdirectory (tools/supported) -add_subdirectory (doc) \ No newline at end of file +add_subdirectory (doc) From 4d4e895878148f480f180106125ff64408fed90e Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Mon, 16 Aug 2010 10:45:17 +0300 Subject: [PATCH 2/9] Modify root CMakeLists.txt some more to behave as submodule. --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff96265da..fa62f5cbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,6 @@ SET ( DFHACK_VERSION "0.4.1.0-dev" ) # the root where this particular CMakeLists.txt file sits. SET(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}) -# Reset compiler flags. -# (Dfterm2 uses -D_UNICODE but dfhack doesn't compile with it, -# breaking dfhack when used as a submodule) -SET(COMPILE_DEFINITIONS "") - # disable warning, autosearch if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) From ac78452228732f3229f578685228e2fe68353628 Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Mon, 16 Aug 2010 10:46:07 +0300 Subject: [PATCH 3/9] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5abcc3138..356bf6399 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ output/* # a file generated by cmake dfhack/include/config.h +library/private/config.h # any build folders build*/ From 35a58cdf0c6f47dad60ef5b27420ab60f81774cd Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Mon, 16 Aug 2010 14:50:12 +0300 Subject: [PATCH 4/9] Add screen_tiles_pointer for Memory.xml and fix reading screen tiles in Position module. --- data/Memory.xml | 1 + library/modules/Position.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/data/Memory.xml b/data/Memory.xml index fd0072623..3b50deb28 100644 --- a/data/Memory.xml +++ b/data/Memory.xml @@ -1721,6 +1721,7 @@ map_data_1b60_offset 0x1B9c f0459165a426a9f2dd8d957e9fa7f01d 0x4C4C32E7 +
0x18313D0
.-"""-. ' \ diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index ab3fccba3..694db6838 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -177,7 +177,7 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) if(!d->StartedScreen) return false; 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); uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/]; @@ -187,10 +187,10 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) { for(int32_t ix=0; ix Date: Mon, 16 Aug 2010 16:35:58 +0300 Subject: [PATCH 5/9] Add a dirty hack to stop flickering on non-synchronizing DF processes. --- library/modules/Position.cpp | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index 694db6838..4499b6089 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -43,6 +43,11 @@ struct Position::Private uint32_t hotkey_size; 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; Process * owner; @@ -57,6 +62,11 @@ Position::Position(DFContextShared * d_) d = new Private; d->d = d_; 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->StartedHotkeys = d->Started = d->StartedScreen = false; memory_info * mem; @@ -90,6 +100,7 @@ Position::Position(DFContextShared * d_) Position::~Position() { + if (d->tiles) delete[] d->tiles; delete d; } @@ -176,13 +187,42 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) if(!d->Inited) 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; + 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; + } - 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); + 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) + { + d->owner->read (d->last_screen_offset, width*height*4, (uint8_t*) d->tiles); + d->last_screen_offset = screen_addr; + } + d->first_read = false; + const uint8_t* tiles = d->tiles; + for(int32_t iy=0; iy Date: Fri, 27 Aug 2010 18:26:53 +0300 Subject: [PATCH 6/9] Revert "Add a dirty hack to stop flickering on non-synchronizing DF processes." This reverts commit 3a33e64acc4da7270eef30ef595fc6f82eb72efc. I guess it's better this way. --- library/modules/Position.cpp | 48 ++++-------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index 4499b6089..694db6838 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -43,11 +43,6 @@ struct Position::Private uint32_t hotkey_size; 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; Process * owner; @@ -62,11 +57,6 @@ Position::Position(DFContextShared * d_) d = new Private; d->d = d_; 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->StartedHotkeys = d->Started = d->StartedScreen = false; memory_info * mem; @@ -100,7 +90,6 @@ Position::Position(DFContextShared * d_) Position::~Position() { - if (d->tiles) delete[] d->tiles; delete d; } @@ -187,42 +176,13 @@ bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) if(!d->Inited) 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; - 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) - { - d->owner->read (d->last_screen_offset, width*height*4, (uint8_t*) d->tiles); - d->last_screen_offset = 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); - d->first_read = false; - const uint8_t* tiles = d->tiles; - for(int32_t iy=0; iy Date: Fri, 27 Aug 2010 18:48:54 +0300 Subject: [PATCH 7/9] Remove final dfveinlook installing command from tools/supported/CMakeLists.txt. --- tools/supported/CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/supported/CMakeLists.txt b/tools/supported/CMakeLists.txt index f7006aeb2..073760894 100644 --- a/tools/supported/CMakeLists.txt +++ b/tools/supported/CMakeLists.txt @@ -116,9 +116,3 @@ dfflows dfliquids RUNTIME DESTINATION bin ) -IF(UNIX) - install(TARGETS - dfveinlook - RUNTIME DESTINATION bin - ) -ENDIF(UNIX) From 543480201c1ff389aaa6d411afd2f3fa9e7cc6e0 Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Fri, 27 Aug 2010 22:59:11 +0300 Subject: [PATCH 8/9] Add screen tiles pointer for Linux DF 0.31.12 --- data/Memory.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/data/Memory.xml b/data/Memory.xml index 3b50deb28..b25348e99 100644 --- a/data/Memory.xml +++ b/data/Memory.xml @@ -2360,6 +2360,7 @@ map_data_1b60_offset 0x1B9c e79cead03187ecb692961b316b7cdcd4 +
0xb291a2c
From 764ad323d1d482434b04132be0db57b978537bf0 Mon Sep 17 00:00:00 2001 From: Mikko Juola Date: Fri, 27 Aug 2010 23:38:05 +0300 Subject: [PATCH 9/9] Fix offset to something that appears more static. --- data/Memory.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Memory.xml b/data/Memory.xml index b25348e99..b8c53ed77 100644 --- a/data/Memory.xml +++ b/data/Memory.xml @@ -2360,7 +2360,7 @@ map_data_1b60_offset 0x1B9c e79cead03187ecb692961b316b7cdcd4 -
0xb291a2c
+
0x09487970