Commit e16a90d6 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Convert graphics.cpp to C

parent 118a80a6
...@@ -34,11 +34,11 @@ endif ...@@ -34,11 +34,11 @@ endif
endif endif
SOURCES_CXX := \ SOURCES_CXX := \
$(CORE_DIR)/graphics.cpp \
$(CORE_DIR)/race-globals.cpp $(CORE_DIR)/race-globals.cpp
SOURCES_C += \ SOURCES_C += \
$(CORE_DIR)/tlcs900h.c \ $(CORE_DIR)/tlcs900h.c \
$(CORE_DIR)/graphics.c \
$(CORE_DIR)/main.c \ $(CORE_DIR)/main.c \
$(CORE_DIR)/flash.c \ $(CORE_DIR)/flash.c \
$(CORE_DIR)/input.c \ $(CORE_DIR)/input.c \
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define BMASK 0x001f #define BMASK 0x001f
#endif #endif
extern ngp_screen* screen; extern struct ngp_screen* screen;
extern int gfx_hacks; extern int gfx_hacks;
/* /*
...@@ -196,7 +196,7 @@ void palette_init32(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask) ...@@ -196,7 +196,7 @@ void palette_init32(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
} }
/* RGB range: [0,1] */ /* RGB range: [0,1] */
void darken_rgb(float &r, float &g, float &b) static void darken_rgb(float *r, float *g, float *b)
{ {
/* Note: This is *very* approximate... /* Note: This is *very* approximate...
* - Should be done in linear colour space. It isn't. * - Should be done in linear colour space. It isn't.
...@@ -219,17 +219,17 @@ void darken_rgb(float &r, float &g, float &b) ...@@ -219,17 +219,17 @@ void darken_rgb(float &r, float &g, float &b)
static const float luma_g = 0.587f; static const float luma_g = 0.587f;
static const float luma_b = 0.114f; static const float luma_b = 0.114f;
/* Calculate luminosity */ /* Calculate luminosity */
float luma = (luma_r * r) + (luma_g * g) + (luma_b * b); float luma = (luma_r * (*r)) + (luma_g * (*g)) + (luma_b * (*b));
/* Get 'darkness' scaling factor /* Get 'darkness' scaling factor
* > User set 'dark filter' level scaled by current luminosity * > User set 'dark filter' level scaled by current luminosity
* (i.e. lighter colours affected more than darker colours) * (i.e. lighter colours affected more than darker colours)
*/ */
float dark_factor = 1.0f - ((static_cast<float>(dark_filter_level) * 0.01f) * luma); float dark_factor = 1.0f - (((float)(dark_filter_level) * 0.01f) * luma);
dark_factor = dark_factor < 0.0f ? 0.0f : dark_factor; dark_factor = dark_factor < 0.0f ? 0.0f : dark_factor;
/* Perform scaling... */ /* Perform scaling... */
r = r * dark_factor; *r = (*r) * dark_factor;
g = g * dark_factor; *g = (*g) * dark_factor;
b = b * dark_factor; *b = (*b) * dark_factor;
} }
void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask) void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
...@@ -295,15 +295,15 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask) ...@@ -295,15 +295,15 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
for (r=0; r<16; r++) for (r=0; r<16; r++)
{ {
/* Convert colour range from [0,0xF] to [0,1] */ /* Convert colour range from [0,0xF] to [0,1] */
r_float = static_cast<float>(r) * rgb_max_inv; r_float = (float)(r) * rgb_max_inv;
g_float = static_cast<float>(g) * rgb_max_inv; g_float = (float)(g) * rgb_max_inv;
b_float = static_cast<float>(b) * rgb_max_inv; b_float = (float)(b) * rgb_max_inv;
/* Perform image darkening */ /* Perform image darkening */
darken_rgb(r_float, g_float, b_float); darken_rgb(&r_float, &g_float, &b_float);
/* Convert back to 4bit unsigned */ /* Convert back to 4bit unsigned */
r_final = static_cast<int>((r_float * rgb_max) + 0.5f) & 0xF; r_final = (int)((r_float * rgb_max) + 0.5f) & 0xF;
g_final = static_cast<int>((g_float * rgb_max) + 0.5f) & 0xF; g_final = (int)((g_float * rgb_max) + 0.5f) & 0xF;
b_final = static_cast<int>((b_float * rgb_max) + 0.5f) & 0xF; b_final = (int)((b_float * rgb_max) + 0.5f) & 0xF;
totalpalette[b*256+g*16+r] = totalpalette[b*256+g*16+r] =
(((b_final<<(BBitCount-4))+(b_final>>(4-(BBitCount-4))))<<BShiftCount) + (((b_final<<(BBitCount-4))+(b_final>>(4-(BBitCount-4))))<<BShiftCount) +
...@@ -332,7 +332,7 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask) ...@@ -332,7 +332,7 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
* Most interface functions seem to use camel case, * Most interface functions seem to use camel case,
* so do the same here... * so do the same here...
*/ */
extern "C" void graphicsSetDarkFilterLevel(unsigned filterLevel) void graphicsSetDarkFilterLevel(unsigned filterLevel)
{ {
unsigned prev_dark_filter_level = dark_filter_level; unsigned prev_dark_filter_level = dark_filter_level;
...@@ -1200,7 +1200,7 @@ void drawScrollPlane(unsigned short* draw, ...@@ -1200,7 +1200,7 @@ void drawScrollPlane(unsigned short* draw,
} }
} }
extern "C" void myGraphicsBlitLine(unsigned char render) /* NOTA */ void myGraphicsBlitLine(unsigned char render) /* NOTA */
{ {
int i,x0,x1; int i,x0,x1;
if (*scanlineY < 152) if (*scanlineY < 152)
...@@ -1336,7 +1336,7 @@ extern "C" void myGraphicsBlitLine(unsigned char render) /* NOTA */ ...@@ -1336,7 +1336,7 @@ extern "C" void myGraphicsBlitLine(unsigned char render) /* NOTA */
* *
*/ */
extern "C" BOOL graphics_init(void) BOOL graphics_init(void)
{ {
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
palette_init = palette_init16; palette_init = palette_init16;
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
#ifndef AFX_GRAPHICS_H #ifndef AFX_GRAPHICS_H
#define AFX_GRAPHICS_H #define AFX_GRAPHICS_H
#if _MSC_VER > 1000
#pragma once
#endif /* _MSC_VER > 1000 */
/* actual NGPC */ /* actual NGPC */
#define NGPC_SIZEX 160 #define NGPC_SIZEX 160
#define NGPC_SIZEY 152 #define NGPC_SIZEY 152
...@@ -69,10 +65,6 @@ void graphicsSetDarkFilterLevel(unsigned filterLevel); ...@@ -69,10 +65,6 @@ void graphicsSetDarkFilterLevel(unsigned filterLevel);
/* new renderer (NeoGeo Pocket (Color)) */ /* new renderer (NeoGeo Pocket (Color)) */
void myGraphicsBlitLine(unsigned char render); void myGraphicsBlitLine(unsigned char render);
#ifdef __cplusplus
}
#endif
/* /*
* adventure vision stuff * adventure vision stuff
*/ */
...@@ -92,4 +84,8 @@ struct ngp_screen ...@@ -92,4 +84,8 @@ struct ngp_screen
void *pixels; void *pixels;
}; };
#ifdef __cplusplus
}
#endif
#endif /* !defined(AFX_GRAPHICS_H) */ #endif /* !defined(AFX_GRAPHICS_H) */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment