src/mess/machine/mc6846.c
| r3754 | r3755 | |
| 86 | 86 | |
| 87 | 87 | |
| 88 | 88 | |
| 89 | | INLINE UINT16 mc6846_counter ( void ) |
| 89 | INLINE UINT16 mc6846_counter ( running_machine *machine ) |
| 90 | 90 | { |
| 91 | 91 | if ( mc6846.timer_started ) |
| 92 | 92 | { |
| 93 | 93 | attotime delay = timer_timeleft( mc6846.interval ); |
| 94 | | return ATTOTIME_TO_CYCLES( mc6846.iface->cpunum, delay ) / FACTOR; |
| 94 | return cpu_attotime_to_clocks( machine->cpu[mc6846.iface->cpunum], delay ) / FACTOR; |
| 95 | 95 | } |
| 96 | 96 | else |
| 97 | 97 | return mc6846.preset; |
| r3754 | r3755 | |
| 148 | 148 | |
| 149 | 149 | INLINE void mc6846_timer_launch ( running_machine *machine ) |
| 150 | 150 | { |
| 151 | | int delay = FACTOR * (mc6846.preset+1); |
| 151 | // int delay = FACTOR * (mc6846.preset+1); |
| 152 | 152 | LOG (( "%f: mc6846 timer launch called, mode=%i, preset=%i (x%i)\n", attotime_to_double(timer_get_time(machine)), MODE, mc6846.preset, FACTOR )); |
| 153 | 153 | |
| 154 | 154 | if ( ! (mc6846.tcr & 2) ) |
| r3754 | r3755 | |
| 193 | 193 | |
| 194 | 194 | static TIMER_CALLBACK(mc6846_timer_expire) |
| 195 | 195 | { |
| 196 | | int delay = FACTOR * (mc6846.latch+1); |
| 196 | // int delay = FACTOR * (mc6846.latch+1); |
| 197 | 197 | |
| 198 | 198 | LOG (( "%f: mc6846 timer expire called, mode=%i, latch=%i (x%i)\n", attotime_to_double(timer_get_time(machine)), MODE, mc6846.latch, FACTOR )); |
| 199 | 199 | |
| r3754 | r3755 | |
| 256 | 256 | case 0: |
| 257 | 257 | case 4: |
| 258 | 258 | LOG (( "$%04x %f: mc6846 CSR read $%02X intr=%i (timer=%i, cp1=%i, cp2=%i)\n", |
| 259 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 259 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 260 | 260 | mc6846.csr, (mc6846.csr >> 7) & 1, |
| 261 | 261 | mc6846.csr & 1, (mc6846.csr >> 1) & 1, (mc6846.csr >> 2) & 1 )); |
| 262 | 262 | mc6846.csr0_to_be_cleared = mc6846.csr & 1; |
| r3754 | r3755 | |
| 265 | 265 | return mc6846.csr; |
| 266 | 266 | |
| 267 | 267 | case 1: |
| 268 | | LOG (( "$%04x %f: mc6846 PCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846.pcr )); |
| 268 | LOG (( "$%04x %f: mc6846 PCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846.pcr )); |
| 269 | 269 | return mc6846.pcr; |
| 270 | 270 | |
| 271 | 271 | case 2: |
| 272 | | LOG (( "$%04x %f: mc6846 DDR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846.ddr )); |
| 272 | LOG (( "$%04x %f: mc6846 DDR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846.ddr )); |
| 273 | 273 | return mc6846.ddr; |
| 274 | 274 | |
| 275 | 275 | case 3: |
| 276 | | LOG (( "$%04x %f: mc6846 PORT read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), PORT_SPACE )); |
| 276 | LOG (( "$%04x %f: mc6846 PORT read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), PORT_SPACE )); |
| 277 | 277 | if ( ! (mc6846.pcr & 0x80) ) |
| 278 | 278 | { |
| 279 | 279 | if ( mc6846.csr1_to_be_cleared ) |
| r3754 | r3755 | |
| 287 | 287 | return PORT_SPACE; |
| 288 | 288 | |
| 289 | 289 | case 5: |
| 290 | | LOG (( "$%04x %f: mc6846 TCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846.tcr )); |
| 290 | LOG (( "$%04x %f: mc6846 TCR read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846.tcr )); |
| 291 | 291 | return mc6846.tcr; |
| 292 | 292 | |
| 293 | 293 | case 6: |
| 294 | | LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846_counter() >> 8 )); |
| 294 | LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846_counter(space->machine) >> 8 )); |
| 295 | 295 | if ( mc6846.csr0_to_be_cleared ) |
| 296 | 296 | { |
| 297 | 297 | mc6846.csr &= ~1; |
| 298 | 298 | mc6846_update_irq(space->machine); |
| 299 | 299 | } |
| 300 | 300 | mc6846.csr0_to_be_cleared = 0; |
| 301 | | return mc6846_counter() >> 8; |
| 301 | return mc6846_counter(space->machine) >> 8; |
| 302 | 302 | |
| 303 | 303 | case 7: |
| 304 | | LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846_counter() & 0xff )); |
| 304 | LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846_counter(space->machine) & 0xff )); |
| 305 | 305 | if ( mc6846.csr0_to_be_cleared ) |
| 306 | 306 | { |
| 307 | 307 | mc6846.csr &= ~1; |
| 308 | 308 | mc6846_update_irq(space->machine); |
| 309 | 309 | } |
| 310 | 310 | mc6846.csr0_to_be_cleared = 0; |
| 311 | | return mc6846_counter() & 0xff; |
| 311 | return mc6846_counter(space->machine) & 0xff; |
| 312 | 312 | |
| 313 | 313 | default: |
| 314 | 314 | logerror( "$%04x mc6846 invalid read offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| r3754 | r3755 | |
| 340 | 340 | "latcged,pos-edge", "latcged,pos-edge,intr" |
| 341 | 341 | }; |
| 342 | 342 | LOG (( "$%04x %f: mc6846 PCR write $%02X reset=%i cp2=%s cp1=%s\n", |
| 343 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, |
| 343 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 344 | 344 | (data >> 7) & 1, cp2[ (data >> 3) & 7 ], cp1[ data & 7 ] )); |
| 345 | 345 | |
| 346 | 346 | } |
| r3754 | r3755 | |
| 368 | 368 | break; |
| 369 | 369 | |
| 370 | 370 | case 2: |
| 371 | | LOG (( "$%04x %f: mc6846 DDR write $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data )); |
| 371 | LOG (( "$%04x %f: mc6846 DDR write $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 372 | 372 | if ( ! (mc6846.pcr & 0x80) ) |
| 373 | 373 | { |
| 374 | 374 | mc6846.ddr = data; |
| r3754 | r3755 | |
| 378 | 378 | break; |
| 379 | 379 | |
| 380 | 380 | case 3: |
| 381 | | LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data,mc6846.ddr )); |
| 381 | LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data,mc6846.ddr )); |
| 382 | 382 | if ( ! (mc6846.pcr & 0x80) ) |
| 383 | 383 | { |
| 384 | 384 | mc6846.pdr = data; |
| r3754 | r3755 | |
| 387 | 387 | if ( mc6846.csr1_to_be_cleared && (mc6846.csr & 2) ) |
| 388 | 388 | { |
| 389 | 389 | mc6846.csr &= ~2; |
| 390 | | LOG (( "$%04x %f: mc6846 CP1 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)) )); |
| 390 | LOG (( "$%04x %f: mc6846 CP1 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)) )); |
| 391 | 391 | } |
| 392 | 392 | if ( mc6846.csr2_to_be_cleared && (mc6846.csr & 4) ) |
| 393 | 393 | { |
| 394 | 394 | mc6846.csr &= ~4; |
| 395 | | LOG (( "$%04x %f: mc6846 CP2 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)) )); |
| 395 | LOG (( "$%04x %f: mc6846 CP2 intr reset\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)) )); |
| 396 | 396 | } |
| 397 | 397 | mc6846.csr1_to_be_cleared = 0; |
| 398 | 398 | mc6846.csr2_to_be_cleared = 0; |
| r3754 | r3755 | |
| 408 | 408 | "freq-cmp", "freq-cmp", "pulse-cmp", "pulse-cmp" |
| 409 | 409 | }; |
| 410 | 410 | LOG (( "$%04x %f: mc6846 TCR write $%02X reset=%i clock=%s scale=%i mode=%s out=%s\n", |
| 411 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, |
| 411 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 412 | 412 | (data >> 7) & 1, (data & 0x40) ? "extern" : "sys", |
| 413 | 413 | (data & 0x40) ? 1 : 8, mode[ (data >> 1) & 7 ], |
| 414 | 414 | (data & 1) ? "enabled" : "0" )); |
| r3754 | r3755 | |
| 442 | 442 | |
| 443 | 443 | case 7: |
| 444 | 444 | mc6846.latch = ( ((UINT16) mc6846.time_MSB) << 8 ) + data; |
| 445 | | LOG (( "$%04x %f: mc6846 COUNT write %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), mc6846.latch )); |
| 445 | LOG (( "$%04x %f: mc6846 COUNT write %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), mc6846.latch )); |
| 446 | 446 | if (!(mc6846.tcr & 0x38)) |
| 447 | 447 | { |
| 448 | 448 | /* timer initialization */ |
| r3754 | r3755 | |
| 564 | 564 | |
| 565 | 565 | /************************** configuration ****************************/ |
| 566 | 566 | |
| 567 | | void mc6846_config ( const mc6846_interface* iface ) |
| 567 | void mc6846_config ( running_machine *machine, const mc6846_interface* iface ) |
| 568 | 568 | { |
| 569 | 569 | mc6846.iface = iface; |
| 570 | 570 | mc6846.interval = timer_alloc(machine, mc6846_timer_expire , NULL); |
src/mess/machine/mc6843.c
| r3754 | r3755 | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | /* Seek Track Zero bottom half */ |
| 191 | | static void mc6843_finish_STZ( void ) |
| 191 | static void mc6843_finish_STZ( running_machine *machine ) |
| 192 | 192 | { |
| 193 | 193 | const device_config* img = mc6843_floppy_image(); |
| 194 | 194 | int i; |
| r3754 | r3755 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | /* Seek bottom half */ |
| 220 | | static void mc6843_finish_SEK( void ) |
| 220 | static void mc6843_finish_SEK( running_machine *machine ) |
| 221 | 221 | { |
| 222 | 222 | const device_config* img = mc6843_floppy_image(); |
| 223 | 223 | |
| r3754 | r3755 | |
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | /* preamble to all sector read / write commands, returns 1 if found */ |
| 238 | | static int mc6843_address_search( chrn_id* id ) |
| 238 | static int mc6843_address_search( running_machine *machine, chrn_id* id ) |
| 239 | 239 | { |
| 240 | 240 | const device_config* img = mc6843_floppy_image(); |
| 241 | 241 | int r = 0; |
| r3754 | r3755 | |
| 293 | 293 | |
| 294 | 294 | |
| 295 | 295 | /* preamble specific to read commands (adds extra checks) */ |
| 296 | | static int mc6843_address_search_read( chrn_id* id ) |
| 296 | static int mc6843_address_search_read( running_machine *machine, chrn_id* id ) |
| 297 | 297 | { |
| 298 | | if ( ! mc6843_address_search( id ) ) |
| 298 | if ( ! mc6843_address_search( machine, id ) ) |
| 299 | 299 | return 0; |
| 300 | 300 | |
| 301 | 301 | if ( id->flags & ID_FLAG_CRC_ERROR_IN_DATA_FIELD ) |
| r3754 | r3755 | |
| 319 | 319 | |
| 320 | 320 | |
| 321 | 321 | /* Read CRC bottom half */ |
| 322 | | static void mc6843_finish_RCR( void ) |
| 322 | static void mc6843_finish_RCR( running_machine *machine ) |
| 323 | 323 | { |
| 324 | 324 | chrn_id id; |
| 325 | | if ( ! mc6843_address_search_read( &id ) ) |
| 325 | if ( ! mc6843_address_search_read( machine, &id ) ) |
| 326 | 326 | return; |
| 327 | 327 | mc6843_cmd_end(); |
| 328 | 328 | } |
| r3754 | r3755 | |
| 330 | 330 | |
| 331 | 331 | |
| 332 | 332 | /* Single / Multiple Sector Read bottom half */ |
| 333 | | static void mc6843_cont_SR( void ) |
| 333 | static void mc6843_cont_SR( running_machine *machine ) |
| 334 | 334 | { |
| 335 | 335 | chrn_id id; |
| 336 | 336 | const device_config* img = mc6843_floppy_image(); |
| 337 | 337 | |
| 338 | 338 | /* sector seek */ |
| 339 | | if ( ! mc6843_address_search_read( &id ) ) |
| 339 | if ( ! mc6843_address_search_read( machine, &id ) ) |
| 340 | 340 | return; |
| 341 | 341 | |
| 342 | 342 | /* sector read */ |
| r3754 | r3755 | |
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | /* Single / Multiple Sector Write bottom half */ |
| 353 | | static void mc6843_cont_SW( void ) |
| 353 | static void mc6843_cont_SW( running_machine *machine ) |
| 354 | 354 | { |
| 355 | 355 | chrn_id id; |
| 356 | 356 | |
| 357 | 357 | /* sector seek */ |
| 358 | | if ( ! mc6843_address_search( &id ) ) |
| 358 | if ( ! mc6843_address_search( machine, &id ) ) |
| 359 | 359 | return; |
| 360 | 360 | |
| 361 | 361 | /* setup sector write buffer */ |
| r3754 | r3755 | |
| 379 | 379 | |
| 380 | 380 | switch ( cmd ) |
| 381 | 381 | { |
| 382 | | case CMD_STZ: mc6843_finish_STZ(); break; |
| 383 | | case CMD_SEK: mc6843_finish_SEK(); break; |
| 384 | | case CMD_SSR: mc6843_cont_SR(); break; |
| 385 | | case CMD_SSW: mc6843_cont_SW(); break; |
| 386 | | case CMD_RCR: mc6843_finish_RCR(); break; |
| 387 | | case CMD_SWD: mc6843_cont_SW(); break; |
| 388 | | case CMD_MSW: mc6843_cont_SW(); break; |
| 389 | | case CMD_MSR: mc6843_cont_SR(); break; |
| 382 | case CMD_STZ: mc6843_finish_STZ(machine); break; |
| 383 | case CMD_SEK: mc6843_finish_SEK(machine); break; |
| 384 | case CMD_SSR: mc6843_cont_SR(machine); break; |
| 385 | case CMD_SSW: mc6843_cont_SW(machine); break; |
| 386 | case CMD_RCR: mc6843_finish_RCR(machine); break; |
| 387 | case CMD_SWD: mc6843_cont_SW(machine); break; |
| 388 | case CMD_MSW: mc6843_cont_SW(machine); break; |
| 389 | case CMD_MSR: mc6843_cont_SR(machine); break; |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
| r3754 | r3755 | |
| 407 | 407 | int cmd = mc6843->CMR & 0x0f; |
| 408 | 408 | |
| 409 | 409 | LOG(( "%f $%04x mc6843_r: data input cmd=%s(%i), pos=%i/%i, GCR=%i, ", |
| 410 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 410 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 411 | 411 | mc6843_cmd[cmd], cmd, mc6843->data_idx, |
| 412 | 412 | mc6843->data_size, mc6843->GCR )); |
| 413 | 413 | |
| r3754 | r3755 | |
| 471 | 471 | case 1: /* Current-Track Address Register (CTAR) */ |
| 472 | 472 | data = mc6843->CTAR; |
| 473 | 473 | LOG(( "%f $%04x mc6843_r: read CTAR %i (actual=%i)\n", |
| 474 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 474 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 475 | 475 | floppy_drive_get_current_track( mc6843_floppy_image() ) )); |
| 476 | 476 | break; |
| 477 | 477 | |
| 478 | 478 | case 2: /* Interrupt Status Register (ISR) */ |
| 479 | 479 | data = mc6843->ISR; |
| 480 | 480 | LOG(( "%f $%04x mc6843_r: read ISR %02X: cmd=%scomplete settle=%scomplete sense-rq=%i STRB=%i\n", |
| 481 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 481 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 482 | 482 | (data & 1) ? "" : "not-" , (data & 2) ? "" : "not-", |
| 483 | 483 | (data >> 2) & 1, (data >> 3) & 1 )); |
| 484 | 484 | |
| r3754 | r3755 | |
| 504 | 504 | |
| 505 | 505 | data = mc6843->STRA; |
| 506 | 506 | LOG(( "%f $%04x mc6843_r: read STRA %02X: data-rq=%i del-dta=%i ready=%i t0=%i wp=%i trk-dif=%i idx=%i busy=%i\n", |
| 507 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 507 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 508 | 508 | data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1, |
| 509 | 509 | (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 )); |
| 510 | 510 | break; |
| r3754 | r3755 | |
| 513 | 513 | case 4: /* Status Register B (STRB) */ |
| 514 | 514 | data = mc6843->STRB; |
| 515 | 515 | LOG(( "%f $%04x mc6843_r: read STRB %02X: data-err=%i CRC-err=%i dta--mrk-err=%i sect-mrk-err=%i seek-err=%i fi=%i wr-err=%i hard-err=%i\n", |
| 516 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 516 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 517 | 517 | data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1, |
| 518 | 518 | (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 )); |
| 519 | 519 | |
| r3754 | r3755 | |
| 525 | 525 | case 7: /* Logical-Track Address Register (LTAR) */ |
| 526 | 526 | data = mc6843->LTAR; |
| 527 | 527 | LOG(( "%f $%04x mc6843_r: read LTAR %i (actual=%i)\n", |
| 528 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 528 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 529 | 529 | floppy_drive_get_current_track( mc6843_floppy_image() ) )); |
| 530 | 530 | break; |
| 531 | 531 | |
| r3754 | r3755 | |
| 546 | 546 | int FWF = (mc6843->CMR >> 4) & 1; |
| 547 | 547 | |
| 548 | 548 | LOG(( "%f $%04x mc6843_w: data output cmd=%s(%i), pos=%i/%i, GCR=%i, data=%02X\n", |
| 549 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 549 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 550 | 550 | mc6843_cmd[cmd], cmd, mc6843->data_idx, |
| 551 | 551 | mc6843->data_size, mc6843->GCR, data )); |
| 552 | 552 | |
| r3754 | r3755 | |
| 563 | 563 | /* end of sector write */ |
| 564 | 564 | const device_config* img = mc6843_floppy_image(); |
| 565 | 565 | |
| 566 | | LOG(( "%f $%04x mc6843_w: write sector %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6843->data_id )); |
| 566 | LOG(( "%f $%04x mc6843_w: write sector %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6843->data_id )); |
| 567 | 567 | |
| 568 | 568 | floppy_drive_write_sector_data( |
| 569 | 569 | img, mc6843->side, mc6843->data_id, |
| r3754 | r3755 | |
| 627 | 627 | UINT8 track = mc6843->data[1]; |
| 628 | 628 | UINT8 sector = mc6843->data[3]; |
| 629 | 629 | UINT8 filler = 0xe5; /* standard Thomson filler */ |
| 630 | | LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), track, sector)); |
| 630 | LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), track, sector)); |
| 631 | 631 | floppy_drive_format_sector( img, mc6843->side, sector, track, 0, sector, 0, filler ); |
| 632 | 632 | } |
| 633 | 633 | else |
| r3754 | r3755 | |
| 657 | 657 | case 1: /* Current-Track Address Register (CTAR) */ |
| 658 | 658 | mc6843->CTAR = data & 0x7f; |
| 659 | 659 | LOG(( "%f $%04x mc6843_w: set CTAR to %i %02X (actual=%i) \n", |
| 660 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6843->CTAR, data, |
| 660 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6843->CTAR, data, |
| 661 | 661 | floppy_drive_get_current_track( mc6843_floppy_image() ) )); |
| 662 | 662 | break; |
| 663 | 663 | |
| r3754 | r3755 | |
| 666 | 666 | int cmd = data & 15; |
| 667 | 667 | |
| 668 | 668 | LOG(( "%f $%04x mc6843_w: set CMR to $%02X: cmd=%s(%i) FWF=%i DMA=%i ISR3-intr=%i fun-intr=%i\n", |
| 669 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 669 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 670 | 670 | data, mc6843_cmd[cmd], cmd, (data >> 4) & 1, (data >> 5) & 1, |
| 671 | 671 | (data >> 6) & 1, (data >> 7) & 1 )); |
| 672 | 672 | |
| r3754 | r3755 | |
| 713 | 713 | |
| 714 | 714 | /* assume CLK freq = 1MHz (IBM 3740 compatibility) */ |
| 715 | 715 | LOG(( "%f $%04x mc6843_w: set SUR to $%02X: head settling time=%fms, track-to-track seek time=%f\n", |
| 716 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 716 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 717 | 717 | data, 4.096 * (data & 15), 1.024 * ((data >> 4) & 15) )); |
| 718 | 718 | break; |
| 719 | 719 | |
| 720 | 720 | case 4: /* Sector Address Register (SAR) */ |
| 721 | 721 | mc6843->SAR = data & 0x1f; |
| 722 | | LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6843->SAR, data )); |
| 722 | LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6843->SAR, data )); |
| 723 | 723 | break; |
| 724 | 724 | |
| 725 | 725 | case 5: /* General Count Register (GCR) */ |
| 726 | 726 | mc6843->GCR = data & 0x7f; |
| 727 | | LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6843->GCR, data )); |
| 727 | LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6843->GCR, data )); |
| 728 | 728 | break; |
| 729 | 729 | |
| 730 | 730 | case 6: /* CRC Control Register (CCR) */ |
| 731 | 731 | mc6843->CCR = data & 3; |
| 732 | 732 | LOG(( "%f $%04x mc6843_w: set CCR to %02X: CRC=%s shift=%i\n", |
| 733 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 733 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 734 | 734 | (data & 1) ? "enabled" : "disabled", (data >> 1) & 1 )); |
| 735 | 735 | break; |
| 736 | 736 | |
| 737 | 737 | case 7: /* Logical-Track Address Register (LTAR) */ |
| 738 | 738 | mc6843->LTAR = data & 0x7f; |
| 739 | 739 | LOG(( "%f $%04x mc6843_w: set LTAR to %i %02X (actual=%i)\n", |
| 740 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6843->LTAR, data, |
| 740 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6843->LTAR, data, |
| 741 | 741 | floppy_drive_get_current_track( mc6843_floppy_image() ) )); |
| 742 | 742 | break; |
| 743 | 743 | |
| r3754 | r3755 | |
| 807 | 807 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->LTAR ); |
| 808 | 808 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->drive ); |
| 809 | 809 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->side ); |
| 810 | | state_save_register_item_array( "mc6843", NULL, 0, mc6843->data ); |
| 810 | state_save_register_item_array( machine, "mc6843", NULL, 0, mc6843->data ); |
| 811 | 811 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->data_size ); |
| 812 | 812 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->data_idx ); |
| 813 | 813 | state_save_register_item(machine, "mc6843", NULL, 0, mc6843->data_id ); |