Previous 199869 Revisions Next

r19759 Sunday 23rd December, 2012 at 21:16:02 UTC by Nathan Woods
[APPLE2] Floppy drive cleanups/modernization (nw)
[src/emu/imagedev]flopdrv.c flopdrv.h
[src/mess/devices]appldriv.c appldriv.h
[src/mess/machine]apple2.c

trunk/src/emu/imagedev/flopdrv.c
r19758r19759
8585   int track;
8686   void (*load_proc)(device_image_interface &image);
8787   void (*unload_proc)(device_image_interface &image);
88   void *custom_data;
8988   int floppy_drive_type;
9089};
9190
r19758r19759
127126   return get_safe_token(image)->floppy;
128127}
129128
130void *flopimg_get_custom_data(device_t *image)
131{
132   floppy_drive *flopimg = get_safe_token( image );
133   return flopimg->custom_data;
134}
135
136void flopimg_alloc_custom_data(device_t *image,void *custom)
137{
138   floppy_drive *flopimg = get_safe_token( image );
139   flopimg->custom_data = custom;
140}
141
142129static int flopimg_get_sectors_per_track(device_t *image, int side)
143130{
144131   floperr_t err;
r19758r19759
224211
225212   pDrive->controller = NULL;
226213
227   pDrive->custom_data = NULL;
228
229214   pDrive->floppy_drive_type = FLOPPY_TYPE_REGULAR;
230215}
231216
trunk/src/emu/imagedev/flopdrv.h
r19758r19759
145145int floppy_get_drive(device_t *image);
146146int floppy_get_drive_by_type(device_t *image,int ftype);
147147
148void *flopimg_get_custom_data(device_t *image);
149void flopimg_alloc_custom_data(device_t *image,void *custom);
150
151148void floppy_drive_set_geometry(device_t *img, floppy_type_t type);
152149
153150/* drive select lines */
trunk/src/mess/devices/appldriv.h
r19758r19759
1111
1212#include "emu.h"
1313#include "imagedev/flopdrv.h"
14#include "formats/ap2_dsk.h"
1415
1516void apple525_set_lines(device_t *device,UINT8 lines);
1617void apple525_set_enable_lines(device_t *device,int enable_mask);
r19758r19759
3233
3334   int get_dividend() { return m_dividend; }
3435   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
3546protected:
3647   virtual void device_start();
48
3749private:
3850   int   m_dividend;
3951   int   m_divisor;
trunk/src/mess/devices/appldriv.c
r19758r19759
1717#define PARENT_FLOPPY_2 "^floppy2"
1818#define PARENT_FLOPPY_3 "^floppy3"
1919
20struct 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
3120INLINE apple525_floppy_image_device *get_device(device_t *device)
3221{
3322   assert(device != NULL);
r19758r19759
7564static void apple525_load_current_track(device_t *image)
7665{
7766   int len;
78   struct apple525_disk *disk;
67   apple525_floppy_image_device *disk;
7968
80   disk = (struct apple525_disk *) flopimg_get_custom_data(image);
69   disk = get_device(image);
8170   len = sizeof(disk->track_data);
8271
8372   floppy_drive_read_track_data_info_buffer(image, 0, disk->track_data, &len);
r19758r19759
8877static void apple525_save_current_track(device_t *image, int unload)
8978{
9079   int len;
91   struct apple525_disk *disk;
80   apple525_floppy_image_device *disk;
9281
93   disk = (struct apple525_disk *)  flopimg_get_custom_data(image);
82   disk = get_device(image);
9483
9584   if (disk->track_dirty)
9685   {
r19758r19759
10291      disk->track_loaded = 0;
10392}
10493
105static void apple525_seek_disk(device_t *img, struct apple525_disk *disk, signed int step)
94static void apple525_seek_disk(device_t *img, signed int step)
10695{
10796   int track;
10897   int pseudo_track;
98   apple525_floppy_image_device *disk;
10999
100   disk = get_device(img);
101
110102   apple525_save_current_track(img, FALSE);
111103
112104   track = floppy_drive_get_current_track(img);
r19758r19759
132124
133125static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_state)
134126{
135   struct apple525_disk *cur_disk;
127   apple525_floppy_image_device *cur_disk;
136128   UINT8 old_state;
137129   unsigned int phase;
138130
139   cur_disk = (struct apple525_disk *)  flopimg_get_custom_data(image);
131   cur_disk = get_device(image);
140132
141133   old_state = cur_disk->state;
142134   cur_disk->state = new_state;
r19758r19759
160152      switch(phase)
161153      {
162154         case 1:
163            apple525_seek_disk(image, cur_disk, +1);
155            apple525_seek_disk(image, +1);
164156            break;
165157         case 3:
166            apple525_seek_disk(image, cur_disk, -1);
158            apple525_seek_disk(image, -1);
167159            break;
168160      }
169161   }
r19758r19759
172164int apple525_get_count(device_t *device)
173165{
174166   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++;
179171
180172//    printf("%d apple525 drives\n", cnt);
181173    return cnt;
r19758r19759
202194static UINT8 apple525_process_byte(device_t *img, int write_value)
203195{
204196   UINT8 read_value;
205   struct apple525_disk *disk;
197   apple525_floppy_image_device *disk;
206198   int spinfract_divisor;
207199   int spinfract_dividend;
208200   apple525_floppy_image_device *config = get_device(img);
209201   device_image_interface *image = dynamic_cast<device_image_interface *>(img);
210202
211   disk = (struct apple525_disk *)  flopimg_get_custom_data(img);
203   disk = get_device(img);
212204   spinfract_dividend = config->get_dividend();
213205   spinfract_divisor = config->get_divisor();
214206
r19758r19759
316308void apple525_floppy_image_device::device_start()
317309{
318310   legacy_floppy_image_device::device_start();
319   flopimg_alloc_custom_data(this,auto_alloc_clear(machine(),struct apple525_disk));
320311   floppy_set_type(this,FLOPPY_TYPE_APPLE);
321312}
322313
trunk/src/mess/machine/apple2.c
r19758r19759
543543   // is a card installed in this slot?
544544   if (slotdevice != NULL)
545545   {
546      if (slotdevice->take_c800())
546      if (slotdevice->take_c800() && (m_a2_cnxx_slot != slotnum))
547547      {
548//          printf("c4xx_r: taking cnxx_slot to %d\n", slotnum);
549548         m_a2_cnxx_slot = slotnum;
550549         apple2_update_memory(space.machine());
551550      }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team