diff --git a/gfx/drivers_font/caca_font.c b/gfx/drivers_font/caca_font.c
index f7ab54f028..034608a4f5 100644
--- a/gfx/drivers_font/caca_font.c
+++ b/gfx/drivers_font/caca_font.c
@@ -59,7 +59,6 @@ static void *caca_init_font(void *data,
static void caca_render_free_font(void *data)
{
-
}
static int caca_get_message_width(void *data, const char *msg,
diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c
index 2409aec4e1..ce4c4e48f4 100644
--- a/gfx/drivers_font/ctr_font.c
+++ b/gfx/drivers_font/ctr_font.c
@@ -109,7 +109,6 @@ static void ctr_font_free_font(void* data)
#else
linearFree(font->texture.data);
#endif
- free(font);
}
static int ctr_font_get_message_width(void* data, const char* msg,
diff --git a/gfx/drivers_font/d3d_w32_font.cpp b/gfx/drivers_font/d3d_w32_font.cpp
index 1fd5065782..d8ba99055d 100644
--- a/gfx/drivers_font/d3d_w32_font.cpp
+++ b/gfx/drivers_font/d3d_w32_font.cpp
@@ -88,9 +88,6 @@ static void d3dfonts_w32_free_font(void *data)
if (d3dfonts->font)
d3dfonts->font->Release();
d3dfonts->font = NULL;
-
- free(d3dfonts);
- d3dfonts = NULL;
}
static void d3dfonts_w32_render_msg(void *data, const char *msg,
diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c
index fb7d653a96..707585ad0c 100644
--- a/gfx/drivers_font/gl_raster_font.c
+++ b/gfx/drivers_font/gl_raster_font.c
@@ -57,8 +57,6 @@ typedef struct
video_font_raster_block_t *block;
} gl_raster_t;
-static void gl_raster_font_free_font(void *data);
-
static bool gl_raster_font_upload_atlas(gl_raster_t *font)
{
unsigned i, j;
@@ -144,6 +142,21 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font)
return true;
}
+static void gl_raster_font_free_font(void *data)
+{
+ gl_raster_t *font = (gl_raster_t*)data;
+ if (!font)
+ return;
+
+ if (font->font_driver && font->font_data)
+ font->font_driver->free(font->font_data);
+
+ if (video_driver_is_threaded())
+ video_context_driver_make_current(true);
+
+ glDeleteTextures(1, &font->tex);
+}
+
static void *gl_raster_font_init_font(void *data,
const char *font_path, float font_size)
{
@@ -156,11 +169,7 @@ static void *gl_raster_font_init_font(void *data,
if (!font_renderer_create_default((const void**)&font->font_driver,
&font->font_data, font_path, font_size))
- {
- RARCH_WARN("Couldn't initialize font renderer.\n");
- free(font);
- return NULL;
- }
+ goto error;
if (video_driver_is_threaded())
video_context_driver_make_current(false);
@@ -186,28 +195,13 @@ static void *gl_raster_font_init_font(void *data,
return font;
error:
+ RARCH_WARN("Couldn't initialize font renderer.\n");
gl_raster_font_free_font(font);
- font = NULL;
+ free(font);
return NULL;
}
-static void gl_raster_font_free_font(void *data)
-{
- gl_raster_t *font = (gl_raster_t*)data;
- if (!font)
- return;
-
- if (font->font_driver && font->font_data)
- font->font_driver->free(font->font_data);
-
- if (video_driver_is_threaded())
- video_context_driver_make_current(true);
-
- glDeleteTextures(1, &font->tex);
-
- free(font);
-}
static int gl_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c
index 0069501abc..2cffc9dbf0 100644
--- a/gfx/drivers_font/vita2d_font.c
+++ b/gfx/drivers_font/vita2d_font.c
@@ -98,8 +98,6 @@ static void vita2d_font_free_font(void *data)
vita2d_wait_rendering_done();
#endif
vita2d_free_texture(font->texture);
-
- free(font);
}
static int vita2d_font_get_message_width(void *data, const char *msg,
diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c
index 84f071a0fc..8f0b66b147 100644
--- a/gfx/drivers_font/vulkan_raster_font.c
+++ b/gfx/drivers_font/vulkan_raster_font.c
@@ -85,8 +85,6 @@ static void vulkan_raster_font_free_font(void *data)
vkQueueWaitIdle(font->vk->context->queue);
vulkan_destroy_texture(
font->vk->context->device, &font->texture);
-
- free(font);
}
static int vulkan_get_message_width(void *data, const char *msg,
diff --git a/gfx/drivers_font/xdk1_xfonts.c b/gfx/drivers_font/xdk1_xfonts.c
index bceffdf95e..644738877c 100644
--- a/gfx/drivers_font/xdk1_xfonts.c
+++ b/gfx/drivers_font/xdk1_xfonts.c
@@ -55,12 +55,6 @@ static void *xfonts_init_font(void *video_data,
static void xfonts_free_font(void *data)
{
- xfonts_t *font = (xfonts_t*)data;
-
- if (font)
- free(font);
-
- font = NULL;
}
static void xfonts_render_msg(void *data, const char *msg,
diff --git a/gfx/drivers_font/xdk360_fonts.cpp b/gfx/drivers_font/xdk360_fonts.cpp
index e0e00ebc57..5f8d128cd5 100644
--- a/gfx/drivers_font/xdk360_fonts.cpp
+++ b/gfx/drivers_font/xdk360_fonts.cpp
@@ -58,18 +58,18 @@ enum
class PackedResource
{
protected:
- BYTE* m_pSysMemData; // Alloc'ed memory for resource headers etc.
+ BYTE* m_pSysMemData; /* Allocated memory for resource headers etc. */
DWORD m_dwSysMemDataSize;
- BYTE* m_pVidMemData; // Alloc'ed memory for resource data, etc.
+ BYTE* m_pVidMemData; /* Allocated memory for resource data, etc. */
DWORD m_dwVidMemDataSize;
- XBRESOURCE* m_pResourceTags; // Tags to associate names with the resources
- DWORD m_dwNumResourceTags; // Number of resource tags
- BOOL m_bInitialized; // Resource is fully initialized
+ XBRESOURCE* m_pResourceTags; /* Tags to associate names with the resources */
+ DWORD m_dwNumResourceTags; /* Number of resource tags */
+ BOOL m_bInitialized; /* Resource is fully initialized */
public:
- // Loads the resources out of the specified bundle
+ /* Loads the resources out of the specified bundle */
#if defined(_XBOX1)
HRESULT Create( const char *strFilename, DWORD dwNumResourceTags = 0L,
XBRESOURCE* pResourceTags = NULL );
@@ -82,20 +82,21 @@ class PackedResource
BOOL Initialized() const;
#ifdef _XBOX360
- // Retrieves the resource tags
+ /* Retrieves the resource tags */
void GetResourceTags( DWORD* pdwNumResourceTags, XBRESOURCE** ppResourceTags );
#endif
- // Helper function to make sure a resource is registered
+ /* Helper function to make sure a resource is registered */
LPDIRECT3DRESOURCE RegisterResource( LPDIRECT3DRESOURCE pResource ) const
{
#ifdef _XBOX1
- // Register the resource, if it has not yet been registered. We mark
- // a resource as registered by upping it's reference count.
+ /* Register the resource, if it has not yet been registered. We mark
+ * a resource as registered by upping it's reference count. */
if( pResource && ( pResource->Common & D3DCOMMON_REFCOUNT_MASK ) == 1 )
{
- // Special case CPU-copy push buffers (which live in system memory)
- if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
+
+ /* Special case CPU-copy push buffers (which live in system memory) */
+ if( ( pResource->Common & D3DCOMMON_TYPE_PUSHBUFFER ) &&
( pResource->Common & D3DPUSHBUFFER_RUN_USING_CPU_COPY ) )
pResource->Data += (DWORD)m_pSysMemData;
else
@@ -107,32 +108,46 @@ class PackedResource
return pResource;
}
- // Functions to retrieve resources by their offset
+ /* Functions to retrieve resources by their offset */
void *GetData( DWORD dwOffset ) const
- { return &m_pSysMemData[dwOffset]; }
+ {
+ return &m_pSysMemData[dwOffset];
+ }
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
- { return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); }
+ {
+ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) );
+ }
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
- { return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); }
+ {
+ return (LPDIRECT3DTEXTURE)GetResource( dwOffset );
+ }
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
- { return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); }
+ {
+ return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset );
+ }
- // Functions to retrieve resources by their name
+ /* Functions to retrieve resources by their name */
void *GetData( const char* strName ) const;
LPDIRECT3DRESOURCE GetResource( const char* strName ) const
- { return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); }
+ {
+ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(strName));
+ }
LPDIRECT3DTEXTURE GetTexture( const char* strName ) const
- { return (LPDIRECT3DTEXTURE)GetResource( strName ); }
+ {
+ return (LPDIRECT3DTEXTURE)GetResource( strName );
+ }
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const char* strName ) const
- { return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); }
+ {
+ return (LPDIRECT3DVERTEXBUFFER)GetResource( strName );
+ }
- // Constructor/destructor
+ /* Constructor/destructor */
PackedResource();
~PackedResource();
};
@@ -143,13 +158,13 @@ class PackedResource
PackedResource::PackedResource()
{
- m_pSysMemData = NULL;
- m_dwSysMemDataSize = 0L;
- m_pVidMemData = NULL;
- m_dwVidMemDataSize = 0L;
- m_pResourceTags = NULL;
+ m_pSysMemData = NULL;
+ m_dwSysMemDataSize = 0L;
+ m_pVidMemData = NULL;
+ m_dwVidMemDataSize = 0L;
+ m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
- m_bInitialized = FALSE;
+ m_bInitialized = FALSE;
}
@@ -235,8 +250,8 @@ HRESULT PackedResource::Create(const char *strFilename)
XPR_HEADER xprh;
bool retval;
#ifdef _XBOX1
- BOOL bHasResourceOffsetsTable = FALSE;
char strResourcePath[512];
+ BOOL bHasResourceOffsetsTable = FALSE;
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
return E_FAIL;
@@ -270,7 +285,7 @@ HRESULT PackedResource::Create(const char *strFilename)
return E_FAIL;
}
- // Compute memory requirements
+ /* Compute memory requirements */
#if defined(_XBOX1)
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
@@ -279,7 +294,7 @@ HRESULT PackedResource::Create(const char *strFilename)
m_dwVidMemDataSize = xprh.dwDataSize;
#endif
- // Allocate memory
+ /* Allocate memory */
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
if (m_pSysMemData == NULL)
{
@@ -304,7 +319,7 @@ HRESULT PackedResource::Create(const char *strFilename)
return E_FAIL;
}
- // Read in the data from the file
+ /* Read in the data from the file */
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL) ||
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL))
{
@@ -312,7 +327,7 @@ HRESULT PackedResource::Create(const char *strFilename)
return E_FAIL;
}
- // Done with the file
+ /* Done with the file */
CloseHandle( hFile);
#ifdef _XBOX1
@@ -371,16 +386,17 @@ void PackedResource::GetResourceTags(DWORD* pdwNumResourceTags,
void PackedResource::Destroy()
{
free(m_pSysMemData);
- m_pSysMemData = NULL;
- m_dwSysMemDataSize = 0L;
- if (m_pVidMemData != NULL)
+ if (m_pVidMemData)
FreeContiguousMemory(m_pVidMemData);
- m_pVidMemData = NULL;
- m_dwVidMemDataSize = 0L;
+ m_pSysMemData = NULL;
+ m_dwSysMemDataSize = 0L;
- m_pResourceTags = NULL;
+ m_pVidMemData = NULL;
+ m_dwVidMemDataSize = 0L;
+
+ m_pResourceTags = NULL;
m_dwNumResourceTags = 0L;
m_bInitialized = FALSE;
@@ -530,8 +546,6 @@ static void *xdk360_init_font(void *video_data,
if (!font)
return NULL;
- (void)font_size;
-
font->d3d = (d3d_video_t*)video_data;
font->m_pFontTexture = NULL;
@@ -599,10 +613,10 @@ static void xdk360_free_font(void *data)
return;
/* Destroy the font */
- font->m_pFontTexture = NULL;
- font->m_dwNumGlyphs = 0L;
- font->m_Glyphs = NULL;
- font->m_cMaxGlyph = 0;
+ font->m_pFontTexture = NULL;
+ font->m_dwNumGlyphs = 0L;
+ font->m_Glyphs = NULL;
+ font->m_cMaxGlyph = 0;
font->m_TranslatorTable = NULL;
if (font->s_FontLocals.m_pFontPixelShader)
@@ -612,15 +626,12 @@ static void xdk360_free_font(void *data)
if (font->s_FontLocals.m_pFontVertexDecl)
font->s_FontLocals.m_pFontVertexDecl->Release();
- font->s_FontLocals.m_pFontPixelShader = NULL;
+ font->s_FontLocals.m_pFontPixelShader = NULL;
font->s_FontLocals.m_pFontVertexShader = NULL;
- font->s_FontLocals.m_pFontVertexDecl = NULL;
+ font->s_FontLocals.m_pFontVertexDecl = NULL;
if (m_xprResource.Initialized())
m_xprResource.Destroy();
-
- free(font);
- font = NULL;
}
static void xdk360_render_msg_post(xdk360_video_font_t * font)
@@ -644,7 +655,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState );
/* Set the texture scaling factor as a vertex shader constant. */
- D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description
+ D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); /* Get the description */
/* Set render state. */
d3d_set_texture(d3dr, 0, font->m_pFontTexture);
@@ -685,11 +696,11 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
* the vColor array. */
d3dr->SetVertexShaderConstantF(1, vColor, 1);
- m_fCursorX = floorf(x);
- m_fCursorY = floorf(y);
+ m_fCursorX = floorf(x);
+ m_fCursorY = floorf(y);
/* Adjust for padding. */
- y -= font->m_fFontTopPadding;
+ y -= font->m_fFontTopPadding;
/* Begin drawing the vertices
* Declared as volatile to force writing in ascending
@@ -699,7 +710,7 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
* memory.
*/
- dwNumChars = wcslen(strText);
+ dwNumChars = wcslen(strText);
d3dr->BeginVertices(D3DPT_QUADLIST, 4 * dwNumChars,
sizeof(XMFLOAT4), (void**)&pVertex);
@@ -710,8 +721,8 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
#ifdef MSB_FIRST
uint32_t tu1, tu2, tv1, tv2;
#endif
- const GLYPH_ATTR *pGlyph;
- wchar_t letter = *strText++; /* Get the current letter in the string */
+ const GLYPH_ATTR *pGlyph = NULL;
+ wchar_t letter = *strText++; /* Get the current letter in the string */
/* Handle the newline character. */
if (letter == L'\n')
@@ -732,16 +743,16 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
fWidth = FONT_SCALE(font->d3d) * (float)pGlyph->wWidth;
fHeight = FONT_SCALE(font->d3d) * font->m_fFontHeight;
- m_fCursorX += fOffset;
+ m_fCursorX += fOffset;
/* Add the vertices to draw this glyph. */
#ifdef MSB_FIRST
/* Convert shorts to 32 bit longs for in register merging */
- tu1 = pGlyph->tu1;
- tv1 = pGlyph->tv1;
- tu2 = pGlyph->tu2;
- tv2 = pGlyph->tv2;
+ tu1 = pGlyph->tu1;
+ tv1 = pGlyph->tv1;
+ tu2 = pGlyph->tu2;
+ tv2 = pGlyph->tv2;
#endif
/* NOTE: The vertexes are 2 floats for the screen coordinates,
@@ -760,27 +771,27 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
/* Setup the vertex/screen coordinates */
- pVertex[0] = m_fCursorX;
- pVertex[1] = m_fCursorY;
- pVertex[3] = 0;
- pVertex[4] = m_fCursorX + fWidth;
- pVertex[5] = m_fCursorY;
- pVertex[7] = 0;
- pVertex[8] = m_fCursorX + fWidth;
- pVertex[9] = m_fCursorY + fHeight;
- pVertex[11] = 0;
- pVertex[12] = m_fCursorX;
- pVertex[13] = m_fCursorY + fHeight;
+ pVertex[0] = m_fCursorX;
+ pVertex[1] = m_fCursorY;
+ pVertex[3] = 0;
+ pVertex[4] = m_fCursorX + fWidth;
+ pVertex[5] = m_fCursorY;
+ pVertex[7] = 0;
+ pVertex[8] = m_fCursorX + fWidth;
+ pVertex[9] = m_fCursorY + fHeight;
+ pVertex[11] = 0;
+ pVertex[12] = m_fCursorX;
+ pVertex[13] = m_fCursorY + fHeight;
#ifdef MSB_FIRST
- ((volatile uint32_t *)pVertex)[2] = (tu1 << 16) | tv1; // Merged using big endian rules
- ((volatile uint32_t *)pVertex)[6] = (tu2 << 16) | tv1; // Merged using big endian rules
- ((volatile uint32_t*)pVertex)[10] = (tu2 << 16) | tv2; // Merged using big endian rules
- ((volatile uint32_t*)pVertex)[14] = (tu1 << 16) | tv2; // Merged using big endian rules
+ ((volatile uint32_t *)pVertex)[2] = (tu1 << 16) | tv1; /* Merged using big endian rules */
+ ((volatile uint32_t *)pVertex)[6] = (tu2 << 16) | tv1; /* Merged using big endian rules */
+ ((volatile uint32_t*)pVertex)[10] = (tu2 << 16) | tv2; /* Merged using big endian rules */
+ ((volatile uint32_t*)pVertex)[14] = (tu1 << 16) | tv2; /* Merged using big endian rules */
#endif
- pVertex[15] = 0;
- pVertex += 16;
+ pVertex[15] = 0;
- m_fCursorX += fAdvance;
+ pVertex += 16;
+ m_fCursorX += fAdvance;
dwNumChars--;
}
diff --git a/gfx/font_driver.c b/gfx/font_driver.c
index 9b6900121f..717800bd6a 100644
--- a/gfx/font_driver.c
+++ b/gfx/font_driver.c
@@ -14,6 +14,10 @@
* If not, see .
*/
+#include
+
+#include
+
#include "font_driver.h"
#include "video_thread_wrapper.h"
@@ -24,8 +28,6 @@
#include "../config.h"
#endif
-#include
-
static const font_renderer_driver_t *font_backends[] = {
#ifdef HAVE_FREETYPE
&freetype_font_renderer,
@@ -192,7 +194,8 @@ static bool vulkan_font_init_first(
for (i = 0; vulkan_font_backends[i]; i++)
{
- void *data = vulkan_font_backends[i]->init(video_data, font_path, font_size);
+ void *data = vulkan_font_backends[i]->init(
+ video_data, font_path, font_size);
if (!data)
continue;
@@ -353,6 +356,9 @@ void font_driver_free(void *font_data)
if (font->renderer && font->renderer->free)
font->renderer->free(font->renderer_data);
+ if (font->renderer_data)
+ free(font->renderer_data);
+
font->renderer = NULL;
font->renderer_data = NULL;
@@ -364,9 +370,9 @@ font_data_t *font_driver_init_first(
void *video_data, const char *font_path, float font_size,
bool threading_hint, enum font_driver_render_api api)
{
- const void *font_driver;
- void *font_handle;
- bool ok = false;
+ const void *font_driver = NULL;
+ void *font_handle = NULL;
+ bool ok = false;
#ifdef HAVE_THREADS
if (threading_hint
@@ -395,12 +401,15 @@ font_data_t *font_driver_init_first(
void font_driver_init_osd(void *video_data, bool threading_hint, enum font_driver_render_api api)
{
settings_t *settings = config_get_ptr();
+ const char *path = settings->path.font;
+
if (video_font_driver)
return;
video_font_driver = font_driver_init_first(video_data,
- *settings->path.font ? settings->path.font : NULL,
- settings->video.font_size, threading_hint, api);
+ (!string_is_empty(path)) ? path : NULL,
+ settings->video.font_size,
+ threading_hint, api);
if (!video_font_driver)
RARCH_ERR("[font]: Failed to initialize OSD font.\n");
diff --git a/gfx/video_driver.c b/gfx/video_driver.c
index 40cfcaa5f7..0ebd227f01 100644
--- a/gfx/video_driver.c
+++ b/gfx/video_driver.c
@@ -1482,14 +1482,10 @@ void video_driver_set_viewport_core(void)
/* Fallback to 1:1 pixel ratio if none provided */
if (geom->aspect_ratio > 0.0f)
- {
aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio;
- }
else
- {
aspectratio_lut[ASPECT_RATIO_CORE].value =
(float)geom->base_width / geom->base_height;
- }
}
void video_driver_reset_custom_viewport(void)
@@ -1652,8 +1648,7 @@ bool video_driver_find_driver(void)
else
{
unsigned d;
- RARCH_ERR("Couldn't find any video driver named \"%s\"\n",
- settings->video.driver);
+ RARCH_ERR("Couldn't find any video driver named \"%s\"\n", settings->video.driver);
RARCH_LOG_OUTPUT("Available video drivers are:\n");
for (d = 0; video_driver_find_handle(d); d++)
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
@@ -1969,7 +1964,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
* geometry for the "normal" case. */
struct retro_system_av_info *av_info =
video_viewport_get_system_av_info();
- unsigned base_height = 0;
+ unsigned base_height = 0;
if (av_info)
base_height = av_info->geometry.base_height;
@@ -2230,20 +2225,20 @@ bool video_driver_translate_coord_viewport(
if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff)
scaled_screen_y = -0x8000; /* OOB */
- mouse_x -= vp->x;
- mouse_y -= vp->y;
+ mouse_x -= vp->x;
+ mouse_y -= vp->y;
- scaled_x = (2 * mouse_x * 0x7fff) / norm_full_vp_width - 0x7fff;
- scaled_y = (2 * mouse_y * 0x7fff) / norm_full_vp_height - 0x7fff;
+ scaled_x = (2 * mouse_x * 0x7fff) / norm_full_vp_width - 0x7fff;
+ scaled_y = (2 * mouse_y * 0x7fff) / norm_full_vp_height - 0x7fff;
if (scaled_x < -0x7fff || scaled_x > 0x7fff)
- scaled_x = -0x8000; /* OOB */
+ scaled_x = -0x8000; /* OOB */
if (scaled_y < -0x7fff || scaled_y > 0x7fff)
- scaled_y = -0x8000; /* OOB */
+ scaled_y = -0x8000; /* OOB */
- *res_x = scaled_x;
- *res_y = scaled_y;
- *res_screen_x = scaled_screen_x;
- *res_screen_y = scaled_screen_y;
+ *res_x = scaled_x;
+ *res_y = scaled_y;
+ *res_screen_x = scaled_screen_x;
+ *res_screen_y = scaled_screen_y;
return true;
}