Beispiel #1
0
/* this is called after successful loading */
static void autostart_finish(void)
{
    if (autostart_run_mode == AUTOSTART_MODE_RUN) {
        log_message(autostart_log, "Starting program.");
        if ((machine_class == VICE_MACHINE_C128) && (c128_column4080_key == 0)) {
            kbdbuf_feed("GRAPHIC5:");
        }
        /* log_message(autostart_log, "Run command is: '%s' (%s)", AutostartRunCommand, AutostartDelayRandom ? "delayed" : "no delay"); */
        if (AutostartDelayRandom) {
            kbdbuf_feed_runcmd(AutostartRunCommand);
        } else {
            kbdbuf_feed(AutostartRunCommand);
        }
    } else {
        log_message(autostart_log, "Program loaded.");
        if ((machine_class == VICE_MACHINE_C128) && (c128_column4080_key == 0)) {
            kbdbuf_feed("GRAPHIC5\x0d");
        }
    }
    /* printf("autostart_finish cmdline_get_autostart_mode(): %d\n", cmdline_get_autostart_mode()); */
    /* inject string given to -keybuf option on commandline into keyboard buffer */
    if (cmdline_get_autostart_mode() != AUTOSTART_MODE_NONE) {
        kbdbuf_feed_cmdline();
    }
}
Beispiel #2
0
static void advance_hastape(void)
{
    char *tmp;

    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        log_message(autostart_log, "Loading file.");
        if (autostart_program_name) {
            tmp = util_concat("LOAD\"", autostart_program_name, "\":\r", NULL);
            kbdbuf_feed(tmp);
            lib_free(tmp);
        } else {
            kbdbuf_feed("LOAD:\r");
        }
        if (tape_tap_attched()) {
            autostartmode = AUTOSTART_PRESSPLAYONTAPE;
        } else {
            autostartmode = AUTOSTART_LOADINGTAPE;
        }
        deallocate_program_name();
        break;
      case NO:
        autostart_disable();
        break;
      case NOT_YET:
        break;
    }
}
Beispiel #3
0
static void advance_hasdisk(void)
{
    char *tmp;
    int traps;

    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        if (autostart_program_name)
            log_message(autostart_log, "Loading program '%s'",
                        autostart_program_name);
        else
            log_message(autostart_log, "Loading program '*'");
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
        if (handle_drive_true_emulation) {
            resources_get_int("VirtualDevices", &traps);
            if (traps) {
                if (orig_drive_true_emulation_state)
                    log_message(autostart_log,
                                "Turning true drive emulation off.");
                set_true_drive_emulation_mode(0);
            } else {
                if (!orig_drive_true_emulation_state)
                    log_message(autostart_log,
                                "Turning true drive emulation on.");
                set_true_drive_emulation_mode(1);
            }
        } else {
            traps = 1;
        }
        if (autostart_program_name)
            tmp = lib_msprintf("LOAD\"%s\",8,1:\r", autostart_program_name);
        else
            tmp = lib_stralloc("LOAD\"*\",8,1:\r");
        kbdbuf_feed(tmp);
        lib_free(tmp);

        if (!traps) {
            if (autostart_run_mode == AUTOSTART_MODE_RUN)
                kbdbuf_feed(AutostartRunCommand);
            autostartmode = AUTOSTART_DONE;
        } else {
            autostartmode = AUTOSTART_LOADINGDISK;
            machine_bus_attention_callback_set(disk_attention_callback);
        }
        deallocate_program_name();
        break;
      case NO:
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
        autostart_disable();
        break;
      case NOT_YET:
        break;
    }
}
Beispiel #4
0
/* This hook is called at the end of every frame.  */
static void machine_vsync_hook(void)
{
    int i;
    unsigned int playtime;
    static unsigned int time = 0;

    if (vsid_autostart_delay > 0) {
        if (-- vsid_autostart_delay == 0) {
            log_message(c64_log, "Triggering VSID autoload");
            psid_init_tune(0);
            for (i = 0; i < vsid_autostart_length; i += 1) {
                mem_inject((WORD)(vsid_autostart_load_addr + i), vsid_autostart_data[i]);
            }
            mem_set_basic_text(vsid_autostart_load_addr, vsid_autostart_load_addr + vsid_autostart_length);
            kbdbuf_feed("RUN\r");
        }
    }

    playtime = (psid_increment_frames() * machine_timing.cycles_per_rfsh) / machine_timing.cycles_per_sec;
    if (playtime != time) {
        vsid_ui_display_time(playtime);
        time = playtime;
    }
    clk_guard_prevent_overflow(maincpu_clk_guard);
}
Beispiel #5
0
/* This function is called by the `serialreceivebyte()' trap as soon as EOF
   is reached.  */
static void disk_eof_callback(void)
{
    if (handle_drive_true_emulation_overridden) {
        BYTE id[2], *buffer;
        unsigned int track, sector;

        if (orig_drive_true_emulation_state) {
            log_message(autostart_log, "Turning true drive emulation on.");
            vdrive_bam_get_disk_id(8, id);
            vdrive_get_last_read(&track, &sector, &buffer);
        }
        set_true_drive_emulation_mode(orig_drive_true_emulation_state);
        if (orig_drive_true_emulation_state) {
            drive_set_disk_memory(id, track, sector, drive_context[0]);
            drive_set_last_read(track, sector, buffer, drive_context[0]);
        }
    }

    if (autostartmode != AUTOSTART_NONE) {
        if (autostart_run_mode == AUTOSTART_MODE_RUN) {
            log_message(autostart_log, "Starting program.");
            kbdbuf_feed(AutostartRunCommand);
        }
        else {
            log_message(autostart_log, "Program loaded.");
        }
    }
    
    autostart_done();

    machine_bus_eof_callback_set(NULL);

    disable_warp_if_was_requested();
}
Beispiel #6
0
/* Initialization.  */
void kbdbuf_init(int location, int plocation, int size, CLOCK mincycles)
{
    kbdbuf_reset(location, plocation, size, mincycles);

    if (kbd_buf_string != NULL)
        kbdbuf_feed(kbd_buf_string);
}
Beispiel #7
0
/* This function is called by the `serialattention()' trap before
   returning.  */
static void disk_attention_callback(void)
{
    if (autostart_run_mode == AUTOSTART_MODE_RUN)
        kbdbuf_feed(AutostartRunCommand);

    machine_bus_attention_callback_set(NULL);

    /* Next step is waiting for end of loading, to turn true drive emulation
       on.  */
    machine_bus_eof_callback_set(disk_eof_callback);
}
Beispiel #8
0
void kbdbuf_feed_cmdline(void)
{
    /* printf("kbdbuf_feed_cmdline\n"); */
    if (kbd_buf_string != NULL) {
        /* printf("kbdbuf_feed_cmdline: %d '%s'\n", KbdbufDelay, kbd_buf_string); */
        if (KbdbufDelay) {
            kbdbuf_feed_runcmd(kbd_buf_string);
        } else {
            kbdbuf_feed(kbd_buf_string);
        }
    }
}
Beispiel #9
0
static void advance_loadingtape(void)
{
    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        log_message(autostart_log, "Starting program.");
        kbdbuf_feed(AutostartRunCommand);
        autostartmode = AUTOSTART_DONE;
        break;
      case NO:
        autostart_disable();
        break;
      case NOT_YET:
        break;
    }
}
Beispiel #10
0
static void advance_loadingtape(void)
{
    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        disable_warp_if_was_requested();

        if (autostart_run_mode == AUTOSTART_MODE_RUN) {
            log_message(autostart_log, "Starting program.");
            kbdbuf_feed(AutostartRunCommand);
        }
        autostart_done();
        break;
      case NO:
        disable_warp_if_was_requested();
        autostart_disable();
        break;
      case NOT_YET:
        /* leave autostart and disable warp if ROM area was left */
        check_rom_area();
        break;
    }
}
Beispiel #11
0
static void advance_waitloadready(void)
{    
    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        //log_message(autostart_log, "Ready");
        disable_warp_if_was_requested();
        autostartmode = AUTOSTART_DONE;

        if (autostart_run_mode == AUTOSTART_MODE_RUN) {
            kbdbuf_feed(AutostartRunCommand);
            //log_message(autostart_log, "Running program");
        }
        break;
      case NO:
        //log_message(autostart_log, "NO Ready");
        disable_warp_if_was_requested();
        autostart_disable();
        break;
      case NOT_YET:
        /* leave autostart and disable warp if ROM area was left */
        check_rom_area();
        break;
    }
}
Beispiel #12
0
static void advance_hasdisk(void)
{
    char *tmp;
    int traps;

    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
      case YES:
        if (autostart_program_name)
            log_message(autostart_log, "Loading program '%s'",
                        autostart_program_name);
        else
            log_message(autostart_log, "Loading program '*'");
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
        if (handle_drive_true_emulation_overridden) {
            resources_get_int("VirtualDevices", &traps);
            if (traps) {
                if (orig_drive_true_emulation_state)
                    log_message(autostart_log,
                                "Turning true drive emulation off.");
                set_true_drive_emulation_mode(0);
            } else {
                if (!orig_drive_true_emulation_state)
                    log_message(autostart_log,
                                "Turning true drive emulation on.");
                set_true_drive_emulation_mode(1);
            }
        } else {
            if (!orig_drive_true_emulation_state) {
                traps = 1;
            } else {
                traps = 0;
            }
        }
        tmp = lib_msprintf("LOAD\"%s\",8%s:\r", 
            autostart_program_name ?
              autostart_program_name : "*",
            autostart_basic_load ? "" : ",1");
        kbdbuf_feed(tmp);
        lib_free(tmp);

        if (!traps) {
            if (AutostartWarp) {
                autostartmode = AUTOSTART_WAITSEARCHINGFOR;
            } else {
                /* be most compatible if warp is disabled */
                if (autostart_run_mode == AUTOSTART_MODE_RUN) {
                    kbdbuf_feed(AutostartRunCommand);
                }
                autostart_done();
            }
        } else {
            autostartmode = AUTOSTART_LOADINGDISK;
            machine_bus_attention_callback_set(disk_attention_callback);
        }

        deallocate_program_name();
        break;
      case NO:
        orig_drive_true_emulation_state = get_true_drive_emulation_state();
        disable_warp_if_was_requested();
        autostart_disable();
        break;
      case NOT_YET:
        break;
    }
}
Beispiel #13
0
static void advance_hasdisk(void)
{
    char *tmp, *temp_name;
    int traps;

    switch (check("READY.", AUTOSTART_WAIT_BLINK)) {
        case YES:

            /* autostart_program_name may be petscii or ascii at this point,
               ANDing the charcodes with 0x7f here is a cheap way to prevent
               illegal characters in the printed message */
            if (autostart_program_name) {
                temp_name = tmp = lib_stralloc(autostart_program_name);
                while (*tmp) {
                    *tmp++ &= 0x7f;
                }
                log_message(autostart_log, "Loading program '%s'", temp_name);
                lib_free(temp_name);
            } else {
                log_message(autostart_log, "Loading program '*'");
            }

            orig_drive_true_emulation_state = get_true_drive_emulation_state();
            if (handle_drive_true_emulation_overridden) {
                resources_get_int("VirtualDevices", &traps);
                if (traps) {
                    if (orig_drive_true_emulation_state) {
                        log_message(autostart_log,
                                    "Turning true drive emulation off.");
                    }
                    set_true_drive_emulation_mode(0);
                } else {
                    if (!orig_drive_true_emulation_state) {
                        log_message(autostart_log,
                                    "Turning true drive emulation on.");
                    }
                    set_true_drive_emulation_mode(1);
                }
            } else {
                if (!orig_drive_true_emulation_state) {
                    traps = 1;
                } else {
                    traps = 0;
                }
            }

            tmp = lib_msprintf("LOAD\"%s\",8%s:\r",
                               autostart_program_name ?
                               autostart_program_name : "*",
                               autostart_basic_load ? "" : ",1");
            DBG(("advance_hasdisk '%s'", tmp));
            kbdbuf_feed(tmp);
            lib_free(tmp);

            if (!traps) {
                if (AutostartWarp) {
                    autostartmode = AUTOSTART_WAITSEARCHINGFOR;
                } else {
                    /* be most compatible if warp is disabled */
                    autostart_finish();
                    autostart_done();
                }
            } else {
                autostartmode = AUTOSTART_LOADINGDISK;
                machine_bus_attention_callback_set(disk_attention_callback);
            }

            deallocate_program_name();
            break;
        case NO:
            orig_drive_true_emulation_state = get_true_drive_emulation_state();
            disable_warp_if_was_requested();
            autostart_disable();
            break;
        case NOT_YET:
            break;
    }
}
Beispiel #14
0
int kbdbuf_feed_string(const char *string)
{
    kbd_buf_parse_string(string);

    return kbdbuf_feed(kbd_buf_string);
}