mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-26 17:40:40 +00:00
Cleanups
This commit is contained in:
parent
6845c604c2
commit
1b0fa60bc5
1
Makefile
1
Makefile
@ -271,7 +271,6 @@ MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
|
||||
$(MEDNAFEN_DIR)/state.cpp \
|
||||
$(CDROM_SOURCES) \
|
||||
$(MEDNAFEN_DIR)/mempatcher.cpp \
|
||||
$(MEDNAFEN_DIR)/video/surface.cpp \
|
||||
$(RESAMPLER_SOURCES) \
|
||||
$(MEDNAFEN_DIR)/file.cpp \
|
||||
$(OKIADPCM_SOURCES) \
|
||||
|
@ -94,7 +94,6 @@ MEDNAFEN_SOURCES := $(MEDNAFEN_DIR)/error.cpp \
|
||||
$(MEDNAFEN_DIR)/Stream.cpp \
|
||||
$(MEDNAFEN_DIR)/state.cpp \
|
||||
$(MEDNAFEN_DIR)/mempatcher.cpp \
|
||||
$(MEDNAFEN_DIR)/video/surface.cpp \
|
||||
$(MEDNAFEN_DIR)/sound/Blip_Buffer.cpp \
|
||||
$(MEDNAFEN_DIR)/file.cpp \
|
||||
$(OKIADPCM_SOURCES) \
|
||||
|
57
libretro.cpp
57
libretro.cpp
@ -413,31 +413,6 @@ static void Emulate(EmulateSpecStruct *espec)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static bool firstcat = true;
|
||||
|
||||
MDFN_PixelFormat tmp_pf;
|
||||
|
||||
tmp_pf.Rshift = 0;
|
||||
tmp_pf.Gshift = 0;
|
||||
tmp_pf.Bshift = 0;
|
||||
tmp_pf.Ashift = 8;
|
||||
|
||||
tmp_pf.Rprec = 0;
|
||||
tmp_pf.Gprec = 0;
|
||||
tmp_pf.Bprec = 0;
|
||||
tmp_pf.Aprec = 0;
|
||||
|
||||
tmp_pf.bpp = 8;
|
||||
tmp_pf.colorspace = MDFN_COLORSPACE_RGB;
|
||||
|
||||
espec->surface->SetFormat(tmp_pf, false);
|
||||
espec->VideoFormatChanged = firstcat;
|
||||
firstcat = false;
|
||||
#endif
|
||||
|
||||
if(espec->VideoFormatChanged)
|
||||
VDC_SetPixelFormat(espec->surface->format); //.Rshift, espec->surface->format.Gshift, espec->surface->format.Bshift);
|
||||
|
||||
if(espec->SoundFormatChanged)
|
||||
{
|
||||
@ -1284,7 +1259,6 @@ static retro_input_state_t input_state_cb;
|
||||
|
||||
static bool overscan;
|
||||
static double last_sound_rate;
|
||||
static MDFN_PixelFormat last_pixel_format;
|
||||
|
||||
static MDFN_Surface *surf;
|
||||
|
||||
@ -1622,16 +1596,29 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
if (!game)
|
||||
return false;
|
||||
|
||||
MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 13);
|
||||
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
|
||||
surf = (MDFN_Surface*)calloc(1, sizeof(*surf));
|
||||
|
||||
surf = new MDFN_Surface(NULL, FB_WIDTH, FB_HEIGHT, FB_WIDTH, pix_fmt);
|
||||
if (!surf)
|
||||
return false;
|
||||
|
||||
surf->width = FB_WIDTH;
|
||||
surf->height = FB_HEIGHT;
|
||||
surf->pitch = FB_WIDTH;
|
||||
|
||||
surf->pixels = (uint16_t*)calloc(1, FB_WIDTH * FB_HEIGHT * 3);
|
||||
|
||||
if (!surf->pixels)
|
||||
{
|
||||
free(surf);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Possible endian bug ...
|
||||
for (unsigned i = 0; i < MAX_PLAYERS; i++)
|
||||
PCEINPUT_SetInput(i, "gamepad", &input_buf[i][0]);
|
||||
|
||||
VDC_SetPixelFormat();
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
@ -1715,13 +1702,6 @@ void retro_run(void)
|
||||
spec.VideoFormatChanged = false;
|
||||
spec.SoundFormatChanged = false;
|
||||
|
||||
if (memcmp(&last_pixel_format, &spec.surface->format, sizeof(MDFN_PixelFormat)))
|
||||
{
|
||||
spec.VideoFormatChanged = TRUE;
|
||||
|
||||
last_pixel_format = spec.surface->format;
|
||||
}
|
||||
|
||||
if (spec.SoundRate != last_sound_rate)
|
||||
{
|
||||
spec.SoundFormatChanged = true;
|
||||
@ -1739,7 +1719,7 @@ void retro_run(void)
|
||||
unsigned width = spec.DisplayRect.w & ~0x1;
|
||||
unsigned height = spec.DisplayRect.h;
|
||||
|
||||
video_cb(surf->pixels16 + surf->pitchinpix * spec.DisplayRect.y, width, height, FB_WIDTH << 1);
|
||||
video_cb(surf->pixels + surf->pitch * spec.DisplayRect.y, width, height, FB_WIDTH << 1);
|
||||
|
||||
video_frames++;
|
||||
audio_frames += spec.SoundBufSize;
|
||||
@ -1775,7 +1755,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
|
||||
void retro_deinit()
|
||||
{
|
||||
delete surf;
|
||||
if (surf)
|
||||
free(surf);
|
||||
surf = NULL;
|
||||
|
||||
if (log_cb)
|
||||
|
@ -214,7 +214,7 @@ vpc_t vpc;
|
||||
#define VDCS_VD 0x20 // Vertical blank interrupt occurred
|
||||
#define VDCS_BSY 0x40 // VDC is waiting for a CPU access slot during the active display area??
|
||||
|
||||
void VDC_SetPixelFormat(const MDFN_PixelFormat &format)
|
||||
void VDC_SetPixelFormat(void)
|
||||
{
|
||||
// I know the temptation is there, but don't combine these two loops just
|
||||
// because they loop 512 times ;)
|
||||
@ -948,7 +948,7 @@ void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES)
|
||||
MDFN_ALIGN(8) uint8 bg_linebuf[8 + 1024];
|
||||
MDFN_ALIGN(8) uint16 spr_linebuf[16 + 1024];
|
||||
|
||||
uint16 *target_ptr16 = surface->pixels16 + (frame_counter - 14) * surface->pitchinpix;
|
||||
uint16 *target_ptr16 = surface->pixels + (frame_counter - 14) * surface->pitch;
|
||||
|
||||
if(fc_vrm && !skip)
|
||||
LineWidths[frame_counter - 14] = DisplayRect->w;
|
||||
|
@ -107,7 +107,7 @@ typedef struct
|
||||
extern vdc_t *vdc;
|
||||
|
||||
|
||||
void VDC_SetPixelFormat(const MDFN_PixelFormat &format) MDFN_COLD;
|
||||
void VDC_SetPixelFormat(void);
|
||||
void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES);
|
||||
void VDC_SetLayerEnableMask(uint64 mask);
|
||||
|
||||
|
@ -1,8 +1,62 @@
|
||||
#ifndef __MDFN_VIDEO_H
|
||||
#define __MDFN_VIDEO_H
|
||||
|
||||
#include "video/surface.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void MDFN_DispMessage(const char *format, ...);
|
||||
#if defined(FRONTEND_SUPPORTS_RGB565)
|
||||
/* 16bit color - RGB565 */
|
||||
#define RED_MASK 0xf800
|
||||
#define GREEN_MASK 0x7e0
|
||||
#define BLUE_MASK 0x1f
|
||||
#define RED_EXPAND 3
|
||||
#define GREEN_EXPAND 2
|
||||
#define BLUE_EXPAND 3
|
||||
#define RED_SHIFT 11
|
||||
#define GREEN_SHIFT 5
|
||||
#define BLUE_SHIFT 0
|
||||
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
|
||||
#else
|
||||
/* 16bit color - RGB555 */
|
||||
#define RED_MASK 0x7c00
|
||||
#define GREEN_MASK 0x3e0
|
||||
#define BLUE_MASK 0x1f
|
||||
#define RED_EXPAND 3
|
||||
#define GREEN_EXPAND 3
|
||||
#define BLUE_EXPAND 3
|
||||
#define RED_SHIFT 10
|
||||
#define GREEN_SHIFT 5
|
||||
#define BLUE_SHIFT 0
|
||||
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t x, y, w, h;
|
||||
} MDFN_Rect;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int colorspace;
|
||||
uint8_t r_shift;
|
||||
uint8_t g_shift;
|
||||
uint8_t b_shift;
|
||||
uint8_t a_shift;
|
||||
} MDFN_PixelFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t *pixels;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t pitch;
|
||||
} MDFN_Surface;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,96 +0,0 @@
|
||||
/* Mednafen - Multi-system Emulator
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../mednafen.h"
|
||||
#include "surface.h"
|
||||
|
||||
MDFN_PixelFormat::MDFN_PixelFormat()
|
||||
{
|
||||
bpp = 0;
|
||||
colorspace = 0;
|
||||
|
||||
Rshift = 0;
|
||||
Gshift = 0;
|
||||
Bshift = 0;
|
||||
Ashift = 0;
|
||||
}
|
||||
|
||||
MDFN_PixelFormat::MDFN_PixelFormat(const unsigned int p_colorspace, const uint8 p_rs, const uint8 p_gs, const uint8 p_bs, const uint8 p_as)
|
||||
{
|
||||
#if defined(WANT_16BPP)
|
||||
bpp = 16;
|
||||
#else
|
||||
bpp = 32;
|
||||
#endif
|
||||
colorspace = p_colorspace;
|
||||
|
||||
Rshift = p_rs;
|
||||
Gshift = p_gs;
|
||||
Bshift = p_bs;
|
||||
Ashift = p_as;
|
||||
}
|
||||
|
||||
MDFN_Surface::MDFN_Surface()
|
||||
{
|
||||
memset(&format, 0, sizeof(format));
|
||||
|
||||
pixels16 = NULL;
|
||||
pitchinpix = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
}
|
||||
|
||||
MDFN_Surface::MDFN_Surface(void *const p_pixels, const uint32 p_width, const uint32 p_height, const uint32 p_pitchinpix, const MDFN_PixelFormat &nf)
|
||||
{
|
||||
Init(p_pixels, p_width, p_height, p_pitchinpix, nf);
|
||||
}
|
||||
|
||||
void MDFN_Surface::Init(void *const p_pixels, const uint32 p_width, const uint32 p_height, const uint32 p_pitchinpix, const MDFN_PixelFormat &nf)
|
||||
{
|
||||
void *rpix = NULL;
|
||||
assert(nf.bpp == 16 || nf.bpp == 32);
|
||||
|
||||
format = nf;
|
||||
|
||||
pixels16 = NULL;
|
||||
|
||||
if(!(rpix = calloc(1, p_pitchinpix * p_height * (nf.bpp / 8))))
|
||||
throw(1);
|
||||
|
||||
//if(nf.bpp == 16)
|
||||
pixels16 = (uint16 *)rpix;
|
||||
|
||||
w = p_width;
|
||||
h = p_height;
|
||||
|
||||
pitchinpix = p_pitchinpix;
|
||||
}
|
||||
|
||||
// When we're converting, only convert the w*h area(AKA leave the last part of the line, pitch32 - w, alone),
|
||||
// for places where we store auxillary information there(graphics viewer in the debugger), and it'll be faster
|
||||
// to boot.
|
||||
void MDFN_Surface::SetFormat(const MDFN_PixelFormat &nf, bool convert)
|
||||
{
|
||||
format = nf;
|
||||
}
|
||||
|
||||
MDFN_Surface::~MDFN_Surface()
|
||||
{
|
||||
if(pixels16)
|
||||
free(pixels16);
|
||||
}
|
||||
|
@ -1,123 +0,0 @@
|
||||
#ifndef __MDFN_SURFACE_H
|
||||
#define __MDFN_SURFACE_H
|
||||
|
||||
#if defined(FRONTEND_SUPPORTS_RGB565)
|
||||
/* 16bit color - RGB565 */
|
||||
#define RED_MASK 0xf800
|
||||
#define GREEN_MASK 0x7e0
|
||||
#define BLUE_MASK 0x1f
|
||||
#define RED_EXPAND 3
|
||||
#define GREEN_EXPAND 2
|
||||
#define BLUE_EXPAND 3
|
||||
#define RED_SHIFT 11
|
||||
#define GREEN_SHIFT 5
|
||||
#define BLUE_SHIFT 0
|
||||
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
|
||||
#else
|
||||
/* 16bit color - RGB555 */
|
||||
#define RED_MASK 0x7c00
|
||||
#define GREEN_MASK 0x3e0
|
||||
#define BLUE_MASK 0x1f
|
||||
#define RED_EXPAND 3
|
||||
#define GREEN_EXPAND 3
|
||||
#define BLUE_EXPAND 3
|
||||
#define RED_SHIFT 10
|
||||
#define GREEN_SHIFT 5
|
||||
#define BLUE_SHIFT 0
|
||||
#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT))
|
||||
#endif
|
||||
|
||||
struct MDFN_PaletteEntry
|
||||
{
|
||||
uint8 r, g, b;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 x, y, w, h;
|
||||
} MDFN_Rect;
|
||||
|
||||
enum
|
||||
{
|
||||
MDFN_COLORSPACE_RGB = 0,
|
||||
MDFN_COLORSPACE_YCbCr = 1,
|
||||
MDFN_COLORSPACE_YUV = 2, // TODO, maybe.
|
||||
};
|
||||
|
||||
class MDFN_PixelFormat
|
||||
{
|
||||
public:
|
||||
|
||||
MDFN_PixelFormat();
|
||||
MDFN_PixelFormat(const unsigned int p_colorspace, const uint8 p_rs, const uint8 p_gs, const uint8 p_bs, const uint8 p_as);
|
||||
|
||||
unsigned int bpp;
|
||||
unsigned int colorspace;
|
||||
|
||||
union
|
||||
{
|
||||
uint8 Rshift; // Bit position of the lowest bit of the red component
|
||||
uint8 Yshift;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
uint8 Gshift; // [...] green component
|
||||
uint8 Ushift;
|
||||
uint8 Cbshift;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
uint8 Bshift; // [...] blue component
|
||||
uint8 Vshift;
|
||||
uint8 Crshift;
|
||||
};
|
||||
|
||||
uint8 Ashift; // [...] alpha component.
|
||||
// Creates a color value for the surface corresponding to the 8-bit R/G/B/A color passed.
|
||||
INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const
|
||||
{
|
||||
return MAKECOLOR(r, g, b, a);
|
||||
}
|
||||
}; // MDFN_PixelFormat;
|
||||
|
||||
// Supports 32-bit RGBA
|
||||
// 16-bit is WIP
|
||||
class MDFN_Surface //typedef struct
|
||||
{
|
||||
public:
|
||||
|
||||
MDFN_Surface();
|
||||
MDFN_Surface(void *const p_pixels, const uint32 p_width, const uint32 p_height, const uint32 p_pitchinpix, const MDFN_PixelFormat &nf);
|
||||
|
||||
~MDFN_Surface();
|
||||
|
||||
uint16 *pixels16;
|
||||
|
||||
// w, h, and pitch32 should always be > 0
|
||||
int32 w;
|
||||
int32 h;
|
||||
|
||||
union
|
||||
{
|
||||
int32 pitch32; // In pixels, not in bytes.
|
||||
int32 pitchinpix; // New name, new code should use this.
|
||||
};
|
||||
|
||||
MDFN_PaletteEntry *palette;
|
||||
|
||||
MDFN_PixelFormat format;
|
||||
|
||||
void SetFormat(const MDFN_PixelFormat &new_format, bool convert);
|
||||
|
||||
// Creates a value for the surface corresponding to the R/G/B/A color passed.
|
||||
INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const
|
||||
{
|
||||
return MAKECOLOR(r, g, b, a);
|
||||
}
|
||||
private:
|
||||
void Init(void *const p_pixels, const uint32 p_width, const uint32 p_height, const uint32 p_pitchinpix, const MDFN_PixelFormat &nf);
|
||||
};
|
||||
|
||||
#endif
|
@ -364,13 +364,6 @@
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="video"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\mednafen\video\surface.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="tremor"
|
||||
Filter="">
|
||||
|
@ -205,7 +205,6 @@
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">CompileAsC</CompileAs>
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">CompileAsC</CompileAs>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\mednafen\video\surface.cpp" />
|
||||
<ClCompile Include="..\..\scrc32.cpp" />
|
||||
<ClCompile Include="..\..\thread.c">
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">CompileAsCpp</CompileAs>
|
||||
|
@ -200,8 +200,5 @@
|
||||
<ClCompile Include="..\..\mednafen\trio\triostr.c">
|
||||
<Filter>Source Files\mednafen\trio</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\mednafen\video\surface.cpp">
|
||||
<Filter>Source Files\mednafen\video</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -117,7 +117,6 @@
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsC</CompileAs>
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsC</CompileAs>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\mednafen\video\surface.cpp" />
|
||||
<ClCompile Include="..\..\scrc32.cpp" />
|
||||
<ClCompile Include="..\..\thread.c">
|
||||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs>
|
||||
|
@ -47,9 +47,6 @@
|
||||
<ClCompile Include="..\..\thread.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\mednafen\video\surface.cpp">
|
||||
<Filter>Source Files\mednafen\video</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\mednafen\error.cpp">
|
||||
<Filter>Source Files\mednafen</Filter>
|
||||
</ClCompile>
|
||||
|
Loading…
Reference in New Issue
Block a user