Changes in emu/main.c [1efc42c:0edef06] in buchla-emu


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/main.c

    r1efc42c r0edef06  
    2525static verb_flag_t verb_flags[] = {
    2626        { "sdl", &sdl_verbose },
     27        { "gdb", &gdb_verbose },
    2728        { "cpu", &cpu_verbose },
    2829        { "fpu", &fpu_verbose },
     
    4041const char *bios = "bios.abs";
    4142const char *disk = "buchla.disk";
     43const char *font = "ttf/vera-sans-mono.ttf";
     44
     45SDL_atomic_t run;
    4246
    4347static void usage(FILE *fh)
    4448{
    45         fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk]\n");
     49        fprintf(fh, "usage: buchla [-h] [-v comp [-v comp [...]]] [-b bios] [-d disk] [-f font]\n");
    4650        fprintf(fh, "where comp is one of: ");
    4751
     
    8387                }
    8488
     89                if (strcmp(argv[i], "-f") == 0) {
     90                        if (++i == argc) {
     91                                usage(stderr);
     92                                fprintf(stderr, "missing argument to -f\n");
     93                                exit(1);
     94                        }
     95
     96                        font = argv[i];
     97                        continue;
     98                }
     99
    85100                if (strcmp(argv[i], "-v") == 0) {
    86101                        if (++i == argc) {
     
    118133}
    119134
     135static int32_t cpu_thread(void *data)
     136{
     137        (void)data;
     138
     139        cpu_loop();
     140        return 0;
     141}
     142
     143static int32_t gdb_thread(void *data)
     144{
     145        (void)data;
     146
     147        gdb_loop();
     148        return 0;
     149}
     150
    120151int32_t main(int32_t argc, char *argv[])
    121152{
    122153        parse_args(argc, argv);
    123154        sdl_init();
     155        gdb_init();
     156        cpu_init();
    124157
    125         cpu_loop();
     158        SDL_AtomicSet(&run, 1);
     159        SDL_Thread *thr_cpu = SDL_CreateThread(cpu_thread, "cpu", NULL);
    126160
     161        if (thr_cpu == NULL) {
     162                fail("SDL_CreateThread() failed: %s", SDL_GetError());
     163        }
     164
     165        SDL_Thread *thr_gdb = SDL_CreateThread(gdb_thread, "gdb", NULL);
     166
     167        if (thr_gdb == NULL) {
     168                fail("SDL_CreateThread() failed: %s", SDL_GetError());
     169        }
     170
     171        sdl_loop();
     172
     173        SDL_WaitThread(thr_cpu, NULL);
     174        SDL_WaitThread(thr_gdb, NULL);
     175
     176        cpu_quit();
     177        gdb_quit();
    127178        sdl_quit();
    128179        return 0;
Note: See TracChangeset for help on using the changeset viewer.