diff options
author | 2012-12-23 21:16:02 +0000 | |
---|---|---|
committer | 2012-12-23 21:16:02 +0000 | |
commit | 7d8aeba37536c0d51a79c712d298bfb97abf4951 (patch) | |
tree | 96eca83c515fcb1005136d3632a77127d0a776ca /src | |
parent | 216abe665fefe992060c7b41616754a095472665 (diff) |
[APPLE2] Floppy drive cleanups/modernization (nw)
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/imagedev/flopdrv.c | 15 | ||||
-rw-r--r-- | src/emu/imagedev/flopdrv.h | 3 | ||||
-rw-r--r-- | src/mess/devices/appldriv.c | 45 | ||||
-rw-r--r-- | src/mess/devices/appldriv.h | 12 | ||||
-rw-r--r-- | src/mess/machine/apple2.c | 3 |
5 files changed, 31 insertions, 47 deletions
diff --git a/src/emu/imagedev/flopdrv.c b/src/emu/imagedev/flopdrv.c index a9d7679f8d5..b6933801034 100644 --- a/src/emu/imagedev/flopdrv.c +++ b/src/emu/imagedev/flopdrv.c @@ -85,7 +85,6 @@ struct floppy_drive int track; void (*load_proc)(device_image_interface &image); void (*unload_proc)(device_image_interface &image); - void *custom_data; int floppy_drive_type; }; @@ -127,18 +126,6 @@ floppy_image_legacy *flopimg_get_image(device_t *image) return get_safe_token(image)->floppy; } -void *flopimg_get_custom_data(device_t *image) -{ - floppy_drive *flopimg = get_safe_token( image ); - return flopimg->custom_data; -} - -void flopimg_alloc_custom_data(device_t *image,void *custom) -{ - floppy_drive *flopimg = get_safe_token( image ); - flopimg->custom_data = custom; -} - static int flopimg_get_sectors_per_track(device_t *image, int side) { floperr_t err; @@ -224,8 +211,6 @@ static void floppy_drive_init(device_t *img) pDrive->controller = NULL; - pDrive->custom_data = NULL; - pDrive->floppy_drive_type = FLOPPY_TYPE_REGULAR; } diff --git a/src/emu/imagedev/flopdrv.h b/src/emu/imagedev/flopdrv.h index a56d09e9a69..c7a1cf28762 100644 --- a/src/emu/imagedev/flopdrv.h +++ b/src/emu/imagedev/flopdrv.h @@ -145,9 +145,6 @@ int floppy_get_count(running_machine &machine); int floppy_get_drive(device_t *image); int floppy_get_drive_by_type(device_t *image,int ftype); -void *flopimg_get_custom_data(device_t *image); -void flopimg_alloc_custom_data(device_t *image,void *custom); - void floppy_drive_set_geometry(device_t *img, floppy_type_t type); /* drive select lines */ diff --git a/src/mess/devices/appldriv.c b/src/mess/devices/appldriv.c index 85e7f72a1a6..355e831ad24 100644 --- a/src/mess/devices/appldriv.c +++ b/src/mess/devices/appldriv.c @@ -17,17 +17,6 @@ #define PARENT_FLOPPY_2 "^floppy2" #define PARENT_FLOPPY_3 "^floppy3" -struct apple525_disk -{ - unsigned int state : 4; /* bits 0-3 are the phase */ - unsigned int tween_tracks : 1; - unsigned int track_loaded : 1; - unsigned int track_dirty : 1; - int position; - int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */ - UINT8 track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT]; -}; - INLINE apple525_floppy_image_device *get_device(device_t *device) { assert(device != NULL); @@ -75,9 +64,9 @@ void apple525_set_enable_lines(device_t *device,int enable_mask) static void apple525_load_current_track(device_t *image) { int len; - struct apple525_disk *disk; + apple525_floppy_image_device *disk; - disk = (struct apple525_disk *) flopimg_get_custom_data(image); + disk = get_device(image); len = sizeof(disk->track_data); floppy_drive_read_track_data_info_buffer(image, 0, disk->track_data, &len); @@ -88,9 +77,9 @@ static void apple525_load_current_track(device_t *image) static void apple525_save_current_track(device_t *image, int unload) { int len; - struct apple525_disk *disk; + apple525_floppy_image_device *disk; - disk = (struct apple525_disk *) flopimg_get_custom_data(image); + disk = get_device(image); if (disk->track_dirty) { @@ -102,10 +91,13 @@ static void apple525_save_current_track(device_t *image, int unload) disk->track_loaded = 0; } -static void apple525_seek_disk(device_t *img, struct apple525_disk *disk, signed int step) +static void apple525_seek_disk(device_t *img, signed int step) { int track; int pseudo_track; + apple525_floppy_image_device *disk; + + disk = get_device(img); apple525_save_current_track(img, FALSE); @@ -132,11 +124,11 @@ static void apple525_seek_disk(device_t *img, struct apple525_disk *disk, signed static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_state) { - struct apple525_disk *cur_disk; + apple525_floppy_image_device *cur_disk; UINT8 old_state; unsigned int phase; - cur_disk = (struct apple525_disk *) flopimg_get_custom_data(image); + cur_disk = get_device(image); old_state = cur_disk->state; cur_disk->state = new_state; @@ -160,10 +152,10 @@ static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_ switch(phase) { case 1: - apple525_seek_disk(image, cur_disk, +1); + apple525_seek_disk(image, +1); break; case 3: - apple525_seek_disk(image, cur_disk, -1); + apple525_seek_disk(image, -1); break; } } @@ -172,10 +164,10 @@ static void apple525_disk_set_lines(device_t *device,device_t *image, UINT8 new_ int apple525_get_count(device_t *device) { int cnt = 0; - if (device->subdevice("^"FLOPPY_0)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_0))!=NULL) cnt++; - if (device->subdevice("^"FLOPPY_1)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_1))!=NULL) cnt++; - if (device->subdevice("^"FLOPPY_2)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_2))!=NULL) cnt++; - if (device->subdevice("^"FLOPPY_3)!=NULL && flopimg_get_custom_data(device->subdevice(PARENT_FLOPPY_3))!=NULL) cnt++; + if (device->subdevice("^"FLOPPY_0)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_0))!=NULL) cnt++; + if (device->subdevice("^"FLOPPY_1)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_1))!=NULL) cnt++; + if (device->subdevice("^"FLOPPY_2)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_2))!=NULL) cnt++; + if (device->subdevice("^"FLOPPY_3)!=NULL && get_device(device->subdevice(PARENT_FLOPPY_3))!=NULL) cnt++; // printf("%d apple525 drives\n", cnt); return cnt; @@ -202,13 +194,13 @@ void apple525_set_lines(device_t *device, UINT8 lines) static UINT8 apple525_process_byte(device_t *img, int write_value) { UINT8 read_value; - struct apple525_disk *disk; + apple525_floppy_image_device *disk; int spinfract_divisor; int spinfract_dividend; apple525_floppy_image_device *config = get_device(img); device_image_interface *image = dynamic_cast<device_image_interface *>(img); - disk = (struct apple525_disk *) flopimg_get_custom_data(img); + disk = get_device(img); spinfract_dividend = config->get_dividend(); spinfract_divisor = config->get_divisor(); @@ -316,7 +308,6 @@ apple525_floppy_image_device::apple525_floppy_image_device(const machine_config void apple525_floppy_image_device::device_start() { legacy_floppy_image_device::device_start(); - flopimg_alloc_custom_data(this,auto_alloc_clear(machine(),struct apple525_disk)); floppy_set_type(this,FLOPPY_TYPE_APPLE); } diff --git a/src/mess/devices/appldriv.h b/src/mess/devices/appldriv.h index 8212ac256b1..9ca321913b6 100644 --- a/src/mess/devices/appldriv.h +++ b/src/mess/devices/appldriv.h @@ -11,6 +11,7 @@ #include "emu.h" #include "imagedev/flopdrv.h" +#include "formats/ap2_dsk.h" void apple525_set_lines(device_t *device,UINT8 lines); void apple525_set_enable_lines(device_t *device,int enable_mask); @@ -32,8 +33,19 @@ public: int get_dividend() { return m_dividend; } int get_divisor() { return m_divisor; } + + // these elements should be private, but are not yet + unsigned int state : 4; /* bits 0-3 are the phase */ + unsigned int tween_tracks : 1; + unsigned int track_loaded : 1; + unsigned int track_dirty : 1; + int position; + int spin_count; /* simulate drive spin to fool RWTS test at $BD34 */ + UINT8 track_data[APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT]; + protected: virtual void device_start(); + private: int m_dividend; int m_divisor; diff --git a/src/mess/machine/apple2.c b/src/mess/machine/apple2.c index ae3b6d5c30d..0825a1dfc4a 100644 --- a/src/mess/machine/apple2.c +++ b/src/mess/machine/apple2.c @@ -543,9 +543,8 @@ READ8_MEMBER(apple2_state::apple2_c4xx_r ) // is a card installed in this slot? if (slotdevice != NULL) { - if (slotdevice->take_c800()) + if (slotdevice->take_c800() && (m_a2_cnxx_slot != slotnum)) { -// printf("c4xx_r: taking cnxx_slot to %d\n", slotnum); m_a2_cnxx_slot = slotnum; apple2_update_memory(space.machine()); } |