Menu

#50 Incorrect handling of shift and rotate instructions

v1.0_(example)
open
nobody
None
5
2017-01-03
2017-01-03
No

Starscream has issues in its handling of shift and rotate instructions for shift counts larger than 31 bits. The main 68k version has a partial fix for this issue; nevertheless, there are 4 separate issues related to this:

  1. For rotation, a rotation count of 63 is an edge case which will yield incorrect results in terms of flags;
  2. For shifts other than asl, all shifts of >= 32 bits are wrong in both result and flags as Starscream only emits a shift for 31 bits and omits the rest of the shift;
  3. Adding the missing instruction to the above case would yield another edge condition for a shift of 63 bits;
  4. The code for main 68k and sub 68k for shifts is out of synch, meaning that the sub 68k does not have even the partial fix.

Here is a patch for Gens-rerecording which fixes this issue: https://github.com/TASVideos/gens-rerecording/commit/fc22fbad2ba321311fe83116d46e38dcbb7deb28

This patch can be used as a base for a fix for mainline Gens.

This is, by the way, what causes the well-known issue in Shining Force 2 which prevents Lemon from equiping anything; specifically, case 2 above: the code does a logical shift right (lsr) of 32 bits (equal to Lemon's class ID of 31 + 1) and checks the carry flag.

Discussion


Log in to post a comment.