Exemplo n.º 1
0
void playb_close (void)
{
      soundoff ();
#ifndef __ZTC__
      setvect (TIMER_TICK_INTR, n_oldtmint);
#else
      int_restore(TIMER_TICK_INTR);
#endif
      free (n_buff);
}
Exemplo n.º 2
0
/**
 * Waits (sleeps) for the given number of ticks.
 * Checks for keystroke.
 *
 * @returns BIOS scan code if available, 0 if not.
 * @param   ticks       Number of ticks to sleep.
 * @param   stop_on_key Whether to stop immediately upon keypress.
 */
uint8_t wait(uint16_t ticks, uint8_t stop_on_key)
{
    long        ticks_to_wait, delta;
    uint16_t    old_flags;
    uint32_t    prev_ticks, t;
    uint8_t     scan_code = 0;

    /*
     * We may or may not be called with interrupts disabled. For the duration
     * of this function, interrupts must be enabled.
     */
    old_flags = int_query();
    int_enable();

    /*
     * The 0:046c wraps around at 'midnight' according to a 18.2Hz clock.
     * We also have to be careful about interrupt storms.
     */
    ticks_to_wait = ticks;
    prev_ticks = read_dword(0x0, 0x46c);
    do
    {
        halt();
        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);
    int_restore(old_flags);
    return scan_code;
}
Exemplo n.º 3
0
/*
 * This function gets called just before we go back home to the command
 * interpreter. On VMS it puts the terminal back in a reasonable state.
 * Another no-operation on CPM.
 */
ttclose()
{
#if     AMIGA
        Close(terminal);
#endif
#if     VMS
        int     status;
        int     iosb[1];

        ttflush();
        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
                 oldmode, sizeof(oldmode), 0, 0, 0, 0);
        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
                exit(status);
        status = SYS$DASSGN(iochan);
        if (status != SS$_NORMAL)
                exit(status);
#endif
#if     CPM
#endif
#if     MSDOS && !__OS2__
        int_restore(0x23);      /* de-install control-break handler     */
#endif
#if     BSDUNIX
        stty(1, &ostate);
#if NONBLOCK
        fcntl(0,F_SETFL,oldstatus);
#endif
#endif

#if     linux || __OpenBSD__ || __APPLE__
        tcsetattr(1, TCSADRAIN, &ostate);	// return to original mode
#endif

#if NCURSES
	endwin();
#endif
}