summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/includes/thomson.h
blob: 02b5f090ec0b1840597b49cd68add874c6840adc (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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/**********************************************************************

  Copyright (C) Antoine Mine' 2006

  Thomson 8-bit computers

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

#ifndef _THOMSON_H_
#define _THOMSON_H_

#include "emu.h"
#include "cpu/m6809/m6809.h"
#include "machine/6821pia.h"
#include "machine/mc6846.h"
#include "machine/6850acia.h"
#include "machine/6551acia.h"
#include "sound/dac.h"
#include "audio/mea8000.h"
#include "machine/ctronics.h"
#include "imagedev/cartslot.h"
#include "imagedev/cassette.h"
#include "machine/mc6843.h"
#include "machine/mc6846.h"
#include "machine/mc6854.h"
#include "formats/thom_cas.h"
#include "formats/thom_dsk.h"
#include "machine/thomflop.h"


class thomson_state : public driver_device
{
public:
	thomson_state(const machine_config &mconfig, device_type type, const char *tag)
		: driver_device(mconfig, type, tag)
	{ }

	DECLARE_DEVICE_IMAGE_LOAD_MEMBER( to7_cartridge );
	DECLARE_DEVICE_IMAGE_LOAD_MEMBER( mo5_cartridge );
};

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

/*************************** common ********************************/

/* 6821 PIAs */
#define THOM_PIA_SYS    "pia_0"  /* system PIA */
#define THOM_PIA_GAME   "pia_1"  /* music & game PIA (joypad + sound) */
#define THOM_PIA_IO     "pia_2"  /* CC 90-232 I/O extension (parallel & RS-232) */
#define THOM_PIA_MODEM  "pia_3"  /* MD 90-120 MODEM extension */

/* sound ports */
#define THOM_SOUND_BUZ    0 /* 1-bit buzzer */
#define THOM_SOUND_GAME   1 /* 6-bit game port DAC */
#define THOM_SOUND_SPEECH 2 /* speech synthesis */

/* bank-switching */
#define THOM_CART_BANK  "bank2" /* cartridge ROM */
#define THOM_RAM_BANK   "bank3" /* data RAM */
#define THOM_FLOP_BANK  "bank4" /* external floppy controller ROM */
#define THOM_BASE_BANK  "bank5" /* system RAM */

extern const pia6821_interface to7_pia6821_sys;
extern const pia6821_interface to7_pia6821_io;
extern const pia6821_interface to7_pia6821_modem;
extern const pia6821_interface to7_pia6821_game;
extern const pia6821_interface to770_pia6821_sys;
extern const pia6821_interface mo5_pia6821_sys;
extern const pia6821_interface to9_pia6821_sys;
extern const pia6821_interface to8_pia6821_sys;
extern const pia6821_interface to9p_pia6821_sys;
extern const pia6821_interface mo6_pia6821_game;
extern const pia6821_interface mo6_pia6821_sys;
extern const pia6821_interface mo5nr_pia6821_sys;
extern const pia6821_interface mo5nr_pia6821_game;

/***************************** TO7 / T9000 *************************/

/* cartridge bank-switching */
extern DECLARE_WRITE8_HANDLER ( to7_cartridge_w );
extern DECLARE_READ8_HANDLER  ( to7_cartridge_r );

/* dispatch MODEM or speech synthesis extension */
extern DECLARE_READ8_HANDLER ( to7_modem_mea8000_r );
extern DECLARE_WRITE8_HANDLER ( to7_modem_mea8000_w );

/* MIDI extension (actually an 6850 ACIA) */
extern DECLARE_READ8_HANDLER  ( to7_midi_r );
extern DECLARE_WRITE8_HANDLER ( to7_midi_w );

extern MACHINE_START ( to7 );
extern MACHINE_RESET ( to7 );

/* centronics */
extern const centronics_interface to7_centronics_config;
extern const centronics_interface mo6_centronics_config;

/* timer */
extern const mc6846_interface to7_timer;

/* speech synthesis */
extern const mea8000_interface to7_speech;

/* modem */
extern const acia6850_interface to7_modem;


/***************************** TO7/70 ******************************/

/* gate-array */
extern DECLARE_READ8_HANDLER  ( to770_gatearray_r );
extern DECLARE_WRITE8_HANDLER ( to770_gatearray_w );

extern MACHINE_START ( to770 );
extern MACHINE_RESET ( to770 );

extern const mc6846_interface to770_timer;

/***************************** MO5 ******************************/

/* gate-array */
extern DECLARE_READ8_HANDLER  ( mo5_gatearray_r );
extern DECLARE_WRITE8_HANDLER ( mo5_gatearray_w );

/* cartridge / extended RAM bank-switching */
extern DECLARE_WRITE8_HANDLER ( mo5_ext_w );
extern DECLARE_WRITE8_HANDLER ( mo5_cartridge_w );
extern DECLARE_READ8_HANDLER  ( mo5_cartridge_r );

extern MACHINE_START ( mo5 );
extern MACHINE_RESET ( mo5 );


/***************************** TO9 ******************************/

/* IEEE extension */
extern DECLARE_WRITE8_HANDLER ( to9_ieee_w );
extern DECLARE_READ8_HANDLER  ( to9_ieee_r );

/* ROM bank-switching */
extern DECLARE_WRITE8_HANDLER ( to9_cartridge_w );
extern DECLARE_READ8_HANDLER  ( to9_cartridge_r );

/* system gate-array */
extern DECLARE_READ8_HANDLER  ( to9_gatearray_r );
extern DECLARE_WRITE8_HANDLER ( to9_gatearray_w );

/* video gate-array */
extern DECLARE_READ8_HANDLER  ( to9_vreg_r );
extern DECLARE_WRITE8_HANDLER ( to9_vreg_w );

/* keyboard */
extern DECLARE_READ8_HANDLER  ( to9_kbd_r );
extern DECLARE_WRITE8_HANDLER ( to9_kbd_w );

extern MACHINE_START ( to9 );
extern MACHINE_RESET ( to9 );

extern const mc6846_interface to9_timer;


/***************************** TO8 ******************************/

/* bank-switching */
#define TO8_SYS_LO      "bank5" /* system RAM low 2 Kb */
#define TO8_SYS_HI      "bank6" /* system RAM hi 2 Kb */
#define TO8_DATA_LO     "bank7" /* data RAM low 2 Kb */
#define TO8_DATA_HI     "bank8" /* data RAM hi 2 Kb */
#define TO8_BIOS_BANK   "bank9" /* BIOS ROM */

extern UINT8 to8_data_vpage;
extern UINT8 to8_cart_vpage;

extern DECLARE_WRITE8_HANDLER ( to8_cartridge_w );
extern DECLARE_READ8_HANDLER  ( to8_cartridge_r );

/* system gate-array */
extern DECLARE_READ8_HANDLER  ( to8_gatearray_r );
extern DECLARE_WRITE8_HANDLER ( to8_gatearray_w );

/* video gate-array */
extern DECLARE_READ8_HANDLER  ( to8_vreg_r );
extern DECLARE_WRITE8_HANDLER ( to8_vreg_w );

/* floppy */
extern DECLARE_READ8_HANDLER  ( to8_floppy_r );
extern DECLARE_WRITE8_HANDLER ( to8_floppy_w );

extern MACHINE_START ( to8 );
extern MACHINE_RESET ( to8 );

extern const mc6846_interface to8_timer;


/***************************** TO9+ ******************************/

extern MACHINE_START ( to9p );
extern MACHINE_RESET ( to9p );

extern const mc6846_interface to9p_timer;


/***************************** MO6 ******************************/

extern DECLARE_READ8_HANDLER  ( mo6_cartridge_r );
extern DECLARE_WRITE8_HANDLER ( mo6_cartridge_w );
extern DECLARE_WRITE8_HANDLER ( mo6_ext_w );

/* system gate-array */
extern DECLARE_READ8_HANDLER  ( mo6_gatearray_r );
extern DECLARE_WRITE8_HANDLER ( mo6_gatearray_w );

/* video gate-array */
extern DECLARE_READ8_HANDLER  ( mo6_vreg_r );
extern DECLARE_WRITE8_HANDLER ( mo6_vreg_w );

extern MACHINE_START ( mo6 );
extern MACHINE_RESET ( mo6 );


/***************************** MO5 NR ******************************/

/* network */
extern DECLARE_READ8_HANDLER  ( mo5nr_net_r );
extern DECLARE_WRITE8_HANDLER ( mo5nr_net_w );

/* printer */
extern DECLARE_READ8_HANDLER  ( mo5nr_prn_r );
extern DECLARE_WRITE8_HANDLER ( mo5nr_prn_w );

extern MACHINE_START ( mo5nr );
extern MACHINE_RESET ( mo5nr );


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

/*
   TO7 video:
   one line (64 us) =
      56 left border pixels ( 7 us)
   + 320 active pixels (40 us)
   +  56 right border pixels ( 7 us)
   +     horizontal retrace (10 us)

   one image (20 ms) =
      47 top border lines (~3 ms)
   + 200 active lines (12.8 ms)
   +  47 bottom border lines (~3 ms)
   +     vertical retrace (~1 ms)

   TO9 and up introduced a half (160 pixels) and double (640 pixels)
   horizontal mode, but still in 40 us (no change in refresh rate).
*/


/***************************** dimensions **************************/

/* original screen dimension (may be different from emulated screen!) */
#define THOM_ACTIVE_WIDTH  320
#define THOM_BORDER_WIDTH   56
#define THOM_ACTIVE_HEIGHT 200
#define THOM_BORDER_HEIGHT  47
#define THOM_TOTAL_WIDTH   432
#define THOM_TOTAL_HEIGHT  294

/* Emulated screen dimension may be doubled to allow hi-res 640x200 mode.
   Emulated screen can have smaller borders.
 */

/* maximum number of video pages:
   1 for TO7 generation (including MO5)
   4 for TO8 generation (including TO9, MO6)
 */
#define THOM_NB_PAGES 4

/* page 0 is banked */
#define THOM_VRAM_BANK "bank1"

extern UINT8* thom_vram;

/*********************** video signals *****************************/

struct thom_vsignal {
	unsigned count;  /* pixel counter */
	unsigned init;   /* 1 -> active vertical windos, 0 -> border/VBLANK */
	unsigned inil;   /* 1 -> active horizontal window, 0 -> border/HBLANK */
	unsigned lt3;    /* bit 3 of us counter */
	unsigned line;   /* line counter */
};

/* current video position */
extern struct thom_vsignal thom_get_vsignal ( running_machine &machine );


/************************* lightpen ********************************/

/* specific TO7 / T9000 lightpen code (no video gate-array) */
extern unsigned to7_lightpen_gpl ( running_machine &machine, int decx, int decy );

/* video position corresponding to lightpen (with some offset) */
extern struct thom_vsignal thom_get_lightpen_vsignal ( running_machine &machine, int xdec, int ydec,
								int xdec2 );

/* specify a lightpencall-back function, called nb times per frame */
extern void thom_set_lightpen_callback ( running_machine &machine, int nb, void (*cb) ( running_machine &machine, int step ) );


/***************************** commons *****************************/

extern VIDEO_START  ( thom );
extern SCREEN_UPDATE_IND16 ( thom );
extern PALETTE_INIT ( thom );
extern SCREEN_VBLANK    ( thom );

/* pass video init signal */
extern void thom_set_init_callback ( running_machine &machine, void (*cb) ( running_machine &machine, int init ) );

/* TO7 TO7/70 MO5 video bank switch */
extern void thom_set_mode_point ( running_machine &machine, int point );

/* set the palette index for the border color */
extern void thom_set_border_color ( running_machine &machine, unsigned color );

/* set one of 16 palette indices to one of 4096 colors */
extern void thom_set_palette ( running_machine &machine, unsigned index, UINT16 color );


/* video modes */
#define THOM_VMODE_TO770       0
#define THOM_VMODE_MO5         1
#define THOM_VMODE_BITMAP4     2
#define THOM_VMODE_BITMAP4_ALT 3
#define THOM_VMODE_80          4
#define THOM_VMODE_BITMAP16    5
#define THOM_VMODE_PAGE1       6
#define THOM_VMODE_PAGE2       7
#define THOM_VMODE_OVERLAY     8
#define THOM_VMODE_OVERLAY3    9
#define THOM_VMODE_TO9        10
#define THOM_VMODE_80_TO9     11
#define THOM_VMODE_NB         12

/* change the current video-mode */
extern void thom_set_video_mode ( running_machine &machine, unsigned mode );

/* select which video page shown among the 4 available */
extern void thom_set_video_page ( running_machine &machine, unsigned page );

/* to tell there is some floppy activity, stays up for a few frames */
extern void thom_floppy_active ( running_machine &machine, int write );


/***************************** TO7 / T9000 *************************/

extern DECLARE_WRITE8_HANDLER ( to7_vram_w );


/***************************** TO7/70 ******************************/

extern DECLARE_WRITE8_HANDLER ( to770_vram_w );


/***************************** TO8 ******************************/

/* write to video memory through system space (always page 1) */
DECLARE_WRITE8_HANDLER ( to8_sys_lo_w );
DECLARE_WRITE8_HANDLER ( to8_sys_hi_w );

/* write to video memory through data space */
DECLARE_WRITE8_HANDLER ( to8_data_lo_w );
DECLARE_WRITE8_HANDLER ( to8_data_hi_w );

/* write to video memory page through cartridge addresses space */
DECLARE_WRITE8_HANDLER ( to8_vcart_w );



class to7_io_line_device :  public device_t,
							public device_serial_interface
{
public:
	// construction/destruction
	to7_io_line_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);

	virtual void input_callback(UINT8 state);

	/* read data register */
	DECLARE_READ8_MEMBER(porta_in);

	/* write data register */
	DECLARE_WRITE8_MEMBER(porta_out);
protected:
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();
};

extern const device_type TO7_IO_LINE;

#define MCFG_TO7_IO_LINE_ADD(_tag)  \
	MCFG_DEVICE_ADD((_tag), TO7_IO_LINE, 0)

#endif /* _THOMSON_H_ */