-
Notifications
You must be signed in to change notification settings - Fork 0
/
conf.c
415 lines (400 loc) · 8.24 KB
/
conf.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
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#include "config.h"
#include <string.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include "display.h"
#include "version.h"
#include "conf.h"
static char conf_filename[256];
extern void conf_set_file(const char * filename)
{
strcpy(conf_filename, filename);
}
extern void conf_get_keyname(dword key, char * res)
{
res[0] = 0;
if((key & PSP_CTRL_CIRCLE) > 0)
strcat(res, "○");
if((key & PSP_CTRL_CROSS) > 0)
{
if(res[0] != 0)
strcat(res, "+×");
else
strcat(res, "×");
}
if((key & PSP_CTRL_SQUARE) > 0)
{
if(res[0] != 0)
strcat(res, "+□");
else
strcat(res, "□");
}
if((key & PSP_CTRL_TRIANGLE) > 0)
{
if(res[0] != 0)
strcat(res, "+△");
else
strcat(res, "△");
}
if((key & PSP_CTRL_LTRIGGER) > 0)
{
if(res[0] != 0)
strcat(res, "+L");
else
strcat(res, "L");
}
if((key & PSP_CTRL_RTRIGGER) > 0)
{
if(res[0] != 0)
strcat(res, "+R");
else
strcat(res, "R");
}
if((key & PSP_CTRL_UP) > 0)
{
if(res[0] != 0)
strcat(res, "+↑");
else
strcat(res, "↑");
}
if((key & PSP_CTRL_DOWN) > 0)
{
if(res[0] != 0)
strcat(res, "+↓");
else
strcat(res, "↓");
}
if((key & PSP_CTRL_LEFT) > 0)
{
if(res[0] != 0)
strcat(res, "+←");
else
strcat(res, "←");
}
if((key & PSP_CTRL_RIGHT) > 0)
{
if(res[0] != 0)
strcat(res, "+→");
else
strcat(res, "→");
}
if((key & PSP_CTRL_SELECT) > 0)
{
if(res[0] != 0)
strcat(res, "+SELECT");
else
strcat(res, "SELECT");
}
if((key & PSP_CTRL_START) > 0)
{
if(res[0] != 0)
strcat(res, "+START");
else
strcat(res, "START");
}
}
static void conf_default(p_conf conf)
{
memset(conf, 0, sizeof(t_conf));
conf->forecolor = 0xFFFFFFFF;
conf->bgcolor = 0;
conf->rowspace = 2;
conf->wordspace = 0;
conf->borderspace = 0;
conf->vertread = 0;
conf->infobar = true;
conf->rlastrow = false;
conf->autobm = true;
conf->encode = conf_encode_gbk;
conf->fit = conf_fit_none;
conf->imginfobar = false;
conf->scrollbar = false;
conf->scale = 0;
conf->rotate = conf_rotate_0;
conf->txtkey[0] = PSP_CTRL_SQUARE;
conf->txtkey[1] = PSP_CTRL_LTRIGGER;
conf->txtkey[2] = PSP_CTRL_RTRIGGER;
conf->txtkey[3] = PSP_CTRL_UP | PSP_CTRL_CIRCLE;
conf->txtkey[4] = PSP_CTRL_DOWN | PSP_CTRL_CIRCLE;
conf->txtkey[5] = PSP_CTRL_LEFT | PSP_CTRL_CIRCLE;
conf->txtkey[6] = PSP_CTRL_RIGHT | PSP_CTRL_CIRCLE;
conf->txtkey[7] = PSP_CTRL_LTRIGGER | PSP_CTRL_CIRCLE;
conf->txtkey[8] = PSP_CTRL_RTRIGGER | PSP_CTRL_CIRCLE;
conf->txtkey[9] = 0;
conf->txtkey[10] = 0;
conf->txtkey[11] = PSP_CTRL_CROSS;
conf->imgkey[0] = PSP_CTRL_LTRIGGER;
conf->imgkey[1] = PSP_CTRL_RTRIGGER;
conf->imgkey[2] = PSP_CTRL_TRIANGLE;
conf->imgkey[3] = PSP_CTRL_UP | PSP_CTRL_CIRCLE;
conf->imgkey[4] = PSP_CTRL_DOWN | PSP_CTRL_CIRCLE;
conf->imgkey[5] = PSP_CTRL_LEFT | PSP_CTRL_CIRCLE;
conf->imgkey[6] = PSP_CTRL_RIGHT | PSP_CTRL_CIRCLE;
conf->imgkey[7] = PSP_CTRL_SQUARE;
conf->imgkey[8] = PSP_CTRL_CIRCLE;
conf->imgkey[9] = PSP_CTRL_CROSS;
conf->imgkey[10] = PSP_CTRL_LTRIGGER | PSP_CTRL_CIRCLE;
conf->flkey[0] = PSP_CTRL_CIRCLE;
conf->flkey[1] = PSP_CTRL_LTRIGGER;
conf->flkey[2] = PSP_CTRL_RTRIGGER;
conf->flkey[3] = PSP_CTRL_CROSS;
conf->flkey[4] = 0;
conf->flkey[5] = PSP_CTRL_TRIANGLE;
conf->flkey[6] = PSP_CTRL_SQUARE;
conf->bicubic = true;
conf->mp3encode = conf_encode_gbk;
conf->mp3cycle = conf_cycle_repeat;
conf->isreading = false;
conf->slideinterval = 5;
conf->hprmctrl = false;
conf->grayscale = 0;
conf->showhidden = true;
conf->showunknown = true;
conf->showfinfo = true;
conf->allowdelete = true;
conf->arrange = conf_arrange_ext;
conf->enableusb = true;
conf->viewpos = conf_viewpos_leftup;
conf->imgmvspd = 8;
conf->imgpaging = conf_imgpaging_direct;
conf->fontsize = 0;
conf->bookfontsize = 0;
conf->reordertxt = false;
conf->pagetonext = false;
conf->thumb = conf_thumb_scroll;
conf->imgpagereserve = 0;
#if defined(ENABLE_MUSIC) && defined(ENABLE_LYRIC)
conf->lyricex = 1;
#else
conf->lyricex = 0;
#endif
conf->savesucc = false;
conf->autoplay = false;
conf->usettf = 0;
}
extern bool conf_load(p_conf conf)
{
conf_default(conf);
int fd = sceIoOpen(conf_filename, PSP_O_RDWR, 0777);
if(fd < 0)
return false;
sceIoRead(fd, conf, sizeof(t_conf));
#ifndef ENABLE_USB
conf->enableusb = false;
#endif
#ifndef ENABLE_BG
strcpy(conf->bgfile, "");
#endif
#ifndef ENABLE_MUSIC
conf->autoplay = false;
conf->hprmctrl = true;
conf->lyricex = 0;
#else
#ifndef ENABLE_LYRIC
conf->lyricex = 0;
#endif
#endif
if(conf->confver < EREADER_VERSION_NUM)
{
if(conf->confver < 0x00060000)
{
conf->imgkey[10] = PSP_CTRL_LTRIGGER | PSP_CTRL_CIRCLE;
conf->bicubic = true;
}
if(conf->confver < 0x00080000)
{
conf->forecolor = RGB_16to32(conf->forecolor);
conf->bgcolor = RGB_16to32(conf->bgcolor);
}
if(conf->confver < 0x00090700)
conf->imgkey[11] = PSP_CTRL_RTRIGGER | PSP_CTRL_CIRCLE;
if(conf->confver < 0x01010000)
{
if(conf->fit == 2)
conf->fit = 3;
else if(conf->fit == 3)
conf->fit = 5;
}
if(conf->confver < 0x01030000)
conf->savesucc = true;
conf->confver = EREADER_VERSION_NUM;
}
if(!conf->savesucc)
{
strcpy(conf->path, "ms0:/");
strcpy(conf->shortpath, "ms0:/");
strcpy(conf->lastfile, "");
strcpy(conf->bgfile, "");
conf->isreading = false;
}
else
conf->savesucc = false;
sceIoLseek32(fd, 0, PSP_SEEK_SET);
sceIoWrite(fd, conf, sizeof(t_conf));
sceIoClose(fd);
conf->savesucc = true;
return true;
}
extern bool conf_save(p_conf conf)
{
int fd = sceIoOpen(conf_filename, PSP_O_CREAT | PSP_O_RDWR, 0777);
if(fd < 0)
return false;
sceIoWrite(fd, conf, sizeof(t_conf));
sceIoClose(fd);
return true;
}
extern const char * conf_get_encodename(t_conf_encode encode)
{
switch(encode)
{
case conf_encode_gbk:
return "GBK ";
case conf_encode_big5:
return "BIG5";
case conf_encode_sjis:
return "SJIS";
case conf_encode_ucs:
return "UCS ";
case conf_encode_utf8:
return "UTF-8";
default:
return "";
}
}
extern const char * conf_get_fitname(t_conf_fit fit)
{
switch(fit)
{
case conf_fit_none:
return "原始大小";
break;
case conf_fit_width:
return "适应宽度";
break;
case conf_fit_dblwidth:
return "适应两倍宽度";
break;
case conf_fit_height:
return "适应高度";
break;
case conf_fit_dblheight:
return "适应两倍高度";
break;
case conf_fit_custom:
return "";
break;
default:
return "";
break;
}
}
extern const char * conf_get_cyclename(t_conf_cycle cycle)
{
switch(cycle)
{
case conf_cycle_single:
return "顺序播放";
case conf_cycle_repeat:
return "循环播放";
case conf_cycle_repeat_one:
return "循环单曲";
case conf_cycle_random:
return "随机播放";
default:
return "";
}
}
extern const char * conf_get_arrangename(t_conf_arrange arrange)
{
switch(arrange)
{
case conf_arrange_ext:
return "按扩展名";
break;
case conf_arrange_name:
return "按文件名";
break;
case conf_arrange_size:
return "按文件大小";
break;
case conf_arrange_ctime:
return "按创建时间";
break;
case conf_arrange_mtime:
return "按修改时间";
break;
default:
return "";
}
}
extern const char * conf_get_viewposname(t_conf_viewpos viewpos)
{
switch(viewpos)
{
case conf_viewpos_leftup:
return "左上";
case conf_viewpos_midup:
return "中上";
case conf_viewpos_rightup:
return "右上";
case conf_viewpos_leftmid:
return "左中";
case conf_viewpos_midmid:
return "正中";
case conf_viewpos_rightmid:
return "右中";
case conf_viewpos_leftdown:
return "左下";
case conf_viewpos_middown:
return "中下";
case conf_viewpos_rightdown:
return "右下";
default:
return "";
}
}
extern const char * conf_get_imgpagingname(t_conf_imgpaging imgpaging)
{
switch(imgpaging)
{
case conf_imgpaging_direct:
return "直接翻页";
case conf_imgpaging_updown:
return "先上下卷动";
case conf_imgpaging_leftright:
return "先左右卷动";
default:
return "";
}
}
extern const char * conf_get_thumbname(t_conf_thumb thumb)
{
switch(thumb)
{
case conf_thumb_none:
return "不显示";
case conf_thumb_scroll:
return "卷动时显示";
case conf_thumb_always:
return "总是显示";
default:
return "";
}
}
extern const char * conf_get_infobarname(t_conf_infobar infobar)
{
switch(infobar)
{
case conf_infobar_none:
return "不显示";
case conf_infobar_info:
return "阅读信息";
#ifdef ENABLE_LYRIC
case conf_infobar_lyric:
return "歌词";
#endif
default:
return "";
}
}