More x64 improvements
This commit is contained in:
parent
9e062adfa4
commit
3832edba89
6 changed files with 120 additions and 89 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -4,3 +4,6 @@
|
||||||
[submodule "extern/aurora"]
|
[submodule "extern/aurora"]
|
||||||
path = extern/aurora
|
path = extern/aurora
|
||||||
url = https://github.com/dbalatoni13/aurora.git
|
url = https://github.com/dbalatoni13/aurora.git
|
||||||
|
[submodule "extern/longjmp_win64"]
|
||||||
|
path = extern/longjmp_win64
|
||||||
|
url = https://github.com/GlinkieGamesInc/longjmp_win64.git
|
||||||
|
|
|
||||||
181
CMakeLists.txt
181
CMakeLists.txt
|
|
@ -1,8 +1,8 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
project(marioparty4 LANGUAGES C CXX OBJC)
|
project(marioparty4 LANGUAGES C CXX OBJC)
|
||||||
else ()
|
else ()
|
||||||
project(marioparty4 LANGUAGES C CXX)
|
project(marioparty4 LANGUAGES C CXX)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
@ -11,88 +11,88 @@ set(CMAKE_CXX_STANDARD 20)
|
||||||
set(VERSION 0)
|
set(VERSION 0)
|
||||||
|
|
||||||
# Set build type to Debug if not specified
|
# Set build type to Debug if not specified
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -fsanitize=address -fsanitize-address-use-after-scope")
|
|
||||||
set(CMAKE_PREFIX_PATH /usr)
|
|
||||||
set(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu)
|
|
||||||
set(CMAKE_LIBRARY_PATH "/usr/lib32" CACHE PATH "")
|
|
||||||
set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX 32)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if(APPLE)
|
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||||
add_compile_options(-Wno-declaration-after-statement)
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -fsanitize=address -fsanitize-address-use-after-scope")
|
||||||
|
set(CMAKE_PREFIX_PATH /usr)
|
||||||
|
set(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu)
|
||||||
|
set(CMAKE_LIBRARY_PATH "/usr/lib32" CACHE PATH "")
|
||||||
|
set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX 32)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
add_compile_options(-Wno-declaration-after-statement)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_compile_options(-fsanitize=address)
|
add_compile_options(-fsanitize=address)
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
add_compile_options(/bigobj)
|
add_compile_options(/bigobj)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_subdirectory(extern/aurora EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/aurora EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(extern/musyx EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/musyx EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(DOLPHIN_FILES
|
set(DOLPHIN_FILES
|
||||||
src/dolphin/mtx/mtx.c
|
src/dolphin/mtx/mtx.c
|
||||||
src/dolphin/mtx/mtx44.c
|
src/dolphin/mtx/mtx44.c
|
||||||
src/dolphin/mtx/vec.c
|
src/dolphin/mtx/vec.c
|
||||||
src/dolphin/os/OSAlloc.c
|
src/dolphin/os/OSAlloc.c
|
||||||
src/dolphin/os/OSArena.c
|
src/dolphin/os/OSArena.c
|
||||||
src/dolphin/os/OSStopwatch.c
|
src/dolphin/os/OSStopwatch.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GAME_FILES
|
set(GAME_FILES
|
||||||
src/game/armem.c
|
src/game/armem.c
|
||||||
src/game/card.c
|
src/game/card.c
|
||||||
src/game/ClusterExec.c
|
src/game/ClusterExec.c
|
||||||
src/game/data.c
|
src/game/data.c
|
||||||
src/game/decode.c
|
src/game/decode.c
|
||||||
src/game/dvd.c
|
src/game/dvd.c
|
||||||
src/game/EnvelopeExec.c
|
src/game/EnvelopeExec.c
|
||||||
src/game/esprite.c
|
src/game/esprite.c
|
||||||
src/game/fault.c
|
src/game/fault.c
|
||||||
src/game/flag.c
|
src/game/flag.c
|
||||||
src/game/font.c
|
src/game/font.c
|
||||||
src/game/frand.c
|
src/game/frand.c
|
||||||
src/game/gamework.c
|
src/game/gamework.c
|
||||||
src/game/hsfanim.c
|
src/game/hsfanim.c
|
||||||
src/game/hsfdraw.c
|
src/game/hsfdraw.c
|
||||||
src/game/hsfex.c
|
src/game/hsfex.c
|
||||||
src/game/hsfload.c
|
src/game/hsfload.c
|
||||||
src/game/hsfman.c
|
src/game/hsfman.c
|
||||||
src/game/hsfmotion.c
|
src/game/hsfmotion.c
|
||||||
src/game/init.c
|
src/game/init.c
|
||||||
src/game/main.c
|
src/game/main.c
|
||||||
src/game/malloc.c
|
src/game/malloc.c
|
||||||
src/game/memory.c
|
src/game/memory.c
|
||||||
src/game/objdll.c
|
src/game/objdll.c
|
||||||
src/game/objmain.c
|
src/game/objmain.c
|
||||||
src/game/ovllist.c
|
src/game/ovllist.c
|
||||||
src/game/ShapeExec.c
|
src/game/ShapeExec.c
|
||||||
src/game/sprman.c
|
src/game/sprman.c
|
||||||
src/game/sprput.c
|
src/game/sprput.c
|
||||||
src/game/pad.c
|
src/game/pad.c
|
||||||
src/game/perf.c
|
src/game/perf.c
|
||||||
src/game/printfunc.c
|
src/game/printfunc.c
|
||||||
src/game/process.c
|
src/game/process.c
|
||||||
src/game/window.c
|
src/game/window.c
|
||||||
src/game/wipe.c
|
src/game/wipe.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PORT_FILES
|
set(PORT_FILES
|
||||||
src/port/ar.c
|
src/port/ar.c
|
||||||
src/port/arq.c
|
src/port/arq.c
|
||||||
src/port/audio.c
|
src/port/audio.c
|
||||||
src/port/byteswap.cpp
|
src/port/byteswap.cpp
|
||||||
src/port/dvd.c
|
src/port/dvd.c
|
||||||
src/port/imgui.cpp
|
src/port/imgui.cpp
|
||||||
src/port/OS.c
|
src/port/OS.c
|
||||||
src/port/stubs.c
|
src/port/stubs.c
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group("Dolphin" FILES ${DOLPHIN_FILES})
|
source_group("Dolphin" FILES ${DOLPHIN_FILES})
|
||||||
|
|
@ -100,12 +100,12 @@ source_group("Game" FILES ${GAME_FILES})
|
||||||
source_group("Port" FILES ${PORT_FILES})
|
source_group("Port" FILES ${PORT_FILES})
|
||||||
|
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
foreach(file ${DOLPHIN_FILES})
|
foreach (file ${DOLPHIN_FILES})
|
||||||
set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=")
|
set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=")
|
||||||
endforeach()
|
endforeach ()
|
||||||
foreach(file ${GAME_FILES})
|
foreach (file ${GAME_FILES})
|
||||||
set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=")
|
set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline=")
|
||||||
endforeach()
|
endforeach ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -114,23 +114,38 @@ target_compile_definitions(dol PRIVATE TARGET_PC TARGET_DOL VERSION=${VERSION} M
|
||||||
target_include_directories(dol PRIVATE include build/GMPE01_00/include)
|
target_include_directories(dol PRIVATE include build/GMPE01_00/include)
|
||||||
target_link_libraries(dol PRIVATE aurora::core aurora::gx aurora::vi musyx)
|
target_link_libraries(dol PRIVATE aurora::core aurora::gx aurora::vi musyx)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_link_options(dol PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def")
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
enable_language(ASM_MASM)
|
||||||
|
target_sources(dol PRIVATE extern/longjmp_win64/longjmp_win64.asm)
|
||||||
|
set_source_files_properties(extern/longjmp_win64/longjmp_win64.asm PROPERTIES LANGUAGE ASM_MASM)
|
||||||
|
endif ()
|
||||||
|
target_link_options(dol PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def")
|
||||||
else ()
|
else ()
|
||||||
target_compile_options(dol PRIVATE "-fvisibility=default")
|
target_compile_options(dol PRIVATE "-fvisibility=default")
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
add_executable(marioparty4 src/port/portmain.c)
|
add_executable(marioparty4 src/port/portmain.c)
|
||||||
target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=${VERSION})
|
target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=${VERSION})
|
||||||
target_include_directories(marioparty4 PRIVATE include)
|
target_include_directories(marioparty4 PRIVATE include)
|
||||||
target_link_libraries(marioparty4 PRIVATE dol aurora::main)
|
target_link_libraries(marioparty4 PRIVATE dol aurora::main)
|
||||||
|
|
||||||
add_library(bootDll SHARED src/REL/bootDll/main.c src/REL/bootDll/language.c)
|
file(GLOB REL_DIRS RELATIVE ${CMAKE_SOURCE_DIR}/src/REL ${CMAKE_SOURCE_DIR}/src/REL/*)
|
||||||
target_compile_definitions(bootDll PRIVATE TARGET_PC VERSION=${VERSION})
|
|
||||||
target_include_directories(bootDll PRIVATE include build/GMPE01_00/include)
|
foreach (dir ${REL_DIRS})
|
||||||
if (MSVC)
|
if (IS_DIRECTORY ${CMAKE_SOURCE_DIR}/src/REL/${dir})
|
||||||
set_target_properties(bootDll PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup")
|
file(GLOB_RECURSE REL_FILES src/REL/${dir}/*.c)
|
||||||
else ()
|
|
||||||
endif()
|
if (REL_FILES)
|
||||||
set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
|
add_library(${dir} SHARED ${REL_FILES})
|
||||||
target_link_libraries(bootDll PRIVATE dol musyx)
|
target_compile_definitions(${dir} PRIVATE TARGET_PC VERSION=${VERSION})
|
||||||
|
target_include_directories(${dir} PRIVATE include build/GMPE01_00/include)
|
||||||
|
if (MSVC)
|
||||||
|
set_target_properties(${dir} PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup")
|
||||||
|
else ()
|
||||||
|
endif ()
|
||||||
|
target_link_libraries(${dir} PRIVATE dol musyx)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
add_dependencies(marioparty4 bootDll)
|
add_dependencies(marioparty4 bootDll)
|
||||||
|
|
|
||||||
1
extern/longjmp_win64
vendored
Submodule
1
extern/longjmp_win64
vendored
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit d04c5b7b486dbd2b80610fe2a5880e833933807f
|
||||||
|
|
@ -2,12 +2,20 @@
|
||||||
#define _GAME_JMP_H
|
#define _GAME_JMP_H
|
||||||
|
|
||||||
#ifdef TARGET_PC
|
#ifdef TARGET_PC
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef _M_X64
|
||||||
|
#include "../extern/longjmp_win64/longjmp_win64.h"
|
||||||
|
#define SETJMP setjmp_win64
|
||||||
|
#define LONGJMP longjmp_win64
|
||||||
|
#define JMPBUF JMP_BUF_WIN64
|
||||||
|
#else
|
||||||
|
#include <setjmp.h>
|
||||||
#define SETJMP setjmp
|
#define SETJMP setjmp
|
||||||
#define LONGJMP longjmp
|
#define LONGJMP longjmp
|
||||||
|
#define JMPBUF jmp_buf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef _JMP_BUF_DEFINED
|
#ifndef _JMP_BUF_DEFINED
|
||||||
#if defined(_M_IX86) || defined(__i386__)
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
|
|
@ -24,7 +32,7 @@ typedef struct __JUMP_BUFFER {
|
||||||
uint32_t UnwindFunc;
|
uint32_t UnwindFunc;
|
||||||
uint32_t UnwindData[6];
|
uint32_t UnwindData[6];
|
||||||
} _JUMP_BUFFER;
|
} _JUMP_BUFFER;
|
||||||
#elif defined(_M_X64) || defined(__x86_64__)
|
#elif defined(__x86_64__)
|
||||||
#ifndef SETJMP_FLOAT128
|
#ifndef SETJMP_FLOAT128
|
||||||
// TODO do we need to align this?
|
// TODO do we need to align this?
|
||||||
typedef struct _SETJMP_FLOAT128 {
|
typedef struct _SETJMP_FLOAT128 {
|
||||||
|
|
@ -136,9 +144,12 @@ typedef struct _JUMP_BUFFER {
|
||||||
#if defined(_M_IX86) || defined(__i386__)
|
#if defined(_M_IX86) || defined(__i386__)
|
||||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Eip = (uintptr_t)func
|
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Eip = (uintptr_t)func
|
||||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Esp = (uintptr_t)sp
|
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Esp = (uintptr_t)sp
|
||||||
#elif defined(_M_X64) || defined(__x86_64__)
|
#elif defined(__x86_64__)
|
||||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Rip = (uintptr_t)func
|
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Rip = (uintptr_t)func
|
||||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Rsp = (uintptr_t)sp
|
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Rsp = (uintptr_t)sp
|
||||||
|
#elif defined(_M_X64)
|
||||||
|
#define SETJMP_SET_IP(jump, func) (jump)->rip_getjmp = (uintptr_t)func
|
||||||
|
#define SETJMP_SET_SP(jump, sp) (jump)->rsp_getjmp = (uintptr_t)sp
|
||||||
#elif defined(_M_ARM) || defined(__arm__)
|
#elif defined(_M_ARM) || defined(__arm__)
|
||||||
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
|
#define SETJMP_SET_IP(jump, func) ((_JUMP_BUFFER *)((jump)))->Pc = (uintptr_t)func
|
||||||
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
|
#define SETJMP_SET_SP(jump, sp) ((_JUMP_BUFFER *)((jump)))->Sp = (uintptr_t)sp
|
||||||
|
|
@ -166,6 +177,7 @@ typedef struct jmp_buf {
|
||||||
s32 gcsetjmp(jmp_buf *jump);
|
s32 gcsetjmp(jmp_buf *jump);
|
||||||
s32 gclongjmp(jmp_buf *jump, s32 status);
|
s32 gclongjmp(jmp_buf *jump, s32 status);
|
||||||
|
|
||||||
|
#define JMPBUF jmp_buf
|
||||||
#define SETJMP(jump) gcsetjmp(&(jump))
|
#define SETJMP(jump) gcsetjmp(&(jump))
|
||||||
#define LONGJMP(jump, status) gclongjmp(&(jump), (status))
|
#define LONGJMP(jump, status) gclongjmp(&(jump), (status))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ typedef struct process {
|
||||||
u16 prio;
|
u16 prio;
|
||||||
s32 sleep_time;
|
s32 sleep_time;
|
||||||
uintptr_t base_sp;
|
uintptr_t base_sp;
|
||||||
jmp_buf jump;
|
JMPBUF jump;
|
||||||
void (*dtor)(void);
|
void (*dtor)(void);
|
||||||
void *user_data;
|
void *user_data;
|
||||||
} Process;
|
} Process;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#define EXEC_CHILDWATCH 2
|
#define EXEC_CHILDWATCH 2
|
||||||
#define EXEC_KILLED 3
|
#define EXEC_KILLED 3
|
||||||
|
|
||||||
static jmp_buf processjmpbuf;
|
static JMPBUF processjmpbuf;
|
||||||
static Process *processtop;
|
static Process *processtop;
|
||||||
static Process *processcur;
|
static Process *processcur;
|
||||||
static u16 processcnt;
|
static u16 processcnt;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue