src/mess/audio/upd1771.c
| r7004 | r7005 | |
| 45 | 45 | logerror( "upd1771_w: received byte 0x%02x\n", data ); |
| 46 | 46 | |
| 47 | 47 | state->packet[ state->index ] = data; |
| 48 | | state->index = ( state->index + 1 ) % MAX_PACKET_SIZE; |
| 48 | state->index = state->index + 1; |
| 49 | 49 | |
| 50 | 50 | devcb_call_write_line( &state->ack_out_func, 0 ); |
| 51 | 51 | |
| 52 | | /* Trigger ACK after 512??? cycles */ |
| 53 | | timer_adjust_oneshot( state->timer, ticks_to_attotime( 512, device->clock ), 0 ); |
| 52 | /* Start of a new command */ |
| 53 | if ( state->expected_bytes == 0 ) |
| 54 | { |
| 55 | switch ( data ) |
| 56 | { |
| 57 | case 0x00: /* 00 - 1 byte command */ |
| 58 | state->expected_bytes = 1; |
| 59 | break; |
| 60 | case 0x01: /* 01 - 10 byte command */ |
| 61 | state->expected_bytes = 10; |
| 62 | case 0x02: /* 02 - 4 byte command */ |
| 63 | state->expected_bytes = 4; |
| 64 | break; |
| 65 | default: |
| 66 | if (LOG) |
| 67 | logerror("upd1771: unknown command %02x received\n", data ); |
| 68 | state->expected_bytes = 99; |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if ( state->index == state->expected_bytes ) |
| 74 | { |
| 75 | /* The command packet has been transferred, handle the command */ |
| 76 | if (LOG) |
| 77 | logerror("upd1771_w: handle command %02x\n", state->packet[0] ); |
| 78 | state->expected_bytes = 0; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | /* We need more data to complete the command packet */ |
| 83 | /* Trigger ACK after 512??? cycles */ |
| 84 | timer_adjust_oneshot( state->timer, ticks_to_attotime( 512, device->clock ), 0 ); |
| 85 | } |
| 86 | |
| 87 | state->index = state->index % MAX_PACKET_SIZE; |
| 54 | 88 | } |
| 55 | 89 | |
| 56 | 90 | |