src/mess/machine/mz700.c
| r4102 | r4103 | |
| 43 | 43 | static emu_timer *ne556_timer[2] = {NULL,}; /* NE556 timer */ |
| 44 | 44 | static UINT8 ne556_out[2] = {0,}; /* NE556 current output status */ |
| 45 | 45 | |
| 46 | | static UINT8 mz700_motor_on = 0; /* cassette motor key (play key) */ |
| 47 | | |
| 48 | 46 | static READ8_DEVICE_HANDLER ( pio_port_a_r ); |
| 49 | 47 | static READ8_DEVICE_HANDLER ( pio_port_b_r ); |
| 50 | 48 | static READ8_DEVICE_HANDLER ( pio_port_c_r ); |
| r4102 | r4103 | |
| 157 | 155 | |
| 158 | 156 | static READ8_DEVICE_HANDLER (pio_port_c_r ) |
| 159 | 157 | { |
| 160 | | UINT8 data = pio_port_c_output & 0x0f; |
| 158 | UINT8 data = pio_port_c_output & 0x0f; |
| 161 | 159 | |
| 162 | 160 | /* |
| 163 | 161 | * bit 7 in vertical blank |
| r4102 | r4103 | |
| 165 | 163 | * bit 5 in tape data (RDATA) |
| 166 | 164 | * bit 4 in motor (1 = on) |
| 167 | 165 | */ |
| 168 | | if (mz700_motor_on) |
| 169 | | data |= 0x10; |
| 170 | 166 | |
| 171 | | if (cassette_input(devtag_get_device(device->machine, CASSETTE, "cassette")) > 0.0038) |
| 172 | | data |= 0x20; /* set the RDATA status */ |
| 167 | /* note: this is actually connected to Q output of the motor-control flip-flop (see below) */ |
| 168 | if ((cassette_get_state(devtag_get_device(device->machine, CASSETTE, "cassette")) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 169 | data |= 0x10; |
| 173 | 170 | |
| 171 | if (cassette_input(devtag_get_device(device->machine, CASSETTE, "cassette")) > 0.0038) |
| 172 | data |= 0x20; /* set the RDATA status */ |
| 173 | |
| 174 | 174 | if (ne556_out[0]) |
| 175 | | data |= 0x40; /* set the 556OUT status */ |
| 175 | data |= 0x40; /* set the 556OUT status */ |
| 176 | 176 | |
| 177 | | data |= input_port_read(device->machine, "STATUS"); /* get VBLANK in bit 7 */ |
| 177 | data |= input_port_read(device->machine, "STATUS"); /* get VBLANK in bit 7 */ |
| 178 | 178 | |
| 179 | 179 | LOG(2,"mz700_pio_port_c_r",("%02X\n", data),device->machine); |
| 180 | 180 | |
| 181 | | return data; |
| 181 | return data; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | static WRITE8_DEVICE_HANDLER (pio_port_a_w ) |
| r4102 | r4103 | |
| 213 | 213 | * bit 1 out tape data (WDATA) |
| 214 | 214 | * bit 0 out unused |
| 215 | 215 | */ |
| 216 | | LOG(2,"mz700_pio_port_c_w",("%02X\n", data),device->machine); |
| 217 | | pio_port_c_output = data; |
| 218 | 216 | |
| 217 | // UINT8 state = cassette_get_state(devtag_get_device(device->machine, CASSETTE, "cassette")); |
| 218 | // UINT8 action = ((~pio_port_c_output & 8) & (data & 8)); /* detect low-to-high transition */ |
| 219 | |
| 220 | /* The motor control circuit consists of a resistor, capacitor, invertor, nand-gate, and D flip-flop. |
| 221 | The sense input from the cassette player goes low whenever play, rewind or fast-forward is pressed. |
| 222 | This connects to most of the above components. |
| 223 | The Q output enables the motor, and also connects to Bit 4 (input). |
| 224 | Bit 3 outputs a string of pulses to the Clock pin, and therefore cannot be used to control |
| 225 | the motor directly. |
| 226 | For the moment, the user can use the UI to select play, stop, etc. |
| 227 | If you load from the command-line or the software-picker, type in L <enter> immediately. |
| 228 | |
| 219 | 229 | cassette_change_state( |
| 220 | 230 | devtag_get_device(device->machine, CASSETTE, "cassette"), |
| 221 | 231 | ((data & 0x08) && mz700_motor_on) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, |
| 222 | 232 | CASSETTE_MOTOR_DISABLED); |
| 223 | 233 | |
| 224 | | cassette_output(devtag_get_device(device->machine, CASSETTE, "cassette"), (data & 0x02) ? +1.0 : -1.0); |
| 234 | */ |
| 235 | |
| 236 | LOG(2,"mz700_pio_port_c_w",("%02X\n", data),device->machine); |
| 237 | |
| 238 | cassette_output(devtag_get_device(device->machine, CASSETTE, "cassette"), (data & 0x02) ? +1.0 : -1.0); |
| 239 | |
| 240 | pio_port_c_output = data; |
| 225 | 241 | } |
| 226 | 242 | |
| 227 | 243 | /************************ MMIO ***********************************************/ |