Commit 55b44ed5 authored by fjtrujy's avatar fjtrujy
Browse files

Fix PS2 compilation and add ABGR color support

parent f4c90bb9
......@@ -196,10 +196,12 @@ else ifeq ($(platform),ps2)
CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
CXX = mips64r5900el-ps2-elf-g++$(EXE_EXT)
AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
FLAGS += -G0 -DPS2 -DABGR1555 -DHAVE_NO_LANGEXTRA
INCFLAGS_PLATFORM += -O3
STATIC_LINKING := 1
LIBS :=
TARGET := $(TARGET_NAME)_libretro_$(platform).a
fpic := -fno-PIC
DEFINES := -G0 -DPS2 -DABGR -DHAVE_NO_LANGEXTRA -O3
LUA_MYCFLAGS := $(DEFINES) $(CFLAGS)
STATIC_LINKING = 1
WANT_PHYSFS=0
# PSP
else ifeq ($(platform), psp1)
......
......@@ -544,10 +544,10 @@ static int gfx_getColor(lua_State *L)
return luaL_error(L, "lutro.graphics.getColor requires 0 arguments, %d given.", n);
canvas = get_canvas_ref(L, cur_canv);
c.a = (canvas->foreground >> 24) & 0xff;
c.r = (canvas->foreground >> 16) & 0xff;
c.g = (canvas->foreground >> 8) & 0xff;
c.b = (canvas->foreground >> 0) & 0xff;
c.a = (canvas->foreground >> ALPHA_SHIFT) & 0xff;
c.r = (canvas->foreground >> RED_SHIFT) & 0xff;
c.g = (canvas->foreground >> GREEN_SHIFT) & 0xff;
c.b = (canvas->foreground >> BLUE_SHIFT) & 0xff;
lua_pushnumber(L, c.r);
lua_pushnumber(L, c.g);
......@@ -604,10 +604,10 @@ static int gfx_getBackgroundColor(lua_State *L)
return luaL_error(L, "lutro.graphics.getBackgroundColor requires 0 arguments, %d given.", n);
canvas = get_canvas_ref(L, cur_canv);
c.a = (canvas->background >> 24) & 0xff;
c.r = (canvas->background >> 16) & 0xff;
c.g = (canvas->background >> 8) & 0xff;
c.b = (canvas->background >> 0) & 0xff;
c.a = (canvas->background >> ALPHA_SHIFT) & 0xff;
c.r = (canvas->background >> RED_SHIFT) & 0xff;
c.g = (canvas->background >> GREEN_SHIFT) & 0xff;
c.b = (canvas->background >> BLUE_SHIFT) & 0xff;
lua_pushnumber(L, c.r);
lua_pushnumber(L, c.g);
......
......@@ -149,10 +149,10 @@ static int l_getPixel(lua_State *L)
uint32_t color = data[y * (self->pitch >> 2) + x];
int a = ((color & 0xff000000)>>24);
int r = ((color & 0xff0000)>>16);
int g = ((color & 0xff00)>>8);
int b = (color & 0xff);
int a = ((color & ALPHA_MASK) >> ALPHA_SHIFT);
int r = ((color & RED_MASK) >> RED_SHIFT);
int g = ((color & GREEN_MASK) >> GREEN_SHIFT);
int b = ((color & BLUE_MASK) >> BLUE_SHIFT);
lua_pushnumber(L, r);
lua_pushnumber(L, g);
......
......@@ -7,6 +7,28 @@
#include <stdbool.h>
#include "runtime.h"
#if defined(ABGR)
#define ALPHA_SHIFT 24
#define RED_SHIFT 0
#define GREEN_SHIFT 8
#define BLUE_SHIFT 16
#define ALPHA_MASK 0xFF000000
#define RED_MASK 0x000000FF
#define GREEN_MASK 0x0000FF00
#define BLUE_MASK 0x00FF0000
#else
#define ALPHA_SHIFT 24
#define RED_SHIFT 16
#define GREEN_SHIFT 8
#define BLUE_SHIFT 0
#define ALPHA_MASK 0xFF000000
#define RED_MASK 0x00FF0000
#define GREEN_MASK 0x0000FF00
#define BLUE_MASK 0x000000FF
#endif
void lutro_image_init();
int lutro_image_preload(lua_State *L);
......
......@@ -8,6 +8,7 @@
#include <retro_miscellaneous.h>
#include "painter.h"
#include "image.h"
#include "lutro_stb_image.h"
#define _USE_MATH_DEFINES
......@@ -17,9 +18,9 @@
/* from http://www.codeguru.com/cpp/cpp/algorithms/general/article.php/c15989/Tip-An-Optimized-Formula-for-Alpha-Blending-Pixels.htm */
#define COMPOSE_FAST(S, D, A) (((S * A) + (D * (256U - A))) >> 8U)
#define DISASSEMBLE_RGB(COLOR, R, G, B) \
R = ((COLOR & 0xff0000)>>16);\
G = ((COLOR & 0xff00)>>8);\
B = (COLOR & 0xff);
R = ((COLOR & RED_MASK) >> RED_SHIFT);\
G = ((COLOR & GREEN_MASK) >> GREEN_SHIFT);\
B = ((COLOR & BLUE_MASK) >> BLUE_SHIFT);
#endif
static int strpos(const char *haystack, char needle)
......
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