Prefetch next tile in tile loop iteration

This commit is contained in:
Jonathan G Rennison
2023-08-17 14:40:39 +01:00
parent cc57ac0eff
commit 9cf39b7a25

View File

@@ -43,6 +43,8 @@
#include "table/strings.h" #include "table/strings.h"
#include "table/sprites.h" #include "table/sprites.h"
#include INCLUDE_FOR_PREFETCH_NTA
#include "safeguards.h" #include "safeguards.h"
extern const TileTypeProcs extern const TileTypeProcs
@@ -866,10 +868,13 @@ void RunTileLoop(bool apply_day_length)
} }
while (count--) { while (count--) {
/* Get the next tile in sequence using a Galois LFSR. */
TileIndex next = (tile >> 1) ^ (-(int32)(tile & 1) & feedback);
if (count > 0) PREFETCH_NTA(&_m[next]);
_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); _tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile);
/* Get the next tile in sequence using a Galois LFSR. */ tile = next;
tile = (tile >> 1) ^ (-(int32)(tile & 1) & feedback);
} }
_cur_tileloop_tile = tile; _cur_tileloop_tile = tile;
@@ -887,13 +892,16 @@ void RunAuxiliaryTileLoop()
TileIndex tile = _aux_tileloop_tile; TileIndex tile = _aux_tileloop_tile;
while (count--) { while (count--) {
/* Get the next tile in sequence using a Galois LFSR. */
TileIndex next = (tile >> 1) ^ (-(int32)(tile & 1) & feedback);
if (count > 0) PREFETCH_NTA(&_m[next]);
if (IsFloodingTypeTile(tile) && !IsNonFloodingWaterTile(tile)) { if (IsFloodingTypeTile(tile) && !IsNonFloodingWaterTile(tile)) {
FloodingBehaviour fb = GetFloodingBehaviour(tile); FloodingBehaviour fb = GetFloodingBehaviour(tile);
if (fb != FLOOD_NONE) TileLoopWaterFlooding(fb, tile); if (fb != FLOOD_NONE) TileLoopWaterFlooding(fb, tile);
} }
/* Get the next tile in sequence using a Galois LFSR. */ tile = next;
tile = (tile >> 1) ^ (-(int32)(tile & 1) & feedback);
} }
_aux_tileloop_tile = tile; _aux_tileloop_tile = tile;