comparison blastem.c @ 690:fc04781f4d28

Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
author Michael Pavone <pavone@retrodev.com>
date Wed, 14 Jan 2015 09:38:54 -0800
parents 70de0bdf8e97
children 318ebe078315
comparison
equal deleted inserted replaced
689:858e31f977ae 690:fc04781f4d28
899 printf("Saved SRAM to %s\n", sram_filename); 899 printf("Saved SRAM to %s\n", sram_filename);
900 } 900 }
901 901
902 void init_run_cpu(genesis_context * gen, FILE * address_log, char * statefile, uint8_t * debugger) 902 void init_run_cpu(genesis_context * gen, FILE * address_log, char * statefile, uint8_t * debugger)
903 { 903 {
904 m68k_context context;
905 m68k_options opts; 904 m68k_options opts;
906 gen->m68k = &context;
907 memmap_chunk memmap[MAX_MAP_CHUNKS]; 905 memmap_chunk memmap[MAX_MAP_CHUNKS];
908 uint32_t num_chunks; 906 uint32_t num_chunks;
909 void * initial_mapped = NULL; 907 void * initial_mapped = NULL;
910 gen->save_ram = NULL; 908 gen->save_ram = NULL;
911 //TODO: Handle carts larger than 4MB 909 //TODO: Handle carts larger than 4MB
996 } 994 }
997 atexit(save_sram); 995 atexit(save_sram);
998 } 996 }
999 init_m68k_opts(&opts, memmap, num_chunks, MCLKS_PER_68K); 997 init_m68k_opts(&opts, memmap, num_chunks, MCLKS_PER_68K);
1000 opts.address_log = address_log; 998 opts.address_log = address_log;
1001 init_68k_context(&context, opts.gen.native_code_map, &opts); 999 m68k_context *context = init_68k_context(&opts);
1002 1000 gen->m68k = context;
1003 context.video_context = gen->vdp; 1001
1004 context.system = gen; 1002 context->video_context = gen->vdp;
1003 context->system = gen;
1005 //cartridge ROM 1004 //cartridge ROM
1006 context.mem_pointers[0] = cart; 1005 context->mem_pointers[0] = cart;
1007 context.target_cycle = context.sync_cycle = mclk_target; 1006 context->target_cycle = context->sync_cycle = mclk_target;
1008 //work RAM 1007 //work RAM
1009 context.mem_pointers[1] = ram; 1008 context->mem_pointers[1] = ram;
1010 //save RAM/map 1009 //save RAM/map
1011 context.mem_pointers[2] = initial_mapped; 1010 context->mem_pointers[2] = initial_mapped;
1012 context.mem_pointers[3] = (uint16_t *)gen->save_ram; 1011 context->mem_pointers[3] = (uint16_t *)gen->save_ram;
1013 uint32_t address; 1012 uint32_t address;
1014 address = cart[2] << 16 | cart[3]; 1013 address = cart[2] << 16 | cart[3];
1015 translate_m68k_stream(address, &context); 1014 translate_m68k_stream(address, context);
1016 if (statefile) { 1015 if (statefile) {
1017 uint32_t pc = load_gst(gen, statefile); 1016 uint32_t pc = load_gst(gen, statefile);
1018 if (!pc) { 1017 if (!pc) {
1019 fprintf(stderr, "Failed to load save state %s\n", statefile); 1018 fprintf(stderr, "Failed to load save state %s\n", statefile);
1020 exit(1); 1019 exit(1);
1021 } 1020 }
1022 printf("Loaded %s\n", statefile); 1021 printf("Loaded %s\n", statefile);
1023 if (debugger) { 1022 if (debugger) {
1024 insert_breakpoint(&context, pc, debugger); 1023 insert_breakpoint(context, pc, debugger);
1025 } 1024 }
1026 adjust_int_cycle(gen->m68k, gen->vdp); 1025 adjust_int_cycle(gen->m68k, gen->vdp);
1027 start_68k_context(&context, pc); 1026 start_68k_context(context, pc);
1028 } else { 1027 } else {
1029 if (debugger) { 1028 if (debugger) {
1030 insert_breakpoint(&context, address, debugger); 1029 insert_breakpoint(context, address, debugger);
1031 } 1030 }
1032 m68k_reset(&context); 1031 m68k_reset(context);
1033 } 1032 }
1034 } 1033 }
1035 1034
1036 char title[64]; 1035 char title[64];
1037 1036