3 static int min(int x, int y) { return x < y ? x : y; }
4 static int max(int x, int y) { return x > y ? x : y; }
6 static const char *men_scaler[] = { "1x1, 1x1", "2x2, 3x2", "2x2, 2x2", "fullscreen", "custom", NULL };
7 static const char h_scaler[] = "Scalers for 40 and 32 column modes\n"
8 "(320 and 256 pixel wide horizontal)";
9 static const char h_cscaler[] = "Displays the scaler layer, you can resize it\n"
10 "using d-pad or move it using R+d-pad";
12 static int menu_loop_cscaler(int id, int keys)
14 int was_layer_clipped = 0;
17 currentConfig.scaling = SCALE_CUSTOM;
19 pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
20 pnd_restore_layer_data();
22 menu_draw_begin(0, 1);
23 menuscreen_memset_lines(g_menuscreen_ptr, 0, g_menuscreen_h);
28 int top_x = max(0, -g_layer_cx * g_screen_ppitch / 800) + 1;
29 int top_y = max(0, -g_layer_cy * g_screen_height / 480) + 1;
31 memcpy(g_screen_ptr, g_menubg_src_ptr,
32 g_screen_ppitch * g_screen_height * 2);
33 snprintf(text, sizeof(text), "%d,%d %dx%d",
34 g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
35 basic_text_out16_nf(g_screen_ptr, g_screen_ppitch,
36 saved_start_col + top_x, saved_start_line + top_y, text);
37 basic_text_out16_nf(g_screen_ptr, g_screen_ppitch, 2,
38 g_screen_height - 20, "d-pad: resize, R+d-pad: move");
41 inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT
42 |PBTN_R|PBTN_MOK|PBTN_MBACK, NULL, 40);
43 if (inp & PBTN_UP) g_layer_cy--;
44 if (inp & PBTN_DOWN) g_layer_cy++;
45 if (inp & PBTN_LEFT) g_layer_cx--;
46 if (inp & PBTN_RIGHT) g_layer_cx++;
47 if (!(inp & PBTN_R)) {
48 if (inp & PBTN_UP) g_layer_ch += 2;
49 if (inp & PBTN_DOWN) g_layer_ch -= 2;
50 if (inp & PBTN_LEFT) g_layer_cw += 2;
51 if (inp & PBTN_RIGHT) g_layer_cw -= 2;
53 if (inp & (PBTN_MOK|PBTN_MBACK))
56 if (inp & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)) {
57 int layer_clipped = 0;
58 g_layer_cx = max(-320, min(g_layer_cx, 640));
59 g_layer_cy = max(-240, min(g_layer_cy, 420));
60 g_layer_cw = max(160, g_layer_cw);
61 g_layer_ch = max( 60, g_layer_ch);
62 if (g_layer_cx < 0 || g_layer_cx + g_layer_cw > 800)
64 if (g_layer_cw > 800+400)
66 if (g_layer_cy < 0 || g_layer_cy + g_layer_ch > 480)
68 if (g_layer_ch > 480+360)
71 pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
72 if (layer_clipped || was_layer_clipped)
73 emu_video_mode_change(saved_start_line, saved_line_count,
74 saved_start_col, saved_col_count);
75 was_layer_clipped = layer_clipped;
79 pnd_setup_layer(0, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
84 #define MENU_OPTIONS_GFX \
85 mee_enum_h ("Scaler", MA_OPT_SCALING, currentConfig.scaling, \
86 men_scaler, h_scaler), \
87 mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \
88 mee_cust_s_h ("Setup custom scaler", MA_NONE, 0, menu_loop_cscaler, NULL, h_cscaler), \
89 mee_range_hide("layer_x", MA_OPT3_LAYER_X, g_layer_cx, -320, 640), \
90 mee_range_hide("layer_y", MA_OPT3_LAYER_Y, g_layer_cy, -240, 420), \
91 mee_range_hide("layer_w", MA_OPT3_LAYER_W, g_layer_cw, 160, 800), \
92 mee_range_hide("layer_h", MA_OPT3_LAYER_H, g_layer_ch, 60, 480), \
94 #define MENU_OPTIONS_ADV
96 static menu_entry e_menu_gfx_options[];
97 static menu_entry e_menu_options[];
98 static menu_entry e_menu_keyconfig[];
100 void pnd_menu_init(void)
102 me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, 0);