Mercurial > repos > blastem
changeset 991:f9ee6f746cb4
Properly emulate machine freeze when reading from VDP while configured for writes
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 27 Apr 2016 23:57:00 -0700 |
parents | 33a46d35b913 |
children | 261995d06897 |
files | vdp.c |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/vdp.c Wed Apr 27 23:11:24 2016 -0700 +++ b/vdp.c Wed Apr 27 23:57:00 2016 -0700 @@ -8,6 +8,7 @@ #include <stdlib.h> #include <string.h> #include "render.h" +#include "util.h" #define NTSC_INACTIVE_START 224 #define PAL_INACTIVE_START 240 @@ -1737,10 +1738,18 @@ context->flags2 &= ~FLAG2_READ_PENDING; } if (context->cd & 1) { - return 0; + warning("Read from VDP data port while writes are configured, CPU is now frozen. VDP Address: %X, CD: %X\n", context->address, context->cd); } + uint32_t old_frame = context->frame; while (!(context->flags & FLAG_READ_FETCHED)) { vdp_run_context(context, context->cycles + ((context->regs[REG_MODE_4] & BIT_H40) ? 16 : 20)); + if (context->frame != old_frame) { + if (!headless) { + //TODO: make pushing frames to renderer automatic so this doesn't need to be here + wait_render_frame(context, 0); + } + old_frame = context->frame; + } } context->flags &= ~FLAG_READ_FETCHED; //Should this happen after the prefetch or after the read?