summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/devices/video/gb_lcd.cpp2
-rw-r--r--src/devices/video/gb_lcd.h7
-rw-r--r--src/devices/video/gba_lcd.cpp4
-rw-r--r--src/devices/video/gba_lcd.h32
-rw-r--r--src/mame/drivers/gba.cpp2
-rw-r--r--src/mame/includes/gba.h16
6 files changed, 34 insertions, 29 deletions
diff --git a/src/devices/video/gb_lcd.cpp b/src/devices/video/gb_lcd.cpp
index 024ba3d777a..e4e34e8e2e7 100644
--- a/src/devices/video/gb_lcd.cpp
+++ b/src/devices/video/gb_lcd.cpp
@@ -419,7 +419,7 @@ void gb_lcd_device::common_reset()
// specific reg initialization
m_vid_regs[0x06] = 0xff;
- for (int i = 0x0c; i < _NR_GB_VID_REGS; i++)
+ for (int i = 0x0c; i < NR_GB_VID_REGS; i++)
m_vid_regs[i] = 0xff;
LCDSTAT = 0x80;
diff --git a/src/devices/video/gb_lcd.h b/src/devices/video/gb_lcd.h
index 4e512e3da79..4c443d827e2 100644
--- a/src/devices/video/gb_lcd.h
+++ b/src/devices/video/gb_lcd.h
@@ -12,9 +12,6 @@
#include "emu.h"
-#define _NR_GB_VID_REGS 0x40
-
-
struct layer_struct {
UINT8 enabled;
UINT8 *bg_tiles;
@@ -82,7 +79,9 @@ protected:
int m_window_lines_drawn;
- UINT8 m_vid_regs[_NR_GB_VID_REGS];
+ static constexpr unsigned NR_GB_VID_REGS = 0x40;
+
+ UINT8 m_vid_regs[NR_GB_VID_REGS];
UINT8 m_bg_zbuf[160];
UINT16 m_cgb_bpal[32]; /* CGB current background palette table */
diff --git a/src/devices/video/gba_lcd.cpp b/src/devices/video/gba_lcd.cpp
index 4a7173a6e03..0c70f76b84f 100644
--- a/src/devices/video/gba_lcd.cpp
+++ b/src/devices/video/gba_lcd.cpp
@@ -15,9 +15,7 @@
#include "gba_lcd.h"
-#include "includes/gba.h"
-
-#define REG_BASE 0x000
+#include "includes/gba.h" // this is a dependency from src/devices to src/mame which is very bad and should be fixed
/* LCD I/O Registers */
#define DISPCNT HWLO(0x000) /* 0x4000000 2 R/W LCD Control */
diff --git a/src/devices/video/gba_lcd.h b/src/devices/video/gba_lcd.h
index 38a315af251..8b36dcfeaca 100644
--- a/src/devices/video/gba_lcd.h
+++ b/src/devices/video/gba_lcd.h
@@ -18,6 +18,7 @@
#include "emu.h"
+
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
@@ -38,8 +39,33 @@ extern const device_type GBA_LCD;
// TYPE DEFINITIONS
//**************************************************************************
-class gba_lcd_device : public device_t,
- public device_video_interface
+template <unsigned COUNT, unsigned BASE>
+class gba_registers
+{
+protected:
+ static constexpr unsigned REG_BASE = BASE;
+
+ UINT32 &WORD(unsigned x) { return m_regs[(x - REG_BASE) / 4]; } // 32-bit Register
+ const UINT32 &WORD(unsigned x) const { return m_regs[(x - REG_BASE) / 4]; } // 32-bit Register
+ UINT16 HWHI(unsigned x) const { return UINT16(WORD(x) >> 16); } // 16-bit Register, Upper Half-Word
+ UINT16 HWLO(unsigned x) const { return UINT16(WORD(x)); } // 16-bit Register, Lower Half-Word
+
+ UINT32 &WORD_SET(unsigned x, UINT32 y) { return WORD(x) |= y; }
+ UINT32 &HWHI_SET(unsigned x, UINT16 y) { return WORD(x) |= UINT32(y) << 16; }
+ UINT32 &HWLO_SET(unsigned x, UINT16 y) { return WORD(x) |= UINT32(y); }
+
+ UINT32 &WORD_RESET(unsigned x, UINT32 y) { return WORD(x) &= ~y; }
+ UINT32 &HWHI_RESET(unsigned x, UINT16 y) { return WORD(x) &= ~(UINT32(y) << 16); }
+ UINT32 &HWLO_RESET(unsigned x, UINT16 y) { return WORD(x) &= ~UINT32(y); }
+
+ UINT32 m_regs[COUNT];
+};
+
+
+class gba_lcd_device
+ : public device_t
+ , public device_video_interface
+ , protected gba_registers<0x060 / 4, 0x000>
{
public:
gba_lcd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
@@ -83,8 +109,6 @@ private:
bitmap_ind16 m_bitmap;
- UINT32 m_regs[0x60 / 4];
-
UINT8 m_windowOn;
UINT8 m_fxOn;
UINT8 m_gfxBG2Changed;
diff --git a/src/mame/drivers/gba.cpp b/src/mame/drivers/gba.cpp
index daaaf72a3be..ab4354e62ff 100644
--- a/src/mame/drivers/gba.cpp
+++ b/src/mame/drivers/gba.cpp
@@ -19,8 +19,6 @@
#include "bus/gba/rom.h"
#include "softlist.h"
-#define REG_BASE 0x060
-
/* Sound Registers */
#define SOUNDCNT_L HWLO(0x080) /* 0x4000080 2 R/W Control Stereo/Volume/Enable */
#define SOUNDCNT_H HWHI(0x080) /* 0x4000082 2 R/W Control Mixing/DMA Control */
diff --git a/src/mame/includes/gba.h b/src/mame/includes/gba.h
index 1e2344e1018..254040e56fd 100644
--- a/src/mame/includes/gba.h
+++ b/src/mame/includes/gba.h
@@ -9,18 +9,6 @@
#include "sound/dac.h"
#include "video/gba_lcd.h"
-#define WORD(x) (m_regs[(x - REG_BASE) / 4]) /* 32-bit Register */
-#define HWHI(x) (m_regs[(x - REG_BASE) / 4] >> 16) /* 16-bit Register, Upper Half-Word */
-#define HWLO(x) (m_regs[(x - REG_BASE) / 4] & 0x0000ffff) /* 16-bit Register, Lower Half-Word */
-
-#define WORD_SET(x, y) (m_regs[(x - REG_BASE) / 4] |= (y))
-#define HWHI_SET(x, y) ((m_regs[(x - REG_BASE) / 4] |= (y << 16)))
-#define HWLO_SET(x, y) (m_regs[(x - REG_BASE) / 4] |= (y))
-
-#define WORD_RESET(x, y) (m_regs[(x - REG_BASE) / 4] &= ~(y))
-#define HWHI_RESET(x, y) ((m_regs[(x - REG_BASE) / 4] &= ~(y << 16)))
-#define HWLO_RESET(x, y) (m_regs[(x - REG_BASE) / 4] &= ~(y))
-
#define INT_VBL 0x0001
#define INT_HBL 0x0002
#define INT_VCNT 0x0004
@@ -37,7 +25,7 @@
#define INT_GAMEPAK 0x2000
/* driver state */
-class gba_state : public driver_device
+class gba_state : public driver_device, protected gba_registers<(0x400 - 0x060) / 4, 0x060>
{
public:
gba_state(const machine_config &mconfig, device_type type, const char *tag)
@@ -75,8 +63,6 @@ public:
void dma_exec(int ch);
void audio_tick(int ref);
- UINT32 m_regs[(0x400 - 0x60) / 4];
-
// DMA
emu_timer *m_dma_timer[4];
UINT32 m_dma_src[4];