mirror of
https://github.com/libretro/mame2003-plus-libretro.git
synced 2024-11-27 18:40:31 +00:00
C89 fixes - code needs to be C89 compliant for Xbox 1/ Xbox 360
and QNX
This commit is contained in:
parent
52783981e8
commit
5d5d73fbd2
2
makefile
2
makefile
@ -53,7 +53,7 @@ endif
|
||||
OBJ = obj/mame
|
||||
DEFS = -DINLINE="static __inline__" -Dasm=__asm__
|
||||
|
||||
CFLAGS = -std=gnu99 -Isrc -Isrc/includes -Isrc/$(MAMEOS) -I$(OBJ)/cpu/m68000 -Isrc/cpu/m68000
|
||||
CFLAGS = -Isrc -Isrc/includes -Isrc/$(MAMEOS) -I$(OBJ)/cpu/m68000 -Isrc/cpu/m68000
|
||||
|
||||
# libretro keyboard
|
||||
USE_RETRO_KEYBOARD = 0
|
||||
|
@ -16,8 +16,6 @@
|
||||
void mame_frame(void);
|
||||
void mame_done(void);
|
||||
|
||||
//
|
||||
|
||||
static retro_video_refresh_t video_cb = NULL;
|
||||
static retro_input_poll_t poll_cb = NULL;
|
||||
static retro_input_state_t input_cb = NULL;
|
||||
@ -31,9 +29,6 @@ void retro_set_input_poll(retro_input_poll_t cb) { poll_cb = cb; }
|
||||
void retro_set_input_state(retro_input_state_t cb) { input_cb = cb; }
|
||||
void retro_set_environment(retro_environment_t cb) { environ_cb = cb; }
|
||||
|
||||
|
||||
//
|
||||
|
||||
#ifndef PATH_SEPARATOR
|
||||
# if defined(WINDOWS_PATH_STYLE) || defined(_WIN32)
|
||||
# define PATH_SEPARATOR '\\'
|
||||
@ -44,41 +39,40 @@ void retro_set_environment(retro_environment_t cb) { environ_cb = cb; }
|
||||
|
||||
static char* normalizePath(char* aPath)
|
||||
{
|
||||
static const char replaced = (PATH_SEPARATOR == '\\') ? '/' : '\\';
|
||||
char *tok;
|
||||
static const char replaced = (PATH_SEPARATOR == '\\') ? '/' : '\\';
|
||||
|
||||
for(char* tok = strchr(aPath, replaced); tok; tok = strchr(aPath, replaced))
|
||||
{
|
||||
*tok = PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
return aPath;
|
||||
for (tok = strchr(aPath, replaced); tok; tok = strchr(aPath, replaced))
|
||||
*tok = PATH_SEPARATOR;
|
||||
|
||||
return aPath;
|
||||
}
|
||||
|
||||
static int getDriverIndex(const char* aPath)
|
||||
{
|
||||
char driverName[128];
|
||||
char *path, *last;
|
||||
char *firstDot;
|
||||
int i;
|
||||
|
||||
// Get all chars after the last slash
|
||||
char* path = normalizePath(strdup(aPath ? aPath : "."));
|
||||
char* last = strrchr(path, PATH_SEPARATOR);
|
||||
path = normalizePath(strdup(aPath ? aPath : "."));
|
||||
last = strrchr(path, PATH_SEPARATOR);
|
||||
memset(driverName, 0, sizeof(driverName));
|
||||
strncpy(driverName, last ? last + 1 : path, sizeof(driverName) - 1);
|
||||
free(path);
|
||||
|
||||
// Remove extension
|
||||
char* const firstDot = strchr(driverName, '.');
|
||||
firstDot = strchr(driverName, '.');
|
||||
|
||||
if(firstDot)
|
||||
{
|
||||
*firstDot = 0;
|
||||
}
|
||||
*firstDot = 0;
|
||||
|
||||
// Search list
|
||||
for(int i = 0; drivers[i]; i ++)
|
||||
for (i = 0; drivers[i]; i++)
|
||||
{
|
||||
if(0 == strcmp(driverName, drivers[i]->name))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
if(strcmp(driverName, drivers[i]->name) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -88,9 +82,7 @@ static char* peelPathItem(char* aPath)
|
||||
{
|
||||
char* last = strrchr(aPath, PATH_SEPARATOR);
|
||||
if(last)
|
||||
{
|
||||
*last = 0;
|
||||
}
|
||||
*last = 0;
|
||||
|
||||
return aPath;
|
||||
}
|
||||
@ -164,33 +156,38 @@ void retro_reset (void)
|
||||
|
||||
void retro_run (void)
|
||||
{
|
||||
poll_cb();
|
||||
|
||||
// Keyboard
|
||||
int i, j;
|
||||
int *jsState;
|
||||
#if USE_RETRO_KEYBOARD
|
||||
const struct KeyboardInfo *thisInput;
|
||||
#endif
|
||||
const void *gotFrame;
|
||||
|
||||
poll_cb();
|
||||
|
||||
// Keyboard
|
||||
#if USE_RETRO_KEYBOARD == 1
|
||||
const struct KeyboardInfo* thisInput = retroKeys;
|
||||
while(thisInput->name)
|
||||
{
|
||||
retroKeyState[thisInput->code] = input_cb(0, RETRO_DEVICE_KEYBOARD, 0, thisInput->code);
|
||||
thisInput ++;
|
||||
}
|
||||
thisInput = retroKeys;
|
||||
while(thisInput->name)
|
||||
{
|
||||
retroKeyState[thisInput->code] = input_cb(0, RETRO_DEVICE_KEYBOARD, 0, thisInput->code);
|
||||
thisInput ++;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Joystick
|
||||
int* jsState = retroJsState;
|
||||
for(int i = 0; i != 4; i ++)
|
||||
{
|
||||
for(int j = 0; j != 16; j ++)
|
||||
{
|
||||
*jsState++ = input_cb(i, RETRO_DEVICE_JOYPAD, 0, j);
|
||||
}
|
||||
}
|
||||
|
||||
mame_frame();
|
||||
|
||||
const void* gotFrame = (videoBufferWidth && videoBufferHeight) ? videoBuffer : 0;
|
||||
video_cb(gotFrame, videoBufferWidth, videoBufferHeight, videoBufferWidth * ((RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode) ? 4 : 2));
|
||||
audio_batch_cb(XsoundBuffer, Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
// Joystick
|
||||
jsState = retroJsState;
|
||||
for (i = 0; i < 4; i ++)
|
||||
{
|
||||
for (j = 0; j < 16; j ++)
|
||||
*jsState++ = input_cb(i, RETRO_DEVICE_JOYPAD, 0, j);
|
||||
}
|
||||
|
||||
mame_frame();
|
||||
|
||||
gotFrame = (videoBufferWidth && videoBufferHeight) ? videoBuffer : 0;
|
||||
video_cb(gotFrame, videoBufferWidth, videoBufferHeight, videoBufferWidth * ((RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode) ? 4 : 2));
|
||||
audio_batch_cb(XsoundBuffer, Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +196,7 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
// Find game index
|
||||
driverIndex = getDriverIndex(game->path);
|
||||
|
||||
if(0 <= driverIndex)
|
||||
if(driverIndex <= 0)
|
||||
{
|
||||
// Get MAME Directory
|
||||
systemDir = normalizePath(strdup(game->path));
|
||||
@ -252,6 +249,7 @@ size_t retro_serialize_size(void)
|
||||
|
||||
bool retro_serialize(void *data, size_t size)
|
||||
{
|
||||
int cpunum;
|
||||
if(retro_serialize_size() && data && size)
|
||||
{
|
||||
/* write the save state */
|
||||
@ -265,7 +263,7 @@ bool retro_serialize(void *data, size_t size)
|
||||
}
|
||||
|
||||
/* loop over CPUs */
|
||||
for(int cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
|
||||
for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
|
||||
{
|
||||
cpuintrf_push_context(cpunum);
|
||||
|
||||
@ -275,9 +273,7 @@ bool retro_serialize(void *data, size_t size)
|
||||
/* save the CPU data */
|
||||
state_save_set_current_tag(cpunum + 1);
|
||||
if(state_save_save_continue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cpuintrf_pop_context();
|
||||
}
|
||||
@ -293,18 +289,17 @@ bool retro_serialize(void *data, size_t size)
|
||||
|
||||
bool retro_unserialize(const void * data, size_t size)
|
||||
{
|
||||
int cpunum;
|
||||
/* if successful, load it */
|
||||
if (retro_serialize_size() && data && size && !state_save_load_begin((void*)data, size))
|
||||
{
|
||||
/* read tag 0 */
|
||||
state_save_set_current_tag(0);
|
||||
if(state_save_load_continue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* loop over CPUs */
|
||||
for(int cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
|
||||
for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
|
||||
{
|
||||
cpuintrf_push_context(cpunum);
|
||||
|
||||
@ -314,9 +309,7 @@ bool retro_unserialize(const void * data, size_t size)
|
||||
/* load the CPU data */
|
||||
state_save_set_current_tag(cpunum + 1);
|
||||
if(state_save_load_continue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
cpuintrf_pop_context();
|
||||
}
|
||||
|
@ -43,6 +43,16 @@ else ifeq ($(platform), android)
|
||||
CC = arm-linux-androideabi-gcc
|
||||
AR = arm-linux-androideabi-ar
|
||||
LD = arm-linux-androideabi-gcc
|
||||
else ifeq ($(platform), qnx)
|
||||
EMULATOR = mame078_libretro.so
|
||||
|
||||
CFLAGS += -fPIC
|
||||
PLATCFLAGS += -march=armv7-a -Dstricmp=strcasecmp
|
||||
LDFLAGS += -fPIC -shared -Wl,--version-script=src/libretro/link.T
|
||||
|
||||
CC = qcc -Vgcc_ntoarmv7le
|
||||
AR = qcc -Vgcc_ntoarmv7le
|
||||
LD = QCC -Vgcc_ntoarmv7le
|
||||
else ifeq ($(platform), wii)
|
||||
EMULATOR = mame078_libretro_wii.a
|
||||
BIGENDIAN = 1
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "mame.h"
|
||||
#include "driver.h"
|
||||
|
||||
|
||||
extern int16_t XsoundBuffer[2048];
|
||||
extern char* systemDir;
|
||||
extern char* romDir;
|
||||
@ -109,21 +108,22 @@ int osd_start_audio_stream(int aStereo)
|
||||
|
||||
int osd_update_audio_stream(INT16 *buffer)
|
||||
{
|
||||
int samplerate_buffer_size = (Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
if(stereo)
|
||||
{
|
||||
memcpy(XsoundBuffer, buffer, samplerate_buffer_size * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < samplerate_buffer_size; i ++)
|
||||
{
|
||||
XsoundBuffer[i * 2 + 0] = buffer[i];
|
||||
XsoundBuffer[i * 2 + 1] = buffer[i];
|
||||
}
|
||||
}
|
||||
int i, samplerate_buffer_size;
|
||||
|
||||
return (Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
samplerate_buffer_size = (Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
|
||||
if(stereo)
|
||||
memcpy(XsoundBuffer, buffer, samplerate_buffer_size * 4);
|
||||
else
|
||||
{
|
||||
for (i = 0; i < samplerate_buffer_size; i ++)
|
||||
{
|
||||
XsoundBuffer[i * 2 + 0] = buffer[i];
|
||||
XsoundBuffer[i * 2 + 1] = buffer[i];
|
||||
}
|
||||
}
|
||||
|
||||
return (Machine->sample_rate / Machine->drv->frames_per_second);
|
||||
}
|
||||
|
||||
void osd_stop_audio_stream(void)
|
||||
@ -191,34 +191,32 @@ int osd_get_path_info(int pathtype, int pathindex, const char *filename)
|
||||
|
||||
osd_file *osd_fopen(int pathtype, int pathindex, const char *filename, const char *mode)
|
||||
{
|
||||
char buffer[1024];
|
||||
char buffer[1024];
|
||||
|
||||
switch(pathtype)
|
||||
{
|
||||
case 1: /* ROM */
|
||||
/* removes the stupid restriction where we need to have roms in a 'rom' folder */
|
||||
snprintf(buffer, 1024, "%s/%s", romDir, filename);
|
||||
break;
|
||||
default:
|
||||
snprintf(buffer, 1024, "%s/%s/%s", systemDir, paths[pathtype], filename);
|
||||
}
|
||||
switch(pathtype)
|
||||
{
|
||||
case 1: /* ROM */
|
||||
/* removes the stupid restriction where we need to have roms in a 'rom' folder */
|
||||
snprintf(buffer, 1024, "%s/%s", romDir, filename);
|
||||
break;
|
||||
default:
|
||||
snprintf(buffer, 1024, "%s/%s/%s", systemDir, paths[pathtype], filename);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
fprintf(stderr, "osd_fopen (buffer = [%s]), (systemDir: [%s]), (path type dir: [%s]), (path: [%d]), (filename: [%s]) \n", buffer, systemDir, paths[pathtype], pathtype, filename);
|
||||
fprintf(stderr, "osd_fopen (buffer = [%s]), (systemDir: [%s]), (path type dir: [%s]), (path: [%d]), (filename: [%s]) \n", buffer, systemDir, paths[pathtype], pathtype, filename);
|
||||
#endif
|
||||
|
||||
osd_file* out = malloc(sizeof(osd_file));
|
||||
out->file = fopen(buffer, mode);
|
||||
|
||||
if(out->file == 0)
|
||||
{
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return out;
|
||||
}
|
||||
osd_file* out = malloc(sizeof(osd_file));
|
||||
out->file = fopen(buffer, mode);
|
||||
|
||||
if(out->file == 0)
|
||||
{
|
||||
free(out);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return out;
|
||||
}
|
||||
|
||||
int osd_fseek(osd_file *file, INT64 offset, int whence)
|
||||
|
@ -23,57 +23,55 @@ static uint32_t* convertedPalette;
|
||||
|
||||
int osd_create_display(const struct osd_create_params *params, UINT32 *rgb_components)
|
||||
{
|
||||
extern unsigned retroColorMode;
|
||||
static const UINT32 rValues[3] = {0x7C00, 0xFF0000, (0x1F << 11)};
|
||||
static const UINT32 gValues[3] = {0x03E0, 0x00FF00, (0x3F << 5)};
|
||||
static const UINT32 bValues[3] = {0x001F, 0x0000FF, (0x1F)};
|
||||
extern unsigned retroColorMode;
|
||||
static const UINT32 rValues[3] = {0x7C00, 0xFF0000, (0x1F << 11)};
|
||||
static const UINT32 gValues[3] = {0x03E0, 0x00FF00, (0x3F << 5)};
|
||||
static const UINT32 bValues[3] = {0x001F, 0x0000FF, (0x1F)};
|
||||
|
||||
memcpy(&videoConfig, params, sizeof(videoConfig));
|
||||
memcpy(&videoConfig, params, sizeof(videoConfig));
|
||||
|
||||
if(Machine->color_depth == 16)
|
||||
{
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_RGB565;
|
||||
if(!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &retroColorMode))
|
||||
{
|
||||
fprintf(stderr, "game bpp: [16], system bpp: [16], color format [RGB565] : NOT AVAILABLE, defaulting to color format [0RGB1555] (SLOW PATH).\n");
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_0RGB1555;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "game bpp: [16], system bpp: [16], color format [RGB565] : SUPPORTED, enabling it.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], defaulting to bpp: [32], color format [XRGB8888].\n", Machine->color_depth);
|
||||
// Assume 32bit color by default
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
if(environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &retroColorMode))
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], system bpp: [32], color format [XRGB8888] : SUPPORTED, enabling it.\n", Machine->color_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], system bpp: [32], color format [XRGB8888] : NOT AVAILLE, defaulting to color format [0RGB1555] (SLOW PATH).\n", Machine->color_depth);
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_0RGB1555;
|
||||
}
|
||||
}
|
||||
|
||||
if(Machine->color_depth == 15)
|
||||
{
|
||||
const int val = (RETRO_PIXEL_FORMAT_RGB565 == retroColorMode) ? 2 : 0;
|
||||
rgb_components[0] = rValues[val];
|
||||
rgb_components[1] = gValues[val];
|
||||
rgb_components[2] = bValues[val];
|
||||
}
|
||||
else if(Machine->color_depth == 32)
|
||||
{
|
||||
rgb_components[0] = rValues[1];
|
||||
rgb_components[1] = gValues[1];
|
||||
rgb_components[2] = bValues[1];
|
||||
}
|
||||
if(Machine->color_depth == 16)
|
||||
{
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_RGB565;
|
||||
if(!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &retroColorMode))
|
||||
{
|
||||
fprintf(stderr, "game bpp: [16], system bpp: [16], color format [RGB565] : NOT AVAILABLE, defaulting to color format [0RGB1555] (SLOW PATH).\n");
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_0RGB1555;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "game bpp: [16], system bpp: [16], color format [RGB565] : SUPPORTED, enabling it.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], defaulting to bpp: [32], color format [XRGB8888].\n", Machine->color_depth);
|
||||
// Assume 32bit color by default
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
if(environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &retroColorMode))
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], system bpp: [32], color format [XRGB8888] : SUPPORTED, enabling it.\n", Machine->color_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "game bpp: [%d], system bpp: [32], color format [XRGB8888] : NOT AVAILLE, defaulting to color format [0RGB1555] (SLOW PATH).\n", Machine->color_depth);
|
||||
retroColorMode = RETRO_PIXEL_FORMAT_0RGB1555;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if(Machine->color_depth == 15)
|
||||
{
|
||||
const int val = (RETRO_PIXEL_FORMAT_RGB565 == retroColorMode) ? 2 : 0;
|
||||
rgb_components[0] = rValues[val];
|
||||
rgb_components[1] = gValues[val];
|
||||
rgb_components[2] = bValues[val];
|
||||
}
|
||||
else if(Machine->color_depth == 32)
|
||||
{
|
||||
rgb_components[0] = rValues[1];
|
||||
rgb_components[1] = gValues[1];
|
||||
rgb_components[2] = bValues[1];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void osd_close_display(void)
|
||||
@ -91,44 +89,42 @@ int osd_skip_this_frame(void)
|
||||
// But mummy I wan't to use templates
|
||||
#define PALETTE_COPY(OTYPE) \
|
||||
{ \
|
||||
OTYPE* output = (OTYPE*)videoBuffer; \
|
||||
const uint16_t* input = &((uint16_t*)display->game_bitmap->base)[y * pitch + x]; \
|
||||
OTYPE* output = (OTYPE*)videoBuffer; \
|
||||
const uint16_t* input = &((uint16_t*)display->game_bitmap->base)[y * pitch + x]; \
|
||||
\
|
||||
for(int i = 0; i != height; i ++) \
|
||||
{ \
|
||||
for(int j = 0; j != width; j ++) \
|
||||
{ \
|
||||
*output++ = convertedPalette[*input++]; \
|
||||
} \
|
||||
input += pitch - width; \
|
||||
} \
|
||||
for(i = 0; i < height; i ++) \
|
||||
{ \
|
||||
for(j = 0; j < width; j ++) \
|
||||
*output++ = convertedPalette[*input++]; \
|
||||
input += pitch - width; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define DIRECT_COPY(OTYPE, ITYPE, ALLOWSIMPLE, RDOWN, RMASK, RUP, GDOWN, GMASK, GUP, BDOWN, BMASK, BUP) \
|
||||
{ \
|
||||
OTYPE* output = (OTYPE*)videoBuffer; \
|
||||
const ITYPE* input = &((const ITYPE*)display->game_bitmap->base)[y * pitch + x]; \
|
||||
\
|
||||
for(int i = 0; i != height; i ++) \
|
||||
{ \
|
||||
if(ALLOWSIMPLE && sizeof(OTYPE) == sizeof(ITYPE)) \
|
||||
{ \
|
||||
memcpy(&output[i * videoConfig.width], input, width * sizeof(OTYPE)); \
|
||||
input += pitch; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
for(int j = 0; j != width; j ++) \
|
||||
{ \
|
||||
const uint32_t color = *input ++; \
|
||||
const uint32_t r = ((color >> (RDOWN)) & RMASK) << RUP; \
|
||||
const uint32_t g = ((color >> (GDOWN)) & GMASK) << GUP; \
|
||||
const uint32_t b = ((color >> (BDOWN)) & BMASK) << BUP; \
|
||||
*output++ = r | g | b; \
|
||||
} \
|
||||
input += pitch - width; \
|
||||
} \
|
||||
} \
|
||||
OTYPE* output = (OTYPE*)videoBuffer; \
|
||||
const ITYPE* input = &((const ITYPE*)display->game_bitmap->base)[y * pitch + x]; \
|
||||
\
|
||||
for(i = 0; i < height; i ++) \
|
||||
{ \
|
||||
if(ALLOWSIMPLE && sizeof(OTYPE) == sizeof(ITYPE)) \
|
||||
{ \
|
||||
memcpy(&output[i * videoConfig.width], input, width * sizeof(OTYPE)); \
|
||||
input += pitch; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
for(j = 0; j < width; j ++) \
|
||||
{ \
|
||||
const uint32_t color = *input ++; \
|
||||
const uint32_t r = ((color >> (RDOWN)) & RMASK) << RUP; \
|
||||
const uint32_t g = ((color >> (GDOWN)) & GMASK) << GUP; \
|
||||
const uint32_t b = ((color >> (BDOWN)) & BMASK) << BUP; \
|
||||
*output++ = r | g | b; \
|
||||
} \
|
||||
input += pitch - width; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SIMPLE_DIRECT_COPY(OTYPE) DIRECT_COPY(OTYPE, OTYPE, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
@ -138,9 +134,7 @@ static uint32_t rgb32toNeeded(uint32_t aColor)
|
||||
extern unsigned retroColorMode;
|
||||
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
return aColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint32_t r = (aColor >> 19) & 0x1F;
|
||||
@ -154,98 +148,99 @@ static uint32_t rgb32toNeeded(uint32_t aColor)
|
||||
|
||||
void osd_update_video_and_audio(struct mame_display *display)
|
||||
{
|
||||
RARCH_PERFORMANCE_INIT(update_video_and_audio);
|
||||
RARCH_PERFORMANCE_START(update_video_and_audio);
|
||||
int i, j;
|
||||
RARCH_PERFORMANCE_INIT(update_video_and_audio);
|
||||
RARCH_PERFORMANCE_START(update_video_and_audio);
|
||||
|
||||
if(display->changed_flags & 0xF)
|
||||
{
|
||||
// Update UI area
|
||||
if(display->changed_flags & GAME_VISIBLE_AREA_CHANGED)
|
||||
{
|
||||
set_ui_visarea(display->game_visible_area.min_x, display->game_visible_area.min_y, display->game_visible_area.max_x, display->game_visible_area.max_y);
|
||||
}
|
||||
|
||||
// Update palette
|
||||
if(display->changed_flags & GAME_PALETTE_CHANGED)
|
||||
{
|
||||
if(display->game_palette_entries > totalColors)
|
||||
{
|
||||
totalColors = display->game_palette_entries;
|
||||
free(convertedPalette);
|
||||
convertedPalette = malloc(4 * display->game_palette_entries + (32 * 4));
|
||||
}
|
||||
|
||||
for(int i = 0; i < display->game_palette_entries; i += 32)
|
||||
{
|
||||
UINT32 dirtyField = display->game_palette_dirty[i / 32];
|
||||
|
||||
for(int j = 0; dirtyField; j ++, dirtyField >>= 1)
|
||||
{
|
||||
if(dirtyField & 1)
|
||||
{
|
||||
convertedPalette[i + j] = rgb32toNeeded(display->game_palette[i + j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern unsigned retroColorMode;
|
||||
|
||||
// Cache some values used in the below macros
|
||||
const uint32_t x = display->game_visible_area.min_x;
|
||||
const uint32_t y = display->game_visible_area.min_y;
|
||||
const uint32_t width = videoConfig.width;
|
||||
const uint32_t height = videoConfig.height;
|
||||
const uint32_t pitch = display->game_bitmap->rowpixels;
|
||||
if(display->changed_flags & 0xF)
|
||||
{
|
||||
// Update UI area
|
||||
if(display->changed_flags & GAME_VISIBLE_AREA_CHANGED)
|
||||
{
|
||||
set_ui_visarea(display->game_visible_area.min_x, display->game_visible_area.min_y, display->game_visible_area.max_x, display->game_visible_area.max_y);
|
||||
}
|
||||
|
||||
// Copy image size
|
||||
videoBufferWidth = width;
|
||||
videoBufferHeight = height;
|
||||
// Update palette
|
||||
if(display->changed_flags & GAME_PALETTE_CHANGED)
|
||||
{
|
||||
if(display->game_palette_entries > totalColors)
|
||||
{
|
||||
totalColors = display->game_palette_entries;
|
||||
free(convertedPalette);
|
||||
convertedPalette = malloc(4 * display->game_palette_entries + (32 * 4));
|
||||
}
|
||||
|
||||
// Copy pixels
|
||||
if(display->game_bitmap->depth == 16)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
for(i = 0; i < display->game_palette_entries; i += 32)
|
||||
{
|
||||
UINT32 dirtyField = display->game_palette_dirty[i / 32];
|
||||
|
||||
for(j = 0; dirtyField; j ++, dirtyField >>= 1)
|
||||
{
|
||||
PALETTE_COPY(uint32_t);
|
||||
if(dirtyField & 1)
|
||||
convertedPalette[i + j] = rgb32toNeeded(display->game_palette[i + j]);
|
||||
}
|
||||
else
|
||||
{
|
||||
PALETTE_COPY(uint16_t);
|
||||
}
|
||||
}
|
||||
else if(display->game_bitmap->depth == 32)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
SIMPLE_DIRECT_COPY(uint32_t);
|
||||
}
|
||||
else if(RETRO_PIXEL_FORMAT_0RGB1555 == retroColorMode)
|
||||
{
|
||||
DIRECT_COPY(uint16_t, uint32_t, 1, 19, 0x1F, 10, 11, 0x1F, 5, 3, 0x1F, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DIRECT_COPY(uint16_t, uint32_t, 1, 19, 0x1F, 11, 10, 0x3F, 5, 3, 0x1F, 0);
|
||||
}
|
||||
}
|
||||
else if(display->game_bitmap->depth == 15)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
DIRECT_COPY(uint32_t, uint16_t, 1, 10, 0x1F, 19, 5, 0x1F, 11, 0, 0x1F, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
SIMPLE_DIRECT_COPY(uint16_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gotFrame = 1;
|
||||
|
||||
RARCH_PERFORMANCE_STOP(update_video_and_audio);
|
||||
}
|
||||
}
|
||||
|
||||
extern unsigned retroColorMode;
|
||||
|
||||
// Cache some values used in the below macros
|
||||
const uint32_t x = display->game_visible_area.min_x;
|
||||
const uint32_t y = display->game_visible_area.min_y;
|
||||
const uint32_t width = videoConfig.width;
|
||||
const uint32_t height = videoConfig.height;
|
||||
const uint32_t pitch = display->game_bitmap->rowpixels;
|
||||
|
||||
// Copy image size
|
||||
videoBufferWidth = width;
|
||||
videoBufferHeight = height;
|
||||
|
||||
// Copy pixels
|
||||
if(display->game_bitmap->depth == 16)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
PALETTE_COPY(uint32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
PALETTE_COPY(uint16_t);
|
||||
}
|
||||
}
|
||||
else if(display->game_bitmap->depth == 32)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
SIMPLE_DIRECT_COPY(uint32_t);
|
||||
}
|
||||
else if(RETRO_PIXEL_FORMAT_0RGB1555 == retroColorMode)
|
||||
{
|
||||
DIRECT_COPY(uint16_t, uint32_t, 1, 19, 0x1F, 10, 11, 0x1F, 5, 3, 0x1F, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DIRECT_COPY(uint16_t, uint32_t, 1, 19, 0x1F, 11, 10, 0x3F, 5, 3, 0x1F, 0);
|
||||
}
|
||||
}
|
||||
else if(display->game_bitmap->depth == 15)
|
||||
{
|
||||
if(RETRO_PIXEL_FORMAT_XRGB8888 == retroColorMode)
|
||||
{
|
||||
DIRECT_COPY(uint32_t, uint16_t, 1, 10, 0x1F, 19, 5, 0x1F, 11, 0, 0x1F, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
SIMPLE_DIRECT_COPY(uint16_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gotFrame = 1;
|
||||
|
||||
RARCH_PERFORMANCE_STOP(update_video_and_audio);
|
||||
}
|
||||
|
||||
struct mame_bitmap *osd_override_snapshot(struct mame_bitmap *bitmap, struct rectangle *bounds){return NULL;}
|
||||
|
||||
struct mame_bitmap *osd_override_snapshot(struct mame_bitmap *bitmap, struct rectangle *bounds)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user