summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/cesblit.h
blob: 93b0598c830aeb757485aa066f07c9414496dcc8 (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
// 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

/***************************************************************************
    INTERFACE CONFIGURATION MACROS
***************************************************************************/

#define MCFG_CESBLIT_ADD(_tag, _screen, _clock) \
	MCFG_DEVICE_ADD(_tag, CESBLIT, _clock) \
	MCFG_VIDEO_SET_SCREEN(_screen)

#define MCFG_CESBLIT_MAP    MCFG_DEVICE_PROGRAM_MAP

#define MCFG_CESBLIT_COMPUTE_ADDR(_compute_addr) \
	cesblit_device::static_set_compute_addr(*device, _compute_addr);

#define MCFG_CESBLIT_IRQ_CB(_devcb) \
	devcb = &cesblit_device::static_set_irq_callback(*device, DEVCB_##_devcb);

/***************************************************************************
    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
	cesblit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// static configuration
	void set_compute_addr(compute_addr_t compute_addr)  { m_compute_addr = compute_addr; }
	static void static_set_compute_addr(device_t &device, compute_addr_t compute_addr) { downcast<cesblit_device &>(device).set_compute_addr(compute_addr); }
	template <class Object> static devcb_base &static_set_irq_callback(device_t &device, Object &&cb) { return downcast<cesblit_device &>(device).m_blit_irq_cb.set_callback(std::forward<Object>(cb)); }

	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 const address_space_config *memory_space_config(address_spacenum spacenum) const override { return (spacenum == AS_PROGRAM) ? &m_space_config : nullptr; }

	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