TraceBullet/vba-rerecording

Lua desyncs with savestate functions

Opened this issue · 2 comments

What steps will reproduce the problem?
1. Run a Lua script in SGB game Pokémon Blue
2. Use functions from savestate lib, such as savestate.load()
3. Load a savestate many times in the script's iterations.

What is the expected output? What do you see instead?
Using functions such as memory.readbyte(), the script reads values that are 
different from those that would appear in a normal movie playback.

For example, ordering the script to do an input and read a value from memory 
returns a number. Manually entering this input and reading the byte in memory 
viewer shows a different value, causing a desync.


Analyzing numbers generated by the RNG, in the first iterations, the values 
sync perfectly. After some, the values begin to differ by 3,4. At the last 
ones, they are completely different. 

What version of the product are you using? On what operating system?

VBA v22,  Windows 7 Ultimate 32 bits


Please provide any additional information below.

The problem is fixed when I remove savestate functions from the script and 
rerecord manually, leading me to believe these functions are buggy.

Original issue reported on code.google.com by flopes...@yahoo.com.br on 11 Aug 2010 at 6:46

I know that if you save, you will get desyncs. Savestate.load does not, by 
itself, cause desyncs. 

Original comment by kylethom...@gmail.com on 23 Oct 2010 at 9:21

After some testing, it seems this issue is related to incorrect emulation of 
the divider register after a bot rerecord. Pokémon RBY uses this register for 
updating its RNG, I tested a script on a game that doesn't and there were no 
desyncs in it.

Original comment by felipe_l...@aluno.ita.br on 16 Jul 2011 at 2:38