# HG changeset patch # User Michael Pavone # Date 1445307388 25200 # Node ID 0433fdd9ba667647f72b71ac5af9384aa6c5c1bb # Parent 079eb395ddd113c5260302e199220f90c1ed1ed5 Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals diff -r 079eb395ddd1 -r 0433fdd9ba66 blastem.c --- a/blastem.c Mon Oct 19 19:15:42 2015 -0700 +++ b/blastem.c Mon Oct 19 19:16:28 2015 -0700 @@ -14,6 +14,7 @@ #include "gst.h" #include "util.h" #include "romdb.h" +#include "terminal.h" #include #include #include @@ -237,7 +238,7 @@ exit(0); } } - + vdp_adjust_cycles(v_context, mclks); io_adjust_cycles(gen->ports, context->current_cycle, mclks); io_adjust_cycles(gen->ports+1, context->current_cycle, mclks); @@ -297,7 +298,7 @@ int blocked; uint32_t before_cycle = v_context->cycles; if (vdp_port < 4) { - + while (vdp_data_port_write(v_context, value) < 0) { while(v_context->flags & FLAG_DMA_RUN) { vdp_run_dma_done(v_context, gen->frame_end); @@ -445,8 +446,8 @@ //TODO: Below cycle time is an estimate based on the time between 68K !BG goes low and Z80 !MREQ goes high // Needs a new logic analyzer capture to get the actual delay on the 68K side gen->m68k->current_cycle += 8 * MCLKS_PER_68K; - - + + vdp_port &= 0x1F; uint16_t ret; if (vdp_port < 0x10) { @@ -794,7 +795,7 @@ void init_run_cpu(genesis_context * gen, rom_info *rom, FILE * address_log, char * statefile, uint8_t * debugger) { m68k_options opts; - + gen->save_type = rom->save_type; if (gen->save_type != SAVE_NONE) { gen->save_ram_mask = rom->save_mask; @@ -817,7 +818,7 @@ } else { gen->save_storage = NULL; } - + init_m68k_opts(&opts, rom->map, rom->map_chunks, MCLKS_PER_68K); opts.address_log = address_log; m68k_context *context = init_68k_context(&opts); @@ -831,7 +832,7 @@ context->mem_pointers[rom->map[i].ptr_index] = rom->map[i].buffer; } } - + if (statefile) { uint32_t pc = load_gst(gen, statefile); if (!pc) { @@ -959,6 +960,9 @@ } statefile = argv[i]; break; + case 't': + force_no_terminal(); + break; case 'y': ym_log = 1; break; diff -r 079eb395ddd1 -r 0433fdd9ba66 terminal.c --- a/terminal.c Mon Oct 19 19:15:42 2015 -0700 +++ b/terminal.c Mon Oct 19 19:16:28 2015 -0700 @@ -17,9 +17,15 @@ unlink(OUTPUT_PATH); } +static char init_done; + +void force_no_terminal() +{ + init_done = 1; +} + void init_terminal() { - static char init_done; if (!init_done) { if (!(isatty(STDIN_FILENO) && isatty(STDOUT_FILENO))) { #ifndef __APPLE__ @@ -32,7 +38,7 @@ //create FIFOs for talking to helper process in terminal app mkfifo(INPUT_PATH, 0666); mkfifo(OUTPUT_PATH, 0666); - + //close existing file descriptors close(STDIN_FILENO); close(STDOUT_FILENO); @@ -59,7 +65,7 @@ } } } - + init_done = 1; } } diff -r 079eb395ddd1 -r 0433fdd9ba66 terminal.h --- a/terminal.h Mon Oct 19 19:15:42 2015 -0700 +++ b/terminal.h Mon Oct 19 19:16:28 2015 -0700 @@ -2,6 +2,7 @@ #define TERMINAL_H_ void init_terminal(); +void force_no_terminal(); #define INPUT_PATH "/tmp/blastem_input" #define OUTPUT_PATH "/tmp/blastem_output" diff -r 079eb395ddd1 -r 0433fdd9ba66 terminal_win.c --- a/terminal_win.c Mon Oct 19 19:15:42 2015 -0700 +++ b/terminal_win.c Mon Oct 19 19:16:28 2015 -0700 @@ -1,13 +1,20 @@ #include #include +static char init_done; + +void force_no_terminal() +{ + init_done = 1; +} + void init_terminal() { - static char init_done; if (!init_done) { AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); + init_done = 1; } }