Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Workin that sucker to death
Browse files Browse the repository at this point in the history
  • Loading branch information
heyjoeway committed Nov 26, 2021
1 parent 9cbb94f commit c5c08f4
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 35 deletions.
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"files.associations": {
"*.vertex": "glsl",
"*.fragment": "glsl",
"__bit_reference": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"array": "cpp",
"deque": "cpp",
"filesystem": "cpp",
"initializer_list": "cpp",
"iterator": "cpp",
"map": "cpp",
"string": "cpp",
"string_view": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp"
}
}
58 changes: 31 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PROFILE ?= 0
STRIP ?= strip

# -fsigned-char required to prevent hang in LoadStageCollisions
CFLAGS ?= -fsigned-char
CFLAGS ?= -fsigned-char -std=c++17

# =============================================================================
# Detect default platform if not explicitly specified
Expand Down Expand Up @@ -77,36 +77,40 @@ ifeq ($(STATIC),1)
CFLAGS += -static
endif

INCLUDES += -I./RSDKv3 \
-I./dependencies/all/theoraplay
INCLUDES += \
-I./RSDKv3 \
-I./dependencies/all/theoraplay \
-I./dependencies/all/tinyxml2

INCLUDES += $(LIBS)

# Main Sources
SOURCES += RSDKv3/Animation \
RSDKv3/Audio \
RSDKv3/Collision \
RSDKv3/Debug \
RSDKv3/Drawing \
RSDKv3/fcaseopen \
RSDKv3/Ini \
RSDKv3/Input \
RSDKv3/main \
RSDKv3/Math \
RSDKv3/ModAPI \
RSDKv3/Object \
RSDKv3/Palette \
RSDKv3/Player \
RSDKv3/Reader \
RSDKv3/RetroEngine \
RSDKv3/Scene \
RSDKv3/Scene3D \
RSDKv3/Script \
RSDKv3/Sprite \
RSDKv3/String \
RSDKv3/Text \
RSDKv3/Userdata \
RSDKv3/Video
SOURCES += \
RSDKv3/Animation \
RSDKv3/Audio \
RSDKv3/Collision \
RSDKv3/Debug \
RSDKv3/Drawing \
RSDKv3/fcaseopen \
RSDKv3/Ini \
RSDKv3/Input \
RSDKv3/main \
RSDKv3/Math \
RSDKv3/ModAPI \
RSDKv3/Object \
RSDKv3/Palette \
RSDKv3/Player \
RSDKv3/Reader \
RSDKv3/RetroEngine \
RSDKv3/Scene \
RSDKv3/Scene3D \
RSDKv3/Script \
RSDKv3/Sprite \
RSDKv3/String \
RSDKv3/Text \
RSDKv3/Userdata \
RSDKv3/Video \
dependencies/all/tinyxml2/tinyxml2

# Theoraplay sources
SOURCES += dependencies/all/theoraplay/theoraplay
Expand Down
5 changes: 5 additions & 0 deletions Makefile_cfgs/Platforms/Switch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ STATIC = 1

include $(DEVKITPRO)/libnx/switch_rules
PKGCONFIG = $(DEVKITPRO)/portlibs/switch/bin/aarch64-none-elf-pkg-config
STRIP = $(DEVKITPRO)/devkitA64/bin/aarch64-none-elf-strip
NACPTOOL=$(DEVKITPRO)/tools/bin/nacptool

CFLAGS += -DARM -march=armv8-a -mtune=cortex-a57 -mtp=soft \
Expand All @@ -15,6 +16,10 @@ ifdef NXLINK
DEFINES += -DENABLE_NXLINK
endif

CFLAGS += `$(PKGCONFIG) --cflags libglad egl glesv1_cm`
LIBS += `$(PKGCONFIG) --libs-only-l libglad egl glesv1_cm`
LIBPATHS += `$(PKGCONFIG) --libs-only-L libglad egl glesv1_cm`

SUFFIX = .elf
PKGSUFFIX = .nro

Expand Down
7 changes: 5 additions & 2 deletions RSDKv3/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ int InitRenderDevice()

SDL_GL_SetSwapInterval(Engine.vsync ? 1 : 0);

#if RETRO_PLATFORM != RETRO_ANDROID && RETRO_PLATFORM != RETRO_OSX
#if RETRO_PLATFORM == RETRO_SWITCH
// Should probably add error
gladLoadGL();
#elif RETRO_PLATFORM != RETRO_ANDROID && RETRO_PLATFORM != RETRO_OSX
// glew Setup
GLenum err = glewInit();
if (err != GLEW_OK) {
Expand Down Expand Up @@ -867,6 +870,7 @@ void RenderFromTexture()

void RenderFromRetroBuffer()
{
#if RETRO_USING_OPENGL
if (drawStageGFXHQ) {
glBindTexture(GL_TEXTURE_2D, retroBuffer2x);

Expand Down Expand Up @@ -912,7 +916,6 @@ void RenderFromRetroBuffer()
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, SCREEN_XSIZE * 2, SCREEN_YSIZE * 2, GL_RGBA, GL_UNSIGNED_BYTE, Engine.texBuffer2x);
}

#if RETRO_USING_OPENGL
glLoadIdentity();
glBindTexture(GL_TEXTURE_2D, drawStageGFXHQ ? retroBuffer2x : retroBuffer);
#if DONT_USE_VIEW_ANGLE
Expand Down
4 changes: 4 additions & 0 deletions RSDKv3/ModAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ namespace fs = std::filesystem;

fs::path resolvePath(fs::path given)
{
// This crashes and I don't know why
// Maybe to do with pathconf somehow?
#if RETRO_PLATFORM != RETRO_SWITCH
if (given.is_relative())
given = fs::current_path() / given; // thanks for the weird syntax!
#endif
for (auto &p : fs::directory_iterator{ given.parent_path() }) {
char pbuf[0x100];
char gbuf[0x100];
Expand Down
7 changes: 7 additions & 0 deletions RSDKv3/RetroEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ typedef unsigned int uint;
#define RETRO_GAMEPLATFORM (RETRO_STANDARD)
#endif

#if RETRO_PLATFORM != RETRO_SWITCH
#define RETRO_USING_OPENGL (1)
#endif

#if RETRO_USING_OPENGL
#if RETRO_PLATFORM == RETRO_ANDROID
Expand Down Expand Up @@ -164,6 +166,11 @@ typedef unsigned int uint;
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
#elif RETRO_PLATFORM == RETRO_SWITCH
#include <GLES/gl.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <glad/glad.h> // OpenGL loader
#else
#include <GL/glew.h>
#endif
Expand Down
14 changes: 8 additions & 6 deletions RSDKv3/Userdata.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "RetroEngine.hpp"

#if defined(__SWITCH__)
#include "filesystem.hpp"
#define STD_FILESYSTEM ghc::filesystem
#else
#define STD_FILESYSTEM std::filesystem
// Your guess is as good as mine
#if RETRO_PLATFORM == RETRO_SWITCH
long pathconf (const char *__path, int __name) {
return 0;
}
#endif

#if RETRO_PLATFORM == RETRO_WIN && _MSC_VER
Expand Down Expand Up @@ -247,6 +247,7 @@ void InitUserdata()
ini.SetBool("Window", "VSync", Engine.vsync = true);
#else
ini.SetBool("Window", "VSync", Engine.vsync = false);
#endif
ini.SetInteger("Window", "ScalingMode", Engine.scalingMode = 0);
ini.SetInteger("Window", "WindowScale", Engine.windowScale = 2);
ini.SetInteger("Window", "ScreenWidth", SCREEN_XSIZE = DEFAULT_SCREEN_XSIZE);
Expand Down Expand Up @@ -364,12 +365,13 @@ void InitUserdata()
Engine.startFullScreen = DEFAULT_FULLSCREEN;
if (!ini.GetBool("Window", "Borderless", &Engine.borderless))
Engine.borderless = false;
if (!ini.GetBool("Window", "VSync", &Engine.vsync))
if (!ini.GetBool("Window", "VSync", &Engine.vsync)) {
#if RETRO_PLATFORM == RETRO_SWITCH
Engine.vsync = true;
#else
Engine.vsync = false;
#endif
}
if (!ini.GetInteger("Window", "ScalingMode", &Engine.scalingMode))
Engine.scalingMode = 0;
if (!ini.GetInteger("Window", "WindowScale", &Engine.windowScale))
Expand Down
33 changes: 33 additions & 0 deletions RSDKv3/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
#include "RetroEngine.hpp"

#ifdef NXLINK
#include <switch.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/errno.h>
#include <arpa/inet.h>
#include <unistd.h>

static int s_nxlinkSock = -1;

static void initNxLink()
{
if (R_FAILED(socketInitializeDefault()))
return;

s_nxlinkSock = nxlinkStdio();
if (s_nxlinkSock >= 0)
printf("printf output now goes to nxlink server\n");
else
socketExit();
}
#endif

int main(int argc, char *argv[])
{
#ifdef NXLINK
initNxLink();
#endif

for (int i = 0; i < argc; ++i) {
if (StrComp(argv[i], "UsingCWD"))
usingCWD = true;
Expand All @@ -10,5 +39,9 @@ int main(int argc, char *argv[])
Engine.Init();
Engine.Run();

#ifdef NXLINK
socketExit();
#endif

return 0;
}

0 comments on commit c5c08f4

Please sign in to comment.