src/mess/image.c
| r3961 | r3962 | |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | |
| 151 | | /*------------------------------------------------- |
| 152 | | device_get_info_str_offline - return an integer |
| 153 | | state value from an allocated device; can be |
| 154 | | called offline |
| 155 | | -------------------------------------------------*/ |
| 156 | | |
| 157 | | INLINE const char *device_get_info_string_offline(const device_config *device, UINT32 state) |
| 158 | | { |
| 159 | | deviceinfo info; |
| 160 | | |
| 161 | | assert(device != NULL); |
| 162 | | assert(device->type != NULL); |
| 163 | | assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); |
| 164 | | |
| 165 | | /* retrieve the value */ |
| 166 | | info.s = 0; |
| 167 | | (*device->type)(device, state, &info); |
| 168 | | return info.s; |
| 169 | | } |
| 170 | | |
| 171 | | |
| 172 | | |
| 173 | 151 | /*************************************************************************** |
| 174 | 152 | CORE IMPLEMENTATION |
| 175 | 153 | ***************************************************************************/ |
| r3961 | r3962 | |
| 402 | 380 | if (name == NULL) |
| 403 | 381 | { |
| 404 | 382 | /* next try DEVINFO_STR_NAME */ |
| 405 | | name = device_get_info_string_offline(device, DEVINFO_STR_NAME); |
| 383 | name = device_get_info_string(device, DEVINFO_STR_NAME); |
| 406 | 384 | } |
| 407 | 385 | |
| 408 | 386 | /* make sure that the name is put into the buffer */ |
| r3961 | r3962 | |
| 428 | 406 | buffer_len--; |
| 429 | 407 | |
| 430 | 408 | /* copy the string */ |
| 431 | | file_extensions = device_get_info_string_offline(device, DEVINFO_STR_IMAGE_FILE_EXTENSIONS); |
| 409 | file_extensions = device_get_info_string(device, DEVINFO_STR_IMAGE_FILE_EXTENSIONS); |
| 432 | 410 | snprintf(buffer, buffer_len, "%s", (file_extensions != NULL) ? file_extensions : ""); |
| 433 | 411 | |
| 434 | 412 | /* convert the comma delimited list to a NUL delimited list */ |
| r3961 | r3962 | |
| 452 | 430 | int count, index; |
| 453 | 431 | |
| 454 | 432 | /* retrieve info about the device instance */ |
| 455 | | result = device_get_info_string_offline(device, state); |
| 433 | result = device_get_info_string(device, state); |
| 456 | 434 | if (result != NULL) |
| 457 | 435 | { |
| 458 | 436 | /* we got info directly */ |
src/mess/device.c
| r3961 | r3962 | |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | /*------------------------------------------------- |
| 258 | safe_strcpy - hack |
| 259 | -------------------------------------------------*/ |
| 260 | |
| 261 | static void safe_strcpy(char *dst, const char *src) |
| 262 | { |
| 263 | strcpy(dst, src ? src : ""); |
| 264 | } |
| 265 | |
| 266 | |
| 267 | |
| 268 | /*------------------------------------------------- |
| 258 | 269 | DEVICE_GET_INFO(mess_device) - device get info |
| 259 | 270 | callback |
| 260 | 271 | -------------------------------------------------*/ |
| r3961 | r3962 | |
| 299 | 310 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 300 | 311 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 301 | 312 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 302 | | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS)); break; |
| 303 | | case DEVINFO_STR_IMAGE_INSTANCE_NAME: strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_NAME + mess_device->io_device.index_in_device)); break; |
| 304 | | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_SHORT_NAME + mess_device->io_device.index_in_device)); break; |
| 313 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: safe_strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_FILE_EXTENSIONS)); break; |
| 314 | case DEVINFO_STR_IMAGE_INSTANCE_NAME: safe_strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_NAME + mess_device->io_device.index_in_device)); break; |
| 315 | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: safe_strcpy(info->s, mess_device_get_info_string(&mess_device->io_device.devclass, MESS_DEVINFO_STR_SHORT_NAME + mess_device->io_device.index_in_device)); break; |
| 305 | 316 | |
| 306 | 317 | default: |
| 307 | 318 | if ((state >= DEVINFO_PTR_IMAGE_CREATE_OPTSPEC) && (state < DEVINFO_PTR_IMAGE_CREATE_OPTSPEC + DEVINFO_CREATE_OPTMAX)) |
| 308 | 319 | info->p = mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_PTR_IMAGE_CREATE_OPTSPEC + MESS_DEVINFO_PTR_CREATE_OPTSPEC); |
| 309 | 320 | else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTNAME) && (state < DEVINFO_STR_IMAGE_CREATE_OPTNAME + DEVINFO_CREATE_OPTMAX)) |
| 310 | | info->s = mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTNAME + MESS_DEVINFO_STR_CREATE_OPTNAME); |
| 321 | safe_strcpy(info->s, mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTNAME + MESS_DEVINFO_STR_CREATE_OPTNAME)); |
| 311 | 322 | else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTDESC) && (state < DEVINFO_STR_IMAGE_CREATE_OPTDESC + DEVINFO_CREATE_OPTMAX)) |
| 312 | | info->s = mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTDESC + MESS_DEVINFO_STR_CREATE_OPTDESC); |
| 323 | safe_strcpy(info->s, mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTDESC + MESS_DEVINFO_STR_CREATE_OPTDESC)); |
| 313 | 324 | else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTEXTS) && (state < DEVINFO_STR_IMAGE_CREATE_OPTEXTS + DEVINFO_CREATE_OPTMAX)) |
| 314 | | info->s = mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTEXTS + MESS_DEVINFO_STR_CREATE_OPTEXTS); |
| 325 | safe_strcpy(info->s, mess_device_get_info_ptr(&mess_device->io_device.devclass, state - DEVINFO_STR_IMAGE_CREATE_OPTEXTS + MESS_DEVINFO_STR_CREATE_OPTEXTS)); |
| 315 | 326 | break; |
| 316 | 327 | } |
| 317 | 328 | } |
src/mess/machine/smc92x4.c
| r3961 | r3962 | |
| 131 | 131 | */ |
| 132 | 132 | static int floppy_read_id(int which, int disk_unit, int head) |
| 133 | 133 | { |
| 134 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 134 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 135 | 135 | UINT8 revolution_count; |
| 136 | 136 | chrn_id id; |
| 137 | 137 | |
| r3961 | r3962 | |
| 163 | 163 | */ |
| 164 | 164 | static int floppy_find_sector(int which, int disk_unit, int cylinder, int head, int check_secnum, int sector, int *sector_data_id, int *sector_len) |
| 165 | 165 | { |
| 166 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 166 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 167 | 167 | UINT8 revolution_count; |
| 168 | 168 | chrn_id id; |
| 169 | 169 | |
| r3961 | r3962 | |
| 207 | 207 | int sector_data_id, sector_len; |
| 208 | 208 | UINT8 buf[MAX_SECTOR_LEN]; |
| 209 | 209 | int i; |
| 210 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 210 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 211 | 211 | |
| 212 | 212 | if (! floppy_find_sector(which, disk_unit, cylinder, head, check_secnum, sector, & sector_data_id, & sector_len)) |
| 213 | 213 | { |
| r3961 | r3962 | |
| 229 | 229 | int sector_data_id, sector_len; |
| 230 | 230 | UINT8 buf[MAX_SECTOR_LEN]; |
| 231 | 231 | int i; |
| 232 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 232 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 233 | 233 | |
| 234 | 234 | if (! floppy_find_sector(which, disk_unit, cylinder, head, check_secnum, sector, & sector_data_id, & sector_len)) |
| 235 | 235 | { |
| r3961 | r3962 | |
| 248 | 248 | |
| 249 | 249 | static void floppy_step(int which, int disk_unit, int direction) |
| 250 | 250 | { |
| 251 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 251 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 252 | 252 | floppy_drive_seek(disk_img, direction); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | static UINT8 floppy_get_disk_status(int which, int disk_unit) |
| 256 | 256 | { |
| 257 | | const device_config *disk_img = image_from_devtype_and_index(IO_FLOPPY, disk_unit); |
| 257 | const device_config *disk_img = image_from_devtype_and_index(machine, IO_FLOPPY, disk_unit); |
| 258 | 258 | int status = floppy_status(disk_img, -1); |
| 259 | 259 | int reply; |
| 260 | 260 | |
src/mess/drivers/sord.c
| r3961 | r3962 | |
| 123 | 123 | |
| 124 | 124 | LOG(("fd5 drive state w: %02x\n",state)); |
| 125 | 125 | |
| 126 | | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), state); |
| 127 | | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), state); |
| 128 | | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1,1); |
| 129 | | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1,1); |
| 126 | floppy_drive_set_motor_state(image_from_devtype_and_index(machine, IO_FLOPPY, 0), state); |
| 127 | floppy_drive_set_motor_state(image_from_devtype_and_index(machine, IO_FLOPPY, 0), state); |
| 128 | floppy_drive_set_ready_state(image_from_devtype_and_index(machine, IO_FLOPPY, 1), 1,1); |
| 129 | floppy_drive_set_ready_state(image_from_devtype_and_index(machine, IO_FLOPPY, 1), 1,1); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | static WRITE8_HANDLER(fd5_tc_w) |
| r3961 | r3962 | |
| 174 | 174 | |
| 175 | 175 | static MACHINE_RESET( sord_m5_fd5 ) |
| 176 | 176 | { |
| 177 | | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 178 | | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 177 | floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 178 | floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 179 | 179 | MACHINE_RESET_CALL(sord_m5); |
| 180 | 180 | ppi8255_set_port_c((device_config*)device_list_find_by_tag( machine->config->devicelist, PPI8255, "ppi8255" ), 0x50); |
| 181 | 181 | } |