src/mess/osd/windows/tapedlg.c
| r3177 | r3178 | |
| 1 | | //============================================================ |
| 2 | | // |
| 3 | | // tapedlg.c - Win32 MESS tape control |
| 4 | | // |
| 5 | | //============================================================ |
| 6 | | |
| 7 | | // standard windows headers |
| 8 | | #define WIN32_LEAN_AND_MEAN |
| 9 | | #include <windows.h> |
| 10 | | #include <commctrl.h> |
| 11 | | |
| 12 | | // MAME/MESS headers |
| 13 | | #include "mame.h" |
| 14 | | #include "tapedlg.h" |
| 15 | | #include "mess.h" |
| 16 | | #include "messres.h" |
| 17 | | #include "window.h" |
| 18 | | #include "winutf8.h" |
| 19 | | #include "uimess.h" |
| 20 | | #include "device.h" |
| 21 | | |
| 22 | | |
| 23 | | |
| 24 | | //============================================================ |
| 25 | | // STRUCTURES |
| 26 | | //============================================================ |
| 27 | | |
| 28 | | struct tape_dialog |
| 29 | | { |
| 30 | | HWND window; |
| 31 | | HWND slider; |
| 32 | | HWND caption; |
| 33 | | HWND status; |
| 34 | | UINT_PTR timer; |
| 35 | | }; |
| 36 | | |
| 37 | | #if HAS_WAVE |
| 38 | | //============================================================ |
| 39 | | // LOCAL VARIABLES |
| 40 | | //============================================================ |
| 41 | | |
| 42 | | static struct tape_dialog tape_dialogs[MAX_DEV_INSTANCES]; |
| 43 | | |
| 44 | | //============================================================ |
| 45 | | // get_tapedialog |
| 46 | | //============================================================ |
| 47 | | |
| 48 | | static struct tape_dialog *get_tapedialog(HWND dialog) |
| 49 | | { |
| 50 | | LONG_PTR lp = GetWindowLongPtr(dialog, GWLP_USERDATA); |
| 51 | | return (struct tape_dialog *) lp; |
| 52 | | } |
| 53 | | |
| 54 | | //============================================================ |
| 55 | | // tapedialog_timerproc |
| 56 | | //============================================================ |
| 57 | | |
| 58 | | static void CALLBACK tapedialog_timerproc(HWND dialog, UINT msg, UINT_PTR idevent, DWORD time) |
| 59 | | { |
| 60 | | struct tape_dialog *dlg; |
| 61 | | int id; |
| 62 | | int curpos, endpos; |
| 63 | | astring *tapestatus = astring_alloc(); |
| 64 | | const device_config *img; |
| 65 | | |
| 66 | | dlg = get_tapedialog(dialog); |
| 67 | | id = dlg - tape_dialogs; |
| 68 | | |
| 69 | | img = image_from_devtype_and_index(IO_CASSETTE, id); |
| 70 | | |
| 71 | | tapecontrol_gettime(tapestatus, img, &curpos, &endpos); |
| 72 | | |
| 73 | | SendMessage(dlg->slider, TBM_SETRANGEMIN, FALSE, 0); |
| 74 | | SendMessage(dlg->slider, TBM_SETRANGEMAX, FALSE, endpos); |
| 75 | | SendMessage(dlg->slider, TBM_SETPOS, TRUE, curpos); |
| 76 | | |
| 77 | | win_set_window_text_utf8(dlg->status, astring_c(tapestatus)); |
| 78 | | |
| 79 | | astring_free(tapestatus); |
| 80 | | } |
| 81 | | |
| 82 | | //============================================================ |
| 83 | | // tapedialog_dlgproc |
| 84 | | //============================================================ |
| 85 | | |
| 86 | | static INT_PTR CALLBACK tapedialog_dlgproc(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam) |
| 87 | | { |
| 88 | | INT_PTR result = 0; |
| 89 | | struct tape_dialog *dlg; |
| 90 | | |
| 91 | | switch(msg) { |
| 92 | | case WM_INITDIALOG: |
| 93 | | dlg = &tape_dialogs[lparam]; |
| 94 | | SetWindowLongPtr(dialog, GWLP_USERDATA, (LONG_PTR) dlg); |
| 95 | | dlg->window = dialog; |
| 96 | | dlg->timer = SetTimer(dialog, (UINT_PTR) 0, 100, tapedialog_timerproc); |
| 97 | | dlg->slider = GetDlgItem(dialog, IDC_SLIDER); |
| 98 | | dlg->caption = GetDlgItem(dialog, IDC_CAPTION); |
| 99 | | dlg->status = GetDlgItem(dialog, IDC_STATUS); |
| 100 | | ShowWindow(dialog, SW_SHOW); |
| 101 | | result = 1; |
| 102 | | break; |
| 103 | | |
| 104 | | case WM_CLOSE: |
| 105 | | KillTimer(dialog, (UINT_PTR) 0); |
| 106 | | dlg = get_tapedialog(dialog); |
| 107 | | memset(dlg, 0, sizeof(*dlg)); |
| 108 | | break; |
| 109 | | } |
| 110 | | return result; |
| 111 | | } |
| 112 | | |
| 113 | | //============================================================ |
| 114 | | // tapedialog_init |
| 115 | | //============================================================ |
| 116 | | |
| 117 | | void tapedialog_init(void) |
| 118 | | { |
| 119 | | memset(tape_dialogs, 0, sizeof(tape_dialogs)); |
| 120 | | } |
| 121 | | |
| 122 | | //============================================================ |
| 123 | | // is_windowed |
| 124 | | //============================================================ |
| 125 | | |
| 126 | | static int is_windowed(void) { return video_config.windowed; } |
| 127 | | |
| 128 | | |
| 129 | | |
| 130 | | //============================================================ |
| 131 | | // tapedialog_show |
| 132 | | //============================================================ |
| 133 | | |
| 134 | | void tapedialog_show(HWND wnd, int id) |
| 135 | | { |
| 136 | | extern HMODULE win_resource_module(void); |
| 137 | | |
| 138 | | if (!is_windowed()) |
| 139 | | winwindow_toggle_full_screen(); |
| 140 | | |
| 141 | | if (tape_dialogs[id].window) |
| 142 | | { |
| 143 | | SetWindowPos(tape_dialogs[id].window, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); |
| 144 | | } |
| 145 | | else |
| 146 | | { |
| 147 | | CreateDialogParam(win_resource_module(), MAKEINTRESOURCE(IDD_TAPEDIALOG), |
| 148 | | wnd, tapedialog_dlgproc, id); |
| 149 | | } |
| 150 | | } |
| 151 | | #endif /* HAS_WAVE */ |
| 152 | | |
src/mess/osd/windows/menu.c
| r3177 | r3178 | |
| 25 | 25 | #include "mslegacy.h" |
| 26 | 26 | #include "strconv.h" |
| 27 | 27 | #include "utils.h" |
| 28 | | #include "tapedlg.h" |
| 29 | 28 | #include "artworkx.h" |
| 30 | 29 | #include "debug/debugcpu.h" |
| 31 | 30 | #include "inptport.h" |
| r3177 | r3178 | |
| 61 | 60 | |
| 62 | 61 | #define MAX_JOYSTICKS (8) |
| 63 | 62 | |
| 64 | | #define USE_TAPEDLG 0 |
| 65 | | |
| 66 | 63 | enum |
| 67 | 64 | { |
| 68 | 65 | DEVOPTION_OPEN, |
| r3177 | r3178 | |
| 72 | 69 | DEVOPTION_CASSETTE_STOPPAUSE, |
| 73 | 70 | DEVOPTION_CASSETTE_PLAY, |
| 74 | 71 | DEVOPTION_CASSETTE_RECORD, |
| 75 | | #if USE_TAPEDLG |
| 76 | | DEVOPTION_CASSETTE_DIALOG, |
| 77 | | #else |
| 78 | 72 | DEVOPTION_CASSETTE_REWIND, |
| 79 | 73 | DEVOPTION_CASSETTE_FASTFORWARD, |
| 80 | | #endif |
| 81 | 74 | DEVOPTION_MAX |
| 82 | 75 | }; |
| 83 | 76 | |
| r3177 | r3178 | |
| 1404 | 1397 | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_STOPPED) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_STOPPAUSE, UI_pauseorstop); |
| 1405 | 1398 | append_menu_uistring(sub_menu, flags_for_exists | ((state == CASSETTE_PLAY) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_PLAY, UI_play); |
| 1406 | 1399 | append_menu_uistring(sub_menu, flags_for_writing | ((state == CASSETTE_RECORD) ? MF_CHECKED : 0), new_item + DEVOPTION_CASSETTE_RECORD, UI_record); |
| 1407 | | #if USE_TAPEDLG |
| 1408 | | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_DIALOG, UI_tapecontrol); |
| 1409 | | #else |
| 1410 | 1400 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_REWIND, UI_rewind); |
| 1411 | 1401 | append_menu_uistring(sub_menu, flags_for_exists, new_item + DEVOPTION_CASSETTE_FASTFORWARD, UI_fastforward); |
| 1412 | | #endif |
| 1413 | 1402 | } |
| 1414 | 1403 | #endif /* HAS_WAVE */ |
| 1415 | 1404 | s = image_exists(img) ? image_filename(img) : ui_getstring(UI_emptyslot); |
| r3177 | r3178 | |
| 1534 | 1523 | cassette_change_state(img, CASSETTE_RECORD, CASSETTE_MASK_UISTATE); |
| 1535 | 1524 | break; |
| 1536 | 1525 | |
| 1537 | | #if USE_TAPEDLG |
| 1538 | | case DEVOPTION_CASSETTE_DIALOG: |
| 1539 | | tapedialog_show(wnd, image_index_in_device(img)); |
| 1540 | | break; |
| 1541 | | #else |
| 1542 | 1526 | case DEVOPTION_CASSETTE_REWIND: |
| 1543 | 1527 | cassette_seek(img, -1.0, SEEK_CUR); |
| 1544 | 1528 | break; |
| r3177 | r3178 | |
| 1546 | 1530 | case DEVOPTION_CASSETTE_FASTFORWARD: |
| 1547 | 1531 | cassette_seek(img, +1.0, SEEK_CUR); |
| 1548 | 1532 | break; |
| 1549 | | #endif |
| 1550 | 1533 | } |
| 1551 | 1534 | break; |
| 1552 | 1535 | #endif /* HAS_WAVE */ |