diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-02 17:29:19 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2023-02-03 13:27:06 -0400 |
commit | f2eabdb6257c09cf2890dac5e9737912728542af (patch) | |
tree | 3b46f6787185d65605651a0f48776dc9779ce648 /include | |
parent | eef1dd840b7cecac28c2e6b0574707b90a37d4e7 (diff) |
global: Add rest of Dolphin SDK proper, add MSL, and MetroTRK
Finally, it links properly.
Diffstat (limited to 'include')
-rw-r--r-- | include/MetroTRK/dolphin_trk.h | 8 | ||||
-rw-r--r-- | include/MetroTRK/intrinsics.h | 12 | ||||
-rw-r--r-- | include/MetroTRK/mem_TRK.h | 10 | ||||
-rw-r--r-- | include/Runtime/platform.h | 159 | ||||
-rw-r--r-- | include/global_types.h | 92 | ||||
-rw-r--r-- | include/libc/stdbool.h | 16 | ||||
-rw-r--r-- | include/placeholder.h | 9 |
7 files changed, 306 insertions, 0 deletions
diff --git a/include/MetroTRK/dolphin_trk.h b/include/MetroTRK/dolphin_trk.h new file mode 100644 index 0000000..9cbc683 --- /dev/null +++ b/include/MetroTRK/dolphin_trk.h @@ -0,0 +1,8 @@ +#ifndef METROTRK_DOLPHIN_TRK_H +#define METROTRK_DOLPHIN_TRK_H + +#include <Runtime/platform.h> + +void EnableMetroTRKInterrupts(void); + +#endif diff --git a/include/MetroTRK/intrinsics.h b/include/MetroTRK/intrinsics.h new file mode 100644 index 0000000..d9b067f --- /dev/null +++ b/include/MetroTRK/intrinsics.h @@ -0,0 +1,12 @@ +#ifndef METROTRK_INTRINSICS_H +#define METROTRK_INTRINSICS_H + +void __sync(void); +void __isync(void); +int __cntlzw(unsigned int); +float sqrtf__Ff(float); +float __fnmsubs(float, float, float); +double __fabs(double); +float __fabsf(float); + +#endif diff --git a/include/MetroTRK/mem_TRK.h b/include/MetroTRK/mem_TRK.h new file mode 100644 index 0000000..bd1946a --- /dev/null +++ b/include/MetroTRK/mem_TRK.h @@ -0,0 +1,10 @@ +#ifndef __MEM_TRK_H__ +#define __MEM_TRK_H__ + +#include <Runtime/platform.h> + +SECTION_INIT void* TRK_memcpy(void* dst, const void* src, unsigned long n); + +SECTION_INIT void* TRK_memset(void* dst, int val, unsigned long n); + +#endif diff --git a/include/Runtime/platform.h b/include/Runtime/platform.h new file mode 100644 index 0000000..ef6538b --- /dev/null +++ b/include/Runtime/platform.h @@ -0,0 +1,159 @@ +#ifndef INCLUDE_RUNTIME_PLATFORM_H +#define INCLUDE_RUNTIME_PLATFORM_H + +#if defined(__MWERKS__) || defined(__GNUC__) +#define MWERKS_GNUC +#endif + +#include <stdbool.h> +#include <stddef.h> + +/// A signed 8-bit integer +typedef signed char s8; + +/// A signed 16-bit integer +typedef signed short s16; + +/// A signed 32-bit integer +typedef signed long s32; + +/// A signed 64-bit integer +typedef signed long long s64; + +/// An unsigned 8-bit integer +typedef unsigned char u8; + +/// An unsigned 16-bit integer +typedef unsigned short u16; + +/// An unsigned 32-bit integer +typedef unsigned long u32; + +/// An unsigned 64-bit integer +typedef unsigned long long u64; + +/// An unsigned integer of platform-dependent size +typedef unsigned int uint; + +/// A volatile, unsigned 8-bit integer +typedef volatile u8 vu8; + +/// A volatile, unsigned 16-bit integer +typedef volatile u16 vu16; + +/// A volatile, unsigned 32-bit integer +typedef volatile u32 vu32; + +/// A volatile, unsigned 64-bit integer +typedef volatile u64 vu64; + +/// A volatile, signed 8-bit integer +typedef volatile s8 vs8; + +/// A volatile, signed 16-bit integer +typedef volatile s16 vs16; + +/// A volatile, signed 32-bit integer +typedef volatile s32 vs32; + +/// A volatile, signed 64-bit integer +typedef volatile s64 vs64; + +/// A 32-bit floating-point number +typedef float f32; + +/// A 64-bit floating-point number +typedef double f64; + +/// A volatile 32-bit floating-point number +typedef volatile f32 vf32; + +/// A volatile 64-bit floating-point number +typedef volatile f64 vf64; + +/// The underlying type of an @c enum, used as a placeholder +typedef int enum_t; + +/// A pointer to an unknown type +typedef void* unk_t; + +/// A pointer to an unspecified type, used for polymorphic data +typedef void* any_t; + +/// A label in a jump table +typedef void (*jmp_t)(void); + +/// A jump table +typedef jmp_t jtbl_t[]; + +/// A @c void callback with no arguments. +typedef void (*Event)(void); + +#if defined(__MWERKS__) && defined(__PPCGEKKO__) +#define MWERKS_GEKKO +#endif + +#ifndef ATTRIBUTE_ALIGN +#if defined(__MWERKS__) || defined(__GNUC__) +#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num))) +#elif defined(_MSC_VER) +#define ATTRIBUTE_ALIGN(num) +#else +#error unknown compiler +#endif +#endif + +#ifndef SECTION_INIT +#if defined(__MWERKS__) && !defined(M2CTX) +#define SECTION_INIT __declspec(section ".init") +#else +#define SECTION_INIT +#endif +#endif + +#ifndef ATTRIBUTE_NORETURN +#if defined(__clang__) || defined(__GNUC__) +#define ATTRIBUTE_NORETURN __attribute__((noreturn)) +#else +#define ATTRIBUTE_NORETURN +#endif +#endif + +#ifdef PERMUTER +#define AT_ADDRESS(x) = FIXEDADDR(x) +#elif defined(__MWERKS__) && !defined(M2CTX) +#define AT_ADDRESS(x) : (x) +#else +#define AT_ADDRESS(x) +#endif + +#ifndef UNK_SIZE_ARRAY +#if defined(__MWERKS__) && !defined(M2CTX) +#define UNK_SIZE_ARRAY [] +#else +#define UNK_SIZE_ARRAY [0] +#endif +#endif + +#ifdef __PPCGEKKO__ +#define qr0 0 +#define qr1 1 +#define qr2 2 +#define qr3 3 +#define qr4 4 +#define qr5 5 +#define qr6 6 +#define qr7 7 +#endif + +#define U8_MAX 0xFF +#define U16_MAX 0xFFFF +#define U32_MAX 0xFFFFFFFF +#define F32_MAX 3.4028235E38 + +#define FLAGS_ZERO 0 +#define FLAGS_ANY(value, flag) ((value) & (flag)) +#define FLAGS_NONE(value, flag) (!((value) & (flag))) +#define FLAGS_ALL(value, flag) (((value) & (flag)) == (flag)) + +#endif diff --git a/include/global_types.h b/include/global_types.h new file mode 100644 index 0000000..77e1053 --- /dev/null +++ b/include/global_types.h @@ -0,0 +1,92 @@ +// This file was taken from the Metroid Prime decompilation project. +// https://github.com/PrimeDecomp/prime/blob/main/include/dolphin/types.h +#ifndef _DOLPHIN_TYPES +#define _DOLPHIN_TYPES + +#ifdef TARGET_PC +#include <stdint.h> +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +#else +typedef signed char s8; +typedef signed short int s16; +typedef signed long s32; +typedef signed long long int s64; +typedef unsigned char u8; +typedef unsigned short int u16; +typedef unsigned long u32; +typedef unsigned long long int u64; +#endif + +typedef volatile u8 vu8; +typedef volatile u16 vu16; +typedef volatile u32 vu32; +typedef volatile u64 vu64; + +typedef volatile s8 vs8; +typedef volatile s16 vs16; +typedef volatile s32 vs32; +typedef volatile s64 vs64; + +typedef float f32; +typedef double f64; + +typedef volatile f32 vf32; +typedef volatile f64 vf64; + +#if defined(TARGET_PC) && !defined(_WIN32) +#include <stdbool.h> +typedef bool BOOL; +#ifndef FALSE +#define FALSE false +#endif +#ifndef TRUE +#define TRUE true +#endif +#else +typedef int BOOL; +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif +#endif + +#ifdef TARGET_PC +#include <stddef.h> +#else +#ifndef NULL +#define NULL 0 +#endif +#endif +#if !defined(__cplusplus) || __cplusplus < 201103L +#ifndef nullptr +#define nullptr NULL +#endif + +#if defined(__MWERKS__) +#ifndef override +#define override +#endif +#endif + +#endif + +#ifndef ATTRIBUTE_ALIGN +#if defined(__MWERKS__) || defined(__GNUC__) +#define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num))) +#elif defined(_MSC_VER) +#define ATTRIBUTE_ALIGN(num) +#else +#error unknown compiler +#endif +#endif + +#endif // _DOLPHIN_TYPES diff --git a/include/libc/stdbool.h b/include/libc/stdbool.h new file mode 100644 index 0000000..1c12915 --- /dev/null +++ b/include/libc/stdbool.h @@ -0,0 +1,16 @@ +/// @file +/// @todo Assumes @c __PPCGEKKO__. +#ifndef STDBOOL_H +#define STDBOOL_H + +/// A signed integer used to contain boolean values +/// @todo Maybe some versions of MetroWerks support @c _Bool? +typedef int bool; + +/// #bool true +#define true 1 + +/// #bool false +#define false 0 + +#endif diff --git a/include/placeholder.h b/include/placeholder.h new file mode 100644 index 0000000..fca55d6 --- /dev/null +++ b/include/placeholder.h @@ -0,0 +1,9 @@ +#ifndef PLACEHOLDER_H +#define PLACEHOLDER_H + +#include <os.h> + +#define NOT_IMPLEMENTED \ + OSPanic(__FILE__, __LINE__, "%s is not implemented!", __func__) + +#endif |