mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-21 05:43:42 -07:00
Add Support for macOS (#441)
* Fixed soh filters * add more makefile changes * almost ready * more updates * update * update * Update Makefiles to handle both platforms * Allow for overriding the CXX and CC executables * Restore original structure while supporting custom CXX flags * Remove some platform specific libs * Dynamic target name * Make X11 paths package-agnostic * Remove changes to `gfx_opengl.cpp` * Use OpenGL2 on MacOS instead of OpenGL3 * make it actually render something * render at least the first texture, still need to figure out the second one * Let’s use OpenGL 3 again * maybe this works to get the right texture? link's eyes still look off a bit * did this work? * set the platform to macos * actual numbers are right, but logic is ugly XXX/TODO, i know * add zlib to ldflags for ZAPDUtils * A bit of cleanup * Revert unneeded changes * Remove GL_CHECK * Fix issues with z64 branch * use an std::map instead of a giant array * three point filter fix (#2) * Fix mac compilation * fix audio for 64 bit * revert audio heap size, keep bigger pools * Add more Apple specific checks to our modifications * Add building instructions for macOS * Remove unecessary step from building instructions * Add missing SDL2 & GLEW to Linux LDLIBS * Update BUILDING.md Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com> * Update soh/.gitignore to include other arch binaries Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com> * Use right platform name for debugging window Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com> * Fix stormlib on macos (arm64) * Simplify some of the ifdef checks * Revert an older no longer necessary fix * Remove remaining unecessary deviations * Update building instructions after StormLib changes * Feature: Use OpenGL 4.1 (#1) * Further tweak the BUILDING * Tidy up * reword -j message * Add Jenkins CI Support (#2) * Fix type issues * add target <appbundle> and <filledappbundle> add makefile targets to create an .app `filledappbundle` creates the target with the .otr included this should perhaps be moved to Application Support though * pull gcc's rpath from otool output * move make target to the end so it's not default * Add Jenkins and make exe in par with other platforms * Actually save build artefacts * Fix artefact path * Remove x11 mentions and linking (not used) * Update building instructions for generating app * use appsupport directory * Add new app icon * Update target to match macOS types * Update more audio types * fix null deref in Audio_PlayFanfare * Remove old import from z64 * address final nit with apple ifdefs Co-authored-by: KiritoDev <36680385+KiritoDv@users.noreply.github.com> Co-authored-by: Jeffrey Crowell <github@crowell.biz> Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>
This commit is contained in:
parent
77e7080a8c
commit
e42b18cf71
32 changed files with 441 additions and 69 deletions
9
soh/.gitignore
vendored
9
soh/.gitignore
vendored
|
@ -18,12 +18,16 @@ notes/
|
|||
baserom/
|
||||
docs/doxygen/
|
||||
*.elf
|
||||
*-arm64
|
||||
*-x86_64
|
||||
*.sra
|
||||
*.z64
|
||||
*.n64
|
||||
*.v64
|
||||
*.map
|
||||
*.dump
|
||||
*.app/
|
||||
*.icns
|
||||
out.txt
|
||||
shipofharkinian.ini
|
||||
imgui.ini
|
||||
|
@ -404,4 +408,7 @@ ZAPD/BuildInfo.h
|
|||
cvars.cfg
|
||||
|
||||
DebugObj/*
|
||||
ReleaseObj/*
|
||||
ReleaseObj/*
|
||||
|
||||
# Junk from App Bundle
|
||||
appsupport
|
||||
|
|
106
soh/Makefile
106
soh/Makefile
|
@ -1,9 +1,11 @@
|
|||
CXX := g++
|
||||
CC := gcc
|
||||
CXX ?= g++
|
||||
CC ?= gcc
|
||||
LD := lld
|
||||
AR := ar
|
||||
FORMAT := clang-format-11
|
||||
ZAPD := ../ZAPDTR/ZAPD.out
|
||||
UNAME := $(shell uname)
|
||||
UNAMEM := $(shell uname -m)
|
||||
|
||||
LIBULTRASHIP := ../libultraship/libultraship.a
|
||||
ZAPDUTILS := ../ZAPDTR/ZAPDUtils/ZAPDUtils.a
|
||||
|
@ -17,11 +19,22 @@ 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 -msse2 -mfpmath=sse
|
||||
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib -msse2 -mfpmath=sse
|
||||
CXXFLAGS := $(WARN) -std=c++20 -D_GNU_SOURCE -fpermissive -no-pie -nostdlib
|
||||
CFLAGS := $(WARN) -std=c99 -D_GNU_SOURCE -no-pie -nostdlib
|
||||
LDFLAGS :=
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
CXXFLAGS += -mhard-float -msse2 -mfpmath=sse
|
||||
CFLAGS += -mhard-float -msse2 -mfpmath=sse
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
CXXFLAGS += $(shell pkg-config --cflags sdl2) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL
|
||||
CFLAGS += $(shell pkg-config --cflags sdl2) $(shell sdl2-config --cflags) $(shell pkg-config --cflags glew) -framework OpenGL
|
||||
endif
|
||||
|
||||
CPPFLAGS := -MMD
|
||||
|
||||
ifneq ($(DEBUG),0)
|
||||
|
@ -41,7 +54,13 @@ ifneq ($(LTO),0)
|
|||
LDFLAGS += -flto
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
TARGET := soh.elf
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
TARGET := soh-$(UNAMEM)
|
||||
endif
|
||||
|
||||
INC_DIRS := $(addprefix -I, \
|
||||
. \
|
||||
|
@ -56,26 +75,52 @@ INC_DIRS := $(addprefix -I, \
|
|||
../libultraship/libultraship/Lib/Fast3D/U64/PR \
|
||||
)
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
INC_DIRS += $(addprefix -I, \
|
||||
/opt/X11/include \
|
||||
)
|
||||
endif
|
||||
|
||||
LDDIRS := $(addprefix -L, \
|
||||
../libultraship/ \
|
||||
)
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
LDDIRS += $(addprefix -L, \
|
||||
/opt/X11/lib \
|
||||
)
|
||||
endif
|
||||
|
||||
LDLIBS := \
|
||||
$(ZAPDUTILS) \
|
||||
$(LIBSTORM) \
|
||||
$(addprefix -l, \
|
||||
X11 \
|
||||
dl \
|
||||
bz2 \
|
||||
z \
|
||||
pthread \
|
||||
atomic \
|
||||
ultraship \
|
||||
)
|
||||
|
||||
ifeq ($(UNAME), Linux) #LINUX
|
||||
LDLIBS += \
|
||||
$(addprefix -l, \
|
||||
X11 \
|
||||
SDL2 \
|
||||
GL \
|
||||
GLEW \
|
||||
pulse\
|
||||
ultraship \
|
||||
pulse \
|
||||
)
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), Darwin) #APPLE
|
||||
LDLIBS += \
|
||||
$(addprefix -framework, \
|
||||
OpenGL \
|
||||
) \
|
||||
$(shell sdl2-config --libs) $(shell pkg-config --libs glew)
|
||||
endif
|
||||
|
||||
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")
|
||||
ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml))
|
||||
|
@ -114,6 +159,14 @@ O_FILES := \
|
|||
$(CXX_FILES:%.cpp=build/%.o)
|
||||
D_FILES := $(O_FILES:%.o=%.d)
|
||||
|
||||
# Apple App Bundle
|
||||
APPNAME=soh
|
||||
APPBUNDLE=$(APPNAME).app
|
||||
APPBUNDLECONTENTS=$(APPBUNDLE)/Contents
|
||||
APPBUNDLEEXE=$(APPBUNDLECONTENTS)/MacOS
|
||||
APPBUNDLERESOURCES=$(APPBUNDLECONTENTS)/Resources
|
||||
APPBUNDLEICON=$(APPBUNDLECONTENTS)/Resources
|
||||
|
||||
# create build directory
|
||||
SRC_DIRS := $(shell find . -type d -a -not -path "*build*")
|
||||
$(shell mkdir -p $(SRC_DIRS:%=build/%))
|
||||
|
@ -157,4 +210,39 @@ $(TARGET): $(LIBULTRASHIP)
|
|||
$(TARGET): $(O_FILES)
|
||||
$(CXX) $^ -o $@ $(LDFLAGS) -fuse-ld=$(LD) $(LDDIRS) $(LDLIBS)
|
||||
|
||||
-include $(D_FILES)
|
||||
-include $(D_FILES)
|
||||
|
||||
appbundle: macosx/$(APPNAME).icns
|
||||
rm -rf $(APPBUNDLE)
|
||||
mkdir $(APPBUNDLE)
|
||||
mkdir $(APPBUNDLE)/Contents
|
||||
mkdir $(APPBUNDLE)/Contents/MacOS
|
||||
mkdir $(APPBUNDLE)/Contents/Resources
|
||||
cp macosx/Info.plist $(APPBUNDLECONTENTS)/
|
||||
cp macosx/PkgInfo $(APPBUNDLECONTENTS)/
|
||||
cp macosx/$(APPNAME).icns $(APPBUNDLEICON)/
|
||||
cp $(TARGET) $(APPBUNDLEEXE)/soh
|
||||
cp macosx/launcher.sh $(APPBUNDLEEXE)/launcher.sh
|
||||
clang -ObjC macosx/appsupport.m -arch arm64 -arch x86_64 -framework Foundation -o macosx/appsupport
|
||||
cp macosx/appsupport $(APPBUNDLEEXE)/appsupport
|
||||
otool -l $(TARGET) | grep -A 2 LC_RPATH | tail -n 1 | awk '{print $2}' | dylibbundler -od -b -x $(APPBUNDLEEXE)/soh -d $(APPBUNDLECONTENTS)/libs
|
||||
|
||||
macosx/$(APPNAME).icns: macosx/$(APPNAME)Icon.png
|
||||
rm -rf macosx/$(APPNAME).iconset
|
||||
mkdir macosx/$(APPNAME).iconset
|
||||
sips -z 16 16 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_16x16.png
|
||||
sips -z 32 32 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_16x16@2x.png
|
||||
sips -z 32 32 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_32x32.png
|
||||
sips -z 64 64 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_32x32@2x.png
|
||||
sips -z 128 128 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_128x128.png
|
||||
sips -z 256 256 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_128x128@2x.png
|
||||
sips -z 256 256 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_256x256.png
|
||||
sips -z 512 512 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_256x256@2x.png
|
||||
sips -z 512 512 macosx/$(APPNAME)Icon.png --out macosx/$(APPNAME).iconset/icon_512x512.png
|
||||
cp macosx/$(APPNAME)Icon.png macosx/$(APPNAME).iconset/icon_512x512@2x.png
|
||||
iconutil -c icns -o macosx/$(APPNAME).icns macosx/$(APPNAME).iconset
|
||||
rm -r macosx/$(APPNAME).iconset
|
||||
|
||||
filledappbundle: appbundle
|
||||
cp ./oot.otr $(APPBUNDLEEXE)/oot.otr
|
||||
|
||||
|
|
|
@ -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, ...);
|
||||
|
|
|
@ -501,7 +501,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 {
|
||||
|
|
35
soh/macosx/Info.plist
Normal file
35
soh/macosx/Info.plist
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Ship of Harkinian</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>launcher.sh</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>soh.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.shipofharkinian.ShipOfHarkinian</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
</array>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>ZOoT</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 2022 HarbourMasters.</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.3</string>
|
||||
</dict>
|
||||
</plist>
|
1
soh/macosx/PkgInfo
Normal file
1
soh/macosx/PkgInfo
Normal file
|
@ -0,0 +1 @@
|
|||
APPLZOoT
|
26
soh/macosx/appsupport.m
Normal file
26
soh/macosx/appsupport.m
Normal file
|
@ -0,0 +1,26 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
int main(void) {
|
||||
NSString *appSupportDir = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];
|
||||
//If there isn't an App Support Directory yet ...
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:appSupportDir isDirectory:NULL]) {
|
||||
NSError *error = nil;
|
||||
//Create one
|
||||
if (![[NSFileManager defaultManager] createDirectoryAtPath:appSupportDir withIntermediateDirectories:YES attributes:nil error:&error]) {
|
||||
NSLog(@"%@", error.localizedDescription);
|
||||
}
|
||||
else {
|
||||
// *** OPTIONAL *** Mark the directory as excluded from iCloud backups
|
||||
NSURL *url = [NSURL fileURLWithPath:appSupportDir];
|
||||
if (![url setResourceValue:@YES
|
||||
forKey:NSURLIsExcludedFromBackupKey
|
||||
error:&error])
|
||||
{
|
||||
NSLog(@"Error excluding %@ from backup %@", url.lastPathComponent, error.localizedDescription);
|
||||
}
|
||||
else {
|
||||
NSLog(@"Yay");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s\n", [appSupportDir UTF8String]);
|
||||
}
|
9
soh/macosx/launcher.sh
Executable file
9
soh/macosx/launcher.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
APPPATH="${0%/*}"
|
||||
cd "${APPPATH}"
|
||||
APPPATH=$(pwd)
|
||||
APPSUPPORT=$(./appsupport)
|
||||
mkdir -p "${APPSUPPORT}/com.shipofharkinian.soh"
|
||||
cd "${APPSUPPORT}/com.shipofharkinian.soh"
|
||||
cp "${APPPATH}/oot.otr" .
|
||||
${APPPATH}/soh
|
BIN
soh/macosx/sohIcon.png
Normal file
BIN
soh/macosx/sohIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
|
@ -40,7 +40,12 @@
|
|||
#include "macros.h"
|
||||
#include <Utils/StringHelper.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <SDL_scancode.h>
|
||||
#else
|
||||
#include <SDL2/SDL_scancode.h>
|
||||
#endif
|
||||
|
||||
#include <Audio.h>
|
||||
|
||||
OTRGlobals* OTRGlobals::Instance;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "z64.h"
|
||||
#include <assert.h>
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -4527,12 +4527,17 @@ void Audio_PlayFanfare(u16 seqId)
|
|||
sp26 = func_800FA0B4(SEQ_PLAYER_FANFARE);
|
||||
sp1C = func_800E5E84(sp26 & 0xFF, &sp20);
|
||||
sp18 = func_800E5E84(seqId & 0xFF, &sp20);
|
||||
if ((sp26 == NA_BGM_DISABLED) || (*sp1C == *sp18)) {
|
||||
D_8016B9F4 = 1;
|
||||
} else {
|
||||
D_8016B9F4 = 5;
|
||||
Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0);
|
||||
}
|
||||
if (!sp1C || !sp18) {
|
||||
// disable BGM, we're about to null deref!
|
||||
D_8016B9F4 = 1;
|
||||
} else {
|
||||
if ((sp26 == NA_BGM_DISABLED) || (*sp1C == *sp18)) {
|
||||
D_8016B9F4 = 1;
|
||||
} else {
|
||||
D_8016B9F4 = 5;
|
||||
Audio_SeqCmd1(SEQ_PLAYER_FANFARE, 0);
|
||||
}
|
||||
}
|
||||
D_8016B9F6 = seqId;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue