summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/ppu2c0x.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-05-07 23:18:47 +1000
committer Vas Crabb <vas@vastheman.com>2017-05-14 21:44:11 +1000
commit0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch)
tree201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/video/ppu2c0x.h
parente6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff)
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are: * Short name, full name and source file are no longer members of device_t, they are part of the device type * MACHINE_COFIG_START no longer needs a driver class * MACHINE_CONFIG_DERIVED_CLASS is no longer necessary * Specify the state class you want in the GAME/COMP/CONS line * The compiler will work out the base class where the driver init member is declared * There is one static device type object per driver rather than one per machine configuration Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type. * DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders. * DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type. Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types. * These macros declare storage for the static data, and instantiate the device type and device finder templates. The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate. Things I've actually messed with substantially: * More descriptive names for a lot of devices * Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes * Changed DECO BSMT2000 ready callback into a device delegate * Untangled Microprose 3D noise from driver state * Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices * Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly * Started to break out common parts of Samsung ARM SoC devices * Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++ * Tried to make Z180 table allocation/setup a bit safer * Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant * Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size * Imporved encapsulation of Z80DART channels * Refactored the SPC7110 bit table generator loop to make it more readable * Added wrappers for SNES PPU operations so members can be made protected * Factored out some boilerplate for YM chips with PSG * toaplan2 gfx * stic/intv resolution * Video System video * Out Run/Y-board sprite alignment * GIC video hookup * Amstrad CPC ROM box members * IQ151 ROM cart region * MSX cart IRQ callback resolution time * SMS passthrough control devices starting subslots I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo). And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros. It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/video/ppu2c0x.h')
-rw-r--r--src/devices/video/ppu2c0x.h197
1 files changed, 98 insertions, 99 deletions
diff --git a/src/devices/video/ppu2c0x.h b/src/devices/video/ppu2c0x.h
index b37d765c475..0ae702fdf1d 100644
--- a/src/devices/video/ppu2c0x.h
+++ b/src/devices/video/ppu2c0x.h
@@ -9,10 +9,10 @@
******************************************************************************/
-#pragma once
+#ifndef MAME_VIDEO_PPU2C0X_H
+#define MAME_VIDEO_PPU2C0X_H
-#ifndef __PPU_2C03B_H__
-#define __PPU_2C03B_H__
+#pragma once
///*************************************************************************
// MACROS / CONSTANTS
@@ -30,58 +30,6 @@
#define PPU_DRAW_OAM 1
-// registers definition
-enum
-{
- PPU_CONTROL0 = 0,
- PPU_CONTROL1,
- PPU_STATUS,
- PPU_SPRITE_ADDRESS,
- PPU_SPRITE_DATA,
- PPU_SCROLL,
- PPU_ADDRESS,
- PPU_DATA,
- PPU_MAX_REG
-};
-
-// bit definitions for (some of) the registers
-enum
-{
- PPU_CONTROL0_INC = 0x04,
- PPU_CONTROL0_SPR_SELECT = 0x08,
- PPU_CONTROL0_CHR_SELECT = 0x10,
- PPU_CONTROL0_SPRITE_SIZE = 0x20,
- PPU_CONTROL0_NMI = 0x80,
-
- PPU_CONTROL1_DISPLAY_MONO = 0x01,
- PPU_CONTROL1_BACKGROUND_L8 = 0x02,
- PPU_CONTROL1_SPRITES_L8 = 0x04,
- PPU_CONTROL1_BACKGROUND = 0x08,
- PPU_CONTROL1_SPRITES = 0x10,
- PPU_CONTROL1_COLOR_EMPHASIS = 0xe0,
-
- PPU_STATUS_8SPRITES = 0x20,
- PPU_STATUS_SPRITE0_HIT = 0x40,
- PPU_STATUS_VBLANK = 0x80
-};
-
-enum
-{
- PPU_NTSC_SCANLINES_PER_FRAME = 262,
- PPU_PAL_SCANLINES_PER_FRAME = 312,
-
- PPU_BOTTOM_VISIBLE_SCANLINE = 239,
- PPU_VBLANK_FIRST_SCANLINE = 241,
- PPU_VBLANK_FIRST_SCANLINE_PALC = 291,
- PPU_VBLANK_LAST_SCANLINE_NTSC = 260,
- PPU_VBLANK_LAST_SCANLINE_PAL = 310
-
- // Both the scanline immediately before and immediately after VBLANK
- // are non-rendering and non-vblank.
-};
-
-/*----------- defined in video/ppu2c0x.c -----------*/
-
///*************************************************************************
// INTERFACE CONFIGURATION MACROS
///*************************************************************************
@@ -117,7 +65,7 @@ enum
ppu2c0x_device::set_color_base(*device, _color);
#define MCFG_PPU2C0X_SET_NMI(_class, _method) \
- ppu2c0x_device::set_nmi_delegate(*device, ppu2c0x_nmi_delegate(&_class::_method, #_class "::" #_method, nullptr, (_class *)nullptr));
+ ppu2c0x_device::set_nmi_delegate(*device, ppu2c0x_device::nmi_delegate(&_class::_method, #_class "::" #_method, nullptr, (_class *)nullptr));
#define MCFG_PPU2C0X_IGNORE_SPRITE_WRITE_LIMIT \
ppu2c0x_device::use_sprite_write_limitation_disable(*device);
@@ -125,12 +73,6 @@ enum
///*************************************************************************
// TYPE DEFINITIONS
///*************************************************************************
-typedef device_delegate<void (int scanline, int vblank, int blanked)> ppu2c0x_scanline_delegate;
-typedef device_delegate<void (int scanline, int vblank, int blanked)> ppu2c0x_hblank_delegate;
-typedef device_delegate<void (int *ppu_regs)> ppu2c0x_nmi_delegate;
-typedef device_delegate<int (int address, int data)> ppu2c0x_vidaccess_delegate;
-typedef device_delegate<void (offs_t offset)> ppu2c0x_latch_delegate;
-
// ======================> ppu2c0x_device
@@ -139,25 +81,35 @@ class ppu2c0x_device : public device_t,
public device_video_interface
{
public:
- // construction/destruction
- ppu2c0x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source);
+ typedef device_delegate<void (int scanline, int vblank, int blanked)> scanline_delegate;
+ typedef device_delegate<void (int scanline, int vblank, int blanked)> hblank_delegate;
+ typedef device_delegate<void (int *ppu_regs)> nmi_delegate;
+ typedef device_delegate<int (int address, int data)> vidaccess_delegate;
+ typedef device_delegate<void (offs_t offset)> latch_delegate;
+
+ enum
+ {
+ NTSC_SCANLINES_PER_FRAME = 262,
+ PAL_SCANLINES_PER_FRAME = 312,
+
+ BOTTOM_VISIBLE_SCANLINE = 239,
+ VBLANK_FIRST_SCANLINE = 241,
+ VBLANK_FIRST_SCANLINE_PALC = 291,
+ VBLANK_LAST_SCANLINE_NTSC = 260,
+ VBLANK_LAST_SCANLINE_PAL = 310
+
+ // Both the scanline immediately before and immediately after VBLANK
+ // are non-rendering and non-vblank.
+ };
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
DECLARE_READ8_MEMBER( palette_read );
DECLARE_WRITE8_MEMBER( palette_write );
- virtual void device_start() override;
- virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
- virtual void device_config_complete() override;
- // device_config_memory_interface overrides
- virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const override;
- // address space configurations
- const address_space_config m_space_config;
-
static void set_cpu_tag(device_t &device, const char *tag) { downcast<ppu2c0x_device &>(device).m_cpu.set_tag(tag); }
static void set_color_base(device_t &device, int colorbase) { downcast<ppu2c0x_device &>(device).m_color_base = colorbase; }
- static void set_nmi_delegate(device_t &device, ppu2c0x_nmi_delegate cb);
+ static void set_nmi_delegate(device_t &device, nmi_delegate &&cb);
/* routines */
void init_palette( palette_device &palette, int first_entry );
@@ -174,9 +126,9 @@ public:
int get_colorbase() { return m_color_base; };
int get_current_scanline() { return m_scanline; };
- void set_scanline_callback( ppu2c0x_scanline_delegate cb ) { m_scanline_callback_proc = cb; m_scanline_callback_proc.bind_relative_to(*owner()); };
- void set_hblank_callback( ppu2c0x_hblank_delegate cb ) { m_hblank_callback_proc = cb; m_hblank_callback_proc.bind_relative_to(*owner()); };
- void set_vidaccess_callback( ppu2c0x_vidaccess_delegate cb ) { m_vidaccess_callback_proc = cb; m_vidaccess_callback_proc.bind_relative_to(*owner()); };
+ void set_scanline_callback( scanline_delegate &&cb ) { m_scanline_callback_proc = std::move(cb); m_scanline_callback_proc.bind_relative_to(*owner()); };
+ void set_hblank_callback( hblank_delegate &&cb ) { m_hblank_callback_proc = std::move(cb); m_hblank_callback_proc.bind_relative_to(*owner()); };
+ void set_vidaccess_callback( vidaccess_delegate &&cb ) { m_vidaccess_callback_proc = std::move(cb); m_vidaccess_callback_proc.bind_relative_to(*owner()); };
void set_scanlines_per_frame( int scanlines ) { m_scanlines_per_frame = scanlines; };
// MMC5 has to be able to check this
@@ -185,12 +137,10 @@ public:
int get_tilenum() { return m_tilecount; };
//27/12/2002 (HACK!)
- void set_latch( ppu2c0x_latch_delegate cb ) { m_latch = cb; m_latch.bind_relative_to(*owner()); };
+ void set_latch( latch_delegate &&cb ) { m_latch = std::move(cb); m_latch.bind_relative_to(*owner()); };
// void update_screen(bitmap_t &bitmap, const rectangle &cliprect);
- required_device<cpu_device> m_cpu;
-
// some bootleg / clone hardware appears to ignore this
static void use_sprite_write_limitation_disable(device_t &device)
{
@@ -199,14 +149,64 @@ public:
}
protected:
+ // registers definition
+ enum
+ {
+ PPU_CONTROL0 = 0,
+ PPU_CONTROL1,
+ PPU_STATUS,
+ PPU_SPRITE_ADDRESS,
+ PPU_SPRITE_DATA,
+ PPU_SCROLL,
+ PPU_ADDRESS,
+ PPU_DATA,
+ PPU_MAX_REG
+ };
+
+ // bit definitions for (some of) the registers
+ enum
+ {
+ PPU_CONTROL0_INC = 0x04,
+ PPU_CONTROL0_SPR_SELECT = 0x08,
+ PPU_CONTROL0_CHR_SELECT = 0x10,
+ PPU_CONTROL0_SPRITE_SIZE = 0x20,
+ PPU_CONTROL0_NMI = 0x80,
+
+ PPU_CONTROL1_DISPLAY_MONO = 0x01,
+ PPU_CONTROL1_BACKGROUND_L8 = 0x02,
+ PPU_CONTROL1_SPRITES_L8 = 0x04,
+ PPU_CONTROL1_BACKGROUND = 0x08,
+ PPU_CONTROL1_SPRITES = 0x10,
+ PPU_CONTROL1_COLOR_EMPHASIS = 0xe0,
+
+ PPU_STATUS_8SPRITES = 0x20,
+ PPU_STATUS_SPRITE0_HIT = 0x40,
+ PPU_STATUS_VBLANK = 0x80
+ };
+
+ // construction/destruction
+ ppu2c0x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void device_start() override;
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
+ virtual void device_config_complete() override;
+
+ // device_config_memory_interface overrides
+ virtual const address_space_config *memory_space_config(address_spacenum spacenum) const override;
+
+ // address space configurations
+ const address_space_config m_space_config;
+
+ required_device<cpu_device> m_cpu;
+
int m_scanlines_per_frame; /* number of scanlines per frame */
int m_security_value; /* 2C05 protection */
int m_vblank_first_scanline; /* the very first scanline where VBLANK occurs */
private:
- static const device_timer_id TIMER_HBLANK = 0;
- static const device_timer_id TIMER_NMI = 1;
- static const device_timer_id TIMER_SCANLINE = 2;
+ static constexpr device_timer_id TIMER_HBLANK = 0;
+ static constexpr device_timer_id TIMER_NMI = 1;
+ static constexpr device_timer_id TIMER_SCANLINE = 2;
inline uint8_t readbyte(offs_t address);
inline void writebyte(offs_t address, uint8_t data);
@@ -216,10 +216,10 @@ private:
std::unique_ptr<pen_t[]> m_colortable; /* color table modified at run time */
std::unique_ptr<pen_t[]> m_colortable_mono; /* monochromatic color table modified at run time */
int m_scanline; /* scanline count */
- ppu2c0x_scanline_delegate m_scanline_callback_proc; /* optional scanline callback */
- ppu2c0x_hblank_delegate m_hblank_callback_proc; /* optional hblank callback */
- ppu2c0x_vidaccess_delegate m_vidaccess_callback_proc; /* optional video access callback */
- ppu2c0x_nmi_delegate m_nmi_callback_proc; /* nmi access callback from interface */
+ scanline_delegate m_scanline_callback_proc; /* optional scanline callback */
+ hblank_delegate m_hblank_callback_proc; /* optional hblank callback */
+ vidaccess_delegate m_vidaccess_callback_proc; /* optional video access callback */
+ nmi_delegate m_nmi_callback_proc; /* nmi access callback from interface */
int m_regs[PPU_MAX_REG]; /* registers */
int m_refresh_data; /* refresh-related */
int m_refresh_latch; /* refresh-related */
@@ -237,7 +237,7 @@ private:
int m_scan_scale; /* scan scale */
int m_tilecount; /* MMC5 can change attributes to subsets of the 34 visible tiles */
int m_draw_phase; /* MMC5 uses different regs for BG and OAM */
- ppu2c0x_latch_delegate m_latch;
+ latch_delegate m_latch;
// timers
emu_timer *m_hblank_timer; /* hblank period at end of each scanline */
@@ -295,15 +295,14 @@ public:
// device type definition
//extern const device_type PPU_2C0X;
-extern const device_type PPU_2C02; // NTSC NES
-extern const device_type PPU_2C03B; // Playchoice 10
-extern const device_type PPU_2C04; // Vs. Unisystem
-extern const device_type PPU_2C07; // PAL NES
-extern const device_type PPU_PALC; // PAL Clones
-extern const device_type PPU_2C05_01; // Vs. Unisystem (Ninja Jajamaru Kun)
-extern const device_type PPU_2C05_02; // Vs. Unisystem (Mighty Bomb Jack)
-extern const device_type PPU_2C05_03; // Vs. Unisystem (Gumshoe)
-extern const device_type PPU_2C05_04; // Vs. Unisystem (Top Gun)
-
-
-#endif
+DECLARE_DEVICE_TYPE(PPU_2C02, ppu2c02_device) // NTSC NES
+DECLARE_DEVICE_TYPE(PPU_2C03B, ppu2c03b_device) // Playchoice 10
+DECLARE_DEVICE_TYPE(PPU_2C04, ppu2c04_device) // Vs. Unisystem
+DECLARE_DEVICE_TYPE(PPU_2C07, ppu2c07_device) // PAL NES
+DECLARE_DEVICE_TYPE(PPU_PALC, ppupalc_device) // PAL Clones
+DECLARE_DEVICE_TYPE(PPU_2C05_01, ppu2c05_01_device) // Vs. Unisystem (Ninja Jajamaru Kun)
+DECLARE_DEVICE_TYPE(PPU_2C05_02, ppu2c05_02_device) // Vs. Unisystem (Mighty Bomb Jack)
+DECLARE_DEVICE_TYPE(PPU_2C05_03, ppu2c05_03_device) // Vs. Unisystem (Gumshoe)
+DECLARE_DEVICE_TYPE(PPU_2C05_04, ppu2c05_04_device) // Vs. Unisystem (Top Gun)
+
+#endif // MAME_VIDEO_PPU2C0X_H