menu.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "plat.h"
  2. static const char *men_scaler[] = { "1x1, 1x1", "2x2, 3x2", "2x2, 2x2", "fullscreen", "custom", NULL };
  3. static const char h_scaler[] = "Scalers for 40 and 32 column modes\n"
  4. "(320 and 256 pixel wide horizontal)";
  5. static const char h_cscaler[] = "Displays the scaler layer, you can resize it\n"
  6. "using d-pad or move it using R+d-pad";
  7. static int menu_loop_cscaler(int id, int keys)
  8. {
  9. unsigned int inp;
  10. currentConfig.scaling = SCALE_CUSTOM;
  11. pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
  12. pnd_restore_layer_data();
  13. for (;;)
  14. {
  15. menu_draw_begin(0, 1);
  16. memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);
  17. text_out16(2, 480 - 18, "%dx%d | d-pad to resize, R+d-pad to move", g_layer_cw, g_layer_ch);
  18. menu_draw_end();
  19. inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT
  20. |PBTN_R|PBTN_MOK|PBTN_MBACK, NULL, 40);
  21. if (inp & PBTN_UP) g_layer_cy--;
  22. if (inp & PBTN_DOWN) g_layer_cy++;
  23. if (inp & PBTN_LEFT) g_layer_cx--;
  24. if (inp & PBTN_RIGHT) g_layer_cx++;
  25. if (!(inp & PBTN_R)) {
  26. if (inp & PBTN_UP) g_layer_ch += 2;
  27. if (inp & PBTN_DOWN) g_layer_ch -= 2;
  28. if (inp & PBTN_LEFT) g_layer_cw += 2;
  29. if (inp & PBTN_RIGHT) g_layer_cw -= 2;
  30. }
  31. if (inp & (PBTN_MOK|PBTN_MBACK))
  32. break;
  33. if (inp & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)) {
  34. if (g_layer_cx < 0) g_layer_cx = 0;
  35. if (g_layer_cx > 640) g_layer_cx = 640;
  36. if (g_layer_cy < 0) g_layer_cy = 0;
  37. if (g_layer_cy > 420) g_layer_cy = 420;
  38. if (g_layer_cw < 160) g_layer_cw = 160;
  39. if (g_layer_ch < 60) g_layer_ch = 60;
  40. if (g_layer_cx + g_layer_cw > 800)
  41. g_layer_cw = 800 - g_layer_cx;
  42. if (g_layer_cy + g_layer_ch > 480)
  43. g_layer_ch = 480 - g_layer_cy;
  44. pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
  45. }
  46. }
  47. pnd_setup_layer(0, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
  48. return 0;
  49. }
  50. #define MENU_OPTIONS_GFX \
  51. mee_enum_h ("Scaler", MA_OPT_SCALING, currentConfig.scaling, \
  52. men_scaler, h_scaler), \
  53. mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \
  54. mee_cust_h ("Setup custom scaler", MA_NONE, menu_loop_cscaler, NULL, h_cscaler), \
  55. mee_range_hide("layer_x", MA_OPT3_LAYER_X, g_layer_cx, 0, 640), \
  56. mee_range_hide("layer_y", MA_OPT3_LAYER_Y, g_layer_cy, 0, 420), \
  57. mee_range_hide("layer_w", MA_OPT3_LAYER_W, g_layer_cw, 160, 800), \
  58. mee_range_hide("layer_h", MA_OPT3_LAYER_H, g_layer_ch, 60, 480), \
  59. #define MENU_OPTIONS_ADV
  60. static menu_entry e_menu_gfx_options[];
  61. static menu_entry e_menu_options[];
  62. static menu_entry e_menu_keyconfig[];
  63. void pnd_menu_init(void)
  64. {
  65. me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, 0);
  66. }