mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
* First pass * Fix n64crc and add submodules properly * Fix other versions * Match func_8005B818 for v80 code. * Formatting * Fix build for JPN in last commit. Still broken in post v77 roms though. * Fix builds for other versions. * Match load_menu_text for other versions. * Fix progress script * update m2c * Modify asset tools to remove the LD script code. * Fix asm file macro inclue * Get a working splat version for us_1.0 to build from the assets tool. * update asm differ * Update tools again * Fix the makefile to only compile assets when requested. This will build all versions successfully, and compile assets for us_1.0 when requested. * First round of suggestions * Small cleanup * Fix the gcc_generate.py path. * Make entrypointThreadStack * Small addition to the last commit * "Fix" score script. Still need to fix the score values themselves, but at least it runs and is kind of close. * Much closer matching score script * Fix the splat version due to a breaking change in 0.33.0 for this repo for now. * Fix the main function name * Add gitignore entries * Fix the padding problem to be handled by objcopy instead of a binary pad from splat. * Update the README and change dependencies to setup. * Have a hasm header that can be tweaked. * Still calculate the checksum on no_verify builds or they won't work. * Add support for boot_custom.bin * Fix custom boot ld code. * Fix score script * Fix gcc building. * Update m2c * Fix warning, stop ignoring mod assets, and add some handy make rules. * Uggh, serves me right for not testing. * First stab at modifiable entrypoint. * Fix typo, and small README change * Stop n64crd from defaulting to returning 6105, so we can properly fail if the CIC checksum fails. Also, fix the * fix a whole heaping spaghetti pile of warnings * stack sizes and header depdendancies * more warns * fix bug oops * t * Update Makefile Create extract_boot.py * Update extract_custom_boot.py * somehow this blew up again in the merge * Update Makefile * fix these * Delete extract_boot.py * simplification * Sage is stoopid * Update controller.c * permissions * Update get-binutils.sh --------- Co-authored-by: Ryan Myers <ryan.p.myers@gmail.com>
79 lines
2.0 KiB
C
79 lines
2.0 KiB
C
#ifndef _MACROS_H_
|
|
#define _MACROS_H_
|
|
|
|
#include <PRinternal/macros.h>
|
|
|
|
#ifndef __sgi
|
|
#define GLOBAL_ASM(...)
|
|
#endif
|
|
|
|
#if !defined(__sgi) && (!defined(NON_MATCHING) || !defined(AVOID_UB))
|
|
// asm-process isn't supported outside of IDO, and undefined behavior causes
|
|
// crashes.
|
|
// #error Matching build is only possible on IDO; please build with NON_MATCHING=1.
|
|
#endif
|
|
|
|
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
|
|
|
|
#define GLUE(a, b) a ## b
|
|
#define GLUE2(a, b) GLUE(a, b)
|
|
|
|
// Avoid undefined behaviour for non-returning functions
|
|
#ifdef __GNUC__
|
|
#define NORETURN __attribute__((noreturn))
|
|
#else
|
|
#define NORETURN
|
|
#endif
|
|
|
|
// Static assertions
|
|
#ifdef __GNUC__
|
|
#define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
|
|
#else
|
|
#define STATIC_ASSERT(cond, msg) typedef char GLUE2(static_assertion_failed, __LINE__)[(cond) ? 1 : -1]
|
|
#endif
|
|
|
|
// Align to 8-byte boundary for DMA requirements
|
|
#ifdef __GNUC__
|
|
#define ALIGNED8 __attribute__((aligned(8)))
|
|
#else
|
|
#define ALIGNED8
|
|
#endif
|
|
|
|
// Align to 16-byte boundary for audio lib requirements
|
|
#ifdef __GNUC__
|
|
#define ALIGNED16 __attribute__((aligned(16)))
|
|
#else
|
|
#define ALIGNED16
|
|
#endif
|
|
|
|
// Use built-in pseudocode where possible in NON_MATCHING builds
|
|
#ifdef __GNUC__
|
|
#define abs(x) __builtin_abs(x)
|
|
#define fabsf(x) __builtin_fabsf(x)
|
|
#define sqrtf(f) __builtin_sqrtf(f)
|
|
#undef ABS
|
|
#undef ABSF
|
|
#define ABS(x) __builtin_abs(x)
|
|
#define ABSF(x) __builtin_fabsf(x)
|
|
#else
|
|
#define inline
|
|
#define ABSF(x) (x < 0.f ? -x : x)
|
|
#endif
|
|
|
|
// convert a virtual address to physical.
|
|
#define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr) & 0x1FFFFFFF)
|
|
|
|
// convert a physical address to virtual.
|
|
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) | 0x80000000)
|
|
|
|
// another way of converting virtual to physical
|
|
#define VIRTUAL_TO_PHYSICAL2(addr) ((u8 *)(addr) - 0x80000000U)
|
|
|
|
// Used to suppress warnings in the ./generate_ctx.sh script.
|
|
#define INCONSISTENT
|
|
|
|
// Used to make a u32 colour value look clearer. Transforms 0xFF0000FF to 255, 0, 0, 255
|
|
#define COLOUR_RGBA32(r, g, b, a) (((r << 24) | (g << 16) | (b << 8) | a))
|
|
|
|
#endif
|