# HG changeset patch # User Michael Pavone # Date 1693538913 25200 # Node ID 83f5529086c50a013e3e9925b38b344de3defc98 # Parent c05b7c5e6f111faa91ff73d76e57fafdbe6b2d4c Make bogus word RAM read more appropriately bogus diff -r c05b7c5e6f11 -r 83f5529086c5 genesis.c --- a/genesis.c Sat Aug 26 20:32:53 2023 -0700 +++ b/genesis.c Thu Aug 31 20:28:33 2023 -0700 @@ -285,13 +285,29 @@ uint32_t word_ram_end = cd->base + 0x240000; if (address >= word_ram && address < word_ram_end) { //FIXME: first word should just be garbage - address -= 2; + if (!cd->has_vdp_dma_value) { + cd->vdp_dma_value = read_word(genesis->m68k->last_prefetch_address, (void **)genesis->m68k->mem_pointers, &genesis->m68k->options->gen, genesis->m68k); + cd->has_vdp_dma_value = 1; + } + uint16_t ret = cd->vdp_dma_value; + cd->vdp_dma_value = read_word(address, (void **)genesis->m68k->mem_pointers, &genesis->m68k->options->gen, genesis->m68k); + return ret; } } return read_word(address, (void **)genesis->m68k->mem_pointers, &genesis->m68k->options->gen, genesis->m68k); } +void vdp_dma_started(void) +{ + genesis_context *genesis = (genesis_context *)current_system; + if (genesis->expansion) { + segacd_context *cd = genesis->expansion; + cd->has_vdp_dma_value = 0; + } +} + + static uint16_t get_open_bus_value(system_header *system) { genesis_context *genesis = (genesis_context *)system; diff -r c05b7c5e6f11 -r 83f5529086c5 segacd.h --- a/segacd.h Sat Aug 26 20:32:53 2023 -0700 +++ b/segacd.h Thu Aug 31 20:28:33 2023 -0700 @@ -30,6 +30,7 @@ uint32_t graphics_dx; uint32_t graphics_dy; uint16_t graphics_dst_x; + uint16_t vdp_dma_value; uint8_t graphics_pixels[4]; uint8_t graphics_debug_window; uint8_t timer_pending; @@ -50,6 +51,7 @@ uint8_t sub_paused_wordram; uint8_t bram_cart_write_enabled; uint8_t bram_cart_id; + uint8_t has_vdp_dma_value; rf5c164 pcm; lc8951 cdc; cdd_mcu cdd; diff -r c05b7c5e6f11 -r 83f5529086c5 vdp.c --- a/vdp.c Sat Aug 26 20:32:53 2023 -0700 +++ b/vdp.c Thu Aug 31 20:28:33 2023 -0700 @@ -4635,6 +4635,7 @@ //sticking with 3 slots for now until I can do some more captures vdp_run_context_full(context, context->cycles + 12 * ((context->regs[REG_MODE_2] & BIT_MODE_5) && (context->regs[REG_MODE_4] & BIT_H40) ? 4 : 5)); context->flags |= FLAG_DMA_RUN; + vdp_dma_started(); return 1; } else { context->flags |= FLAG_DMA_RUN; diff -r c05b7c5e6f11 -r 83f5529086c5 vdp.h --- a/vdp.h Sat Aug 26 20:32:53 2023 -0700 +++ b/vdp.h Thu Aug 31 20:28:33 2023 -0700 @@ -304,6 +304,7 @@ void vdp_inc_debug_mode(vdp_context *context); //to be implemented by the host system uint16_t read_dma_value(uint32_t address); +void vdp_dma_started(void); void vdp_replay_event(vdp_context *context, uint8_t event, event_reader *reader); #endif //VDP_H_