예제 #1
0
int init_vice(const char *c64Dir) {
	printf("Initing vice from %s", c64Dir);
	maincpu_early_init();
	machine_setup_context();
	drive_setup_context();
	machine_early_init();
	sysfile_init("C64");
	gfxoutput_early_init();
	if(init_resources() < 0) {
		archdep_startup_log_error("Failed to init resources");
		return -1;
	}

	if(resources_set_defaults() < 0) {
		archdep_startup_log_error("Cannot set defaults.\n");
		return -2;
	}

	resources_set_int("SidResidSampling", 0);
	resources_set_int("VICIIVideoCache", 0);
	resources_set_string("Directory", c64Dir);
	if(init_main() < 0) {
		archdep_startup_log_error("Failed to init main");
		return -3;
	}

	fprintf(stderr, "All is OK");
	return 0;
}
예제 #2
0
JNIEXPORT void JNICALL Java_com_ssb_droidsound_plugins_VICEPlugin_N_1setDataDir(JNIEnv *env, jclass cl, jstring path)
{
    const char* cpath = env->GetStringUTFChars(path, 0);

    __android_log_print(ANDROID_LOG_VERBOSE, "VICEPlugin", "setRootDir() to %s", cpath);
    maincpu_early_init();
    machine_setup_context();
    drive_setup_context();
    machine_early_init();
    sysfile_init("C64");

    gfxoutput_early_init(0);

    if (init_resources() < 0)
    {
        archdep_startup_log_error("Failed to init resources");
        return;
    }

    /* Set factory defaults.  */
    if (resources_set_defaults() < 0)
    {
        archdep_startup_log_error("Cannot set defaults.\n");
        return;
    }

    resources_set_int("SidResidSampling", 0);
    resources_set_int("VICIIVideoCache", 0);
    resources_set_string("Directory", cpath);

    if (init_main() < 0)
    {
        archdep_startup_log_error("Failed to init main");
        return;
    }

    env->ReleaseStringUTFChars(path, cpath);
}
예제 #3
0
파일: main.c 프로젝트: r-type/vice-libretro
/* This is the main program entry point.  Call this from `main()'.  */
int main_program(int argc, char **argv)
{
    int i, n;
    char *program_name;
    char *tmp;
    int ishelp = 0;

    lib_init_rand();

    /* Check for -config and -console before initializing the user interface.
       -config  => use specified configuration file
       -console => no user interface
    */
    DBG(("main:early cmdline(argc:%d)\n", argc));
    for (i = 0; i < argc; i++) {
#ifndef __OS2__
        if ((!strcmp(argv[i], "-console")) || (!strcmp(argv[i], "--console"))) {
            console_mode = 1;
            video_disabled_mode = 1;
        } else
#endif
        if ((!strcmp(argv[i], "-config")) || (!strcmp(argv[i], "--config"))) {
            if ((i + 1) < argc) {
                vice_config_file = lib_stralloc(argv[++i]);
            }
        } else if ((!strcmp(argv[i], "-help")) ||
                   (!strcmp(argv[i], "--help")) ||
                   (!strcmp(argv[i], "-h")) ||
                   (!strcmp(argv[i], "-?"))) {
            ishelp = 1;
        }
    }

#ifdef ENABLE_NLS
    /* gettext stuff, not needed in Gnome, but here I can
       overrule the default locale path */
    setlocale(LC_ALL, "");
    bindtextdomain(PACKAGE, NLS_LOCALEDIR);
    textdomain(PACKAGE);
#endif

    DBG(("main:archdep_init(argc:%d)\n", argc));
    if (archdep_init(&argc, argv) != 0) {
        archdep_startup_log_error("archdep_init failed.\n");
        return -1;
    }

#ifndef __LIBRETRO__
//retro fix atexit in other thread
    if (atexit(main_exit) < 0) {
        archdep_startup_log_error("atexit failed.\n");
        return -1;
    }
#endif

    maincpu_early_init();
    machine_setup_context();
    drive_setup_context();
    machine_early_init();

    /* Initialize system file locator.  */
    sysfile_init(machine_name);

    gfxoutput_early_init(ishelp);
    if ((init_resources() < 0) || (init_cmdline_options() < 0)) {
        return -1;
    }

    /* Set factory defaults.  */
    if (resources_set_defaults() < 0) {
        archdep_startup_log_error("Cannot set defaults.\n");
        return -1;
    }

    /* Initialize the user interface.  `ui_init()' might need to handle the
       command line somehow, so we call it before parsing the options.
       (e.g. under X11, the `-display' option is handled independently).  */
    DBG(("main:ui_init(argc:%d)\n", argc));
    if (!console_mode && ui_init(&argc, argv) < 0) {
        archdep_startup_log_error("Cannot initialize the UI.\n");
        return -1;
    }

#ifdef HAS_TRANSLATION
    /* set the default arch language */
    translate_arch_language_init();
#endif

    if (!ishelp) {
        /* Load the user's default configuration file.  */
        if (resources_load(NULL) < 0) {
            /* The resource file might contain errors, and thus certain
            resources might have been initialized anyway.  */
            if (resources_set_defaults() < 0) {
                archdep_startup_log_error("Cannot set defaults.\n");
                return -1;
            }
        }
    }

    if (log_init() < 0) {
        archdep_startup_log_error("Cannot startup logging system.\n");
    }

    DBG(("main:initcmdline_check_args(argc:%d)\n", argc));
    if (initcmdline_check_args(argc, argv) < 0) {
        return -1;
    }

    program_name = archdep_program_name();

    /* VICE boot sequence.  */
    log_message(LOG_DEFAULT, " ");
#ifdef USE_SVN_REVISION
    log_message(LOG_DEFAULT, "*** VICE Version %s, rev %s ***", VERSION, VICE_SVN_REV_STRING);
#else
    log_message(LOG_DEFAULT, "*** VICE Version %s ***", VERSION);
#endif
    log_message(LOG_DEFAULT, "OS compiled for: %s", platform_get_compile_time_os());
    log_message(LOG_DEFAULT, "GUI compiled for: %s", platform_get_ui());
    log_message(LOG_DEFAULT, "CPU compiled for: %s", platform_get_compile_time_cpu());
    log_message(LOG_DEFAULT, "Compiler used: %s", platform_get_compile_time_compiler());
    log_message(LOG_DEFAULT, "Current OS: %s", platform_get_runtime_os());
    log_message(LOG_DEFAULT, "Current CPU: %s", platform_get_runtime_cpu());
    log_message(LOG_DEFAULT, " ");
    if (machine_class == VICE_MACHINE_VSID) {
        log_message(LOG_DEFAULT, "Welcome to %s, the free portable SID Player.",
                    program_name);
    } else {
        log_message(LOG_DEFAULT, "Welcome to %s, the free portable %s Emulator.",
                    program_name, machine_name);
    }
    log_message(LOG_DEFAULT, " ");

    log_message(LOG_DEFAULT, "Current VICE team members:");
    tmp = lib_malloc(80);
    n = 0; *tmp = 0;
    for (i = 0; core_team[i].name; i++) {
        n += strlen(core_team[i].name);
        if (n > 74) {
            log_message(LOG_DEFAULT, tmp);
            n = 0; *tmp = 0;
        }
        strcat(tmp, core_team[i].name);
        if (core_team[i + 1].name) {
            strcat(tmp, ", ");
        } else {
            strcat(tmp, ".");
            log_message(LOG_DEFAULT, tmp);
        }
    }
    lib_free(tmp);

    log_message(LOG_DEFAULT, " ");
    log_message(LOG_DEFAULT, "This is free software with ABSOLUTELY NO WARRANTY.");
    log_message(LOG_DEFAULT, "See the \"About VICE\" command for more info.");
    log_message(LOG_DEFAULT, " ");

    lib_free(program_name);

    /* Complete the GUI initialization (after loading the resources and
       parsing the command-line) if necessary.  */
    if (!console_mode && ui_init_finish() < 0) {
        return -1;
    }

    if (!console_mode && video_init() < 0) {
        return -1;
    }

    if (initcmdline_check_psid() < 0) {
        return -1;
    }

    if (init_main() < 0) {
        return -1;
    }

    initcmdline_check_attach();

    init_done = 1;
#ifdef __LIBRETRO__
#ifndef NO_LIBCO
	resources_save("./vicerc0");
	co_switch(mainThread);
#endif
#endif
    /* Let's go...  */
    log_message(LOG_DEFAULT, "Main CPU: starting at ($FFFC).");
    maincpu_mainloop();

    log_error(LOG_DEFAULT, "perkele!");

    return 0;
}
예제 #4
0
파일: main.c 프로젝트: twinaphex/vice-next
int main_program(int argc, char **argv)
{
	int i;
	char *program_name;

	/* Check for -config, -console and -vsid before initializing the user interface.
	   -config  => use specified configuration file
	   -console => no user interface
	   -vsid    => user interface in separate process */

	console_mode = 0;
	video_disabled_mode = 0;
	vsid_mode=0;
	machine_class = VICE_MACHINE_C64;
	//machine_class = VICE_MACHINE_CBM6x0;

	archdep_init(&argc, argv);

	if (atexit(emulator_shutdown) < 0) {
		archdep_startup_log_error("atexit");
		return -1;
	}

	maincpu_early_init();
	machine_setup_context();
	drive_setup_context();
	machine_early_init();

	/* Initialize system file locator.  */
	sysfile_init(machine_name);

	gfxoutput_early_init();

	if (init_resources() < 0 || init_cmdline_options() < 0)
		return -1;

	/* Set factory defaults.  */
	if (resources_set_defaults() < 0) {
		archdep_startup_log_error("Cannot set defaults.\n");
		return -1;
	}

	/* Initialize the user interface.  `ui_init()' might need to handle the
	   command line somehow, so we call it before parsing the options.
	   (e.g. under X11, the `-display' option is handled independently).  */
	if (!console_mode && ui_init(&argc, argv) < 0) {
		archdep_startup_log_error("Cannot initialize the UI.\n");
		return -1;
	}

	if (initcmdline_check_args(argc, argv) < 0)
		return -1;

	program_name = archdep_program_name();

	/* VICE boot sequence.  */
	#if 0
	log_message(LOG_DEFAULT, "*** VICE Version %s ***", VERSION);
	log_message(LOG_DEFAULT, "OS compiled for: %s", platform_get_compile_time_os());
	log_message(LOG_DEFAULT, "GUI compiled for: %s", platform_get_ui());
	log_message(LOG_DEFAULT, "CPU compiled for: %s", platform_get_compile_time_cpu());
	log_message(LOG_DEFAULT, "Compiler used: %s", platform_get_compile_time_compiler());
	log_message(LOG_DEFAULT, "Current OS: %s", platform_get_runtime_os());
	log_message(LOG_DEFAULT, "Current CPU: %s", platform_get_runtime_cpu());
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "Welcome to %s, the free portable %s Emulator.",
			program_name, machine_name);
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "Current VICE team members:");
	log_message(LOG_DEFAULT, "A. Boose, D. Lem, T. Biczo, A. Dehmel, T. Bretz, A. Matthies,");
	log_message(LOG_DEFAULT, "M. Pottendorfer, M. Brenner, S. Trikaliotis, M. van den Heuvel,");
	log_message(LOG_DEFAULT, "C. Vogelgsang, F. Gennari, H. Nuotio, D. Kahlin, A. Lankila.");
	log_message(LOG_DEFAULT, " ");
	log_message(LOG_DEFAULT, "This is free software with ABSOLUTELY NO WARRANTY.");
	log_message(LOG_DEFAULT, "See the \"About VICE\" command for more info.");
	log_message(LOG_DEFAULT, " ");
	#endif

	lib_free(program_name);

	/* Complete the GUI initialization (after loading the resources and
	   parsing the command-line) if necessary.  */
	if (!console_mode && ui_init_finish() < 0)
		return -1;

	if (!console_mode && video_init() < 0)
		return -1;

	if (initcmdline_check_psid() < 0)
		return -1;

	if (init_main() < 0)
		return -1;

	initcmdline_check_attach();

	init_done = 1;

	/* Let's go...  */
	#ifdef CELL_DEBUG
	printf("Main CPU: starting at ($FFFC).\n");
	#endif
	maincpu_mainloop();

	#ifdef CELL_DEBUG
	printf("perkele!\n");
	#endif

	return 0;
}