Jump to content
IGNORED

Three.s


Recommended Posts

  • 2 weeks later...

A nasty bug kept me busy for some hours.

 

For undo, I have to restore the random number generator values (2 bytes). To save one byte here, I decided to optimize my existing code and to count the random number generator (LFSR) calls during a move. Then, on undo, I call a reverse LFSR as often a counted during the move. So I only have to store the count byte, but not the two random number bytes for undo.

 

However, this didn't work, the restored random number byte didn't match. After testing my reverse LFSR, I started debugging the code. But I could not reproduce the bug. Whenever I debugged, the numbers matched. I tried working with save states to identify the differing bytes. Sometimes I found none relevant and sometimes the random number bytes were different. But I could not spot a pattern.

 

Finally, after spending some hours of my time, I realized the problem. The undo is triggered by the fire button. And, as long as the fire button is pressed! Before my optimization, this was no problem as the same values were just written over and over again. But with my optimization the reverse LFSR is called over and over again too and therefore moving backwards far more than it should.

 

After realizing the cause the fix was done within one minute. :)

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...