c7eb229a |
1 | #include "plat.h" |
2 | |
ca980e1b |
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; } |
5 | |
c7eb229a |
6 | static const char *men_scaler[] = { "1x1, 1x1", "2x2, 3x2", "2x2, 2x2", "fullscreen", "custom", NULL }; |
be672de7 |
7 | static const char h_scaler[] = "Scalers for 40 and 32 column modes\n" |
8 | "(320 and 256 pixel wide horizontal)"; |
c7eb229a |
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"; |
c7eb229a |
11 | |
21ebcfd3 |
12 | static int menu_loop_cscaler(int id, int keys) |
c7eb229a |
13 | { |
ca980e1b |
14 | int was_layer_clipped = 0; |
c7eb229a |
15 | unsigned int inp; |
16 | |
17 | currentConfig.scaling = SCALE_CUSTOM; |
18 | |
19 | pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch); |
20 | pnd_restore_layer_data(); |
21 | |
ca980e1b |
22 | menu_draw_begin(0, 1); |
23 | menuscreen_memset_lines(g_menuscreen_ptr, 0, g_menuscreen_h); |
24 | menu_draw_end(); |
25 | |
c7eb229a |
26 | for (;;) |
27 | { |
ca980e1b |
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; |
30 | char text[128]; |
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"); |
39 | plat_video_flip(); |
c7eb229a |
40 | |
d4d62665 |
41 | inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT |
42 | |PBTN_R|PBTN_MOK|PBTN_MBACK, NULL, 40); |
ca980e1b |
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)) { |
c7eb229a |
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; |
52 | } |
53 | if (inp & (PBTN_MOK|PBTN_MBACK)) |
54 | break; |
55 | |
56 | if (inp & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)) { |
ca980e1b |
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) |
63 | layer_clipped = 1; |
64 | if (g_layer_cw > 800+400) |
65 | g_layer_cw = 800+400; |
66 | if (g_layer_cy < 0 || g_layer_cy + g_layer_ch > 480) |
67 | layer_clipped = 1; |
68 | if (g_layer_ch > 480+360) |
69 | g_layer_ch = 480+360; |
70 | // resize the layer |
c7eb229a |
71 | pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch); |
ca980e1b |
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; |
c7eb229a |
76 | } |
77 | } |
78 | |
79 | pnd_setup_layer(0, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch); |
80 | |
81 | return 0; |
82 | } |
be672de7 |
83 | |
9bb5d91c |
84 | #define MENU_OPTIONS_GFX \ |
be672de7 |
85 | mee_enum_h ("Scaler", MA_OPT_SCALING, currentConfig.scaling, \ |
c7eb229a |
86 | men_scaler, h_scaler), \ |
c7eb229a |
87 | mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \ |
ca980e1b |
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), \ |
c7eb229a |
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), \ |
9bb5d91c |
93 | |
75a30842 |
94 | #define MENU_OPTIONS_ADV |
c7eb229a |
95 | |
c7eb229a |
96 | static menu_entry e_menu_gfx_options[]; |
f4750ee0 |
97 | static menu_entry e_menu_options[]; |
45285368 |
98 | static menu_entry e_menu_keyconfig[]; |
c7eb229a |
99 | |
100 | void pnd_menu_init(void) |
101 | { |
45285368 |
102 | me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, 0); |
c7eb229a |
103 | } |
104 | |