src/mess/machine/wd17xx.c
| r7787 | r7788 | |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | /* |
| 537 | | Gets the size in bytes of the current track. For real hardware this |
| 538 | | may vary per system in small degree, and there even for each track |
| 539 | | and head, so we should not assume a fixed value here. |
| 540 | | As we are using a buffered track writing, we have to find out how long |
| 541 | | the track will become. The only object which can tell us is the |
| 542 | | selected format. |
| 543 | | */ |
| 544 | | static int get_track_size(wd1770_state *w) |
| 545 | | { |
| 546 | | int size = 0; |
| 547 | | floppy_image *floppy = flopimg_get_image(w->drive); |
| 548 | | if (floppy != NULL) |
| 549 | | { |
| 550 | | const struct FloppyCallbacks *fmt = floppy_callbacks(floppy); |
| 551 | | if (fmt != NULL) |
| 552 | | { |
| 553 | | size = fmt->get_track_size(floppy, w->hd, w->track); |
| 554 | | } |
| 555 | | } |
| 556 | | return size; |
| 557 | | } |
| 558 | | |
| 559 | | /* |
| 560 | 537 | Write an entire track. Formats which do not define a write_track |
| 561 | 538 | function pointer will cause a silent return. |
| 562 | 539 | What is written to the image depends on the selected format. Sector |
| r7787 | r7788 | |
| 567 | 544 | static void write_track(running_device *device) |
| 568 | 545 | { |
| 569 | 546 | wd1770_state *w = get_safe_token(device); |
| 547 | floppy_image *floppy; |
| 570 | 548 | #if 0 |
| 571 | 549 | int i; |
| 572 | 550 | for (i=0;i+4<w->data_offset;) |
| r7787 | r7788 | |
| 589 | 567 | } |
| 590 | 568 | #endif |
| 591 | 569 | |
| 592 | | /* Determine the track size. We cannot allow different sizes in this |
| 593 | | design. */ |
| 594 | | w->data_count = get_track_size(w); |
| 570 | /* Get the size in bytes of the current track. For real hardware this |
| 571 | may vary per system in small degree, and there even for each track |
| 572 | and head, so we should not assume a fixed value here. |
| 573 | As we are using a buffered track writing, we have to find out how long |
| 574 | the track will become. The only object which can tell us is the |
| 575 | selected format. |
| 576 | */ |
| 577 | w->data_count = 0; |
| 578 | floppy = flopimg_get_image(w->drive); |
| 579 | if (floppy != NULL) |
| 580 | w->data_count = floppy_get_track_size(floppy, w->hd, w->track); |
| 595 | 581 | |
| 596 | 582 | if (w->data_count==0) |
| 597 | 583 | { |
| r7787 | r7788 | |
| 619 | 605 | static void read_track(running_device *device) |
| 620 | 606 | { |
| 621 | 607 | wd1770_state *w = get_safe_token(device); |
| 608 | floppy_image *floppy; |
| 622 | 609 | #if 0 |
| 623 | 610 | UINT8 *psrc; /* pointer to track format structure */ |
| 624 | 611 | UINT8 *pdst; /* pointer to track buffer */ |
| r7787 | r7788 | |
| 738 | 725 | } |
| 739 | 726 | #endif |
| 740 | 727 | /* Determine the track size. We cannot allow different sizes in this |
| 741 | | design. */ |
| 742 | | w->data_count = get_track_size(w); |
| 728 | design (see above, write_track). */ |
| 729 | w->data_count = 0; |
| 730 | floppy = flopimg_get_image(w->drive); |
| 731 | if (floppy != NULL) |
| 732 | w->data_count = floppy_get_track_size(floppy, w->hd, w->track); |
| 743 | 733 | |
| 744 | 734 | if (w->data_count==0) |
| 745 | 735 | { |
src/mess/formats/flopimg.c
| r7787 | r7788 | |
| 739 | 739 | |
| 740 | 740 | UINT32 floppy_get_track_size(floppy_image *floppy, int head, int track) |
| 741 | 741 | { |
| 742 | | return floppy_callbacks(floppy)->get_track_size(floppy, head, track); |
| 742 | const struct FloppyCallbacks *fmt; |
| 743 | |
| 744 | fmt = floppy_callbacks(floppy); |
| 745 | if (!fmt->get_track_size) |
| 746 | return 0; |
| 747 | |
| 748 | return fmt->get_track_size(floppy, head, track); |
| 743 | 749 | } |
| 744 | 750 | |
| 745 | 751 | |