summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes/mbc55x.h
blob: 055420ad26097bc95aa8aca13f3fe5c7d13992ec (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
187
188
189
190
// license:BSD-3-Clause
// copyright-holders:Phill Harvey-Smith
/*
    mbc55x.h
    Includes for the Sanyo MBC-550, MBC-555.

    Phill Harvey-Smith
    2011-01-29.
*/
#ifndef MAME_INCLUDES_MBC55X_H
#define MAME_INCLUDES_MBC55X_H

#pragma once

#include "bus/a2gameio/gameio.h"
#include "bus/centronics/ctronics.h"
#include "cpu/i86/i86.h"
#include "imagedev/floppy.h"
#include "machine/bankdev.h"
#include "machine/i8251.h"
#include "machine/i8255.h"
#include "machine/pic8259.h"
#include "machine/pit8253.h"
#include "machine/ram.h"
#include "machine/wd_fdc.h"
#include "sound/spkrdev.h"
#include "video/mc6845.h"

#include "debug/debugcon.h"
#include "debugger.h"
#include "emupal.h"

#include "formats/pc_dsk.h"


#define MAINCPU_TAG "maincpu"

#define SCREEN_TAG      "screen"
#define SCREEN_WIDTH_PIXELS     640
#define SCREEN_HEIGHT_LINES     250
#define SCREEN_NO_COLOURS       8

#define VIDEO_MEM_SIZE      (32*1024)
#define VID_MC6845_NAME     "mc6845"

// Red and blue colour planes sit at a fixed location, green
// is in main memory.

#define COLOUR_PLANE_SIZE   0x4000

#define RED_PLANE_OFFSET    (0*COLOUR_PLANE_SIZE)
#define BLUE_PLANE_OFFSET   (1*COLOUR_PLANE_SIZE)

#define COLOUR_PLANE_MEMBASE    0xF0000
#define RED_PLANE_MEMBASE   (COLOUR_PLANE_MEMBASE+RED_PLANE_OFFSET)
#define BLUE_PLANE_MEMBASE  (COLOUR_PLANE_MEMBASE+BLUE_PLANE_OFFSET)

#define RED_PLANE_TAG       "red"
#define BLUE_PLANE_TAG      "blue"

#define PPI8255_TAG     "ppi8255"
#define PIC8259_TAG     "pic8259"
#define PIT8253_TAG     "pit8253"

#define MONO_TAG                "mono"
#define I8251A_KB_TAG           "i8251a_kb"
#define FDC_TAG                 "wd1793"



class mbc55x_state : public driver_device
{
public:
	mbc55x_state(const machine_config &mconfig, device_type type, const char *tag) :
		driver_device(mconfig, type, tag),
		m_maincpu(*this, MAINCPU_TAG),
		m_iodecode(*this, "iodecode"),
		m_crtc(*this, VID_MC6845_NAME),
		m_kb_uart(*this, I8251A_KB_TAG),
		m_pit(*this, PIT8253_TAG),
		m_ppi(*this, PPI8255_TAG),
		m_pic(*this, PIC8259_TAG),
		m_fdc(*this, FDC_TAG),
		m_floppy(*this, FDC_TAG ":%u", 0U),
		m_gameio(*this, "gameio"),
		m_printer(*this, "printer"),
		m_speaker(*this, "speaker"),
		m_ram(*this, RAM_TAG),
		m_palette(*this, "palette")
	{
	}

	void mbc55x(machine_config &config);

	required_device<i8086_cpu_device> m_maincpu;
	required_device<address_map_bank_device> m_iodecode;

protected:
	virtual void machine_start() override;
	virtual void machine_reset() override;
	virtual void video_start() override;
	virtual void video_reset() override;

private:
	DECLARE_FLOPPY_FORMATS(floppy_formats);

	uint8_t iodecode_r(offs_t offset);
	void iodecode_w(offs_t offset, uint8_t data);

	uint8_t vram_page_r();
	void vram_page_w(uint8_t data);
	uint8_t game_io_r();
	uint8_t printer_status_r();
	void printer_data_w(uint8_t data);
	void disk_select_w(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(printer_busy_w);
	DECLARE_WRITE_LINE_MEMBER(printer_paper_end_w);
	DECLARE_WRITE_LINE_MEMBER(printer_select_w);

	DECLARE_WRITE_LINE_MEMBER(vid_hsync_changed);
	DECLARE_WRITE_LINE_MEMBER(vid_vsync_changed);

	MC6845_UPDATE_ROW(crtc_update_row);
	void mbc55x_palette(palette_device &palette) const;

	void mbc55x_io(address_map &map);
	void mbc55x_mem(address_map &map);
	void mbc55x_iodecode(address_map &map);

	void set_ram_size();

	required_device<mc6845_device> m_crtc;
	required_device<i8251_device> m_kb_uart;
	required_device<pit8253_device> m_pit;
	required_device<i8255_device> m_ppi;
	required_device<pic8259_device> m_pic;
	required_device<fd1793_device> m_fdc;
	required_device_array<floppy_connector, 4> m_floppy;
	required_device<apple2_gameio_device> m_gameio;
	required_device<centronics_device> m_printer;
	required_device<speaker_sound_device> m_speaker;
	required_device<ram_device> m_ram;
	required_device<palette_device> m_palette;

	uint32_t      m_debug_video;
	uint8_t       m_video_mem[VIDEO_MEM_SIZE];
	uint8_t       m_vram_page;
	uint8_t       m_printer_status;

	double        m_x_calibration, m_y_calibration;
	bool          m_ls123_strobe;
	double        m_ls123_clear_time[4];

	void video_debug(int ref, const std::vector<std::string> &params);
};

/*----------- defined in machine/mbc55x.c -----------*/

/* Memory controller */
#define RAM_BANK00_TAG  "bank0"
#define RAM_BANK01_TAG  "bank1"
#define RAM_BANK02_TAG  "bank2"
#define RAM_BANK03_TAG  "bank3"
#define RAM_BANK04_TAG  "bank4"
#define RAM_BANK05_TAG  "bank5"
#define RAM_BANK06_TAG  "bank6"
#define RAM_BANK07_TAG  "bank7"
#define RAM_BANK08_TAG  "bank8"
#define RAM_BANK09_TAG  "bank9"
#define RAM_BANK0A_TAG  "banka"
#define RAM_BANK0B_TAG  "bankb"
#define RAM_BANK0C_TAG  "bankc"
#define RAM_BANK0D_TAG  "bankd"
#define RAM_BANK0E_TAG  "banke"

#define RAM_BANK_SIZE   (64*1024)
#define RAM_BANK_COUNT  15

/* Floppy drive interface */

#define FDC_PAUSE               10000


/*----------- defined in video/mbc55x.c -----------*/

#define LINEAR_ADDR(seg,ofs)    ((seg<<4)+ofs)

#define OUTPUT_SEGOFS(mess,seg,ofs)  logerror("%s=%04X:%04X [%08X]\n",mess,seg,ofs,((seg<<4)+ofs))

#endif // MAME_INCLUDES_MBC55X_H