source: ps2launchargs/source/uLaunchELF/hdd.c@ 1155

Last change on this file since 1155 was 1101, checked in by iritscen, 7 years ago

Added following to ps2launchargs:\n-Source code.\n-DLL needed to run ps2client.\n-Instructions for building uLaunchELF.

  • Property svn:executable set to *
File size: 35.6 KB
RevLine 
[1101]1//--------------------------------------------------------------
2//File name: hdd.c
3//--------------------------------------------------------------
4#include "launchelf.h"
5
6#define MAX_PARTGB 128 //Partition MAX in GB
7#define MAX_PARTMB (MAX_PARTGB*1024) //Partition MAX in MB
8
9typedef struct{
10 char Name[MAX_NAME];
11 s64 RawSize;
12 s64 TotalSize;
13 s64 FreeSize;
14 s64 UsedSize;
15 int FsGroup;
16 GameInfo Game; //Intended for HDL game info, implemented through IRX module
17 int Count;
18 int Treatment;
19} PARTYINFO;
20
21enum {//For Treatment codes
22 TREAT_PFS = 0, //PFS partition for normal file access
23 TREAT_HDL_RAW, //HDL game partition before reading GameInfo data
24 TREAT_HDL_GAME, //HDL game partition after reading GameInfo data
25 TREAT_SYSTEM, //System partition that must never be modified (__mbr)
26 TREAT_NOACCESS //Inaccessible partition (but can be deleted)
27};
28
29enum {//For menu commands
30 CREATE = 0,
31 REMOVE,
32 RENAME,
33 EXPAND,
34 FORMAT,
35 NUM_MENU
36};
37
38#define SECTORS_PER_MB 2048 //Divide by this to convert from sector count to MB
39#define MB 1048576
40
41PARTYINFO PartyInfo[MAX_PARTITIONS];
42int numParty;
43int hddSize, hddFree, hddFreeSpace, hddUsed;
44int hddConnected, hddFormated;
45
46char DbgMsg[MAX_TEXT_LINE*30];
47
48//--------------------------------------------------------------
49///*
50void DebugDisp(char *Message)
51{
52 int done;
53
54 for(done=0; done==0;){
55 nonDialog(Message);
56 drawLastMsg();
57 if(readpad() && new_pad){
58 done=1;
59 }
60 }
61}
62//*/
63//------------------------------
64//endfunc DebugDisp
65//--------------------------------------------------------------
66/*
67void DebugDispStat(iox_dirent_t *p)
68{
69 char buf[MAX_TEXT_LINE*24]="";
70 int stp, pos, i;
71 unsigned int *ip = &p->stat.private_0;
72 int *cp = (int *) p->stat.ctime;
73 int *ap = (int *) p->stat.atime;
74 int *mp = (int *) p->stat.mtime;
75
76 pos = 0;
77 sprintf(buf+pos,"dirent.name == \"%s\"\n%n", p->name, &stp); pos+=stp;
78 sprintf(buf+pos,"dirent.unknown == %d\n%n", p->unknown, &stp); pos+=stp;
79 sprintf(buf+pos," mode == 0x%08X, attr == 0x%08X\n%n",p->stat.mode,p->stat.attr,&stp); pos+=stp;
80 sprintf(buf+pos,"hisize == 0x%08X, size == 0x%08X\n%n",p->stat.hisize,p->stat.size,&stp); pos+=stp;
81 sprintf(buf+pos,"ctime == 0x%08X%08X \n%n", cp[1],cp[0], &stp); pos+=stp;
82 sprintf(buf+pos,"atime == 0x%08X%08X\n%n", ap[1],ap[0], &stp); pos+=stp;
83 sprintf(buf+pos,"mtime == 0x%08X%08X\n%n", mp[1],mp[0], &stp); pos+=stp;
84 for(i=0; i<6; i++){
85 sprintf(buf+pos,"private_%d == 0x%08X\n%n", i, ip[i], &stp); pos+=stp;
86 }
87 DebugDisp(buf);
88}
89//*/
90//------------------------------
91//endfunc DebugDispStat
92//--------------------------------------------------------------
93void GetHddInfo(void)
94{
95 iox_dirent_t infoDirEnt;
96 int rv, hddFd=0, partitionFd, i, Treat;
97 s64 size=0;
98 char tmp[MAX_PATH];
99 char dbgtmp[MAX_PATH];
100 s64 zoneFree, zoneSize;
101 char pfs_str[6];
102
103 strcpy(pfs_str, "pfs0:");
104 hddSize=0, hddFree=0, hddFreeSpace=0, hddUsed=0;
105 hddConnected=0, hddFormated=0;
106 numParty=0;
107
108 drawMsg(LNG(Reading_HDD_Information));
109
110 if(hddCheckPresent() < 0){
111 hddConnected=0;
112 goto end;
113 }else
114 hddConnected=1;
115
116 if(hddCheckFormatted() < 0){
117 hddFormated=0;
118 goto end;
119 }else
120 hddFormated=1;
121
122 size =((s64) fileXioDevctl("hdd0:", HDDCTL_TOTAL_SECTORS, NULL, 0, NULL, 0))*512;
123 hddSize = (size / MB);
124
125 if((hddFd = fileXioDopen("hdd0:")) < 0) return;
126
127 while(fileXioDread(hddFd, &infoDirEnt) > 0){ //Starts main while loop
128 int found_size =
129 ((((s64) infoDirEnt.stat.hisize)<<32) + infoDirEnt.stat.size) / MB;
130
131 //DebugDispStat(&infoDirEnt);
132
133 if(infoDirEnt.stat.mode == FS_TYPE_EMPTY)
134 continue;
135 hddUsed += found_size;
136 for(i=0; i<numParty; i++) //Check with previous partitions
137 if(!strcmp(infoDirEnt.name,PartyInfo[i].Name))
138 break;
139 if(i<numParty) { //found another reference to an old name
140 PartyInfo[i].RawSize += found_size; //Add new segment to old size
141 } else { //Starts clause for finding brand new name for PartyInfo[numParty]
142 sprintf(dbgtmp, "%s \"%s\"", LNG(Found), infoDirEnt.name);
143 drawMsg(dbgtmp);
144
145 memset(&PartyInfo[numParty], 0, sizeof(PARTYINFO));
146 strcpy(PartyInfo[numParty].Name, infoDirEnt.name);
147 PartyInfo[numParty].RawSize = found_size; //Store found segment size
148 PartyInfo[numParty].Count = numParty;
149
150 if(infoDirEnt.stat.mode == 0x0001) //New test of partition type by 'mode'
151 Treat = TREAT_SYSTEM;
152 else if(!strncmp(infoDirEnt.name,"PP.HDL.",7))
153 Treat = TREAT_HDL_RAW;
154 else {
155 sprintf(tmp, "hdd0:%s", infoDirEnt.name);
156 partitionFd = fileXioOpen(tmp, O_RDONLY, 0);
157 if(partitionFd < 0){
158 Treat = TREAT_NOACCESS; //needed for Sony-style protected partitions
159 } else {
160 fileXioClose(partitionFd);
161 Treat = TREAT_PFS;
162 }
163 }
164 PartyInfo[numParty].Treatment = Treat;
165
166 if((PartyInfo[numParty].Name[0] == '_') && (PartyInfo[numParty].Name[1] == '_'))
167 PartyInfo[numParty].FsGroup = FS_GROUP_SYSTEM;
168 else if(PartyInfo[numParty].Name[0] == FS_COMMON_PREFIX)
169 PartyInfo[numParty].FsGroup = FS_GROUP_COMMON;
170 else
171 PartyInfo[numParty].FsGroup = FS_GROUP_APPLICATION;
172
173 if(Treat == TREAT_PFS){ //Starts clause for TREAT_PFS
174 sprintf(tmp, "hdd0:%s", PartyInfo[numParty].Name);
175 partitionFd = fileXioOpen(tmp, O_RDONLY, 0);
176
177 for(i = 0, size = 0; i < infoDirEnt.stat.private_0 + 1; i++)
178 {
179 rv = fileXioIoctl2(partitionFd, HDDIO_GETSIZE, &i, 4, NULL, 0);
180 size += rv * 512 / 1024 / 1024;
181 }
182 PartyInfo[numParty].TotalSize=size;
183
184 fileXioClose(partitionFd);
185
186 mountParty(tmp);
187 pfs_str[3] = '0'+latestMount;
188 zoneFree = fileXioDevctl(pfs_str, PFSCTL_GET_ZONE_FREE, NULL,0,NULL,0);
189 zoneSize = fileXioDevctl(pfs_str, PFSCTL_GET_ZONE_SIZE, NULL,0,NULL,0);
190 unmountParty(latestMount);
191
192 PartyInfo[numParty].FreeSize = zoneFree*zoneSize / MB;
193 PartyInfo[numParty].UsedSize = PartyInfo[numParty].TotalSize-PartyInfo[numParty].FreeSize;
194
195 } //Ends clause for TREAT_PFS
196
197 numParty++;
198 } //Ends clause for finding brand new name for PartyInfo[numParty]
199 } //ends main while loop
200 fileXioDclose(hddFd);
201 hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area
202 hddFree = (hddFreeSpace*100)/hddSize; //free space percentage
203
204end:
205 drawMsg(LNG(HDD_Information_Read));
206
207 WaitTime=Timer();
208 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
209}
210//------------------------------
211//endfunc GetHddInfo
212//--------------------------------------------------------------
213int sizeSelector(int size)
214{
215 int x, y;
216 int saveSize=size;
217 float scrollBar;
218 char c[MAX_PATH];
219 int event, post_event=0;
220
221 int mSprite_X1 = SCREEN_WIDTH/2-12*FONT_WIDTH; //Left edge of sprite
222 int mSprite_Y1 = SCREEN_HEIGHT/2-3*FONT_HEIGHT; //Top edge of sprite
223 int mSprite_X2 = SCREEN_WIDTH/2+12*FONT_WIDTH; //Right edge of sprite
224 int mSprite_Y2 = SCREEN_HEIGHT/2+3*FONT_HEIGHT; //Bottom edge of sprite
225
226 event = 1; //event = initial entry
227 while(1){
228 //Pad response section
229 waitPadReady(0, 0);
230 if(readpad()){
231 if(new_pad & PAD_RIGHT){
232 event |= 2; //event |= valid pad command
233 if((size += 128)>MAX_PARTMB)
234 size = MAX_PARTMB;
235 }else if(new_pad & PAD_LEFT){
236 event |= 2; //event |= valid pad command
237 if((size -= 128)<saveSize)
238 size = saveSize;
239 }else if(new_pad & PAD_R1){
240 event |= 2; //event |= valid pad command
241 if(size<1024)
242 size=1024;
243 else{
244 if((size += 1024)>MAX_PARTMB)
245 size = MAX_PARTMB;
246 }
247 }else if(new_pad & PAD_L1){
248 event |= 2; //event |= valid pad command
249 if((size -= 1024)<saveSize)
250 size = saveSize;
251 }else if(new_pad & PAD_R2){
252 event |= 2; //event |= valid pad command
253 if(size<10240)
254 size=10240;
255 else{
256 if((size += 10240)>MAX_PARTMB)
257 size = MAX_PARTMB;
258 }
259 }else if(new_pad & PAD_L2){
260 event |= 2; //event |= valid pad command
261 if((size -= 10240)<saveSize)
262 size = saveSize;
263 }else if((new_pad & PAD_TRIANGLE)
264 || (!swapKeys && new_pad & PAD_CROSS)
265 || (swapKeys && new_pad & PAD_CIRCLE) ){
266 return -1;
267 }else if((swapKeys && new_pad & PAD_CROSS)
268 || (!swapKeys && new_pad & PAD_CIRCLE) ){
269 event |= 2; //event |= valid pad command
270 break;
271 }
272 }
273
274 if(event||post_event){ //NB: We need to update two frame buffers per event
275
276 //Display section
277 drawPopSprite(setting->color[0],
278 mSprite_X1, mSprite_Y1,
279 mSprite_X2, mSprite_Y2);
280 drawFrame(mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2, setting->color[1]);
281
282 sprintf(c, "%d %s", size, LNG(MB));
283 printXY(c, mSprite_X1+12*FONT_WIDTH-(strlen(c)*FONT_WIDTH)/2,
284 mSprite_Y1+FONT_HEIGHT, setting->color[3], TRUE, 0);
285 drawFrame(mSprite_X1+7*FONT_WIDTH, mSprite_Y1+FONT_HEIGHT/2,
286 mSprite_X2-7*FONT_WIDTH, mSprite_Y1+FONT_HEIGHT*2+FONT_HEIGHT/2, setting->color[1]);
287
288 //RA NB: Next line assumes a scrollbar 19 characters wide (see below)
289 sprintf(c, "128%s %3d%s", LNG(MB), MAX_PARTGB, LNG(GB));
290 printXY(c, mSprite_X1+FONT_WIDTH, mSprite_Y1+FONT_HEIGHT*3, setting->color[3], TRUE, 0);
291
292 drawOpSprite(setting->color[1],
293 mSprite_X1+2*FONT_WIDTH+FONT_WIDTH/2, mSprite_Y1+FONT_HEIGHT*5-LINE_THICKNESS+1,
294 mSprite_X2-2*FONT_WIDTH-FONT_WIDTH/2, mSprite_Y1+FONT_HEIGHT*5);
295
296
297 //RA NB: Next line sets scroll position on a bar 19 chars wide (see above)
298 scrollBar = (size*(19*FONT_WIDTH)/(MAX_PARTMB-128));
299
300 drawOpSprite(setting->color[1],
301 mSprite_X1+2*FONT_WIDTH+FONT_WIDTH/2+(int)scrollBar-LINE_THICKNESS+1,
302 mSprite_Y1+FONT_HEIGHT*5-FONT_HEIGHT/2,
303 mSprite_X1+2*FONT_WIDTH+FONT_WIDTH/2+(int)scrollBar,
304 mSprite_Y1+FONT_HEIGHT*5+FONT_HEIGHT/2);
305
306 //Tooltip section
307 x = SCREEN_MARGIN;
308 y = Menu_tooltip_y;
309 drawSprite(setting->color[0],
310 0, y-1,
311 SCREEN_WIDTH, y+16);
312 if (swapKeys)
313 sprintf(c, "ÿ1:%s ÿ0:%s ÿ3:%s ÿ</ÿ::-/+128%s L1/R1:-/+1%s L2/R2:-/+10%s",
314 LNG(OK), LNG(Cancel), LNG(Back), LNG(MB), LNG(GB), LNG(GB));
315 else
316 sprintf(c, "ÿ0:%s ÿ1:%s ÿ3:%s ÿ</ÿ::-/+128%s L1/R1:-/+1%s L2/R2:-/+10%s",
317 LNG(OK), LNG(Cancel), LNG(Back), LNG(MB), LNG(GB), LNG(GB));
318 printXY(c, x, y, setting->color[2], TRUE, 0);
319 }//ends if(event||post_event)
320 drawScr();
321 post_event = event;
322 event = 0;
323 }//ends while
324 return size;
325}
326//------------------------------
327//endfunc sizeSelector
328//--------------------------------------------------------------
329int MenuParty(PARTYINFO Info)
330{
331 u64 color;
332 char enable[NUM_MENU], tmp[64];
333 int x, y, i, sel;
334 int event, post_event=0;
335
336 int menu_len=strlen(LNG(Create))>strlen(LNG(Remove))?
337 strlen(LNG(Create)):strlen(LNG(Remove));
338 menu_len=strlen(LNG(Rename))>menu_len? strlen(LNG(Rename)):menu_len;
339 menu_len=strlen(LNG(Expand))>menu_len? strlen(LNG(Expand)):menu_len;
340 menu_len=strlen(LNG(Format))>menu_len? strlen(LNG(Format)):menu_len;
341
342 int menu_ch_w = menu_len+1; //Total characters in longest menu string
343 int menu_ch_h = NUM_MENU; //Total number of menu lines
344 int mSprite_Y1 = 64; //Top edge of sprite
345 int mSprite_X2 = SCREEN_WIDTH-35; //Right edge of sprite
346 int mSprite_X1 = mSprite_X2-(menu_ch_w+3)*FONT_WIDTH; //Left edge of sprite
347 int mSprite_Y2 = mSprite_Y1+(menu_ch_h+1)*FONT_HEIGHT; //Bottom edge of sprite
348
349 unmountAll(); //unmount all uLE-used mountpoints
350 unmountParty(0); //unconditionally unmount primary mountpoint
351 unmountParty(1); //unconditionally unmount secondary mountpoint
352
353 memset(enable, TRUE, NUM_MENU);
354
355 if(Info.FsGroup==FS_GROUP_SYSTEM){
356 enable[REMOVE] = FALSE;
357 enable[RENAME] = FALSE;
358 enable[EXPAND] = FALSE;
359 }
360 if(Info.FsGroup==FS_GROUP_APPLICATION){
361 enable[RENAME] = FALSE;
362 }
363 if(Info.Treatment == TREAT_HDL_RAW){
364 enable[RENAME] = FALSE;
365 enable[EXPAND] = FALSE;
366 }
367 if(Info.Treatment == TREAT_HDL_GAME){
368 enable[RENAME] = TRUE;
369 enable[EXPAND] = FALSE;
370 }
371
372 for(sel=0; sel<NUM_MENU; sel++)
373 if(enable[sel]==TRUE) break;
374
375 event = 1; //event = initial entry
376 while(1){
377 //Pad response section
378 waitPadReady(0, 0);
379 if(readpad()){
380 if(new_pad & PAD_UP && sel<NUM_MENU){
381 event |= 2; //event |= valid pad command
382 do{
383 sel--;
384 if(sel<0) sel=NUM_MENU-1;
385 }while(!enable[sel]);
386 }else if(new_pad & PAD_DOWN && sel<NUM_MENU){
387 event |= 2; //event |= valid pad command
388 do{
389 sel++;
390 if(sel==NUM_MENU) sel=0;
391 }while(!enable[sel]);
392 }else if((new_pad & PAD_TRIANGLE)
393 || (!swapKeys && new_pad & PAD_CROSS)
394 || (swapKeys && new_pad & PAD_CIRCLE) ){
395 return -1;
396 }else if((swapKeys && new_pad & PAD_CROSS)
397 || (!swapKeys && new_pad & PAD_CIRCLE) ){
398 event |= 2; //event |= valid pad command
399 break;
400 }
401 }
402
403 if(event||post_event){ //NB: We need to update two frame buffers per event
404
405 //Display section
406 drawPopSprite(setting->color[0],
407 mSprite_X1, mSprite_Y1,
408 mSprite_X2, mSprite_Y2);
409 drawFrame(mSprite_X1, mSprite_Y1, mSprite_X2, mSprite_Y2, setting->color[1]);
410
411 for(i=0,y=mSprite_Y1+FONT_HEIGHT/2; i<NUM_MENU; i++){
412 if(i==CREATE) strcpy(tmp, LNG(Create));
413 else if(i==REMOVE) strcpy(tmp, LNG(Remove));
414 else if(i==RENAME) strcpy(tmp, LNG(Rename));
415 else if(i==EXPAND) strcpy(tmp, LNG(Expand));
416 else if(i==FORMAT) strcpy(tmp, LNG(Format));
417
418 if(enable[i]) color = setting->color[3];
419 else color = setting->color[1];
420
421 printXY(tmp, mSprite_X1+2*FONT_WIDTH, y, color, TRUE, 0);
422 y+=FONT_HEIGHT;
423 }
424 if(sel<NUM_MENU)
425 drawChar(LEFT_CUR, mSprite_X1+FONT_WIDTH, mSprite_Y1+(FONT_HEIGHT/2+sel*FONT_HEIGHT), setting->color[3]);
426
427 //Tooltip section
428 x = SCREEN_MARGIN;
429 y = Menu_tooltip_y;
430 drawSprite(setting->color[0],
431 0, y-1,
432 SCREEN_WIDTH, y+16);
433 if (swapKeys)
434 sprintf(tmp, "ÿ1:%s ÿ0:%s ÿ3:%s", LNG(OK), LNG(Cancel), LNG(Back));
435 else
436 sprintf(tmp, "ÿ0:%s ÿ1:%s ÿ3:%s", LNG(OK), LNG(Cancel), LNG(Back));
437 printXY(tmp, x, y, setting->color[2], TRUE, 0);
438 }//ends if(event||post_event)
439 drawScr();
440 post_event = event;
441 event = 0;
442 }//ends while
443 return sel;
444}
445//------------------------------
446//endfunc MenuParty
447//--------------------------------------------------------------
448int CreateParty(char *party, int size)
449{
450 int i, num=1, ret=0;
451 int remSize = size-2048;
452 char tmpName[MAX_ENTRY];
453 t_hddFilesystem hddFs[MAX_PARTITIONS];
454
455 drawMsg(LNG(Creating_New_Partition));
456
457 tmpName[0]=0;
458 sprintf(tmpName, "+%s", party);
459 for(i=0; i<MAX_PARTITIONS; i++){
460 if(!strcmp(PartyInfo[i].Name, tmpName)){
461 sprintf(tmpName, "+%s%d", party, num);
462 num++;
463 }
464 }
465 strcpy(party, tmpName+1);
466 if(remSize <= 0)
467 ret = hddMakeFilesystem(size, party, FS_GROUP_COMMON);
468 else{
469 ret = hddMakeFilesystem(2048, party, FS_GROUP_COMMON);
470 hddGetFilesystemList(hddFs, MAX_PARTITIONS);
471 for(i=0; i<MAX_PARTITIONS; i++){
472 if(!strcmp(hddFs[i].name, party))
473 ret = hddExpandFilesystem(&hddFs[i], remSize);
474 }
475 }
476
477 if(ret>0){
478 GetHddInfo();
479 drawMsg(LNG(New_Partition_Created));
480 }else{
481 drawMsg(LNG(Failed_Creating_New_Partition));
482 }
483
484 WaitTime=Timer();
485 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
486
487 return ret;
488}
489//------------------------------
490//endfunc CreateParty
491//--------------------------------------------------------------
492int RemoveParty(PARTYINFO Info)
493{
494 int i, ret=0;
495 char tmpName[MAX_ENTRY];
496
497 //printf("Remove Partition: %d\n", Info.Count);
498
499 drawMsg(LNG(Removing_Current_Partition));
500
501 sprintf(tmpName, "hdd0:%s", Info.Name);
502 ret = fileXioRemove(tmpName);
503
504 if(ret==0){
505 hddUsed -= Info.TotalSize;
506 hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area
507 hddFree = (hddFreeSpace*100)/hddSize; //free space percentage
508 numParty--;
509 if(Info.Count==numParty){
510 memset(&PartyInfo[numParty], 0, sizeof(PARTYINFO));
511 }else{
512 for(i=Info.Count; i<numParty; i++){
513 memset(&PartyInfo[i], 0, sizeof(PARTYINFO));
514 memcpy(&PartyInfo[i], &PartyInfo[i+1], sizeof(PARTYINFO));
515 PartyInfo[i].Count--;
516 }
517 memset(&PartyInfo[numParty], 0, sizeof(PARTYINFO));
518 }
519 drawMsg(LNG(Partition_Removed));
520 }else{
521 drawMsg(LNG(Failed_Removing_Current_Partition));
522 }
523
524 WaitTime=Timer();
525 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
526
527 return ret;
528}
529//------------------------------
530//endfunc RemoveParty
531//--------------------------------------------------------------
532int RenameParty(PARTYINFO Info, char *newName)
533{
534 int i, num=1, ret=0;
535 char in[MAX_ENTRY], out[MAX_ENTRY], tmpName[MAX_ENTRY];
536
537 //printf("Rename Partition: %d group: %d\n", Info.Count, Info.FsGroup);
538 drawMsg(LNG(Renaming_Partition));
539
540 in[0]=0;
541 out[0]=0;
542 tmpName[0]=0;
543 if(Info.FsGroup==FS_GROUP_APPLICATION){
544 sprintf(tmpName, "%s", newName);
545 if(!strcmp(Info.Name, tmpName))
546 goto end;
547 for(i=0; i<MAX_PARTITIONS; i++){
548 if(!strcmp(PartyInfo[i].Name, tmpName)){
549 sprintf(tmpName, "%s%d", newName, num);
550 num++;
551 }
552 }
553 strcpy(newName, tmpName);
554 sprintf(in, "hdd0:%s", Info.Name);
555 sprintf(out, "hdd0:%s", newName);
556 }else{ // FS_GROUP_COMMON
557 sprintf(tmpName, "+%s", newName);
558 if(!strcmp(Info.Name, tmpName))
559 goto end;
560 for(i=0; i<MAX_PARTITIONS; i++){
561 if(!strcmp(PartyInfo[i].Name, tmpName)){
562 sprintf(tmpName, "+%s%d", newName, num);
563 num++;
564 }
565 }
566 strcpy(newName, tmpName+1);
567 sprintf(in, "hdd0:%s", Info.Name);
568 sprintf(out, "hdd0:+%s", newName);
569 }
570
571 ret = fileXioRename(in, out);
572
573 if(ret==0){
574 if(Info.FsGroup==FS_GROUP_APPLICATION)
575 strcpy(PartyInfo[Info.Count].Name, newName);
576 else // FS_GROUP_COMMON
577 sprintf(PartyInfo[Info.Count].Name, "+%s", newName);
578 drawMsg(LNG(Partition_Renamed));
579 }else{
580 drawMsg(LNG(Failed_Renaming_Partition));
581 }
582
583 WaitTime=Timer();
584 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
585
586end:
587 return ret;
588}
589//------------------------------
590//endfunc RenameParty
591//--------------------------------------------------------------
592int RenameGame(PARTYINFO Info, char *newName)
593{
594 //printf("Rename Game: %d\n", Info.Count);
595
596 int i, fd, num=1, ret=0;
597 char tmpName[MAX_ENTRY];
598
599 drawMsg(LNG(Renaming_Game));
600
601 if(!strcmp(Info.Game.Name, newName))
602 goto end1;
603
604 tmpName[0]=0;
605 strcpy(tmpName, newName);
606 for(i=0; i<MAX_PARTITIONS; i++){
607 if(!strcmp(PartyInfo[i].Game.Name, tmpName)){
608 if(strlen(tmpName)>=32)
609 goto end2; //For this case HDL renaming can't be done
610 sprintf(tmpName, "%s%d", newName, num);
611 num++;
612 }
613 }
614 strcpy(newName, tmpName);
615
616 ret = HdlRenameGame(Info.Game.Name, newName);
617
618 if(ret==0){
619 strcpy(PartyInfo[Info.Count].Game.Name, newName);
620 if(mountParty("hdd0:HDLoader Settings")>=0){
621 if((fd=genOpen("pfs0:/gamelist.log", O_RDONLY)) >= 0){
622 genClose(fd);
623 if(fileXioRemove("pfs0:/gamelist.log")!=0)
624 ret=0;
625 }
626 unmountParty(latestMount);
627 }
628 }else{
629 sprintf(DbgMsg,"HdlRenameGame(\"%s\",\n \"%s\")\n=> %d",Info.Game.Name, newName,ret);
630 DebugDisp(DbgMsg);
631 }
632
633
634 if(ret!=0){
635 strcpy(PartyInfo[Info.Count].Game.Name, newName);
636 drawMsg(LNG(Game_Renamed));
637 }else{
638end2:
639 drawMsg(LNG(Failed_Renaming_Game));
640 }
641
642 WaitTime=Timer();
643 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
644
645end1:
646 return ret;
647}
648//------------------------------
649//endfunc RenameGame
650//--------------------------------------------------------------
651int ExpandParty(PARTYINFO Info, int size)
652{
653 int i, ret=0;
654 char tmpName[MAX_ENTRY];
655 t_hddFilesystem hddFs[MAX_PARTITIONS];
656
657 drawMsg(LNG(Expanding_Current_Partition));
658 //printf("Expand Partition: %d\n", Info.Count);
659
660 if(Info.FsGroup==FS_GROUP_APPLICATION){
661 strcpy(tmpName, Info.Name);
662 }else{
663 strcpy(tmpName, Info.Name+1);
664 }
665
666 hddGetFilesystemList(hddFs, MAX_PARTITIONS);
667 for(i=0; i<MAX_PARTITIONS; i++){
668 if(!strcmp(hddFs[i].name, tmpName))
669 ret = hddExpandFilesystem(&hddFs[i], size);
670 }
671
672 if(ret>0){
673 hddUsed += size;
674 hddFreeSpace = (hddSize - hddUsed) & 0x7FFFFF80; //free space rounded to useful area
675 hddFree = (hddFreeSpace*100)/hddSize; //free space percentage
676
677 PartyInfo[Info.Count].TotalSize += size;
678 PartyInfo[Info.Count].FreeSize += size;
679 drawMsg(LNG(Partition_Expanded));
680 }else{
681 drawMsg(LNG(Failed_Expanding_Current_Partition));
682 }
683
684 WaitTime=Timer();
685 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
686
687 return ret;
688}
689//------------------------------
690//endfunc ExpandParty
691//--------------------------------------------------------------
692int FormatHdd(void)
693{
694 int ret=0;
695
696 drawMsg(LNG(Formating_HDD));
697
698 ret = hddFormat();
699
700 if(ret==0){
701 drawMsg(LNG(HDD_Formated));
702 }else{
703 drawMsg(LNG(HDD_Format_Failed));
704 }
705
706 WaitTime=Timer();
707 while(Timer()<WaitTime+1500); // print operation result during 1.5 sec.
708
709 GetHddInfo();
710
711 return ret;
712}
713//------------------------------
714//endfunc FormatHdd
715//--------------------------------------------------------------
716void hddManager(void)
717{
718 char c[MAX_PATH];
719 int Angle;
720 int x, y, y0, y1, x2, y2;
721 float x3, y3;
722 int i, ret;
723 int partySize;
724 int pfsFree;
725 int ray=50;
726 u64 Color;
727 char tmp[MAX_PATH];
728 char tooltip[MAX_TEXT_LINE];
729 int top=0, rows;
730 int event, post_event=0;
731 int browser_sel=0, browser_nfiles=0;
732 int Treat;
733
734 rows = (Menu_end_y-Menu_start_y)/FONT_HEIGHT;
735
736 loadHddModules();
737 GetHddInfo();
738
739 event = 1; //event = initial entry
740 while(1){
741
742 //Pad response section
743 waitPadReady(0, 0);
744 if(readpad()){
745 if(new_pad){
746 //printf("Selected Partition: %d\n", browser_sel);
747 event |= 2; //event |= pad command
748 }
749 if(new_pad & PAD_UP)
750 browser_sel--;
751 else if(new_pad & PAD_DOWN)
752 browser_sel++;
753 else if(new_pad & PAD_LEFT)
754 browser_sel-=rows/2;
755 else if(new_pad & PAD_RIGHT)
756 browser_sel+=rows/2;
757 else if((new_pad & PAD_SELECT) || (new_pad & PAD_TRIANGLE)){
758 //Prepare for exit from HddManager
759 unmountAll(); //unmount all uLE-used mountpoints
760 unmountParty(0); //unconditionally unmount primary mountpoint
761 unmountParty(1); //unconditionally unmount secondary mountpoint
762 return;
763 }else if(new_pad & PAD_SQUARE){
764 if(PartyInfo[browser_sel].Treatment == TREAT_HDL_RAW){
765 loadHdlInfoModule();
766 ret=HdlGetGameInfo(PartyInfo[browser_sel].Name, &PartyInfo[browser_sel].Game);
767 if(ret==0)
768 PartyInfo[browser_sel].Treatment = TREAT_HDL_GAME;
769 else{
770 sprintf(DbgMsg, "HdlGetGameInfo(\"%s\",bf)\n=> %d", PartyInfo[browser_sel].Name, ret);
771 DebugDisp(DbgMsg);
772 }
773 }
774 }else if(new_pad & PAD_R1) { //Starts clause for R1 menu
775 ret = MenuParty(PartyInfo[browser_sel]);
776 tmp[0]=0;
777 if(ret==CREATE){
778 drawMsg(LNG(Enter_New_Partition_Name));
779 drawMsg(LNG(Enter_New_Partition_Name));
780 if(keyboard(tmp, 36)>0){
781 partySize=128;
782 drawMsg(LNG(Select_New_Partition_Size_In_MB));
783 drawMsg(LNG(Select_New_Partition_Size_In_MB));
784 if((ret = sizeSelector(partySize))>0){
785 if(ynDialog(LNG(Create_New_Partition))==1){
786 CreateParty(tmp, ret);
787 nparties = 0; //Tell FileBrowser to refresh party list
788 }
789 }
790 }
791 } else if(ret==REMOVE){
792 if(ynDialog(LNG(Remove_Current_Partition))==1) {
793 RemoveParty(PartyInfo[browser_sel]);
794 nparties = 0; //Tell FileBrowser to refresh party list
795 }
796 } else if(ret==RENAME){
797 drawMsg(LNG(Enter_New_Partition_Name));
798 drawMsg(LNG(Enter_New_Partition_Name));
799 if(PartyInfo[browser_sel].Treatment == TREAT_HDL_GAME){//Rename HDL Game
800 strcpy(tmp, PartyInfo[browser_sel].Game.Name);
801 if(keyboard(tmp, 32)>0){
802 if(ynDialog(LNG(Rename_Current_Game))==1)
803 RenameGame(PartyInfo[browser_sel], tmp);
804 }
805 }else{//starts clause for normal partition RENAME
806 strcpy(tmp, PartyInfo[browser_sel].Name+1);
807 if(keyboard(tmp, 36)>0){
808 if(ynDialog(LNG(Rename_Current_Partition))==1){
809 RenameParty(PartyInfo[browser_sel], tmp);
810 nparties = 0; //Tell FileBrowser to refresh party list
811 }
812 }
813 }//ends clause for normal partition RENAME
814 } else if(ret==EXPAND){
815 drawMsg(LNG(Select_New_Partition_Size_In_MB));
816 drawMsg(LNG(Select_New_Partition_Size_In_MB));
817 partySize=PartyInfo[browser_sel].TotalSize;
818 if((ret=sizeSelector(partySize))>0){
819 if(ynDialog(LNG(Expand_Current_Partition))==1){
820 ret -= partySize;
821 ExpandParty(PartyInfo[browser_sel], ret);
822 nparties = 0; //Tell FileBrowser to refresh party list
823 }
824 }
825 } else if(ret==FORMAT){
826 if(ynDialog(LNG(Format_HDD))==1){
827 FormatHdd();
828 nparties = 0; //Tell FileBrowser to refresh party list
829 }
830 }
831 } //Ends clause for R1 menu
832 }//ends pad response section
833
834 if(event||post_event){ //NB: We need to update two frame buffers per event
835
836 //Display section
837 clrScr(setting->color[0]);
838
839 browser_nfiles=numParty;
840 //printf("Number Of Partition: %d\n", numParty);
841
842 if(top > browser_nfiles-rows) top=browser_nfiles-rows;
843 if(top < 0) top=0;
844 if(browser_sel >= browser_nfiles) browser_sel=browser_nfiles-1;
845 if(browser_sel < 0) browser_sel=0;
846 if(browser_sel >= top+rows) top=browser_sel-rows+1;
847 if(browser_sel < top) top=browser_sel;
848
849 y = Menu_start_y;
850
851 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(LNG(HDD_STATUS))*FONT_WIDTH)/2;
852 printXY(LNG(HDD_STATUS), x, y, setting->color[3], TRUE, 0);
853
854 if(TV_mode == TV_mode_NTSC)
855 y += FONT_HEIGHT+10;
856 else
857 y += FONT_HEIGHT+11;
858
859 drawOpSprite(setting->color[1],
860 SCREEN_MARGIN, y-6,
861 SCREEN_WIDTH/2-20, y-4);
862
863 if(hddConnected==0)
864 sprintf(c, "%s: %s / %s: %s",
865 LNG(CONNECTED), LNG(NO), LNG(FORMATED), LNG(NO));
866 else if((hddConnected==1)&&(hddFormated==0))
867 sprintf(c, "%s: %s / %s: %s",
868 LNG(CONNECTED), LNG(YES), LNG(FORMATED), LNG(NO));
869 else if(hddFormated==1)
870 sprintf(c, "%s: %s / %s: %s",
871 LNG(CONNECTED), LNG(YES), LNG(FORMATED), LNG(YES));
872
873 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
874 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
875
876 drawOpSprite(setting->color[1],
877 SCREEN_WIDTH/2-21, Frame_start_y,
878 SCREEN_WIDTH/2-19, Frame_end_y);
879
880 if(TV_mode == TV_mode_NTSC)
881 y += FONT_HEIGHT+11;
882 else
883 y += FONT_HEIGHT+12;
884
885 drawOpSprite(setting->color[1],
886 SCREEN_MARGIN, y-6,
887 SCREEN_WIDTH/2-20, y-4);
888
889 if(hddFormated==1){
890
891 sprintf(c, "%s: %d %s", LNG(HDD_SIZE), hddSize, LNG(MB));
892 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
893 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
894 y += FONT_HEIGHT;
895 sprintf(c, "%s: %d %s", LNG(HDD_USED), hddUsed, LNG(MB));
896 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
897 y += FONT_HEIGHT;
898 sprintf(c, "%s: %d %s", LNG(HDD_FREE), hddFreeSpace, LNG(MB));
899 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
900
901 if(TV_mode == TV_mode_NTSC)
902 ray = 45;
903 else
904 ray = 55;
905
906 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x);
907 if(TV_mode == TV_mode_NTSC)
908 y += ray+20;
909 else
910 y += ray+25;
911
912 Angle=0;
913
914 for(i=0; i<360; i++){
915 if((Angle = i-90) >= 360) Angle = i+270;
916 if(((i*100)/360) >= hddFree)
917 Color = setting->color[5];
918 else
919 Color = setting->color[4];
920 x3 = ray*cosdgf(Angle);
921 if(TV_mode == TV_mode_NTSC)
922 y3 = (ray-5)*sindgf(Angle);
923 else
924 y3 = (ray)*sindgf(Angle);
925 x2 = x+x3;
926 y2 = y+(y3);
927 gsKit_prim_line(gsGlobal, x, y, x2, y2, 1, Color);
928 gsKit_prim_line(gsGlobal, x, y, x2+1, y2, 1, Color);
929 gsKit_prim_line(gsGlobal, x, y, x2, y2+1, 1, Color);
930 }
931
932 sprintf(c, "%d%% %s",hddFree, LNG(FREE));
933 printXY(c, x-FONT_WIDTH*4, y-FONT_HEIGHT/4, setting->color[3], TRUE, 0);
934
935 if(TV_mode == TV_mode_NTSC)
936 y += ray+15;
937 else
938 y += ray+20;
939
940 drawOpSprite(setting->color[1],
941 SCREEN_MARGIN, y-6,
942 SCREEN_WIDTH/2-20, y-4);
943
944 Treat = PartyInfo[browser_sel].Treatment;
945 if(Treat == TREAT_SYSTEM){
946 sprintf(c, "%s: %d %s", LNG(Raw_SIZE), (int)PartyInfo[browser_sel].RawSize, LNG(MB));
947 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
948 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
949 y += FONT_HEIGHT;
950 strcpy(c, LNG(Reserved_for_system));
951 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
952 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
953 y += FONT_HEIGHT;
954 pfsFree = 0;
955 } else if(Treat == TREAT_NOACCESS){
956 sprintf(c, "%s: %d %s", LNG(Raw_SIZE), (int)PartyInfo[browser_sel].RawSize, LNG(MB));
957 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
958 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
959 y += FONT_HEIGHT;
960 strcpy(c, LNG(Inaccessible));
961 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
962 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
963 y += FONT_HEIGHT;
964 pfsFree = 0;
965 } else if(Treat == TREAT_HDL_RAW){ //starts clause for HDL without GameInfo
966 //---------- Start of clause for HDL game partitions ----------
967 //dlanor NB: Not properly implemented yet
968 sprintf(c, "%s: %d %s", LNG(HDL_SIZE), (int)PartyInfo[browser_sel].RawSize, LNG(MB));
969 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
970 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
971 y += FONT_HEIGHT*4;
972 strcpy(c, LNG(Info_not_loaded));
973 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
974 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
975 pfsFree = -1; //Disable lower pie chart display
976 } else if(Treat == TREAT_HDL_GAME){ //starts clause for HDL with GameInfo
977 y += FONT_HEIGHT/4;
978
979 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-
980 (strlen(LNG(GAME_INFORMATION))*FONT_WIDTH)/2;
981 printXY(LNG(GAME_INFORMATION), x, y,
982 setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
983
984 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)
985 -(strlen(PartyInfo[browser_sel].Game.Name)*FONT_WIDTH)/2;
986 y += FONT_HEIGHT*2;
987 printXY(PartyInfo[browser_sel].Game.Name, x, y,
988 setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
989
990 y += FONT_HEIGHT+FONT_HEIGHT/2+FONT_HEIGHT/4;
991 sprintf(c, "%s: %s", LNG(STARTUP), PartyInfo[browser_sel].Game.Startup);
992 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
993 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
994 y += FONT_HEIGHT+FONT_HEIGHT/2;
995 sprintf(c, "%s: %d %s", LNG(SIZE), (int)PartyInfo[browser_sel].RawSize, LNG(MB));
996 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
997 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
998 y += FONT_HEIGHT+FONT_HEIGHT/2;
999 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-
1000 (strlen(LNG(TYPE_DVD_GAME))*FONT_WIDTH)/2;
1001 if(PartyInfo[browser_sel].Game.Is_Dvd==1)
1002 printXY(LNG(TYPE_DVD_GAME), x, y,
1003 setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
1004 else
1005 printXY(LNG(TYPE_CD_GAME), x, y,
1006 setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
1007 pfsFree = -1; //Disable lower pie chart display
1008 //---------- End of clause for HDL game partitions ----------
1009 }else{ //ends clause for HDL, starts clause for normal partitions
1010 //---------- Start of clause for PFS partitions ----------
1011
1012 sprintf(c, "%s: %d %s", LNG(PFS_SIZE), (int)PartyInfo[browser_sel].TotalSize, LNG(MB));
1013 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x)-(strlen(c)*FONT_WIDTH)/2;
1014 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
1015 y += FONT_HEIGHT;
1016 sprintf(c, "%s: %d %s", LNG(PFS_USED), (int)PartyInfo[browser_sel].UsedSize, LNG(MB));
1017 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
1018 y += FONT_HEIGHT;
1019 sprintf(c, "%s: %d %s", LNG(PFS_FREE), (int)PartyInfo[browser_sel].FreeSize, LNG(MB));
1020 printXY(c, x, y, setting->color[3], TRUE, ((SCREEN_WIDTH/2-20)-SCREEN_MARGIN-2*FONT_WIDTH));
1021
1022 pfsFree = (PartyInfo[browser_sel].FreeSize * 100) / PartyInfo[browser_sel].TotalSize;
1023
1024 //---------- End of clause for normal partitions (not HDL games) ----------
1025 } //ends clause for normal partitions
1026
1027 if(pfsFree >= 0){ //Will be negative when skipping this graph
1028 x = ((((SCREEN_WIDTH/2-25)-Menu_start_x)/2)+Menu_start_x);
1029 if(TV_mode == TV_mode_NTSC)
1030 y += ray+20;
1031 else
1032 y += ray+25;
1033
1034 Angle=0;
1035
1036 for(i=0; i<360; i++){
1037 if((Angle = i-90) >= 360) Angle = i+270;
1038 if(((i*100)/360) >= pfsFree)
1039 Color = setting->color[5];
1040 else
1041 Color = setting->color[4];
1042 x3 = ray*cosdgf(Angle);
1043 if(TV_mode == TV_mode_NTSC)
1044 y3 = (ray-5)*sindgf(Angle);
1045 else
1046 y3 = (ray)*sindgf(Angle);
1047 x2 = x+x3;
1048 y2 = y+(y3);
1049 gsKit_prim_line(gsGlobal, x, y, x2, y2, 1, Color);
1050 gsKit_prim_line(gsGlobal, x, y, x2+1, y2, 1, Color);
1051 gsKit_prim_line(gsGlobal, x, y, x2, y2+1, 1, Color);
1052 }
1053
1054 sprintf(c, "%d%% %s",pfsFree, LNG(FREE));
1055 printXY(c, x-FONT_WIDTH*4, y-FONT_HEIGHT/2, setting->color[3], TRUE, 0);
1056 }
1057
1058 rows = (Menu_end_y-Menu_start_y)/FONT_HEIGHT;
1059
1060 x = SCREEN_WIDTH/2-FONT_WIDTH;
1061 y = Menu_start_y;
1062
1063 for(i=0; i<rows; i++)
1064 {
1065 if(top+i >= browser_nfiles) break;
1066 if(top+i == browser_sel) Color = setting->color[2]; //Highlight cursor line
1067 else Color = setting->color[3];
1068
1069 strcpy(tmp,PartyInfo[top+i].Name);
1070 printXY(tmp, x+4, y, Color, TRUE, ((SCREEN_WIDTH-SCREEN_MARGIN)-(SCREEN_WIDTH/2-FONT_WIDTH)));
1071 y += FONT_HEIGHT;
1072 } //ends for, so all browser rows were fixed above
1073 if(browser_nfiles > rows) { //if more files than available rows, use scrollbar
1074 drawFrame(SCREEN_WIDTH-SCREEN_MARGIN-LINE_THICKNESS*8, Frame_start_y,
1075 SCREEN_WIDTH-SCREEN_MARGIN, Frame_end_y, setting->color[1]);
1076 y0=(Menu_end_y-Menu_start_y+8) * ((double)top/browser_nfiles);
1077 y1=(Menu_end_y-Menu_start_y+8) * ((double)(top+rows)/browser_nfiles);
1078 drawOpSprite(setting->color[1],
1079 SCREEN_WIDTH-SCREEN_MARGIN-LINE_THICKNESS*6, (y0+Menu_start_y-4),
1080 SCREEN_WIDTH-SCREEN_MARGIN-LINE_THICKNESS*2, (y1+Menu_start_y-4));
1081 } //ends clause for scrollbar
1082 } //ends hdd formated
1083 //Tooltip section
1084 sprintf(tooltip, "R1:%s ÿ3:%s", LNG(MENU), LNG(Exit));
1085 if(PartyInfo[browser_sel].Treatment == TREAT_HDL_RAW){
1086 sprintf(tmp, " ÿ2:%s", LNG(Load_HDL_Game_Info));
1087 strcat(tooltip, tmp);
1088 }
1089 setScrTmp(LNG(PS2_HDD_MANAGER), tooltip);
1090
1091 }//ends if(event||post_event)
1092 drawScr();
1093 post_event = event;
1094 event = 0;
1095 }//ends while
1096
1097 return;
1098}
1099//------------------------------
1100//endfunc hddManager
1101//--------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.