Start compiling Griffin as C for 360 - C89 fixes

This commit is contained in:
twinaphex 2017-10-03 04:11:41 +02:00
parent bd94f265fa
commit d10de20bff
15 changed files with 67 additions and 42 deletions

View File

@ -138,15 +138,21 @@ bool d3d_surface_lock_rect(void *data, void *data2)
{
LPDIRECT3DSURFACE surf = (LPDIRECT3DSURFACE)data;
#if defined(HAVE_D3D9) && !defined(__cplusplus)
#if defined(_XBOX)
IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY);
#else
if (FAILED(IDirect3DSurface9_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#endif
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (FAILED(IDirect3DSurface8_LockRect(surf, (D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#elif defined(_XBOX)
surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY);
#else
if (FAILED(surf->LockRect((D3DLOCKED_RECT*)data2, NULL, D3DLOCK_READONLY)))
return false;
#endif
return false;
return true;
}
@ -332,7 +338,7 @@ bool d3d_device_create_offscreen_plain_surface(
void **surf_data,
void *data)
{
#if defined(HAVE_D3D9)
#if defined(HAVE_D3D9) && !defined(_XBOX)
#ifdef __cplusplus
if (SUCCEEDED(dev->CreateOffscreenPlainSurface(width, height,
(D3DFORMAT)format, (D3DPOOL)pool,
@ -351,6 +357,8 @@ bool d3d_device_create_offscreen_plain_surface(
return false;
}
#ifndef _XBOX360
/* XBox 360 has no fixed-function pipeline. */
static void d3d_set_texture_stage_state(LPDIRECT3DDEVICE dev,
unsigned sampler, unsigned value, unsigned type)
{
@ -362,6 +370,7 @@ static void d3d_set_texture_stage_state(LPDIRECT3DDEVICE dev,
dev->SetTextureStageState(sampler, (D3DTEXTURESTAGESTATETYPE)type, value);
#endif
}
#endif
void d3d_set_sampler_address_u(LPDIRECT3DDEVICE dev,
unsigned sampler, unsigned value)
@ -434,16 +443,23 @@ void d3d_set_sampler_magfilter(LPDIRECT3DDEVICE dev,
bool d3d_begin_scene(LPDIRECT3DDEVICE dev)
{
#if defined(HAVE_D3D9) && !defined(__cplusplus)
if (SUCCEEDED(IDirect3DDevice9_BeginScene(dev)))
#if defined(_XBOX)
IDirect3DDevice9_BeginScene(dev);
#else
if (FAILED(IDirect3DDevice9_BeginScene(dev)))
return false;
#endif
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
if (SUCCEEDED(IDirect3DDevice8_BeginScene(dev)))
if (FAILED(IDirect3DDevice8_BeginScene(dev)))
return false;
#elif defined(_XBOX)
dev->BeginScene();
#else
if (SUCCEEDED(dev->BeginScene()))
if (FAILED(dev->BeginScene()))
return false;
#endif
return true;
return false;
return true;
}
void d3d_end_scene(LPDIRECT3DDEVICE dev)
@ -510,10 +526,10 @@ bool d3d_device_get_render_target_data(LPDIRECT3DDEVICE dev,
{
LPDIRECT3DSURFACE src = (LPDIRECT3DSURFACE)_src;
LPDIRECT3DSURFACE dst = (LPDIRECT3DSURFACE)_dst;
#if defined(HAVE_D3D9) && !defined(__cplusplus)
#if defined(HAVE_D3D9) && !defined(__cplusplus) && !defined(_XBOX)
if (SUCCEEDED(IDirect3DDevice9_GetRenderTargetData(dev, src, dst)))
return true;
#else
#elif !defined(_XBOX)
if (SUCCEEDED(dev->GetRenderTargetData(src, dst)))
return true;
#endif
@ -609,7 +625,11 @@ void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler,
D3DTAG_MASKENCODE(D3DTAG_START(D3DTAG_FETCHCONSTANTS)
+ fetchConstant, D3DTAG_START(D3DTAG_FETCHCONSTANTS)
+ fetchConstant);
#if defined(__cplusplus)
D3DDevice_SetTexture(dev, sampler, tex, pendingMask3);
#else
D3DDevice_SetTexture(dev, sampler, (D3DBaseTexture*)tex, pendingMask3);
#endif
#elif defined(HAVE_D3D9) && !defined(__cplusplus)
IDirect3DDevice9_SetTexture(dev, sampler, (IDirect3DBaseTexture9*)tex);
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
@ -782,9 +802,9 @@ static bool d3d_reset_internal(LPDIRECT3DDEVICE dev,
static HRESULT d3d_test_cooperative_level(LPDIRECT3DDEVICE dev)
{
#if defined(HAVE_D3D9) && !defined(__cplusplus)
#if defined(HAVE_D3D9) && !defined(__cplusplus) && !defined(_XBOX)
return IDirect3DDevice9_TestCooperativeLevel(dev);
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
#elif defined(HAVE_D3D8) && !defined(__cplusplus) && !defined(_XBOX)
return IDirect3DDevice8_TestCooperativeLevel(dev);
#elif defined(_XBOX)
return E_FAIL;

View File

@ -605,8 +605,10 @@ void d3d_make_d3dpp(void *data,
if (widescreen_mode)
d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;
#elif defined(_XBOX360)
#if 0
if (!widescreen_mode)
d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
#endif
if (global->console.screen.gamma_correction)
d3dpp->FrontBufferFormat = (D3DFORMAT)

View File

@ -246,13 +246,14 @@ static void gfx_ctx_d3d_get_video_size(void *data,
unsigned *width, unsigned *height)
{
#ifdef _XBOX
#ifdef _XBOX360
XVIDEO_MODE video_mode;
#endif
d3d_video_t *d3d = (d3d_video_t*)data;
(void)width;
(void)height;
#if defined(_XBOX360)
XVIDEO_MODE video_mode;
XGetVideoMode(&video_mode);
*width = video_mode.dwDisplayWidth;

View File

@ -224,11 +224,10 @@ static void *twoxbr_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -67,11 +67,11 @@ static void *twoxsai_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -124,9 +124,8 @@ static void *blargg_ntsc_snes_generic_create(const struct softfilter_config *con
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
(void)simd;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -66,11 +66,10 @@ static void *darken_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -67,11 +67,10 @@ static void *epx_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -66,11 +66,10 @@ static void *lq2x_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -129,11 +129,10 @@ static void *scale2x_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)

View File

@ -68,11 +68,10 @@ static void *supereagle_generic_create(const struct softfilter_config *config,
unsigned max_width, unsigned max_height,
unsigned threads, softfilter_simd_mask_t simd, void *userdata)
{
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
(void)simd;
(void)config;
(void)userdata;
struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data));

View File

@ -112,15 +112,16 @@ static uint64_t xdk_input_get_capabilities(void *data)
static bool xdk_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
#ifdef _XBOX360
XINPUT_VIBRATION rumble_state;
#endif
xdk_input_t *xdk = (xdk_input_t*)data;
bool val = false;
(void)xdk;
bool val = false;
#if 0
#if defined(_XBOX360)
XINPUT_VIBRATION rumble_state;
if (effect == RETRO_RUMBLE_STRONG)
rumble_state.wLeftMotorSpeed = strength;
else if (effect == RETRO_RUMBLE_WEAK)

View File

@ -142,6 +142,9 @@ static void xdk_joypad_poll(void)
for (port = 0; port < MAX_PADS; port++)
{
unsigned i, j;
XINPUT_STATE state_tmp;
uint64_t *state_cur = NULL;
#ifdef _XBOX1
XINPUT_CAPABILITIES caps[MAX_PADS];
(void)caps;
@ -187,8 +190,6 @@ static void xdk_joypad_poll(void)
* the device handle will be NULL. */
#endif
XINPUT_STATE state_tmp;
#if defined(_XBOX1)
if (XInputPoll(gamepads[port]) != ERROR_SUCCESS)
continue;
@ -200,7 +201,7 @@ static void xdk_joypad_poll(void)
continue;
#endif
uint64_t *state_cur = &pad_state[port];
state_cur = &pad_state[port];
*state_cur = 0;
*state_cur |= ((state_tmp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0);
@ -237,8 +238,8 @@ static void xdk_joypad_poll(void)
analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = state_tmp.Gamepad.sThumbRX;
analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = state_tmp.Gamepad.sThumbRY;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
if (analog_state[port][i][j] == -0x8000)
analog_state[port][i][j] = -0x7fff;
}

View File

@ -98,12 +98,12 @@ static void resolve_float(float *out, const fft_complex_t *in, unsigned samples,
fft_t *fft_new(unsigned block_size_log2)
{
unsigned size;
fft_t *fft = (fft_t*)calloc(1, sizeof(*fft));
if (!fft)
return NULL;
unsigned size = 1 << block_size_log2;
size = 1 << block_size_log2;
fft->interleave_buffer = (fft_complex_t*)calloc(size, sizeof(*fft->interleave_buffer));
fft->bitinverse_buffer = (unsigned*)calloc(size, sizeof(*fft->bitinverse_buffer));
fft->phase_lut = (fft_complex_t*)calloc(2 * size + 1, sizeof(*fft->phase_lut));

View File

@ -355,7 +355,14 @@
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\griffin\griffin.c" />
<ClCompile Include="..\..\..\griffin\griffin.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">CompileAsC</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">CompileAsC</CompileAs>
</ClCompile>
<ClCompile Include="..\..\..\griffin\griffin_cpp.cpp" />
</ItemGroup>
<ItemGroup>
@ -438,4 +445,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>