summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/vrender0.h
blob: b68b0a47f0eb77ea5af86685e8af307410c19ec6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// license:BSD-3-Clause
// copyright-holders:ElSemi
#ifndef MAME_VIDEO_VRENDER0_H
#define MAME_VIDEO_VRENDER0_H

#pragma once


/***************************************************************************
 TYPE DEFINITIONS
 ***************************************************************************/

class vr0video_device : public device_t,
						public device_video_interface
{
public:
	vr0video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void set_areas(uint16_t *textureram, uint16_t *frameram);
	void regs_map(address_map &map);
	void execute_flipping();
	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
	auto idleskip_cb() { return m_idleskip_cb.bind(); }

	DECLARE_READ16_MEMBER(flip_count_r);
	DECLARE_WRITE16_MEMBER(flip_count_w);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	int vrender0_ProcessPacket(uint32_t PacketPtr);

	devcb_write_line  m_idleskip_cb;

	struct RenderStateInfo
	{
		uint32_t Tx;
		uint32_t Ty;
		uint32_t Txdx;
		uint32_t Tydx;
		uint32_t Txdy;
		uint32_t Tydy;
		uint32_t SrcAlphaColor;
		uint32_t SrcBlend;
		uint32_t DstAlphaColor;
		uint32_t DstBlend;
		uint32_t ShadeColor;
		uint32_t TransColor;
		uint32_t TileOffset;
		uint32_t FontOffset;
		uint32_t PalOffset;
		uint32_t PaletteBank;
		uint32_t TextureMode;
		uint32_t PixelFormat;
		uint32_t Width;
		uint32_t Height;
	};


	uint16_t m_InternalPalette[256];
	uint32_t m_LastPalUpdate;

	RenderStateInfo m_RenderState;

	uint8_t *m_textureram;
	uint16_t *m_packetram;
	uint16_t *m_frameram;

	DECLARE_READ16_MEMBER( cmd_queue_front_r );
	DECLARE_WRITE16_MEMBER( cmd_queue_front_w );

	DECLARE_READ16_MEMBER( cmd_queue_rear_r );
	uint16_t m_queue_rear, m_queue_front;

	DECLARE_READ16_MEMBER( bank1_select_r );
	DECLARE_WRITE16_MEMBER( bank1_select_w );
	bool m_bank1_select;		//!< Select framebuffer bank1 address

	DECLARE_READ16_MEMBER( display_bank_r );
	uint8_t m_display_bank;		//!< Current display bank

	DECLARE_READ16_MEMBER( render_control_r );
	DECLARE_WRITE16_MEMBER( render_control_w );
	bool m_draw_select;			//!< If true, device draws to Front buffer instead of Back
	bool m_render_reset;		//!< Reset pipeline FIFO
	bool m_render_start;		//!< Enable pipeline processing
	uint8_t m_dither_mode;		//!< applied on RGB888 to RGB565 conversions (00: 2x2, 01:4x4, 1x disable)
	uint8_t m_flip_count;		//!< number of framebuffer "syncs" loaded in the parameter RAM,
								//!< a.k.a. how many full (vblank) buffers are ready for the device to parse.
	
	uint16_t *m_DrawDest;		//!< frameram pointer to draw buffer area
	uint16_t *m_DisplayDest;	//!< frameram pointer to display buffer area
};

DECLARE_DEVICE_TYPE(VIDEO_VRENDER0, vr0video_device)

#endif // MAME_VIDEO_VRENDER0_H