Closed IlFalco1992 closed 2 years ago
Merged! I guess it doesn't show up here since I used the desktop app to do it, so I'll close this PR.
I'm so glad this was merged into your repo! It was my first real-world C development experience (even though it was mostly preprocessor vars😅). Any chance I can get a tiny mention among the contributors? Also, there are some things we should mention in the wiki for building on MacOS. The make which comes with the OS won't work, it's an old version that struggles with split makefiles, so people need to install gmake (brew install make) and use that. Also, by default on MacOS's PATH, gcc, cpp, g++ and so on are all actually clang, which won't understand the parameters of the makefile. People should install gcc, g++ and so on from homebrew and then put those in the PATH, or make an alias to gcc-11, g++-11, or whatever version they install. Thank you!
Ahhh I didn't see your response, I should be checking GitHub more often.
I mentioned you in the changelog but if you want I can put your name in the credits section of the repo as well. As for the building section of the wiki, I don't think I'd be able to write a building guide myself but if you can I'd gladly add it in.
But yeah, I was gonna say that I just released the update with your changes merged in. I did make some minor changes, but I don't think it would affect if the game compiles on Mac or not.
Thanks for this. I've got it built for intel MacOS. As mentioned I needed to use homebrew gcc rather than clang. Do do this I took /Library/Developer/CommandLineTools/usr/bin
out of my PATH. I also needed to patch /tools/aiff_extract_codebook.c
and add:
#ifdef __APPLE__
// even with -std=gnu99 vsnprintf seems to not be defined in stdio.h, why?
extern int vsnprintf(char * __restrict, size_t, const char * __restrict, va_list);
#endif
I'm assuming the MacOS version doesn't have a launcher like windows.
I've also noticed the music is crackly, especially in the intro by the castle. Not so noticeable with sound effects. Anyone else notice this?
@palmerj the music does have issues, it's a problem that I have fixed, it's something to do with the function sync_framerate_with_timer in gfx_sdl2.c. I still haven't cleaned up the code so I didn't create a PR. I will in the future
Thank you @IlFalco1992. Are you able to share that uncleaned code for gfx_sdl2.c so I can quickly test? Doesn't need to be PR ready.
@palmerj Replace the function sync_framerate_with_timer with this:
static const int frame_time = 1000 / 60;
static void sync_framerate_with_timer(void) {
static Uint32 last_time = 0;
// get base timestamp on the first frame (might be different from 0)
if (last_time == 0) last_time = SDL_GetTicks();
const int elapsed = SDL_GetTicks() - last_time;
if (elapsed < frame_time)
SDL_Delay(frame_time - elapsed);
last_time += frame_time;
}
Thanks - that worked!
Awesome! I have noticed that with this code if the window goes out of focus the game runs crazy fast, you can hear it from the music playing in the background. Does this happen to you as well? Also, I took this function (sync_framerate_with_timer) from sm64ex, the credit is not mine.
Seems ok to me, and doesn't run fast - I'm on an intel mac. But unlike some of the other ports the only way to loose focus on the window is to wipe to another desktop space.
@IlFalco1992 Do you have a fork (or patches) for a working copy of sm64plus on macOS (Apple Silicon) ?
I'm able to compile the code and run it, but I have no music or sound effects. I also tried your sync_framerate_with_timer function from above but it didn't help.
Checked the code and there doesn't seem any obvious issues, so I'm merging this with my development branch. Thank you so much for this!