summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/bfm_dm01.h
blob: 06a2923f6bb721322d609fb99d3c9bcf1a2ae0ae (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
// license:BSD-3-Clause
// copyright-holders:David Haywood
/************************************************************************************

    Bellfruit dotmatrix driver, (under heavy construction !!!)

*************************************************************************************/
#ifndef MAME_VIDEO_BFM_DM01
#define MAME_VIDEO_BFM_DM01

#pragma once

#include "screen.h"

#define MCFG_BFM_DM01_BUSY_CB(_devcb) \
	devcb = &downcast<bfm_dm01_device &>(*device).set_busy_callback(DEVCB_##_devcb);

class bfm_dm01_device : public device_t
{
public:
	bfm_dm01_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	~bfm_dm01_device() {}

	template <class Object> devcb_base &set_busy_callback(Object &&cb) { return m_busy_cb.set_callback(std::forward<Object>(cb)); }

	DECLARE_READ8_MEMBER( control_r );
	DECLARE_WRITE8_MEMBER( control_w );
	DECLARE_READ8_MEMBER( mux_r );
	DECLARE_WRITE8_MEMBER( mux_w );
	DECLARE_READ8_MEMBER( comm_r );
	DECLARE_WRITE8_MEMBER( comm_w );
	DECLARE_READ8_MEMBER( unknown_r );
	DECLARE_WRITE8_MEMBER( unknown_w );

	void writedata(uint8_t data);
	int busy(void);

	void bfm_dm01_memmap(address_map &map);
protected:
	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	static constexpr unsigned BYTES_PER_ROW = 9;

	required_device<cpu_device> m_matrixcpu;
	required_device<screen_device> m_screen;
	required_device<palette_device> m_palette;

	// internal state
	int m_data_avail;
	int m_control;
	int m_xcounter;
	int m_segbuffer[65];
	int m_busy;

	uint8_t m_scanline[BYTES_PER_ROW];
	uint8_t m_comdata;

	devcb_write_line m_busy_cb;

	int read_data(void);

	bitmap_ind16 m_tmpbitmap;

	INTERRUPT_GEN_MEMBER(nmi_line_assert);

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

DECLARE_DEVICE_TYPE(BFM_DM01, bfm_dm01_device)

#endif // MAME_VIDEO_BFM_DM01