Mercurial > repos > blastem
diff genesis.c @ 1117:928a65750345
Initial support for Genesis/Megadrive PBC mode. VDP still needs Mode 4 to be useful.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 22 Dec 2016 19:51:25 -0800 |
parents | fe8c79f82c22 |
children | 8f14767661fa |
line wrap: on
line diff
--- a/genesis.c Thu Dec 22 10:51:33 2016 -0800 +++ b/genesis.c Thu Dec 22 19:51:25 2016 -0800 @@ -39,9 +39,9 @@ return 0; } -uint16_t get_open_bus_value() +static uint16_t get_open_bus_value(system_header *system) { - genesis_context *genesis = (genesis_context *)current_system; + genesis_context *genesis = (genesis_context *)system; return read_dma_value(genesis->m68k->last_prefetch_address/2); } @@ -101,7 +101,7 @@ #define dputs #endif -void z80_next_int_pulse(z80_context * z_context) +static void z80_next_int_pulse(z80_context * z_context) { genesis_context * gen = z_context->system; z_context->int_pulse_start = vdp_next_vint_z80(gen->vdp); @@ -626,7 +626,7 @@ } else { if (location == 0x1100) { value = z80_enabled ? !z80_get_busack(gen->z80, context->current_cycle) : !gen->z80->busack; - value |= (get_open_bus_value() >> 8) & 0xFE; + value |= (get_open_bus_value(&gen->header) >> 8) & 0xFE; dprintf("Byte read of BUSREQ returned %d @ %d (reset: %d)\n", value, context->current_cycle, gen->z80->reset); } else if (location == 0x1200) { value = !gen->z80->reset; @@ -641,12 +641,13 @@ static uint16_t io_read_w(uint32_t location, m68k_context * context) { + genesis_context *gen = context->system; uint16_t value = io_read(location, context); if (location < 0x10000 || (location & 0x1FFF) < 0x100) { value = value | (value << 8); } else { value <<= 8; - value |= get_open_bus_value() & 0xFF; + value |= get_open_bus_value(&gen->header) & 0xFF; } return value; } @@ -902,6 +903,7 @@ gen->header.load_save = load_save; gen->header.persist_save = persist_save; gen->header.free_context = free_genesis; + gen->header.get_open_bus_value = get_open_bus_value; gen->header.request_exit = request_exit; gen->header.inc_debug_mode = inc_debug_mode; gen->header.inc_debug_pal = inc_debug_pal; @@ -909,6 +911,7 @@ gen->vdp = malloc(sizeof(vdp_context)); init_vdp_context(gen->vdp, gen->version_reg & 0x40); + gen->vdp->system = &gen->header; gen->frame_end = vdp_cycles_to_frame_end(gen->vdp); char * config_cycles = tern_find_path(config, "clocks\0max_cycles\0").ptrval; gen->max_cycles = config_cycles ? atoi(config_cycles) : DEFAULT_SYNC_INTERVAL; @@ -929,6 +932,7 @@ z80_options *z_opts = malloc(sizeof(z80_options)); init_z80_opts(z_opts, z80_map, 5, NULL, 0, MCLKS_PER_Z80, 0xFFFF); init_z80_context(gen->z80, z_opts); + gen->z80->next_int_pulse = z80_next_int_pulse; z80_assert_reset(gen->z80, 0); #endif