summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/psx.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/psx.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/psx.h')
-rw-r--r--src/devices/video/psx.h333
1 files changed, 168 insertions, 165 deletions
diff --git a/src/devices/video/psx.h b/src/devices/video/psx.h
index d3b56642222..b60e1d1a69f 100644
--- a/src/devices/video/psx.h
+++ b/src/devices/video/psx.h
@@ -7,10 +7,12 @@
*
*/
+#ifndef MAME_VIDEO_PSX_H
+#define MAME_VIDEO_PSX_H
+
#pragma once
-#ifndef __PSXGPU_H__
-#define __PSXGPU_H__
+#define PSXGPU_DEBUG_VIEWER ( 0 )
#define MCFG_PSX_GPU_VBLANK_HANDLER(_devcb) \
@@ -21,211 +23,212 @@
MCFG_PSX_GPU_READ_HANDLER(DEVREAD32(tag, psxgpu_device, read)) \
MCFG_PSX_GPU_WRITE_HANDLER(DEVWRITE32(tag, psxgpu_device, write)) \
MCFG_DEVICE_ADD( tag, type, clock ) \
- ((psxgpu_device *) device)->vramSize = _vramSize; \
+ psxgpu_device::set_vram_size(*device, _vramSize); \
MCFG_PSX_GPU_VBLANK_HANDLER(DEVWRITELINE(cputag ":irq", psxirq_device, intin0)) \
- MCFG_PSX_DMA_CHANNEL_READ( cputag, 2, psx_dma_write_delegate(&psxgpu_device::dma_read, (psxgpu_device *) device ) ) \
- MCFG_PSX_DMA_CHANNEL_WRITE( cputag, 2, psx_dma_read_delegate(&psxgpu_device::dma_write, (psxgpu_device *) device ) )
+ MCFG_PSX_DMA_CHANNEL_READ( cputag, 2, psxdma_device::write_delegate(&psxgpu_device::dma_read, (psxgpu_device *) device ) ) \
+ MCFG_PSX_DMA_CHANNEL_WRITE( cputag, 2, psxdma_device::read_delegate(&psxgpu_device::dma_write, (psxgpu_device *) device ) )
#define MCFG_PSXGPU_REPLACE( cputag, tag, type, _vramSize, clock ) \
MCFG_DEVICE_MODIFY( cputag ) \
MCFG_PSX_GPU_READ_HANDLER(DEVREAD32(tag, psxgpu_device, read)) \
MCFG_PSX_GPU_WRITE_HANDLER(DEVWRITE32(tag, psxgpu_device, write)) \
MCFG_DEVICE_REPLACE( tag, type, clock ) \
- ((psxgpu_device *) device)->vramSize = _vramSize; \
+ psxgpu_device::set_vram_size(*device, _vramSize); \
MCFG_PSX_GPU_VBLANK_HANDLER(DEVWRITELINE(cputag ":irq", psxirq_device, intin0)) \
- MCFG_PSX_DMA_CHANNEL_READ( cputag, 2, psx_dma_write_delegate(&psxgpu_device::dma_read, (psxgpu_device *) device ) ) \
- MCFG_PSX_DMA_CHANNEL_WRITE( cputag, 2, psx_dma_read_delegate(&psxgpu_device::dma_write, (psxgpu_device *) device ) )
+ MCFG_PSX_DMA_CHANNEL_READ( cputag, 2, psxdma_device::write_delegate(&psxgpu_device::dma_read, (psxgpu_device *) device ) ) \
+ MCFG_PSX_DMA_CHANNEL_WRITE( cputag, 2, psxdma_device::read_delegate(&psxgpu_device::dma_write, (psxgpu_device *) device ) )
#define MCFG_PSXGPU_VBLANK_CALLBACK( _delegate ) \
((screen_device *) config.device_find( device, "screen" ))->register_vblank_callback( _delegate );
-extern const device_type CXD8514Q;
-extern const device_type CXD8538Q;
-extern const device_type CXD8561Q;
-extern const device_type CXD8561BQ;
-extern const device_type CXD8561CQ;
-extern const device_type CXD8654Q;
-
-#define STOP_ON_ERROR ( 0 )
-
-#define MAX_LEVEL ( 32 )
-#define MID_LEVEL ( ( MAX_LEVEL / 2 ) << 8 )
-#define MAX_SHADE ( 0x100 )
-#define MID_SHADE ( 0x80 )
+DECLARE_DEVICE_TYPE(CXD8514Q, cxd8514q_device)
+DECLARE_DEVICE_TYPE(CXD8538Q, cxd8538q_device)
+DECLARE_DEVICE_TYPE(CXD8561Q, cxd8561q_device)
+DECLARE_DEVICE_TYPE(CXD8561BQ, cxd8561bq_device)
+DECLARE_DEVICE_TYPE(CXD8561CQ, cxd8561cq_device)
+DECLARE_DEVICE_TYPE(CXD8654Q, cxd8654q_device)
-#define DEBUG_COORDS ( 10 )
-
-struct psx_gpu_debug
+class psxgpu_device : public device_t
{
- std::unique_ptr<bitmap_ind16> mesh;
- int b_clear;
- int b_mesh;
- int n_skip;
- int b_texture;
- int n_interleave;
- int n_coord;
- int n_coordx[ DEBUG_COORDS ];
- int n_coordy[ DEBUG_COORDS ];
-};
+public:
+ virtual machine_config_constructor device_mconfig_additions() const override;
-struct FLATVERTEX
-{
- PAIR n_coord;
-};
+ // static configuration helpers
+ template <class Object> static devcb_base &set_vblank_handler(device_t &device, Object &&cb) { return downcast<psxgpu_device &>(device).m_vblank_handler.set_callback(std::forward<Object>(cb)); }
+ static void set_vram_size(device_t &device, int size) { downcast<psxgpu_device &>(device).vramSize = size; }
-struct GOURAUDVERTEX
-{
- PAIR n_bgr;
- PAIR n_coord;
-};
+ uint32_t update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ DECLARE_WRITE32_MEMBER( write );
+ DECLARE_READ32_MEMBER( read );
+ void dma_read( uint32_t *ram, uint32_t n_address, int32_t n_size );
+ void dma_write( uint32_t *ram, uint32_t n_address, int32_t n_size );
+ void lightgun_set( int, int );
+ void vblank(screen_device &screen, bool vblank_state);
+ DECLARE_PALETTE_INIT( psx );
-struct FLATTEXTUREDVERTEX
-{
- PAIR n_coord;
- PAIR n_texture;
-};
+protected:
+ static constexpr unsigned MAX_LEVEL = 32;
+ static constexpr unsigned MID_LEVEL = (MAX_LEVEL / 2) << 8;
+ static constexpr unsigned MAX_SHADE = 0x100;
+ static constexpr unsigned MID_SHADE = 0x80;
-struct GOURAUDTEXTUREDVERTEX
-{
- PAIR n_bgr;
- PAIR n_coord;
- PAIR n_texture;
-};
+ // construction/destruction
+ psxgpu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-union PACKET
-{
- uint32_t n_entry[ 16 ];
+ virtual void device_start() override;
+ virtual void device_reset() override;
- struct
- {
- PAIR n_cmd;
- struct FLATVERTEX vertex[ 2 ];
- PAIR n_size;
- } MoveImage;
+ int vramSize;
- struct
- {
- PAIR n_bgr;
- PAIR n_coord;
- PAIR n_size;
- } FlatRectangle;
+private:
+ static constexpr unsigned DEBUG_COORDS = 10;
- struct
+ struct psx_gpu_debug
{
- PAIR n_bgr;
- PAIR n_coord;
- } FlatRectangle8x8;
-
- struct
+ std::unique_ptr<bitmap_ind16> mesh;
+ int b_clear;
+ int b_mesh;
+ int n_skip;
+ int b_texture;
+ int n_interleave;
+ int n_coord;
+ int n_coordx[ DEBUG_COORDS ];
+ int n_coordy[ DEBUG_COORDS ];
+ };
+
+ struct FLATVERTEX
{
- PAIR n_bgr;
PAIR n_coord;
- } FlatRectangle16x16;
+ };
- struct
+ struct GOURAUDVERTEX
{
PAIR n_bgr;
PAIR n_coord;
- PAIR n_texture;
- } Sprite8x8;
+ };
- struct
+ struct FLATTEXTUREDVERTEX
{
- PAIR n_bgr;
PAIR n_coord;
PAIR n_texture;
- } Sprite16x16;
+ };
- struct
+ struct GOURAUDTEXTUREDVERTEX
{
PAIR n_bgr;
PAIR n_coord;
PAIR n_texture;
- PAIR n_size;
- } FlatTexturedRectangle;
+ };
- struct
+ union PACKET
{
- PAIR n_bgr;
- struct FLATVERTEX vertex[ 4 ];
- } FlatPolygon;
-
- struct
- {
- struct GOURAUDVERTEX vertex[ 4 ];
- } GouraudPolygon;
-
- struct
- {
- PAIR n_bgr;
- struct FLATVERTEX vertex[ 2 ];
- } MonochromeLine;
-
- struct
- {
- struct GOURAUDVERTEX vertex[ 2 ];
- } GouraudLine;
-
- struct
- {
- PAIR n_bgr;
- struct FLATTEXTUREDVERTEX vertex[ 4 ];
- } FlatTexturedPolygon;
+ uint32_t n_entry[ 16 ];
+
+ struct
+ {
+ PAIR n_cmd;
+ struct FLATVERTEX vertex[ 2 ];
+ PAIR n_size;
+ } MoveImage;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ PAIR n_size;
+ } FlatRectangle;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ } FlatRectangle8x8;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ } FlatRectangle16x16;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ PAIR n_texture;
+ } Sprite8x8;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ PAIR n_texture;
+ } Sprite16x16;
+
+ struct
+ {
+ PAIR n_bgr;
+ PAIR n_coord;
+ PAIR n_texture;
+ PAIR n_size;
+ } FlatTexturedRectangle;
+
+ struct
+ {
+ PAIR n_bgr;
+ struct FLATVERTEX vertex[ 4 ];
+ } FlatPolygon;
+
+ struct
+ {
+ struct GOURAUDVERTEX vertex[ 4 ];
+ } GouraudPolygon;
+
+ struct
+ {
+ PAIR n_bgr;
+ struct FLATVERTEX vertex[ 2 ];
+ } MonochromeLine;
+
+ struct
+ {
+ struct GOURAUDVERTEX vertex[ 2 ];
+ } GouraudLine;
+
+ struct
+ {
+ PAIR n_bgr;
+ struct FLATTEXTUREDVERTEX vertex[ 4 ];
+ } FlatTexturedPolygon;
+
+ struct
+ {
+ struct GOURAUDTEXTUREDVERTEX vertex[ 4 ];
+ } GouraudTexturedPolygon;
+
+ struct
+ {
+ PAIR n_bgr;
+ struct FLATVERTEX vertex;
+ } Dot;
+ };
- struct
- {
- struct GOURAUDTEXTUREDVERTEX vertex[ 4 ];
- } GouraudTexturedPolygon;
-
- struct
- {
- PAIR n_bgr;
- struct FLATVERTEX vertex;
- } Dot;
-};
-
-class psxgpu_device : public device_t
-{
-public:
- // construction/destruction
- psxgpu_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);
- virtual machine_config_constructor device_mconfig_additions() const override;
-
- // static configuration helpers
- template<class _Object> static devcb_base &set_vblank_handler(device_t &device, _Object object) { return downcast<psxgpu_device &>(device).m_vblank_handler.set_callback(object); }
-
- uint32_t update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- DECLARE_WRITE32_MEMBER( write );
- DECLARE_READ32_MEMBER( read );
- void dma_read( uint32_t *ram, uint32_t n_address, int32_t n_size );
- void dma_write( uint32_t *ram, uint32_t n_address, int32_t n_size );
- void lightgun_set( int, int );
- int vramSize;
- void vblank(screen_device &screen, bool vblank_state);
- DECLARE_PALETTE_INIT( psx );
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
void updatevisiblearea();
void decode_tpage( uint32_t tpage );
void FlatPolygon( int n_points );
void FlatTexturedPolygon( int n_points );
void GouraudPolygon( int n_points );
void GouraudTexturedPolygon( int n_points );
- void MonochromeLine( void );
- void GouraudLine( void );
- void FrameBufferRectangleDraw( void );
- void FlatRectangle( void );
- void FlatRectangle8x8( void );
- void FlatRectangle16x16( void );
- void FlatTexturedRectangle( void );
- void Sprite8x8( void );
- void Sprite16x16( void );
- void Dot( void );
- void MoveImage( void );
+ void MonochromeLine();
+ void GouraudLine();
+ void FrameBufferRectangleDraw();
+ void FlatRectangle();
+ void FlatRectangle8x8();
+ void FlatRectangle16x16();
+ void FlatTexturedRectangle();
+ void Sprite8x8();
+ void Sprite16x16();
+ void Dot();
+ void MoveImage();
void psx_gpu_init( int n_gputype );
void gpu_reset();
void gpu_read( uint32_t *p_ram, int32_t n_size );
@@ -302,12 +305,12 @@ private:
devcb_write_line m_vblank_handler;
-#if defined(DEBUG_VIEWER) && DEBUG_VIEWER
+#if defined(PSXGPU_DEBUG_VIEWER) && PSXGPU_DEBUG_VIEWER
required_device<screen_device> m_screen;
- void DebugMeshInit( void );
+ void DebugMeshInit();
void DebugMesh( int n_coordx, int n_coordy );
- void DebugMeshEnd( void );
- void DebugCheckKeys( void );
+ void DebugMeshEnd();
+ void DebugCheckKeys();
int DebugMeshDisplay( bitmap_ind16 &bitmap, const rectangle &cliprect );
int DebugTextureDisplay( bitmap_ind16 &bitmap );
@@ -357,4 +360,4 @@ public:
cxd8654q_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};
-#endif
+#endif // MAME_VIDEO_PSX_H