Mercurial > repos > blastem
comparison vdp.c @ 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 | bd4d698d995b |
children | 2bc27415565b |
comparison
equal
deleted
inserted
replaced
990:33a46d35b913 | 991:f9ee6f746cb4 |
---|---|
6 #include "vdp.h" | 6 #include "vdp.h" |
7 #include "blastem.h" | 7 #include "blastem.h" |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include "render.h" | 10 #include "render.h" |
11 #include "util.h" | |
11 | 12 |
12 #define NTSC_INACTIVE_START 224 | 13 #define NTSC_INACTIVE_START 224 |
13 #define PAL_INACTIVE_START 240 | 14 #define PAL_INACTIVE_START 240 |
14 #define BUF_BIT_PRIORITY 0x40 | 15 #define BUF_BIT_PRIORITY 0x40 |
15 #define MAP_BIT_PRIORITY 0x8000 | 16 #define MAP_BIT_PRIORITY 0x8000 |
1735 //Should these be cleared here? | 1736 //Should these be cleared here? |
1736 context->flags &= ~FLAG_READ_FETCHED; | 1737 context->flags &= ~FLAG_READ_FETCHED; |
1737 context->flags2 &= ~FLAG2_READ_PENDING; | 1738 context->flags2 &= ~FLAG2_READ_PENDING; |
1738 } | 1739 } |
1739 if (context->cd & 1) { | 1740 if (context->cd & 1) { |
1740 return 0; | 1741 warning("Read from VDP data port while writes are configured, CPU is now frozen. VDP Address: %X, CD: %X\n", context->address, context->cd); |
1741 } | 1742 } |
1743 uint32_t old_frame = context->frame; | |
1742 while (!(context->flags & FLAG_READ_FETCHED)) { | 1744 while (!(context->flags & FLAG_READ_FETCHED)) { |
1743 vdp_run_context(context, context->cycles + ((context->regs[REG_MODE_4] & BIT_H40) ? 16 : 20)); | 1745 vdp_run_context(context, context->cycles + ((context->regs[REG_MODE_4] & BIT_H40) ? 16 : 20)); |
1746 if (context->frame != old_frame) { | |
1747 if (!headless) { | |
1748 //TODO: make pushing frames to renderer automatic so this doesn't need to be here | |
1749 wait_render_frame(context, 0); | |
1750 } | |
1751 old_frame = context->frame; | |
1752 } | |
1744 } | 1753 } |
1745 context->flags &= ~FLAG_READ_FETCHED; | 1754 context->flags &= ~FLAG_READ_FETCHED; |
1746 //Should this happen after the prefetch or after the read? | 1755 //Should this happen after the prefetch or after the read? |
1747 context->address += context->regs[REG_AUTOINC]; | 1756 context->address += context->regs[REG_AUTOINC]; |
1748 return context->prefetch; | 1757 return context->prefetch; |