src/mess/machine/super80.c
| r0 | r4934 | |
| 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 | |
| 17 | UINT8 super80_shared=0xff;
|
| 18 | |
| 19 | static const device_config *super80_z80pio;
|
| 20 | static const device_config *super80_speaker;
|
| 21 | static const device_config *super80_cassette;
|
| 22 | static const device_config *super80_printer;
|
| 23 | |
| 24 | /**************************** PIO ******************************************************************************/
|
| 25 | |
| 26 | static UINT8 keylatch;
|
| 27 | |
| 28 | /* This activates when Control + C + 4 pressed */
|
| 29 | static void super80_pio_interrupt(const device_config *device, int state)
|
| 30 | {
|
| 31 | cputag_set_input_line(device->machine, "maincpu", 0, state );
|
| 32 | }
|
| 33 | |
| 34 | static WRITE8_DEVICE_HANDLER( pio_port_a_w )
|
| 35 | {
|
| 36 | keylatch = data;
|
| 37 | };
|
| 38 | |
| 39 | static 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 | |
| 54 | const 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 | |
| 68 | static 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 | |
| 84 | static 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 | |
| 104 | static 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 */
|
| 123 | static TIMER_CALLBACK( super80_reset )
|
| 124 | {
|
| 125 | memory_set_bank(machine, 1, 0);
|
| 126 | }
|
| 127 | |
| 128 | static 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 | |
| 171 | READ8_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 | |
| 183 | READ8_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 | |
| 191 | WRITE8_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 | |
| 199 | static UINT8 last_data;
|
| 200 | |
| 201 | WRITE8_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 | |
| 212 | WRITE8_HANDLER( super80r_f0_w )
|
| 213 | {
|
| 214 | super80_f0_w(space, 0, data);
|
| 215 | super80_shared |= 0x14;
|
| 216 | }
|
| 217 | |
| 218 | READ8_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 | |
| 232 | WRITE8_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 | |
| 248 | MACHINE_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 | |
| 259 | static 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 | |
| 266 | DRIVER_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 | |
| 272 | DRIVER_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/drivers/super80.c
| r4933 | r4934 | |
| 4 | 4 | #include "cpu/z80/z80.h" |
| 5 | 5 | #include "cpu/z80/z80daisy.h" |
| 6 | 6 | #include "sound/wave.h" |
| 7 | | #include "machine/z80pio.h" |
| 8 | 7 | #include "devices/snapquik.h" |
| 9 | 8 | #include "devices/cartslot.h" |
| 10 | 9 | #include "devices/cassette.h" |
| 11 | 10 | #include "devices/z80bin.h" |
| 12 | 11 | #include "sound/speaker.h" |
| 13 | 12 | #include "machine/ctronics.h" |
| 14 | | #include "video/mc6845.h" |
| 15 | 13 | #include "super80.h" |
| 16 | 14 | |
| 17 | | |
| 18 | | static const device_config *super80_z80pio; |
| 19 | | static const device_config *super80_speaker; |
| 20 | | static const device_config *super80_cassette; |
| 21 | | static const device_config *super80_printer; |
| 22 | | |
| 23 | 15 | UINT8 *pcgram; |
| 24 | | UINT8 super80v_vid_col=1; // 0 = color ram ; 1 = video ram |
| 25 | | UINT8 super80v_rom_pcg=1; // 0 = prom ; 1 = pcg |
| 26 | | UINT8 super80_mhz=2; /* state of bit 2 of port F0 */ |
| 27 | 16 | |
| 28 | 17 | #define MASTER_CLOCK (XTAL_12MHz) |
| 29 | 18 | #define PIXEL_CLOCK (MASTER_CLOCK/2) |
| r4933 | r4934 | |
| 39 | 28 | #define SUPER80V_DOTS (7) |
| 40 | 29 | |
| 41 | 30 | |
| 42 | | /**************************** PIO ******************************************************************************/ |
| 43 | | |
| 44 | | static UINT8 keylatch; |
| 45 | | |
| 46 | | /* This activates when Control + C + 4 pressed */ |
| 47 | | static void super80_pio_interrupt(const device_config *device, int state) |
| 48 | | { |
| 49 | | cputag_set_input_line(device->machine, "maincpu", 0, state ); |
| 50 | | } |
| 51 | | |
| 52 | | static WRITE8_DEVICE_HANDLER( pio_port_a_w ) |
| 53 | | { |
| 54 | | keylatch = data; |
| 55 | | }; |
| 56 | | |
| 57 | | static 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 | | |
| 72 | | static 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 | | |
| 84 | | static const z80_daisy_chain super80_daisy_chain[] = |
| 85 | | { |
| 86 | | { "z80pio" }, |
| 87 | | { NULL } |
| 88 | | }; |
| 89 | | |
| 90 | | /**************************** CASSETTE ROUTINES *****************************************************************/ |
| 91 | | |
| 92 | | static 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 | | |
| 108 | | static 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 | | |
| 128 | | static 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 | | |
| 159 | | static 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 | | |
| 171 | | static 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 | | |
| 179 | | static 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 | | |
| 187 | | static UINT8 last_data; |
| 188 | | |
| 189 | | static 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 | | |
| 202 | | static 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 | | |
| 214 | | static 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 | | |
| 228 | | static READ8_HANDLER( super80_f8_r ) { return z80pio_d_r (super80_z80pio,0); } |
| 229 | | static READ8_HANDLER( super80_f9_r ) { return z80pio_c_r (super80_z80pio,0); } |
| 230 | | static READ8_HANDLER( super80_fa_r ) { return z80pio_d_r (super80_z80pio,1); } |
| 231 | | static READ8_HANDLER( super80_fb_r ) { return z80pio_c_r (super80_z80pio,1); } |
| 232 | | static WRITE8_HANDLER( super80_f8_w ) { z80pio_d_w(super80_z80pio,0, data); } |
| 233 | | static WRITE8_HANDLER( super80_f9_w ) { z80pio_c_w(super80_z80pio,0, data); } |
| 234 | | static WRITE8_HANDLER( super80_fa_w ) { z80pio_d_w(super80_z80pio,1, data); } |
| 235 | | static WRITE8_HANDLER( super80_fb_w ) { z80pio_c_w(super80_z80pio,1, data); } |
| 236 | | |
| 237 | 31 | /**************************** MEMORY AND I/O MAPPINGS *****************************************************************/ |
| 238 | 32 | |
| 239 | 33 | /* A read_byte or write_byte to unmapped memory crashes MESS, and UNMAP doesnt fix it. |
| r4933 | r4934 | |
| 269 | 63 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80_f0_w) |
| 270 | 64 | AM_RANGE(0xe1, 0xe1) AM_MIRROR(0x14) AM_WRITE(super80_f1_w) |
| 271 | 65 | 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) |
| 276 | 67 | ADDRESS_MAP_END |
| 277 | 68 | |
| 278 | 69 | static ADDRESS_MAP_START( super80r_io, ADDRESS_SPACE_IO, 8 ) |
| r4933 | r4934 | |
| 284 | 75 | AM_RANGE(0xdc, 0xdc) AM_READWRITE(super80_dc_r, super80_dc_w) |
| 285 | 76 | AM_RANGE(0xe0, 0xe0) AM_MIRROR(0x14) AM_WRITE(super80r_f0_w) |
| 286 | 77 | 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) |
| 291 | 79 | ADDRESS_MAP_END |
| 292 | 80 | |
| 293 | 81 | static ADDRESS_MAP_START( super80v_io, ADDRESS_SPACE_IO, 8 ) |
| r4933 | r4934 | |
| 297 | 85 | AM_RANGE(0x11, 0x11) AM_DEVREAD("crtc", mc6845_register_r) |
| 298 | 86 | AM_RANGE(0x11, 0x11) AM_WRITE(super80v_11_w) |
| 299 | 87 | 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) |
| 301 | 89 | 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) |
| 306 | 91 | ADDRESS_MAP_END |
| 307 | 92 | |
| 308 | 93 | /**************************** DIPSWITCHES, KEYBOARD, HARDWARE CONFIGURATION ****************************************/ |
| r4933 | r4934 | |
| 553 | 338 | |
| 554 | 339 | /**************************** BASIC MACHINE CONSTRUCTION ***********************************************************/ |
| 555 | 340 | |
| 556 | | static 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++; |
| 562 | 341 | |
| 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 */ |
| 588 | | static TIMER_CALLBACK( super80_reset ) |
| 342 | static const z80_daisy_chain super80_daisy_chain[] = |
| 589 | 343 | { |
| 590 | | memory_set_bank(machine, 1, 0); |
| 591 | | } |
| 344 | { "z80pio" }, |
| 345 | { NULL } |
| 346 | }; |
| 592 | 347 | |
| 593 | | static 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 | | |
| 603 | 348 | static const cassette_config super80_cassette_config = |
| 604 | 349 | { |
| 605 | 350 | cassette_default_formats, |
| r4933 | r4934 | |
| 746 | 491 | MDRV_CPU_IO_MAP(super80r_io) |
| 747 | 492 | MACHINE_DRIVER_END |
| 748 | 493 | |
| 749 | | static 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 | | |
| 756 | | static 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 | | |
| 762 | | static 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 | | |
| 771 | 494 | /**************************** ROMS *****************************************************************/ |
| 772 | 495 | |
| 773 | 496 | ROM_START( super80 ) |