diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-10-19 19:16:28 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-10-19 19:16:28 -0700 |
commit | da5249a364aac3ec1b6d28dd7200cf6cdd9a2913 (patch) | |
tree | e7edeec1163420ca06c59eacc88917fa72c8d110 | |
parent | 70a4bf6d6b7c79c936e96fc8e3cceb96c125695a (diff) |
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
-rw-r--r-- | blastem.c | 18 | ||||
-rw-r--r-- | terminal.c | 12 | ||||
-rw-r--r-- | terminal.h | 1 | ||||
-rw-r--r-- | terminal_win.c | 9 |
4 files changed, 29 insertions, 11 deletions
@@ -14,6 +14,7 @@ #include "gst.h" #include "util.h" #include "romdb.h" +#include "terminal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -237,7 +238,7 @@ m68k_context * sync_components(m68k_context * context, uint32_t address) 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 @@ m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, uint16_ 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 @@ uint8_t z80_vdp_port_read(uint32_t vdp_port, void * vcontext) //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 persist_save() 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 @@ void init_run_cpu(genesis_context * gen, rom_info *rom, FILE * address_log, char } 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 @@ void init_run_cpu(genesis_context * gen, rom_info *rom, FILE * address_log, char 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 @@ int main(int argc, char ** argv) } statefile = argv[i]; break; + case 't': + force_no_terminal(); + break; case 'y': ym_log = 1; break; @@ -17,9 +17,15 @@ void cleanup_terminal() 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 @@ void init_terminal() //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 @@ void init_terminal() } } } - + init_done = 1; } } @@ -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 --git a/terminal_win.c b/terminal_win.c index 1716fd4..f270308 100644 --- a/terminal_win.c +++ b/terminal_win.c @@ -1,13 +1,20 @@ #include <windows.h> #include <stdio.h> +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; } } |