Ejemplo n.º 1
0
void Java_org_puder_trs80_XTRS_run(JNIEnv* env, jclass clazz) {
    clear_paste_string();
    if (!setjmp(ex_buf)) {
        screenUpdateRequired = 1;
        reset_required = 0;
        while (isRunning) {
            z80_run(0);
            if (screenUpdateRequired) {
                trigger_screen_update(isForcedScreenUpdateRequired);
            }
            if (reset_required) {
                reset_required = 0;
                clear_paste_string();
                trs_timer_init();
                trs_reset(0);
            }
        }
    } else {
        // Got not implemented exception
    }
    OpenSLWrap_Shutdown();
}
Ejemplo n.º 2
0
static void init_xtrs(JNIEnv* env, jint model, jstring romFile, Ushort entryAddr, jstring xtrsCassette,
                      jstring xtrsDisk0, jstring xtrsDisk1, jstring xtrsDisk2, jstring xtrsDisk3) {
    int debug = FALSE;

    program_name = "xtrs";
    check_endian();
    trs_model = model;
    init_emulator();

    const char* path = (*env)->GetStringUTFChars(env, romFile, NULL);
    char* dest = NULL;
    switch(model) {
    case 1:
        dest = romfile;
        break;
    case 3:
        dest = romfile3;
        break;
    case 4:
    case 5:
        dest = romfile4p;
        break;
    }
    strncpy(dest, path, FILENAME_MAX);
    (*env)->ReleaseStringUTFChars(env, romFile, path);
    trs_autodelay = 1;
    trs_emtsafe = 1;
    trs_show_led = 0;
    timer_overclock = 0;
    grafyx_set_microlabs(0);
    trs_disk_doubler = TRSDISK_BOTH;
    trs_disk_truedam = 0;
    trs_uart_name = "UART";
    trs_uart_switches = 0;
    trs_kb_bracket(0);
    mem_init();
    trs_rom_init();
    trs_screen_init();
    trs_timer_init();
    trs_reset(1);
    // Cassette
    trs_cassette_remove();
    if (xtrsCassette != NULL) {
        path = (*env)->GetStringUTFChars(env, xtrsCassette, NULL);
        trs_cassette_insert((char*) path);
        (*env)->ReleaseStringUTFChars(env, xtrsCassette, path);
    }
    // Disk 0
    trs_disk_remove(0);
    if (xtrsDisk0 != NULL) {
        path = (*env)->GetStringUTFChars(env, xtrsDisk0, NULL);
        if (ends_with(path, ".cmd")) {
            FILE* f = fopen(path, "rb");
            load_cmd(f, memory, NULL, 0, NULL, -1, NULL, &entryAddr, 1);
            fclose(f);
        } else {
            trs_disk_insert(0, (char *) path);
        }
        (*env)->ReleaseStringUTFChars(env, xtrsDisk0, path);
    }
    // Disk 1
    trs_disk_remove(1);
    if (xtrsDisk1 != NULL) {
        path = (*env)->GetStringUTFChars(env, xtrsDisk1, NULL);
        trs_disk_insert(1, (char*) path);
        (*env)->ReleaseStringUTFChars(env, xtrsDisk1, path);
    }
    // Disk 2
    trs_disk_remove(2);
    if (xtrsDisk2 != NULL) {
        path = (*env)->GetStringUTFChars(env, xtrsDisk2, NULL);
        trs_disk_insert(2, (char*) path);
        (*env)->ReleaseStringUTFChars(env, xtrsDisk2, path);
    }
    // Disk 3
    trs_disk_remove(3);
    if (xtrsDisk3 != NULL) {
        path = (*env)->GetStringUTFChars(env, xtrsDisk3, NULL);
        trs_disk_insert(3, (char*) path);
        (*env)->ReleaseStringUTFChars(env, xtrsDisk3, path);
    }

    trs_disk_init(1);
    z80_state.pc.word = entryAddr;
    clear_paste_string();
}
Ejemplo n.º 3
0
int SDLmain(int argc, char *argv[])
{
    int debug = FALSE;
    struct stat st;

    /* program_name must be set first because the error
     * printing routines use it. */
    program_name = strrchr(argv[0], '/');
    if (program_name == NULL) {
      program_name = argv[0];
    } else {
      program_name++;
    }

    check_endian();

#ifndef MACOSX
    putenv("SDL_VIDEO_CENTERED=1");
#endif	
    
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) { 
        fprintf(stderr, "Failed to initialize SDL library");
  	    exit(1);
    }
        
    /* Enable Unicode key translations */
    SDL_EnableUNICODE(TRUE); 

    argc = trs_parse_command_line(argc, argv, &debug);
    if (argc > 1) {
      fprintf(stderr, "%s: erroneous argument %s\n", program_name, argv[1]);
      exit(1);
    }
    
    trs_set_keypad_joystick();    
    trs_open_joystick();
    
    if (stat(trs_disk_dir, &st) < 0) {
      strcpy(trs_disk_dir,".");
    }                   
    if (stat(trs_hard_dir, &st) < 0) {
      strcpy(trs_hard_dir,".");
    }                   
    if (stat(trs_cass_dir, &st) < 0) {
      strcpy(trs_cass_dir,".");
    }                   
    if (stat(trs_state_dir, &st) < 0) {
      strcpy(trs_state_dir,".");
    }                   
    if (stat(trs_disk_set_dir, &st) < 0) {
      strcpy(trs_disk_set_dir,".");
    }                   
    if (stat(trs_printer_dir, &st) < 0) {
      strcpy(trs_printer_dir,".");
    }                   
 
    mem_init();
    trs_disk_init(0);
    trs_rom_init();
    trs_screen_init();
    screen_init();
    trs_timer_init();

    trs_reset(1);
    if (init_state_file[0] != 0) {
      trs_state_load(init_state_file);
      trs_screen_init();
      trs_screen_refresh();
      }
#ifdef MACOSX
	TrsOriginSet();
#endif
	
    if (!debug || fullscreen) {
      /* Run continuously until exit or request to enter debugger */
      z80_run(TRUE);
    }
    printf("Entering debugger.\n");
    debug_init();
    debug_shell();
    printf("Quitting.\n");
#ifdef MACOSX
    trs_mac_save_defaults();
#endif
    exit(0);
}