summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier Trujillo Mata2019-10-12 12:47:38 +0200
committerFrancisco Javier Trujillo Mata2021-02-06 14:19:00 +0100
commitb581c72d0245ddcc6e7208b5527bf001dae94adc (patch)
treef01e544579d3779c9fb539d4ab8d8b8069727175
parentff6a6e6e6482ac1a773b192f87916688ebd86abd (diff)
downloadsnes9x2002-b581c72d0245ddcc6e7208b5527bf001dae94adc.tar.gz
snes9x2002-b581c72d0245ddcc6e7208b5527bf001dae94adc.tar.bz2
snes9x2002-b581c72d0245ddcc6e7208b5527bf001dae94adc.zip
Add BGR support and add PS2 platform
-rw-r--r--Makefile12
-rw-r--r--src/gfx.h2
-rw-r--r--src/pixform.h27
-rw-r--r--src/port.h4
4 files changed, 43 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 33f86b3..acbc259 100644
--- a/Makefile
+++ b/Makefile
@@ -170,6 +170,16 @@ else ifeq ($(platform), classic_armv7_a7)
endif
#######################################
+else ifeq ($(platform), ps2)
+ TARGET := $(TARGET_NAME)_libretro_$(platform).a
+ CC = mips64r5900el-ps2-elf-gcc$(EXE_EXT)
+ CXX = mips64r5900el-ps2-elf-g++$(EXE_EXT)
+ AR = mips64r5900el-ps2-elf-ar$(EXE_EXT)
+ STATIC_LINKING = 1
+ LOAD_FROM_MEMORY_TEST = 0
+ CFLAGS += -DPS2 -G0 -DFRAME_SKIP -fomit-frame-pointer -ffast-math
+ STATIC_LINKING := 1
+
else ifeq ($(platform), psp1)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = psp-gcc$(EXE_EXT)
@@ -335,7 +345,7 @@ LIBRETRO_DIR := ./libretro
ifeq ($(DEBUG), 1)
DEFINES += -O0 -g
else
-DEFINES += -O2 -DNDEBUG=1
+DEFINES += -O3 -DNDEBUG=1
endif
LDFLAGS += $(LIBM)
diff --git a/src/gfx.h b/src/gfx.h
index 362da1d..adc568e 100644
--- a/src/gfx.h
+++ b/src/gfx.h
@@ -224,7 +224,7 @@ static INLINE uint16_t COLOR_ADD(uint16_t C1, uint16_t C2)
{
const int RED_MASK = 0x1F << RED_SHIFT_BITS;
const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS;
- const int BLUE_MASK = 0x1F;
+ const int BLUE_MASK = 0x1F << BLUE_SHIFT_BITS;
int rb = (C1 & (RED_MASK | BLUE_MASK)) + (C2 & (RED_MASK | BLUE_MASK));
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
diff --git a/src/pixform.h b/src/pixform.h
index 1edd9c5..8f22825 100644
--- a/src/pixform.h
+++ b/src/pixform.h
@@ -88,6 +88,7 @@ extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
#define MAX_BLUE_RGB565 31
#define RED_SHIFT_BITS_RGB565 11
#define GREEN_SHIFT_BITS_RGB565 6
+#define BLUE_SHIFT_BITS_RGB565 0
#define RED_LOW_BIT_MASK_RGB565 0x0800
#define GREEN_LOW_BIT_MASK_RGB565 0x0020
#define BLUE_LOW_BIT_MASK_RGB565 0x0001
@@ -99,6 +100,29 @@ extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
#define THIRD_COLOR_MASK_RGB565 0x001F
#define ALPHA_BITS_MASK_RGB565 0x0000
+// BGR555 format
+#define BUILD_PIXEL_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
+#define BUILD_PIXEL2_BGR555(R,G,B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
+#define DECOMPOSE_PIXEL_BGR555(PIX,R,G,B) {(B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
+#define SPARE_RGB_BIT_MASK_BGR555 (1 << 5)
+
+#define MAX_RED_BGR555 31
+#define MAX_GREEN_BGR555 31
+#define MAX_BLUE_BGR555 31
+#define RED_SHIFT_BITS_BGR555 0
+#define GREEN_SHIFT_BITS_BGR555 5
+#define BLUE_SHIFT_BITS_BGR555 10
+#define RED_LOW_BIT_MASK_BGR555 0x0001
+#define GREEN_LOW_BIT_MASK_BGR555 0x0020
+#define BLUE_LOW_BIT_MASK_BGR555 0x0400
+#define RED_HI_BIT_MASK_BGR555 0x0010
+#define GREEN_HI_BIT_MASK_BGR555 0x0200
+#define BLUE_HI_BIT_MASK_BGR555 0x4000
+#define FIRST_COLOR_MASK_BGR555 0x7C00
+#define SECOND_COLOR_MASK_BGR555 0x03E0
+#define THIRD_COLOR_MASK_BGR555 0x001F
+#define ALPHA_BITS_MASK_BGR555 0x0000
+
// RGB555 format
#define BUILD_PIXEL_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
#define BUILD_PIXEL2_RGB555(R,G,B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B))
@@ -110,6 +134,7 @@ extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
#define MAX_BLUE_RGB555 31
#define RED_SHIFT_BITS_RGB555 10
#define GREEN_SHIFT_BITS_RGB555 5
+#define BLUE_SHIFT_BITS_RGB555 0
#define RED_LOW_BIT_MASK_RGB555 0x0400
#define GREEN_LOW_BIT_MASK_RGB555 0x0020
#define BLUE_LOW_BIT_MASK_RGB555 0x0001
@@ -139,6 +164,7 @@ extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_,F)
#define RED_SHIFT_BITS_D(F) CONCAT(RED_SHIFT_BITS_, F)
#define GREEN_SHIFT_BITS_D(F) CONCAT(GREEN_SHIFT_BITS_, F)
+#define BLUE_SHIFT_BITS_D(F) CONCAT(BLUE_SHIFT_BITS_, F)
#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_,F)
#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_,F)
#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_,F)
@@ -155,6 +181,7 @@ extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT)
#define RED_SHIFT_BITS RED_SHIFT_BITS_D(PIXEL_FORMAT)
#define GREEN_SHIFT_BITS GREEN_SHIFT_BITS_D(PIXEL_FORMAT)
+#define BLUE_SHIFT_BITS BLUE_SHIFT_BITS_D(PIXEL_FORMAT)
#define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT)
diff --git a/src/port.h b/src/port.h
index e6b5c1d..c8d0be8 100644
--- a/src/port.h
+++ b/src/port.h
@@ -110,7 +110,11 @@ typedef short int16_32;
#define VAR_CYCLES
//#define SPC700_SHUTDOWN
#define FASTCALL
+#if defined(PS2)
+#define PIXEL_FORMAT BGR555
+#else
#define PIXEL_FORMAT RGB565
+#endif
#define CPU_SHUTDOWN
#define PACKING __attribute__ ((packed))
#define ALIGN_BY_ONE __attribute__ ((aligned (1), packed))