Mercurial > repos > blastem
comparison io.c @ 451:b7c3b2d22858
Added support for saving savestates. Added gst savestate format test harness
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 26 Jul 2013 19:55:04 -0700 |
parents | cc754a309ead |
children | 140af5509ce7 |
comparison
equal
deleted
inserted
replaced
448:e85a107e6ec0 | 451:b7c3b2d22858 |
---|---|
11 | 11 |
12 typedef enum { | 12 typedef enum { |
13 UI_DEBUG_MODE_INC, | 13 UI_DEBUG_MODE_INC, |
14 UI_DEBUG_PAL_INC, | 14 UI_DEBUG_PAL_INC, |
15 UI_ENTER_DEBUGGER, | 15 UI_ENTER_DEBUGGER, |
16 UI_SAVE_STATE, | |
16 UI_EXIT | 17 UI_EXIT |
17 } ui_action; | 18 } ui_action; |
18 | 19 |
19 typedef struct { | 20 typedef struct { |
20 uint8_t bind_type; | 21 uint8_t bind_type; |
105 #define BUTTON_START GAMEPAD_BUTTON(GAMEPAD_TH0, GAMEPAD_NONE, 0x20) | 106 #define BUTTON_START GAMEPAD_BUTTON(GAMEPAD_TH0, GAMEPAD_NONE, 0x20) |
106 #define BUTTON_C GAMEPAD_BUTTON(GAMEPAD_TH1, GAMEPAD_NONE, 0x20) | 107 #define BUTTON_C GAMEPAD_BUTTON(GAMEPAD_TH1, GAMEPAD_NONE, 0x20) |
107 | 108 |
108 void bind_gamepad(int keycode, int gamepadnum, int button) | 109 void bind_gamepad(int keycode, int gamepadnum, int button) |
109 { | 110 { |
110 | 111 |
111 if (gamepadnum < 1 || gamepadnum > 2) { | 112 if (gamepadnum < 1 || gamepadnum > 2) { |
112 return; | 113 return; |
113 } | 114 } |
114 uint8_t bind_type = gamepadnum - 1 + BIND_GAMEPAD1; | 115 uint8_t bind_type = gamepadnum - 1 + BIND_GAMEPAD1; |
115 bind_key(keycode, bind_type, button >> 12, button >> 8 & 0xF, button & 0xFF); | 116 bind_key(keycode, bind_type, button >> 12, button >> 8 & 0xF, button & 0xFF); |
207 } | 208 } |
208 render_debug_pal(ui_debug_pal); | 209 render_debug_pal(ui_debug_pal); |
209 break; | 210 break; |
210 case UI_ENTER_DEBUGGER: | 211 case UI_ENTER_DEBUGGER: |
211 break_on_sync = 1; | 212 break_on_sync = 1; |
213 break; | |
214 case UI_SAVE_STATE: | |
215 save_state = 1; | |
212 break; | 216 break; |
213 case UI_EXIT: | 217 case UI_EXIT: |
214 exit(0); | 218 exit(0); |
215 } | 219 } |
216 break; | 220 break; |
281 *ui_out = UI_DEBUG_MODE_INC; | 285 *ui_out = UI_DEBUG_MODE_INC; |
282 } else if(!strcmp(target + 3, "vdp_debug_pal")) { | 286 } else if(!strcmp(target + 3, "vdp_debug_pal")) { |
283 *ui_out = UI_DEBUG_PAL_INC; | 287 *ui_out = UI_DEBUG_PAL_INC; |
284 } else if(!strcmp(target + 3, "enter_debugger")) { | 288 } else if(!strcmp(target + 3, "enter_debugger")) { |
285 *ui_out = UI_ENTER_DEBUGGER; | 289 *ui_out = UI_ENTER_DEBUGGER; |
290 } else if(!strcmp(target + 3, "save_state")) { | |
291 *ui_out = UI_SAVE_STATE; | |
286 } else if(!strcmp(target + 3, "exit")) { | 292 } else if(!strcmp(target + 3, "exit")) { |
287 *ui_out = UI_EXIT; | 293 *ui_out = UI_EXIT; |
288 } else { | 294 } else { |
289 fprintf(stderr, "Unreconized UI binding type %s\n", target); | 295 fprintf(stderr, "Unreconized UI binding type %s\n", target); |
290 return 0; | 296 return 0; |
343 special = tern_insert_int(special, "down", RENDERKEY_DOWN); | 349 special = tern_insert_int(special, "down", RENDERKEY_DOWN); |
344 special = tern_insert_int(special, "left", RENDERKEY_LEFT); | 350 special = tern_insert_int(special, "left", RENDERKEY_LEFT); |
345 special = tern_insert_int(special, "right", RENDERKEY_RIGHT); | 351 special = tern_insert_int(special, "right", RENDERKEY_RIGHT); |
346 special = tern_insert_int(special, "enter", '\r'); | 352 special = tern_insert_int(special, "enter", '\r'); |
347 special = tern_insert_int(special, "esc", RENDERKEY_ESC); | 353 special = tern_insert_int(special, "esc", RENDERKEY_ESC); |
348 | 354 |
349 tern_node * padbuttons = tern_insert_int(NULL, ".up", DPAD_UP); | 355 tern_node * padbuttons = tern_insert_int(NULL, ".up", DPAD_UP); |
350 padbuttons = tern_insert_int(padbuttons, ".down", DPAD_DOWN); | 356 padbuttons = tern_insert_int(padbuttons, ".down", DPAD_DOWN); |
351 padbuttons = tern_insert_int(padbuttons, ".left", DPAD_LEFT); | 357 padbuttons = tern_insert_int(padbuttons, ".left", DPAD_LEFT); |
352 padbuttons = tern_insert_int(padbuttons, ".right", DPAD_RIGHT); | 358 padbuttons = tern_insert_int(padbuttons, ".right", DPAD_RIGHT); |
353 padbuttons = tern_insert_int(padbuttons, ".a", BUTTON_A); | 359 padbuttons = tern_insert_int(padbuttons, ".a", BUTTON_A); |
356 padbuttons = tern_insert_int(padbuttons, ".x", BUTTON_X); | 362 padbuttons = tern_insert_int(padbuttons, ".x", BUTTON_X); |
357 padbuttons = tern_insert_int(padbuttons, ".y", BUTTON_Y); | 363 padbuttons = tern_insert_int(padbuttons, ".y", BUTTON_Y); |
358 padbuttons = tern_insert_int(padbuttons, ".z", BUTTON_Z); | 364 padbuttons = tern_insert_int(padbuttons, ".z", BUTTON_Z); |
359 padbuttons = tern_insert_int(padbuttons, ".start", BUTTON_START); | 365 padbuttons = tern_insert_int(padbuttons, ".start", BUTTON_START); |
360 padbuttons = tern_insert_int(padbuttons, ".mode", BUTTON_MODE); | 366 padbuttons = tern_insert_int(padbuttons, ".mode", BUTTON_MODE); |
361 | 367 |
362 tern_node * keys = tern_find_prefix(config, "bindingskeys"); | 368 tern_node * keys = tern_find_prefix(config, "bindingskeys"); |
363 process_keys(keys, special, padbuttons, NULL); | 369 process_keys(keys, special, padbuttons, NULL); |
364 char prefix[] = "bindingspads00"; | 370 char prefix[] = "bindingspads00"; |
365 for (int i = 0; i < 100 && i < render_num_joysticks(); i++) | 371 for (int i = 0; i < 100 && i < render_num_joysticks(); i++) |
366 { | 372 { |