summaryrefslogtreecommitdiff
path: root/apps/plugins/doom
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2006-04-17 03:09:29 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2006-04-17 03:09:29 +0000
commitc87f98ce7faed9ba1d2acc9e0e9c9eb5bfb32bfe (patch)
tree7d7710c3c9b9e35d0417e0f0f6677b48d1d7330d /apps/plugins/doom
parenta5af06b580f55f8339d1bf135365993b4db5287c (diff)
downloadrockbox-c87f98ce7faed9ba1d2acc9e0e9c9eb5bfb32bfe.tar.gz
rockbox-c87f98ce7faed9ba1d2acc9e0e9c9eb5bfb32bfe.zip
Finally add support for unlimited number of addons and demos. Also cleaned up the code and made a general function to handle the addons and demos.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9700 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/doom')
-rw-r--r--apps/plugins/doom/rockdoom.c97
1 files changed, 40 insertions, 57 deletions
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index b4d2692af4..fab1fb308e 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -240,8 +240,8 @@ const unsigned char wads_builtin[7][30] =
240}; 240};
241 241
242int namemap[7]; 242int namemap[7];
243static struct opt_items addons[10]; 243static struct opt_items *addons;
244static struct opt_items demolmp[11]; 244static struct opt_items *demolmp;
245char addon[200]; 245char addon[200];
246// This sets up the base game and builds up myargv/c 246// This sets up the base game and builds up myargv/c
247bool Dhandle_ver (int dver) 247bool Dhandle_ver (int dver)
@@ -391,67 +391,54 @@ int Dbuild_base (struct opt_items *names)
391 return i; 391 return i;
392} 392}
393 393
394int Dbuild_addons(struct opt_items *names, char *firstentry, char *directory, char *stringmatch) 394// This is a general function that takes in an opt_items structure and makes a list
395// of files within it based on matching the string stringmatch to the files.
396int Dbuild_filelist(struct opt_items **names, char *firstentry, char *directory, char *stringmatch)
395{ 397{
396 int i=1; 398 int i=0;
399 DIR *filedir;
400 struct dirent *dptr;
401 char *startpt;
402 struct opt_items *temp;
397 403
398 DIR *addondir; 404 filedir=opendir(directory);
399 struct dirent *dptr;
400 char *startpt;
401 405
402// startpt=malloc(strlen("No Addon")*sizeof(char)); // Add this on to allow for no addon to be played 406 if(filedir==NULL)
403// strcpy(startpt,"No Addon");
404 names[0].string=firstentry;
405 names[0].voice_id=0;
406
407 addondir=opendir(directory);
408 if(addondir==NULL)
409 return 1;
410
411 while((dptr=rb->readdir(addondir)) && i<10)
412 { 407 {
413 if(rb->strcasestr(dptr->d_name, stringmatch)) 408 temp=malloc(sizeof(struct opt_items));
414 { 409 temp[0].string=firstentry;
415 startpt=malloc(strlen(dptr->d_name)*sizeof(char)); 410 temp[0].voice_id=0;
416 strcpy(startpt,dptr->d_name); 411 *names=temp;
417 names[i].string=startpt; 412 return 1;
418 names[i].voice_id=0;
419 i++;
420 }
421 } 413 }
422 closedir(addondir);
423 return i;
424}
425 414
426int Dbuild_demos(struct opt_items *names) 415 // Get the total number of entries
427{ 416 while((dptr=rb->readdir(filedir)))
428 int i=1; 417 i++;
429
430 DIR *demos;
431 struct dirent *dptr;
432 char *startpt;
433 418
434 startpt=malloc(strlen("No Demo")*sizeof(char)); // Add this on to allow for no demo to be played 419 // Reset the directory
435 strcpy(startpt,"No Demo"); 420 closedir(filedir);
436 names[0].string=startpt; 421 filedir=opendir(directory);
437 names[0].voice_id=0;
438 422
439 demos=opendir(GAMEBASE"demos/"); 423 i++;
440 if(demos==NULL) 424 temp=malloc(i*sizeof(struct opt_items));
441 return 1; 425 temp[0].string=firstentry;
426 temp[0].voice_id=0;
427 i=1;
442 428
443 while((dptr=rb->readdir(demos)) && i<11) 429 while((dptr=rb->readdir(filedir)))
444 { 430 {
445 if(rb->strcasestr(dptr->d_name, ".LMP")) 431 if(rb->strcasestr(dptr->d_name, stringmatch))
446 { 432 {
447 startpt=malloc(strlen(dptr->d_name)*sizeof(char)); 433 startpt=malloc(strlen(dptr->d_name)*sizeof(char));
448 strcpy(startpt,dptr->d_name); 434 strcpy(startpt,dptr->d_name);
449 names[i].string=startpt; 435 temp[i].string=startpt;
450 names[i].voice_id=0; 436 temp[i].voice_id=0;
451 i++; 437 i++;
452 } 438 }
453 } 439 }
454 closedir(demos); 440 closedir(filedir);
441 *names=temp;
455 return i; 442 return i;
456} 443}
457 444
@@ -729,11 +716,11 @@ int doom_menu()
729 return -1; 716 return -1;
730 } 717 }
731 718
732 int numadd=Dbuild_addons(addons, "No Addons", GAMEBASE"addons/", ".WAD" ); 719 int numadd=Dbuild_filelist(&addons, "No Addons", GAMEBASE"addons/", ".WAD" );
733 720
734 int numdemos=Dbuild_demos(demolmp); 721 int numdemos=Dbuild_filelist(&demolmp, "No Demos", GAMEBASE"demos/", ".LMP" );
735 argvlist.demonum=0;
736 722
723 argvlist.demonum=0;
737 argvlist.addonnum=0; 724 argvlist.addonnum=0;
738 725
739 gamever=status-1; 726 gamever=status-1;
@@ -810,7 +797,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
810 797
811 // We're using doom's memory management since it implements a proper free (and re-uses the memory) 798 // We're using doom's memory management since it implements a proper free (and re-uses the memory)
812 // and now with prboom's code: realloc and calloc 799 // and now with prboom's code: realloc and calloc
813 printf ("Z_Init: Init zone memory allocation daemon. \n"); 800 printf ("Z_Init: Init zone memory allocation daemon.\n");
814 Z_Init (); 801 Z_Init ();
815 802
816 printf ("M_LoadDefaults: Load system defaults.\n"); 803 printf ("M_LoadDefaults: Load system defaults.\n");
@@ -826,10 +813,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
826 rb->splash(HZ*2, true, "Welcome to RockDoom"); 813 rb->splash(HZ*2, true, "Welcome to RockDoom");
827#endif 814#endif
828 815
829 myargv = malloc(sizeof(char *)*MAXARGVS); 816 myargv =0;
830 memset(myargv,0,sizeof(char *)*MAXARGVS); 817 myargc=0;
831 myargv[0]="doom.rock";
832 myargc=1;
833 818
834 int result=doom_menu(); 819 int result=doom_menu();
835 820
@@ -865,8 +850,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
865 fpoint--; 850 fpoint--;
866 } 851 }
867 852
868// rb->splash(HZ, true, "Bye");
869
870#ifdef HAVE_ADJUSTABLE_CPU_FREQ 853#ifdef HAVE_ADJUSTABLE_CPU_FREQ
871 rb->cpu_boost(false); 854 rb->cpu_boost(false);
872#endif 855#endif