src/mess/machine/rx01.c
| r15732 | r15733 | |
| 121 | 121 | |
| 122 | 122 | void rx01_device::command_write(UINT16 data) |
| 123 | 123 | { |
| 124 | printf("command_write %04x\n",data); |
| 124 | 125 | m_unit = BIT(data,4); |
| 125 | 126 | m_interrupt = BIT(data,6); |
| 127 | |
| 128 | floppy_drive_set_ready_state(m_image[m_unit], 1,0); |
| 129 | |
| 130 | |
| 126 | 131 | if (BIT(data,14)) // Initialize |
| 127 | 132 | { |
| 133 | printf("initialize\n"); |
| 134 | m_state = RX01_INIT; |
| 128 | 135 | } |
| 129 | | if (BIT(data,1)) // If GO bit is selected |
| 136 | else if (BIT(data,1)) // If GO bit is selected |
| 130 | 137 | { |
| 131 | 138 | m_rxcs &= ~(1<<5); // Clear done bit |
| 132 | 139 | m_buf_pos = 0; // Point to start of buffer |
| r15732 | r15733 | |
| 139 | 146 | m_state = RX01_EMPTY; |
| 140 | 147 | break; |
| 141 | 148 | case 2: // Write Sector |
| 142 | | break; |
| 143 | 149 | case 3: // Read Sector |
| 150 | case 6: // Write Deleted Data Sector |
| 151 | m_rxes &= ~(1<<6 | 1<<1 | 1<<0);// Reset bits 0, 1 and 6 |
| 152 | m_state = RX01_SET_SECTOR; |
| 144 | 153 | break; |
| 145 | 154 | case 4: // Not Used |
| 155 | m_state = RX01_COMPLETE; |
| 146 | 156 | break; |
| 147 | 157 | case 5: // Read Status |
| 158 | m_state = RX01_COMPLETE; |
| 159 | m_rxdb = m_rxes; |
| 148 | 160 | break; |
| 149 | | case 6: // Write Deleted Data Sector |
| 150 | | break; |
| 151 | 161 | case 7: // Read Error Register |
| 162 | m_state = RX01_COMPLETE; |
| 163 | // set ready signal according to current drive status |
| 164 | m_rxes |= floppy_drive_get_flag_state(m_image[m_unit], FLOPPY_DRIVE_READY) << 7; |
| 152 | 165 | break; |
| 153 | 166 | } |
| 154 | 167 | } |
| 168 | machine().scheduler().timer_set(attotime::from_msec(100), FUNC(command_execution_callback), 0, this); |
| 155 | 169 | } |
| 156 | 170 | |
| 157 | 171 | UINT16 rx01_device::status_read() |
| 158 | 172 | { |
| 173 | //printf("status_read %04x\n",m_rxcs); |
| 159 | 174 | return m_rxcs; |
| 160 | 175 | } |
| 161 | 176 | |
| 162 | 177 | void rx01_device::data_write(UINT16 data) |
| 163 | 178 | { |
| 179 | printf("data_write %04x\n",data); |
| 164 | 180 | // data can be written only if TR is set |
| 165 | 181 | if (BIT(m_rxcs,7)) m_rxdb = data; |
| 182 | machine().scheduler().timer_set(attotime::from_msec(100), FUNC(command_execution_callback), 0, this); |
| 166 | 183 | } |
| 167 | 184 | |
| 168 | 185 | UINT16 rx01_device::data_read() |
| 169 | 186 | { |
| 170 | 187 | if (m_state==RX01_EMPTY && BIT(m_rxcs,7)) m_rxcs &= (1<<7); // clear TR bit; |
| 188 | printf("data_read %04x\n",m_rxdb); |
| 171 | 189 | return m_rxdb; |
| 172 | 190 | } |
| 173 | 191 | |
| 174 | 192 | void rx01_device::service_command() |
| 175 | 193 | { |
| 194 | printf("service_command %d\n",m_state); |
| 195 | m_rxes |= floppy_drive_get_flag_state(m_image[m_unit], FLOPPY_DRIVE_READY) << 7; |
| 176 | 196 | switch(m_state) { |
| 177 | 197 | case RX01_FILL : |
| 178 | 198 | m_buffer[m_buf_pos] = m_rxdb & 0xff; |
| r15732 | r15733 | |
| 210 | 230 | case RX01_COMPLETE: |
| 211 | 231 | break; |
| 212 | 232 | case RX01_INIT: |
| 233 | m_rxes |= (1<<2); // Set init done flag |
| 234 | m_rxcs |= (1<<5); // Set operation done |
| 213 | 235 | break; |
| 214 | 236 | } |
| 215 | 237 | } |