summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/xerox820.h
blob: 3cbb101bf88b5edb52603b7040164b0b3e977ca0 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// license:BSD-3-Clause
// copyright-holders:Curt Coder
#ifndef MAME_INCLUDES_XEROX820_H
#define MAME_INCLUDES_XEROX820_H

#pragma once

#include "bus/scsi/sa1403d.h"
#include "bus/rs232/rs232.h"
#include "cpu/z80/z80.h"
#include "machine/z80daisy.h"
#include "cpu/i86/i86.h"
#include "machine/com8116.h"
#include "machine/ram.h"
#include "bus/scsi/scsi.h"
#include "bus/scsi/scsihd.h"
#include "machine/timer.h"
#include "machine/wd_fdc.h"
#include "machine/x820kb.h"
#include "machine/z80pio.h"
#include "machine/z80ctc.h"
#include "machine/z80dart.h"
#include "sound/spkrdev.h"
#include "sound/beep.h"
#include "imagedev/snapquik.h"
#include "emupal.h"

#define SCREEN_TAG      "screen"

#define Z80_TAG         "u46"
#define Z80PIO_KB_TAG   "u105"
#define Z80PIO_GP_TAG   "u101"
#define Z80PIO_RD_TAG   "u8"
#define Z80SIO_TAG      "u96"
#define Z80CTC_TAG      "u99"
#define FD1771_TAG      "u109"
#define FD1797_TAG      "u109"
#define COM8116_TAG     "u76"
#define I8086_TAG       "i8086"
#define SASIBUS_TAG     "sasi"
#define RS232_A_TAG     "rs232a"
#define RS232_B_TAG     "rs232b"
#define KEYBOARD_TAG    "kb"

#define XEROX820_VIDEORAM_SIZE  0x1000
#define XEROX820_VIDEORAM_MASK  0x0fff

class xerox820_state : public driver_device
{
public:
	xerox820_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, Z80_TAG),
		m_kbpio(*this, Z80PIO_KB_TAG),
		m_ctc(*this, Z80CTC_TAG),
		m_sio(*this, Z80SIO_TAG),
		m_fdc(*this, FD1771_TAG),
		m_ram(*this, RAM_TAG),
		m_palette(*this, "palette"),
		m_floppy0(*this, FD1771_TAG":0"),
		m_floppy1(*this, FD1771_TAG":1"),
		m_kb(*this, KEYBOARD_TAG),
		m_rom(*this, Z80_TAG),
		m_char_rom(*this, "chargen"),
		m_video_ram(*this, "video_ram"),
		m_fdc_irq(0),
		m_fdc_drq(0),
		m_8n5(0),
		m_400_460(0)
	{ }
	
	void mk83(machine_config &config);
	void xerox820(machine_config &config);

	DECLARE_QUICKLOAD_LOAD_MEMBER(xerox820);

	DECLARE_READ8_MEMBER( fdc_r );
	DECLARE_WRITE8_MEMBER( fdc_w );
	DECLARE_WRITE8_MEMBER( scroll_w );
	//DECLARE_WRITE8_MEMBER( x120_system_w );
	DECLARE_READ8_MEMBER( kbpio_pa_r );
	DECLARE_WRITE8_MEMBER( kbpio_pa_w );
	DECLARE_READ8_MEMBER( kbpio_pb_r );
	DECLARE_WRITE_LINE_MEMBER( fdc_intrq_w );
	DECLARE_WRITE_LINE_MEMBER( fdc_drq_w );

protected:
	uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);


	TIMER_DEVICE_CALLBACK_MEMBER(ctc_tick);

	void mk83_mem(address_map &map);
	void xerox820_io(address_map &map);
	void xerox820_mem(address_map &map);

	virtual void machine_start() override;
	virtual void machine_reset() override;

	required_device<cpu_device> m_maincpu;
	required_device<z80pio_device> m_kbpio;
	required_device<z80ctc_device> m_ctc;
	required_device<z80sio0_device> m_sio;
	required_device<wd_fdc_device_base> m_fdc;
	required_device<ram_device> m_ram;
	required_device<palette_device> m_palette;
	required_device<floppy_connector> m_floppy0;
	required_device<floppy_connector> m_floppy1;
	required_device<xerox_820_keyboard_device> m_kb;
	required_memory_region m_rom;
	required_memory_region m_char_rom;
	required_shared_ptr<uint8_t> m_video_ram;

	virtual void bankswitch(int bank);
	void update_nmi();

	/* video state */
	uint8_t m_scroll;                     /* vertical scroll */
	uint8_t m_framecnt;
	int m_ncset2;                       /* national character set */
	int m_vatt;                         /* X120 video attribute */
	int m_lowlite;                      /* low light attribute */
	int m_chrom;                        /* character ROM index */

	/* floppy state */
	bool m_fdc_irq;                     /* interrupt request */
	bool m_fdc_drq;                     /* data request */
	int m_8n5;                          /* 5.25" / 8" drive select */
	int m_400_460;                      /* double sided disk detect */
};

class bigboard_state : public xerox820_state
{
public:
	bigboard_state(const machine_config &mconfig, device_type type, const char *tag)
		: xerox820_state(mconfig, type, tag)
		, m_beeper(*this, "beeper")
	{ }

	DECLARE_WRITE8_MEMBER( kbpio_pa_w );

	void bigboard(machine_config &config);
protected:
	virtual void machine_reset() override;

	TIMER_CALLBACK_MEMBER(bigboard_beepoff);

	required_device<beep_device> m_beeper;

	bool m_bit5;
};

class xerox820ii_state : public xerox820_state
{
public:
	xerox820ii_state(const machine_config &mconfig, device_type type, const char *tag) :
		xerox820_state(mconfig, type, tag),
		m_speaker(*this, "speaker"),
		m_sasibus(*this, SASIBUS_TAG)
	{
	}

	DECLARE_WRITE8_MEMBER( bell_w );
	DECLARE_WRITE8_MEMBER( slden_w );
	DECLARE_WRITE8_MEMBER( chrom_w );
	DECLARE_WRITE8_MEMBER( lowlite_w );
	DECLARE_WRITE8_MEMBER( sync_w );

	DECLARE_WRITE8_MEMBER( rdpio_pb_w );
	DECLARE_WRITE_LINE_MEMBER( rdpio_pardy_w );

	void xerox168(machine_config &config);
	void xerox820ii(machine_config &config);
	void xerox168_mem(address_map &map);
	void xerox820ii_io(address_map &map);
	void xerox820ii_mem(address_map &map);
protected:
	virtual void machine_reset() override;

	void bankswitch(int bank) override;

	required_device<speaker_sound_device> m_speaker;
	required_device<scsi_port_device> m_sasibus;
};

#endif // MAME_INCLUDES_XEROX820_H