static void cassette_update(device_t *device) { dev_cassette_t *cassette = get_safe_token( device ); double cur_time = device->machine().time().as_double(); if (cassette_is_motor_on(device)) { double new_position = cassette->position + (cur_time - cassette->position_time); switch(cassette->state & CASSETTE_MASK_UISTATE) { case CASSETTE_RECORD: cassette_put_sample(cassette->cassette, 0, cassette->position, new_position - cassette->position, cassette->value); break; case CASSETTE_PLAY: if ( cassette->cassette ) { cassette_get_sample(cassette->cassette, 0, new_position, 0.0, &cassette->value); /* See if reached end of tape */ double length = cassette_get_length(device); if (new_position > length) { cassette->state = (cassette_state)(( cassette->state & ~CASSETTE_MASK_UISTATE ) | CASSETTE_STOPPED); new_position = length; } } break; } cassette->position = new_position; } cassette->position_time = cur_time; }
void cassette_seek(device_t *device, double time, int origin) { dev_cassette_t *cassette = get_safe_token( device ); double length; cassette_update(device); length = cassette_get_length(device); switch(origin) { case SEEK_SET: break; case SEEK_END: time += length; break; case SEEK_CUR: time += cassette_get_position(device); break; } /* clip position into legal bounds */ if (time < 0) time = 0; else if (time > length) time = length; cassette->position = time; }
/* display a small tape icon, with the current position in the tape image */ static void device_display_cassette(mess_image *image) { char buf[65]; float x, y; int n; double position, length; cassette_state uistate; /* abort if we should not be showing the image */ if (!image_exists(image)) return; if (!cassette_is_motor_on(image)) return; /* figure out where we are in the cassette */ position = cassette_get_position(image); length = cassette_get_length(image); uistate = cassette_get_state(image) & CASSETTE_MASK_UISTATE; /* choose a location on the screen */ x = 0.0f; y = image_index_in_device(image) * ui_get_line_height(); /* choose which frame of the animation we are at */ n = ((int) position / ANIMATION_FPS) % ANIMATION_FRAMES; /* character pairs 2-3, 4-5, 6-7, 8-9 form little tape cassette images */ snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]", n * 2 + 2, /* cassette icon left */ n * 2 + 3, /* cassette icon right */ (uistate == CASSETTE_PLAY) ? 16 : 14, /* play or record icon */ ((int) position / 60), ((int) position % 60), (int) position, ((int) length / 60), ((int) length % 60), (int) length); /* draw the cassette */ ui_draw_text_box(buf, JUSTIFY_LEFT, x, y, UI_FILLCOLOR); }
void cassette_seek(mess_image *cassette, double time, int origin) { struct mess_cassetteimg *tag; cassette_update(cassette); switch(origin) { case SEEK_SET: break; case SEEK_END: time += cassette_get_length(cassette); break; case SEEK_CUR: time += cassette_get_position(cassette); break; } /* clip position into legal bounds */ tag = get_cassimg(cassette); tag->position = time; }
/* display a small tape icon, with the current position in the tape image */ static DEVICE_IMAGE_DISPLAY(cassette) { device_t *device = &image.device(); char buf[65]; float x, y; int n; double position, length; cassette_state uistate; device_t *dev; static const UINT8 shapes[8] = { 0x2d, 0x5c, 0x7c, 0x2f, 0x2d, 0x20, 0x20, 0x20 }; /* abort if we should not be showing the image */ if (!image.exists()) return; if (!cassette_is_motor_on(device)) return; /* figure out where we are in the cassette */ position = cassette_get_position(device); length = cassette_get_length(device); uistate = (cassette_state)(cassette_get_state(device) & CASSETTE_MASK_UISTATE); /* choose a location on the screen */ x = 0.2f; y = 0.5f; dev = device->machine().m_devicelist.first(CASSETTE ); while ( dev && strcmp( dev->tag(), device->tag() ) ) { y += 1; dev = dev->typenext(); } y *= ui_get_line_height(device->machine()) + 2.0f * UI_BOX_TB_BORDER; /* choose which frame of the animation we are at */ n = ((int) position / ANIMATION_FPS) % ANIMATION_FRAMES; /* Since you can have anything in a BDF file, we will use crude ascii characters instead */ snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]", #if 0 /* THE ANIMATION HASN'T WORKED SINCE 0.114 - LEFT HERE FOR REFERENCE */ /* NEVER SEEN THE PLAY / RECORD ICONS */ /* character pairs 2-3, 4-5, 6-7, 8-9 form little tape cassette images */ n * 2 + 2, /* cassette icon left */ n * 2 + 3, /* cassette icon right */ (uistate == CASSETTE_PLAY) ? 16 : 14, /* play or record icon */ #else shapes[n], /* cassette icon left */ shapes[n|4], /* cassette icon right */ (uistate == CASSETTE_PLAY) ? 0x50 : 0x52, /* play (P) or record (R) */ #endif ((int) position / 60), ((int) position % 60), (int) position, ((int) length / 60), ((int) length % 60), (int) length); /* draw the cassette */ ui_draw_text_box(&device->machine().render().ui_container(), buf, JUSTIFY_LEFT, x, y, UI_BACKGROUND_COLOR); }