trunk/src/mess/devices/appldriv.h
| r19758 | r19759 | |
| 11 | 11 | |
| 12 | 12 | #include "emu.h" |
| 13 | 13 | #include "imagedev/flopdrv.h" |
| 14 | #include "formats/ap2_dsk.h" |
| 14 | 15 | |
| 15 | 16 | void apple525_set_lines(device_t *device,UINT8 lines); |
| 16 | 17 | void apple525_set_enable_lines(device_t *device,int enable_mask); |
| r19758 | r19759 | |
| 32 | 33 | |
| 33 | 34 | int get_dividend() { return m_dividend; } |
| 34 | 35 | int get_divisor() { return m_divisor; } |
| 36 | |
| 37 | // these elements should be private, but are not yet |
| 38 | unsigned int state : 4; /* bits 0-3 are the phase */ |
| 39 | unsigned int tween_tracks : 1; |
| 40 | unsigned int track_loaded : 1; |
| 41 | unsigned int track_dirty : 1; |
| 42 | int position; |
| 43 | int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */ |
| 44 | UINT8 track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT]; |
| 45 | |
| 35 | 46 | protected: |
| 36 | 47 | virtual void device_start(); |
| 48 | |
| 37 | 49 | private: |
| 38 | 50 | int m_dividend; |
| 39 | 51 | int m_divisor; |
trunk/src/mess/devices/appldriv.c
| r19758 | r19759 | |
| 17 | 17 | #define PARENT_FLOPPY_2 "^floppy2" |
| 18 | 18 | #define PARENT_FLOPPY_3 "^floppy3" |
| 19 | 19 | |
| 20 | | struct apple525_disk |
| 21 | | { |
| 22 | | unsigned int state : 4; /* bits 0-3 are the phase */ |
| 23 | | unsigned int tween_tracks : 1; |
| 24 | | unsigned int track_loaded : 1; |
| 25 | | unsigned int track_dirty : 1; |
| 26 | | int position; |
| 27 | | int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */ |
| 28 | | UINT8 track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT]; |
| 29 | | }; |
| 30 | | |
| 31 | 20 | INLINE apple525_floppy_image_device *get_device(device_t *device) |
| 32 | 21 | { |
| 33 | 22 | assert(device != NULL); |
| r19758 | r19759 | |
| 75 | 64 | static void apple525_load_current_track(device_t *image) |
| 76 | 65 | { |
| 77 | 66 | int len; |
| 78 | | struct apple525_disk *disk; |
| 67 | apple525_floppy_image_device *disk; |
| 79 | 68 | |
| 80 | | disk = (struct apple525_disk *) flopimg_get_custom_data(image); |
| 69 | disk = get_device(image); |
| 81 | 70 | len = sizeof(disk->track_data); |
| 82 | 71 | |
| 83 | 72 | floppy_drive_read_track_data_info_buffer(image, 0, disk->track_data, &len); |
| r19758 | r19759 | |
| 88 | 77 | static void apple525_save_current_track(device_t *image, int unload) |
| 89 | 78 | { |
| 90 | 79 | int len; |
| 91 | | struct apple525_disk *disk; |
| 80 | apple525_floppy_image_device *disk; |
| 92 | 81 | |
| 93 | | disk = (struct apple525_disk *) flopimg_get_custom_data(image); |
| 82 | disk = get_device(image); |
| 94 | 83 | |
| 95 | 84 | if (disk->track_dirty) |
| 96 | 85 | { |
| r19758 | r19759 | |
| 102 | 91 | disk->track_loaded = 0; |
| 103 | 92 | } |
| 104 | 93 | |
| 105 | | static void apple525_seek_disk(device_t *img, struct apple525_disk *disk, signed int step) |
| 94 | static void apple525_seek_disk(device_t *img, signed int step) |
| 106 | 95 | { |
| 107 | 96 | int track; |
| 108 | 97 | int pseudo_track; |
| 98 | apple525_floppy_image_device *disk; |
| 109 | 99 | |
| 100 | disk = get_device(img); |
| 101 | |
| 110 | 102 | apple525_save_current_track(img, FALSE); |
| 111 | 103 | |
| 112 | 104 | track = floppy_drive_get_current_track(img); |
| r19758 | r19759 | |
| 132 | 124 | |
| 133 | 125 | static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_state) |
| 134 | 126 | { |
| 135 | | struct apple525_disk *cur_disk; |
| 127 | apple525_floppy_image_device *cur_disk; |
| 136 | 128 | UINT8 old_state; |
| 137 | 129 | unsigned int phase; |
| 138 | 130 | |
| 139 | | cur_disk = (struct apple525_disk *) flopimg_get_custom_data(image); |
| 131 | cur_disk = get_device(image); |
| 140 | 132 | |
| 141 | 133 | old_state = cur_disk->state; |
| 142 | 134 | cur_disk->state = new_state; |
| r19758 | r19759 | |
| 160 | 152 | switch(phase) |
| 161 | 153 | { |
| 162 | 154 | case 1: |
| 163 | | apple525_seek_disk(image, cur_disk, +1); |
| 155 | apple525_seek_disk(image, +1); |
| 164 | 156 | break; |
| 165 | 157 | case 3: |
| 166 | | apple525_seek_disk(image, cur_disk, -1); |
| 158 | apple525_seek_disk(image, -1); |
| 167 | 159 | break; |
| 168 | 160 | } |
| 169 | 161 | } |
| r19758 | r19759 | |
| 172 | 164 | int apple525_get_count(device_t *device) |
| 173 | 165 | { |
| 174 | 166 | int cnt = 0; |
| 175 | | if (device->subdevice("^"FLOPPY_0)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_0))!=NULL) cnt++; |
| 176 | | if (device->subdevice("^"FLOPPY_1)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_1))!=NULL) cnt++; |
| 177 | | if (device->subdevice("^"FLOPPY_2)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_2))!=NULL) cnt++; |
| 178 | | if (device->subdevice("^"FLOPPY_3)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_3))!=NULL) cnt++; |
| 167 | if (device->subdevice("^"FLOPPY_0)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_0))!=NULL) cnt++; |
| 168 | if (device->subdevice("^"FLOPPY_1)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_1))!=NULL) cnt++; |
| 169 | if (device->subdevice("^"FLOPPY_2)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_2))!=NULL) cnt++; |
| 170 | if (device->subdevice("^"FLOPPY_3)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_3))!=NULL) cnt++; |
| 179 | 171 | |
| 180 | 172 | // printf("%d apple525 drives\n", cnt); |
| 181 | 173 | return cnt; |
| r19758 | r19759 | |
| 202 | 194 | static UINT8 apple525_process_byte(device_t *img, int write_value) |
| 203 | 195 | { |
| 204 | 196 | UINT8 read_value; |
| 205 | | struct apple525_disk *disk; |
| 197 | apple525_floppy_image_device *disk; |
| 206 | 198 | int spinfract_divisor; |
| 207 | 199 | int spinfract_dividend; |
| 208 | 200 | apple525_floppy_image_device *config = get_device(img); |
| 209 | 201 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 210 | 202 | |
| 211 | | disk = (struct apple525_disk *) flopimg_get_custom_data(img); |
| 203 | disk = get_device(img); |
| 212 | 204 | spinfract_dividend = config->get_dividend(); |
| 213 | 205 | spinfract_divisor = config->get_divisor(); |
| 214 | 206 | |
| r19758 | r19759 | |
| 316 | 308 | void apple525_floppy_image_device::device_start() |
| 317 | 309 | { |
| 318 | 310 | legacy_floppy_image_device::device_start(); |
| 319 | | flopimg_alloc_custom_data(this,auto_alloc_clear(machine(),struct apple525_disk)); |
| 320 | 311 | floppy_set_type(this,FLOPPY_TYPE_APPLE); |
| 321 | 312 | } |
| 322 | 313 | |