Files
ci-libretro-fceumm/src/general.c

105 lines
2.4 KiB
C
Raw Normal View History

/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2002 Xodnizel
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
2014-04-15 01:59:54 -07:00
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
2014-04-15 01:59:54 -07:00
#endif
#include <file/file_path.h>
#include "fceu-types.h"
#include "fceu.h"
#include "general.h"
#include "state.h"
#include "driver.h"
#include "md5.h"
static char BaseDirectory[2048] = {0};
void FCEUI_SetBaseDirectory(const char *dir)
2015-08-06 13:03:54 +02:00
{
strncpy(BaseDirectory, dir, 2047);
BaseDirectory[2047] = 0;
}
2017-10-15 03:13:11 +08:00
static char *odirs[FCEUIOD__COUNT] = { 0, 0, 0, 0, 0, 0 }; /* odirs, odors. ^_^ */
2015-08-06 13:03:54 +02:00
void FCEUI_SetDirOverride(int which, char *n)
{
odirs[which] = n;
}
2015-08-06 13:03:54 +02:00
char *FCEU_MakeFName(int type, int id1, char *cd1)
{
2020-10-25 08:31:41 +08:00
char tmp[4096 + 512] = {0}; /* +512 for no reason :D */
2016-09-09 07:48:53 +02:00
char *ret = 0;
2015-08-06 13:03:54 +02:00
switch (type)
{
case FCEUMKF_GGROM:
fill_pathname_join(tmp, BaseDirectory,
"gg.rom", sizeof(tmp));
2015-08-06 13:03:54 +02:00
break;
case FCEUMKF_FDSROM:
fill_pathname_join(tmp, BaseDirectory,
"disksys.rom", sizeof(tmp));
2015-08-06 13:03:54 +02:00
break;
case FCEUMKF_PALETTE:
fill_pathname_join(tmp, BaseDirectory,
"nes.pal", sizeof(tmp));
2017-03-15 02:32:00 +08:00
break;
2015-08-06 13:03:54 +02:00
default:
2016-09-09 07:48:53 +02:00
break;
2015-08-06 13:03:54 +02:00
}
2016-09-09 07:48:53 +02:00
FCEU_printf(" FCEU_MakeFName: %s\n", tmp);
ret = (char*)malloc(strlen(tmp) * sizeof(char) + 1);
strcpy(ret, tmp);
2015-08-06 13:03:54 +02:00
return(ret);
}
2015-08-06 13:03:54 +02:00
uint32 uppow2(uint32 n)
{
int x;
for (x = 31; x >= 0; x--)
if (n & (1 << x))
{
if ((1 << x) != n)
return(1 << (x + 1));
break;
}
return n;
}