summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/ti99/peb/horizon.h
blob: 7fb99429f5b91117a64a0f4b24199592803dcc79 (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
// license:LGPL-2.1+
// copyright-holders:Michael Zapf
/****************************************************************************

    Horizon Ramdisk
    See horizon.c for documentation

    Michael Zapf

    February 2012

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

#ifndef MAME_BUS_TI99_PEB_HORIZON_H
#define MAME_BUS_TI99_PEB_HORIZON_H

#pragma once

#include "peribox.h"
#include "machine/ram.h"
#include "machine/74259.h"

namespace bus::ti99::peb {

class horizon_ramdisk_device : public device_t, public device_ti99_peribox_card_interface, public device_nvram_interface
{
public:
	horizon_ramdisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
	void readz(offs_t offset, uint8_t *value) override;
	void write(offs_t offset, uint8_t data) override;

	void crureadz(offs_t offset, uint8_t *value) override;
	void cruwrite(offs_t offset, uint8_t data) override;

	DECLARE_INPUT_CHANGED_MEMBER( hs_changed );

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

	virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
	virtual ioport_constructor device_input_ports() const override ATTR_COLD;

	virtual void nvram_default() override;
	virtual bool nvram_read(util::read_stream &file) override;
	virtual bool nvram_write(util::write_stream &file) override;
	virtual bool nvram_can_write() const override;

	void reset_in(int state) override;

private:
	required_device<ram_device> m_ram;
	required_device<ram_device> m_dsrram;
	required_device<ram_device> m_optram;
	required_device<ls259_device> m_crulatch_u4;
	required_device<ls259_device> m_crulatch_u3;

	void    get_mem_size(int& ramsize, int& dsrsize);
	void    get_address_prefix();
	void    read_write(offs_t offset, uint8_t *value, bool write);

	bool    m_32k_installed;
	bool    m_phoenix_accessed;
	bool    m_dsr32k;
	bool    m_128kx8;
	bool    m_geneve_mode;
	bool    m_phoenix_split;
	bool    m_hideswitch;
	bool    m_rambo_supported;

	bool    m_reset_in;

	// Do not save if nothing was modified.
	bool    m_modified;

	int     m_page;
	int     m_bank;
	int     m_ramsize;

	int     m_cru_base_horizon;
	int     m_cru_base_phoenix;

	// Debugging
	int     m_current_bank;
	int     m_current_page;
};

} // end namespace bus::ti99::peb

DECLARE_DEVICE_TYPE_NS(TI99_HORIZON, bus::ti99::peb, horizon_ramdisk_device)

#endif // MAME_BUS_TI99_PEB_HORIZON_H