Fix dynarec flag optimization in Thumb mode

Usually blocks end with a branch, which also consumes all flags, but in
case the block is aborted early (or any other reason to not finish the
block on a branch), it will result in only a subset of flags being
generated, which causes problems in a couple of games.

This performs an out of bounds flag read, which is incorrect
This commit is contained in:
David Guillen Fandos 2021-12-13 18:42:06 +01:00
parent 09cab16654
commit fae9c7074b
1 changed files with 2 additions and 5 deletions

View File

@ -2917,18 +2917,15 @@ block_lookup_address_builder(dual);
#define thumb_dead_flag_eliminate() \
{ \
u32 needed_mask; \
needed_mask = block_data[block_data_position].flag_data >> 8; \
u32 needed_mask = 0xff; \
\
block_data_position--; \
while(block_data_position >= 0) \
while(--block_data_position >= 0) \
{ \
flag_status = block_data[block_data_position].flag_data; \
block_data[block_data_position].flag_data = \
(flag_status & needed_mask); \
needed_mask &= ~((flag_status >> 4) & 0x0F); \
needed_mask |= flag_status >> 8; \
block_data_position--; \
} \
} \