src/emu/imagedev/harddriv.c
| r9936 | r9937 | |
| 1 | 1 | /********************************************************************* |
| 2 | 2 | |
| 3 | | Code to interface the MESS image code with MAME's harddisk core. |
| 3 | Code to interface the image code with harddisk core. |
| 4 | 4 | |
| 5 | 5 | We do not support diff files as it will involve some changes in |
| 6 | | the MESS image code. Additionally, the need for diff files comes |
| 6 | the image code. Additionally, the need for diff files comes |
| 7 | 7 | from MAME's need for "cannonical" hard drive images. |
| 8 | 8 | |
| 9 | 9 | Raphael Nabet 2003 |
| r9936 | r9937 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | |
| 58 | | static OPTION_GUIDE_START(mess_hd_option_guide) |
| 58 | static OPTION_GUIDE_START(hd_option_guide) |
| 59 | 59 | OPTION_INT('C', "cylinders", "Cylinders") |
| 60 | 60 | OPTION_INT('H', "heads", "Heads") |
| 61 | 61 | OPTION_INT('S', "sectors", "Sectors") |
| r9936 | r9937 | |
| 63 | 63 | OPTION_INT('K', "hunksize", "Hunk Bytes") |
| 64 | 64 | OPTION_GUIDE_END |
| 65 | 65 | |
| 66 | | static const char *mess_hd_option_spec = |
| 66 | static const char *hd_option_spec = |
| 67 | 67 | "C1-[512]-1024;H1/2/[4]/8;S1-[16]-64;L128/256/[512]/1024;K512/1024/2048/[4096]"; |
| 68 | 68 | |
| 69 | 69 | |
| r9936 | r9937 | |
| 87 | 87 | |
| 88 | 88 | /************************************* |
| 89 | 89 | * |
| 90 | | * DEVICE_IMAGE_LOAD(mess_hd) |
| 91 | | * DEVICE_IMAGE_CREATE(mess_hd) |
| 90 | * DEVICE_IMAGE_LOAD(hd) |
| 91 | * DEVICE_IMAGE_CREATE(hd) |
| 92 | 92 | * |
| 93 | 93 | * Device load and create |
| 94 | 94 | * |
| 95 | 95 | *************************************/ |
| 96 | 96 | |
| 97 | | static int internal_load_mess_hd(device_image_interface &image, const char *metadata) |
| 97 | static int internal_load_hd(device_image_interface &image, const char *metadata) |
| 98 | 98 | { |
| 99 | 99 | dev_harddisk_t *harddisk = get_safe_token( &image.device() ); |
| 100 | 100 | chd_error err = (chd_error)0; |
| r9936 | r9937 | |
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | |
| 149 | | static DEVICE_IMAGE_LOAD( mess_hd ) |
| 149 | static DEVICE_IMAGE_LOAD( hd ) |
| 150 | 150 | { |
| 151 | 151 | dev_harddisk_t *harddisk = get_safe_token( image ); |
| 152 | 152 | int our_result; |
| 153 | 153 | |
| 154 | | our_result = internal_load_mess_hd(image, NULL); |
| 154 | our_result = internal_load_hd(image, NULL); |
| 155 | 155 | |
| 156 | 156 | /* Check if there is an image_load callback defined */ |
| 157 | 157 | if ( harddisk->config && harddisk->config->device_image_load ) |
| r9936 | r9937 | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
| 166 | | static DEVICE_IMAGE_CREATE( mess_hd ) |
| 166 | static DEVICE_IMAGE_CREATE( hd ) |
| 167 | 167 | { |
| 168 | 168 | int err; |
| 169 | 169 | char metadata[256]; |
| r9936 | r9937 | |
| 184 | 184 | goto error; |
| 185 | 185 | |
| 186 | 186 | sprintf(metadata, HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize); |
| 187 | | return internal_load_mess_hd(image, metadata); |
| 187 | return internal_load_hd(image, metadata); |
| 188 | 188 | |
| 189 | 189 | error: |
| 190 | 190 | return IMAGE_INIT_FAIL; |
| r9936 | r9937 | |
| 194 | 194 | |
| 195 | 195 | /************************************* |
| 196 | 196 | * |
| 197 | | * DEVICE_IMAGE_UNLOAD(mess_hd) |
| 197 | * DEVICE_IMAGE_UNLOAD(hd) |
| 198 | 198 | * |
| 199 | 199 | * Device unload |
| 200 | 200 | * |
| 201 | 201 | *************************************/ |
| 202 | 202 | |
| 203 | | static DEVICE_IMAGE_UNLOAD( mess_hd ) |
| 203 | static DEVICE_IMAGE_UNLOAD( hd ) |
| 204 | 204 | { |
| 205 | 205 | dev_harddisk_t *harddisk = get_safe_token( image ); |
| 206 | 206 | |
| r9936 | r9937 | |
| 226 | 226 | |
| 227 | 227 | /************************************* |
| 228 | 228 | * |
| 229 | | * Get the MESS/MAME hard disk handle (from the src/harddisk.c core) |
| 230 | | * after an image has been opened with the mess_hd core |
| 229 | * Get the hard disk handle (from the src/harddisk.c core) |
| 230 | * after an image has been opened with the hd core |
| 231 | 231 | * |
| 232 | 232 | *************************************/ |
| 233 | 233 | |
| 234 | | hard_disk_file *mess_hd_get_hard_disk_file(device_t *device) |
| 234 | hard_disk_file *hd_get_hard_disk_file(device_t *device) |
| 235 | 235 | { |
| 236 | 236 | dev_harddisk_t *harddisk = get_safe_token( device ); |
| 237 | 237 | |
| r9936 | r9937 | |
| 241 | 241 | |
| 242 | 242 | /************************************* |
| 243 | 243 | * |
| 244 | | * Get the MESS/MAME CHD file (from the src/chd.c core) |
| 245 | | * after an image has been opened with the mess_hd core |
| 244 | * Get the CHD file (from the src/chd.c core) |
| 245 | * after an image has been opened with the hd core |
| 246 | 246 | * |
| 247 | 247 | *************************************/ |
| 248 | 248 | |
| 249 | | chd_file *mess_hd_get_chd_file(device_t *device) |
| 249 | chd_file *hd_get_chd_file(device_t *device) |
| 250 | 250 | { |
| 251 | 251 | chd_file *result = NULL; |
| 252 | 252 | hard_disk_file *hd_file; |
| 253 | 253 | |
| 254 | 254 | if (device) |
| 255 | 255 | { |
| 256 | | hd_file = mess_hd_get_hard_disk_file(device); |
| 256 | hd_file = hd_get_hard_disk_file(device); |
| 257 | 257 | if (hd_file) |
| 258 | 258 | result = hard_disk_get_chd(hd_file); |
| 259 | 259 | } |
| r9936 | r9937 | |
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | /*------------------------------------------------- |
| 265 | | DEVICE_START(mess_hd) |
| 265 | DEVICE_START(hd) |
| 266 | 266 | -------------------------------------------------*/ |
| 267 | 267 | |
| 268 | | static DEVICE_START(mess_hd) |
| 268 | static DEVICE_START(hd) |
| 269 | 269 | { |
| 270 | 270 | dev_harddisk_t *harddisk = get_safe_token( device ); |
| 271 | 271 | |
| r9936 | r9937 | |
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | /*------------------------------------------------- |
| 279 | | DEVICE_GET_INFO(mess_hd) |
| 279 | DEVICE_GET_INFO(hd) |
| 280 | 280 | -------------------------------------------------*/ |
| 281 | 281 | |
| 282 | | DEVICE_GET_INFO(mess_hd) |
| 282 | DEVICE_GET_INFO(hd) |
| 283 | 283 | { |
| 284 | 284 | switch( state ) |
| 285 | 285 | { |
| r9936 | r9937 | |
| 293 | 293 | case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT: info->i = 1; break; |
| 294 | 294 | |
| 295 | 295 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 296 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mess_hd); break; |
| 297 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mess_hd); break; |
| 298 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mess_hd); break; |
| 299 | | case DEVINFO_FCT_IMAGE_CREATE: info->f = (genf *) DEVICE_IMAGE_CREATE_NAME(mess_hd); break; |
| 300 | | case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *) mess_hd_option_guide; break; |
| 301 | | case DEVINFO_PTR_IMAGE_CREATE_OPTSPEC+0: info->p = (void *) mess_hd_option_spec; break; |
| 296 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(hd); break; |
| 297 | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(hd); break; |
| 298 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(hd); break; |
| 299 | case DEVINFO_FCT_IMAGE_CREATE: info->f = (genf *) DEVICE_IMAGE_CREATE_NAME(hd); break; |
| 300 | case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *) hd_option_guide; break; |
| 301 | case DEVINFO_PTR_IMAGE_CREATE_OPTSPEC+0: info->p = (void *) hd_option_spec; break; |
| 302 | 302 | |
| 303 | 303 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 304 | 304 | case DEVINFO_STR_NAME: strcpy(info->s, "Harddisk"); break; |
| r9936 | r9937 | |
| 306 | 306 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 307 | 307 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "chd,hd"); break; |
| 308 | 308 | case DEVINFO_STR_IMAGE_CREATE_OPTNAME+0: strcpy(info->s, "chd"); break; |
| 309 | | case DEVINFO_STR_IMAGE_CREATE_OPTDESC+0: strcpy(info->s, "MAME/MESS CHD Hard drive"); break; |
| 309 | case DEVINFO_STR_IMAGE_CREATE_OPTDESC+0: strcpy(info->s, "CHD Hard drive"); break; |
| 310 | 310 | case DEVINFO_STR_IMAGE_CREATE_OPTEXTS+0: strcpy(info->s, "chd,hd"); break; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
| 315 | | static DEVICE_START(mess_ide) |
| 315 | static DEVICE_START(ide) |
| 316 | 316 | { |
| 317 | 317 | /* old code from idedrive.c */ |
| 318 | 318 | #ifdef UNUSED_FUNCTION |
| r9936 | r9937 | |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
| 336 | | static DEVICE_IMAGE_LOAD(mess_ide) |
| 336 | static DEVICE_IMAGE_LOAD(ide) |
| 337 | 337 | { |
| 338 | 338 | /* old code from idedrive.c */ |
| 339 | 339 | #ifdef UNUSED_FUNCTION |
| r9936 | r9937 | |
| 351 | 351 | |
| 352 | 352 | /* configure IDE */ |
| 353 | 353 | /* FIXME IDE */ |
| 354 | | /* ide_controller_init_custom(which_bus, intf, mess_hd_get_chd_file(image)); */ |
| 354 | /* ide_controller_init_custom(which_bus, intf, hd_get_chd_file(image)); */ |
| 355 | 355 | /* ide_controller_reset(which_bus); */ |
| 356 | 356 | return IMAGE_INIT_PASS; |
| 357 | 357 | #endif |
| 358 | | return device_load_mess_hd( image ); |
| 358 | return device_load_hd( image ); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | |
| 362 | | static DEVICE_IMAGE_UNLOAD(mess_ide) |
| 362 | static DEVICE_IMAGE_UNLOAD(ide) |
| 363 | 363 | { |
| 364 | 364 | /* old code from idedrive.c */ |
| 365 | 365 | #ifdef UNUSED_FUNCTION |
| r9936 | r9937 | |
| 378 | 378 | /* ide_controller_init_custom(which_bus, intf, NULL); */ |
| 379 | 379 | /* ide_controller_reset(which_bus); */ |
| 380 | 380 | #endif |
| 381 | | device_unload_mess_hd( image ); |
| 381 | device_unload_hd( image ); |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
| 385 | | DEVICE_GET_INFO(mess_ide) |
| 385 | DEVICE_GET_INFO(ide) |
| 386 | 386 | { |
| 387 | 387 | switch( state ) |
| 388 | 388 | { |
| 389 | 389 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 390 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mess_ide); break; |
| 391 | | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mess_ide); break; |
| 392 | | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mess_ide); break; |
| 390 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ide); break; |
| 391 | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(ide); break; |
| 392 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(ide); break; |
| 393 | 393 | |
| 394 | 394 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 395 | 395 | case DEVINFO_STR_NAME: strcpy(info->s, "IDE harddisk"); break; |
| 396 | 396 | case DEVINFO_STR_IMAGE_INSTANCE_NAME: strcpy(info->s, "ideharddrive"); break; |
| 397 | 397 | case DEVINFO_STR_IMAGE_BRIEF_INSTANCE_NAME: strcpy(info->s, "idehd"); break; |
| 398 | 398 | |
| 399 | | default: DEVICE_GET_INFO_CALL( mess_hd ); break; |
| 399 | default: DEVICE_GET_INFO_CALL( hd ); break; |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | | DEFINE_LEGACY_IMAGE_DEVICE(HARDDISK, mess_hd); |
| 404 | | DEFINE_LEGACY_IMAGE_DEVICE(IDE_HARDDISK, mess_ide); |
| 403 | DEFINE_LEGACY_IMAGE_DEVICE(HARDDISK, hd); |
| 404 | DEFINE_LEGACY_IMAGE_DEVICE(IDE_HARDDISK, ide); |
src/emu/imagedev/chd_cd.c
| r9936 | r9937 | |
| 1 | 1 | /********************************************************************* |
| 2 | 2 | |
| 3 | | Code to interface the MESS image code with MAME's CHD-CD core. |
| 3 | Code to interface the image code with CHD-CD core. |
| 4 | 4 | |
| 5 | 5 | Based on harddriv.c by Raphael Nabet 2003 |
| 6 | 6 | |
| r9936 | r9937 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | | static OPTION_GUIDE_START(mess_cd_option_guide) |
| 55 | static OPTION_GUIDE_START(cd_option_guide) |
| 56 | 56 | OPTION_INT('K', "hunksize", "Hunk Bytes") |
| 57 | 57 | OPTION_GUIDE_END |
| 58 | 58 | |
| 59 | | static const char mess_cd_option_spec[] = |
| 59 | static const char cd_option_spec[] = |
| 60 | 60 | "K512/1024/2048/[4096]"; |
| 61 | 61 | |
| 62 | 62 | |
| r9936 | r9937 | |
| 112 | 112 | |
| 113 | 113 | /************************************* |
| 114 | 114 | * |
| 115 | | * Get the MESS/MAME cdrom handle (from the src/cdrom.c core) |
| 116 | | * after an image has been opened with the mess_cd core |
| 115 | * Get the cdrom handle (from the src/cdrom.c core) |
| 116 | * after an image has been opened with the cd core |
| 117 | 117 | * |
| 118 | 118 | *************************************/ |
| 119 | 119 | |
| 120 | | cdrom_file *mess_cd_get_cdrom_file(device_t *image) |
| 120 | cdrom_file *cd_get_cdrom_file(device_t *image) |
| 121 | 121 | { |
| 122 | 122 | dev_cdrom_t *cdrom = get_safe_token( image ); |
| 123 | 123 | |
| r9936 | r9937 | |
| 166 | 166 | case DEVINFO_FCT_IMAGE_LOAD: info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cdrom); break; |
| 167 | 167 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cdrom); break; |
| 168 | 168 | case DEVINFO_FCT_IMAGE_SOFTLIST_LOAD: info->f = (genf *) DEVICE_IMAGE_SOFTLIST_LOAD_NAME(cdrom); break; |
| 169 | | case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *) mess_cd_option_guide; break; |
| 170 | | case DEVINFO_PTR_IMAGE_CREATE_OPTSPEC+0: info->p = (void *) mess_cd_option_spec; break; |
| 169 | case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE: info->p = (void *) cd_option_guide; break; |
| 170 | case DEVINFO_PTR_IMAGE_CREATE_OPTSPEC+0: info->p = (void *) cd_option_spec; break; |
| 171 | 171 | |
| 172 | 172 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 173 | 173 | case DEVINFO_STR_NAME: strcpy(info->s, "Cdrom"); break; |
| r9936 | r9937 | |
| 175 | 175 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 176 | 176 | case DEVINFO_STR_IMAGE_FILE_EXTENSIONS: strcpy(info->s, "chd"); break; |
| 177 | 177 | case DEVINFO_STR_IMAGE_CREATE_OPTNAME+0: strcpy(info->s, "chdcd"); break; |
| 178 | | case DEVINFO_STR_IMAGE_CREATE_OPTDESC+0: strcpy(info->s, "MAME/MESS CHD CD-ROM drive"); break; |
| 178 | case DEVINFO_STR_IMAGE_CREATE_OPTDESC+0: strcpy(info->s, "CHD CD-ROM drive"); break; |
| 179 | 179 | case DEVINFO_STR_IMAGE_CREATE_OPTEXTS+0: strcpy(info->s, "chd"); break; |
| 180 | 180 | |
| 181 | 181 | case DEVINFO_STR_IMAGE_INTERFACE: |
src/mess/devices/ti99_hd.c
| r9936 | r9937 | |
| 72 | 72 | UINT32 lba; |
| 73 | 73 | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 74 | 74 | device_t *drive = harddisk->subdevice("drive"); |
| 75 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 75 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 76 | 76 | |
| 77 | 77 | *sector_length = 256; |
| 78 | 78 | *buf = (UINT8 *)malloc(*sector_length); |
| r9936 | r9937 | |
| 108 | 108 | UINT32 lba; |
| 109 | 109 | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 110 | 110 | device_t *drive = harddisk->subdevice("drive"); |
| 111 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 111 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 112 | 112 | |
| 113 | 113 | if (file==NULL) |
| 114 | 114 | { |
| r9936 | r9937 | |
| 191 | 191 | int crc; |
| 192 | 192 | |
| 193 | 193 | const hard_disk_info *info; |
| 194 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 194 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 195 | 195 | |
| 196 | 196 | if (file==NULL) |
| 197 | 197 | { |
| r9936 | r9937 | |
| 308 | 308 | UINT32 lba; |
| 309 | 309 | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 310 | 310 | device_t *drive = harddisk->subdevice("drive"); |
| 311 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 311 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 312 | 312 | |
| 313 | 313 | /* printf("ti99_hd write track c=%d h=%d\n", hd->current_cylinder, head); */ |
| 314 | 314 | |
| r9936 | r9937 | |
| 411 | 411 | device_t *drive; |
| 412 | 412 | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 413 | 413 | drive = harddisk->subdevice("drive"); |
| 414 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 414 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 415 | 415 | |
| 416 | 416 | if (file!=NULL) |
| 417 | 417 | status |= MFMHD_READY; |
| r9936 | r9937 | |
| 434 | 434 | device_t *drive = harddisk->subdevice("drive"); |
| 435 | 435 | mfmhd_state *hd = (mfmhd_state *)downcast<legacy_device_base *>(harddisk)->token(); |
| 436 | 436 | const hard_disk_info *info; |
| 437 | | hard_disk_file *file = mess_hd_get_hard_disk_file(drive); |
| 437 | hard_disk_file *file = hd_get_hard_disk_file(drive); |
| 438 | 438 | |
| 439 | 439 | if (file==NULL) return; |
| 440 | 440 | |
| r9936 | r9937 | |
| 464 | 464 | hard_disk_file *file; |
| 465 | 465 | int interleave = 3; |
| 466 | 466 | |
| 467 | | file = mess_hd_get_hard_disk_file(drive); |
| 467 | file = hd_get_hard_disk_file(drive); |
| 468 | 468 | if (file==NULL) |
| 469 | 469 | { |
| 470 | 470 | hd->status &= ~MFMHD_READY; |
src/mess/drivers/fmtowns.c
| r9936 | r9937 | |
| 1229 | 1229 | |
| 1230 | 1230 | for(track=1;track<99;track++) |
| 1231 | 1231 | { |
| 1232 | | if(cdrom_get_track_start(mess_cd_get_cdrom_file(cdrom),track) > lba) |
| 1232 | if(cdrom_get_track_start(cd_get_cdrom_file(cdrom),track) > lba) |
| 1233 | 1233 | break; |
| 1234 | 1234 | } |
| 1235 | 1235 | return track; |
| r9936 | r9937 | |
| 1278 | 1278 | state->towns_cd.extra_status = 0; |
| 1279 | 1279 | towns_cd_set_status(device->machine,0x22,0x00,0x00,0x00); |
| 1280 | 1280 | towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1); |
| 1281 | | cdrom_read_data(mess_cd_get_cdrom_file(state->cdrom),++state->towns_cd.lba_current,state->towns_cd.buffer,CD_TRACK_MODE1); |
| 1281 | cdrom_read_data(cd_get_cdrom_file(state->cdrom),++state->towns_cd.lba_current,state->towns_cd.buffer,CD_TRACK_MODE1); |
| 1282 | 1282 | timer_adjust_oneshot(state->towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1); |
| 1283 | 1283 | state->towns_cd.buffer_ptr = -1; |
| 1284 | 1284 | } |
| r9936 | r9937 | |
| 1308 | 1308 | state->towns_cd.lba_last = msf_to_lba(lba2); |
| 1309 | 1309 | |
| 1310 | 1310 | // first track starts at 00:02:00 - this is hardcoded in the boot procedure |
| 1311 | | track = cdrom_get_track(mess_cd_get_cdrom_file(device),state->towns_cd.lba_current); |
| 1311 | track = cdrom_get_track(cd_get_cdrom_file(device),state->towns_cd.lba_current); |
| 1312 | 1312 | if(track < 2) |
| 1313 | 1313 | { // recalculate LBA |
| 1314 | 1314 | state->towns_cd.lba_current -= 150; |
| r9936 | r9937 | |
| 1328 | 1328 | } |
| 1329 | 1329 | else |
| 1330 | 1330 | { |
| 1331 | | cdrom_read_data(mess_cd_get_cdrom_file(device),state->towns_cd.lba_current,state->towns_cd.buffer,CD_TRACK_MODE1); |
| 1331 | cdrom_read_data(cd_get_cdrom_file(device),state->towns_cd.lba_current,state->towns_cd.buffer,CD_TRACK_MODE1); |
| 1332 | 1332 | state->towns_cd.status |= 0x10; // DMA transfer begin |
| 1333 | 1333 | state->towns_cd.status &= ~0x20; // not a software transfer |
| 1334 | 1334 | // state->towns_cd.buffer_ptr = 0; |
| r9936 | r9937 | |
| 1366 | 1366 | state->towns_cd.cdda_current = msf_to_lba(lba1); |
| 1367 | 1367 | state->towns_cd.cdda_length = msf_to_lba(lba2) - state->towns_cd.cdda_current; |
| 1368 | 1368 | |
| 1369 | | cdda_set_cdrom(cdda,mess_cd_get_cdrom_file(device)); |
| 1369 | cdda_set_cdrom(cdda,cd_get_cdrom_file(device)); |
| 1370 | 1370 | cdda_start_audio(cdda,state->towns_cd.cdda_current,state->towns_cd.cdda_length); |
| 1371 | 1371 | logerror("CD: CD-DA start from LBA:%i length:%i\n",state->towns_cd.cdda_current,state->towns_cd.cdda_length); |
| 1372 | 1372 | if(state->towns_cd.command & 0x20) |
| r9936 | r9937 | |
| 1385 | 1385 | { |
| 1386 | 1386 | towns_state* state = device->machine->driver_data<towns_state>(); |
| 1387 | 1387 | |
| 1388 | | if(mess_cd_get_cdrom_file(device) == NULL) |
| 1388 | if(cd_get_cdrom_file(device) == NULL) |
| 1389 | 1389 | { // No CD in drive |
| 1390 | 1390 | if(state->towns_cd.command & 0x20) |
| 1391 | 1391 | { |
| r9936 | r9937 | |
| 1544 | 1544 | break; |
| 1545 | 1545 | case 4: // st1 = last track number (BCD) |
| 1546 | 1546 | towns_cd_set_status(space->machine,0x17, |
| 1547 | | byte_to_bcd(cdrom_get_last_track(mess_cd_get_cdrom_file(state->cdrom))), |
| 1547 | byte_to_bcd(cdrom_get_last_track(cd_get_cdrom_file(state->cdrom))), |
| 1548 | 1548 | 0x00,0x00); |
| 1549 | 1549 | state->towns_cd.extra_status++; |
| 1550 | 1550 | break; |
| 1551 | 1551 | case 5: // st1 = control/adr of track 0xaa? |
| 1552 | 1552 | towns_cd_set_status(space->machine,0x16, |
| 1553 | | cdrom_get_adr_control(mess_cd_get_cdrom_file(state->cdrom),0xaa), |
| 1553 | cdrom_get_adr_control(cd_get_cdrom_file(state->cdrom),0xaa), |
| 1554 | 1554 | 0xaa,0x00); |
| 1555 | 1555 | state->towns_cd.extra_status++; |
| 1556 | 1556 | break; |
| 1557 | 1557 | case 6: // st1/2/3 = address of track 0xaa? (BCD) |
| 1558 | | addr = cdrom_get_track_start(mess_cd_get_cdrom_file(state->cdrom),0xaa); |
| 1558 | addr = cdrom_get_track_start(cd_get_cdrom_file(state->cdrom),0xaa); |
| 1559 | 1559 | addr = lba_to_msf(addr); |
| 1560 | 1560 | towns_cd_set_status(space->machine,0x17, |
| 1561 | 1561 | (addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8,addr & 0x0000ff); |
| r9936 | r9937 | |
| 1565 | 1565 | if(state->towns_cd.extra_status & 0x01) |
| 1566 | 1566 | { |
| 1567 | 1567 | towns_cd_set_status(space->machine,0x16, |
| 1568 | | ((cdrom_get_adr_control(mess_cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-3) & 0x0f) << 4) |
| 1569 | | | ((cdrom_get_adr_control(mess_cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-3) & 0xf0) >> 4), |
| 1568 | ((cdrom_get_adr_control(cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-3) & 0x0f) << 4) |
| 1569 | | ((cdrom_get_adr_control(cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-3) & 0xf0) >> 4), |
| 1570 | 1570 | (state->towns_cd.extra_status/2)-3,0x00); |
| 1571 | 1571 | state->towns_cd.extra_status++; |
| 1572 | 1572 | } |
| 1573 | 1573 | else |
| 1574 | 1574 | { |
| 1575 | | addr = cdrom_get_track_start(mess_cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-4); |
| 1575 | addr = cdrom_get_track_start(cd_get_cdrom_file(state->cdrom),(state->towns_cd.extra_status/2)-4); |
| 1576 | 1576 | addr = lba_to_msf(addr); |
| 1577 | 1577 | towns_cd_set_status(space->machine,0x17, |
| 1578 | 1578 | (addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8,addr & 0x0000ff); |
| 1579 | | if(((state->towns_cd.extra_status/2)-3) >= cdrom_get_last_track(mess_cd_get_cdrom_file(state->cdrom))) |
| 1579 | if(((state->towns_cd.extra_status/2)-3) >= cdrom_get_last_track(cd_get_cdrom_file(state->cdrom))) |
| 1580 | 1580 | { |
| 1581 | 1581 | state->towns_cd.extra_status = 0; |
| 1582 | 1582 | } |