From f5af934528bfc9b8ed6c102f7090eb910460ec46 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Mon, 16 May 2022 13:11:07 -0400 Subject: [PATCH] almost ready --- ZAPDTR/Makefile | 5 ++++- libultraship/Makefile | 2 +- .../libultraship/Lib/Fast3D/gfx_opengl.cpp | 8 +++++-- .../Lib/ImGui/backends/imgui_impl_glfw.cpp | 2 +- .../Lib/ImGui/backends/imgui_impl_opengl3.cpp | 6 +++--- libultraship/libultraship/SohImGuiImpl.cpp | 4 ++++ soh/.gitignore | 3 ++- soh/Makefile | 21 ++++++++++++------- soh/include/functions.h | 2 ++ soh/include/z64item.h | 2 +- soh/soh/OTRGlobals.cpp | 5 +++++ soh/src/buffers/heaps.c | 2 ++ 12 files changed, 45 insertions(+), 17 deletions(-) diff --git a/ZAPDTR/Makefile b/ZAPDTR/Makefile index d1aa8c3cd..6182b20b1 100644 --- a/ZAPDTR/Makefile +++ b/ZAPDTR/Makefile @@ -47,7 +47,10 @@ endif # CXXFLAGS += -DTEXTURE_DEBUG LDFLAGS := -lm -ldl -lpng \ - -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm -lSDL2 $(shell pkg-config --libs glew) -lX11 + -L../external -L../libultraship -lz -lbz2 -pthread -lpulse -lultraship -lstorm $(shell pkg-config --libs glew x11 libpng) $(shell sdl2-config --libs) + + + # Use LLD if available. Set LLD=0 to not use it ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) diff --git a/libultraship/Makefile b/libultraship/Makefile index 2d04a4ec3..d967bf7f3 100644 --- a/libultraship/Makefile +++ b/libultraship/Makefile @@ -18,7 +18,7 @@ WARN := -Wall -Wextra -Werror \ -Wno-narrowing \ -Wno-missing-field-initializers -CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 -Wno-deprecated-enum-enum-conversion CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -DENABLE_OPENGL -DSPDLOG_ACTIVE_LEVEL=0 CPPFLAGS := -MMD $(shell pkg-config --cflags sdl2 glew) diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index 99236c7a4..ed4f74aa5 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -280,7 +280,11 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad append_line(vs_buf, &vs_len, "}"); // Fragment shader +#ifdef __APPLE__ append_line(fs_buf, &fs_len, "#version 130"); +#else + append_line(fs_buf, &fs_len, "#version 130"); +#endif //append_line(fs_buf, &fs_len, "precision mediump float;"); for (int i = 0; i < 2; i++) { if (cc_features.used_textures[i]) { @@ -435,9 +439,9 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad GLint max_length = 0; glGetShaderiv(vertex_shader, GL_INFO_LOG_LENGTH, &max_length); char error_log[1024]; - //fprintf(stderr, "Vertex shader compilation failed\n"); + fprintf(stderr, "Vertex shader compilation failed\n"); glGetShaderInfoLog(vertex_shader, max_length, &max_length, &error_log[0]); - //fprintf(stderr, "%s\n", &error_log[0]); + fprintf(stderr, "%s\n", &error_log[0]); abort(); } diff --git a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_glfw.cpp b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_glfw.cpp index 4a5a9855d..366782485 100644 --- a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_glfw.cpp +++ b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_glfw.cpp @@ -126,7 +126,7 @@ struct ImGui_ImplGlfw_Data GLFWcharfun PrevUserCallbackChar; GLFWmonitorfun PrevUserCallbackMonitor; - ImGui_ImplGlfw_Data() { memset(this, 0, sizeof(*this)); } + ImGui_ImplGlfw_Data() { /*memset(this, 0, sizeof(*this));*/ } }; // Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts diff --git a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp index 499798bb0..ae9ee5f90 100644 --- a/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp +++ b/libultraship/libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp @@ -216,11 +216,11 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); // Initialize our loader -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) +#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) || 0 if (imgl3wInit() != 0) { fprintf(stderr, "Failed to initialize OpenGL loader!\n"); - return false; + // return false; } #endif @@ -254,7 +254,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version) // Store GLSL version string so we can refer to it later in case we recreate shaders. // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure. - if (glsl_version == NULL) + if (glsl_version == NULL || true) { #if defined(IMGUI_IMPL_OPENGL_ES2) glsl_version = "#version 100"; diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 8e4becaab..3c7b7f1bf 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -153,7 +153,11 @@ namespace SohImGui { void ImGuiBackendInit() { switch (impl.backend) { case Backend::SDL: +#if __APPLE__ ImGui_ImplOpenGL3_Init("#version 120"); +#else + ImGui_ImplOpenGL3_Init("#version 120"); +#endif break; #if defined(ENABLE_DX11) || defined(ENABLE_DX12) diff --git a/soh/.gitignore b/soh/.gitignore index 5920cfba7..345f7532d 100644 --- a/soh/.gitignore +++ b/soh/.gitignore @@ -18,6 +18,7 @@ notes/ baserom/ docs/doxygen/ *.elf +*.arm64 *.sra *.z64 *.n64 @@ -404,4 +405,4 @@ ZAPD/BuildInfo.h cvars.cfg DebugObj/* -ReleaseObj/* \ No newline at end of file +ReleaseObj/* diff --git a/soh/Makefile b/soh/Makefile index 186c820ff..3e99950f8 100644 --- a/soh/Makefile +++ b/soh/Makefile @@ -16,10 +16,10 @@ LTO ?= 0 WARN := \ -Wno-return-type \ -funsigned-char \ - -mhard-float -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ + -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-strict-aliasing -fno-inline-functions -fno-inline-small-functions -fno-toplevel-reorder -ffreestanding -fwrapv \ -CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib -march=i386 -CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -march=i386 +CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib $(shell pkg-config --cflags sdl2 x11) +CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib $(shell pkg-config --cflags sdl2 x11) LDFLAGS := CPPFLAGS := -MMD @@ -28,6 +28,9 @@ ifneq ($(DEBUG),0) CFLAGS += -g endif +CXXFLAGS += -g +CFLAGS += -g + ifneq ($(ASAN),0) CXXFLAGS += -fsanitize=address LDFLAGS += -fsanitize=address @@ -38,7 +41,7 @@ ifneq ($(LTO),0) LDFLAGS += -flto endif -TARGET := soh.elf +TARGET := soh.arm64 INC_DIRS := $(addprefix -I, \ . \ @@ -51,11 +54,16 @@ INC_DIRS := $(addprefix -I, \ ../libultraship/libultraship/Lib/spdlog/include \ ../libultraship/libultraship/Lib/Fast3D/U64 \ ../libultraship/libultraship/Lib/Fast3D/U64/PR \ + /opt/X11/include \ ) +CFLAGS := $(CFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) +CXXFLAGS := $(CXXFLAGS) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) + LDDIRS := $(addprefix -L, \ ../external \ ../libultraship/ \ + /opt/X11/lib \ ) LDLIBS := \ @@ -67,14 +75,13 @@ LDLIBS := \ z \ pthread \ atomic \ - SDL2 \ GL \ - GLEW \ storm \ - pulse\ ultraship \ ) \ +LDLIBS := $(LDLIBS) $(shell sdl2-config --libs) $(shell pkg-config --libs glew) + ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml)) ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) diff --git a/soh/include/functions.h b/soh/include/functions.h index 0b32e4cdd..ee0df73a9 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -60,7 +60,9 @@ void Locale_ResetRegion(void); u32 func_80001F48(void); u32 func_80001F8C(void); u32 Locale_IsRegionNative(void); +#ifndef __APPLE__ void __assert(const char* exp, const char* file, s32 line); +#endif void isPrintfInit(void); void osSyncPrintfUnused(const char* fmt, ...); //void osSyncPrintf(const char* fmt, ...); diff --git a/soh/include/z64item.h b/soh/include/z64item.h index 05b2a24b2..13b2ece55 100644 --- a/soh/include/z64item.h +++ b/soh/include/z64item.h @@ -495,7 +495,7 @@ typedef enum { /* 0x72 */ GID_BULLET_BAG_50, /* 0x73 */ GID_SWORD_KOKIRI, /* 0x74 */ GID_SKULL_TOKEN_2, - /* 0x75 */ GID_MAX + /* 0x75 */ GID_MAXIMUM } GetItemDrawID; typedef enum { diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index ebc4b3621..9251fe5fe 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -35,7 +35,12 @@ #include "macros.h" #include +#ifdef __APPLE__ +#include +#else #include +#endif + OTRGlobals* OTRGlobals::Instance; diff --git a/soh/src/buffers/heaps.c b/soh/src/buffers/heaps.c index b6f16ab11..410c843a5 100644 --- a/soh/src/buffers/heaps.c +++ b/soh/src/buffers/heaps.c @@ -1,6 +1,8 @@ #include "z64.h" #include +#ifndef __APPLE__ #include +#endif #ifndef _MSC_VER #include