Mercurial > repos > blastem
comparison blastem.c @ 832:0433fdd9ba66
Added a command line option to force BlastEm to not open a new terminal even if it detects that stdin/out are not terminals
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 19 Oct 2015 19:16:28 -0700 |
parents | ab017fb09e77 |
children | f2cd380adebe |
comparison
equal
deleted
inserted
replaced
831:079eb395ddd1 | 832:0433fdd9ba66 |
---|---|
12 #include "blastem.h" | 12 #include "blastem.h" |
13 #include "gdb_remote.h" | 13 #include "gdb_remote.h" |
14 #include "gst.h" | 14 #include "gst.h" |
15 #include "util.h" | 15 #include "util.h" |
16 #include "romdb.h" | 16 #include "romdb.h" |
17 #include "terminal.h" | |
17 #include <stdio.h> | 18 #include <stdio.h> |
18 #include <stdlib.h> | 19 #include <stdlib.h> |
19 #include <string.h> | 20 #include <string.h> |
20 #include <ctype.h> | 21 #include <ctype.h> |
21 | 22 |
235 --exit_after; | 236 --exit_after; |
236 if (!exit_after) { | 237 if (!exit_after) { |
237 exit(0); | 238 exit(0); |
238 } | 239 } |
239 } | 240 } |
240 | 241 |
241 vdp_adjust_cycles(v_context, mclks); | 242 vdp_adjust_cycles(v_context, mclks); |
242 io_adjust_cycles(gen->ports, context->current_cycle, mclks); | 243 io_adjust_cycles(gen->ports, context->current_cycle, mclks); |
243 io_adjust_cycles(gen->ports+1, context->current_cycle, mclks); | 244 io_adjust_cycles(gen->ports+1, context->current_cycle, mclks); |
244 io_adjust_cycles(gen->ports+2, context->current_cycle, mclks); | 245 io_adjust_cycles(gen->ports+2, context->current_cycle, mclks); |
245 context->current_cycle -= mclks; | 246 context->current_cycle -= mclks; |
295 genesis_context * gen = context->system; | 296 genesis_context * gen = context->system; |
296 if (vdp_port < 0x10) { | 297 if (vdp_port < 0x10) { |
297 int blocked; | 298 int blocked; |
298 uint32_t before_cycle = v_context->cycles; | 299 uint32_t before_cycle = v_context->cycles; |
299 if (vdp_port < 4) { | 300 if (vdp_port < 4) { |
300 | 301 |
301 while (vdp_data_port_write(v_context, value) < 0) { | 302 while (vdp_data_port_write(v_context, value) < 0) { |
302 while(v_context->flags & FLAG_DMA_RUN) { | 303 while(v_context->flags & FLAG_DMA_RUN) { |
303 vdp_run_dma_done(v_context, gen->frame_end); | 304 vdp_run_dma_done(v_context, gen->frame_end); |
304 if (v_context->cycles >= gen->frame_end) { | 305 if (v_context->cycles >= gen->frame_end) { |
305 context->current_cycle = v_context->cycles; | 306 context->current_cycle = v_context->cycles; |
443 context->current_cycle += 3 * MCLKS_PER_Z80; | 444 context->current_cycle += 3 * MCLKS_PER_Z80; |
444 //TODO: add cycle for an access right after a previous one | 445 //TODO: add cycle for an access right after a previous one |
445 //TODO: Below cycle time is an estimate based on the time between 68K !BG goes low and Z80 !MREQ goes high | 446 //TODO: Below cycle time is an estimate based on the time between 68K !BG goes low and Z80 !MREQ goes high |
446 // Needs a new logic analyzer capture to get the actual delay on the 68K side | 447 // Needs a new logic analyzer capture to get the actual delay on the 68K side |
447 gen->m68k->current_cycle += 8 * MCLKS_PER_68K; | 448 gen->m68k->current_cycle += 8 * MCLKS_PER_68K; |
448 | 449 |
449 | 450 |
450 vdp_port &= 0x1F; | 451 vdp_port &= 0x1F; |
451 uint16_t ret; | 452 uint16_t ret; |
452 if (vdp_port < 0x10) { | 453 if (vdp_port < 0x10) { |
453 //These probably won't currently interact well with the 68K accessing the VDP | 454 //These probably won't currently interact well with the 68K accessing the VDP |
454 vdp_run_context(gen->vdp, context->current_cycle); | 455 vdp_run_context(gen->vdp, context->current_cycle); |
792 } | 793 } |
793 | 794 |
794 void init_run_cpu(genesis_context * gen, rom_info *rom, FILE * address_log, char * statefile, uint8_t * debugger) | 795 void init_run_cpu(genesis_context * gen, rom_info *rom, FILE * address_log, char * statefile, uint8_t * debugger) |
795 { | 796 { |
796 m68k_options opts; | 797 m68k_options opts; |
797 | 798 |
798 gen->save_type = rom->save_type; | 799 gen->save_type = rom->save_type; |
799 if (gen->save_type != SAVE_NONE) { | 800 if (gen->save_type != SAVE_NONE) { |
800 gen->save_ram_mask = rom->save_mask; | 801 gen->save_ram_mask = rom->save_mask; |
801 gen->save_size = rom->save_size; | 802 gen->save_size = rom->save_size; |
802 gen->save_storage = rom->save_buffer; | 803 gen->save_storage = rom->save_buffer; |
815 eeprom_init(&gen->eeprom, gen->save_storage, gen->save_size); | 816 eeprom_init(&gen->eeprom, gen->save_storage, gen->save_size); |
816 } | 817 } |
817 } else { | 818 } else { |
818 gen->save_storage = NULL; | 819 gen->save_storage = NULL; |
819 } | 820 } |
820 | 821 |
821 init_m68k_opts(&opts, rom->map, rom->map_chunks, MCLKS_PER_68K); | 822 init_m68k_opts(&opts, rom->map, rom->map_chunks, MCLKS_PER_68K); |
822 opts.address_log = address_log; | 823 opts.address_log = address_log; |
823 m68k_context *context = init_68k_context(&opts); | 824 m68k_context *context = init_68k_context(&opts); |
824 gen->m68k = context; | 825 gen->m68k = context; |
825 | 826 |
829 { | 830 { |
830 if (rom->map[i].flags & MMAP_PTR_IDX) { | 831 if (rom->map[i].flags & MMAP_PTR_IDX) { |
831 context->mem_pointers[rom->map[i].ptr_index] = rom->map[i].buffer; | 832 context->mem_pointers[rom->map[i].ptr_index] = rom->map[i].buffer; |
832 } | 833 } |
833 } | 834 } |
834 | 835 |
835 if (statefile) { | 836 if (statefile) { |
836 uint32_t pc = load_gst(gen, statefile); | 837 uint32_t pc = load_gst(gen, statefile); |
837 if (!pc) { | 838 if (!pc) { |
838 fatal_error("Failed to load save state %s\n", statefile); | 839 fatal_error("Failed to load save state %s\n", statefile); |
839 } | 840 } |
957 if (i >= argc) { | 958 if (i >= argc) { |
958 fatal_error("-s must be followed by a savestate filename\n"); | 959 fatal_error("-s must be followed by a savestate filename\n"); |
959 } | 960 } |
960 statefile = argv[i]; | 961 statefile = argv[i]; |
961 break; | 962 break; |
963 case 't': | |
964 force_no_terminal(); | |
965 break; | |
962 case 'y': | 966 case 'y': |
963 ym_log = 1; | 967 ym_log = 1; |
964 break; | 968 break; |
965 case 'h': | 969 case 'h': |
966 info_message( | 970 info_message( |