2006-03-28 15:44:01 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Karl Kurbjun
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-03-28 15:44:01 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* H300 Port by Karl Kurbjun
|
|
|
|
* IPod port by Dave Chapman and Paul Louden
|
|
|
|
* Additional code contributed by Thom Johansen
|
|
|
|
* Based off work by: Digita Doom, IDoom, Prboom, lSDLDoom, LxDoom,
|
|
|
|
* MBF, Boom, DosDoom,
|
|
|
|
* and of course Original Doom by ID Software
|
|
|
|
* See: http://prboom.sourceforge.net/about.html for the history
|
|
|
|
*
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "d_main.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "m_fixed.h"
|
|
|
|
#include "m_argv.h"
|
|
|
|
#include "m_misc.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "rockmacros.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "i_system.h"
|
2006-04-22 03:48:15 +00:00
|
|
|
#include "hu_stuff.h"
|
|
|
|
#include "st_stuff.h"
|
2007-05-08 11:55:43 +00:00
|
|
|
#include "lib/oldmenuapi.h"
|
2008-01-06 14:05:55 +00:00
|
|
|
#include "lib/helper.h"
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
PLUGIN_HEADER
|
2006-11-18 02:18:29 +00:00
|
|
|
PLUGIN_IRAM_DECLARE
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
extern boolean timingdemo, singledemo, demoplayback, fastdemo; // killough
|
|
|
|
|
|
|
|
int filearray[9];
|
|
|
|
int fpoint=1; // save 0 for closing
|
|
|
|
|
|
|
|
int fileexists(const char * fname)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
fd = open(fname,O_RDONLY);
|
|
|
|
|
|
|
|
if (fd>=0)
|
|
|
|
{
|
|
|
|
close(fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef SIMULATOR
|
|
|
|
int my_open(const char *file, int flags)
|
|
|
|
{
|
|
|
|
if(fpoint==8)
|
|
|
|
return -1;
|
|
|
|
#undef open
|
|
|
|
filearray[fpoint]=rb->open(file, flags);
|
|
|
|
|
|
|
|
if(filearray[fpoint]<0)
|
|
|
|
return filearray[fpoint];
|
|
|
|
|
|
|
|
fpoint++;
|
|
|
|
return filearray[fpoint-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
int my_close(int id)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
if(id<0)
|
|
|
|
return id;
|
|
|
|
while(filearray[i]!=id && i<8)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
if(i==8)
|
|
|
|
{
|
|
|
|
printf("A requested FID did not exist!!!!");
|
|
|
|
return -9;
|
|
|
|
}
|
|
|
|
#undef close
|
|
|
|
rb->close(id);
|
|
|
|
|
|
|
|
for(; i<fpoint-1; i++)
|
|
|
|
filearray[i]=filearray[i+1];
|
|
|
|
|
|
|
|
fpoint--;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2008-05-13 09:57:56 +00:00
|
|
|
const struct plugin_api* rb;
|
2006-03-28 15:44:01 +00:00
|
|
|
#define MAXARGVS 100
|
|
|
|
|
2006-04-03 17:11:42 +00:00
|
|
|
bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates
|
|
|
|
|
2007-06-03 22:03:36 +00:00
|
|
|
#ifndef SIMULATOR
|
2006-03-28 15:44:01 +00:00
|
|
|
// Here is a hacked up printf command to get the output from the game.
|
|
|
|
int printf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
static int p_xtpt;
|
|
|
|
char p_buf[50];
|
|
|
|
bool ok;
|
2007-01-17 18:52:24 +00:00
|
|
|
rb->yield();
|
2006-03-28 15:44:01 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
ok = vsnprintf(p_buf,sizeof(p_buf), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
rb->lcd_putsxy(1,p_xtpt, (unsigned char *)p_buf);
|
2006-04-03 17:11:42 +00:00
|
|
|
if (!noprintf)
|
|
|
|
rb->lcd_update();
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
p_xtpt+=8;
|
|
|
|
if(p_xtpt>LCD_HEIGHT-8)
|
|
|
|
{
|
|
|
|
p_xtpt=0;
|
2006-04-03 17:11:42 +00:00
|
|
|
if (!noprintf)
|
|
|
|
rb->lcd_clear_display();
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2007-06-03 22:03:36 +00:00
|
|
|
#endif
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
char *my_strtok( char * s, const char * delim )
|
|
|
|
{
|
|
|
|
register char *spanp;
|
|
|
|
register int c, sc;
|
|
|
|
char *tok;
|
|
|
|
static char *lasts;
|
|
|
|
|
|
|
|
|
|
|
|
if (s == NULL && (s = lasts) == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
|
|
|
|
*/
|
|
|
|
cont:
|
|
|
|
c = *s++;
|
|
|
|
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
|
|
|
|
if (c == sc)
|
|
|
|
goto cont;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == 0) { /* no non-delimiter characters */
|
|
|
|
lasts = NULL;
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
tok = s - 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
|
|
|
|
* Note that delim must have one NUL; we stop if we see that, too.
|
|
|
|
*/
|
|
|
|
for (;;) {
|
|
|
|
c = *s++;
|
|
|
|
spanp = (char *)delim;
|
|
|
|
do {
|
|
|
|
if ((sc = *spanp++) == c) {
|
|
|
|
if (c == 0)
|
|
|
|
s = NULL;
|
|
|
|
else
|
|
|
|
s[-1] = 0;
|
|
|
|
lasts = s;
|
|
|
|
return (tok);
|
|
|
|
}
|
|
|
|
} while (sc != 0);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void* memcpy(void* dst, const void* src, size_t size)
|
|
|
|
{
|
|
|
|
return rb->memcpy(dst, src, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct argvlist
|
|
|
|
{
|
|
|
|
int timedemo; // 1 says there's a timedemo
|
|
|
|
int demonum;
|
|
|
|
int addonnum;
|
|
|
|
} argvlist;
|
|
|
|
|
|
|
|
const unsigned char versions_builtin[7][20] =
|
|
|
|
{
|
|
|
|
"Doom Shareware",
|
|
|
|
"Doom Registered",
|
|
|
|
"Ultimate Doom",
|
|
|
|
"Doom 2",
|
2007-02-17 17:51:44 +00:00
|
|
|
"Freedoom",
|
2006-03-28 15:44:01 +00:00
|
|
|
"Plutonia",
|
|
|
|
"TNT"
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned char wads_builtin[7][30] =
|
|
|
|
{
|
|
|
|
GAMEBASE"doom1.wad",
|
|
|
|
GAMEBASE"doom.wad",
|
|
|
|
GAMEBASE"doomu.wad",
|
|
|
|
GAMEBASE"doom2.wad",
|
2007-02-17 17:51:44 +00:00
|
|
|
GAMEBASE"doomf.wad",
|
2006-03-28 15:44:01 +00:00
|
|
|
GAMEBASE"plutonia.wad",
|
|
|
|
GAMEBASE"tnt.wad"
|
|
|
|
};
|
|
|
|
|
|
|
|
int namemap[7];
|
2006-04-17 04:38:26 +00:00
|
|
|
static struct menu_item *addons;
|
|
|
|
static struct menu_item *demolmp;
|
2006-03-28 15:44:01 +00:00
|
|
|
char addon[200];
|
|
|
|
// This sets up the base game and builds up myargv/c
|
|
|
|
bool Dhandle_ver (int dver)
|
|
|
|
{
|
|
|
|
switch (dver) {
|
|
|
|
case 0: /* Doom Shareware */
|
|
|
|
gamemode = shareware;
|
|
|
|
gamemission = doom;
|
|
|
|
D_AddFile(wads_builtin[0],source_iwad);
|
|
|
|
break;
|
|
|
|
case 1: /* Doom registered */
|
|
|
|
gamemode = registered;
|
|
|
|
gamemission = doom;
|
|
|
|
D_AddFile(wads_builtin[1],source_iwad);
|
|
|
|
break;
|
|
|
|
case 2: /* Ultimate Doom */
|
|
|
|
gamemode = retail;
|
|
|
|
gamemission = doom;
|
|
|
|
D_AddFile(wads_builtin[2],source_iwad);
|
|
|
|
break;
|
|
|
|
case 3: /* Doom2 */
|
|
|
|
gamemode = commercial;
|
|
|
|
gamemission = doom2;
|
|
|
|
D_AddFile(wads_builtin[3],source_iwad);
|
|
|
|
break;
|
|
|
|
case 4: /* Doom2f */
|
|
|
|
gamemode = commercial;
|
|
|
|
gamemission = doom2;
|
|
|
|
D_AddFile(wads_builtin[4],source_iwad);
|
|
|
|
break;
|
|
|
|
case 5: /* Plutonia */
|
|
|
|
gamemode = commercial;
|
|
|
|
gamemission = pack_plut;
|
|
|
|
D_AddFile(wads_builtin[5],source_iwad);
|
|
|
|
break;
|
|
|
|
case 6: /* TNT */
|
|
|
|
gamemode = commercial;
|
|
|
|
gamemission = pack_tnt;
|
|
|
|
D_AddFile(wads_builtin[6],source_iwad);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gamemission = none;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// Start adding to myargv
|
|
|
|
if(argvlist.timedemo && (gamemode == shareware))
|
|
|
|
{
|
|
|
|
singletics = true;
|
|
|
|
timingdemo = true; // show stats after quit
|
|
|
|
G_DeferedPlayDemo("demo3");
|
|
|
|
singledemo = true; // quit after one demo
|
|
|
|
}
|
|
|
|
|
|
|
|
if(argvlist.addonnum)
|
|
|
|
{
|
2006-04-17 04:38:26 +00:00
|
|
|
snprintf(addon,sizeof(addon),"%s%s", GAMEBASE"addons/", addons[argvlist.addonnum].desc);
|
2006-03-28 15:44:01 +00:00
|
|
|
D_AddFile(addon,source_pwad);
|
|
|
|
modifiedgame = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(argvlist.demonum)
|
|
|
|
{
|
2006-04-17 04:38:26 +00:00
|
|
|
snprintf(addon, sizeof(addon),"%s%s", GAMEBASE"demos/", demolmp[argvlist.demonum].desc);
|
2006-03-28 15:44:01 +00:00
|
|
|
D_AddFile(addon, source_lmp);
|
|
|
|
G_DeferedPlayDemo(addon);
|
|
|
|
singledemo = true; // quit after one demo
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function builds up the basegame list for use in the options selection
|
|
|
|
// it also sets the defaults for the argvlist
|
2006-04-03 20:03:02 +00:00
|
|
|
// Now checking for rcokdoom.wad based on prboom.wad
|
2006-03-28 15:44:01 +00:00
|
|
|
int Dbuild_base (struct opt_items *names)
|
|
|
|
{
|
2006-04-03 20:03:02 +00:00
|
|
|
if ( fileexists(GAMEBASE"rockdoom.wad") )
|
2006-03-28 15:44:01 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-04-03 20:03:02 +00:00
|
|
|
D_AddFile (GAMEBASE"rockdoom.wad", source_pwad);
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
int i=0, j;
|
2006-03-28 15:44:01 +00:00
|
|
|
/* Doom Shareware */
|
|
|
|
/* Doom registered */
|
|
|
|
/* Ultimate Doom */
|
|
|
|
/* Doom2 */
|
|
|
|
/* Doom2f */
|
|
|
|
/* Plutonia */
|
|
|
|
/* TNT */
|
2007-01-17 18:52:24 +00:00
|
|
|
for(j=0;j<7;j++)
|
|
|
|
if ( !fileexists (wads_builtin[j]) )
|
|
|
|
{
|
|
|
|
names[i].string=versions_builtin[j];
|
2007-10-02 19:53:35 +00:00
|
|
|
names[i].voice_id=-1;
|
2007-01-17 18:52:24 +00:00
|
|
|
namemap[i]=j;
|
|
|
|
i++;
|
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
// Set argvlist defaults
|
|
|
|
argvlist.timedemo=0;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
// This is a general function that takes in a menu_item structure and makes a list
|
2006-04-17 04:38:26 +00:00
|
|
|
// of files within it based on matching the string stringmatch to the files.
|
|
|
|
int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory, char *stringmatch)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
DIR *filedir;
|
|
|
|
struct dirent *dptr;
|
|
|
|
char *startpt;
|
|
|
|
struct menu_item *temp;
|
|
|
|
|
2007-07-20 17:06:55 +00:00
|
|
|
filedir=rb->opendir(directory);
|
2006-04-17 04:38:26 +00:00
|
|
|
|
|
|
|
if(filedir==NULL)
|
|
|
|
{
|
2007-10-02 19:53:35 +00:00
|
|
|
temp=malloc(sizeof(struct menu_item));
|
2006-04-17 04:38:26 +00:00
|
|
|
temp[0].desc=firstentry;
|
|
|
|
temp[0].function=0;
|
|
|
|
*names=temp;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the total number of entries
|
|
|
|
while((dptr=rb->readdir(filedir)))
|
|
|
|
i++;
|
|
|
|
|
|
|
|
// Reset the directory
|
2007-07-20 17:06:55 +00:00
|
|
|
rb->closedir(filedir);
|
|
|
|
filedir=rb->opendir(directory);
|
2006-04-17 04:38:26 +00:00
|
|
|
|
|
|
|
i++;
|
2007-10-02 19:53:35 +00:00
|
|
|
temp=malloc(i*sizeof(struct menu_item));
|
2006-04-17 04:38:26 +00:00
|
|
|
temp[0].desc=firstentry;
|
|
|
|
temp[0].function=0;
|
|
|
|
i=1;
|
|
|
|
|
|
|
|
while((dptr=rb->readdir(filedir)))
|
|
|
|
{
|
|
|
|
if(rb->strcasestr(dptr->d_name, stringmatch))
|
|
|
|
{
|
|
|
|
startpt=malloc(strlen(dptr->d_name)*sizeof(char));
|
|
|
|
strcpy(startpt,dptr->d_name);
|
|
|
|
temp[i].desc=startpt;
|
|
|
|
temp[i].function=0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2007-07-20 17:06:55 +00:00
|
|
|
rb->closedir(filedir);
|
2006-04-17 04:38:26 +00:00
|
|
|
*names=temp;
|
|
|
|
return i;
|
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
static int translatekey(int key) __attribute__ ((noinline));
|
|
|
|
|
2006-04-04 17:53:29 +00:00
|
|
|
// This key configuration code is not the cleanest or the most efficient, but it works
|
2007-01-17 18:52:24 +00:00
|
|
|
static int translatekey(int key)
|
2006-04-04 17:53:29 +00:00
|
|
|
{
|
|
|
|
if (key<31)
|
|
|
|
{
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
return KEY_RIGHTARROW;
|
|
|
|
case 2:
|
|
|
|
return KEY_LEFTARROW;
|
|
|
|
case 3:
|
|
|
|
return KEY_UPARROW;
|
|
|
|
case 4:
|
|
|
|
return KEY_DOWNARROW;
|
|
|
|
case 5:
|
2007-01-17 18:52:24 +00:00
|
|
|
return KEY_ENTER;
|
2006-04-04 17:53:29 +00:00
|
|
|
case 6:
|
2007-01-17 18:52:24 +00:00
|
|
|
return KEY_RCTRL;
|
2006-04-04 17:53:29 +00:00
|
|
|
case 7:
|
2007-01-17 18:52:24 +00:00
|
|
|
return ' ';
|
2006-04-04 17:53:29 +00:00
|
|
|
case 8:
|
2007-01-17 18:52:24 +00:00
|
|
|
return KEY_ESCAPE;
|
2006-04-04 17:53:29 +00:00
|
|
|
case 9:
|
2007-01-17 18:52:24 +00:00
|
|
|
return 'w';
|
2006-04-04 23:13:50 +00:00
|
|
|
case 10:
|
2007-01-17 18:52:24 +00:00
|
|
|
return KEY_TAB;
|
2006-04-04 17:53:29 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
case KEY_RIGHTARROW:
|
|
|
|
return 1;
|
|
|
|
case KEY_LEFTARROW:
|
|
|
|
return 2;
|
|
|
|
case KEY_UPARROW:
|
|
|
|
return 3;
|
|
|
|
case KEY_DOWNARROW:
|
|
|
|
return 4;
|
2007-01-17 18:52:24 +00:00
|
|
|
case KEY_ENTER:
|
2006-04-04 17:53:29 +00:00
|
|
|
return 5;
|
2007-01-17 18:52:24 +00:00
|
|
|
case KEY_RCTRL:
|
2006-04-04 17:53:29 +00:00
|
|
|
return 6;
|
2007-01-17 18:52:24 +00:00
|
|
|
case ' ':
|
2006-04-04 17:53:29 +00:00
|
|
|
return 7;
|
2007-01-17 18:52:24 +00:00
|
|
|
case KEY_ESCAPE:
|
2006-04-04 17:53:29 +00:00
|
|
|
return 8;
|
2007-01-17 18:52:24 +00:00
|
|
|
case 'w':
|
2006-04-04 17:53:29 +00:00
|
|
|
return 9;
|
2007-01-17 18:52:24 +00:00
|
|
|
case KEY_TAB:
|
|
|
|
return 10;
|
2006-04-04 17:53:29 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// I havn't added configurable keys for enter or escape because this requires some modification to
|
|
|
|
// m_menu.c which hasn't been done yet.
|
|
|
|
|
|
|
|
int Oset_keys()
|
2006-03-28 15:44:01 +00:00
|
|
|
{
|
2006-04-04 17:53:29 +00:00
|
|
|
int m, result;
|
|
|
|
int menuquit=0;
|
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
|
2006-04-04 17:53:29 +00:00
|
|
|
static const struct opt_items doomkeys[] = {
|
2007-10-02 19:53:35 +00:00
|
|
|
{ "Unmapped", -1 },
|
|
|
|
{ "Key Right", -1 },
|
|
|
|
{ "Key Left", -1 },
|
|
|
|
{ "Key Up", -1 },
|
|
|
|
{ "Key Down", -1 },
|
|
|
|
{ "Key Select", -1 },
|
2007-01-17 18:52:24 +00:00
|
|
|
#if defined(TOSHIBA_GIGABEAT_F)
|
2007-10-02 19:53:35 +00:00
|
|
|
{ "Key A", -1 },
|
|
|
|
{ "Key Menu", -1 },
|
|
|
|
{ "Key Power", -1 },
|
|
|
|
{ "Key Volume Down", -1 },
|
|
|
|
{ "Key Volume Up", -1 },
|
2007-01-17 18:52:24 +00:00
|
|
|
#else
|
2007-10-02 19:53:35 +00:00
|
|
|
{ "Key Record", -1 },
|
|
|
|
{ "Key Mode", -1 },
|
|
|
|
{ "Key Off", -1 },
|
|
|
|
{ "Key On", -1 },
|
2007-01-17 18:52:24 +00:00
|
|
|
#endif
|
2006-04-04 17:53:29 +00:00
|
|
|
};
|
2007-01-17 18:52:24 +00:00
|
|
|
|
|
|
|
int *keys[]={
|
|
|
|
&key_right,
|
|
|
|
&key_left,
|
|
|
|
&key_up,
|
|
|
|
&key_down,
|
|
|
|
&key_fire,
|
|
|
|
&key_use,
|
|
|
|
&key_strafe,
|
|
|
|
&key_weapon,
|
|
|
|
&key_map
|
|
|
|
};
|
|
|
|
|
2006-04-04 17:53:29 +00:00
|
|
|
int numdoomkeys=sizeof(doomkeys) / sizeof(*doomkeys);
|
|
|
|
|
|
|
|
static const struct menu_item items[] = {
|
|
|
|
{ "Game Right", NULL },
|
|
|
|
{ "Game Left", NULL },
|
|
|
|
{ "Game Up", NULL },
|
|
|
|
{ "Game Down", NULL },
|
|
|
|
{ "Game Shoot", NULL },
|
|
|
|
{ "Game Open", NULL },
|
|
|
|
{ "Game Strafe", NULL },
|
|
|
|
{ "Game Weapon", NULL },
|
2006-04-04 23:13:50 +00:00
|
|
|
{ "Game Automap", NULL },
|
2006-04-04 17:53:29 +00:00
|
|
|
};
|
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
m = menu_init(rb, items, sizeof(items) / sizeof(*items),
|
2006-06-10 18:47:11 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2006-04-04 17:53:29 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
while(!menuquit)
|
|
|
|
{
|
2007-05-08 11:55:43 +00:00
|
|
|
result=menu_show(m);
|
2007-01-17 18:52:24 +00:00
|
|
|
if(result<0)
|
2006-04-04 17:53:29 +00:00
|
|
|
menuquit=1;
|
2007-01-17 18:52:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*keys[result]=translatekey(*keys[result]);
|
|
|
|
rb->set_option(items[result].desc, keys[result], INT, doomkeys, numdoomkeys, NULL );
|
|
|
|
*keys[result]=translatekey(*keys[result]);
|
|
|
|
}
|
2006-04-04 17:53:29 +00:00
|
|
|
}
|
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
menu_exit(m);
|
2006-04-04 17:53:29 +00:00
|
|
|
|
|
|
|
return (1);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern int fake_contrast;
|
|
|
|
|
|
|
|
static bool Doptions()
|
|
|
|
{
|
2006-04-17 04:38:26 +00:00
|
|
|
static const struct opt_items onoff[2] = {
|
2007-10-02 19:53:35 +00:00
|
|
|
{ "Off", -1 },
|
|
|
|
{ "On", -1 },
|
2006-04-17 04:38:26 +00:00
|
|
|
};
|
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
int m, result;
|
|
|
|
int menuquit=0;
|
|
|
|
|
|
|
|
static const struct menu_item items[] = {
|
2006-04-04 17:53:29 +00:00
|
|
|
{ "Set Keys", NULL },
|
2007-01-17 18:52:24 +00:00
|
|
|
{ "Sound", NULL },
|
2006-03-28 15:44:01 +00:00
|
|
|
{ "Timedemo", NULL },
|
|
|
|
{ "Player Bobbing", NULL },
|
|
|
|
{ "Weapon Recoil", NULL },
|
|
|
|
{ "Translucency", NULL },
|
|
|
|
{ "Fake Contrast", NULL },
|
2006-04-17 00:37:51 +00:00
|
|
|
{ "Always Run", NULL },
|
2006-04-22 03:48:15 +00:00
|
|
|
{ "Headsup Display", NULL },
|
|
|
|
{ "Statusbar Always Red", NULL },
|
2007-01-17 18:52:24 +00:00
|
|
|
#if(LCD_HEIGHT>LCD_WIDTH)
|
|
|
|
{ "Rotate Screen 90 deg", NULL },
|
|
|
|
#endif
|
2006-03-28 15:44:01 +00:00
|
|
|
};
|
2007-01-17 18:52:24 +00:00
|
|
|
|
|
|
|
void *options[]={
|
|
|
|
&enable_sound,
|
|
|
|
&argvlist.timedemo,
|
|
|
|
&default_player_bobbing,
|
|
|
|
&default_weapon_recoil,
|
|
|
|
&default_translucency,
|
|
|
|
&fake_contrast,
|
|
|
|
&autorun,
|
|
|
|
&hud_displayed,
|
|
|
|
&sts_always_red,
|
|
|
|
#if(LCD_HEIGHT>LCD_WIDTH)
|
|
|
|
&rotate_screen,
|
|
|
|
#endif
|
|
|
|
};
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
m = menu_init(rb, items, sizeof(items) / sizeof(*items),
|
2007-01-17 18:52:24 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
while(!menuquit)
|
|
|
|
{
|
2007-05-08 11:55:43 +00:00
|
|
|
result=menu_show(m);
|
2007-01-17 18:52:24 +00:00
|
|
|
if(result==0)
|
2006-03-28 15:44:01 +00:00
|
|
|
Oset_keys();
|
2007-01-17 18:52:24 +00:00
|
|
|
else if (result > 0)
|
|
|
|
rb->set_option(items[result].desc, options[result-1], INT, onoff, 2, NULL );
|
|
|
|
else
|
2006-03-28 15:44:01 +00:00
|
|
|
menuquit=1;
|
2007-01-17 18:52:24 +00:00
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
menu_exit(m);
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
return (1);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
2006-04-17 04:38:26 +00:00
|
|
|
int menuchoice(struct menu_item *menu, int items)
|
|
|
|
{
|
|
|
|
int m, result;
|
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
m = menu_init(rb, menu, items,NULL, NULL, NULL, NULL);
|
2006-04-17 04:38:26 +00:00
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
result= menu_show(m);
|
|
|
|
menu_exit(m);
|
2006-04-17 04:38:26 +00:00
|
|
|
if(result<items && result>=0)
|
|
|
|
return result;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
//
|
|
|
|
// Doom Menu
|
|
|
|
//
|
|
|
|
int doom_menu()
|
|
|
|
{
|
|
|
|
int m;
|
|
|
|
int result;
|
|
|
|
int status;
|
|
|
|
int gamever;
|
|
|
|
bool menuquit=0;
|
|
|
|
|
|
|
|
static struct opt_items names[7];
|
|
|
|
|
|
|
|
static const struct menu_item items[] = {
|
|
|
|
{ "Game", NULL },
|
|
|
|
{ "Addons", NULL },
|
|
|
|
{ "Demos", NULL },
|
|
|
|
{ "Options", NULL },
|
|
|
|
{ "Play Game", NULL },
|
|
|
|
{ "Quit", NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
if( (status=Dbuild_base(names)) == 0 ) // Build up the base wad files (select last added file)
|
|
|
|
{
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2, "Missing Base WAD!");
|
2006-04-17 05:01:33 +00:00
|
|
|
return -2;
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
2006-04-17 04:38:26 +00:00
|
|
|
int numadd=Dbuild_filelistm(&addons, "No Addon", GAMEBASE"addons/", ".WAD" );
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-17 04:38:26 +00:00
|
|
|
int numdemos=Dbuild_filelistm(&demolmp, "No Demo", GAMEBASE"demos/", ".LMP" );
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-17 03:09:29 +00:00
|
|
|
argvlist.demonum=0;
|
2006-03-28 15:44:01 +00:00
|
|
|
argvlist.addonnum=0;
|
|
|
|
|
|
|
|
gamever=status-1;
|
|
|
|
|
2006-06-10 18:47:11 +00:00
|
|
|
/* Clean out the button Queue */
|
|
|
|
while (rb->button_get(false) != BUTTON_NONE)
|
|
|
|
rb->yield();
|
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
m = menu_init(rb, items, sizeof(items) / sizeof(*items),
|
2006-06-10 18:47:11 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
while(!menuquit)
|
|
|
|
{
|
2007-05-08 11:55:43 +00:00
|
|
|
result=menu_show(m);
|
2006-03-28 15:44:01 +00:00
|
|
|
switch (result) {
|
|
|
|
case 0: /* Game picker */
|
2006-04-17 04:38:26 +00:00
|
|
|
rb->set_option("Game WAD", &gamever, INT, names, status, NULL );
|
2006-03-28 15:44:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* Addon picker */
|
2006-04-17 04:38:26 +00:00
|
|
|
argvlist.addonnum=menuchoice(addons,numadd);
|
2006-03-28 15:44:01 +00:00
|
|
|
break;
|
|
|
|
|
2006-04-04 17:53:29 +00:00
|
|
|
case 2: /* Demos */
|
2006-04-17 04:38:26 +00:00
|
|
|
argvlist.demonum=menuchoice(demolmp,numdemos);
|
2006-03-28 15:44:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* Options */
|
|
|
|
Doptions();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* Play Game */
|
|
|
|
menuquit=1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: /* Quit */
|
|
|
|
menuquit=1;
|
|
|
|
gamever=-1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-08 11:55:43 +00:00
|
|
|
menu_exit(m);
|
2006-03-28 15:44:01 +00:00
|
|
|
|
|
|
|
return (gamever);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int systemvol;
|
|
|
|
/* this is the plugin entry point */
|
2008-05-13 09:57:56 +00:00
|
|
|
enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
|
2006-03-28 15:44:01 +00:00
|
|
|
{
|
2006-11-26 18:31:41 +00:00
|
|
|
PLUGIN_IRAM_INIT(api)
|
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
rb = api;
|
|
|
|
(void)parameter;
|
|
|
|
|
2006-04-15 22:08:36 +00:00
|
|
|
doomexit=0;
|
|
|
|
|
2006-04-09 15:00:30 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-03-28 15:44:01 +00:00
|
|
|
rb->cpu_boost(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rb->lcd_setfont(0);
|
|
|
|
|
|
|
|
// We're using doom's memory management since it implements a proper free (and re-uses the memory)
|
|
|
|
// and now with prboom's code: realloc and calloc
|
2006-04-17 03:09:29 +00:00
|
|
|
printf ("Z_Init: Init zone memory allocation daemon.\n");
|
2006-03-28 15:44:01 +00:00
|
|
|
Z_Init ();
|
|
|
|
|
|
|
|
printf ("M_LoadDefaults: Load system defaults.\n");
|
|
|
|
M_LoadDefaults (); // load before initing other systems
|
|
|
|
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2, "Welcome to RockDoom");
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-17 03:09:29 +00:00
|
|
|
myargv =0;
|
|
|
|
myargc=0;
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-17 05:01:33 +00:00
|
|
|
rb->lcd_clear_display();
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-17 05:01:33 +00:00
|
|
|
int result = doom_menu();
|
2006-10-01 01:07:45 +00:00
|
|
|
if (result < 0)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2008-01-06 14:05:55 +00:00
|
|
|
rb->cpu_boost(false);
|
2006-10-01 01:07:45 +00:00
|
|
|
#endif
|
2008-01-06 14:05:55 +00:00
|
|
|
if( result == -1 )
|
|
|
|
return PLUGIN_OK; // Quit was selected
|
|
|
|
else
|
|
|
|
return PLUGIN_ERROR; // Missing base wads
|
2006-10-01 01:07:45 +00:00
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
#if(LCD_HEIGHT>LCD_WIDTH)
|
|
|
|
if(rotate_screen)
|
|
|
|
{
|
|
|
|
SCREENHEIGHT=LCD_WIDTH;
|
|
|
|
SCREENWIDTH=LCD_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCREENHEIGHT=LCD_HEIGHT;
|
|
|
|
SCREENWIDTH=LCD_WIDTH;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
Dhandle_ver( namemap[ result ] );
|
|
|
|
|
|
|
|
rb->lcd_setfont(0);
|
|
|
|
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
2006-04-02 20:45:24 +00:00
|
|
|
systemvol= rb->global_settings->volume-rb->global_settings->volume%((rb->sound_max(SOUND_VOLUME)-rb->sound_min(SOUND_VOLUME))/15);
|
2006-03-28 15:44:01 +00:00
|
|
|
general_translucency = default_translucency; // phares
|
2006-04-14 21:07:56 +00:00
|
|
|
|
2008-01-06 14:05:55 +00:00
|
|
|
backlight_force_on(rb);
|
2006-04-14 21:07:56 +00:00
|
|
|
#ifdef RB_PROFILE
|
|
|
|
rb->profile_thread();
|
|
|
|
#endif
|
|
|
|
|
2008-04-07 22:09:14 +00:00
|
|
|
#if LCD_DEPTH>1
|
2006-11-15 06:14:27 +00:00
|
|
|
rb->lcd_set_backdrop(NULL);
|
2008-04-07 22:09:14 +00:00
|
|
|
#endif
|
2006-11-15 06:14:27 +00:00
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
D_DoomMain ();
|
|
|
|
|
2006-04-14 21:07:56 +00:00
|
|
|
#ifdef RB_PROFILE
|
|
|
|
rb->profstop();
|
|
|
|
#endif
|
2008-01-06 14:05:55 +00:00
|
|
|
backlight_use_settings(rb);
|
2006-04-14 21:07:56 +00:00
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
M_SaveDefaults ();
|
|
|
|
|
|
|
|
I_Quit(); // Make SURE everything was closed out right
|
|
|
|
|
2006-04-17 00:37:51 +00:00
|
|
|
printf("There were still: %d files open\n", fpoint);
|
2006-03-28 15:44:01 +00:00
|
|
|
while(fpoint>0)
|
|
|
|
{
|
2007-10-09 18:44:07 +00:00
|
|
|
#ifdef SIMULATOR
|
|
|
|
close(filearray[fpoint]);
|
|
|
|
#else
|
2006-03-28 15:44:01 +00:00
|
|
|
rb->close(filearray[fpoint]);
|
2007-10-09 18:44:07 +00:00
|
|
|
#endif
|
2006-03-28 15:44:01 +00:00
|
|
|
fpoint--;
|
|
|
|
}
|
|
|
|
|
2006-04-09 15:00:30 +00:00
|
|
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
2006-03-28 15:44:01 +00:00
|
|
|
rb->cpu_boost(false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|