[hatari-devel] Wrong memory init

Nicolas Pomarède npomarede at corp.free.fr
Sun Nov 27 14:23:33 CET 2011


Hello

I spent some hard hours trying to fix the game Yolanda (on Pompey 
Pirates 46).
The game freezes after a few second because of a bad random number 
generator that always returns 0.
This random number is inititalized with the value in $100. By default, 
this value is 0 under Hatari, because FastBoot is on, which bypasses the 
TOS memory init functions that write data between $8 and $200.


The "culprit" is in stMemory.c. I'm wondering what is this MMU reference 
? I see this code is present since the initial import of tos.c in 2001, 
but this looks like a bug to me, especially since Hatari works fine when 
fastboot is turned off in System settings.

         /* Fill in magic numbers, so TOS does not try to reference MMU */
         if (ConfigureParams.System.bFastBoot
             || (ConfigureParams.Memory.nMemorySize > 4 && !bIsEmuTOS))
         {
                 /* Write magic values to sysvars to signal valid config */
                 STMemory_WriteLong(0x420, 0x752019f3);    /* memvalid */
                 STMemory_WriteLong(0x43a, 0x237698aa);    /* memval2 */
                 STMemory_WriteLong(0x51a, 0x5555aaaa);    /* memval3 */
         }

So, I would propose to remove this piece of code ; this has nearly no 
impact on boot time.

Additionnaly, I think bFastBoot should be false by default, to ensure 
the system always starts in the maximum compatibility level. The user 
can still change it later if he wants (this is used in tos.c, when patch 
has TP_HDIMAGE_OFF ; is it still useful ?)

Thomas (or others), any comment on this "ancient" behaviour ?

Nicolas




More information about the hatari-devel mailing list