summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2014-12-17 23:03:19 -0800
committerMichael Pavone <pavone@retrodev.com>2014-12-17 23:03:19 -0800
commit4cad512b6d7ac0f7042b90e1029626fb14788bf0 (patch)
tree5d8d24324bee0ca18a6cfa12a92ef279719f24cf
parent9dc3feb135af0a8853798bd79cff754cd86dbd0f (diff)
Get rest of emulator compiling again with Z80 core enabled
-rw-r--r--backend.h1
-rw-r--r--blastem.c51
-rw-r--r--z80_to_x86.c9
-rw-r--r--z80_to_x86.h3
4 files changed, 59 insertions, 5 deletions
diff --git a/backend.h b/backend.h
index 97e2ae4..a228d13 100644
--- a/backend.h
+++ b/backend.h
@@ -79,6 +79,7 @@ typedef struct {
#define MMAP_ONLY_ODD 0x10
#define MMAP_ONLY_EVEN 0x20
#define MMAP_FUNC_NULL 0x40
+#define MMAP_CUSTOM 0x80
typedef uint16_t (*read_16_fun)(uint32_t address, void * context);
typedef uint8_t (*read_8_fun)(uint32_t address, void * context);
diff --git a/blastem.c b/blastem.c
index 4555f86..2659fa4 100644
--- a/blastem.c
+++ b/blastem.c
@@ -383,8 +383,9 @@ m68k_context * vdp_port_write_b(uint32_t vdp_port, m68k_context * context, uint8
return vdp_port_write(vdp_port, context, vdp_port < 0x10 ? value | value << 8 : ((vdp_port & 1) ? value : 0));
}
-z80_context * z80_vdp_port_write(uint16_t vdp_port, z80_context * context, uint8_t value)
+void * z80_vdp_port_write(uint32_t vdp_port, void * vcontext, uint8_t value)
{
+ z80_context * context = vcontext;
genesis_context * gen = context->system;
if (vdp_port & 0xE0) {
printf("machine freeze due to write to Z80 address %X\n", 0x7F00 | vdp_port);
@@ -453,6 +454,34 @@ uint8_t vdp_port_read_b(uint32_t vdp_port, m68k_context * context)
}
}
+uint8_t z80_vdp_port_read(uint32_t vdp_port, void * vcontext)
+{
+ z80_context * context = vcontext;
+ if (vdp_port & 0xE0) {
+ printf("machine freeze due to read from Z80 address %X\n", 0x7F00 | vdp_port);
+ exit(1);
+ }
+ genesis_context * gen = context->system;
+ vdp_port &= 0x1F;
+ uint16_t ret;
+ if (vdp_port < 0x10) {
+ //These probably won't currently interact well with the 68K accessing the VDP
+ vdp_run_context(gen->vdp, context->current_cycle * MCLKS_PER_Z80);
+ if (vdp_port < 4) {
+ ret = vdp_data_port_read(gen->vdp);
+ } else if (vdp_port < 8) {
+ ret = vdp_control_port_read(gen->vdp);
+ } else {
+ printf("Illegal write to HV Counter port %X\n", vdp_port);
+ exit(1);
+ }
+ } else {
+ //TODO: Figure out the correct value today
+ ret = 0xFFFF;
+ }
+ return vdp_port & 1 ? ret : ret >> 8;
+}
+
uint32_t zram_counter = 0;
#define Z80_ACK_DELAY 3
#define Z80_BUSY_DELAY 1//TODO: Find the actual value for this
@@ -674,8 +703,9 @@ uint16_t io_read_w(uint32_t location, m68k_context * context)
return value;
}
-z80_context * z80_write_ym(uint16_t location, z80_context * context, uint8_t value)
+void * z80_write_ym(uint32_t location, void * vcontext, uint8_t value)
{
+ z80_context * context = vcontext;
genesis_context * gen = context->system;
sync_sound(gen, context->current_cycle * MCLKS_PER_Z80);
if (location & 1) {
@@ -688,13 +718,28 @@ z80_context * z80_write_ym(uint16_t location, z80_context * context, uint8_t val
return context;
}
-uint8_t z80_read_ym(uint16_t location, z80_context * context)
+uint8_t z80_read_ym(uint32_t location, void * vcontext)
{
+ z80_context * context = vcontext;
genesis_context * gen = context->system;
sync_sound(gen, context->current_cycle * MCLKS_PER_Z80);
return ym_read_status(gen->ym);
}
+uint8_t z80_read_bank(uint32_t location, void * vcontext)
+{
+ z80_context * context = vcontext;
+ //TODO: Implement me
+ return 0;
+}
+
+void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value)
+{
+ z80_context * context = vcontext;
+ //TODO: Implement me
+ return context;
+}
+
uint16_t read_sram_w(uint32_t address, m68k_context * context)
{
genesis_context * gen = context->system;
diff --git a/z80_to_x86.c b/z80_to_x86.c
index ba4fc66..6d5f928 100644
--- a/z80_to_x86.c
+++ b/z80_to_x86.c
@@ -1897,7 +1897,7 @@ void translate_z80_stream(z80_context * context, uint32_t address)
}
}
-void init_x86_z80_opts(z80_options * options, memmap_chunk * chunks, uint32_t num_chunks)
+void init_x86_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks)
{
memset(options, 0, sizeof(*options));
@@ -2069,6 +2069,13 @@ void init_x86_z80_opts(z80_options * options, memmap_chunk * chunks, uint32_t nu
jmp_r(code, options->gen.scratch1);
}
+void * z80_gen_bank_write(uint32_t start_address, void * voptions)
+{
+ z80_options * options = voptions;
+ //TODO: Handle writes to bank register
+ return options;
+}
+
void init_z80_context(z80_context * context, z80_options * options)
{
memset(context, 0, sizeof(*context));
diff --git a/z80_to_x86.h b/z80_to_x86.h
index fa9db33..d5d232c 100644
--- a/z80_to_x86.h
+++ b/z80_to_x86.h
@@ -67,7 +67,7 @@ typedef struct {
} z80_context;
void translate_z80_stream(z80_context * context, uint32_t address);
-void init_x86_z80_opts(z80_options * options, memmap_chunk * chunks, uint32_t num_chunks);
+void init_x86_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks);
void init_z80_context(z80_context * context, z80_options * options);
code_ptr z80_get_native_address(z80_context * context, uint32_t address);
code_ptr z80_get_native_address_trans(z80_context * context, uint32_t address);
@@ -76,6 +76,7 @@ void z80_run(z80_context * context);
void z80_reset(z80_context * context);
void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler);
void zremove_breakpoint(z80_context * context, uint16_t address);
+void * z80_gen_bank_write(uint32_t start_address, void * voptions);
#endif //Z80_TO_X86_H_