Skip to content

Commit 7c63693

Browse files
committed
Added category sorting.
Fixed newlines. Formatted code with astyle.
1 parent 5b40910 commit 7c63693

32 files changed

+2102
-1928
lines changed

categories_lite.h

+222-228
Large diffs are not rendered by default.

category.c

+46-23
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,48 @@
2727

2828
static const char *eboot_types[] = { "EBOOT.PBP", "PARAM.PBP", "PBOOT.PBP" };
2929

30-
Category *GetNextCategory(Category *head[], Category *prev, int location) {
31-
u64 time = 0, last;
32-
Category *newest = NULL;
30+
Category *GetNextCategory(Category *head[], Category *prev, int location)
31+
{
3332

34-
if (prev) {
35-
last = prev->mtime;
36-
} else {
37-
last = (u64) -1;
38-
}
33+
Category *newest = NULL;
3934
Category *p = (Category *) head[location];
4035

41-
while (p) {
42-
if (p->mtime < last) {
43-
if (p->mtime > time) {
44-
time = p->mtime;
45-
newest = p;
36+
if(config.catsort) {
37+
char *name = NULL;
38+
char *last = prev ? &prev->name : NULL;
39+
40+
while (p) {
41+
if (!last || sce_paf_private_strcmp(&p->name, last) > 0) {
42+
if(!name || sce_paf_private_strcmp(&p->name, name) < 0) {
43+
name = &p->name;
44+
newest = p;
45+
}
4646
}
47+
48+
p = p->next;
4749
}
4850

49-
p = p->next;
51+
} else {
52+
u64 time = 0;
53+
u64 last = prev ? prev->mtime : (u64)-1;
54+
55+
while (p) {
56+
if (p->mtime < last) {
57+
if (p->mtime > time) {
58+
time = p->mtime;
59+
newest = p;
60+
}
61+
}
62+
63+
p = p->next;
64+
}
5065
}
5166

5267
return newest;
5368
}
5469

55-
void ClearCategories(Category *head[], int location) {
70+
void ClearCategories(Category *head[], int location)
71+
{
5672
Category *next;
5773
Category *p = (void *) head[location];
5874

@@ -65,7 +81,8 @@ void ClearCategories(Category *head[], int location) {
6581
head[location] = NULL;
6682
}
6783

68-
int CountCategories(Category *head[], int location) {
84+
int CountCategories(Category *head[], int location)
85+
{
6986
int i = 0;
7087
Category *p = (void *) head[location];
7188

@@ -77,7 +94,8 @@ int CountCategories(Category *head[], int location) {
7794
return i;
7895
}
7996

80-
int AddCategory(Category *head[], const char *category, u64 mtime, int location) {
97+
int AddCategory(Category *head[], const char *category, u64 mtime, int location)
98+
{
8199
Category *p, *category_entry;
82100

83101
while (1) {
@@ -117,7 +135,8 @@ int AddCategory(Category *head[], const char *category, u64 mtime, int location)
117135
return 0;
118136
}
119137

120-
void DelCategory(Category *head[], char *category, int location) {
138+
void DelCategory(Category *head[], char *category, int location)
139+
{
121140
Category *prev = NULL;
122141
Category *p = (Category *) head[location];
123142

@@ -135,7 +154,8 @@ void DelCategory(Category *head[], char *category, int location) {
135154
}
136155
}
137156

138-
Category *FindCategory(Category *head[], const char *category, int location) {
157+
Category *FindCategory(Category *head[], const char *category, int location)
158+
{
139159
Category *p = (Category *) head[location];
140160
while(p) {
141161
if (sce_paf_private_strcmp(&p->name, category) == 0) {
@@ -146,7 +166,8 @@ Category *FindCategory(Category *head[], const char *category, int location) {
146166
return p;
147167
}
148168

149-
int is_game_folder(const char *base, const char *path) {
169+
int is_game_folder(const char *base, const char *path)
170+
{
150171
SceIoStat stat;
151172
char buffer[256];
152173

@@ -160,7 +181,8 @@ int is_game_folder(const char *base, const char *path) {
160181
return 0;
161182
}
162183

163-
int has_directories(const char *base, const char *path) {
184+
int has_directories(const char *base, const char *path)
185+
{
164186
SceIoDirent dir;
165187
char buffer[256];
166188
int ret = 0;
@@ -185,7 +207,8 @@ int has_directories(const char *base, const char *path) {
185207
return ret;
186208
}
187209

188-
void IndexCategories(Category *head[], const char *path, int location) {
210+
void IndexCategories(Category *head[], const char *path, int location)
211+
{
189212
SceIoDirent dir;
190213
SceUID fd;
191214
u64 mtime;
@@ -215,7 +238,7 @@ void IndexCategories(Category *head[], const char *path, int location) {
215238
if(has_directories(full_path, dir.d_name) > 0) {
216239
match = 1;
217240
}
218-
}else if(config.prefix && sce_paf_private_strncmp(dir.d_name, "CAT_", 4) == 0) {
241+
} else if(config.prefix && sce_paf_private_strncmp(dir.d_name, "CAT_", 4) == 0) {
219242
if(has_directories(full_path, dir.d_name) > 0) {
220243
sce_paf_private_strcpy(dir.d_name, dir.d_name + 4);
221244
match = 1;

config.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
#include "logger.h"
2424

2525
CategoryConfig config;
26-
static CategoryConfig prev_conf = {-1, -1, -1, -1};
26+
static CategoryConfig prev_conf = {-1, -1, -1, -1, -1};
2727

2828
extern int model;
2929

3030
char filebuf[32];
3131

32-
int load_config() {
32+
int load_config()
33+
{
3334
int read;
3435
SceUID fd;
3536
if(sce_paf_private_memcmp(&config, &prev_conf, sizeof(CategoryConfig)) != 0) {
@@ -50,14 +51,15 @@ int load_config() {
5051
return 1;
5152
}
5253

53-
int save_config() {
54+
int save_config()
55+
{
5456
int written;
5557
SceUID fd;
5658
int reset;
5759
char device[12];
5860

5961
if(sce_paf_private_memcmp(&config, &prev_conf, sizeof(CategoryConfig)) != 0) {
60-
if(prev_conf.mode != config.mode || prev_conf.prefix != config.prefix || prev_conf.uncategorized != config.uncategorized) {
62+
if(prev_conf.mode != config.mode || prev_conf.prefix != config.prefix || prev_conf.uncategorized != config.uncategorized || prev_conf.catsort != config.catsort) {
6163
reset = 1;
6264
} else {
6365
reset = 0;

config.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef struct {
2727
u32 prefix;
2828
u32 uncategorized;
2929
u32 selection;
30+
u32 catsort;
3031
} CategoryConfig;
3132

3233
enum uncat {

context.c

+12-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ static void *xmb_arg0, *xmb_arg1;
4545

4646
static int context_action_arg[2];
4747

48-
int PatchExecuteActionForContext(int *action, int *action_arg) {
48+
int PatchExecuteActionForContext(int *action, int *action_arg)
49+
{
4950
int location;
5051
int uncategorized;
5152

@@ -97,7 +98,8 @@ int PatchExecuteActionForContext(int *action, int *action_arg) {
9798
return -1;
9899
}
99100

100-
int PatchAddVshItemForContext(void *arg, int topitem, SceVshItem *item, int location) {
101+
int PatchAddVshItemForContext(void *arg, int topitem, SceVshItem *item, int location)
102+
{
101103
u32 index = 0;
102104
int uncategorized;
103105

@@ -160,14 +162,16 @@ int PatchAddVshItemForContext(void *arg, int topitem, SceVshItem *item, int loca
160162
// return OnMenuListScrollIn(arg0, arg1);
161163
//}
162164

163-
int OnXmbPushPatched(void *arg0, void *arg1) {
165+
int OnXmbPushPatched(void *arg0, void *arg1)
166+
{
164167
kprintf("called\n");
165168
xmb_arg0 = arg0;
166169
xmb_arg1 = arg1;
167170
return OnXmbPush(arg0, arg1);
168171
}
169172

170-
int OnXmbContextMenuPatched(void *arg0, void *arg1) {
173+
int OnXmbContextMenuPatched(void *arg0, void *arg1)
174+
{
171175
kprintf("called, global_pos: %i\n", global_pos);
172176
context_gamecats = 0;
173177
if (original_item[global_pos]) {
@@ -177,7 +181,8 @@ int OnXmbContextMenuPatched(void *arg0, void *arg1) {
177181
return OnXmbContextMenu(arg0, arg1);
178182
}
179183

180-
void PatchGetBackupVshItemForContext(SceVshItem *item, SceVshItem *res) {
184+
void PatchGetBackupVshItemForContext(SceVshItem *item, SceVshItem *res)
185+
{
181186
kprintf("id: %i, action_arg: %i\n", item->id, item->action_arg);
182187
int location = get_location(item->action_arg);
183188
if(location != INVALID && item->id == vsh_id[location]) {
@@ -189,7 +194,8 @@ void PatchGetBackupVshItemForContext(SceVshItem *item, SceVshItem *res) {
189194
}
190195
}
191196

192-
void PatchVshmainForContext(u32 text_addr) {
197+
void PatchVshmainForContext(u32 text_addr)
198+
{
193199
OnXmbPush = redir2stub(text_addr+patches.OnXmbPush[patch_index], xmb_push_stub, OnXmbPushPatched);
194200
OnXmbContextMenu = redir2stub(text_addr+patches.OnXmbContextMenu[patch_index], xmb_context_stub, OnXmbContextMenuPatched);
195201
//OnMenuListScrollIn = redir2stub(text_addr+patches.OnMenuListScrollIn[patch_index], menu_scroll_stub, OnMenuListScrollInPatched);

filter.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static char *filter_data = NULL;
2929
static SceSize filter_size;
3030
static int counter;
3131

32-
int check_filter(const char *str) {
32+
int check_filter(const char *str)
33+
{
3334
int c = counter;
3435
char *buf = filter_data;
3536

@@ -52,7 +53,8 @@ int check_filter(const char *str) {
5253
return 0;
5354
}
5455

55-
static int split_filters() {
56+
static int split_filters()
57+
{
5658
int count = 0;
5759
for(u32 i = 0; i < filter_size; i++) {
5860
if(filter_data[i] == '\r') {
@@ -67,14 +69,16 @@ static int split_filters() {
6769
return count;
6870
}
6971

70-
void unload_filter() {
72+
void unload_filter()
73+
{
7174
if(filter_data != NULL) {
7275
sce_paf_private_free(filter_data);
7376
filter_data = NULL;
7477
}
7578
}
7679

77-
int load_filter() {
80+
int load_filter()
81+
{
7882
SceUID fd;
7983

8084
if(filter_data != NULL) {

0 commit comments

Comments
 (0)