summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nubus/supermac.h
blob: 25b57b0968380655a8ccc04aaa320c27fcf70afc (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
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
#ifndef MAME_BUS_NUBUS_SUPERMAC_H
#define MAME_BUS_NUBUS_SUPERMAC_H

#pragma once


class supermac_spec_crtc
{
public:
	void register_save(device_t &device);

	void reset() noexcept;

	void write(device_t &device, offs_t offset, u32 data);

	bool valid(device_t &device) const;

	u32 h_sync(u32 scale) const noexcept
	{ return (m_hsync + 1) * scale; }
	u32 h_total(u32 scale) const noexcept
	{ return (m_htotal + 1) * scale; }
	u32 h_active(u32 scale) const noexcept
	{ return (m_hend - m_hstart) * scale; }
	u32 h_start(u32 scale) const noexcept
	{ return (m_hstart + 1) * scale; }
	u32 h_end(u32 scale) const noexcept
	{ return (m_hend + 1) * scale; }

	u16 v_sync() const noexcept
	{ return m_vsync + 1; }
	u16 v_total() const noexcept
	{ return m_vtotal + 1; }
	u32 v_active() const noexcept
	{ return (m_vend - m_vstart); }
	u16 v_start() const noexcept
	{ return m_vstart + 1; }
	u16 v_end() const noexcept
	{ return m_vend + 1; }

	attoseconds_t frame_time(u32 scale, XTAL const &osc) const noexcept
	{ return attotime::from_ticks((m_htotal + 1) * (m_vtotal + 1) * scale, osc).attoseconds(); }

private:
	u16 m_hsync, m_hstart, m_hend, m_htotal;
	u16 m_vsync, m_vstart, m_vend, m_vtotal;
};


class supermac_spec_shift_reg
{
public:
	void register_save(device_t &device);

	void reset() noexcept;

	void write_control(device_t &device, u32 data);
	void write_data(device_t &device, u32 data);

	bool ready() const noexcept { return m_shift_count == 10; }
	u8 select() const noexcept { return (m_shift_data >> 6) & 0x03; }
	u8 value() const noexcept { return (m_shift_data >> 8) & 0xff; }

private:
	u16 m_shift_data;
	u8 m_shift_count;
};

#endif // MAME_BUS_NUBUS_SUPERMAC_H