summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2020-08-04 21:03:25 +0200
committer hap <happppp@users.noreply.github.com>2020-08-04 21:03:37 +0200
commitab4a7a6022c3d26c6660356673af31bda52a04dd (patch)
tree376b935408d8bd9d6698b1f648a0b78bee7ebd85 /src
parent72186b58046f9e88083edeb657bdc13113d0f325 (diff)
i8244: don't access unused registers
Diffstat (limited to 'src')
-rw-r--r--src/devices/video/i8244.cpp65
-rw-r--r--src/devices/video/i8244.h19
2 files changed, 74 insertions, 10 deletions
diff --git a/src/devices/video/i8244.cpp b/src/devices/video/i8244.cpp
index 526a4d0d5b3..141b2e85198 100644
--- a/src/devices/video/i8244.cpp
+++ b/src/devices/video/i8244.cpp
@@ -8,7 +8,6 @@ TODO:
- NTSC has 263 scanlines, PAL has 313 scanlines, a quick fix will probably
cause small regressions here and there
- PAL has 228 clocks per line (so, 456 half clocks)
-- are the 'reserved' registers like RAM, or does writing have no effect?
***************************************************************************/
@@ -241,12 +240,47 @@ offs_t i8244_device::fix_register_mirrors( offs_t offset )
return offset & 0xFF;
}
+bool i8244_device::unused_register( offs_t offset )
+{
+ bool unused = false;
+
+ u8 low = offset & 0xf;
+
+ // these registers are inaccessible
+ switch (offset & 0xf0)
+ {
+ case 0x00:
+ unused = ((low & 0x3) == 0x3);
+ break;
+ case 0xa0:
+ unused = (low == 0x6 || low >= 0xb);
+ break;
+ case 0xc0: case 0xd0:
+ unused = (low >= 0x9);
+ break;
+ case 0xe0:
+ unused = (low >= 0xa);
+ break;
+ case 0xf0:
+ unused = true;
+ break;
+
+ default:
+ break;
+ }
+
+ return unused;
+}
+
uint8_t i8244_device::read(offs_t offset)
{
uint8_t data;
- offset = fix_register_mirrors( offset );
+ offset = fix_register_mirrors(offset);
+
+ if (unused_register(offset))
+ return 0;
switch (offset)
{
@@ -299,15 +333,32 @@ uint8_t i8244_device::read(offs_t offset)
void i8244_device::write(offs_t offset, uint8_t data)
{
- offset = fix_register_mirrors( offset );
+ offset = fix_register_mirrors(offset);
- /* Major systems Y CAM d0 is not connected! */
- if (offset >= 0x10 && !(offset & 0x83))
+ if (unused_register(offset))
+ return;
+
+ // read-only registers
+ if (offset == 0xa1 || offset == 0xa4 || offset == 0xa5)
+ return;
+
+ // Color registers d4-d7 are not connected
+ if ((offset & 0x83) == 0x03)
+ data &= 0x0f;
+
+ // Major systems Y CAM d0 is not connected!
+ if (offset >= 0x10 && (offset & 0x83) == 0x00)
data &= ~0x01;
- /* Update the sound */
+ // Horizontal grid high byte only d0 is connected
+ if ((offset & 0xf0) == 0xd0)
+ data &= 0x01;
+
+ // Update the sound
if (offset >= 0xa7 && offset <= 0xaa)
{
+ if (offset == 0xaa)
+ data &= 0xbf;
m_stream->update();
}
@@ -316,7 +367,7 @@ void i8244_device::write(offs_t offset, uint8_t data)
if ( ( m_vdc.s.control & VDC_CONTROL_REG_STROBE_XY )
&& !(data & VDC_CONTROL_REG_STROBE_XY))
{
- /* Toggling strobe bit, tuck away values */
+ // Toggling strobe bit, tuck away values
m_x_beam_pos = get_x_beam();
m_y_beam_pos = get_y_beam();
}
diff --git a/src/devices/video/i8244.h b/src/devices/video/i8244.h
index a51d5ab31da..8db0fb511d9 100644
--- a/src/devices/video/i8244.h
+++ b/src/devices/video/i8244.h
@@ -56,32 +56,44 @@ protected:
union vdc_t {
uint8_t reg[0x100];
struct {
+ // 0x00
struct {
- uint8_t y,x,color,reserved;
+ uint8_t y,x,color,unused;
} sprites[4];
+
+ // 0x10
struct {
uint8_t y,x,ptr,color;
} foreground[12];
+
+ // 0x40
struct {
struct {
uint8_t y,x,ptr,color;
} single[4];
} quad[4];
+
+ // 0x80
uint8_t shape[4][8];
+
+ // 0xa0
uint8_t control;
uint8_t status;
uint8_t collision;
uint8_t color;
uint8_t y;
uint8_t x;
- uint8_t reserved;
+ uint8_t unused;
uint8_t shift1;
uint8_t shift2;
uint8_t shift3;
uint8_t sound;
- uint8_t reserved2[5+0x10];
+ uint8_t unused2[5+0x10];
+
+ // 0xc0
uint8_t hgrid[2][0x10];
uint8_t vgrid[0x10];
+ uint8_t unused3[0x10];
} s;
};
@@ -101,6 +113,7 @@ protected:
int get_y_beam();
int get_x_beam();
offs_t fix_register_mirrors( offs_t offset );
+ bool unused_register( offs_t offset );
// Local constants
static constexpr uint8_t VDC_CONTROL_REG_STROBE_XY = 0x02;