src/mess/drivers/super80.c
| r2850 | r2851 | |
| 386 | 386 | |
| 387 | 387 | /********************************************* TIMER ************************************************/ |
| 388 | 388 | |
| 389 | | static UINT8 wave_length, last_wave_state=0, cass_out; |
| 389 | static UINT8 cass_data[]={ 0, 0, 0, 0 }; |
| 390 | 390 | |
| 391 | 391 | /* this timer runs at 200khz and does 2 jobs: |
| 392 | 392 | 1. Scan the keyboard and present the results to the pio |
| r2850 | r2851 | |
| 401 | 401 | |
| 402 | 402 | static TIMER_CALLBACK( super80_timer ) |
| 403 | 403 | { |
| 404 | | UINT8 wave_state=0, i, mask=1, out_f8=z80pio_p_r(0,0), in_fa=255; |
| 404 | UINT8 cass_ws=0, i, mask=1, out_f8=z80pio_p_r(0,0), in_fa=255; |
| 405 | 405 | char port[6]; |
| 406 | 406 | |
| 407 | 407 | for ( i=0; i < 8;i++) |
| r2850 | r2851 | |
| 413 | 413 | |
| 414 | 414 | z80pio_p_w(0,1,in_fa); |
| 415 | 415 | |
| 416 | | if (cassette_input(cassette_device_image()) > +0.03) wave_state+=6; |
| 416 | cass_data[1]++; |
| 417 | cass_ws = (cassette_input(cassette_device_image()) > +0.03) ? 4 : 0; |
| 417 | 418 | |
| 418 | | if (wave_state == last_wave_state) |
| 419 | | wave_length++; |
| 420 | | else |
| 419 | if (cass_ws != cass_data[0]) |
| 421 | 420 | { |
| 422 | | last_wave_state = wave_state; |
| 423 | | cass_out = wave_state; |
| 424 | | if (wave_length < 0x40) cass_out++; |
| 425 | | wave_length = 0; |
| 421 | if (cass_ws) cass_data[3] ^= 2; |
| 422 | cass_data[0] = cass_ws; |
| 423 | cass_data[2] = ((cass_data[1] < 0x40) ? 1 : 0) | cass_ws | cass_data[3]; |
| 424 | cass_data[1] = 0; |
| 426 | 425 | } |
| 427 | 426 | } |
| 428 | 427 | |
| r2850 | r2851 | |
| 439 | 438 | static READ8_HANDLER( super80_f2_r ) |
| 440 | 439 | { |
| 441 | 440 | UINT8 data = input_port_read(machine, "DSW") & 0xf0; // dip switches on pcb |
| 442 | | data |= cass_out; // bit 0 = output of U1, bit 1 = current wave_state |
| 443 | | data |= 0x08; // bits 2,3 - not used |
| 441 | data |= cass_data[2]; // bit 0 = output of U1, bit 2 = current wave_state |
| 442 | data |= 0x08; // bit 3 - not used |
| 444 | 443 | return data; |
| 445 | 444 | } |
| 446 | 445 | |