Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

Bit8u wait ( Bit16u  ticks,
Bit8u  stop_on_key 
)

Waits (sleeps) for the given number of ticks. Checks for keystroke.

Returns:
BIOS scan code if available, 0 if not.
Parameters:
ticks Number of ticks to sleep.
stop_on_key Whether to stop immediately upon keypress.

Definition at line 167 of file logo.c.

References check_for_keystroke(), and get_keystroke().

{
    long ticks_to_wait, delta;
    Bit32u prev_ticks, t;
    Bit8u scan_code = 0;

    /*
     * The 0:046c wraps around at 'midnight' according to a 18.2Hz clock.
     * We also have to be careful about interrupt storms.
     */
ASM_START
    pushf
    sti
ASM_END
    ticks_to_wait = ticks;
    prev_ticks = read_dword(0x0, 0x46c);
    do
    {
ASM_START
        hlt
ASM_END
        t = read_dword(0x0, 0x46c);
        if (t > prev_ticks)
        {
            delta = t - prev_ticks;     /* The temp var is required or bcc screws up. */
            ticks_to_wait -= delta;
        }
        else if (t < prev_ticks)
            ticks_to_wait -= t;         /* wrapped */
        prev_ticks = t;

        if (check_for_keystroke())
        {
            scan_code = get_keystroke();
            bios_printf(BIOS_PRINTF_INFO, "Key pressed: %x\n", scan_code);
            if (stop_on_key)
                return scan_code;
        }
    } while (ticks_to_wait > 0);
ASM_START
    popf
ASM_END
    return scan_code;
}


Generated by  Doxygen 1.6.0   Back to index