Skip to content

Commit

Permalink
video: initial port of libretro glide64
Browse files Browse the repository at this point in the history
  • Loading branch information
fzurita committed Feb 6, 2016
1 parent 7c49534 commit 0d93424
Show file tree
Hide file tree
Showing 58 changed files with 24,071 additions and 70 deletions.
12 changes: 12 additions & 0 deletions assets/mupen64plus_data/profiles/emulation.cfg
Expand Up @@ -10,6 +10,18 @@ r4300Emulator=2
videoPlugin=libmupen64plus-video-glide64mk2.so videoPlugin=libmupen64plus-video-glide64mk2.so
glide64Frameskip=-5 glide64Frameskip=-5


[libretro-Glide64-Accurate]
comment=glide64 video with recommended settings for quality
r4300Emulator=2
videoPlugin=libmupen64plus-video-glide2gl.so
glide64Frameskip=0

[libretro-Glide64-Fast]
comment=glide64 video with recommended settings for speed
r4300Emulator=2
videoPlugin=libmupen64plus-video-glide2gl.so
glide64Frameskip=-5

[GlideN64-GLES-2.0] [GlideN64-GLES-2.0]
comment=gliden64 video with recommended settings for most older devices comment=gliden64 video with recommended settings for most older devices
r4300Emulator=2 r4300Emulator=2
Expand Down
21 changes: 17 additions & 4 deletions jni/mupen64plus-video-glide2gl.mk
Expand Up @@ -11,7 +11,10 @@ LOCAL_STATIC_LIBRARIES := png
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm


LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/$(SRCDIR)/Glitch64/inc \ $(LOCAL_PATH)/$(SRCDIR)/Glitch64 \
$(LOCAL_PATH)/$(SRCDIR)/Glide64 \
$(LOCAL_PATH)/$(SRCDIR)/libretro \
$(LOCAL_PATH)/$(SRCDIR) \
$(M64P_API_INCLUDES) \ $(M64P_API_INCLUDES) \
$(PNG_INCLUDES) \ $(PNG_INCLUDES) \
$(SDL_INCLUDES) \ $(SDL_INCLUDES) \
Expand All @@ -21,8 +24,8 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glitch64/glitch64_combiner.c \ $(SRCDIR)/Glitch64/glitch64_combiner.c \
$(SRCDIR)/Glitch64/glitch64_textures.c \ $(SRCDIR)/Glitch64/glitch64_textures.c \
$(SRCDIR)/Glitch64/glitchmain.c \ $(SRCDIR)/Glitch64/glitchmain.c \
$(SRCDIR)/Glide64/osal_dynamiclib_unix.c \
$(SRCDIR)/Glide64/Combine.c \ $(SRCDIR)/Glide64/Combine.c \
$(SRCDIR)/Glide64/DepthBufferRender.c \
$(SRCDIR)/Glide64/FBtoScreen.c \ $(SRCDIR)/Glide64/FBtoScreen.c \
$(SRCDIR)/Glide64/glide64_3dmath.c \ $(SRCDIR)/Glide64/glide64_3dmath.c \
$(SRCDIR)/Glide64/Glide64_Ini.c \ $(SRCDIR)/Glide64/Glide64_Ini.c \
Expand All @@ -33,6 +36,15 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glide64/MiClWr.c \ $(SRCDIR)/Glide64/MiClWr.c \
$(SRCDIR)/Glide64/TexCache.c \ $(SRCDIR)/Glide64/TexCache.c \
$(SRCDIR)/Glide64/TexLoad.c \ $(SRCDIR)/Glide64/TexLoad.c \
$(SRCDIR)/libretro/gdp.c \
$(SRCDIR)/libretro/opengl_state_machine.c \
$(SRCDIR)/libretro/libretro.c \
$(SRCDIR)/libretro/libretro_crc.c \
$(SRCDIR)/libretro/glsym/rglgen.c \
$(SRCDIR)/libretro/glsym/glsym_es2.c \





LOCAL_CFLAGS := \ LOCAL_CFLAGS := \
$(COMMON_CFLAGS) \ $(COMMON_CFLAGS) \
Expand All @@ -56,7 +68,8 @@ LOCAL_LDLIBS := \


ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
# Use for ARM7a: # Use for ARM7a:
LOCAL_CFLAGS += -mfpu=vfp LOCAL_CFLAGS += -D__ARM_NEON__
LOCAL_CFLAGS += -mfpu=neon
LOCAL_CFLAGS += -mfloat-abi=softfp LOCAL_CFLAGS += -mfloat-abi=softfp


else ifeq ($(TARGET_ARCH_ABI), x86) else ifeq ($(TARGET_ARCH_ABI), x86)
Expand All @@ -67,6 +80,6 @@ else


endif endif


LOCAL_CFLAGS += -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DM64P_PLUGIN_API -D__LIBRETRO__ -DINLINE="inline" -DSDL_VIDEO_OPENGL_ES2=1 -DANDROID -DSINC_LOWER_QUALITY -DHAVE_LOGGER -DHAVE_COMBINE_EXT -fexceptions $(GLFLAGS) -DGLES LOCAL_CFLAGS += -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DM64P_PLUGIN_API -D__LIBRETRO__ -DINLINE="inline" -DSDL_VIDEO_OPENGL_ES2=1 -DANDROID -DSINC_LOWER_QUALITY -DHAVE_LOGGER -DHAVE_COMBINE_EXT -fexceptions -DGLES -DHAVE_OPENGLES2 -DDISABLE_3POINT -DUSE_GLES


include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
42 changes: 19 additions & 23 deletions jni/mupen64plus-video-glide2gl/src/Glide64/Glide64_Ini.c
Expand Up @@ -4,8 +4,8 @@
#include "rdp.h" #include "rdp.h"
#include "DepthBufferRender.h" #include "DepthBufferRender.h"


#include "api/libretro.h" #include "libretro/libretro.h"
#include "../../libretro/SDL.h" #include "libretro/SDL.h"


extern bool no_audio; extern bool no_audio;
extern uint8_t microcode[4096]; extern uint8_t microcode[4096];
Expand Down Expand Up @@ -178,7 +178,7 @@ void ReadSpecialSettings (const char * name)
//depthmode = 0 //depthmode = 0
} }
// ;Bakushou Jinsei 64 - Mezease! Resort Ou. // ;Bakushou Jinsei 64 - Mezease! Resort Ou.
else if (strstr(name, (const char *)"ÊÞ¸¼®³¼Þݾ²64")) else if (strstr(name, (const char *)"ÊÞ¸¼®³¼ÞÃ�¾²64"))
{ {
//fb_info_disable = 1 //fb_info_disable = 1
//depthmode = 0 //depthmode = 0
Expand Down Expand Up @@ -484,7 +484,7 @@ void ReadSpecialSettings (const char * name)
hires = 1; hires = 1;
#endif #endif
} }
else if (strstr(name, (const char *)"´¸½ÄØ°ÑG2")) else if (strstr(name, (const char *)"´¸½ÄØ°ÑG2"))
{ {
//depthmode = 0 //depthmode = 0
smart_read = 0; smart_read = 0;
Expand Down Expand Up @@ -526,7 +526,7 @@ void ReadSpecialSettings (const char * name)
hires = 1; hires = 1;
#endif #endif
} }
else if (strstr(name, (const char *)"´²º³É¾ÝıÝÄÞØ­°½")) else if (strstr(name, (const char *)"´²º³É¾Ã�ıÃ�ÄÞØ­°½"))
{ {
//;Eikou no Saint Andrew //;Eikou no Saint Andrew
settings.correct_viewport = 1; settings.correct_viewport = 1;
Expand Down Expand Up @@ -604,7 +604,7 @@ void ReadSpecialSettings (const char * name)
cpu_write_hack = 1; cpu_write_hack = 1;
//depthmode = 0 //depthmode = 0
} }
else if (strstr(name, (const char*)"ÄÞ×´ÓÝ3 ÉËÞÀÉÏÁSOS!")) else if (strstr(name, (const char*)"ÄÞ×´ÓÃ�3 ÉËÞÀÉÃ�Ã�SOS!"))
{ {
//;Doraemon 3 - Nobita no Machi SOS! (J) //;Doraemon 3 - Nobita no Machi SOS! (J)
settings.clip_zmin = 1; settings.clip_zmin = 1;
Expand Down Expand Up @@ -645,7 +645,7 @@ void ReadSpecialSettings (const char * name)
//depthmode = 0 //depthmode = 0
settings.buff_clear = 0; settings.buff_clear = 0;
} }
else if (strstr(name, (const char*)"F3 ̳ײɼÚÝ2")) else if (strstr(name, (const char*)"F3 ̳ײɼÚÃ�2"))
{ {
//;Fushigi no Dungeon - Furai no Shiren 2 (J) //;Fushigi no Dungeon - Furai no Shiren 2 (J)
settings.decrease_fillrect_edge = 1; settings.decrease_fillrect_edge = 1;
Expand Down Expand Up @@ -706,7 +706,7 @@ void ReadSpecialSettings (const char * name)
settings.swapmode = 0; settings.swapmode = 0;
} }
else if (strstr(name, (const char*)"GANBAKE GOEMON") else if (strstr(name, (const char*)"GANBAKE GOEMON")
//|| strstr(name, (const char*)"¶ÞÝÊÞÚ\ ºÞ´ÓÝ") */ TODO: illegal characters - find by ucode CRC */ //|| strstr(name, (const char*)"¶ÞÃ�ÊÞÚ\ ºÞ´ÓÃ�") */ TODO: illegal characters - find by ucode CRC */
|| strstr(name, (const char*)"MYSTICAL NINJA") || strstr(name, (const char*)"MYSTICAL NINJA")
|| strstr(name, (const char*)"MYSTICAL NINJA2 SG") || strstr(name, (const char*)"MYSTICAL NINJA2 SG")
) )
Expand Down Expand Up @@ -753,14 +753,14 @@ void ReadSpecialSettings (const char * name)
settings.filtering = 1; settings.filtering = 1;
//depthmode = 1 //depthmode = 1
} }
else if (strstr(name, (const char*)"ÊѽÀ°ÓɶÞÀØ64") else if (strstr(name, (const char*)"ÊѽÀ°ÓɶÞÀØ64")
) )
{ {
settings.force_microcheck = 1; settings.force_microcheck = 1;
//depthmode = 0 //depthmode = 0
} }
else if (strstr(name, (const char*)"HARVESTMOON64") else if (strstr(name, (const char*)"HARVESTMOON64")
|| strstr(name, (const char*)"ÎÞ¸¼Þ®³ÓɶÞÀØ2") || strstr(name, (const char*)"ÎÞ¸¼Þ®³ÓɶÞÀØ2")
) )
{ {
settings.zmode_compare_less = 1; settings.zmode_compare_less = 1;
Expand Down Expand Up @@ -819,7 +819,7 @@ void ReadSpecialSettings (const char * name)
//depthmode = 0 //depthmode = 0
settings.buff_clear = 0; settings.buff_clear = 0;
} }
else if (strstr(name, (const char*)"ÓØÀ¼®³·Þ64")) else if (strstr(name, (const char*)"ÓØÀ¼®³·Þ64"))
{ {
//;Morita Shogi 64 //;Morita Shogi 64
settings.correct_viewport = 1; settings.correct_viewport = 1;
Expand Down Expand Up @@ -911,7 +911,7 @@ void ReadSpecialSettings (const char * name)
hires = 1; hires = 1;
#endif #endif
} }
else if (strstr(name, (const char*)"ÄÞ×´ÓÝ Ð¯Âɾ²Ú²¾·")) else if (strstr(name, (const char*)"ÄÞ×´ÓÃ� Ã�¯Âɾ²Ú²¾·"))
{ {
//;Doraemon - Mittsu no Seireiseki (J) //;Doraemon - Mittsu no Seireiseki (J)
read_back_to_screen = 1; read_back_to_screen = 1;
Expand All @@ -921,7 +921,7 @@ void ReadSpecialSettings (const char * name)
hires = 1; hires = 1;
#endif #endif
} }
else if (strstr(name, (const char*)"HEIWA ÊßÁݺ Ü°ÙÄÞ64")) else if (strstr(name, (const char*)"HEIWA ÊßÃ�Ã�º Ü°ÙÄÞ64"))
{ {
//; Heiwa Pachinko World //; Heiwa Pachinko World
//depthmode = 0 //depthmode = 0
Expand All @@ -932,13 +932,13 @@ void ReadSpecialSettings (const char * name)
hires = 1; hires = 1;
#endif #endif
} }
else if (strstr(name, (const char*)"·×¯Ä¶²¹Â 64ÀÝòÀÞÝ")) else if (strstr(name, (const char*)"·×¯Ä¶²¹Â 64ÀÃ�òÀÞÃ�"))
{ {
settings.filtering = 1; settings.filtering = 1;
//depthmode = 0 //depthmode = 0
settings.buff_clear = 0; settings.buff_clear = 0;
} }
else if (strstr(name, (const char*)"½°Êß°ÛÎÞ¯ÄÀ²¾Ý64")) else if (strstr(name, (const char*)"½°Êß°ÛÎÞ¯ÄÀ²¾Ã�64"))
{ {
//;Super Robot Taisen 64 (J) //;Super Robot Taisen 64 (J)
smart_read = 1; smart_read = 1;
Expand All @@ -957,18 +957,14 @@ void ReadSpecialSettings (const char * name)
//depthmode = 0 //depthmode = 0
settings.buff_clear = 0; settings.buff_clear = 0;
} }
else if (strstr(name, (const char*)"TOP GEAR RALLY")) else if (strstr(name, (const char*)"½½Ò!À²¾�Êß½ÞÙÀÞ�"))
{
no_audio = true;
}
else if (strstr(name, (const char*)"½½Ò!À²¾ÝÊß½ÞÙÀÞÏ"))
{ {
settings.force_microcheck = 1; settings.force_microcheck = 1;
//depthmode = 1 //depthmode = 1
settings.fog = 0; settings.fog = 0;
settings.swapmode = 0; settings.swapmode = 0;
} }
else if (strstr(name, (const char*)"ÐÝÅÃÞÀϺޯÁÜ°ÙÄÞ")) else if (strstr(name, (const char*)"Ã�Ã�ÅÃÞÀÃ�ºÞ¯Ã�Ü°ÙÄÞ"))
{ {
//;Tamagotchi World 64 (J) //;Tamagotchi World 64 (J)
//depthmode = 0 //depthmode = 0
Expand Down Expand Up @@ -1025,7 +1021,7 @@ void ReadSpecialSettings (const char * name)
#if 0 #if 0
// TODO: illegal characters - will have to find this game by ucode CRC // TODO: illegal characters - will have to find this game by ucode CRC
// later // later
else if (strstr(name, (const char*)"JØ°¸Þ\ ²ÚÌÞÝËÞ°Ä1997")) else if (strstr(name, (const char*)"JØ°¸Þ\ ²ÚÌÞÃ�ËÞ°Ä1997"))
{ {
//;J.League Eleven Beat 1997 //;J.League Eleven Beat 1997
smart_read = 1; smart_read = 1;
Expand Down Expand Up @@ -1062,7 +1058,7 @@ void ReadSpecialSettings (const char * name)
{ {
settings.buff_clear = 0; settings.buff_clear = 0;
} }
else if (strstr(name, (const char*)"ǼÂÞØ64")) else if (strstr(name, (const char*)"ǼÂÞØ64"))
{ {
//; Nushi Zuri 64 //; Nushi Zuri 64
settings.force_microcheck = 1; settings.force_microcheck = 1;
Expand Down
6 changes: 3 additions & 3 deletions jni/mupen64plus-video-glide2gl/src/Glide64/Glide64_UCode.c
@@ -1,7 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include "Glide64_UCode.h" #include "Glide64_UCode.h"
#include "rdp.h" #include "rdp.h"
#include "api/libretro.h" #include "libretro/libretro.h"


extern uint8_t microcode[4096]; extern uint8_t microcode[4096];
extern uint32_t uc_crc; extern uint32_t uc_crc;
Expand Down Expand Up @@ -182,8 +182,8 @@ void microcheck(void)
) )
{ {
settings.ucode = 2; settings.ucode = 2;
if (log_cb) //if (log_cb)
log_cb(RETRO_LOG_INFO, "Microcode 2 - F3DEX 2.XX (The Legend of Zelda: Ocarina of Time)\n"); // log_cb(RETRO_LOG_INFO, "Microcode 2 - F3DEX 2.XX (The Legend of Zelda: Ocarina of Time)\n");
} }
else if ( else if (
uc_crc == UCODE_WAVERACE_64 uc_crc == UCODE_WAVERACE_64
Expand Down
12 changes: 6 additions & 6 deletions jni/mupen64plus-video-glide2gl/src/Glide64/glide64_3dmath.c
Expand Up @@ -38,7 +38,7 @@
//**************************************************************** //****************************************************************


#include "Gfx_1.3.h" #include "Gfx_1.3.h"
#include "../../libretro/SDL.h" #include "libretro/SDL.h"


#include <math.h> #include <math.h>
#include "3dmath.h" #include "3dmath.h"
Expand Down Expand Up @@ -208,17 +208,17 @@ void math_init(void)
{ {
unsigned cpu = 0; unsigned cpu = 0;


if (perf_get_cpu_features_cb) //if (perf_get_cpu_features_cb)
cpu = perf_get_cpu_features_cb(); // cpu = perf_get_cpu_features_cb();


#if defined(__ARM_NEON__) #if defined(__ARM_NEON__)
if (cpu & RETRO_SIMD_NEON) if (/*cpu & */RETRO_SIMD_NEON)
{ {
glide64NormalizeVector = NormalizeVectorNeon; glide64NormalizeVector = NormalizeVectorNeon;
glide64MulMatrices = MulMatricesNeon; glide64MulMatrices = MulMatricesNeon;
glide64DotProduct = DotProductNeon; glide64DotProduct = DotProductNeon;
if (log_cb) //if (log_cb)
log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n"); // log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n");
} }
#endif #endif
} }
Expand Down
10 changes: 5 additions & 5 deletions jni/mupen64plus-video-glide2gl/src/Glide64/glide64_rdp.c
Expand Up @@ -47,7 +47,7 @@
#include "CRC.h" #include "CRC.h"
#include "GBI.h" #include "GBI.h"
#include "Glide64_UCode.h" #include "Glide64_UCode.h"
#include "../../libretro/SDL.h" #include "libretro/SDL.h"


#ifdef __LIBRETRO__ // Prefix API #ifdef __LIBRETRO__ // Prefix API
#define VIDEO_TAG(X) glide64##X #define VIDEO_TAG(X) glide64##X
Expand Down Expand Up @@ -226,8 +226,8 @@ void rdp_new(void)
rdp.cur_cache[i] = 0; rdp.cur_cache[i] = 0;
} }


if (perf_get_cpu_features_cb) //if (perf_get_cpu_features_cb)
cpu = perf_get_cpu_features_cb(); // cpu = perf_get_cpu_features_cb();


_gSPVertex = gSPVertex_G64; _gSPVertex = gSPVertex_G64;
} }
Expand All @@ -236,8 +236,8 @@ void rdp_setfuncs(void)
{ {
if (settings.hacks & hack_Makers) if (settings.hacks & hack_Makers)
{ {
if (log_cb) //if (log_cb)
log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n"); // log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n");
gfx_instruction[0][191] = uc0_tri1_mischief; gfx_instruction[0][191] = uc0_tri1_mischief;
} }
} }
Expand Down
12 changes: 8 additions & 4 deletions jni/mupen64plus-video-glide2gl/src/Glide64/glidemain.c
Expand Up @@ -46,10 +46,10 @@
#include "FBtoScreen.h" #include "FBtoScreen.h"
#include "DepthBufferRender.h" #include "DepthBufferRender.h"
#include "Glide64_Ini.h" #include "Glide64_Ini.h"
#include "api/libretro.h" #include "libretro/libretro.h"
#include <android/log.h>


extern void CRC_BuildTable(); extern void CRC_BuildTable();
extern retro_log_printf_t log_cb;
extern uint32_t screen_aspectmodehint; extern uint32_t screen_aspectmodehint;


#if defined(__GNUC__) #if defined(__GNUC__)
Expand Down Expand Up @@ -96,6 +96,8 @@ extern uint32_t screen_aspectmodehint;


void (*_gSPVertex)(uint32_t addr, uint32_t n, uint32_t v0); void (*_gSPVertex)(uint32_t addr, uint32_t n, uint32_t v0);


GFX_INFO gfx_info;

int romopen = false; int romopen = false;
int exception = false; int exception = false;


Expand Down Expand Up @@ -491,6 +493,8 @@ EXPORT int CALL InitiateGFX (GFX_INFO Gfx_Info)


rdp_new(); rdp_new();


gfx_info = Gfx_Info;

// Assume scale of 1 for debug purposes // Assume scale of 1 for debug purposes
rdp.scale_x = 1.0f; rdp.scale_x = 1.0f;
rdp.scale_y = 1.0f; rdp.scale_y = 1.0f;
Expand Down Expand Up @@ -544,8 +548,8 @@ static void CheckDRAMSize(void)
else else
BMASK = 0x3FFFFF; BMASK = 0x3FFFFF;


if (log_cb)
log_cb(RETRO_LOG_INFO, "Detected RDRAM size: %08lx\n", BMASK); __android_log_print(ANDROID_LOG_ERROR, "glide2gl","Detected RDRAM size: %08lx\n", BMASK);
} }


/****************************************************************** /******************************************************************
Expand Down
2 changes: 1 addition & 1 deletion jni/mupen64plus-video-glide2gl/src/Glide64/rdp.h
Expand Up @@ -40,7 +40,7 @@
#ifndef RDP_H #ifndef RDP_H
#define RDP_H #define RDP_H


#include "rdp_common/gdp.h" #include "gdp.h"
#include "Gfx_1.3.h" #include "Gfx_1.3.h"


extern uint32_t frame_count; // frame counter extern uint32_t frame_count; // frame counter
Expand Down

0 comments on commit 0d93424

Please sign in to comment.