summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/video/ef9364.h
blob: ef7fc2cb99a025f98e3553d3a36020deae9524c0 (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
101
102
103
104
105
106
107
108
109
110
111
// license:BSD-3-Clause
// copyright-holders:Jean-Francois DEL NERO
/*********************************************************************

    ef9364.h

    Thomson EF9364 video controller

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

#ifndef MAME_VIDEO_EF9364_H
#define MAME_VIDEO_EF9364_H

#pragma once

#include "emupal.h"

#define MCFG_EF9364_PALETTE(_palette_tag) \
	downcast<ef9364_device &>(*device).set_palette_tag(_palette_tag);

#define MCFG_EF9364_PAGES_CNT(_pages_number) \
	downcast<ef9364_device &>(*device).set_nb_of_pages(_pages_number);

#define MCFG_EF9364_IRQ_HANDLER(_devcb) \
	devcb = &downcast<ef9364_device &>(*device).set_irq_handler(DEVCB_##_devcb);

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

// ======================> ef9364_device

class ef9364_device :   public device_t,
						public device_memory_interface,
						public device_video_interface
{
public:
	static constexpr unsigned NB_OF_COLUMNS = 64;
	static constexpr unsigned NB_OF_ROWS = 16;

	static constexpr unsigned TXTPLANE_MAX_SIZE = NB_OF_COLUMNS * NB_OF_ROWS;
	static constexpr unsigned MAX_TXTPLANES = 2;

	// construction/destruction
	ef9364_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// configuration
	template <typename T> void set_palette_tag(T &&tag) { m_palette.set_tag(std::forward<T>(tag)); }
	void set_nb_of_pages(int nb_bitplanes) {
		if (nb_bitplanes > 0 && nb_bitplanes <= 8)
		{
			nb_of_pages = nb_bitplanes;
		}
	}

	// device interface
	void update_scanline(uint16_t scanline);
	void set_color_entry( int index, uint8_t r, uint8_t g, uint8_t b );

	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
	void char_latch_w(uint8_t data);
	void command_w(uint8_t cmd);

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

	// device_config_memory_interface overrides
	virtual space_config_vector memory_space_config() const override;

	// address space configurations
	const address_space_config      m_space_config;

	// inline helper

private:
	void set_video_mode(void);
	void draw_border(uint16_t line);

	void ef9364(address_map &map);

	// internal state

	required_region_ptr<uint8_t> m_charset;
	address_space *m_textram;

	uint8_t x_curs_pos;
	uint8_t y_curs_pos;
	uint8_t char_latch;

	uint8_t m_border[80];                     //border color

	rgb_t palette[2];
	int   nb_of_pages;
	int   bitplane_xres;
	int   bitplane_yres;
	int   vsync_scanline_pos;
	int   cursor_cnt;
	int   cursor_state;

	uint32_t clock_freq;
	bitmap_rgb32 m_screen_out;

	required_device<palette_device> m_palette;
};

// device type definition
DECLARE_DEVICE_TYPE(EF9364, ef9364_device)

#endif // MAME_VIDEO_EF9364_H