Previous 15994 Revisions Next

r9969 Sunday 9th January, 2011 at 11:04:10 UTC by Robbbert
[EXIDY] Renamed to Sorcerer. Converted to MODERN. Added notes.
[src/mess]mess.mak messdriv.c
[src/mess/drivers]exidy.c sorcerer.c*
[src/mess/formats]exidydsk.c exidydsk.h sorc_dsk.c* sorc_dsk.h*
[src/mess/includes]exidy.h sorcerer.h*
[src/mess/machine]exidy.c sorcerer.c*

src/mess/machine/exidy.c
r9968r9969
1/******************************************************************************
2
3  Exidy Sorcerer machine functions
4
5*******************************************************************************/
6
7#include "emu.h"
8#include "cpu/z80/z80.h"
9#include "sound/dac.h"
10#include "sound/wave.h"
11#include "machine/ctronics.h"
12#include "imagedev/cassette.h"
13#include "imagedev/snapquik.h"
14#include "imagedev/cartslot.h"
15#include "machine/ay31015.h"
16#include "../includes/exidy.h"
17#include "imagedev/flopdrv.h"
18
19
20
21
22#if 0
23
24/* The serial code (which was never connected to the outside) is disabled for now. */
25
26/* timer for exidy serial chip transmit and receive */
27
28static TIMER_CALLBACK(exidy_serial_timer_callback)
29{
30   exidy_state *state = machine->driver_data<exidy_state>();
31   /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe.
32    Transmit and receive clocks are connected to the same clock */
33
34   /* if rs232 is disabled, receive clock is linked to cassette hardware */
35   if (state->fe & 0x80)
36   {
37      /* connect to rs232 */
38   }
39}
40#endif
41
42
43/* timer to read cassette waveforms */
44
45
46static device_t *cassette_device_image(running_machine *machine)
47{
48   exidy_state *state = machine->driver_data<exidy_state>();
49   if (state->fe & 0x20)
50      return machine->device("cassette2");
51   else
52      return machine->device("cassette1");
53}
54
55
56
57static TIMER_CALLBACK(exidy_cassette_tc)
58{
59   exidy_state *state = machine->driver_data<exidy_state>();
60   UINT8 cass_ws = 0;
61   switch (state->fe & 0xc0)      /*/ bit 7 low indicates cassette */
62   {
63      case 0x00:            /* Cassette 300 baud */
64
65         /* loading a tape - this is basically the same as the super80.
66                We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */
67
68         state->cass_data.input.length++;
69
70         cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
71
72         if (cass_ws != state->cass_data.input.level)
73         {
74            state->cass_data.input.level = cass_ws;
75            state->cass_data.input.bit = ((state->cass_data.input.length < 0x6) || (state->cass_data.input.length > 0x20)) ? 1 : 0;
76            state->cass_data.input.length = 0;
77            ay31015_set_input_pin( state->ay31015, AY31015_SI, state->cass_data.input.bit );
78         }
79
80         /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies.
81                Synchronisation of the frequency pulses to the uart is extremely important. */
82
83         state->cass_data.output.length++;
84         if (!(state->cass_data.output.length & 0x1f))
85         {
86            cass_ws = ay31015_get_output_pin( state->ay31015, AY31015_SO );
87            if (cass_ws != state->cass_data.output.bit)
88            {
89               state->cass_data.output.bit = cass_ws;
90               state->cass_data.output.length = 0;
91            }
92         }
93
94         if (!(state->cass_data.output.length & 3))
95         {
96            if (!((state->cass_data.output.bit == 0) && (state->cass_data.output.length & 4)))
97            {
98               state->cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
99               cassette_output(cassette_device_image(machine), state->cass_data.output.level ? -1.0 : +1.0);
100            }
101         }
102         return;
103
104      case 0x40:         /* Cassette 1200 baud */
105         /* loading a tape */
106         state->cass_data.input.length++;
107
108         cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
109
110         if (cass_ws != state->cass_data.input.level || state->cass_data.input.length == 10)
111         {
112            state->cass_data.input.bit = ((state->cass_data.input.length < 10) || (state->cass_data.input.length > 0x20)) ? 1 : 0;
113            if ( cass_ws != state->cass_data.input.level )
114            {
115               state->cass_data.input.length = 0;
116               state->cass_data.input.level = cass_ws;
117            }
118            ay31015_set_input_pin( state->ay31015, AY31015_SI, state->cass_data.input.bit );
119         }
120
121         /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */
122
123         state->cass_data.output.length++;
124         if (!(state->cass_data.output.length & 0x07))
125         {
126            cass_ws = ay31015_get_output_pin( state->ay31015, AY31015_SO );
127            if (cass_ws != state->cass_data.output.bit)
128            {
129               state->cass_data.output.bit = cass_ws;
130               state->cass_data.output.length = 0;
131            }
132         }
133
134         if (!(state->cass_data.output.length & 7))
135         {
136            if (!((state->cass_data.output.bit == 0) && (state->cass_data.output.length & 8)))
137            {
138               state->cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
139               cassette_output(cassette_device_image(machine), state->cass_data.output.level ? -1.0 : +1.0);
140            }
141         }
142         return;
143   }
144}
145
146
147/* after the first 4 bytes have been read from ROM, switch the ram back in */
148static TIMER_CALLBACK( exidy_reset )
149{
150   memory_set_bank(machine, "boot", 0);
151}
152
153WRITE8_HANDLER(exidy_fc_w)
154{
155   exidy_state *state = space->machine->driver_data<exidy_state>();
156   ay31015_set_transmit_data( state->ay31015, data );
157}
158
159
160WRITE8_HANDLER(exidy_fd_w)
161{
162   exidy_state *state = space->machine->driver_data<exidy_state>();
163   /* Translate data to control signals */
164
165   ay31015_set_input_pin( state->ay31015, AY31015_CS, 0 );
166   ay31015_set_input_pin( state->ay31015, AY31015_NB1, ( data & 0x01 ) ? 1 : 0 );
167   ay31015_set_input_pin( state->ay31015, AY31015_NB2, ( data & 0x02 ) ? 1 : 0 );
168   ay31015_set_input_pin( state->ay31015, AY31015_TSB, ( data & 0x04 ) ? 1 : 0 );
169   ay31015_set_input_pin( state->ay31015, AY31015_EPS, ( data & 0x08 ) ? 1 : 0 );
170   ay31015_set_input_pin( state->ay31015, AY31015_NP,  ( data & 0x10 ) ? 1 : 0 );
171   ay31015_set_input_pin( state->ay31015, AY31015_CS, 1 );
172}
173
174#define EXIDY_CASSETTE_MOTOR_MASK ((1<<4)|(1<<5))
175
176
177WRITE8_HANDLER(exidy_fe_w)
178{
179   exidy_state *state = space->machine->driver_data<exidy_state>();
180   UINT8 changed_bits = (state->fe ^ data) & 0xf0;
181   state->fe = data;
182
183   /* bits 0..3 */
184   state->keyboard_line = data & 0x0f;
185
186   if (!changed_bits) return;
187
188   /* bits 4..5 */
189   /* does user want to hear the sound? */
190   if ((input_port_read(space->machine, "CONFIG") & 8) && (data & EXIDY_CASSETTE_MOTOR_MASK))
191   {
192      if (data & 0x20)
193      {
194         cassette_change_state(space->machine->device("cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
195         cassette_change_state(space->machine->device("cassette2"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
196      }
197      else
198      {
199         cassette_change_state(space->machine->device("cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
200         cassette_change_state(space->machine->device("cassette1"), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
201      }
202   }
203   else
204   {
205      cassette_change_state(space->machine->device("cassette2"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
206      cassette_change_state(space->machine->device("cassette1"), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
207   }
208
209   /* cassette 1 motor */
210   cassette_change_state(space->machine->device("cassette1"),
211      (data & 0x10) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
212
213   /* cassette 2 motor */
214   cassette_change_state(space->machine->device("cassette2"),
215      (data & 0x20) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
216
217   if ((data & EXIDY_CASSETTE_MOTOR_MASK) && (~data & 0x80))
218      timer_adjust_periodic(state->cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(19200));
219   else
220      timer_adjust_oneshot(state->cassette_timer, attotime_zero, 0);
221
222   /* bit 6 */
223   if (changed_bits & 0x40)
224   {
225      ay31015_set_receiver_clock( state->ay31015, (data & 0x40) ? 19200.0 : 4800.0);
226      ay31015_set_transmitter_clock( state->ay31015, (data & 0x40) ? 19200.0 : 4800.0);
227   }
228
229   /* bit 7 */
230   if (changed_bits & 0x80)
231   {
232      if (data & 0x80)
233      {
234      /* connect to serial device (not yet emulated) */
235//          timer_adjust_periodic(state->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate));
236      }
237      else
238      {
239      /* connect to tape */
240//          hd6402_connect(&cassette_serial_connection);
241      }
242   }
243}
244
245WRITE8_HANDLER(exidy_ff_w)
246{
247   device_t *printer = space->machine->device("centronics");
248   device_t *dac_device = space->machine->device("dac");
249   /* reading the config switch */
250   switch (input_port_read(space->machine, "CONFIG") & 0x06)
251   {
252      case 0: /* speaker */
253         dac_data_w(dac_device, data);
254         break;
255
256      case 2: /* Centronics 7-bit printer */
257         /* bit 7 = strobe, bit 6..0 = data */
258         centronics_strobe_w(printer, (~data>>7) & 0x01);
259         centronics_data_w(printer, 0, data & 0x7f);
260         break;
261
262      case 4: /* 8-bit parallel output */
263         /* hardware strobe driven from port select, bit 7..0 = data */
264         centronics_strobe_w(printer, 1);
265         centronics_data_w(printer, 0, data);
266         centronics_strobe_w(printer, 0);
267         break;
268   }
269}
270
271READ8_HANDLER(exidy_fc_r)
272{
273   exidy_state *state = space->machine->driver_data<exidy_state>();
274   UINT8 data = ay31015_get_received_data( state->ay31015 );
275   ay31015_set_input_pin( state->ay31015, AY31015_RDAV, 0 );
276   ay31015_set_input_pin( state->ay31015, AY31015_RDAV, 1 );
277   return data;
278}
279
280READ8_HANDLER(exidy_fd_r)
281{
282   exidy_state *state = space->machine->driver_data<exidy_state>();
283   /* set unused bits high */
284   UINT8 data = 0xe0;
285
286   ay31015_set_input_pin( state->ay31015, AY31015_SWE, 0 );
287   data |= ay31015_get_output_pin( state->ay31015, AY31015_TBMT ) ? 0x01 : 0;
288   data |= ay31015_get_output_pin( state->ay31015, AY31015_DAV  ) ? 0x02 : 0;
289   data |= ay31015_get_output_pin( state->ay31015, AY31015_OR   ) ? 0x04 : 0;
290   data |= ay31015_get_output_pin( state->ay31015, AY31015_FE   ) ? 0x08 : 0;
291   data |= ay31015_get_output_pin( state->ay31015, AY31015_PE   ) ? 0x10 : 0;
292   ay31015_set_input_pin( state->ay31015, AY31015_SWE, 1 );
293
294   return data;
295}
296
297READ8_HANDLER(exidy_fe_r)
298{
299   exidy_state *state = space->machine->driver_data<exidy_state>();
300   /* bits 6..7
301     - hardware handshakes from user port
302     - not emulated
303     - tied high, allowing PARIN and PAROUT bios routines to run */
304
305   UINT8 data = 0xc0;
306   static const char *const keynames[] = {
307      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
308      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15"
309   };
310
311   /* bit 5 - vsync (inverted) */
312   data |= (((~input_port_read(space->machine, "VS")) & 0x01)<<5);
313
314   /* bits 4..0 - keyboard data */
315   data |= (input_port_read(space->machine, keynames[state->keyboard_line]) & 0x1f);
316
317   return data;
318}
319
320READ8_HANDLER(exidy_ff_r)
321{
322   /* The use of the parallel port as a general purpose port is not emulated.
323    Currently the only use is to read the printer status in the Centronics CENDRV bios routine.
324    This uses bit 7. The other bits have been set high (=nothing plugged in).
325    This fixes those games that use a joystick. */
326
327   device_t *printer = space->machine->device("centronics");
328   UINT8 data=0x7f;
329
330   /* bit 7 = printer busy
331    0 = printer is not busy */
332
333   data |= centronics_busy_r(printer) << 7;
334
335   return data;
336}
337
338
339
340/**********************************************************************************************************/
341
342Z80BIN_EXECUTE( exidy )
343{
344   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
345
346   if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (space->read_byte(0xdffa) != 0xc3))
347      return;               /* can't run a program if the cartridge isn't in */
348
349   /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run.
350    1. A start address of 01D5 indicates a basic program which needs its pointers fixed up.
351    2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt).
352    Important addresses:
353        01D5 = start (load) address of a conventional basic program
354        C858 = an autorun basic program will have this exec address on the tape
355        C3DD = part of basic that displays READY and lets user enter input */
356
357   if ((start_address == 0x1d5) || (execute_address == 0xc858))
358   {
359      UINT8 i;
360      static const UINT8 data[]={
361         0xcd, 0x26, 0xc4,   // CALL C426    ;set up other pointers
362         0x21, 0xd4, 1,      // LD HL,01D4   ;start of program address (used by C689)
363         0x36, 0,      // LD (HL),00   ;make sure dummy end-of-line is there
364         0xc3, 0x89, 0xc6   // JP C689  ;run program
365      };
366
367      for (i = 0; i < ARRAY_LENGTH(data); i++)
368         space->write_byte(0xf01f + i, data[i]);
369
370      if (!autorun)
371         space->write_word(0xf028,0xc3dd);
372
373      /* tell BASIC where program ends */
374      space->write_byte(0x1b7, (end_address >> 0) & 0xff);
375      space->write_byte(0x1b8, (end_address >> 8) & 0xff);
376
377      if ((execute_address != 0xc858) && autorun)
378         space->write_word(0xf028, execute_address);
379
380      cpu_set_reg(machine->device("maincpu"), STATE_GENPC, 0xf01f);
381   }
382   else
383   {
384      if (autorun)
385         cpu_set_reg(machine->device("maincpu"), STATE_GENPC, execute_address);
386   }
387}
388
389/******************************************************************************
390 Snapshot Handling
391******************************************************************************/
392
393SNAPSHOT_LOAD(exidy)
394{
395   UINT8 *ptr = image.device().machine->region("maincpu")->base();
396   device_t *cpu = image.device().machine->device("maincpu");
397   UINT8 header[28];
398
399   /* check size */
400   if (snapshot_size != 0x1001c)
401   {
402      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Snapshot must be 65564 bytes");
403      image.message("Snapshot must be 65564 bytes");
404      return IMAGE_INIT_FAIL;
405   }
406
407   /* get the header */
408   image.fread( &header, sizeof(header));
409
410   /* write it to ram */
411   image.fread( ptr, 0x10000);
412
413   /* patch CPU registers */
414   cpu_set_reg(cpu, Z80_I, header[0]);
415   cpu_set_reg(cpu, Z80_HL2, header[1] | (header[2] << 8));
416   cpu_set_reg(cpu, Z80_DE2, header[3] | (header[4] << 8));
417   cpu_set_reg(cpu, Z80_BC2, header[5] | (header[6] << 8));
418   cpu_set_reg(cpu, Z80_AF2, header[7] | (header[8] << 8));
419   cpu_set_reg(cpu, Z80_HL, header[9] | (header[10] << 8));
420   cpu_set_reg(cpu, Z80_DE, header[11] | (header[12] << 8));
421   cpu_set_reg(cpu, Z80_BC, header[13] | (header[14] << 8));
422   cpu_set_reg(cpu, Z80_IY, header[15] | (header[16] << 8));
423   cpu_set_reg(cpu, Z80_IX, header[17] | (header[18] << 8));
424   cpu_set_reg(cpu, Z80_IFF1, header[19]&2 ? 1 : 0);
425   cpu_set_reg(cpu, Z80_IFF2, header[19]&4 ? 1 : 0);
426   cpu_set_reg(cpu, Z80_R, header[20]);
427   cpu_set_reg(cpu, Z80_AF, header[21] | (header[22] << 8));
428   cpu_set_reg(cpu, STATE_GENSP, header[23] | (header[24] << 8));
429   cpu_set_reg(cpu, Z80_IM, header[25]);
430   cpu_set_reg(cpu, STATE_GENPC, header[26] | (header[27] << 8));
431
432   return IMAGE_INIT_PASS;
433}
434
435MACHINE_START( exidy )
436{
437   exidy_state *state = machine->driver_data<exidy_state>();
438//  state->serial_timer = timer_alloc(machine, exidy_serial_timer_callback, NULL);
439   state->cassette_timer = timer_alloc(machine, exidy_cassette_tc, NULL);
440   state->fe = 0xff;
441}
442
443MACHINE_RESET( exidy )
444{
445   exidy_state *state = machine->driver_data<exidy_state>();
446   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
447
448   /* Initialize cassette interface */
449   state->cass_data.output.length = 0;
450   state->cass_data.output.level = 1;
451   state->cass_data.input.length = 0;
452   state->cass_data.input.bit = 1;
453
454   state->ay31015 = machine->device("ay_3_1015");
455
456   exidy_fe_w(space, 0, 0);
457
458   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, exidy_reset);
459   memory_set_bank(machine, "boot", 1);
460}
src/mess/machine/sorcerer.c
r0r9969
1/******************************************************************************
2
3  Exidy Sorcerer machine functions
4
5*******************************************************************************/
6
7#include "emu.h"
8#include "includes/sorcerer.h"
9
10#if SORCERER_USING_RS232
11
12/* The serial code (which was never connected to the outside) is disabled for now. */
13
14/* timer for sorcerer serial chip transmit and receive */
15
16static TIMER_CALLBACK(sorcerer_serial_tc)
17{
18   sorcerer_state *state = machine->driver_data<sorcerer_state>();
19   /* if rs232 is enabled, uart is connected to clock defined by bit6 of port fe.
20    Transmit and receive clocks are connected to the same clock */
21
22   /* if rs232 is disabled, receive clock is linked to cassette hardware */
23   if (state->m_fe & 0x80)
24   {
25      /* connect to rs232 */
26   }
27}
28#endif
29
30
31/* timer to read cassette waveforms */
32
33
34static device_t *cassette_device_image(running_machine *machine)
35{
36   sorcerer_state *state = machine->driver_data<sorcerer_state>();
37   if (state->m_fe & 0x20)
38      return machine->device("cassette2");
39   else
40      return machine->device("cassette1");
41}
42
43
44
45static TIMER_CALLBACK(sorcerer_cassette_tc)
46{
47   sorcerer_state *state = machine->driver_data<sorcerer_state>();
48   UINT8 cass_ws = 0;
49   switch (state->m_fe & 0xc0)      /*/ bit 7 low indicates cassette */
50   {
51      case 0x00:            /* Cassette 300 baud */
52
53         /* loading a tape - this is basically the same as the super80.
54                           We convert the 1200/2400 Hz signal to a 0 or 1, and send it to the uart. */
55
56         state->m_cass_data.input.length++;
57
58         cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
59
60         if (cass_ws != state->m_cass_data.input.level)
61         {
62            state->m_cass_data.input.level = cass_ws;
63            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 0x6) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
64            state->m_cass_data.input.length = 0;
65            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
66         }
67
68         /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies.
69                           Synchronisation of the frequency pulses to the uart is extremely important. */
70
71         state->m_cass_data.output.length++;
72         if (!(state->m_cass_data.output.length & 0x1f))
73         {
74            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
75            if (cass_ws != state->m_cass_data.output.bit)
76            {
77               state->m_cass_data.output.bit = cass_ws;
78               state->m_cass_data.output.length = 0;
79            }
80         }
81
82         if (!(state->m_cass_data.output.length & 3))
83         {
84            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 4)))
85            {
86               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
87               cassette_output(cassette_device_image(machine), state->m_cass_data.output.level ? -1.0 : +1.0);
88            }
89         }
90         return;
91
92      case 0x40:         /* Cassette 1200 baud */
93         /* loading a tape */
94         state->m_cass_data.input.length++;
95
96         cass_ws = (cassette_input(cassette_device_image(machine)) > +0.02) ? 1 : 0;
97
98         if (cass_ws != state->m_cass_data.input.level || state->m_cass_data.input.length == 10)
99         {
100            state->m_cass_data.input.bit = ((state->m_cass_data.input.length < 10) || (state->m_cass_data.input.length > 0x20)) ? 1 : 0;
101            if ( cass_ws != state->m_cass_data.input.level )
102            {
103               state->m_cass_data.input.length = 0;
104               state->m_cass_data.input.level = cass_ws;
105            }
106            ay31015_set_input_pin( state->m_uart, AY31015_SI, state->m_cass_data.input.bit );
107         }
108
109         /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */
110
111         state->m_cass_data.output.length++;
112         if (!(state->m_cass_data.output.length & 7))
113         {
114            cass_ws = ay31015_get_output_pin( state->m_uart, AY31015_SO );
115            if (cass_ws != state->m_cass_data.output.bit)
116            {
117               state->m_cass_data.output.bit = cass_ws;
118               state->m_cass_data.output.length = 0;
119            }
120         }
121
122         if (!(state->m_cass_data.output.length & 7))
123         {
124            if (!((state->m_cass_data.output.bit == 0) && (state->m_cass_data.output.length & 8)))
125            {
126               state->m_cass_data.output.level ^= 1;         // toggle output state, except on 2nd half of low bit
127               cassette_output(cassette_device_image(machine), state->m_cass_data.output.level ? -1.0 : +1.0);
128            }
129         }
130         return;
131   }
132}
133
134
135/* after the first 4 bytes have been read from ROM, switch the ram back in */
136static TIMER_CALLBACK( sorcerer_reset )
137{
138   memory_set_bank(machine, "boot", 0);
139}
140
141WRITE8_MEMBER(sorcerer_state::sorcerer_fc_w)
142{
143   ay31015_set_transmit_data( m_uart, data );
144}
145
146
147WRITE8_MEMBER(sorcerer_state::sorcerer_fd_w)
148{
149   /* Translate data to control signals */
150
151   ay31015_set_input_pin( m_uart, AY31015_CS, 0 );
152   ay31015_set_input_pin( m_uart, AY31015_NB1, data & 1);
153   ay31015_set_input_pin( m_uart, AY31015_NB2, (BIT(data, 1)) ? 1 : 0 );
154   ay31015_set_input_pin( m_uart, AY31015_TSB, (BIT(data, 2)) ? 1 : 0 );
155   ay31015_set_input_pin( m_uart, AY31015_EPS, (BIT(data, 3)) ? 1 : 0 );
156   ay31015_set_input_pin( m_uart, AY31015_NP,  (BIT(data, 4)) ? 1 : 0 );
157   ay31015_set_input_pin( m_uart, AY31015_CS, 1 );
158}
159
160WRITE8_MEMBER(sorcerer_state::sorcerer_fe_w)
161{
162   UINT8 changed_bits = (m_fe ^ data) & 0xf0;
163   m_fe = data;
164
165   /* bits 0..3 */
166   m_keyboard_line = data & 0x0f;
167
168   if (!changed_bits) return;
169
170   /* bits 4..5 */
171   /* does user want to hear the sound? */
172
173   if (!BIT(data, 7)) // cassette operations
174   {
175#if SORCERER_USING_RS232
176      timer_adjust_oneshot(m_serial_timer, attotime_zero, 0);
177#endif
178
179      UINT8 sound = input_port_read(machine, "CONFIG") & 8;
180
181      cassette_change_state(m_cass1,
182         ((BIT(data, 4)) && (sound)) ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
183
184      cassette_change_state(m_cass2,
185         ((BIT(data, 5)) && (sound)) ? CASSETTE_SPEAKER_ENABLED : CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
186
187      /* cassette 1 motor */
188      cassette_change_state(m_cass1,
189         (BIT(data, 4)) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
190
191      /* cassette 2 motor */
192      cassette_change_state(m_cass2,
193         (BIT(data, 5)) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
194
195      if (data & 0x30)
196         timer_adjust_periodic(m_cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(19200));
197      else
198         timer_adjust_oneshot(m_cassette_timer, attotime_zero, 0);
199   }
200#if SORCERER_USING_RS232
201   else
202   {
203      timer_adjust_periodic(m_serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(19200));
204      timer_adjust_oneshot(m_cassette_timer, attotime_zero, 0);
205   }
206#endif
207
208   // bit 6 baud rate */
209   if (BIT(changed_bits, 6))
210   {
211      ay31015_set_receiver_clock( m_uart, (BIT(data, 6)) ? 19200.0 : 4800.0);
212      ay31015_set_transmitter_clock( m_uart, (BIT(data, 6)) ? 19200.0 : 4800.0);
213   }
214}
215
216WRITE8_MEMBER(sorcerer_state::sorcerer_ff_w)
217{
218   /* reading the config switch */
219   switch (input_port_read(machine, "CONFIG") & 0x06)
220   {
221      case 0: /* speaker */
222         dac_data_w(m_dac, data);
223         break;
224
225      case 2: /* Centronics 7-bit printer */
226         /* bit 7 = strobe, bit 6..0 = data */
227         centronics_strobe_w(m_printer, (~data>>7) & 0x01);
228         centronics_data_w(m_printer, 0, data & 0x7f);
229         break;
230
231      case 4: /* 8-bit parallel output */
232         /* hardware strobe driven from port select, bit 7..0 = data */
233         centronics_strobe_w(m_printer, 1);
234         centronics_data_w(m_printer, 0, data);
235         centronics_strobe_w(m_printer, 0);
236         break;
237   }
238}
239
240READ8_MEMBER(sorcerer_state::sorcerer_fc_r)
241{
242   UINT8 data = ay31015_get_received_data( m_uart );
243   ay31015_set_input_pin( m_uart, AY31015_RDAV, 0 );
244   ay31015_set_input_pin( m_uart, AY31015_RDAV, 1 );
245   return data;
246}
247
248READ8_MEMBER(sorcerer_state::sorcerer_fd_r)
249{
250   /* set unused bits high */
251   UINT8 data = 0xe0;
252
253   ay31015_set_input_pin( m_uart, AY31015_SWE, 0 );
254   data |= ay31015_get_output_pin( m_uart, AY31015_TBMT ) ? 0x01 : 0;
255   data |= ay31015_get_output_pin( m_uart, AY31015_DAV  ) ? 0x02 : 0;
256   data |= ay31015_get_output_pin( m_uart, AY31015_OR   ) ? 0x04 : 0;
257   data |= ay31015_get_output_pin( m_uart, AY31015_FE   ) ? 0x08 : 0;
258   data |= ay31015_get_output_pin( m_uart, AY31015_PE   ) ? 0x10 : 0;
259   ay31015_set_input_pin( m_uart, AY31015_SWE, 1 );
260
261   return data;
262}
263
264READ8_MEMBER(sorcerer_state::sorcerer_fe_r)
265{
266   /* bits 6..7
267     - hardware handshakes from user port
268     - not emulated
269     - tied high, allowing PARIN and PAROUT bios routines to run */
270
271   UINT8 data = 0xc0;
272   static const char *const keynames[] = {
273      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
274      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15"
275   };
276
277   /* bit 5 - vsync (inverted) */
278   data |= (((~input_port_read(machine, "VS")) & 0x01)<<5);
279
280   /* bits 4..0 - keyboard data */
281   data |= (input_port_read(machine, keynames[m_keyboard_line]) & 0x1f);
282
283   return data;
284}
285
286READ8_MEMBER(sorcerer_state::sorcerer_ff_r)
287{
288   /* The use of the parallel port as a general purpose port is not emulated.
289    Currently the only use is to read the printer status in the Centronics CENDRV bios routine.
290    This uses bit 7. The other bits have been set high (=nothing plugged in).
291    This fixes those games that use a joystick. */
292
293   UINT8 data=0x7f;
294
295   /* bit 7 = printer busy   0 = printer is not busy */
296
297   data |= centronics_busy_r(m_printer) << 7;
298
299   return data;
300}
301
302
303
304/**********************************************************************************************************/
305
306Z80BIN_EXECUTE( sorcerer )
307{
308   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
309
310   if ((execute_address >= 0xc000) && (execute_address <= 0xdfff) && (space->read_byte(0xdffa) != 0xc3))
311      return;               /* can't run a program if the cartridge isn't in */
312
313   /* Since Exidy Basic is by Microsoft, it needs some preprocessing before it can be run.
314    1. A start address of 01D5 indicates a basic program which needs its pointers fixed up.
315    2. If autorunning, jump to C689 (command processor), else jump to C3DD (READY prompt).
316    Important addresses:
317        01D5 = start (load) address of a conventional basic program
318        C858 = an autorun basic program will have this exec address on the tape
319        C3DD = part of basic that displays READY and lets user enter input */
320
321   if ((start_address == 0x1d5) || (execute_address == 0xc858))
322   {
323      UINT8 i;
324      static const UINT8 data[]={
325         0xcd, 0x26, 0xc4,   // CALL C426    ;set up other pointers
326         0x21, 0xd4, 1,      // LD HL,01D4   ;start of program address (used by C689)
327         0x36, 0,      // LD (HL),00   ;make sure dummy end-of-line is there
328         0xc3, 0x89, 0xc6   // JP C689  ;run program
329      };
330
331      for (i = 0; i < ARRAY_LENGTH(data); i++)
332         space->write_byte(0xf01f + i, data[i]);
333
334      if (!autorun)
335         space->write_word(0xf028,0xc3dd);
336
337      /* tell BASIC where program ends */
338      space->write_byte(0x1b7, end_address & 0xff);
339      space->write_byte(0x1b8, (end_address >> 8) & 0xff);
340
341      if ((execute_address != 0xc858) && autorun)
342         space->write_word(0xf028, execute_address);
343
344      cpu_set_reg(machine->device("maincpu"), STATE_GENPC, 0xf01f);
345   }
346   else
347   {
348      if (autorun)
349         cpu_set_reg(machine->device("maincpu"), STATE_GENPC, execute_address);
350   }
351}
352
353/******************************************************************************
354 Snapshot Handling
355******************************************************************************/
356
357SNAPSHOT_LOAD(sorcerer)
358{
359   device_t *cpu = image.device().machine->device("maincpu");
360   UINT8 *RAM = image.device().machine->region(cpu->tag())->base();
361   address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM);
362   UINT8 header[28];
363   unsigned char s_byte;
364
365   /* check size */
366   if (snapshot_size != 0x1001c)
367   {
368      image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Snapshot must be 65564 bytes");
369      image.message("Snapshot must be 65564 bytes");
370      return IMAGE_INIT_FAIL;
371   }
372
373   /* get the header */
374   image.fread( &header, sizeof(header));
375
376   /* write it to ram */
377   for (int i = 0; i < 0xc000; i++)
378   {
379      image.fread( &s_byte, 1);
380      space->write_byte(i, s_byte);
381   }
382   image.fread( RAM+0xc000, 0x4000);
383
384   /* patch CPU registers */
385   cpu_set_reg(cpu, Z80_I, header[0]);
386   cpu_set_reg(cpu, Z80_HL2, header[1] | (header[2] << 8));
387   cpu_set_reg(cpu, Z80_DE2, header[3] | (header[4] << 8));
388   cpu_set_reg(cpu, Z80_BC2, header[5] | (header[6] << 8));
389   cpu_set_reg(cpu, Z80_AF2, header[7] | (header[8] << 8));
390   cpu_set_reg(cpu, Z80_HL, header[9] | (header[10] << 8));
391   cpu_set_reg(cpu, Z80_DE, header[11] | (header[12] << 8));
392   cpu_set_reg(cpu, Z80_BC, header[13] | (header[14] << 8));
393   cpu_set_reg(cpu, Z80_IY, header[15] | (header[16] << 8));
394   cpu_set_reg(cpu, Z80_IX, header[17] | (header[18] << 8));
395   cpu_set_reg(cpu, Z80_IFF1, header[19]&2 ? 1 : 0);
396   cpu_set_reg(cpu, Z80_IFF2, header[19]&4 ? 1 : 0);
397   cpu_set_reg(cpu, Z80_R, header[20]);
398   cpu_set_reg(cpu, Z80_AF, header[21] | (header[22] << 8));
399   cpu_set_reg(cpu, STATE_GENSP, header[23] | (header[24] << 8));
400   cpu_set_reg(cpu, Z80_IM, header[25]);
401   cpu_set_reg(cpu, STATE_GENPC, header[26] | (header[27] << 8));
402
403   return IMAGE_INIT_PASS;
404}
405
406MACHINE_START( sorcerer )
407{
408   sorcerer_state *state = machine->driver_data<sorcerer_state>();
409   state->m_cassette_timer = timer_alloc(machine, sorcerer_cassette_tc, NULL);
410#if SORCERER_USING_RS232
411   state->m_serial_timer = timer_alloc(machine, sorcerer_serial_tc, NULL);
412#endif
413
414#if SORCERER_USING_DISKS
415   UINT16 endmem = 0xbbff;
416#else
417   UINT16 endmem = 0xbfff;
418#endif
419
420   address_space *space = cpu_get_address_space(state->m_maincpu, ADDRESS_SPACE_PROGRAM);
421   /* configure RAM */
422   switch (ram_get_size(state->m_ram))
423   {
424   case 8*1024:
425      memory_unmap_readwrite(space, 0x2000, endmem, 0, 0);
426      break;
427
428   case 16*1024:
429      memory_unmap_readwrite(space, 0x4000, endmem, 0, 0);
430      break;
431
432   case 32*1024:
433      memory_unmap_readwrite(space, 0x8000, endmem, 0, 0);
434      break;
435   }
436}
437
438MACHINE_RESET( sorcerer )
439{
440   sorcerer_state *state = machine->driver_data<sorcerer_state>();
441   address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
442
443   /* Initialize cassette interface */
444   state->m_cass_data.output.length = 0;
445   state->m_cass_data.output.level = 1;
446   state->m_cass_data.input.length = 0;
447   state->m_cass_data.input.bit = 1;
448
449   state->m_fe = 0xff;
450   state->sorcerer_fe_w(*space, 0, 0, 0xff);
451
452   memory_set_bank(machine, "boot", 1);
453   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, sorcerer_reset);
454}
src/mess/includes/exidy.h
r9968r9969
1/*****************************************************************************
2 *
3 * includes/exidy.h
4 *
5 ****************************************************************************/
6
7#ifndef EXIDY_H_
8#define EXIDY_H_
9
10#include "imagedev/snapquik.h"
11
12typedef struct {
13   struct {
14      int length;      /* time cassette level is at input.level */
15      int level;      /* cassette level */
16      int bit;      /* bit being read */
17   } input;
18   struct {
19      int length;      /* time cassette level is at output.level */
20      int level;      /* cassette level */
21      int bit;      /* bit to to output */
22   } output;
23} cass_data_t;
24
25
26class exidy_state : public driver_device
27{
28public:
29   exidy_state(running_machine &machine, const driver_device_config_base &config)
30      : driver_device(machine, config) { }
31
32   device_t *ay31015;
33   UINT8 fe;
34   UINT8 keyboard_line;
35   emu_timer *serial_timer;
36   emu_timer *cassette_timer;
37   cass_data_t cass_data;
38};
39
40
41/*----------- defined in machine/exidy.c -----------*/
42
43READ8_HANDLER(exidy_fc_r);
44READ8_HANDLER(exidy_fd_r);
45READ8_HANDLER(exidy_fe_r);
46READ8_HANDLER(exidy_ff_r);
47WRITE8_HANDLER(exidy_fc_w);
48WRITE8_HANDLER(exidy_fd_w);
49WRITE8_HANDLER(exidy_fe_w);
50WRITE8_HANDLER(exidy_ff_w);
51MACHINE_START( exidy );
52MACHINE_RESET( exidy );
53Z80BIN_EXECUTE( exidy );
54SNAPSHOT_LOAD( exidy );
55
56#endif /* EXIDY_H_ */
src/mess/includes/sorcerer.h
r0r9969
1/*****************************************************************************
2 *
3 * includes/sorcerer.h
4 *
5 ****************************************************************************/
6
7#ifndef SORCERER_H_
8#define SORCERER_H_
9
10#include "cpu/z80/z80.h"
11#include "sound/dac.h"
12#include "sound/wave.h"
13#include "machine/ctronics.h"
14#include "machine/ram.h"
15#include "imagedev/cassette.h"
16#include "imagedev/snapquik.h"
17#include "imagedev/cartslot.h"
18#include "machine/ay31015.h"
19#include "imagedev/flopdrv.h"
20#include "formats/sorc_dsk.h"
21
22#define SORCERER_USING_DISKS 0
23#define SORCERER_USING_RS232 0
24
25typedef struct {
26   struct {
27      int length;      /* time cassette level is at input.level */
28      int level;      /* cassette level */
29      int bit;      /* bit being read */
30   } input;
31   struct {
32      int length;      /* time cassette level is at output.level */
33      int level;      /* cassette level */
34      int bit;      /* bit to to output */
35   } output;
36} cass_data_t;
37
38
39class sorcerer_state : public driver_device
40{
41public:
42   sorcerer_state(running_machine &machine, const driver_device_config_base &config)
43      : driver_device(machine, config),
44        m_maincpu(*this, "maincpu"),
45        m_cass1(*this, "cassette1"),
46        m_cass2(*this, "cassette2"),
47        m_wave1(*this, "wave.1"),
48        m_wave2(*this, "wave.2"),
49        m_dac(*this, "dac"),
50        m_uart(*this, "uart"),
51        m_printer(*this, "centronics"),
52        m_ram(*this, RAM_TAG)
53   { }
54
55   required_device<cpu_device> m_maincpu;
56   required_device<device_t> m_cass1;
57   required_device<device_t> m_cass2;
58   required_device<device_t> m_wave1;
59   required_device<device_t> m_wave2;
60   required_device<device_t> m_dac;
61   required_device<device_t> m_uart;
62   required_device<device_t> m_printer;
63   required_device<device_t> m_ram;
64   DECLARE_READ8_MEMBER(sorcerer_fc_r);
65   DECLARE_READ8_MEMBER(sorcerer_fd_r);
66   DECLARE_READ8_MEMBER(sorcerer_fe_r);
67   DECLARE_READ8_MEMBER(sorcerer_ff_r);
68   DECLARE_WRITE8_MEMBER(sorcerer_fc_w);
69   DECLARE_WRITE8_MEMBER(sorcerer_fd_w);
70   DECLARE_WRITE8_MEMBER(sorcerer_fe_w);
71   DECLARE_WRITE8_MEMBER(sorcerer_ff_w);
72   UINT8 m_fe;
73   UINT8 m_keyboard_line;
74   emu_timer *m_serial_timer;
75   emu_timer *m_cassette_timer;
76   cass_data_t m_cass_data;
77};
78
79
80/*----------- defined in machine/sorcerer.c -----------*/
81
82
83MACHINE_START( sorcerer );
84MACHINE_RESET( sorcerer );
85Z80BIN_EXECUTE( sorcerer );
86SNAPSHOT_LOAD( sorcerer );
87
88#endif /* SORCERER_H_ */
src/mess/formats/exidydsk.c
r9968r9969
1/*********************************************************************
2
3    formats/exi_dsk.c
4
5    Exidy Sorcerer floppy-disk images
6
7*********************************************************************/
8
9#include <string.h>
10
11#include "formats/exidydsk.h"
12#include "formats/basicdsk.h"
13#include "emu.h"
14
15static FLOPPY_IDENTIFY(exi_dsk_identify)
16{
17   *vote = (floppy_image_size(floppy) == 332640) ? 100 : 0;
18   return FLOPPY_ERROR_SUCCESS;
19}
20
21static int exi_get_heads_per_disk(floppy_image *floppy)
22{
23   return 1;
24}
25
26static int exi_get_tracks_per_disk(floppy_image *floppy)
27{
28   return 77;
29}
30
31static UINT64 exi_translate_offset(floppy_image *floppy, int track, int head, int sector)
32{
33   return 13+270*(16*track+sector);
34}
35
36static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
37{
38   UINT64 offs;
39   /* translate the sector to a raw sector */
40   if (!sector_is_index)
41   {
42      sector -= 1;
43   }
44   /* check to see if we are out of range */
45   if ((head != 0) || (track < 0) || (track >= 77) || (sector < 0) || (sector >= 16))
46      return FLOPPY_ERROR_SEEKERROR;
47
48   offs = exi_translate_offset(floppy, track, head, sector);
49   if (offset)
50      *offset = offs;
51   return FLOPPY_ERROR_SUCCESS;
52}
53
54
55
56static floperr_t internal_exi_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
57{
58   UINT64 offset;
59   floperr_t err;
60   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
61   if (err)
62      return err;
63
64   floppy_image_read(floppy, buffer, offset, buflen);
65   return FLOPPY_ERROR_SUCCESS;
66}
67
68
69
70static floperr_t internal_exi_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
71{
72   UINT64 offset;
73   floperr_t err;
74
75   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
76   if (err)
77      return err;
78
79   floppy_image_write(floppy, buffer, offset, buflen);
80   return FLOPPY_ERROR_SUCCESS;
81}
82
83
84
85static floperr_t exi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
86{
87   return internal_exi_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
88}
89
90static floperr_t exi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
91{
92   return internal_exi_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
93}
94
95static floperr_t exi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
96{
97   return internal_exi_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
98}
99
100static floperr_t exi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
101{
102   return internal_exi_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
103}
104
105static floperr_t exi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
106{
107   floperr_t err;
108   err = get_offset(floppy, head, track, sector, FALSE, NULL);
109   if (err)
110      return err;
111
112   if (sector_length) {
113      *sector_length = 256;
114   }
115   return FLOPPY_ERROR_SUCCESS;
116}
117
118
119
120static floperr_t exi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
121{
122   sector_index += 1;
123   if (cylinder)
124      *cylinder = track;
125   if (side)
126      *side = head;
127   if (sector)
128      *sector = sector_index;
129   if (flags)
130      /* TODO: read DAM or DDAM and determine flags */
131      *flags = 0;
132   return exi_get_sector_length(floppy, head, track, sector_index, sector_length);
133}
134
135
136static FLOPPY_CONSTRUCT(exi_dsk_construct)
137{
138   struct FloppyCallbacks *callbacks;
139   callbacks = floppy_callbacks(floppy);
140   callbacks->read_sector = exi_read_sector;
141   callbacks->write_sector = exi_write_sector;
142   callbacks->read_indexed_sector = exi_read_indexed_sector;
143   callbacks->write_indexed_sector = exi_write_indexed_sector;
144   callbacks->get_sector_length = exi_get_sector_length;
145   callbacks->get_heads_per_disk = exi_get_heads_per_disk;
146   callbacks->get_tracks_per_disk = exi_get_tracks_per_disk;
147   callbacks->get_indexed_sector_info = exi_get_indexed_sector_info;
148
149   return FLOPPY_ERROR_SUCCESS;
150}
151
152
153
154/* ----------------------------------------------------------------------- */
155
156FLOPPY_OPTIONS_START( exidy )
157   FLOPPY_OPTION( exi_dsk, "dsk", "Exidy Sorcerer floppy disk image", exi_dsk_identify, exi_dsk_construct, NULL)
158FLOPPY_OPTIONS_END
src/mess/formats/exidydsk.h
r9968r9969
1/*********************************************************************
2
3    formats/exi_dsk.h
4
5    Exidy Sorcerer disk images
6
7*********************************************************************/
8
9#ifndef EXI_DSK_H
10#define EXI_DSK_H
11
12#include "imagedev/flopimg.h"
13
14/**************************************************************************/
15
16FLOPPY_OPTIONS_EXTERN(exidy);
17
18#endif /* EXI_DSK_H */
src/mess/formats/sorc_dsk.c
r0r9969
1/*********************************************************************
2
3    formats/exi_dsk.c
4
5    Exidy Sorcerer floppy-disk images
6
7*********************************************************************/
8
9#include <string.h>
10
11#include "formats/sorc_dsk.h"
12#include "formats/basicdsk.h"
13#include "emu.h"
14
15static FLOPPY_IDENTIFY(exi_dsk_identify)
16{
17   *vote = (floppy_image_size(floppy) == 332640) ? 100 : 0;
18   return FLOPPY_ERROR_SUCCESS;
19}
20
21static int exi_get_heads_per_disk(floppy_image *floppy)
22{
23   return 1;
24}
25
26static int exi_get_tracks_per_disk(floppy_image *floppy)
27{
28   return 77;
29}
30
31static UINT64 exi_translate_offset(floppy_image *floppy, int track, int head, int sector)
32{
33   return 13+270*(16*track+sector);
34}
35
36static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
37{
38   UINT64 offs;
39   /* translate the sector to a raw sector */
40   if (!sector_is_index)
41   {
42      sector -= 1;
43   }
44   /* check to see if we are out of range */
45   if ((head != 0) || (track < 0) || (track >= 77) || (sector < 0) || (sector >= 16))
46      return FLOPPY_ERROR_SEEKERROR;
47
48   offs = exi_translate_offset(floppy, track, head, sector);
49   if (offset)
50      *offset = offs;
51   return FLOPPY_ERROR_SUCCESS;
52}
53
54
55
56static floperr_t internal_exi_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
57{
58   UINT64 offset;
59   floperr_t err;
60   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
61   if (err)
62      return err;
63
64   floppy_image_read(floppy, buffer, offset, buflen);
65   return FLOPPY_ERROR_SUCCESS;
66}
67
68
69
70static floperr_t internal_exi_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam)
71{
72   UINT64 offset;
73   floperr_t err;
74
75   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
76   if (err)
77      return err;
78
79   floppy_image_write(floppy, buffer, offset, buflen);
80   return FLOPPY_ERROR_SUCCESS;
81}
82
83
84
85static floperr_t exi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
86{
87   return internal_exi_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
88}
89
90static floperr_t exi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
91{
92   return internal_exi_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam);
93}
94
95static floperr_t exi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
96{
97   return internal_exi_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
98}
99
100static floperr_t exi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
101{
102   return internal_exi_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam);
103}
104
105static floperr_t exi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
106{
107   floperr_t err;
108   err = get_offset(floppy, head, track, sector, FALSE, NULL);
109   if (err)
110      return err;
111
112   if (sector_length) {
113      *sector_length = 256;
114   }
115   return FLOPPY_ERROR_SUCCESS;
116}
117
118
119
120static floperr_t exi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
121{
122   sector_index += 1;
123   if (cylinder)
124      *cylinder = track;
125   if (side)
126      *side = head;
127   if (sector)
128      *sector = sector_index;
129   if (flags)
130      /* TODO: read DAM or DDAM and determine flags */
131      *flags = 0;
132   return exi_get_sector_length(floppy, head, track, sector_index, sector_length);
133}
134
135
136static FLOPPY_CONSTRUCT(exi_dsk_construct)
137{
138   struct FloppyCallbacks *callbacks;
139   callbacks = floppy_callbacks(floppy);
140   callbacks->read_sector = exi_read_sector;
141   callbacks->write_sector = exi_write_sector;
142   callbacks->read_indexed_sector = exi_read_indexed_sector;
143   callbacks->write_indexed_sector = exi_write_indexed_sector;
144   callbacks->get_sector_length = exi_get_sector_length;
145   callbacks->get_heads_per_disk = exi_get_heads_per_disk;
146   callbacks->get_tracks_per_disk = exi_get_tracks_per_disk;
147   callbacks->get_indexed_sector_info = exi_get_indexed_sector_info;
148
149   return FLOPPY_ERROR_SUCCESS;
150}
151
152
153
154/* ----------------------------------------------------------------------- */
155
156FLOPPY_OPTIONS_START( exidy )
157   FLOPPY_OPTION( exi_dsk, "dsk", "Exidy Sorcerer floppy disk image", exi_dsk_identify, exi_dsk_construct, NULL)
158FLOPPY_OPTIONS_END
src/mess/formats/sorc_dsk.h
r0r9969
1/*********************************************************************
2
3    formats/sorc_dsk.h
4
5    Exidy Sorcerer disk images
6
7*********************************************************************/
8
9#ifndef EXI_DSK_H
10#define EXI_DSK_H
11
12#include "imagedev/flopimg.h"
13
14/**************************************************************************/
15
16FLOPPY_OPTIONS_EXTERN(exidy);
17
18#endif /* EXI_DSK_H */
src/mess/messdriv.c
r9968r9969
11891189//  DRIVER( aquariu2 )  /* 1984 Aquarius II  */
11901190
11911191   /* Exidy, Inc. */
1192   DRIVER( exidy )    /* Sorcerer     */
1193   DRIVER( exidyd )   /* Sorcerer (cassette only)  */
1192   DRIVER( sorcerer )    /* Sorcerer     */
11941193
11951194   /* Galaksija */
11961195   DRIVER( galaxy )
src/mess/mess.mak
r9968r9969
966966   $(MESS_DRIVERS)/exelv.o      \
967967
968968$(MESSOBJ)/exidy.a:            \
969   $(MESS_MACHINE)/exidy.o      \
970   $(MESS_FORMATS)/exidydsk.o   \
971   $(MESS_DRIVERS)/exidy.o      \
969   $(MESS_MACHINE)/sorcerer.o   \
970   $(MESS_FORMATS)/sorc_dsk.o   \
971   $(MESS_DRIVERS)/sorcerer.o   \
972972
973973$(MESSOBJ)/fairch.a:         \
974974   $(MESS_VIDEO)/channelf.o   \
src/mess/drivers/exidy.c
r9968r9969
1/******************************************************************************
2
3  Exidy Sorcerer system driver
4
5    The UART controls rs232 and cassette i/o. The chip is a AY-3-1014A or AY-3-1015.
6
7
8    port fc:
9    ========
10    input/output:
11        uart data
12
13    port fd:
14    ========
15    input: uart status
16        bit 4: parity error (RPE)
17        bit 3: framing error (RFE)
18        bit 2: over-run (RDP)
19        bit 1: data available (RDA)
20        bit 0: transmit buffer empty (TPMT)
21
22    output:
23        bit 4: no parity (NPB)
24        bit 3: parity type (POE)
25        bit 2: number of stop bits (NSB)
26        bit 1: number of bits per char bit 2 (NDB2)
27        bit 0: number of bits per char bit 1 (NDB1)
28
29    port fe:
30    ========
31
32    output:
33
34        bit 7: rs232 enable (1=rs232, 0=cassette)
35        bit 6: baud rate (1=1200, 0=300)
36        bit 5: cassette motor 2
37        bit 4: cassette motor 1
38        bit 3..0: keyboard line select
39
40    input:
41        bit 7..6: parallel control (not emulated)
42                7: must be 1 to read data from parallel port via PARIN
43                6: must be 1 to send data out of parallel port via PAROUT
44        bit 5: vsync
45        bit 4..0: keyboard line data
46
47    port ff:
48    ========
49      parallel port in/out
50
51    -------------------------------------------------------------------------------------
52
53    When cassette is selected, it is connected to the uart data input via the cassette
54    interface hardware.
55
56    The cassette interface hardware converts square-wave pulses into bits which the uart receives.
57
58    1. the cassette format: "frequency shift" is converted
59    into the uart data format "non-return to zero"
60
61    2. on cassette a 1 data bit is stored as a high frequency
62    and a 0 data bit as a low frequency
63    - At 1200 baud, a logic 1 is 1 cycle of 1200 Hz and a logic 0 is 1/2 cycle of 600 Hz.
64    - At 300 baud, a logic 1 is 8 cycles of 2400 Hz and a logic 0 is 4 cycles of 1200 Hz.
65
66    Attenuation is applied to the signal and the square wave edges are rounded.
67
68    A manchester encoder is used. A flip-flop synchronises input
69    data on the positive-edge of the clock pulse.
70
71    Interestingly the data on cassette is stored in xmodem-checksum.
72
73
74    Due to bugs in the hardware and software of a real Sorcerer, the serial
75    interface misbehaves.
76    1. Sorcerer I had a hardware problem causing rs232 idle to be a space (+9v)
77    instead of mark (-9v). Fixed in Sorcerer II.
78    2. When you select a different baud for rs232, it was "remembered" but not
79    sent to port fe. It only gets sent when motor on was requested. Motor on is
80    only meaningful in a cassette operation.
81    3. The monitor software always resets the device to cassette whenever the
82    keyboard is scanned, motors altered, or an error occurred.
83    4. The above problems make rs232 communication impractical unless you write
84    your own routines or create a corrected monitor rom.
85
86    Sound:
87
88    External speaker connected to the parallel port.
89    There was a dac you could make instead, this is supported.
90
91
92    Kevin Thacker [MESS driver]
93    Robbbert [Various corrections and additions over the years]
94
95 ******************************************************************************
96
97    The CPU clock speed is 2.106 MHz, which was increased to 4.0 MHz on the last production runs.
98
99    The Sorcerer has a bus connection for S100 equipment. This allows the connection
100    of disk drives, provided that suitable driver/boot software is loaded.
101
102    The driver "exidy" emulates a Sorcerer with 4 floppy disk drives fitted, and 44k of ram.
103
104    The driver "exidyd" emulates the most common form, a cassette-based system with 48k of ram.
105
106*******************************************************************************
107
108
109Emulation status:
110
111exidy: 32k disk-based system. Disks not tested. Optional S-100 interface not implemented.
112exidyd: 48k cassette-based system. Disks and S-100 are not options on this system.
113
114Real machines had optional RAM sizes of 4k, 16k, 32k, 48k (officially).
115Unofficially, the cart could hold another 8k of static RAM (4x 6116), giving 56k total.
116
117On the back of the machine is a 50-pin expansion port, which could be hooked to the
118expansion unit.
119
120Also is a 25-pin parallel port, allowing inwards and outwards communication.
121It was often hooked to a printer, a joystick, a music card, or a speaker.
122
123We emulate the printer and the speaker.
124
125Another 25-pin port provided two-way serial communications. Only two speeds are
126available - 300 baud and 1200 baud. There is no handshaking. This protocol is
127currently not emulated.
128
129Other pins on this connector provided for two cassette players. The connections
130for cassette unit 1 are duplicated on a set of phono plugs.
131
132We emulate the use of two cassette units. An option allows you to hear the sound
133of the tape during playback.
134
135The sorcerer has a UART device used by the serial interface and the cassette system.
136
137An examination of the disk controller boot rom shows the controller is not a
138standard one; a custom implementation will need to be written.
139
140
141********************************************************************************/
142
143#include "emu.h"
144#include "cpu/z80/z80.h"
145#include "sound/dac.h"
146#include "sound/wave.h"
147#include "machine/ctronics.h"
148#include "machine/wd17xx.h"
149#include "imagedev/cassette.h"
150#include "imagedev/snapquik.h"
151#include "imagedev/cartslot.h"
152#include "machine/ay31015.h"
153#include "imagedev/flopdrv.h"
154#include "formats/exidydsk.h"
155#include "../includes/exidy.h"
156
157
158static READ8_HANDLER( exidy_read_ff ) { return 0xff; }
159
160static ADDRESS_MAP_START( exidy_mem, ADDRESS_SPACE_PROGRAM, 8)
161   ADDRESS_MAP_UNMAP_HIGH
162   AM_RANGE(0x0000, 0x07ff) AM_RAMBANK("boot")
163   AM_RANGE(0x0800, 0xbbff) AM_RAM AM_REGION("maincpu", 0x0800)
164   AM_RANGE(0xbc00, 0xbcff) AM_ROM                  /* disk bios */
165   AM_RANGE(0xbd00, 0xbdff) AM_READ(exidy_read_ff) AM_WRITENOP
166   AM_RANGE(0xbe00, 0xbe03) AM_DEVREADWRITE("wd179x", wd17xx_r, wd17xx_w)
167   AM_RANGE(0xbe04, 0xbfff) AM_READ(exidy_read_ff) AM_WRITENOP
168   AM_RANGE(0xc000, 0xefff) AM_ROM                  /* rom pac and bios */
169   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_REGION("maincpu", 0xf000)      /* screen ram */
170   AM_RANGE(0xf800, 0xfbff) AM_ROM                  /* char rom */
171   AM_RANGE(0xfc00, 0xffff) AM_RAM   AM_REGION("maincpu", 0xfc00)      /* programmable chars */
172ADDRESS_MAP_END
173
174static ADDRESS_MAP_START( exidyd_mem, ADDRESS_SPACE_PROGRAM, 8)
175   ADDRESS_MAP_UNMAP_HIGH
176   AM_RANGE(0x0000, 0x07ff) AM_RAMBANK("boot")
177   AM_RANGE(0x0800, 0xbfff) AM_RAM AM_REGION("maincpu", 0x0800)
178   AM_RANGE(0xc000, 0xefff) AM_ROM                  /* rom pac and bios */
179   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_REGION("maincpu", 0xf000)      /* screen ram */
180   AM_RANGE(0xf800, 0xfbff) AM_ROM                  /* char rom */
181   AM_RANGE(0xfc00, 0xffff) AM_RAM   AM_REGION("maincpu", 0xfc00)      /* programmable chars */
182ADDRESS_MAP_END
183
184static ADDRESS_MAP_START( exidy_io, ADDRESS_SPACE_IO, 8)
185   ADDRESS_MAP_GLOBAL_MASK(0xff)
186   ADDRESS_MAP_UNMAP_HIGH
187   AM_RANGE(0xfc, 0xfc) AM_READWRITE( exidy_fc_r, exidy_fc_w )
188   AM_RANGE(0xfd, 0xfd) AM_READWRITE( exidy_fd_r, exidy_fd_w )
189   AM_RANGE(0xfe, 0xfe) AM_READWRITE( exidy_fe_r, exidy_fe_w )
190   AM_RANGE(0xff, 0xff) AM_READWRITE( exidy_ff_r, exidy_ff_w )
191ADDRESS_MAP_END
192
193static INPUT_PORTS_START(exidy)
194   PORT_START("VS")
195   /* vblank */
196   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK)
197
198   /* line 0 */
199   PORT_START("LINE0")
200   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
201   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE
202   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Control") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2)
203   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Graphic") PORT_CODE(KEYCODE_F1)
204   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Stop") PORT_CODE(KEYCODE_ESC) PORT_CHAR(27)
205   /* line 1 */
206   PORT_START("LINE1")
207   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(Sel)") PORT_CODE(KEYCODE_F2) PORT_CHAR(27)
208   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Skip") PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
209   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
210   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Repeat") PORT_CODE(KEYCODE_F4)
211   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Clear") PORT_CODE(KEYCODE_F5) PORT_CHAR(12)
212   /* line 2 */
213   PORT_START("LINE2")
214   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
215   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') PORT_CHAR('q') PORT_CHAR(0x11)
216   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A') PORT_CHAR('a') PORT_CHAR(0x01)
217   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') PORT_CHAR('z') PORT_CHAR(0x1a)
218   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X') PORT_CHAR('x') PORT_CHAR(0x18)
219   /* line 3 */
220   PORT_START("LINE3")
221   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('\"')
222   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W') PORT_CHAR('w') PORT_CHAR(0x17)
223   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S') PORT_CHAR('s') PORT_CHAR(0x13)
224   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D') PORT_CHAR('d') PORT_CHAR(0x04)
225   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') PORT_CHAR('c') PORT_CHAR(0x03)
226   /* line 4 */
227   PORT_START("LINE4")
228   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
229   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
230   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E') PORT_CHAR('e') PORT_CHAR(0x05)
231   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R') PORT_CHAR('r') PORT_CHAR(0x12)
232   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F') PORT_CHAR('f') PORT_CHAR(0x06)
233   /* line 5 */
234   PORT_START("LINE5")
235   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
236   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T') PORT_CHAR('t') PORT_CHAR(0x14)
237   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G') PORT_CHAR('g') PORT_CHAR(0x07)
238   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V') PORT_CHAR('v') PORT_CHAR(0x16)
239   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B') PORT_CHAR('b') PORT_CHAR(0x02)
240   /* line 6 */
241   PORT_START("LINE6")
242   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
243   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') PORT_CHAR('y') PORT_CHAR(0x19)
244   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H') PORT_CHAR('h') PORT_CHAR(0x08)
245   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N') PORT_CHAR('n') PORT_CHAR(0x0e)
246   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') PORT_CHAR('m') PORT_CHAR(0x0d)
247   /* line 7 */
248   PORT_START("LINE7")
249   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
250   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U') PORT_CHAR('u') PORT_CHAR(0x15)
251   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J') PORT_CHAR('j') PORT_CHAR(0x0a)
252   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I') PORT_CHAR('i') PORT_CHAR(0x09)
253   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K') PORT_CHAR('k') PORT_CHAR(0x0b)
254   /* line 8 */
255   PORT_START("LINE8")
256   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
257   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
258   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O') PORT_CHAR('o') PORT_CHAR(0x0f)
259   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L') PORT_CHAR('l') PORT_CHAR(0x0c)
260   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
261   /* line 9 */
262   PORT_START("LINE9")
263   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
264   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P') PORT_CHAR('p') PORT_CHAR(0x10)
265   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("; +") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
266   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
267   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
268   /* line 10 */
269   PORT_START("LINE10")
270   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(": *") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
271   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')  PORT_CHAR('{')
272   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']')  PORT_CHAR('}')
273   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("@ `") PORT_CODE(KEYCODE_F7) PORT_CHAR('@') PORT_CHAR('`')
274   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')  PORT_CHAR('|')
275   /* line 11 */
276   PORT_START("LINE11")
277   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- =") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
278   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("^ ~") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') PORT_CHAR('~')
279   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_F6) PORT_CHAR(10)
280   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(13)
281   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("_ Rub") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR('_') PORT_CHAR(8)
282   /* line 12 */
283   PORT_START("LINE12")
284   PORT_BIT (0x10, 0x10, IPT_UNUSED)
285   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- (PAD)") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
286   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/ (PAD)") PORT_CODE(KEYCODE_SLASH_PAD)
287   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("* (PAD)") PORT_CODE(KEYCODE_ASTERISK)
288   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("+ (PAD)") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))
289   /* line 13 */
290   PORT_START("LINE13")
291   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7 (PAD)") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
292   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8 (PAD)") PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
293   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4 (PAD)") PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
294   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1 (PAD)") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
295   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0 (PAD)") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
296   /* line 14 */
297   PORT_START("LINE14")
298   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9 (PAD)") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
299   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6 (PAD)") PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
300   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5 (PAD)") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
301   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2 (PAD)") PORT_CODE(KEYCODE_2_PAD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
302   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(". (PAD)") PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
303   /* line 15 */
304   PORT_START("LINE15")
305   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 (PAD)") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
306   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("= (PAD)") PORT_CODE(KEYCODE_NUMLOCK)
307   PORT_BIT (0x04, 0x04, IPT_UNUSED)
308   PORT_BIT (0x02, 0x02, IPT_UNUSED)
309   PORT_BIT (0x01, 0x01, IPT_UNUSED)
310
311   /* Enhanced options not available on real hardware */
312   PORT_START("CONFIG")
313   PORT_CONFNAME( 0x01, 0x01, "Autorun on Quickload")
314   PORT_CONFSETTING(    0x00, DEF_STR(No))
315   PORT_CONFSETTING(    0x01, DEF_STR(Yes))
316   /* hardware connected to printer port */
317   PORT_CONFNAME( 0x06, 0x00, "Parallel port" )
318   PORT_CONFSETTING(    0x00, "Speaker" )
319   PORT_CONFSETTING(    0x02, "Printer (7-bit)" )
320   PORT_CONFSETTING(    0x04, "Printer (8-bit)" )
321   PORT_CONFNAME( 0x08, 0x08, "Cassette Speaker")
322   PORT_CONFSETTING(    0x08, DEF_STR(On))
323   PORT_CONFSETTING(    0x00, DEF_STR(Off))
324INPUT_PORTS_END
325
326/**************************** F4 CHARACTER DISPLAYER ******************************************************/
327
328static const gfx_layout exidy_charlayout =
329{
330   8, 8,               /* 8 x 8 characters */
331   256,               /* 256 characters */
332   1,               /* 1 bits per pixel */
333   { 0 },               /* no bitplanes */
334   /* x offsets */
335   { 0, 1, 2, 3, 4, 5, 6, 7 },
336   /* y offsets */
337   {  0*8,  1*8,  2*8,  3*8,  4*8,  5*8,  6*8,  7*8 },
338   8*8               /* every char takes 8 bytes */
339};
340
341/* This will show the 128 characters in the ROM + whatever happens to be in the PCG */
342static GFXDECODE_START( exidy )
343   GFXDECODE_ENTRY( "maincpu", 0xf800, exidy_charlayout, 0, 1 )
344GFXDECODE_END
345
346static VIDEO_UPDATE( exidy )
347{
348   UINT8 y,ra,chr,gfx;
349   UINT16 sy=0,ma=0xf080,x;
350   UINT8 *RAM = screen->machine->region("maincpu")->base();
351
352   for (y = 0; y < 30; y++)
353   {
354      for (ra = 0; ra < 8; ra++)
355      {
356         UINT16  *p = BITMAP_ADDR16(bitmap, sy++, 0);
357
358         for (x = ma; x < ma+64; x++)
359         {
360            chr = RAM[x];
361
362            /* get pattern of pixels for that character scanline */
363            gfx = RAM[0xf800 | (chr<<3) | ra];
364
365            /* Display a scanline of a character (8 pixels) */
366            *p++ = ( gfx & 0x80 ) ? 1 : 0;
367            *p++ = ( gfx & 0x40 ) ? 1 : 0;
368            *p++ = ( gfx & 0x20 ) ? 1 : 0;
369            *p++ = ( gfx & 0x10 ) ? 1 : 0;
370            *p++ = ( gfx & 0x08 ) ? 1 : 0;
371            *p++ = ( gfx & 0x04 ) ? 1 : 0;
372            *p++ = ( gfx & 0x02 ) ? 1 : 0;
373            *p++ = ( gfx & 0x01 ) ? 1 : 0;
374         }
375      }
376      ma+=64;
377   }
378   return 0;
379}
380
381
382/**********************************************************************************************************/
383
384static const ay31015_config exidy_ay31015_config =
385{
386   AY_3_1015,
387   4800.0,
388   4800.0,
389   NULL,
390   NULL,
391   NULL
392};
393
394
395static const cassette_config exidy_cassette_config =
396{
397   cassette_default_formats,
398   NULL,
399   (cassette_state)(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
400   NULL
401};
402
403static const floppy_config exidy_floppy_config =
404{
405   DEVCB_NULL,
406   DEVCB_NULL,
407   DEVCB_NULL,
408   DEVCB_NULL,
409   DEVCB_NULL,
410   FLOPPY_STANDARD_5_25_DSHD,
411   FLOPPY_OPTIONS_NAME(exidy),
412   NULL
413};
414
415static MACHINE_CONFIG_START( exidy, exidy_state )
416   /* basic machine hardware */
417   MCFG_CPU_ADD("maincpu", Z80, 12638000/6)
418   MCFG_CPU_PROGRAM_MAP(exidy_mem)
419   MCFG_CPU_IO_MAP(exidy_io)
420
421   MCFG_MACHINE_START( exidy )
422   MCFG_MACHINE_RESET( exidy )
423
424   /* video hardware */
425   MCFG_SCREEN_ADD("screen", RASTER)
426   MCFG_SCREEN_REFRESH_RATE(50)
427   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(200))
428   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
429   MCFG_SCREEN_SIZE(64*8, 30*8)
430   MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 30*8-1)
431
432   MCFG_GFXDECODE(exidy)
433   MCFG_PALETTE_LENGTH(2)
434   MCFG_PALETTE_INIT(black_and_white)
435
436   MCFG_VIDEO_UPDATE( exidy )
437
438   /* sound hardware */
439   MCFG_SPEAKER_STANDARD_MONO("mono")
440   MCFG_SOUND_WAVE_ADD("wave.1", "cassette1")
441   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)   // cass1 speaker
442   MCFG_SOUND_WAVE_ADD("wave.2", "cassette2")
443   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)   // cass2 speaker
444   MCFG_SOUND_ADD("dac", DAC, 0)
445   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)   // speaker or music card on parallel port
446
447   MCFG_AY31015_ADD( "ay_3_1015", exidy_ay31015_config )
448
449   /* printer */
450   MCFG_CENTRONICS_ADD("centronics", standard_centronics)
451
452   /* quickload */
453   MCFG_SNAPSHOT_ADD("snapshot", exidy, "snp", 2)
454   MCFG_Z80BIN_QUICKLOAD_ADD("quickload", exidy, 2)
455
456   MCFG_CASSETTE_ADD( "cassette1", exidy_cassette_config )
457   MCFG_CASSETTE_ADD( "cassette2", exidy_cassette_config )
458
459   MCFG_WD179X_ADD("wd179x", default_wd17xx_interface )
460
461   /* cartridge */
462   MCFG_CARTSLOT_ADD("cart")
463   MCFG_CARTSLOT_EXTENSION_LIST("rom")
464   MCFG_CARTSLOT_NOT_MANDATORY
465
466   MCFG_FLOPPY_4_DRIVES_ADD(exidy_floppy_config)
467MACHINE_CONFIG_END
468
469static MACHINE_CONFIG_DERIVED( exidyd, exidy )
470
471   MCFG_CPU_MODIFY("maincpu")
472   MCFG_CPU_PROGRAM_MAP(exidyd_mem)
473
474   MCFG_FLOPPY_4_DRIVES_REMOVE()
475MACHINE_CONFIG_END
476
477static DRIVER_INIT( exidy )
478{
479   UINT8 *RAM = machine->region("maincpu")->base();
480   memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0xe000);
481}
482
483/***************************************************************************
484
485  Game driver(s)
486
487***************************************************************************/
488ROM_START(exidy)
489   ROM_REGION( 0x10000, "maincpu", 0 )
490   ROM_LOAD("exmo1-1.dat", 0xe000, 0x0800, CRC(ac924f67) SHA1(72fcad6dd1ed5ec0527f967604401284d0e4b6a1) ) /* monitor roms */
491   ROM_LOAD("exmo1-2.dat", 0xe800, 0x0800, CRC(ead1d0f6) SHA1(c68bed7344091bca135e427b4793cc7d49ca01be) )
492   ROM_LOAD("exchr-1.dat", 0xf800, 0x0400, CRC(4a7e1cdd) SHA1(2bf07a59c506b6e0c01ec721fb7b747b20f5dced) ) /* char rom */
493   ROM_LOAD_OPTIONAL("diskboot.dat",0xbc00, 0x0100, BAD_DUMP CRC(d82a40d6) SHA1(cd1ef5fb0312cd1640e0853d2442d7d858bc3e3b))
494   ROM_CART_LOAD("cart", 0xc000, 0x2000, ROM_FILL_FF | ROM_OPTIONAL)
495
496   ROM_REGION( 0x0020, "proms", 0 )
497   ROM_LOAD_OPTIONAL("bruce.dat",   0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */
498ROM_END
499
500ROM_START(exidyd)
501   ROM_REGION( 0x10000, "maincpu", 0 )
502   ROM_LOAD("exmo1-1.dat", 0xe000, 0x0800, CRC(ac924f67) SHA1(72fcad6dd1ed5ec0527f967604401284d0e4b6a1) ) /* monitor roms */
503   ROM_LOAD("exmo1-2.dat", 0xe800, 0x0800, CRC(ead1d0f6) SHA1(c68bed7344091bca135e427b4793cc7d49ca01be) )
504   ROM_LOAD("exchr-1.dat", 0xf800, 0x0400, CRC(4a7e1cdd) SHA1(2bf07a59c506b6e0c01ec721fb7b747b20f5dced) ) /* char rom */
505   ROM_CART_LOAD("cart", 0xc000, 0x2000, ROM_FILL_FF | ROM_OPTIONAL)
506
507   ROM_REGION( 0x0020, "proms", 0 )
508   ROM_LOAD_OPTIONAL("bruce.dat",   0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */
509ROM_END
510
511/*    YEAR  NAME    PARENT  COMPAT      MACHINE INPUT   INIT    COMPANY        FULLNAME */
512COMP(1979, exidy,   0,      0,   exidy,   exidy,   exidy,      "Exidy Inc", "Sorcerer", 0 )
513COMP(1979, exidyd,  exidy,   0,   exidyd,   exidy,   exidy,      "Exidy Inc", "Sorcerer (Cassette only)", 0 )
514
src/mess/drivers/sorcerer.c
r0r9969
1/******************************************************************************
2
3  Exidy Sorcerer system driver
4
5    The UART controls rs232 and cassette i/o. The chip is a AY-3-1014A or AY-3-1015.
6
7
8    port fc:
9    ========
10    input/output:
11        uart data
12
13    port fd:
14    ========
15    input: uart status
16        bit 4: parity error (RPE)
17        bit 3: framing error (RFE)
18        bit 2: over-run (RDP)
19        bit 1: data available (RDA)
20        bit 0: transmit buffer empty (TPMT)
21
22    output:
23        bit 4: no parity (NPB)
24        bit 3: parity type (POE)
25        bit 2: number of stop bits (NSB)
26        bit 1: number of bits per char bit 2 (NDB2)
27        bit 0: number of bits per char bit 1 (NDB1)
28
29    port fe:
30    ========
31
32    output:
33
34        bit 7: rs232 enable (1=rs232, 0=cassette)
35        bit 6: baud rate (1=1200, 0=300)
36        bit 5: cassette motor 2
37        bit 4: cassette motor 1
38        bit 3..0: keyboard line select
39
40    input:
41        bit 7..6: parallel control (not emulated)
42                7: must be 1 to read data from parallel port via PARIN
43                6: must be 1 to send data out of parallel port via PAROUT
44        bit 5: vsync
45        bit 4..0: keyboard line data
46
47    port ff:
48    ========
49      parallel port in/out
50
51    -------------------------------------------------------------------------------------
52
53    When cassette is selected, it is connected to the uart data input via the cassette
54    interface hardware.
55
56    The cassette interface hardware converts square-wave pulses into bits which the uart receives.
57
58    1. the cassette format: "frequency shift" is converted
59    into the uart data format "non-return to zero"
60
61    2. on cassette a 1 data bit is stored as a high frequency
62    and a 0 data bit as a low frequency
63    - At 1200 baud, a logic 1 is 1 cycle of 1200 Hz and a logic 0 is 1/2 cycle of 600 Hz.
64    - At 300 baud, a logic 1 is 8 cycles of 2400 Hz and a logic 0 is 4 cycles of 1200 Hz.
65
66    Attenuation is applied to the signal and the square wave edges are rounded.
67
68    A manchester encoder is used. A flip-flop synchronises input
69    data on the positive-edge of the clock pulse.
70
71    Interestingly the data on cassette is stored in xmodem-checksum.
72
73
74    Due to bugs in the hardware and software of a real Sorcerer, the serial
75    interface misbehaves.
76    1. Sorcerer I had a hardware problem causing rs232 idle to be a space (+9v)
77    instead of mark (-9v). Fixed in Sorcerer II.
78    2. When you select a different baud for rs232, it was "remembered" but not
79    sent to port fe. It only gets sent when motor on was requested. Motor on is
80    only meaningful in a cassette operation.
81    3. The monitor software always resets the device to cassette whenever the
82    keyboard is scanned, motors altered, or an error occurred.
83    4. The above problems make rs232 communication impractical unless you write
84    your own routines or create a corrected monitor rom.
85
86    Sound:
87
88    External speaker connected to the parallel port.
89    There was a dac you could make instead, this is supported.
90
91
92    Kevin Thacker [MESS driver]
93    Robbbert [Various corrections and additions over the years]
94
95 ******************************************************************************
96
97    The CPU clock speed is 2.106 MHz, which was increased to 4.0 MHz on the last production runs.
98
99    The Sorcerer has a bus connection for S100 equipment. This allows the connection
100    of disk drives, provided that suitable driver/boot software is loaded.
101
102*******************************************************************************
103
104Real machines had optional RAM sizes of 8k, 16k, 32k, 48k (officially).
105Unofficially, the cart could hold another 8k of static RAM (4x 6116), giving 56k total.
106
107On the back of the machine is a 50-pin expansion port, which could be hooked to the
108expansion unit.
109
110Also is a 25-pin parallel port, allowing inwards and outwards communication.
111It was often hooked to a printer, a joystick, a music card, or a speaker.
112
113We emulate the printer and the speaker.
114
115Another 25-pin port provided two-way serial communications. Only two speeds are
116available - 300 baud and 1200 baud. There is no handshaking. This protocol is
117currently not emulated.
118
119Other pins on this connector provided for two cassette players. The connections
120for cassette unit 1 are duplicated on a set of phono plugs.
121
122We emulate the use of two cassette units. An option allows you to hear the sound
123of the tape during playback.
124
125An examination of the disk controller boot rom shows the controller is not a
126standard one; a custom implementation will need to be written.
127
128********************************************************************************
129
130NOTES (2011-01-09)
1311. Converted to MODERN driver as much as possible.
1322. Added 2 defines for work that needs doing at some time:
133- SORCERER_USING_RS232 - this is for when we can connect a serial interface.
134- SORCERER_USING_DISKS - the disk controller I believe most likely to be a
135                         'Micropolis Floppy Disk System' at 143KB on 13cm disks.
136                         There was a hard-sector system (top of ram = BBFF),
137                         and a soft-sector system (top of RAM = BDFF). You could
138                         use alternate systems (since you could attach a S-100
139                         unit), so not sure how this could be developed. The
140                         Micropolis seems completely undocumented in the technical
141                         sense. When using the hard-sector system, in the monitor
142                         enter GO BC00 to boot the disk. No idea how in other
143                         disk systems.
144
145                         Note that the code within the defines has NOT been
146                         compiled or tested. You are on your own!
147
148********************************************************************************/
149#define ADDRESS_MAP_MODERN
150
151#include "emu.h"
152#include "includes/sorcerer.h"
153
154
155static ADDRESS_MAP_START( sorcerer_mem, ADDRESS_SPACE_PROGRAM, 8, sorcerer_state)
156   ADDRESS_MAP_UNMAP_HIGH
157   AM_RANGE(0x0000, 0x07ff) AM_RAMBANK("boot")
158#if SORCERER_USING_DISKS
159   AM_RANGE(0x0800, 0xbbff) AM_RAM
160   AM_RANGE(0xbc00, 0xbcff) AM_ROM //micropolis boot code
161   AM_RANGE(0xbe00, 0xbe03) //micropolis memory-mapped disk controller
162#else
163   AM_RANGE(0x0800, 0xbfff) AM_RAM
164#endif
165   AM_RANGE(0xc000, 0xefff) AM_ROM                  /* rom pac and bios */
166   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_REGION("maincpu", 0xf000)      /* screen ram */
167   AM_RANGE(0xf800, 0xfbff) AM_ROM                  /* char rom */
168   AM_RANGE(0xfc00, 0xffff) AM_RAM   AM_REGION("maincpu", 0xfc00)      /* programmable chars */
169ADDRESS_MAP_END
170
171static ADDRESS_MAP_START( sorcerer_io, ADDRESS_SPACE_IO, 8, sorcerer_state)
172   ADDRESS_MAP_GLOBAL_MASK(0xff)
173   ADDRESS_MAP_UNMAP_HIGH
174   AM_RANGE(0xfc, 0xfc) AM_READWRITE( sorcerer_fc_r, sorcerer_fc_w )
175   AM_RANGE(0xfd, 0xfd) AM_READWRITE( sorcerer_fd_r, sorcerer_fd_w )
176   AM_RANGE(0xfe, 0xfe) AM_READWRITE( sorcerer_fe_r, sorcerer_fe_w )
177   AM_RANGE(0xff, 0xff) AM_READWRITE( sorcerer_ff_r, sorcerer_ff_w )
178ADDRESS_MAP_END
179
180static INPUT_PORTS_START(sorcerer)
181   PORT_START("VS")
182   /* vblank */
183   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK)
184
185   /* line 0 */
186   PORT_START("LINE0")
187   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
188   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE
189   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Control") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2)
190   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Graphic") PORT_CODE(KEYCODE_F1)
191   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Stop") PORT_CODE(KEYCODE_ESC) PORT_CHAR(27)
192   /* line 1 */
193   PORT_START("LINE1")
194   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(Sel)") PORT_CODE(KEYCODE_F2) PORT_CHAR(27)
195   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Skip") PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
196   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
197   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Repeat") PORT_CODE(KEYCODE_F4)
198   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Clear") PORT_CODE(KEYCODE_F5) PORT_CHAR(12)
199   /* line 2 */
200   PORT_START("LINE2")
201   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
202   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') PORT_CHAR('q') PORT_CHAR(0x11)
203   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A') PORT_CHAR('a') PORT_CHAR(0x01)
204   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') PORT_CHAR('z') PORT_CHAR(0x1a)
205   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X') PORT_CHAR('x') PORT_CHAR(0x18)
206   /* line 3 */
207   PORT_START("LINE3")
208   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('\"')
209   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W') PORT_CHAR('w') PORT_CHAR(0x17)
210   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S') PORT_CHAR('s') PORT_CHAR(0x13)
211   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D') PORT_CHAR('d') PORT_CHAR(0x04)
212   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C') PORT_CHAR('c') PORT_CHAR(0x03)
213   /* line 4 */
214   PORT_START("LINE4")
215   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
216   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
217   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E') PORT_CHAR('e') PORT_CHAR(0x05)
218   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R') PORT_CHAR('r') PORT_CHAR(0x12)
219   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F') PORT_CHAR('f') PORT_CHAR(0x06)
220   /* line 5 */
221   PORT_START("LINE5")
222   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
223   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T') PORT_CHAR('t') PORT_CHAR(0x14)
224   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G') PORT_CHAR('g') PORT_CHAR(0x07)
225   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V') PORT_CHAR('v') PORT_CHAR(0x16)
226   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B') PORT_CHAR('b') PORT_CHAR(0x02)
227   /* line 6 */
228   PORT_START("LINE6")
229   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
230   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') PORT_CHAR('y') PORT_CHAR(0x19)
231   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H') PORT_CHAR('h') PORT_CHAR(0x08)
232   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N') PORT_CHAR('n') PORT_CHAR(0x0e)
233   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M') PORT_CHAR('m') PORT_CHAR(0x0d)
234   /* line 7 */
235   PORT_START("LINE7")
236   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
237   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U') PORT_CHAR('u') PORT_CHAR(0x15)
238   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J') PORT_CHAR('j') PORT_CHAR(0x0a)
239   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I') PORT_CHAR('i') PORT_CHAR(0x09)
240   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K') PORT_CHAR('k') PORT_CHAR(0x0b)
241   /* line 8 */
242   PORT_START("LINE8")
243   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
244   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
245   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O') PORT_CHAR('o') PORT_CHAR(0x0f)
246   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L') PORT_CHAR('l') PORT_CHAR(0x0c)
247   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
248   /* line 9 */
249   PORT_START("LINE9")
250   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
251   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P') PORT_CHAR('p') PORT_CHAR(0x10)
252   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("; +") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
253   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(". >") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
254   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/ ?") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
255   /* line 10 */
256   PORT_START("LINE10")
257   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(": *") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
258   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[ {") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')  PORT_CHAR('{')
259   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("] }") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']')  PORT_CHAR('}')
260   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("@ `") PORT_CODE(KEYCODE_F7) PORT_CHAR('@') PORT_CHAR('`')
261   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\ |") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')  PORT_CHAR('|')
262   /* line 11 */
263   PORT_START("LINE11")
264   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- =") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=')
265   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("^ ~") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') PORT_CHAR('~')
266   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LINE FEED") PORT_CODE(KEYCODE_F6) PORT_CHAR(10)
267   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RETURN") PORT_CODE(KEYCODE_ENTER) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(13)
268   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("_ Rub") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR('_') PORT_CHAR(8)
269   /* line 12 */
270   PORT_START("LINE12")
271   PORT_BIT (0x10, 0x10, IPT_UNUSED)
272   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("- (PAD)") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
273   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/ (PAD)") PORT_CODE(KEYCODE_SLASH_PAD)
274   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("* (PAD)") PORT_CODE(KEYCODE_ASTERISK)
275   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("+ (PAD)") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD))
276   /* line 13 */
277   PORT_START("LINE13")
278   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7 (PAD)") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
279   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8 (PAD)") PORT_CODE(KEYCODE_8_PAD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
280   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4 (PAD)") PORT_CODE(KEYCODE_4_PAD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
281   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1 (PAD)") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
282   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0 (PAD)") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
283   /* line 14 */
284   PORT_START("LINE14")
285   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9 (PAD)") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
286   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6 (PAD)") PORT_CODE(KEYCODE_6_PAD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
287   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5 (PAD)") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
288   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2 (PAD)") PORT_CODE(KEYCODE_2_PAD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
289   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(". (PAD)") PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
290   /* line 15 */
291   PORT_START("LINE15")
292   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 (PAD)") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
293   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("= (PAD)") PORT_CODE(KEYCODE_NUMLOCK)
294   PORT_BIT (0x04, 0x04, IPT_UNUSED)
295   PORT_BIT (0x02, 0x02, IPT_UNUSED)
296   PORT_BIT (0x01, 0x01, IPT_UNUSED)
297
298   /* Enhanced options not available on real hardware */
299   PORT_START("CONFIG")
300   PORT_CONFNAME( 0x01, 0x01, "Autorun on Quickload")
301   PORT_CONFSETTING(    0x00, DEF_STR(No))
302   PORT_CONFSETTING(    0x01, DEF_STR(Yes))
303   /* hardware connected to printer port */
304   PORT_CONFNAME( 0x06, 0x00, "Parallel port" )
305   PORT_CONFSETTING(    0x00, "Speaker" )
306   PORT_CONFSETTING(    0x02, "Printer (7-bit)" )
307   PORT_CONFSETTING(    0x04, "Printer (8-bit)" )
308   PORT_CONFNAME( 0x08, 0x08, "Cassette Speaker")
309   PORT_CONFSETTING(    0x08, DEF_STR(On))
310   PORT_CONFSETTING(    0x00, DEF_STR(Off))
311INPUT_PORTS_END
312
313/**************************** F4 CHARACTER DISPLAYER ******************************************************/
314
315static const gfx_layout sorcerer_charlayout =
316{
317   8, 8,               /* 8 x 8 characters */
318   256,               /* 256 characters */
319   1,               /* 1 bits per pixel */
320   { 0 },               /* no bitplanes */
321   /* x offsets */
322   { 0, 1, 2, 3, 4, 5, 6, 7 },
323   /* y offsets */
324   {  0*8,  1*8,  2*8,  3*8,  4*8,  5*8,  6*8,  7*8 },
325   8*8               /* every char takes 8 bytes */
326};
327
328/* This will show the 128 characters in the ROM + whatever happens to be in the PCG */
329static GFXDECODE_START( sorcerer )
330   GFXDECODE_ENTRY( "maincpu", 0xf800, sorcerer_charlayout, 0, 1 )
331GFXDECODE_END
332
333static VIDEO_UPDATE( sorcerer )
334{
335   UINT8 y,ra,chr,gfx;
336   UINT16 sy=0,ma=0xf080,x;
337   UINT8 *RAM = screen->machine->region("maincpu")->base();
338
339   for (y = 0; y < 30; y++)
340   {
341      for (ra = 0; ra < 8; ra++)
342      {
343         UINT16 *p = BITMAP_ADDR16(bitmap, sy++, 0);
344
345         for (x = ma; x < ma+64; x++)
346         {
347            chr = RAM[x];
348
349            /* get pattern of pixels for that character scanline */
350            gfx = RAM[0xf800 | (chr<<3) | ra];
351
352            /* Display a scanline of a character (8 pixels) */
353            *p++ = ( gfx & 0x80 ) ? 1 : 0;
354            *p++ = ( gfx & 0x40 ) ? 1 : 0;
355            *p++ = ( gfx & 0x20 ) ? 1 : 0;
356            *p++ = ( gfx & 0x10 ) ? 1 : 0;
357            *p++ = ( gfx & 0x08 ) ? 1 : 0;
358            *p++ = ( gfx & 0x04 ) ? 1 : 0;
359            *p++ = ( gfx & 0x02 ) ? 1 : 0;
360            *p++ = ( gfx & 0x01 ) ? 1 : 0;
361         }
362      }
363      ma+=64;
364   }
365   return 0;
366}
367
368
369/**********************************************************************************************************/
370
371static const ay31015_config sorcerer_ay31015_config =
372{
373   AY_3_1015,
374   4800.0,
375   4800.0,
376   NULL,
377   NULL,
378   NULL
379};
380
381
382static const cassette_config sorcerer_cassette_config =
383{
384   cassette_default_formats,
385   NULL,
386   (cassette_state)(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
387   NULL
388};
389
390#if SORCERER_USING_DISKS
391static const floppy_config sorcerer_floppy_config =
392{
393   DEVCB_NULL,
394   DEVCB_NULL,
395   DEVCB_NULL,
396   DEVCB_NULL,
397   DEVCB_NULL,
398   FLOPPY_STANDARD_5_25_DSHD,
399   FLOPPY_OPTIONS_NAME(sorcerer),
400   NULL
401};
402#endif
403
404static MACHINE_CONFIG_START( sorcerer, sorcerer_state )
405   /* basic machine hardware */
406   MCFG_CPU_ADD("maincpu", Z80, 12638000/6)
407   MCFG_CPU_PROGRAM_MAP(sorcerer_mem)
408   MCFG_CPU_IO_MAP(sorcerer_io)
409
410   MCFG_MACHINE_START( sorcerer )
411   MCFG_MACHINE_RESET( sorcerer )
412
413   /* video hardware */
414   MCFG_SCREEN_ADD("screen", RASTER)
415   MCFG_SCREEN_REFRESH_RATE(50)
416   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(200))
417   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
418   MCFG_SCREEN_SIZE(64*8, 30*8)
419   MCFG_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 30*8-1)
420
421   MCFG_GFXDECODE(sorcerer)
422   MCFG_PALETTE_LENGTH(2)
423   MCFG_PALETTE_INIT(black_and_white)
424
425   MCFG_VIDEO_UPDATE( sorcerer )
426
427   /* sound hardware */
428   MCFG_SPEAKER_STANDARD_MONO("mono")
429   MCFG_SOUND_WAVE_ADD("wave.1", "cassette1")
430   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)   // cass1 speaker
431   MCFG_SOUND_WAVE_ADD("wave.2", "cassette2")
432   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)   // cass2 speaker
433   MCFG_SOUND_ADD("dac", DAC, 0)
434   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)   // speaker or music card on parallel port
435
436   MCFG_AY31015_ADD( "uart", sorcerer_ay31015_config )
437
438   /* printer */
439   MCFG_CENTRONICS_ADD("centronics", standard_centronics)
440
441   /* quickload */
442   MCFG_SNAPSHOT_ADD("snapshot", sorcerer, "snp", 2)
443   MCFG_Z80BIN_QUICKLOAD_ADD("quickload", sorcerer, 2)
444
445   MCFG_CASSETTE_ADD( "cassette1", sorcerer_cassette_config )
446   MCFG_CASSETTE_ADD( "cassette2", sorcerer_cassette_config )
447
448   /* cartridge */
449   MCFG_CARTSLOT_ADD("cart")
450   MCFG_CARTSLOT_EXTENSION_LIST("rom")
451
452   // internal ram
453   MCFG_RAM_ADD(RAM_TAG)
454   MCFG_RAM_DEFAULT_SIZE("48K")
455   MCFG_RAM_EXTRA_OPTIONS("8K,16K,32K")
456
457#if SORCERER_USING_DISKS
458   MCFG_xx_ADD("micropolis", default_micropolis_interface ) // custom micropolis controller
459   MCFG_FLOPPY_4_DRIVES_ADD(sorcerer_floppy_config)
460#endif
461MACHINE_CONFIG_END
462
463static DRIVER_INIT( sorcerer )
464{
465   UINT8 *RAM = machine->region("maincpu")->base();
466   memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0xe000);
467}
468
469/***************************************************************************
470
471  Game driver(s)
472
473***************************************************************************/
474ROM_START(sorcerer)
475   ROM_REGION( 0x10000, "maincpu", 0 )
476#if SORCERER_USING_DISKS
477   ROM_LOAD("diskboot.dat",0xbc00, 0x0100, BAD_DUMP CRC(d82a40d6) SHA1(cd1ef5fb0312cd1640e0853d2442d7d858bc3e3b))
478#endif
479   ROM_LOAD("exmo1-1.dat", 0xe000, 0x0800, CRC(ac924f67) SHA1(72fcad6dd1ed5ec0527f967604401284d0e4b6a1) ) /* monitor roms */
480   ROM_LOAD("exmo1-2.dat", 0xe800, 0x0800, CRC(ead1d0f6) SHA1(c68bed7344091bca135e427b4793cc7d49ca01be) )
481   ROM_LOAD("exchr-1.dat", 0xf800, 0x0400, CRC(4a7e1cdd) SHA1(2bf07a59c506b6e0c01ec721fb7b747b20f5dced) ) /* char rom */
482   ROM_CART_LOAD("cart", 0xc000, 0x2000, ROM_FILL_FF | ROM_OPTIONAL)
483
484   ROM_REGION( 0x10000, "proms", 0 )
485   ROM_LOAD_OPTIONAL("bruce.dat",   0x0000, 0x0020, CRC(fae922cb) SHA1(470a86844cfeab0d9282242e03ff1d8a1b2238d1)) /* video prom */
486   ROM_LOAD_OPTIONAL("diskboot.dat",0xbc00, 0x0100, BAD_DUMP CRC(d82a40d6) SHA1(cd1ef5fb0312cd1640e0853d2442d7d858bc3e3b))
487ROM_END
488
489/*    YEAR  NAME    PARENT  COMPAT      MACHINE INPUT   INIT    COMPANY        FULLNAME */
490COMP(1979, sorcerer, 0,      0,   sorcerer, sorcerer, sorcerer, "Exidy Inc", "Sorcerer", 0 )
491

Previous 15994 Revisions Next


© 1998-2018 The MESS Team