Previous 15994 Revisions Next

r4934 Thursday 4th June, 2009 at 12:03:09 UTC by Robbbert
[SUPER80] Split code to machine.c
[src/mess]mess.mak
[src/mess/drivers]super80.c
[src/mess/includes]super80.h
[src/mess/machine]super80.c*
[src/mess/video]super80.c

src/mess/video/super80.c
r4933r4934
77
88
99#include "driver.h"
10#include "video/mc6845.h"
1110#include "super80.h"
1211
1312
r4933r4934
103102   UINT16 sy=0,ma=vidpg,x;
104103   UINT8 *RAM = memory_region(screen->machine, "maincpu");
105104
106   if ((super80_mhz == 1) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
105   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
107106      screen_on++;
108107
109108   for (y = 0; y < 16; y++)
r4933r4934
142141   UINT16 sy=0,ma=vidpg,x;
143142   UINT8 *RAM = memory_region(screen->machine, "maincpu");
144143
145   if ((super80_mhz == 1) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
144   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
146145      screen_on++;
147146
148147   for (y = 0; y < 16; y++)
r4933r4934
181180   UINT16 sy=0,ma=vidpg,x;
182181   UINT8 *RAM = memory_region(screen->machine, "maincpu");
183182
184   if ((super80_mhz == 1) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
183   if ((super80_shared & 4) || (!(input_port_read(screen->machine, "CONFIG") & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
185184      screen_on++;
186185
187186   for (y = 0; y < 16; y++)
r4933r4934
224223   /* get selected character generator */
225224   UINT8 cgen = current_charset ^ ((options & 0x10)>>4);   /* bit 0 of port F1 and cgen config switch */
226225
227   if ((super80_mhz == 1) || (!(options & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
226   if ((super80_shared & 4) || (!(options & 4)))   /* bit 2 of port F0 is high, OR user turned on config switch */
228227      screen_on++;
229228
230229   if (screen_on)
r4933r4934
297296
298297READ8_HANDLER( super80v_low_r )
299298{
300   if (!super80v_vid_col)
301      return colorram[offset];
302   else
299   if (super80_shared & 4)
303300      return videoram[offset];
301   else
302      return colorram[offset];
304303}
305304
306305WRITE8_HANDLER( super80v_low_w )
307306{
308   if (!super80v_vid_col)
309      colorram[offset] = data;
310   else
307   if (super80_shared & 4)
311308      videoram[offset] = data;
309   else
310      colorram[offset] = data;
312311}
313312
314313READ8_HANDLER( super80v_high_r )
315314{
316   if (!super80v_vid_col)
315   if (~super80_shared & 4)
317316      return colorram[0x800+offset];
318317
319   if (!super80v_rom_pcg)
320      return pcgram[offset];
321   else
318   if (super80_shared & 0x10)
322319      return pcgram[0x800+offset];
320   else
321      return pcgram[offset];
323322}
324323
325324WRITE8_HANDLER( super80v_high_w )
326325{
327   if (!super80v_vid_col)
326   if (~super80_shared & 4)
328327      colorram[offset+0x800] = data;
329328   else
330329   {
331330      videoram[offset+0x800] = data;
332331
333      if (super80v_rom_pcg)
332      if (super80_shared & 0x10)
334333         pcgram[0x800+offset] = data;
335334   }
336335}
r4933r4934
419418      fg = 5;                  /* green */
420419      if ((options & 0x60) == 0x60) fg = 15;      /* b&w */
421420
422      if (!(options & 0x40))
421      if (~options & 0x40)
423422      {
424423          col = colorram[mem];               /* byte of colour to display */
425424         fg = col & 0x0f;
r4933r4934
427426      }
428427
429428      /* if inverse mode, replace any pcgram chrs with inverse chrs */
430      if ((!super80v_rom_pcg) && (chr & 0x80))         // is it a high chr in inverse mode
429      if ((~super80_shared & 0x10) && (chr & 0x80))         // is it a high chr in inverse mode
431430      {
432431         inv ^= 0xff;                  // invert the chr
433432         chr &= 0x7f;                  // and drop bit 7
src/mess/includes/super80.h
r4933r4934
1#include "video/mc6845.h"
2#include "machine/z80pio.h"
3
14/*----- super80 ----------*/
25
36
r4933r4934
2326MC6845_UPDATE_ROW( super80v_update_row );
2427
2528extern UINT8 *pcgram;
26extern UINT8 super80v_vid_col;
27extern UINT8 super80v_rom_pcg;
28extern UINT8 super80_mhz;
29
30/*------- machine -------*/
31
32READ8_HANDLER( super80_dc_r );
33READ8_HANDLER( super80_f2_r );
34WRITE8_HANDLER( super80_dc_w );
35WRITE8_HANDLER( super80_f0_w );
36WRITE8_HANDLER( super80r_f0_w );
37READ8_DEVICE_HANDLER( super80_pio_r );
38WRITE8_DEVICE_HANDLER( super80_pio_w );
39MACHINE_RESET( super80 );
40DRIVER_INIT( super80 );
41DRIVER_INIT( super80v );
42
43extern UINT8 super80_shared;
44extern const z80pio_interface super80_pio_intf;
45
src/mess/machine/super80.c
r0r4934
1/* Super80.c written by Robbbert, 2005-2009. See the MESS wiki for documentation. */
2 
3#include "driver.h"
4//#include "cpu/z80/z80.h"
5#include "sound/wave.h"
6#include "devices/cassette.h"
7#include "sound/speaker.h"
8#include "machine/ctronics.h"
9#include "super80.h"
10 
11/* Bits in shared variable:
12   d5 cassette LED
13   d4 super80v rom or pcg bankswitch (1=pcg ram, 0=char gen rom)
14   d2 super80v video or colour bankswitch (1=video ram, 0=colour ram)
15   d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */
16 
17UINT8 super80_shared=0xff;
18 
19static const device_config *super80_z80pio;
20static const device_config *super80_speaker;
21static const device_config *super80_cassette;
22static const device_config *super80_printer;
23 
24/**************************** PIO ******************************************************************************/
25 
26static UINT8 keylatch;
27 
28/* This activates when Control + C + 4 pressed */
29static void super80_pio_interrupt(const device_config *device, int state)
30{
31   cputag_set_input_line(device->machine, "maincpu", 0, state );
32}
33 
34static WRITE8_DEVICE_HANDLER( pio_port_a_w )
35{
36   keylatch = data;
37};
38 
39static READ8_DEVICE_HANDLER( pio_port_b_r )
40{
41   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
42 
43   int bit;
44   UINT8 data = 0xff;
45 
46   for (bit = 0; bit < 8; bit++)
47   {
48      if (!BIT(keylatch, bit)) data &= input_port_read(device->machine, keynames[bit]);
49   }
50 
51   return data;
52};
53 
54const z80pio_interface super80_pio_intf =
55{
56   DEVCB_LINE(super80_pio_interrupt),      /* callback when change interrupt status */
57   DEVCB_NULL,
58   DEVCB_HANDLER(pio_port_b_r),
59   DEVCB_HANDLER(pio_port_a_w),
60   DEVCB_NULL,
61   DEVCB_NULL,         /* portA ready active callback (not used in super80) */
62   DEVCB_NULL         /* portB ready active callback (not used in super80) */
63};
64 
65 
66/**************************** CASSETTE ROUTINES *****************************************************************/
67 
68static void super80_cassette_motor( running_machine *machine, UINT8 data )
69{
70   if (data)
71      cassette_change_state(super80_cassette, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
72   else
73      cassette_change_state(super80_cassette, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
74 
75   /* does user want to hear the sound? */
76   if (input_port_read(machine, "CONFIG") & 8)
77      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
78   else
79      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
80}
81 
82/********************************************* TIMER ************************************************/
83 
84static UINT8 cass_data[]={ 0, 0, 0, 0 };
85 
86   /* this timer runs at 200khz and does 2 jobs:   
87   1. Scan the keyboard and present the results to the pio   
88   2. Emulate the 2 chips in the cassette input circuit   
89 
90   Reasons why it is necessary:   
91   1. The real z80pio is driven by the cpu clock and is capable of independent actions.   
92   MAME does not support this at all. If the interrupt key sequence is entered, the   
93   computer can be reset out of a hung state by the operator.   
94   2. This "emulates" U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage,   
95   and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint.
96 
97   The MDS homebrew input circuit consists of 2 op-amps followed by a D-flipflop.
98   My "read-any-system" cassette circuit was a CA3140 op-amp, the smarts being done in software.
99 
100   bit 0 = original system (U79 and U1)
101   bit 1 = MDS fast system
102   bit 2 = CA3140 */
103 
104static TIMER_CALLBACK( super80_timer )
105{
106   UINT8 cass_ws=0;
107 
108   cass_data[1]++;
109   cass_ws = (cassette_input(super80_cassette) > +0.03) ? 4 : 0;
110 
111   if (cass_ws != cass_data[0])
112   {
113      if (cass_ws) cass_data[3] ^= 2;                  // the MDS flipflop
114      cass_data[0] = cass_ws;
115      cass_data[2] = ((cass_data[1] < 0x40) ? 1 : 0) | cass_ws | cass_data[3];
116      cass_data[1] = 0;
117   }
118 
119   z80pio_p_w(super80_z80pio,1,pio_port_b_r(super80_z80pio,0));
120}
121 
122/* after the first 4 bytes have been read from ROM, switch the ram back in */
123static TIMER_CALLBACK( super80_reset )
124{
125   memory_set_bank(machine, 1, 0);
126}
127 
128static TIMER_CALLBACK( super80_halfspeed )
129{
130   static UINT8 int_sw=0;
131   UINT8 go_fast = 0;
132   if (!(super80_shared & 4) || (!(input_port_read(machine, "CONFIG") & 2)))   /* bit 2 of port F0 is low, OR user turned on config switch */
133      go_fast++;
134 
135   /* code to slow down computer to 1 MHz by halting cpu on every second frame */
136   if (!go_fast)
137   {
138      if (!int_sw)
139         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, ASSERT_LINE);   // if going, stop it
140 
141      int_sw++;
142      if (int_sw > 1)
143      {
144         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);      // if stopped, start it
145         int_sw = 0;
146      }
147   }
148   else
149   {
150      if (int_sw < 8)                        // @2MHz, reset just once
151      {
152         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);
153         int_sw = 8;                     // ...not every time
154      }
155   }
156}
157 
158/*************************************** PRINTER ********************************************************/
159 
160/* The Super80 had an optional I/O card that plugged into the S-100 slot. The card had facility for running
161   an 8-bit Centronics printer, and a serial device at 300, 600, or 1200 baud. The I/O address range
162   was selectable via 4 dipswitches. The serial parameters (baud rate, parity, stop bits, etc) was
163   chosen with more dipswitches. Regretably, no parameters could be set by software. Currently, the
164   Centronics printer is emulated; the serial side of things may be done later, as will the dipswitches.
165 
166   The most commonly used I/O range is DC-DE (DC = centronics, DD = serial data, DE = serial control
167   All the home-brew roms use this, except for super80e which uses BC-BE (which we don't support yet). */
168 
169/**************************** I/O PORTS *****************************************************************/
170 
171READ8_HANDLER( super80_dc_r )
172{
173   UINT8 data=0x7f;
174 
175   /* bit 7 = printer busy
176   0 = printer is not busy */
177 
178   data |= centronics_busy_r(super80_printer) << 7;
179 
180   return data;
181}
182 
183READ8_HANDLER( super80_f2_r )
184{
185   UINT8 data = input_port_read(space->machine, "DSW") & 0xf0;   // dip switches on pcb
186   data |= cass_data[2];         // bit 0 = output of U1, bit 1 = MDS cass state, bit 2 = current wave_state
187   data |= 0x08;            // bit 3 - not used
188   return data;
189}
190 
191WRITE8_HANDLER( super80_dc_w )
192{
193   /* hardware strobe driven from port select, bit 7..0 = data */
194   centronics_strobe_w(super80_printer, 1);
195   centronics_data_w(super80_printer, 0, data);
196   centronics_strobe_w(super80_printer, 0);
197}
198 
199static UINT8 last_data;
200 
201WRITE8_HANDLER( super80_f0_w )
202{
203   UINT8 bits = data ^ last_data;
204   super80_shared = data;
205   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
206   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
207   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
208 
209   last_data = data;
210}
211 
212WRITE8_HANDLER( super80r_f0_w )
213{
214   super80_f0_w(space, 0, data);
215   super80_shared |= 0x14;
216}
217 
218READ8_DEVICE_HANDLER( super80_pio_r )
219{
220   if (!offset)
221      return z80pio_d_r(device, 0);
222   else
223   if (offset == 1)
224      return z80pio_c_r(device, 0);
225   else
226   if (offset == 2)
227      return z80pio_d_r(device, 1);
228   else
229      return z80pio_c_r(device, 1);
230}
231 
232WRITE8_DEVICE_HANDLER( super80_pio_w )
233{
234   if (!offset)
235      z80pio_d_w(device, 0, data);
236   else
237   if (offset == 1)
238      z80pio_c_w(device, 0, data);
239   else
240   if (offset == 2)
241      z80pio_d_w(device, 1, data);
242   else
243      z80pio_c_w(device, 1, data);
244}
245 
246/**************************** BASIC MACHINE CONSTRUCTION ***********************************************************/
247 
248MACHINE_RESET( super80 )
249{
250   super80_shared=0xff;
251   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset);
252   memory_set_bank(machine, 1, 1);
253   super80_z80pio = devtag_get_device(machine, "z80pio");
254   super80_speaker = devtag_get_device(machine, "speaker");
255   super80_cassette = devtag_get_device(machine, "cassette");
256   super80_printer = devtag_get_device(machine, "centronics");
257}
258 
259static void driver_init_common( running_machine *machine )
260{
261   UINT8 *RAM = memory_region(machine, "maincpu");
262   memory_configure_bank(machine, 1, 0, 2, &RAM[0x0000], 0xc000);
263   timer_pulse(machine, ATTOTIME_IN_HZ(200000),NULL,0,super80_timer);   /* timer for keyboard and cassette */
264}
265 
266DRIVER_INIT( super80 )
267{
268   timer_pulse(machine, ATTOTIME_IN_HZ(100),NULL,0,super80_halfspeed);   /* timer for 1MHz slowdown */
269   driver_init_common(machine);
270}
271 
272DRIVER_INIT( super80v )
273{
274   pcgram = memory_region(machine, "maincpu")+0xf000;
275   videoram = memory_region(machine, "maincpu")+0x18000;
276   colorram = memory_region(machine, "maincpu")+0x1C000;
277   driver_init_common(machine);
278}
279 
src/mess/mess.mak
r4933r4934
872872
873873$(MESSOBJ)/super80.a :   \
874874   $(MESS_DRIVERS)/super80.o   \
875   $(MESS_MACHINE)/super80.o   \
875876   $(MESS_VIDEO)/super80.o
876877
877878$(MESSOBJ)/jupiter.a : \
src/mess/drivers/super80.c
r4933r4934
44#include "cpu/z80/z80.h"
55#include "cpu/z80/z80daisy.h"
66#include "sound/wave.h"
7#include "machine/z80pio.h"
87#include "devices/snapquik.h"
98#include "devices/cartslot.h"
109#include "devices/cassette.h"
1110#include "devices/z80bin.h"
1211#include "sound/speaker.h"
1312#include "machine/ctronics.h"
14#include "video/mc6845.h"
1513#include "super80.h"
1614
17
18static const device_config *super80_z80pio;
19static const device_config *super80_speaker;
20static const device_config *super80_cassette;
21static const device_config *super80_printer;
22
2315UINT8 *pcgram;
24UINT8 super80v_vid_col=1;         // 0 = color ram ; 1 = video ram
25UINT8 super80v_rom_pcg=1;         // 0 = prom ; 1 = pcg
26UINT8 super80_mhz=2;   /* state of bit 2 of port F0 */
2716
2817#define MASTER_CLOCK         (XTAL_12MHz)
2918#define PIXEL_CLOCK         (MASTER_CLOCK/2)
r4933r4934
3928#define SUPER80V_DOTS         (7)
4029
4130
42/**************************** PIO ******************************************************************************/
43
44static UINT8 keylatch;
45
46/* This activates when Control + C + 4 pressed */
47static void super80_pio_interrupt(const device_config *device, int state)
48{
49   cputag_set_input_line(device->machine, "maincpu", 0, state );
50}
51
52static WRITE8_DEVICE_HANDLER( pio_port_a_w )
53{
54   keylatch = data;
55};
56
57static READ8_DEVICE_HANDLER( pio_port_b_r )
58{
59   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
60
61   int bit;
62   UINT8 data = 0xff;
63
64   for (bit = 0; bit < 8; bit++)
65   {
66      if (!BIT(keylatch, bit)) data &= input_port_read(device->machine, keynames[bit]);
67   }
68
69   return data;
70};
71
72static const z80pio_interface super80_pio_intf =
73{
74   DEVCB_LINE(super80_pio_interrupt),      /* callback when change interrupt status */
75   DEVCB_NULL,
76   DEVCB_HANDLER(pio_port_b_r),
77   DEVCB_HANDLER(pio_port_a_w),
78   DEVCB_NULL,
79   DEVCB_NULL,         /* portA ready active callback (not used in super80) */
80   DEVCB_NULL         /* portB ready active callback (not used in super80) */
81};
82
83
84static const z80_daisy_chain super80_daisy_chain[] =
85{
86   { "z80pio" },
87   { NULL }
88};
89
90/**************************** CASSETTE ROUTINES *****************************************************************/
91
92static void super80_cassette_motor( running_machine *machine, UINT8 data )
93{
94   if (data)
95      cassette_change_state(super80_cassette, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
96   else
97      cassette_change_state(super80_cassette, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
98
99   /* does user want to hear the sound? */
100   if (input_port_read(machine, "CONFIG") & 8)
101      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER);
102   else
103      cassette_change_state(super80_cassette, CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER);
104}
105
106/********************************************* TIMER ************************************************/
107
108static UINT8 cass_data[]={ 0, 0, 0, 0 };
109
110   /* this timer runs at 200khz and does 2 jobs: 
111   1. Scan the keyboard and present the results to the pio 
112   2. Emulate the 2 chips in the cassette input circuit 
113
114   Reasons why it is necessary: 
115   1. The real z80pio is driven by the cpu clock and is capable of independent actions. 
116   MAME does not support this at all. If the interrupt key sequence is entered, the 
117   computer can be reset out of a hung state by the operator. 
118   2. This "emulates" U79 CD4046BCN PLL chip and U1 LM311P op-amp. U79 converts a frequency to a voltage, 
119   and U1 amplifies that voltage to digital levels. U1 has a trimpot connected, to set the midpoint.
120
121   The MDS homebrew input circuit consists of 2 op-amps followed by a D-flipflop.
122   My "read-any-system" cassette circuit was a CA3140 op-amp, the smarts being done in software.
123
124   bit 0 = original system (U79 and U1)
125   bit 1 = MDS fast system
126   bit 2 = CA3140 */
127
128static TIMER_CALLBACK( super80_timer )
129{
130   UINT8 cass_ws=0;
131
132   cass_data[1]++;
133   cass_ws = (cassette_input(super80_cassette) > +0.03) ? 4 : 0;
134
135   if (cass_ws != cass_data[0])
136   {
137      if (cass_ws) cass_data[3] ^= 2;                  // the MDS flipflop
138      cass_data[0] = cass_ws;
139      cass_data[2] = ((cass_data[1] < 0x40) ? 1 : 0) | cass_ws | cass_data[3];
140      cass_data[1] = 0;
141   }
142
143   z80pio_p_w(super80_z80pio,1,pio_port_b_r(super80_z80pio,0));
144}
145
146/*************************************** PRINTER ********************************************************/
147
148/* The Super80 had an optional I/O card that plugged into the S-100 slot. The card had facility for running
149   an 8-bit Centronics printer, and a serial device at 300, 600, or 1200 baud. The I/O address range
150   was selectable via 4 dipswitches. The serial parameters (baud rate, parity, stop bits, etc) was
151   chosen with more dipswitches. Regretably, no parameters could be set by software. Currently, the
152   Centronics printer is emulated; the serial side of things may be done later, as will the dipswitches.
153
154   The most commonly used I/O range is DC-DE (DC = centronics, DD = serial data, DE = serial control
155   All the home-brew roms use this, except for super80e which uses BC-BE (which we don't support yet). */
156
157/**************************** I/O PORTS *****************************************************************/
158
159static READ8_HANDLER( super80_dc_r )
160{
161   UINT8 data=0x7f;
162
163   /* bit 7 = printer busy
164   0 = printer is not busy */
165
166   data |= centronics_busy_r(super80_printer) << 7;
167
168   return data;
169}
170
171static READ8_HANDLER( super80_f2_r )
172{
173   UINT8 data = input_port_read(space->machine, "DSW") & 0xf0;   // dip switches on pcb
174   data |= cass_data[2];         // bit 0 = output of U1, bit 1 = MDS cass state, bit 2 = current wave_state
175   data |= 0x08;            // bit 3 - not used
176   return data;
177}
178
179static WRITE8_HANDLER( super80_dc_w )
180{
181   /* hardware strobe driven from port select, bit 7..0 = data */
182   centronics_strobe_w(super80_printer, 1);
183   centronics_data_w(super80_printer, 0, data);
184   centronics_strobe_w(super80_printer, 0);
185}
186
187static UINT8 last_data;
188
189static WRITE8_HANDLER( super80_f0_w )
190{
191   UINT8 bits = data ^ last_data;
192
193   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
194   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
195   super80_mhz = (data & 4) ? 1 : 2;            /* bit 2 - video on/off */
196   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
197   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
198
199   last_data = data;
200}
201
202static WRITE8_HANDLER( super80r_f0_w )
203{
204   UINT8 bits = data ^ last_data;
205
206   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
207   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
208   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
209   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
210
211   last_data = data;
212}
213
214static WRITE8_HANDLER( super80v_f0_w )
215{
216   UINT8 bits = data ^ last_data;
217
218   if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1);      /* bit 5 - LED - scroll lock led is used */
219   super80v_rom_pcg = data & 0x10;               /* bit 4 - bankswitch gfx rom or pcg */
220   speaker_level_w(super80_speaker, (data & 8) ? 0 : 1);            /* bit 3 - speaker */
221   super80v_vid_col = data & 4;               /* bit 2 - bankswitch video or colour ram */
222   if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0);   /* bit 1 - cassette motor */
223   if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0);   /* bit 0 - cass out */
224
225   last_data = data;
226}
227
228static READ8_HANDLER( super80_f8_r ) { return z80pio_d_r (super80_z80pio,0); }
229static READ8_HANDLER( super80_f9_r ) { return z80pio_c_r (super80_z80pio,0); }
230static READ8_HANDLER( super80_fa_r ) { return z80pio_d_r (super80_z80pio,1); }
231static READ8_HANDLER( super80_fb_r ) { return z80pio_c_r (super80_z80pio,1); }
232static WRITE8_HANDLER( super80_f8_w ) { z80pio_d_w(super80_z80pio,0, data); }
233static WRITE8_HANDLER( super80_f9_w ) { z80pio_c_w(super80_z80pio,0, data); }
234static WRITE8_HANDLER( super80_fa_w ) { z80pio_d_w(super80_z80pio,1, data); }
235static WRITE8_HANDLER( super80_fb_w ) { z80pio_c_w(super80_z80pio,1, data); }
236
23731/**************************** MEMORY AND I/O MAPPINGS *****************************************************************/
23832
23933/* A read_byte or write_byte to unmapped memory crashes MESS, and UNMAP doesnt fix it.
r4933r4934
26963   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80_f0_w)
27064   AM_RANGE(0xe1, 0xe1) AM_MIRROR(0x14) AM_WRITE(super80_f1_w)
27165   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
272   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w)
273   AM_RANGE(0xf9, 0xf9) AM_MIRROR(0x04) AM_READWRITE(super80_f9_r,super80_f9_w)
274   AM_RANGE(0xfa, 0xfa) AM_MIRROR(0x04) AM_READWRITE(super80_fa_r,super80_fa_w)
275   AM_RANGE(0xfb, 0xfb) AM_MIRROR(0x04) AM_READWRITE(super80_fb_r,super80_fb_w)
66   AM_RANGE(0xf8, 0xfb) AM_MIRROR(0x04) AM_DEVREADWRITE("z80pio",super80_pio_r,super80_pio_w)
27667ADDRESS_MAP_END
27768
27869static ADDRESS_MAP_START( super80r_io, ADDRESS_SPACE_IO, 8 )
r4933r4934
28475   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
28576   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w)
28677   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
287   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w)
288   AM_RANGE(0xf9, 0xf9) AM_MIRROR(0x04) AM_READWRITE(super80_f9_r,super80_f9_w)
289   AM_RANGE(0xfa, 0xfa) AM_MIRROR(0x04) AM_READWRITE(super80_fa_r,super80_fa_w)
290   AM_RANGE(0xfb, 0xfb) AM_MIRROR(0x04) AM_READWRITE(super80_fb_r,super80_fb_w)
78   AM_RANGE(0xf8, 0xfb) AM_MIRROR(0x04) AM_DEVREADWRITE("z80pio",super80_pio_r,super80_pio_w)
29179ADDRESS_MAP_END
29280
29381static ADDRESS_MAP_START( super80v_io, ADDRESS_SPACE_IO, 8 )
r4933r4934
29785   AM_RANGE(0x11, 0x11) AM_DEVREAD("crtc", mc6845_register_r)
29886   AM_RANGE(0x11, 0x11) AM_WRITE(super80v_11_w)
29987   AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w)
300   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80v_f0_w)
88   AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80_f0_w)
30189   AM_RANGE(0xe2, 0xe2) AM_MIRROR(0x14) AM_READ(super80_f2_r)
302   AM_RANGE(0xf8, 0xf8) AM_MIRROR(0x04) AM_READWRITE(super80_f8_r,super80_f8_w)
303   AM_RANGE(0xf9, 0xf9) AM_MIRROR(0x04) AM_READWRITE(super80_f9_r,super80_f9_w)
304   AM_RANGE(0xfa, 0xfa) AM_MIRROR(0x04) AM_READWRITE(super80_fa_r,super80_fa_w)
305   AM_RANGE(0xfb, 0xfb) AM_MIRROR(0x04) AM_READWRITE(super80_fb_r,super80_fb_w)
90   AM_RANGE(0xf8, 0xfb) AM_MIRROR(0x04) AM_DEVREADWRITE("z80pio",super80_pio_r,super80_pio_w)
30691ADDRESS_MAP_END
30792
30893/**************************** DIPSWITCHES, KEYBOARD, HARDWARE CONFIGURATION ****************************************/
r4933r4934
553338
554339/**************************** BASIC MACHINE CONSTRUCTION ***********************************************************/
555340
556static TIMER_CALLBACK( super80_halfspeed )
557{
558   static UINT8 int_sw=0;
559   UINT8 go_fast = 0;
560   if ((super80_mhz == 2) || (!(input_port_read(machine, "CONFIG") & 2)))   /* bit 2 of port F0 is low, OR user turned on config switch */
561      go_fast++;
562341
563   /* code to slow down computer to 1 MHz by halting cpu on every second frame */
564   if (!go_fast)
565   {
566      if (!int_sw)
567         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, ASSERT_LINE);   // if going, stop it
568
569      int_sw++;
570      if (int_sw > 1)
571      {
572         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);      // if stopped, start it
573         int_sw = 0;
574      }
575   }
576   else
577   {
578      if (int_sw < 8)                        // @2MHz, reset just once
579      {
580         cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);
581         int_sw = 8;                     // ...not every time
582      }
583   }
584}
585
586
587/* after the first 4 bytes have been read from ROM, switch the ram back in */
588static TIMER_CALLBACK( super80_reset )
342static const z80_daisy_chain super80_daisy_chain[] =
589343{
590   memory_set_bank(machine, 1, 0);
591}
344   { "z80pio" },
345   { NULL }
346};
592347
593static MACHINE_RESET( super80 )
594{
595   timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset);
596   memory_set_bank(machine, 1, 1);
597   super80_z80pio = devtag_get_device(machine, "z80pio");
598   super80_speaker = devtag_get_device(machine, "speaker");
599   super80_cassette = devtag_get_device(machine, "cassette");
600   super80_printer = devtag_get_device(machine, "centronics");
601}
602
603348static const cassette_config super80_cassette_config =
604349{
605350   cassette_default_formats,
r4933r4934
746491   MDRV_CPU_IO_MAP(super80r_io)
747492MACHINE_DRIVER_END
748493
749static void driver_init_common( running_machine *machine )
750{
751   UINT8 *RAM = memory_region(machine, "maincpu");
752   memory_configure_bank(machine, 1, 0, 2, &RAM[0x0000], 0xc000);
753   timer_pulse(machine, ATTOTIME_IN_HZ(200000),NULL,0,super80_timer);   /* timer for keyboard and cassette */
754}
755
756static DRIVER_INIT( super80 )
757{
758   timer_pulse(machine, ATTOTIME_IN_HZ(100),NULL,0,super80_halfspeed);   /* timer for 1MHz slowdown */
759   driver_init_common(machine);
760}
761
762static DRIVER_INIT( super80v )
763{
764   pcgram = memory_region(machine, "maincpu")+0xf000;
765   videoram = memory_region(machine, "maincpu")+0x18000;
766   colorram = memory_region(machine, "maincpu")+0x1C000;
767   driver_init_common(machine);
768}
769
770
771494/**************************** ROMS *****************************************************************/
772495
773496ROM_START( super80 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team