Skip to content

Commit 3230471

Browse files
committed
utils: Minor consistency changes and clean up
1 parent 3d4fc40 commit 3230471

File tree

9 files changed

+186
-191
lines changed

9 files changed

+186
-191
lines changed

app/include/gui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct {
3030
g2dTexture *texture = nullptr;
3131
} MenuItem;
3232

33-
extern bool g_running;
33+
extern bool running;
3434

3535
namespace GUI {
3636
void ResetCheckbox(MenuItem &item);

app/include/utils.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ enum BROWSE_STATE {
1818
BROWSE_STATE_UMD
1919
};
2020

21-
extern bool psp_usb_cable_connection, is_ms_inserted, is_psp_go;
21+
extern bool isMSInserted, isPSPGo;
2222
extern enum PspCtrlButtons PSP_CTRL_ENTER, PSP_CTRL_CANCEL;
2323
extern BROWSE_STATE device;
24-
extern int g_psp_language;
24+
extern int language;
2525

2626
namespace Utils {
2727
void SetBounds(int &set, int min, int max);
@@ -32,7 +32,7 @@ namespace Utils {
3232
void TermKernelDrivers(void);
3333
void HandleUSB(void);
3434
bool IsModelPSPGo(void);
35-
int IsMemCardInserted(bool &is_inserted);
35+
int IsMemCardInserted(bool &isInserted);
3636
bool IsInternalStorage(void);
3737
int LaunchEboot(const char *path);
3838
u64 GetTotalStorage(void);

app/source/config.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ namespace Config {
2727
int ret = 0;
2828

2929
// Set root path and current working directory based on model.
30-
cfg.cwd = is_psp_go? "ef0:" : "ms0:";
31-
device = is_psp_go ? BROWSE_STATE_INTERNAL : BROWSE_STATE_EXTERNAL;
30+
cfg.cwd = isPSPGo? "ef0:" : "ms0:";
31+
device = isPSPGo ? BROWSE_STATE_INTERNAL : BROWSE_STATE_EXTERNAL;
3232

3333
if (!FS::FileExists("config.json")) {
3434
cfg = config_t();
35-
cfg.cwd = is_psp_go? "ef0:" : "ms0:";
35+
cfg.cwd = isPSPGo? "ef0:" : "ms0:";
3636
return Config::Save(cfg);
3737
}
3838

@@ -53,7 +53,7 @@ namespace Config {
5353
(!document.HasMember("dark_theme")) || (!document.HasMember("dev_options"))) {
5454
Log::Error("%s failed: Malformed config file, resetting\n", __func__);
5555
cfg = config_t();
56-
cfg.cwd = is_psp_go? "ef0:" : "ms0:";
56+
cfg.cwd = isPSPGo? "ef0:" : "ms0:";
5757
return Config::Save(cfg);
5858
}
5959

@@ -68,7 +68,7 @@ namespace Config {
6868
if (config_version_holder < config_version) {
6969
sceIoRemove("config.json");
7070
cfg = config_t();
71-
cfg.cwd = is_psp_go? "ef0:" : "ms0:";
71+
cfg.cwd = isPSPGo? "ef0:" : "ms0:";
7272
return Config::Save(cfg);
7373
}
7474

app/source/g2d.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace G2D {
6060
std::memset(&params, 0, sizeof(SceUtilityOskParams));
6161

6262
params.base.size = sizeof(SceUtilityOskParams);
63-
params.base.language = g_psp_language;
63+
params.base.language = language;
6464
params.base.buttonSwap = (PSP_CTRL_ENTER == PSP_CTRL_CROSS)? PSP_UTILITY_ACCEPT_CROSS : PSP_UTILITY_ACCEPT_CIRCLE;
6565
params.base.graphicsThread = 17;
6666
params.base.accessThread = 19;

app/source/gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace GUI {
9696
float resolution = sceRtcGetTickResolution() / 1000.f;
9797
sceRtcGetCurrentTick(&last_tick);
9898

99-
while(g_running) {
99+
while(running) {
100100
u64 current_tick = 0;
101101
sceRtcGetCurrentTick(&current_tick);
102102
float delta = (current_tick - last_tick) / resolution;

app/source/gui/menubar.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ namespace GUI {
2929

3030
G2D::FontSetStyle(1.f, cfg.dark_theme? WHITE : BLACK, INTRAFONT_ALIGN_LEFT);
3131

32-
if (is_psp_go) {
32+
if (isPSPGo) {
3333
G2D::DrawImage(icon_sd[cfg.dark_theme], pos_x + 10, 92);
34-
G2D::DrawText(pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2), !is_ms_inserted? "ef0:/" : "ms0:/");
34+
G2D::DrawText(pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2), !isMSInserted? "ef0:/" : "ms0:/");
3535

36-
if (is_ms_inserted) {
36+
if (isMSInserted) {
3737
G2D::DrawImage(icon_secure[cfg.dark_theme], pos_x + 10, 122);
3838
G2D::DrawText(pos_x + 50, 90 + ((30 - (font->glyph->height - 6)) / 2) + 30, "ef0:/");
3939

@@ -96,14 +96,14 @@ namespace GUI {
9696
else if (ctrl & PSP_CTRL_DOWN)
9797
selection++;
9898

99-
if (is_psp_go) {
99+
if (isPSPGo) {
100100
if (cfg.dev_options) {
101-
Utils::SetMax(selection, 0, is_ms_inserted? 5 : 4);
102-
Utils::SetMin(selection, is_ms_inserted? 5 : 4, 0);
101+
Utils::SetMax(selection, 0, isMSInserted? 5 : 4);
102+
Utils::SetMin(selection, isMSInserted? 5 : 4, 0);
103103
}
104104
else {
105-
Utils::SetMax(selection, 0, is_ms_inserted? 1 : 0);
106-
Utils::SetMin(selection, is_ms_inserted? 1 : 0, 0);
105+
Utils::SetMax(selection, 0, isMSInserted? 1 : 0);
106+
Utils::SetMin(selection, isMSInserted? 1 : 0, 0);
107107
}
108108
}
109109
else {
@@ -116,31 +116,31 @@ namespace GUI {
116116

117117
switch (selection) {
118118
case 0:
119-
if ((is_psp_go && is_ms_inserted) || (!is_psp_go)) {
119+
if ((isPSPGo && isMSInserted) || (!isPSPGo)) {
120120
cfg.cwd = "ms0:";
121121
device = BROWSE_STATE_EXTERNAL;
122122
}
123-
else if (is_psp_go && !is_ms_inserted) {
123+
else if (isPSPGo && !isMSInserted) {
124124
cfg.cwd = "ef0:";
125125
device = BROWSE_STATE_INTERNAL;
126126
}
127127
break;
128128

129129
case 1:
130-
if (!(is_psp_go && is_ms_inserted)) {
130+
if (!(isPSPGo && isMSInserted)) {
131131
if ((R_FAILED(ret = sceIoUnassign("flash0:"))) && (ret != 0x80020321))
132132
Log::Error("sceIoUnassign(flash0) failed: 0x%x\n", ret);
133133

134134
if (R_FAILED(ret = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, nullptr, 0)))
135135
Log::Error("sceIoAssign(flash0) failed: 0x%x\n", ret);
136136
}
137137

138-
cfg.cwd = (is_psp_go && is_ms_inserted)? "ef0:" : "flash0:/";
139-
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_INTERNAL : BROWSE_STATE_FLASH0;
138+
cfg.cwd = (isPSPGo && isMSInserted)? "ef0:" : "flash0:/";
139+
device = (isPSPGo && isMSInserted)? BROWSE_STATE_INTERNAL : BROWSE_STATE_FLASH0;
140140
break;
141141

142142
case 2:
143-
if (is_psp_go && is_ms_inserted) {
143+
if (isPSPGo && isMSInserted) {
144144
if ((R_FAILED(ret = sceIoUnassign("flash0:"))) && (ret != 0x80020321))
145145
Log::Error("sceIoUnassign(flash0) failed: 0x%x\n", ret);
146146

@@ -155,12 +155,12 @@ namespace GUI {
155155
Log::Error("sceIoAssign(flash1) failed: 0x%x\n", ret);
156156
}
157157

158-
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash0:/" : "flash1:/";
159-
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH0 : BROWSE_STATE_FLASH1;
158+
cfg.cwd = (isPSPGo && isMSInserted)? "flash0:/" : "flash1:/";
159+
device = (isPSPGo && isMSInserted)? BROWSE_STATE_FLASH0 : BROWSE_STATE_FLASH1;
160160
break;
161161

162162
case 3:
163-
if (is_psp_go && is_ms_inserted) {
163+
if (isPSPGo && isMSInserted) {
164164
if ((R_FAILED(ret = sceIoUnassign("flash1:"))) && (ret != 0x80020321))
165165
Log::Error("sceIoUnassign(flash1) failed: 0x%x\n", ret);
166166

@@ -175,12 +175,12 @@ namespace GUI {
175175
Log::Error("sceIoAssign(flash2) failed: 0x%x\n", ret);
176176
}
177177

178-
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash1:/" : "flash2:/";
179-
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH1 : BROWSE_STATE_FLASH2;
178+
cfg.cwd = (isPSPGo && isMSInserted)? "flash1:/" : "flash2:/";
179+
device = (isPSPGo && isMSInserted)? BROWSE_STATE_FLASH1 : BROWSE_STATE_FLASH2;
180180
break;
181181

182182
case 4:
183-
if (is_psp_go && is_ms_inserted) {
183+
if (isPSPGo && isMSInserted) {
184184
if ((R_FAILED(ret = sceIoUnassign("flash2:"))) && (ret != 0x80020321))
185185
Log::Error("sceIoUnassign(flash2) failed: 0x%x\n", ret);
186186

@@ -195,12 +195,12 @@ namespace GUI {
195195
Log::Error("sceIoAssign(flash3) failed: 0x%x\n", ret);
196196
}
197197

198-
cfg.cwd = (is_psp_go && is_ms_inserted)? "flash2:/" : "flash3:/";
199-
device = (is_psp_go && is_ms_inserted)? BROWSE_STATE_FLASH2 : BROWSE_STATE_FLASH3;
198+
cfg.cwd = (isPSPGo && isMSInserted)? "flash2:/" : "flash3:/";
199+
device = (isPSPGo && isMSInserted)? BROWSE_STATE_FLASH2 : BROWSE_STATE_FLASH3;
200200
break;
201201

202202
case 5:
203-
if (is_psp_go && is_ms_inserted) {
203+
if (isPSPGo && isMSInserted) {
204204
if ((R_FAILED(ret = sceIoUnassign("flash3:"))) && (ret != 0x80020321))
205205
Log::Error("sceIoUnassign(flash3) failed: 0x%x\n", ret);
206206

@@ -210,7 +210,7 @@ namespace GUI {
210210
cfg.cwd = "flash3:/";
211211
device = BROWSE_STATE_FLASH3;
212212
}
213-
else if (!is_psp_go) {
213+
else if (!isPSPGo) {
214214
if (sceUmdCheckMedium() != 0) {
215215
if (R_FAILED(ret = sceUmdActivate(1, "disc0:")))
216216
Log::Error("sceUmdActivate(disc0) failed: 0x%x\n", ret);

app/source/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
1414
PSP_HEAP_THRESHOLD_SIZE_KB(1024);
1515
PSP_HEAP_SIZE_KB(-2048);
1616

17-
bool g_running = true;
17+
bool running = true;
1818

1919
namespace Services {
2020
int Init(void) {
@@ -24,6 +24,9 @@ namespace Services {
2424
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
2525
Utils::InitKernelDrivers();
2626
Textures::Load();
27+
28+
Utils::IsMemCardInserted(isMSInserted);
29+
isPSPGo = Utils::IsModelPSPGo();
2730

2831
if (R_FAILED(ret = Config::Load())) {
2932
Log::Error("Config::Load failed: 0x%08x\n", ret);
@@ -46,12 +49,9 @@ namespace Services {
4649
font_size_cache[i] = intraFontMeasureText(font, character);
4750
}
4851

49-
Utils::IsMemCardInserted(is_ms_inserted);
50-
is_psp_go = Utils::IsModelPSPGo();
51-
5252
PSP_CTRL_ENTER = Utils::GetEnterButton();
5353
PSP_CTRL_CANCEL = Utils::GetCancelButton();
54-
g_psp_language = Utils::GetLanguage();
54+
language = Utils::GetLanguage();
5555
return 0;
5656
}
5757

@@ -70,7 +70,7 @@ namespace Services {
7070
}
7171

7272
static int ExitCallback(int arg1, int arg2, void *common) {
73-
g_running = false;
73+
running = false;
7474
return 0;
7575
}
7676

app/source/net.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace Net {
9898
std::memset(&data, 0, sizeof(pspUtilityNetconfData));
9999

100100
data.base.size = sizeof(pspUtilityNetconfData);
101-
data.base.language = g_psp_language;
101+
data.base.language = language;
102102
data.base.buttonSwap = (PSP_CTRL_ENTER == PSP_CTRL_CROSS)? PSP_UTILITY_ACCEPT_CROSS : PSP_UTILITY_ACCEPT_CIRCLE;
103103
data.base.graphicsThread = 17;
104104
data.base.accessThread = 19;
@@ -213,8 +213,8 @@ namespace Net {
213213
std::snprintf(string, 27, "FTP initialization Failed.");
214214
return false;
215215
}
216-
if (is_psp_go) {
217-
if (is_ms_inserted) {
216+
if (isPSPGo) {
217+
if (isMSInserted) {
218218
ftppsp_add_device("ms0:");
219219
ftppsp_add_device("ef0:");
220220
}
@@ -257,8 +257,8 @@ namespace Net {
257257
}
258258

259259
void ExitFTP(void) {
260-
if (is_psp_go) {
261-
if (is_ms_inserted) {
260+
if (isPSPGo) {
261+
if (isMSInserted) {
262262
ftppsp_del_device("ms0:");
263263
ftppsp_del_device("ef0:");
264264
}

0 commit comments

Comments
 (0)