summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-11-08 15:51:57 -0800
committerMichael Pavone <pavone@retrodev.com>2015-11-08 15:51:57 -0800
commitc125d82e2076aad6d24062212c55e5db834cd90c (patch)
treed7dde6fdb87a935ae431517da1e609b1b9e7506b
parente4c347d394fc7ee86e8c7bb6d10029ad7157a6d5 (diff)
Initial work for allowing loading a ROM from menu
-rw-r--r--blastem.c5
-rw-r--r--m68k_core.h3
-rw-r--r--m68k_core_x86.c7
-rw-r--r--menu.c3
-rw-r--r--menu.s682
5 files changed, 18 insertions, 2 deletions
diff --git a/blastem.c b/blastem.c
index 55a22ab..c1208b4 100644
--- a/blastem.c
+++ b/blastem.c
@@ -171,6 +171,9 @@ void adjust_int_cycle(m68k_context * context, vdp_context * v_context)
}*/
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 @@ int main(int argc, char ** argv)
//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 --git a/m68k_core.h b/m68k_core.h
index 86aed4c..b796061 100644
--- a/m68k_core.h
+++ b/m68k_core.h
@@ -59,11 +59,12 @@ typedef struct {
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 --git a/m68k_core_x86.c b/m68k_core_x86.c
index 62f0d6a..fca07b5 100644
--- a/m68k_core_x86.c
+++ b/m68k_core_x86.c
@@ -2509,7 +2509,14 @@ void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chu
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 --git a/menu.c b/menu.c
index d5dd26d..40b17bb 100644
--- a/menu.c
+++ b/menu.c
@@ -127,6 +127,9 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value)
}
break;
}
+ case 2:
+ m68k->should_return = 1;
+ break;
default:
fprintf(stderr, "WARNING: write to undefined menu port %X\n", address);
}
diff --git a/menu.s68 b/menu.s68
index fbee8d7..a8902c0 100644
--- a/menu.s68
+++ b/menu.s68
@@ -289,6 +289,8 @@ start_pressed:
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