static int device_load_cassette(mess_image *image) { casserr_t err; int cassette_flags; struct mess_cassetteimg *tag; const struct IODevice *dev; const struct CassetteFormat **formats; const struct CassetteOptions *create_opts; const char *extension; int is_writable; tag = get_cassimg(image); /* figure out the cassette format */ dev = device_find(Machine->devices, IO_CASSETTE); formats = device_get_info_ptr(&dev->devclass, DEVINFO_PTR_CASSETTE_FORMATS); if (image_has_been_created(image)) { /* creating an image */ create_opts = (const struct CassetteOptions *) device_get_info_ptr(&dev->devclass, DEVINFO_PTR_CASSETTE_OPTIONS); err = cassette_create(image, &mess_ioprocs, &wavfile_format, create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &tag->cassette); if (err) goto error; } else { /* opening an image */ do { is_writable = image_is_writable(image); cassette_flags = is_writable ? (CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT) : CASSETTE_FLAG_READONLY; extension = image_filetype(image); err = cassette_open_choices(image, &mess_ioprocs, extension, formats, cassette_flags, &tag->cassette); /* this is kind of a hack */ if (err && is_writable) image_make_readonly(image); } while(err && is_writable); if (err) goto error; } /* set to default state, but only change the UI state */ cassette_change_state(image, get_default_state(dev), CASSETTE_MASK_UISTATE); /* reset the position */ tag->position = 0.0; tag->position_time = timer_get_time(); return INIT_PASS; error: return INIT_FAIL; }
static DEVICE_IMAGE_LOAD( cassette ) { device_t *device = &image.device(); dev_cassette_t *cassette = get_safe_token( device ); casserr_t err; int cassette_flags; const struct CassetteFormat * const *formats; const struct CassetteOptions *create_opts; const char *extension; int is_writable; /* figure out the cassette format */ formats = cassette->config->formats; if (image.has_been_created()) { /* creating an image */ create_opts = cassette->config->create_opts; err = cassette_create((void *) &image, &image_ioprocs, &wavfile_format, create_opts, CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT, &cassette->cassette); if (err) goto error; } else { /* opening an image */ do { is_writable = image.is_writable(); cassette_flags = is_writable ? (CASSETTE_FLAG_READWRITE|CASSETTE_FLAG_SAVEONEXIT) : CASSETTE_FLAG_READONLY; extension = image.filetype(); err = cassette_open_choices((void *) &image, &image_ioprocs, extension, formats, cassette_flags, &cassette->cassette); /* this is kind of a hack */ if (err && is_writable) image.make_readonly(); } while(err && is_writable); if (err) goto error; } /* set to default state, but only change the UI state */ cassette_change_state(device, cassette->config->default_state, CASSETTE_MASK_UISTATE); /* reset the position */ cassette->position = 0.0; cassette->position_time = device->machine().time().as_double(); return IMAGE_INIT_PASS; error: return IMAGE_INIT_FAIL; }
static DEVICE_IMAGE_UNLOAD( cassette ) { device_t *device = &image.device(); dev_cassette_t *cassette = get_safe_token( device ); /* if we are recording, write the value to the image */ if ((cassette->state & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD) cassette_update(device); /* close out the cassette */ cassette_close(cassette->cassette); cassette->cassette = NULL; /* set to default state, but only change the UI state */ cassette_change_state(device, CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); }
static void device_unload_cassette(mess_image *image) { struct mess_cassetteimg *tag; tag = get_cassimg(image); /* if we are recording, write the value to the image */ if ((tag->state & CASSETTE_MASK_UISTATE) == CASSETTE_RECORD) cassette_update(image); /* close out the cassette */ cassette_close(tag->cassette); tag->cassette = NULL; /* set to default state, but only change the UI state */ cassette_change_state(image, CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); }
void cassette_set_state(mess_image *cassette, cassette_state state) { cassette_change_state(cassette, state, ~0); }
void cassette_set_state(device_t *device, cassette_state state) { cassette_change_state(device, state, (cassette_state)(~0)); }
static WRITE8_HANDLER(exidy_fe_port_w) { int changed_bits; exidy_keyboard_line = data & 0x0f; changed_bits = exidy_fe^data; /* either cassette motor state changed */ if ((changed_bits & EXIDY_CASSETTE_MOTOR_MASK)!=0) { /* cassette 1 motor */ cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0), (data & 0x10) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); /* cassette 2 motor */ cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 1), (data & 0x20) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); if ((data & EXIDY_CASSETTE_MOTOR_MASK)==0) { /* both are now off */ /* stop timer */ timer_adjust(cassette_timer, 0, 0, 0); } else { /* if both motors were off previously, at least one motor has been switched on */ if ((exidy_fe & EXIDY_CASSETTE_MOTOR_MASK)==0) { cassette_clock_counter = 0; cassette_clock_state = 0; /* start timer */ timer_adjust(cassette_timer, 0, 0, TIME_IN_HZ(4800)); } } } if (data & 0x080) { /* connect to serial device */ } else { /* connect to tape */ hd6402_connect(&cassette_serial_connection); } if ((changed_bits & (1<<6))!=0) { int baud_rate; baud_rate = 300; if (data & (1<<6)) { baud_rate = 1200; } timer_adjust(serial_timer, 0, 0, TIME_IN_HZ(baud_rate)); } exidy_fe = data; }