summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/alphatan.cpp
blob: 0bf5eb7ed1f3aef13b0e7f666785cfe2886767cd (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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    Tantel AlphaTantel


    Hardware:
    ---------
    CPU:    R6504

    RAM:    M6810
            M5101 - battery backed
            2114 x 2 - video RAM

    Video: SAA5020 VTC
           SAA5050 VCG
           SAA5070 VIOP
           TEA1002

    TODO:
    - implement SAA5070 (datasheet required)
    - keyboard matrix (probably via SAA5070)
    - cassette interface (via SAA5070)
    - program mode switch

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

#include "emu.h"
#include "cpu/m6502/m6504.h"
#include "machine/nvram.h"
#include "machine/output_latch.h"
#include "video/tea1002.h"
#include "video/saa5050.h"
#include "bus/centronics/ctronics.h"
#include "imagedev/cassette.h"

#include "emupal.h"
#include "screen.h"


class alphatan_state : public driver_device
{
public:
	alphatan_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
		, m_maincpu(*this, "maincpu")
		, m_videoram(*this, "videoram")
		, m_nvram(*this, "nvram")
		, m_screen(*this, "screen")
		, m_tea1002(*this, "encoder")
		, m_palette(*this, "palette")
		, m_trom(*this, "saa5050")
		, m_centronics(*this, "centronics")
		, m_cent_data_out(*this, "cent_data_out")
		, m_cassette(*this, "cassette")
		, m_config(*this, "CONFIG")
		{ }

	void alphatan(machine_config &config);

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

protected:
	virtual void machine_start() override;

private:
	required_device<cpu_device> m_maincpu;
	required_shared_ptr<uint8_t> m_videoram;
	required_device<nvram_device> m_nvram;
	required_device<screen_device> m_screen;
	required_device<tea1002_device> m_tea1002;
	required_device<palette_device> m_palette;
	required_device<saa5050_device> m_trom;
	required_device<centronics_device> m_centronics;
	required_device<output_latch_device> m_cent_data_out;
	required_device<cassette_image_device> m_cassette;
	required_ioport m_config;

	void alphatan_map(address_map &map);

	uint8_t saa5070_r(offs_t offset);
	void saa5070_w(offs_t offset, uint8_t data);
	void write400(offs_t offset, uint8_t data);
	void write600(offs_t offset, uint8_t data);

	void palette_init(palette_device &palette) const;
};

void alphatan_state::alphatan_map(address_map &map)
{
	map.unmap_value_high();
	map(0x0000, 0x007f).ram().mirror(0x0180); // MCM6810
	map(0x0200, 0x027f).ram().share("nvram"); // MCM5101
	map(0x0300, 0x0300).rw(FUNC(alphatan_state::saa5070_r), FUNC(alphatan_state::saa5070_w)); // write 0x20, 0x14, 0x0c, 0x18, 0x40, 0x90, 0x1f, 0xd4, 0x0f
	map(0x0400, 0x0400).w(FUNC(alphatan_state::write400)); // write 0x03, 0x06, 0x08, 0x00, 0x04, 0x07, 0x01, 0x05
	map(0x0500, 0x0500).w(m_cent_data_out, FUNC(output_latch_device::write));
	map(0x0600, 0x0600).w(FUNC(alphatan_state::write600)); // unknown, writes only 0x01, 0x02, or 0x03
	map(0x0700, 0x0700).portr("CONFIG");
	map(0x0800, 0x0fff).ram().share("videoram"); // 2x2114
	map(0x1000, 0x1fff).rom().region("maincpu", 0);
}


static INPUT_PORTS_START( alphatan )
	PORT_START("CONFIG")
	PORT_CONFNAME(0x10, 0x10, "Banner")
	PORT_CONFSETTING(0x00, "Granada")
	PORT_CONFSETTING(0x10, "Tantel")
INPUT_PORTS_END


uint8_t alphatan_state::saa5070_r(offs_t offset)
{
	uint8_t data = 0x00;

	//logerror("saa5070_r: %02x\n", data);

	return data;
}

void alphatan_state::saa5070_w(offs_t offset, uint8_t data)
{
	//logerror("saa5070_w: %02x\n", data);
}

void alphatan_state::write400(offs_t offset, uint8_t data)
{
	//logerror("write400: %02x\n", data);
}

void alphatan_state::write600(offs_t offset, uint8_t data)
{
	//logerror("write600: %02x\n", data);
}


void alphatan_state::palette_init(palette_device &palette) const
{
	for (int i = 0; i < 8; i++)
		palette.set_indirect_color(i, m_tea1002->color(i));
}

uint32_t alphatan_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	const rgb_t *palette = m_palette->palette()->entry_list_raw();

	m_trom->dew_w(1);
	m_trom->dew_w(0);

	for (int y = 0; y < 24 * 20; y++)
	{
		int sy = y / 20;
		int x = 0;

		m_trom->lose_w(1);
		m_trom->lose_w(0);

		int ssy = m_trom->tlc_r() ? sy : sy - 1;
		offs_t video_ram_addr = ssy * 64;

		for (int sx = 0; sx < 40; sx++)
		{
			uint8_t code = m_videoram[video_ram_addr++];

			m_trom->write(code & 0x7f);

			m_trom->f1_w(1);
			m_trom->f1_w(0);

			for (int bit = 0; bit < 12; bit++)
			{
				m_trom->tr6_w(1);
				m_trom->tr6_w(0);

				int color = m_trom->get_rgb();

				if (BIT(code, 7)) color ^= 0x07;

				bitmap.pix(y, x++) = palette[color];
			}
		}
	}

	return 0;
}


void alphatan_state::machine_start()
{
}


void alphatan_state::alphatan(machine_config &config)
{
	M6504(config, m_maincpu, 8.86_MHz_XTAL / 2);
	m_maincpu->set_addrmap(AS_PROGRAM, &alphatan_state::alphatan_map);

	NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_0);

	SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
	//m_screen->set_raw(6_MHz_XTAL, 768, 0, 480, 625, 0, 480);
	m_screen->set_refresh_hz(50);
	m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500));
	m_screen->set_size(768, 480);
	m_screen->set_visarea(0, 480-1, 0, 480-1);
	m_screen->set_screen_update(FUNC(alphatan_state::screen_update));

	TEA1002(config, m_tea1002, 8.86_MHz_XTAL);
	PALETTE(config, m_palette, FUNC(alphatan_state::palette_init), 8, 8);

	SAA5050(config, m_trom, 6_MHz_XTAL);

	CENTRONICS(config, m_centronics, centronics_devices, "printer");

	OUTPUT_LATCH(config, m_cent_data_out);
	m_centronics->set_output_latch(*m_cent_data_out);

	CASSETTE(config, m_cassette);
	m_cassette->set_default_state(CASSETTE_STOPPED);
}


ROM_START(alphatan)
	ROM_REGION(0x1000, "maincpu", 0)
	ROM_LOAD("tantel2732.bin", 0x0000, 0x1000, CRC(875c1ce9) SHA1(76e874cbc5d1341b09f57424181f24bdb31da210))
ROM_END


//    YEAR  NAME       PARENT  COMPAT  MACHINE     INPUT      CLASS           INIT        COMPANY    FULLNAME        FLAGS
COMP( 1981, alphatan,  0,      0,      alphatan,   alphatan,  alphatan_state, empty_init, "Tantel",  "AlphaTantel",  MACHINE_NO_SOUND_HW | MACHINE_NOT_WORKING )