# HG changeset patch # User Michael Pavone # Date 1447026717 28800 # Node ID 7022ba865cfd167ca13002d465b50ac347a0c676 # Parent f364f4f22f8f8037e83dfe6eda61cfa8a483b451 Initial work for allowing loading a ROM from menu diff -r f364f4f22f8f -r 7022ba865cfd blastem.c --- a/blastem.c Fri Nov 06 19:47:58 2015 -0800 +++ b/blastem.c Sun Nov 08 15:51:57 2015 -0800 @@ -171,6 +171,9 @@ }*/ context->target_cycle = context->int_cycle < context->sync_cycle ? context->int_cycle : context->sync_cycle; + if (context->should_return) { + context->target_cycle = context->current_cycle; + } /*printf("Cyc: %d, Trgt: %d, Int Cyc: %d, Int: %d, Mask: %X, V: %d, H: %d, HICount: %d, HReg: %d, Line: %d\n", context->current_cycle, context->target_cycle, context->int_cycle, context->int_num, (context->status & 0x7), v_context->regs[REG_MODE_2] & 0x20, v_context->regs[REG_MODE_1] & 0x10, v_context->hint_counter, v_context->regs[REG_HINT], v_context->cycles / MCLKS_LINE);*/ @@ -1016,7 +1019,7 @@ //Temporary hack until UI is in place if (!(rom_size = load_rom("/mnt/sdcard/rom.bin"))) { fatal_error("Failed to open /mnt/sdcard/rom.bin for reading"); - + } romfname = "/mnt/sdcard/rom.bin"; loaded = 1; diff -r f364f4f22f8f -r 7022ba865cfd m68k_core.h --- a/m68k_core.h Fri Nov 06 19:47:58 2015 -0800 +++ b/m68k_core.h Sun Nov 08 15:51:57 2015 -0800 @@ -59,11 +59,12 @@ uint32_t int_num; uint16_t *mem_pointers[NUM_MEM_AREAS]; void *video_context; - + void *resume_pc; native_map_slot *native_code_map; m68k_options *options; void *system; uint8_t int_pending; + uint8_t should_return; uint8_t ram_code_flags[]; } m68k_context; diff -r f364f4f22f8f -r 7022ba865cfd m68k_core_x86.c --- a/m68k_core_x86.c Fri Nov 06 19:47:58 2015 -0800 +++ b/m68k_core_x86.c Sun Nov 08 15:51:57 2015 -0800 @@ -2509,7 +2509,14 @@ mov_rr(code, RAX, opts->gen.context_reg, SZ_PTR); jmp(code, opts->gen.load_context); *skip_sync = code->cur - (skip_sync+1); + cmp_irdisp(code, 0, opts->gen.context_reg, offsetof(m68k_context, should_return), SZ_B); + code_ptr do_ret = code->cur + 1; + jcc(code, CC_NZ, do_ret); retn(code); + *do_ret = code->cur - (do_ret+1); + pop_r(code, opts->gen.scratch1); + retn(code); + mov_rrdisp(code, opts->gen.scratch1, opts->gen.context_reg, offsetof(m68k_context, resume_pc), SZ_PTR); *do_int = code->cur - (do_int+1); //implement 1 instruction latency cmp_irdisp(code, 0, opts->gen.context_reg, offsetof(m68k_context, int_pending), SZ_B); diff -r f364f4f22f8f -r 7022ba865cfd menu.c --- a/menu.c Fri Nov 06 19:47:58 2015 -0800 +++ b/menu.c Sun Nov 08 15:51:57 2015 -0800 @@ -127,6 +127,9 @@ } break; } + case 2: + m68k->should_return = 1; + break; default: fprintf(stderr, "WARNING: write to undefined menu port %X\n", address); } diff -r f364f4f22f8f -r 7022ba865cfd menu.s68 --- a/menu.s68 Fri Nov 06 19:47:58 2015 -0800 +++ b/menu.s68 Sun Nov 08 15:51:57 2015 -0800 @@ -289,6 +289,8 @@ tst.b (-1, a2) bne enter_dir ;regular file + lea menu_port+8, a3 + move.l a2, (a3) rte enter_dir: lea menu_port+4, a3