[hatari-devel] Issues after restoring a memory snapshot

Eero Tamminen oak at helsinkinet.fi
Sun Jan 16 17:51:05 CET 2011


Hi,

On sunnuntai 16 tammikuu 2011, Eero Tamminen wrote:
> But while testing this I noticed a much worse issue...
> 
> If one starts Hatari with memory snapshot (in my case for Mahabharata
> demo), Hatari doesn't anymore react to any keyboard input or other user
> input. You cannot open the Options dialog, close the window, move the
> Atari mouse, nothing.  Statusbar isn't always updated either (can be
> black).

Input events are handled in Main_EventHandler() which gets called only from
IKBD_InterruptHandler_AutoSend() interrupt handler.  This is called only on
INTERRUPT_IKBD_AUTOSEND interrupts which are generated only by this
interrupt handler itself and IKBD_Reset(), nothing else.

So I added debug output to these...


If I use:
	hatari mahabhar.prg
I get:
	GEMDOS HDD emulation, C: <-> ...
	Virtual autostart file 'NEWDESK.INF' created for 'MAHABHAR.PRG'.
	IKBD_Reset()
	OS clock ticks / second: 100
	Main_EventHandler()
	Main_EventHandler()
	<lots of messages>

And everything works.


If I use:
	hatari --memstate maha.sav
I get:
	IKBD_Reset()
	IKBD_Reset()
	GEMDOS HDD emulation, C: <-> ...
	No (more) breakpoints to remove.
	No (more) breakpoints to remove.
	MemorySnapShot_Restore()

There are IKBD_Reset()s, but no Main_EventHandler() calls.
Output comes in a much different order and no input is processed.


As the IKBD code is this:
---------------
void IKBD_InterruptHandler_AutoSend(void)
{
        /* Remove this interrupt from list and re-order */
        CycInt_AcknowledgeInterrupt();

        /* Handle user events and other messages, (like quit message) */
        Main_EventHandler();

        /* Did user try to quit? */
        if (bQuitProgram)
        {
                /* Pass NULL interrupt function to quit cleanly */
                CycInt_AddAbsoluteInterrupt(4, INT_CPU_CYCLE, 
INTERRUPT_NULL);
                /* Assure that CPU core shuts down */
                M68000_SetSpecial(SPCFLAG_BRK);
                return;
        }

        /* Trigger this auto-update function again after a while */
        CycInt_AddRelativeInterrupt(150000, INT_CPU_CYCLE, 
INTERRUPT_IKBD_AUTOSEND);
---------------

-> When user saves the memory snapshot from SDL UI or through shortcut,
    there's no INTERRUPT_IKBD_AUTOSEND and that state is restore when
    the memory snapshot is loaded.

If restore was done from the UI, this interrupt will be added before exiting
from this function, but if it's done from command line, that naturally
doesn't happen.

I see two possible ways to fix this:
* Acknowledge the interrupt only after Main_EventHandler() call, or
* Make sure in IKBD_MemorySnapShot_Capture() that after restore
   there is (one) INTERRUPT_IKBD_AUTOSEND interrupt.

Nicolas?



	- Eero

PS. Could the 150000 instruction delay in INTERRUPT_IKBD_AUTOSEND affect
the issue that it takes a lot longer with some TOSes until Hatari gives
the corresponding keyboard clicks?



More information about the hatari-devel mailing list