Skip to content

Commit

Permalink
Clean up makefile and build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ckosmic committed Oct 3, 2021
1 parent 6ebe973 commit 6ba6f01
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ ifeq ($(OSX_BUILD),1) # Modify GFX & SDL2 for OSX GL
VERSION_CFLAGS += -DOSX_BUILD
endif

ifeq ($(TARGET_IOS),1)
VERSION_CFLAGS += -DIOS_BUILD
endif

VERSION_ASFLAGS := --defsym AVOID_UB=1
COMPARE := 0

Expand Down Expand Up @@ -514,8 +518,10 @@ else ifeq ($(findstring SDL,$(WINDOW_API)),SDL)
BACKEND_LDFLAGS += -lglew32 -lglu32 -lopengl32
else ifeq ($(TARGET_RPI),1)
BACKEND_LDFLAGS += -lGLESv2
else ifeq ($(OSX_BUILD),1)
else ifeq ($(TARGET_IOS),1)
BACKEND_LDFLAGS += -framework OpenGLES -framework AVFoundation -framework AudioToolbox -framework CoreFoundation -framework CoreGraphics -framework CoreBluetooth -framework CoreAudio -framework IOKit -framework GameController -framework Foundation -framework UIKit -framework QuartzCore -framework CoreMotion -framework CoreHaptics -framework Metal -L. -lSDL2 -lc++ -lstdc++ -D.
else ifeq ($(OSX_BUILD),1)
BACKEND_LDFLAGS += -framework OpenGL `pkg-config --libs glew`
else
BACKEND_LDFLAGS += -lGL
endif
Expand Down Expand Up @@ -761,7 +767,6 @@ $(BUILD_DIR)/$(RPC_LIBS):
@$(CP) -f $(RPC_LIBS) $(BUILD_DIR)

libultra: $(BUILD_DIR)/libultra.a
libsm64ios: $(BUILD_DIR)/libsm64ios.a

$(BUILD_DIR)/asm/boot.o: $(IPL3_RAW_FILES)
$(BUILD_DIR)/src/game/crash_screen.o: $(CRASH_TEXTURE_C_FILES)
Expand Down Expand Up @@ -1019,11 +1024,8 @@ $(BUILD_DIR)/%.o: %.s

$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS)
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)

$(BUILD_DIR)/libsm64ios.a: $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(BUILD_DIR)/$(RPC_LIBS)
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)

.PHONY: all clean distclean default diff test load libultra res libsm64ios
.PHONY: all clean distclean default diff test load libultra res
.PRECIOUS: $(BUILD_DIR)/bin/%.elf $(SOUND_BIN_DIR)/%.ctl $(SOUND_BIN_DIR)/%.tbl $(SOUND_SAMPLE_TABLES) $(SOUND_BIN_DIR)/%.s $(BUILD_DIR)/%
.DELETE_ON_ERROR:

Expand Down
8 changes: 5 additions & 3 deletions build_ios.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export CC="clang -arch arm64 -mios-version-min=13.2 -fobjc-weak -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -DUSE_GLES -DAAPI_SDL2 -DWAPI_SDL2"
export CXX="clang++ -arch arm64 -mios-version-min=13.2 -fobjc-weak -std=c++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -DUSE_GLES -DAAPI_SDL2 -DWAPI_SDL2"
export IOSINCLUDE="/Users/christiankosman/Documents/ioslib/include"
export IOSLIBS="/Users/christiankosman/Documents/ioslib/lib"
export IOSINCLUDE="../ioslib/include"
export IOSLIBS="../ioslib/lib"

gmake -j4 TARGET_IOS=1

Expand All @@ -11,10 +11,12 @@ if [ $? -eq 0 ]; then
cp -R build/us_pc build/sm64ios.app
codesign -f -s "Apple Development" --entitlements sm64ios.entitlements build/sm64ios.app
rm -rf build/Payload
rm build/sm64ios.ipa
rm -rf build/sm64ios.ipa
mkdir build/Payload
cp -r build/sm64ios.app build/Payload
cd build
zip -r -q sm64ios.ipa Payload
rm -rf Payload
rm -rf sm64ios.app
cd ..
fi
4 changes: 2 additions & 2 deletions build_sim.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export CC="clang -arch x86_64 -mios-version-min=13.2 -fobjc-weak -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -DUSE_GLES -DAAPI_SDL2 -DWAPI_SDL2"
export CXX="clang++ -arch x86_64 -mios-version-min=13.2 -fobjc-weak -std=c++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -DUSE_GLES -DAAPI_SDL2 -DWAPI_SDL2"
export IOSINCLUDE="/Users/christiankosman/Documents/simlib/include"
export IOSLIBS="/Users/christiankosman/Documents/simlib/lib"
export IOSINCLUDE="../simlib/include"
export IOSLIBS="../simlib/lib"

gmake -j4 TARGET_IOS=1

Expand Down
57 changes: 28 additions & 29 deletions src/pc/pc_main.m.orig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

#ifdef TARGET_WEB
#include <emscripten.h>
Expand Down Expand Up @@ -40,6 +39,8 @@
#include "controller/controller_touchscreen.h"
#include "fs/fs.h"

#include "src/ios/native_ui_controller.h"

#include "game/game_init.h"
#include "game/main.h"
#include "game/thread6.h"
Expand Down Expand Up @@ -113,31 +114,31 @@ static inline void patch_interpolations(void) {

void produce_one_frame(void) {
gfx_start_frame();
if(!paused_by_menu) {
const f32 master_mod = (f32)configMasterVolume / 127.0f;
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);

const f32 master_mod = (f32)configMasterVolume / 127.0f;
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);


game_loop_one_iteration();
thread6_rumble_loop(NULL);

int samples_left = audio_api->buffered();
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
//printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
s16 audio_buffer[SAMPLES_HIGH * 2 * 2];
for (int i = 0; i < 2; i++) {
/*if (audio_cnt-- == 0) {
audio_cnt = 2;

game_loop_one_iteration();
thread6_rumble_loop(NULL);

int samples_left = audio_api->buffered();
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
//printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
s16 audio_buffer[SAMPLES_HIGH * 2 * 2];
for (int i = 0; i < 2; i++) {
/*if (audio_cnt-- == 0) {
audio_cnt = 2;
}
u32 num_audio_samples = audio_cnt < 2 ? 528 : 544;*/
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
}
u32 num_audio_samples = audio_cnt < 2 ? 528 : 544;*/
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
}
//printf("Audio samples before submitting: %d\n", audio_api->buffered());

audio_api->play((u8 *)audio_buffer, 2 * num_audio_samples * 4);
//printf("Audio samples before submitting: %d\n", audio_api->buffered());

audio_api->play((u8 *)audio_buffer, 2 * num_audio_samples * 4);
}
gfx_end_frame();

gfx_start_frame();
Expand Down Expand Up @@ -268,7 +269,6 @@ void main_func(void) {
configWindow.settings_changed = true;
wm_api->reset_dimension_and_pos();

set_root_viewcontroller(gfxVc);
menu_button_pressed = &present_first_screen;

#if defined(AAPI_SDL1) || defined(AAPI_SDL2)
Expand Down Expand Up @@ -315,10 +315,9 @@ void main_func(void) {
}

int main(int argc, char *argv[]) {
parse_cli_opts(argc, argv);
//pthread_t thread;
//pthread_create(&thread, NULL, main_func, NULL);
//pthread_join(thread, NULL);
main_func();
@autoreleasepool {
parse_cli_opts(argc, argv);
main_func();
}
return 0;
}

0 comments on commit 6ba6f01

Please sign in to comment.