summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/sis630_gui.h
blob: b84326bdc699aa6846b5fb9fb2c6df7522373b42 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// license: BSD-3-Clause
// copyright-holders: Angelo Salese

#ifndef MAME_MACHINE_SIS630_VGA_H
#define MAME_MACHINE_SIS630_VGA_H

#pragma once

#include "pci.h"
#include "video/pc_vga.h"

class sis630_svga_device : public svga_device
{
public:
	sis630_svga_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

	virtual uint8_t mem_r(offs_t offset) override;
	virtual void mem_w(offs_t offset, uint8_t data) override;

	virtual u8 port_03c0_r(offs_t offset) override;
	virtual void port_03c0_w(offs_t offset, uint8_t data) override;

protected:
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual uint8_t crtc_reg_read(uint8_t index) override;
	virtual void crtc_reg_write(uint8_t index, uint8_t data) override;
	virtual uint8_t seq_reg_read(uint8_t index) override;
	virtual void seq_reg_write(uint8_t index, uint8_t data) override;
	virtual uint16_t offset() override;
	virtual void recompute_params() override;

	u8 m_crtc_ext_regs[0x100]{};
	u8 m_seq_ext_regs[0x100]{};
	u8 m_ramdac_mode = 0;
	u8 m_ext_misc_ctrl_0 = 0;
	u8 m_ext_vert_overflow = 0;
	u8 m_ext_horz_overflow[2]{};
	u32 m_svga_bank_reg_w = 0;
	u32 m_svga_bank_reg_r = 0;
	bool m_unlock_reg = false;

	std::tuple<u8, u8> flush_true_color_mode();
//  bool m_dual_seg_mode = false;
};

DECLARE_DEVICE_TYPE(SIS630_SVGA, sis630_svga_device)


class sis630_gui_device : public pci_device
{
public:
	sis630_gui_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

	void legacy_memory_map(address_map &map);
	void legacy_io_map(address_map &map);

protected:
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_add_mconfig(machine_config &config) override;

	virtual const tiny_rom_entry *device_rom_region() const override;

//  virtual void reset_all_mappings() override;

	virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
						   uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;

	virtual void config_map(address_map &map) override;

	void memory_map(address_map &map);
	void io_map(address_map &map);
	void space_io_map(address_map &map);

private:
	required_device<sis630_svga_device> m_svga;
	required_memory_region m_gui_rom;

	u8 vram_r(offs_t offset);
	void vram_w(offs_t offset, uint8_t data);
	u32 vga_3b0_r(offs_t offset, uint32_t mem_mask = ~0);
	void vga_3b0_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
	u32 vga_3c0_r(offs_t offset, uint32_t mem_mask = ~0);
	void vga_3c0_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
	u32 vga_3d0_r(offs_t offset, uint32_t mem_mask = ~0);
	void vga_3d0_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);

	void subvendor_w(offs_t offset, u32 data, u32 mem_mask = ~0);

	virtual u8 capptr_r() override;
	u32 agp_id_r();
	u32 agp_status_r();
	u32 agp_command_r(offs_t offset, uint32_t mem_mask);
	void agp_command_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);

	struct {
		bool enable = false;
		u8 data_rate = 0;
	} m_agp;

	u32 m_subsystem_logger_mask = 0;

	u8 unmap_log_r(offs_t offset);
	void unmap_log_w(offs_t offset, u8 data);
};

DECLARE_DEVICE_TYPE(SIS630_GUI, sis630_gui_device)

class sis630_bridge_device : public pci_bridge_device
{
public:
	template <typename T> sis630_bridge_device(
		const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock,
		T &&gui_tag
	) : sis630_bridge_device(mconfig, tag, owner, clock)
	{
		// either 0001 or 6001 as device ID
		set_ids_bridge(0x10396001, 0x00);
		//set_multifunction_device(true);
		m_vga.set_tag(std::forward<T>(gui_tag));
	}

	sis630_bridge_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
						   uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;

private:
	required_device<sis630_gui_device> m_vga;

	virtual void bridge_control_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0) override;


};

DECLARE_DEVICE_TYPE(SIS630_BRIDGE, sis630_bridge_device)


#endif