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
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]
comment=gliden64 video with recommended settings for most older devices
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_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) \
$(PNG_INCLUDES) \
$(SDL_INCLUDES) \
Expand All @@ -21,8 +24,8 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glitch64/glitch64_combiner.c \
$(SRCDIR)/Glitch64/glitch64_textures.c \
$(SRCDIR)/Glitch64/glitchmain.c \
$(SRCDIR)/Glide64/osal_dynamiclib_unix.c \
$(SRCDIR)/Glide64/Combine.c \
$(SRCDIR)/Glide64/DepthBufferRender.c \
$(SRCDIR)/Glide64/FBtoScreen.c \
$(SRCDIR)/Glide64/glide64_3dmath.c \
$(SRCDIR)/Glide64/Glide64_Ini.c \
Expand All @@ -33,6 +36,15 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glide64/MiClWr.c \
$(SRCDIR)/Glide64/TexCache.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 := \
$(COMMON_CFLAGS) \
Expand All @@ -56,7 +68,8 @@ LOCAL_LDLIBS := \

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

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

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)
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 "DepthBufferRender.h"

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

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

extern uint8_t microcode[4096];
extern uint32_t uc_crc;
Expand Down Expand Up @@ -182,8 +182,8 @@ void microcheck(void)
)
{
settings.ucode = 2;
if (log_cb)
log_cb(RETRO_LOG_INFO, "Microcode 2 - F3DEX 2.XX (The Legend of Zelda: Ocarina of Time)\n");
//if (log_cb)
// log_cb(RETRO_LOG_INFO, "Microcode 2 - F3DEX 2.XX (The Legend of Zelda: Ocarina of Time)\n");
}
else if (
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 "../../libretro/SDL.h"
#include "libretro/SDL.h"

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

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

#if defined(__ARM_NEON__)
if (cpu & RETRO_SIMD_NEON)
if (/*cpu & */RETRO_SIMD_NEON)
{
glide64NormalizeVector = NormalizeVectorNeon;
glide64MulMatrices = MulMatricesNeon;
glide64DotProduct = DotProductNeon;
if (log_cb)
log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n");
//if (log_cb)
// log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n");
}
#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 "GBI.h"
#include "Glide64_UCode.h"
#include "../../libretro/SDL.h"
#include "libretro/SDL.h"

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

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

_gSPVertex = gSPVertex_G64;
}
Expand All @@ -236,8 +236,8 @@ void rdp_setfuncs(void)
{
if (settings.hacks & hack_Makers)
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n");
//if (log_cb)
// log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n");
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 "DepthBufferRender.h"
#include "Glide64_Ini.h"
#include "api/libretro.h"
#include "libretro/libretro.h"
#include <android/log.h>

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

#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);

GFX_INFO gfx_info;

int romopen = false;
int exception = false;

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

rdp_new();

gfx_info = Gfx_Info;

// Assume scale of 1 for debug purposes
rdp.scale_x = 1.0f;
rdp.scale_y = 1.0f;
Expand Down Expand Up @@ -544,8 +548,8 @@ static void CheckDRAMSize(void)
else
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
#define RDP_H

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

extern uint32_t frame_count; // frame counter
Expand Down

0 comments on commit 0d93424

Please sign in to comment.