summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/cesblit.h
blob: d535921ef6bb799e4caf2c1c0c4f68d2ed340c5d (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
// license:BSD-3-Clause
// copyright-holders:Luca Elia
/***************************************************************************

    CES Blitter, with two layers and double buffering (Xilinx FPGA)

***************************************************************************/

#ifndef MAME_VIDEO_CESBLIT_H
#define MAME_VIDEO_CESBLIT_H

#pragma once


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

// ======================> cesblit_device

class cesblit_device :  public device_t,
						public device_video_interface,
						public device_memory_interface
{
public:
	typedef int (*compute_addr_t) (uint16_t reg_low, uint16_t reg_mid, uint16_t reg_high);

	// construction/destruction
	template <typename T>
	cesblit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&screen_tag)
		: cesblit_device(mconfig, tag, owner, clock)
	{
		set_screen(std::forward<T>(screen_tag));
	}

	cesblit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// configuration
	void set_compute_addr(compute_addr_t compute_addr)  { m_compute_addr = compute_addr; }
	auto irq_callback() { return m_blit_irq_cb.bind(); }

	DECLARE_WRITE16_MEMBER(color_w);
	DECLARE_WRITE16_MEMBER(addr_hi_w);
	DECLARE_WRITE16_MEMBER(regs_w);
	DECLARE_READ16_MEMBER(status_r);

	uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_stop() override;
	virtual space_config_vector memory_space_config() const override;

	void do_blit();

	address_space_config m_space_config;
	address_space *m_space;

	devcb_write_line m_blit_irq_cb; // blit finished irq

	bitmap_ind16 m_bitmap[2][2];
	uint16_t m_regs[0x12/2];
	uint16_t m_color;
	uint16_t m_addr_hi;
	compute_addr_t m_compute_addr;
};

/***************************************************************************
    GLOBAL VARIABLES
***************************************************************************/

// device type definition
DECLARE_DEVICE_TYPE(CESBLIT, cesblit_device)

#endif // MAME_VIDEO_CESBLIT_H