mirror of
https://github.com/libretro/libretro-common.git
synced 2025-02-26 03:26:24 +00:00
Cleanups
This commit is contained in:
parent
f88c23f5c6
commit
670db51124
@ -26,15 +26,15 @@
|
||||
#include <streams/file_stream.h>
|
||||
#include <formats/rbmp.h>
|
||||
|
||||
static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool is32bpp)
|
||||
void form_bmp_header(uint8_t *header,
|
||||
unsigned width, unsigned height,
|
||||
bool is32bpp)
|
||||
{
|
||||
uint8_t header[54];
|
||||
unsigned line_size = (width * (is32bpp?4:3) + 3) & ~3;
|
||||
unsigned size = line_size * height + 54;
|
||||
unsigned size_array = line_size * height;
|
||||
|
||||
/* Generic BMP stuff. */
|
||||
|
||||
/* signature */
|
||||
header[0] = 'B';
|
||||
header[1] = 'M';
|
||||
@ -72,7 +72,7 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool
|
||||
header[26] = 1;
|
||||
header[27] = 0;
|
||||
/* Bits per pixel */
|
||||
header[28] = is32bpp?32:24;
|
||||
header[28] = 24;
|
||||
header[29] = 0;
|
||||
/* Compression method */
|
||||
header[30] = 0;
|
||||
@ -104,7 +104,12 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool
|
||||
header[51] = 0;
|
||||
header[52] = 0;
|
||||
header[53] = 0;
|
||||
}
|
||||
|
||||
static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool is32bpp)
|
||||
{
|
||||
uint8_t header[54];
|
||||
form_bmp_header(header, width, height, is32bpp);
|
||||
return filestream_write(file, header, sizeof(header)) == sizeof(header);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,10 @@ bool rbmp_save_image(
|
||||
int rbmp_process_image(rbmp_t *rbmp, void **buf,
|
||||
size_t size, unsigned *width, unsigned *height);
|
||||
|
||||
void form_bmp_header(uint8_t *header,
|
||||
unsigned width, unsigned height,
|
||||
bool is32bpp);
|
||||
|
||||
bool rbmp_set_buf_ptr(rbmp_t *rbmp, void *data);
|
||||
|
||||
void rbmp_free(rbmp_t *rbmp);
|
||||
|
@ -1117,7 +1117,7 @@ enum retro_mod
|
||||
* This may be still be done regardless of the core options
|
||||
* interface version.
|
||||
*
|
||||
* If version is >= 1 however, core options may instead be set by
|
||||
* If version is 1 however, core options may instead be set by
|
||||
* passing an array of retro_core_option_definition structs to
|
||||
* RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of
|
||||
* retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
|
||||
@ -1132,8 +1132,8 @@ enum retro_mod
|
||||
* GET_VARIABLE.
|
||||
* This allows the frontend to present these variables to
|
||||
* a user dynamically.
|
||||
* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
|
||||
* returns an API version of >= 1.
|
||||
* This should only be called if RETRO_ENVIRONMENT_GET_ENHANCED_CORE_OPTIONS
|
||||
* returns an API version of 1.
|
||||
* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
|
||||
* This should be called the first time as early as
|
||||
* possible (ideally in retro_set_environment).
|
||||
@ -1169,6 +1169,8 @@ enum retro_mod
|
||||
* i.e. it should be feasible to cycle through options
|
||||
* without a keyboard.
|
||||
*
|
||||
* First entry should be treated as a default.
|
||||
*
|
||||
* Example entry:
|
||||
* {
|
||||
* "foo_option",
|
||||
@ -1194,8 +1196,8 @@ enum retro_mod
|
||||
* GET_VARIABLE.
|
||||
* This allows the frontend to present these variables to
|
||||
* a user dynamically.
|
||||
* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
|
||||
* returns an API version of >= 1.
|
||||
* This should only be called if RETRO_ENVIRONMENT_GET_ENHANCED_CORE_OPTIONS
|
||||
* returns an API version of 1.
|
||||
* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
|
||||
* This should be called the first time as early as
|
||||
* possible (ideally in retro_set_environment).
|
||||
@ -2502,20 +2504,8 @@ struct retro_core_option_display
|
||||
};
|
||||
|
||||
/* Maximum number of values permitted for a core option
|
||||
* > Note: We have to set a maximum value due the limitations
|
||||
* of the C language - i.e. it is not possible to create an
|
||||
* array of structs each containing a variable sized array,
|
||||
* so the retro_core_option_definition values array must
|
||||
* have a fixed size. The size limit of 128 is a balancing
|
||||
* act - it needs to be large enough to support all 'sane'
|
||||
* core options, but setting it too large may impact low memory
|
||||
* platforms. In practise, if a core option has more than
|
||||
* 128 values then the implementation is likely flawed.
|
||||
* To quote the above API reference:
|
||||
* "The number of possible options should be very limited
|
||||
* i.e. it should be feasible to cycle through options
|
||||
* without a keyboard."
|
||||
*/
|
||||
* NOTE: This may be increased on a core-by-core basis
|
||||
* if required (doing so has no effect on the frontend) */
|
||||
#define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
|
||||
|
||||
struct retro_core_option_value
|
||||
|
@ -132,9 +132,6 @@ void file_list_set_userdata(const file_list_t *list, size_t idx, void *ptr);
|
||||
|
||||
void file_list_set_actiondata(const file_list_t *list, size_t idx, void *ptr);
|
||||
|
||||
void file_list_get_alt_at_offset(const file_list_t *list, size_t index,
|
||||
const char **alt);
|
||||
|
||||
void file_list_sort_on_alt(file_list_t *list);
|
||||
|
||||
void file_list_sort_on_type(file_list_t *list);
|
||||
|
@ -265,15 +265,6 @@ void file_list_set_alt_at_offset(file_list_t *list, size_t idx,
|
||||
list->list[idx].alt = strdup(alt);
|
||||
}
|
||||
|
||||
void file_list_get_alt_at_offset(const file_list_t *list, size_t idx,
|
||||
const char **alt)
|
||||
{
|
||||
if (list && alt)
|
||||
*alt = list->list[idx].alt
|
||||
? list->list[idx].alt
|
||||
: list->list[idx].path;
|
||||
}
|
||||
|
||||
static int file_list_alt_cmp(const void *a_, const void *b_)
|
||||
{
|
||||
const struct item_file *a = (const struct item_file*)a_;
|
||||
@ -384,7 +375,6 @@ void file_list_get_last(const file_list_t *list,
|
||||
bool file_list_search(const file_list_t *list, const char *needle, size_t *idx)
|
||||
{
|
||||
size_t i;
|
||||
const char *alt = NULL;
|
||||
bool ret = false;
|
||||
|
||||
if (!list)
|
||||
@ -393,8 +383,10 @@ bool file_list_search(const file_list_t *list, const char *needle, size_t *idx)
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
const char *str = NULL;
|
||||
const char *alt = list->list[i].alt
|
||||
? list->list[i].alt
|
||||
: list->list[i].path;
|
||||
|
||||
file_list_get_alt_at_offset(list, i, &alt);
|
||||
if (!alt)
|
||||
{
|
||||
file_list_get_label_at_offset(list, i, &alt);
|
||||
|
@ -938,7 +938,9 @@ int retro_vfs_stat_impl(const char *path, int32_t *size)
|
||||
/* if fileXioGetStat fails */
|
||||
int dir_ret = fileXioDopen(path);
|
||||
is_dir = dir_ret > 0;
|
||||
fileXioDclose(dir_ret);
|
||||
if (is_dir) {
|
||||
fileXioDclose(dir_ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
is_dir = FIO_S_ISDIR(buf.mode);
|
||||
@ -1227,21 +1229,28 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir)
|
||||
|
||||
const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir)
|
||||
{
|
||||
if (!rdir)
|
||||
return NULL;
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(LEGACY_WIN32)
|
||||
char *name_local = local_to_utf8_string_alloc(rdir->entry.cFileName);
|
||||
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
|
||||
strlcpy(rdir->entry.cFileName, name_local, sizeof(rdir->entry.cFileName));
|
||||
{
|
||||
char *name_local = local_to_utf8_string_alloc(rdir->entry.cFileName);
|
||||
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
|
||||
strlcpy(rdir->entry.cFileName, name_local, sizeof(rdir->entry.cFileName));
|
||||
|
||||
if (name_local)
|
||||
free(name_local);
|
||||
if (name_local)
|
||||
free(name_local);
|
||||
}
|
||||
#else
|
||||
char *name = utf16_to_utf8_string_alloc(rdir->entry.cFileName);
|
||||
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
|
||||
strlcpy((char*)rdir->entry.cFileName, name, sizeof(rdir->entry.cFileName));
|
||||
{
|
||||
char *name = utf16_to_utf8_string_alloc(rdir->entry.cFileName);
|
||||
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
|
||||
strlcpy((char*)rdir->entry.cFileName, name, sizeof(rdir->entry.cFileName));
|
||||
|
||||
if (name)
|
||||
free(name);
|
||||
if (name)
|
||||
free(name);
|
||||
}
|
||||
#endif
|
||||
return (char*)rdir->entry.cFileName;
|
||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(ORBIS)
|
||||
@ -1249,7 +1258,6 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir
|
||||
#elif defined(PS2)
|
||||
return rdir->entry.name;
|
||||
#else
|
||||
|
||||
return rdir->entry->d_name;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user