* Update the minimap position. * * @param packed The new position. * @param forceUpdate If true force the update even if the position didn't change. */
| 233 | * @param forceUpdate If true force the update even if the position didn't change. |
| 234 | */ |
| 235 | void Map_UpdateMinimapPosition(uint16 packed, bool forceUpdate) |
| 236 | { |
| 237 | /* Border tiles of the viewport relative to the top-left. */ |
| 238 | static const uint16 viewportBorder[] = { |
| 239 | 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, |
| 240 | 0x0040, 0x004E, |
| 241 | 0x0080, 0x008E, |
| 242 | 0x00C0, 0x00CE, |
| 243 | 0x0100, 0x010E, |
| 244 | 0x0140, 0x014E, |
| 245 | 0x0180, 0x018E, |
| 246 | 0x01C0, 0x01CE, |
| 247 | 0x0200, 0x020E, |
| 248 | 0x0240, 0x0241, 0x0242, 0x0243, 0x0244, 0x0245, 0x0246, 0x0247, 0x0248, 0x0249, 0x024A, 0x024B, 0x024C, 0x024D, 0x024E, |
| 249 | 0xFFFF |
| 250 | }; |
| 251 | |
| 252 | static uint16 minimapPreviousPosition = 0; |
| 253 | |
| 254 | bool cleared; |
| 255 | Screen oldScreenID; |
| 256 | |
| 257 | if (packed != 0xFFFF && packed == minimapPreviousPosition && !forceUpdate) return; |
| 258 | if (g_selectionType == SELECTIONTYPE_MENTAT) return; |
| 259 | |
| 260 | oldScreenID = GFX_Screen_SetActive(SCREEN_1); |
| 261 | |
| 262 | cleared = false; |
| 263 | |
| 264 | if (minimapPreviousPosition != 0xFFFF && minimapPreviousPosition != packed) { |
| 265 | const uint16 *m; |
| 266 | |
| 267 | cleared = true; |
| 268 | |
| 269 | for (m = viewportBorder; *m != 0xFFFF; m++) { |
| 270 | uint16 curPacked; |
| 271 | |
| 272 | curPacked = minimapPreviousPosition + *m; |
| 273 | BitArray_Clear(g_displayedMinimap, curPacked); |
| 274 | |
| 275 | GUI_Widget_Viewport_DrawTile(curPacked); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | if (packed != 0xFFFF && (packed != minimapPreviousPosition || forceUpdate)) { |
| 280 | const uint16 *m; |
| 281 | uint16 mapScale; |
| 282 | const MapInfo *mapInfo; |
| 283 | uint16 left, top, right, bottom; |
| 284 | |
| 285 | mapScale = g_scenario.mapScale; |
| 286 | mapInfo = &g_mapInfos[mapScale]; |
| 287 | |
| 288 | left = (Tile_GetPackedX(packed) - mapInfo->minX) * (mapScale + 1) + 256; |
| 289 | right = left + mapScale * 15 + 14; |
| 290 | top = (Tile_GetPackedY(packed) - mapInfo->minY) * (mapScale + 1) + 136; |
| 291 | bottom = top + mapScale * 10 + 9; |
| 292 |
no test coverage detected