Merge branch 'master' into cmake

This commit is contained in:
HengiFettlich 2020-05-08 10:40:42 +02:00
commit 14063afbd3
3 changed files with 80 additions and 7 deletions

View File

@ -19,6 +19,8 @@ COMPARE ?= 1
NON_MATCHING ?= 0
# Build for the N64 (turn this off for ports)
TARGET_N64 ?= 0
# Build and optimize for Raspberry Pi(s)
TARGET_RPI ?= 0
# Compiler to use (ido or gcc)
COMPILER ?= ido
@ -79,7 +81,7 @@ ifeq ($(VERSION),sh)
GRUCODE_ASFLAGS := --defsym F3D_NEW=1
TARGET := sm64.sh
# TODO: GET RID OF THIS!!! We should mandate assets for Shindou like EU but we dont have the addresses extracted yet so we'll just pretend you have everything extracted for now.
NOEXTRACT := 1
NOEXTRACT := 1
else
$(error unknown version "$(VERSION)")
endif
@ -130,6 +132,9 @@ endif
ifeq ($(NON_MATCHING),1)
VERSION_CFLAGS := $(VERSION_CFLAGS) -DNON_MATCHING -DAVOID_UB
ifeq ($(TARGET_RPI),1) # Define RPi to change SDL2 title & GLES2 hints
VERSION_CFLAGS += -DTARGET_RPI
endif
VERSION_ASFLAGS := --defsym AVOID_UB=1
COMPARE := 0
endif
@ -185,10 +190,17 @@ EXE := $(BUILD_DIR)/$(TARGET).html
else
ifeq ($(WINDOWS_BUILD),1)
EXE := $(BUILD_DIR)/$(TARGET).exe
else #Linux builds here
ifeq ($(TARGET_RPI),1)
EXE := $(BUILD_DIR)/$(TARGET).arm
else
EXE := $(BUILD_DIR)/$(TARGET)
endif
endif
endif
ROM := $(BUILD_DIR)/$(TARGET).z64
ELF := $(BUILD_DIR)/$(TARGET).elf
LD_SCRIPT := sm64.ld
@ -242,8 +254,32 @@ endif
endif
# Use a default opt flag for gcc
ifeq ($(COMPILER),gcc)
OPT_FLAGS := -O2
ifeq ($(NON_MATCHING),1)
OPT_FLAGS := -O2
endif
ifeq ($(TARGET_RPI),1)
machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
# Raspberry Pi B+, Zero, etc
ifneq (,$(findstring armv6l,$(machine)))
OPT_FLAGS := -march=armv6zk+fp -mfpu=vfp -Ofast
endif
# Raspberry Pi 2 and 3
ifneq (,$(findstring armv7l,$(machine)))
model = $(shell sh -c 'cat /sys/firmware/devicetree/base/model 2>/dev/null || echo unknown')
ifneq (,$(findstring 3,$(model)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3
else
OPT_FLAGS := -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -O3
endif
endif
# RPi4 / ARM A64 NEEDS TESTING 32BIT.
ifneq (,$(findstring aarch64,$(machine)))
OPT_FLAGS := -march=armv8-a+crc -mtune=cortex-a53 -mfpu=neon-fp-armv8 -O3
endif
endif
# File dependencies and variables for specific files
@ -466,6 +502,7 @@ CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fn
else ifeq ($(TARGET_WEB),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -s USE_SDL=2
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2
# Linux / Other builds below
else
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) -Wall -Wextra -Wno-format-security $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) `$(CROSS)sdl2-config --cflags`
CFLAGS := $(OPT_FLAGS) $(INCLUDE_CFLAGS) $(VERSION_CFLAGS) $(GRUCODE_CFLAGS) -fno-strict-aliasing -fwrapv `$(CROSS)sdl2-config --cflags`
@ -479,9 +516,14 @@ else
ifeq ($(WINDOWS_BUILD),1)
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -Llib -lpthread -lglew32 `$(CROSS)sdl2-config --static-libs` -lm -lglu32 -lsetupapi -ldinput8 -luser32 -lgdi32 -limm32 -lole32 -loleaut32 -lshell32 -lwinmm -lversion -luuid -lopengl32 -no-pie -static
else
# Linux / Other builds below
ifeq ($(TARGET_RPI),1)
LDFLAGS := $(OPT_FLAGS) -lm -lGLESv2 `$(CROSS)sdl2-config --libs` -no-pie
else
LDFLAGS := $(BITS) -march=$(TARGET_ARCH) -lm -lGL `$(CROSS)sdl2-config --libs` -no-pie -lpthread
endif
endif
endif #Added for Pi ifeq
endif
@ -839,7 +881,6 @@ $(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(SOUND_OBJ_FILES) $(ULTRA_O_FILES) $(
endif
.PHONY: all clean distclean default diff test load libultra
.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:

View File

@ -4,6 +4,13 @@ OpenGL adaptation of [n64decomp/sm64](https://github.com/n64decomp/sm64).
Feel free to report bugs and contribute, but remember, there must be **no upload of any copyrighted asset**.
Run `./extract-assets.py --clean && make clean` or `make distclean` to remove ROM-originated content.
## Features
* Native rendering. You can now play SM64 without the need of an emulator.
* Variable aspect ratio and resolution. The game can now correctly render at basically any window size.
* Native xinput controller support. On Linux, DualShock 4 has been confirmed to work plug-and-play.
* True analog camera control is now available on our [testing branch](https://github.com/sm64pc/sm64pc/tree/testing).
## Building
### On Linux
@ -64,6 +71,19 @@ A full guide is to be written. You can use [mxe](https://mxe.cc/) and MinGW.
The game can be compiled for web browsers that support WebGL using [Emscripten](https://github.com/emscripten-core). To do so, install [emsdk](https://github.com/emscripten-core/emsdk) and run `make TARGET_WEB=1`.
## Optional enhancements
On the `./enhancements` folder, you'll find several .patch files, which can be applied in the following manner:
```
git apply fps.patch --ignore-whitespace --reject
```
If any rejections occur, you can search for them with `find | grep .rej`.
Try to solve rejections through [wiggle](https://github.com/neilbrown/wiggle).
```
wiggle rejection.rej --replace
```
### Current issues
* Support for the EU version is still experimental.

View File

@ -80,16 +80,28 @@ const SDL_Scancode scancode_rmapping_nonextended[][2] = {
static void gfx_sdl_init(void) {
SDL_Init(SDL_INIT_VIDEO);
SDL_ShowCursor(SDL_DISABLE); // Removes the cursor from view when upon the game's window.
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#ifdef TARGET_RPI
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); // These attributes allow for hardware acceleration on RPis.
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
#endif
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
#ifndef TARGET_RPI
wnd = SDL_CreateWindow("Super Mario 64 PC-Port", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
#else
wnd = SDL_CreateWindow("Super Mario 64 RPi (GLES2)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
DESIRED_SCREEN_WIDTH, DESIRED_SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
#endif
if (configFullscreen)
{
SDL_SetWindowFullscreen(wnd, SDL_WINDOW_FULLSCREEN_DESKTOP);
@ -204,4 +216,4 @@ struct GfxWindowManagerAPI gfx_sdl = {
gfx_sdl_swap_buffers_begin,
gfx_sdl_swap_buffers_end,
gfx_sdl_get_time
};
};