-
Notifications
You must be signed in to change notification settings - Fork 9
/
SDL_video_mmiyoo.h
299 lines (256 loc) · 8.58 KB
/
SDL_video_mmiyoo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
Customized version for Miyoo-Mini handheld.
Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer.
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 2022-2022 Steward Fu <steward.fu@gmail.com>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#ifndef __SDL_VIDEO_MMIYOO_H__
#define __SDL_VIDEO_MMIYOO_H__
#include <linux/fb.h>
#include "../SDL_sysvideo.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "SDL_ttf.h"
#include "SDL_image.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
#include "SDL_loadso.h"
#include "SDL_events.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_video_mmiyoo.h"
#include "SDL_event_mmiyoo.h"
#include "SDL_framebuffer_mmiyoo.h"
#include "SDL_opengles_mmiyoo.h"
#include "detour.h"
#include "mi_sys.h"
#include "mi_gfx.h"
#ifndef MAX_PATH
#define MAX_PATH 255
#endif
#define PREFIX "[SDL] "
#define FB_W 640
#define FB_H 480
#define FB_BPP 4
#define FB_SIZE (FB_W * FB_H * FB_BPP * 2)
#define TMP_SIZE (FB_W * FB_H * FB_BPP)
#define CFG_PATH "resources/settings.json"
#define THEME_PATH "resources/bg"
#define PEN_PATH "resources/pen"
#define OVERLAY_PATH "resources/overlay"
#define MENU_BG_FILE "resources/menu/bg.png"
#define MENU_CURSOR_FILE "resources/menu/cursor.png"
#define DRASTIC_MENU_BG_FILE "resources/menu/drastic_bg.png"
#define DRASTIC_MENU_YES_FILE "resources/menu/drastic_yes.png"
#define DRASTIC_MENU_NO_FILE "resources/menu/drastic_no.png"
#define DRASTIC_MENU_CURSOR_FILE "resources/menu/drastic_cursor.png"
#define TRANSLATE_PATH "resources/translate"
#define MMIYOO_DRIVER_NAME "mmiyoo"
#define BASE_REG_RIU_PA 0x1f000000
#define BASE_REG_MPLL_PA (BASE_REG_RIU_PA + 0x103000 * 2)
#define PLL_SIZE 0x1000
#define PEN_LT 0
#define PEN_LB 1
#define PEN_RT 2
#define PEN_RB 3
#define FONT_PATH "resources/font/font.ttf"
#define FONT_SIZE 24
#define NDS_DIS_MODE_VH_T0 0
#define NDS_DIS_MODE_VH_T1 1
#define NDS_DIS_MODE_S0 2
#define NDS_DIS_MODE_S1 3
#define NDS_DIS_MODE_V0 4
#define NDS_DIS_MODE_V1 5
#define NDS_DIS_MODE_H0 6
#define NDS_DIS_MODE_H1 7
#define NDS_DIS_MODE_VH_S0 8
#define NDS_DIS_MODE_VH_S1 9
#define NDS_DIS_MODE_VH_C0 10
#define NDS_DIS_MODE_VH_C1 11
#define NDS_DIS_MODE_HH0 12
#define NDS_DIS_MODE_LAST 12
#define NDS_DIS_MODE_HRES0 13
#define NDS_DIS_MODE_HRES1 14
#define NDS_ALPHA_MAX 7
#define NDS_BORDER_MAX 7
#define NDS_STATE_QSAVE 1
#define NDS_STATE_QLOAD 2
#define NDS_STATE_FF 4
#define NDS_SCALE_BLUR 0
#define NDS_SCALE_PIXEL 1
#define JSON_NDS_PEN_XV "xv"
#define JSON_NDS_PEN_YV "yv"
#define JSON_NDS_PEN_SEL "pen"
#define JSON_NDS_PEN_POS "touchpad"
#define JSON_NDS_THEME_SEL "theme"
#define JSON_NDS_DIS_MODE "mode"
#define JSON_NDS_ALPHA_VALUE "alpha"
#define JSON_NDS_ALPHA_POSITION "position"
#define JSON_NDS_ALPHA_BORDER "border"
#define JSON_NDS_MAX_CPU "maxcpu"
#define JSON_NDS_MIN_CPU "mincpu"
#define JSON_NDS_OVERLAY "overlay"
#define JSON_NDS_ALT_MODE "alt"
#define JSON_NDS_SWAP_L1L2 "swap_l1l2"
#define JSON_NDS_SWAP_R1R2 "swap_r1r2"
#define JSON_NDS_CUST_MENU "cust_menu"
#define JSON_NDS_LANG "lang"
#define JSON_NDS_KEYS_90D "key_90d"
#define JSON_NDS_MENU_C0 "menu_c0"
#define JSON_NDS_MENU_C1 "menu_c1"
#define JSON_NDS_MENU_C2 "menu_c2"
#define JSON_NDS_AUTO_STATE "auto_state"
#define JSON_NDS_AUTO_SLOT "auto_slot"
#define GFX_ACTION_NONE 0
#define GFX_ACTION_FLIP 1
#define GFX_ACTION_COPY0 2
#define GFX_ACTION_COPY1 3
#define RELOAD_BG_COUNT 5
#define MAX_QUEUE 2
#define NDS_LANG_EN 0
#define MAX_LANG_LINE 128
#define MAX_MENU_LINE 128
#define NDS_DRASTIC_MENU_MAIN 1
#define NDS_DRASTIC_MENU_OPTION 2
#define NDS_DRASTIC_MENU_CONTROLLER 3
#define NDS_DRASTIC_MENU_CONTROLLER2 4
#define NDS_DRASTIC_MENU_FIRMWARE 5
#define NDS_DRASTIC_MENU_CHEAT 6
#define NDS_DRASTIC_MENU_ROM 7
typedef struct MMIYOO_VideoInfo {
SDL_Window *window;
} MMIYOO_VideoInfo;
typedef struct _GFX {
int fd;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
struct _DMA {
MI_PHY phyAddr;
void *virAddr;
} fb, tmp, overlay;
struct _HW {
struct _BUF {
MI_GFX_Surface_t surf;
MI_GFX_Rect_t rt;
} src, dst, overlay;
MI_GFX_Opt_t opt;
} hw;
int action;
struct _THREAD {
void *pixels;
SDL_Rect srt;
SDL_FRect drt;
SDL_Texture *texture;
} thread[MAX_QUEUE];
} GFX;
typedef struct _NDS {
int lang;
int mincpu;
int maxcpu;
int volume;
int dis_mode;
int alt_mode;
int hres_mode;
int cust_menu;
int swap_l1l2;
int swap_r1r2;
int keys_90d;
int auto_slot;
int auto_state;
int defer_update_bg;
char cfg_path[MAX_PATH];
TTF_Font *font;
uint32_t state;
struct _MENU {
int enable;
SDL_Surface *bg;
SDL_Surface *cursor;
struct _DRASTIC {
int enable;
SDL_Surface *bg;
SDL_Surface *main;
SDL_Surface *yes;
SDL_Surface *no;
SDL_Surface *cursor;
} drastic;
uint32_t c0;
uint32_t c1;
uint32_t c2;
} menu;
struct _ALPHA {
int val;
int pos;
int border;
} alpha;
struct _OVERLAY {
int sel;
int max;
int alpha;
SDL_Surface *img;
char path[MAX_PATH];
} overlay;
struct _THEME {
int sel;
int max;
SDL_Surface *img;
char path[MAX_PATH];
} theme;
struct _PEN {
int xv;
int yv;
int sel;
int max;
int pos;
int type;
SDL_Surface *img;
clock_t pre_ticks;
char path[MAX_PATH];
} pen;
} NDS;
typedef struct _CUST_MENU_SUB {
int x;
int y;
int cheat;
int enable;
uint32_t fg;
uint32_t bg;
char msg[128];
} CUST_MENU_SUB;
typedef struct _CUST_MENU {
int cnt;
CUST_MENU_SUB item[MAX_MENU_LINE];
} CUST_MENU;
int snd_nds_savestate(int slot);
void snd_nds_reload_config(void);
void neon_memcpy(void *dest, const void *src, size_t n);
void GFX_Clear(void);
void GFX_Flip(void);
int GFX_Copy(const void *pixels, SDL_Rect srcrect, SDL_Rect dstrect, int pitch, int alpha, int rotate);
int draw_pen(const void *pixels, int width, int pitch);
int draw_info(SDL_Surface *dst, const char *info, int x, int y, uint32_t fgcolor, uint32_t bgcolor);
int get_font_width(const char *info);
int get_font_height(const char *info);
int reload_bg(void);
int reload_pen(void);
int reload_overlay(void);
int handle_menu(int key);
int process_drastic_menu(void);
int My_QueueCopy(SDL_Texture *texture, const void *pixels, const SDL_Rect *srcrect, const SDL_FRect *dstrect);
const void* get_pixels(void *chk);
const char *to_lang(const char *p);
#endif