Esempio n. 1
0
/* Flush pending characters into the kernal's queue if possible.
   This is (at least) called once per frame in vsync handler */
void kbdbuf_flush(void)
{
    unsigned int i, n;

    if ((!kbd_buf_enabled)
        || (num_pending == 0)
        || !kbdbuf_is_empty()
        || (maincpu_clk < kernal_init_cycles)
        || (kbdbuf_flush_alarm_time != 0)) {
        return;
    }
    n = num_pending > buffer_size ? buffer_size : num_pending;
    /* printf("kbdbuf_flush pending: %d n: %d head_idx: %d\n", num_pending, n, head_idx); */
    for (i = 0; i < n; i++) {
        /* printf("kbdbuf_flush i:%d head_idx:%d queue[head_idx]: %d use_kbdbuf_flush_alarm: %d\n",i,head_idx,queue[head_idx],use_kbdbuf_flush_alarm); */
        /* use an alarm to randomly delay RETURN for up to one frame */
        if ((queue[head_idx] == 13) && (use_kbdbuf_flush_alarm == 1)) {
            /* we actually need to wait _at least_ one frame to not overrun the buffer */
            kbdbuf_flush_alarm_time = maincpu_clk + machine_get_cycles_per_frame();
            kbdbuf_flush_alarm_time += lib_unsigned_rand(1, machine_get_cycles_per_frame());
            alarm_set(kbdbuf_flush_alarm, kbdbuf_flush_alarm_time);
            return;
        }
        tokbdbuffer(queue[head_idx]);
        removefromqueue();
    }
}
Esempio n. 2
0
/* Flush pending characters into the kernal's queue if possible.  */
void kbdbuf_flush(void)
{
    unsigned int i, n;

    if ((!kbd_buf_enabled)
          || num_pending == 0
          || maincpu_clk < kernal_init_cycles
          || !kbdbuf_is_empty())
        return;

    n = num_pending > buffer_size ? buffer_size : num_pending;
    for (i = 0; i < n; head_idx = (head_idx + 1) % QUEUE_SIZE, i++)
        mem_store((WORD)(buffer_location + i), queue[head_idx]);

    mem_store((WORD)(num_pending_location), (BYTE)(n));
    num_pending -= n;
}
Esempio n. 3
0
static enum { YES, NO, NOT_YET } check(const char *s, unsigned int blink_mode)
{
    int screen_addr, line_length, cursor_column, addr, i;

    screen_addr = (int)(mem_read((WORD)(pnt)) | (mem_read((WORD)(pnt + 1)) << 8));
    cursor_column = (int)mem_read((WORD)(pntr));

    line_length = (int)(lnmx < 0 ? -lnmx : mem_read((WORD)(lnmx)) + 1);

    DBG(("check(%s) pnt:%04x pntr:%04x addr:%04x column:%d, linelen:%d blnsw:%04x(%d)",
         s, pnt, pntr, screen_addr, cursor_column, line_length, blnsw, mem_read(blnsw)));

    if (!kbdbuf_is_empty()) {
        return NOT_YET;
    }

    if (blink_mode == AUTOSTART_WAIT_BLINK && cursor_column != 0) {
        return NOT_YET;
    }

    if (blink_mode == AUTOSTART_WAIT_BLINK && blnsw != 0 && mem_read(blnsw) != 0) {
        return NOT_YET;
    }

    if (blink_mode == AUTOSTART_WAIT_BLINK) {
        addr = screen_addr - line_length;
    } else {
        addr = screen_addr;
    }

    for (i = 0; s[i] != '\0'; i++) {
        if (mem_read((WORD)(addr + i)) != s[i] % 64) {
            if (mem_read((WORD)(addr + i)) != (BYTE)32) {
                return NO;
            }
            return NOT_YET;
        }
    }
    return YES;
}
Esempio n. 4
0
static enum { YES, NO, NOT_YET } check(const char *s, unsigned int blink_mode)
{
    int screen_addr, line_length, cursor_column, addr, i;

    screen_addr = (int)(mem_read((WORD)(pnt))
                  | (mem_read((WORD)(pnt + 1)) << 8));
    cursor_column = (int)mem_read((WORD)(pntr));

    line_length = (int)(lnmx < 0 ? -lnmx : mem_read((WORD)(lnmx)) + 1);

    if (!kbdbuf_is_empty())
        return NOT_YET;

    if (blink_mode == AUTOSTART_WAIT_BLINK && cursor_column != 0)
        return NOT_YET;

    if (blink_mode == AUTOSTART_WAIT_BLINK && blnsw != 0
        && mem_read(blnsw) != 0)
        return NOT_YET;

    if (blink_mode == AUTOSTART_WAIT_BLINK)
        addr = screen_addr - line_length;
    else
        addr = screen_addr;

    for (i = 0; s[i] != '\0'; i++) {

        if (mem_read((WORD)(addr + i)) != s[i] % 64) {
            if (mem_read((WORD)(addr + i)) != (BYTE)32)
                return NO;
            return NOT_YET;
        }
    }

    return YES;
}