This repository has been archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
init.c
112 lines (75 loc) · 2.86 KB
/
init.c
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
#include "init.h"
extern unsigned char _binary_materials_button_pad_png_start;
extern unsigned char _binary_materials_button_cross_png_start;
extern unsigned char _binary_materials_button_circle_png_start;
vita2d_pgf *pgf = NULL;
vita2d_texture *button_pad = NULL;
vita2d_texture *button_enter = NULL;
vita2d_texture *button_cancel = NULL;
int SCE_CTRL_ENTER = SCE_CTRL_CROSS;
int SCE_CTRL_CANCEL = SCE_CTRL_CIRCLE;
/// Vita2DLib /////////////////////////////////////////////////////////////////////////////////////////////
void initVita2DLib() {
vita2d_init();
pgf = vita2d_load_default_pgf();
button_pad = vita2d_load_PNG_buffer(&_binary_materials_button_pad_png_start);
if ( SCE_CTRL_ENTER == SCE_CTRL_CROSS ) {
button_enter = vita2d_load_PNG_buffer(&_binary_materials_button_cross_png_start);
button_cancel = vita2d_load_PNG_buffer(&_binary_materials_button_circle_png_start);
} else {
button_enter = vita2d_load_PNG_buffer(&_binary_materials_button_circle_png_start);
button_cancel = vita2d_load_PNG_buffer(&_binary_materials_button_cross_png_start);
}
}
void closeVita2DLib() {
vita2d_free_texture(button_pad);
vita2d_free_texture(button_enter);
vita2d_free_texture(button_cancel);
vita2d_free_pgf(pgf);
vita2d_fini();
}
/// NET /////////////////////////////////////////////////////////////////////////////////////////////
void netInit() {
sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
SceNetInitParam netInitParam;
int size = 1*1024*1024;
netInitParam.memory = malloc(size);
netInitParam.size = size;
netInitParam.flags = 0;
sceNetInit(&netInitParam);
sceNetCtlInit();
}
void httpInit() {
sceSysmoduleLoadModule(SCE_SYSMODULE_HTTP);
sceHttpInit(1*1024*1024);
}
/// SceAppUtil /////////////////////////////////////////////////////////////////////////////////////////////
void initSceAppUtil() {
SceAppUtilInitParam init_param;
SceAppUtilBootParam boot_param;
memset(&init_param, 0, sizeof(SceAppUtilInitParam));
memset(&boot_param, 0, sizeof(SceAppUtilBootParam));
sceAppUtilInit(&init_param, &boot_param);
}
void finishSceAppUtil() {
sceAppUtilShutdown();
}
int readInEnterButton() {
int enter_button = 0;
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_ENTER_BUTTON, &enter_button);
if (enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) { //switch butons
SCE_CTRL_ENTER = SCE_CTRL_CIRCLE;
SCE_CTRL_CANCEL = SCE_CTRL_CROSS;
}
return enter_button;
}
char *getUsername() {
static SceChar8 username[SCE_SYSTEM_PARAM_USERNAME_MAXSIZE];
sceAppUtilSystemParamGetString(SCE_SYSTEM_PARAM_ID_USERNAME, username, SCE_SYSTEM_PARAM_USERNAME_MAXSIZE);
return (char *)username;
}
int getSystemLanguageCode() {
int systemlanguage = 0;
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &systemlanguage);
return systemlanguage;
}