Fixed all remaining compilation issues

This commit is contained in:
KiritoDv 2024-05-20 22:29:07 -06:00 committed by Sonic Dreamcaster
parent 4c37fa4369
commit 69cfe9b2c4
65 changed files with 579 additions and 732 deletions

View File

@ -34,7 +34,7 @@ set(VCPKG_TARGET_TRIPLET x64-mingw-static)
endif() endif()
vcpkg_bootstrap() vcpkg_bootstrap()
vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libzip libpng getopt dirent libusb pthread glew glfw3) vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libzip libpng getopt dirent libusb pthread glew glfw3 nlohmann-json tinyxml2 spdlog)
endif() endif()
if (MSVC) if (MSVC)
@ -111,7 +111,7 @@ file(GLOB_RECURSE ALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
# Exclude specific files from the ALL_FILES list # Exclude specific files from the ALL_FILES list
list(FILTER ALL_FILES EXCLUDE REGEX ".*.inc.c") list(FILTER ALL_FILES EXCLUDE REGEX ".*.inc.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_A4290_colheaders.c") list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_colheaders.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_edata_info.c") list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_edata_info.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_rcp_setup.c") list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_rcp_setup.c")
list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_load_inits.c") list(FILTER ALL_FILES EXCLUDE REGEX "src/engine/fox_load_inits.c")

View File

@ -34,7 +34,7 @@
G_TX_RENDERTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \ G_TX_RENDERTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, dw, dh, \ gDPSetTileSize(pkt, G_TX_RENDERTILE, dw, dh, \
((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((width)-1) << G_TEXTURE_IMAGE_FRAC, \
((height)-1) << G_TEXTURE_IMAGE_FRAC) \ ((height)-1) << G_TEXTURE_IMAGE_FRAC); \
} }
#define gsDPSetupTile(fmt, siz, width, height, dw, dh, \ #define gsDPSetupTile(fmt, siz, width, height, dw, dh, \
@ -83,10 +83,6 @@ typedef enum WipeMode {
WIPE_VERTICAL, WIPE_VERTICAL,
} WipeMode; } WipeMode;
typedef struct {
u8 r, g, b;
} Color_RGB8; // size = 0x3
typedef struct Color_RGBA32 { typedef struct Color_RGBA32 {
u8 r, g, b, a; u8 r, g, b, a;
} Color_RGBA32; // size = 0x4 } Color_RGBA32; // size = 0x4

View File

@ -23,6 +23,7 @@ typedef enum OverlayCalls {
/* 110 */ OVLCALL_UNKMAP_DRAW, /* 110 */ OVLCALL_UNKMAP_DRAW,
} OverlayCalls; } OverlayCalls;
#include "sf64context.h"
#include "sf64audio_external.h" #include "sf64audio_external.h"
#include "functions.h" #include "functions.h"
#include "variables.h" #include "variables.h"

View File

@ -14,10 +14,10 @@
/** /**
* Quick Boot: * Quick Boot:
* Define this variable to a game state to boot into that * Define this variable to a game state to boot into that
* state. Two presets (map and main menu) are provided. * state. Two presets (map and main menu) are provided.
* For the full list of game states, see sf64thread.h. * For the full list of game states, see sf64thread.h.
*/ */
// #define MODS_BOOT_STATE 3 // main menu #define MODS_BOOT_STATE 3 // main menu
// #define MODS_BOOT_STATE 4 // map // #define MODS_BOOT_STATE 4 // map
/** /**
@ -25,8 +25,8 @@
* Use the D-Pad to select a level. Press L to start in * Use the D-Pad to select a level. Press L to start in
* an advanced level phase (warp zone or Andross fight). * an advanced level phase (warp zone or Andross fight).
* Useful for debugging and speedrunning training. * Useful for debugging and speedrunning training.
*/ */
#define MODS_LEVEL_SELECT 0 #define MODS_LEVEL_SELECT 1
/** /**
* Sound Effects Jukebox: * Sound Effects Jukebox:
@ -45,13 +45,13 @@
/** /**
* FPS Counter: * FPS Counter:
* Hold Z + R and press L to toggle FPS Display * Press L to toggle FPS Display
*/ */
#define MODS_FPS_COUNTER 0 #define MODS_FPS_COUNTER 1
/** /**
* RAM modifier: * RAM modifier:
* Hold Z + R and press C> to cycle modes * Press C> while paused to cycle modes
* *
* Cheats: * Cheats:
* Use D-Pad up and down to select a cheat * Use D-Pad up and down to select a cheat

View File

@ -93,8 +93,8 @@ typedef enum {
} SampleMedium; } SampleMedium;
typedef enum { typedef enum {
/* 0 */ CODEC_ADPCM, // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte /* 0 */ CODEC_ADPCM, // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte
/* 1 */ CODEC_S8, // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) /* 1 */ CODEC_S8, // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes)
/* 2 */ CODEC_S16_INMEMORY, /* 2 */ CODEC_S16_INMEMORY,
/* 3 */ CODEC_SMALL_ADPCM, // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte /* 3 */ CODEC_SMALL_ADPCM, // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte
/* 4 */ CODEC_REVERB, /* 4 */ CODEC_REVERB,
@ -229,8 +229,8 @@ typedef struct {
} AdpcmBook; // size >= 8, 0x8 aligned } AdpcmBook; // size >= 8, 0x8 aligned
typedef struct { typedef struct {
/* 0x00 */ u32 codec : 4; // The state of compression or decompression /* 0x00 */ u32 codec : 4; // The state of compression or decompression
/* 0x00 */ u32 medium : 2; // Medium where sample is currently stored /* 0x00 */ u32 medium : 2; // Medium where sample is currently stored
/* 0x00 */ u32 unk_bit26 : 1; /* 0x00 */ u32 unk_bit26 : 1;
/* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers) /* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers)
/* 0x01 */ u32 size : 24; // Size of the sample /* 0x01 */ u32 size : 24; // Size of the sample
@ -261,7 +261,7 @@ typedef struct {
typedef struct { typedef struct {
/* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable /* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
/* 0x01 */ u8 pan; /* 0x01 */ u8 pan;
/* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers) /* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers)
/* 0x04 */ TunedSample tunedSample; /* 0x04 */ TunedSample tunedSample;
/* 0x0C */ EnvelopePoint* envelope; /* 0x0C */ EnvelopePoint* envelope;
} Drum; // size = 0x10 } Drum; // size = 0x10
@ -318,7 +318,7 @@ typedef struct {
} SynthesisReverb; // size = 0x1D4 } SynthesisReverb; // size = 0x1D4
typedef struct { typedef struct {
/* 0x00 */ u8* pc; // program counter /* 0x00 */ u8* pc; // program counter
/* 0x04 */ u8* stack[4]; /* 0x04 */ u8* stack[4];
/* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations /* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations
/* 0x18 */ u8 depth; /* 0x18 */ u8 depth;
@ -485,7 +485,7 @@ typedef struct SequenceLayer {
/* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound /* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
/* 0x00 */ u8 bit3 : 1; // "loaded"? /* 0x00 */ u8 bit3 : 1; // "loaded"?
/* 0x00 */ u8 ignoreDrumPan : 1; /* 0x00 */ u8 ignoreDrumPan : 1;
/* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"?
/* 0x00 */ u8 notePropertiesNeedInit : 1; /* 0x00 */ u8 notePropertiesNeedInit : 1;
/* 0x01 */ Stereo stereo; /* 0x01 */ Stereo stereo;
/* 0x02 */ u8 instOrWave; /* 0x02 */ u8 instOrWave;
@ -643,15 +643,15 @@ typedef struct {
/* 0x10 */ u32 persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently /* 0x10 */ u32 persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently
/* 0x14 */ u32 persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently /* 0x14 */ u32 persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently
/* 0x18 */ u32 /* 0x18 */ u32
persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently
/* 0x1C */ u32 temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily /* 0x1C */ u32 temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily
/* 0x20 */ u32 temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily /* 0x20 */ u32 temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily
/* 0x24 */ u32 temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily /* 0x24 */ u32 temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily
/* 0x28 */ s32 /* 0x28 */ s32
persistentSampleCacheSize; // size of cache in the audio misc pool to store individual samples persistently persistentSampleCacheSize; // size of cache in the audio misc pool to store individual samples persistently
/* 0x2C */ s32 /* 0x2C */ s32
temporarySampleCacheSize; // size of cache in the audio misc pool to store individual samples temporarily temporarySampleCacheSize; // size of cache in the audio misc pool to store individual samples temporarily
} AudioSpec; // size = 0x30 } AudioSpec; // size = 0x30
/** /**
* The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the * The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the
@ -703,7 +703,7 @@ typedef struct {
/* 0x02 */ s8 sampleBankId; /* 0x02 */ s8 sampleBankId;
/* 0x03 */ char unk_03[0x5]; /* 0x03 */ char unk_03[0x5];
/* 0x08 */ u8* allocatedAddr; /* 0x08 */ u8* allocatedAddr;
/* 0x0C */ uintptr_t sampleAddr; /* 0x0C */ void* sampleAddr;
/* 0x10 */ u32 size; /* 0x10 */ u32 size;
} SampleCacheEntry; // size = 0x14 } SampleCacheEntry; // size = 0x14
@ -844,7 +844,7 @@ typedef struct {
typedef struct SampleDma { typedef struct SampleDma {
/* 0x00 */ u8* ramAddr; /* 0x00 */ u8* ramAddr;
/* 0x04 */ uintptr_t devAddr; /* 0x04 */ u32 devAddr;
/* 0x08 */ u16 sizeUnused; /* 0x08 */ u16 sizeUnused;
/* 0x0A */ u16 size; /* 0x0A */ u16 size;
/* 0x0C */ u8 unused; /* 0x0C */ u8 unused;
@ -868,14 +868,14 @@ typedef struct {
typedef struct { typedef struct {
/* 0x0 */ s16 unk_00; // set to 0x1C00, unused /* 0x0 */ s16 unk_00; // set to 0x1C00, unused
/* 0x2 */ s16 seqTicksPerBeat; /* 0x2 */ s16 seqTicksPerBeat;
} TempoData; // size = 0x4 } TempoData; // size = 0x4
typedef struct { typedef struct {
/* 0x00 */ u32 heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` /* 0x00 */ u32 heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap`
// (ideally about the same size) // (ideally about the same size)
/* 0x04 */ u32 initPoolSize; // The entire audio heap is split into two pools. /* 0x04 */ u32 initPoolSize; // The entire audio heap is split into two pools.
/* 0x08 */ u32 permanentPoolSize; /* 0x08 */ u32 permanentPoolSize;
} AudioHeapInitSizes; // size = 0xC } AudioHeapInitSizes; // size = 0xC
typedef struct { typedef struct {
AudioAllocPool pool; AudioAllocPool pool;
@ -1040,8 +1040,8 @@ uintptr_t AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id);
s32 AudioHeap_ResetStep(void); s32 AudioHeap_ResetStep(void);
void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id);
u8* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size); u8* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size);
void* AudioHeap_AllocTemporarySampleCache(s32 size, s32 fontId, uintptr_t sampleAddr, s8 medium); void* AudioHeap_AllocTemporarySampleCache(s32 size, s32 fontId, s32 sampleAddr, s8 medium);
void* AudioHeap_AllocPersistentSampleCache(s32 size, s32 fontId, uintptr_t sampleAddr, s8 medium); void* AudioHeap_AllocPersistentSampleCache(s32 size, s32 fontId, s32 sampleAddr, s8 medium);
// audio_load // audio_load
void AudioLoad_DecreaseSampleDmaTtls(void); void AudioLoad_DecreaseSampleDmaTtls(void);

View File

@ -724,7 +724,7 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, u32 devAddr, void
handle = osCartRomInit(); handle = osCartRomInit();
break; break;
case MEDIUM_DISK_DRIVE: case MEDIUM_DISK_DRIVE:
handle = osDriveRomInit(); // handle = osDriveRomInit();
break; break;
default: default:
return 0; return 0;

View File

@ -44,7 +44,7 @@ s32 Message_GetCharCount(u16* msgPtr) {
s32 count = 0; s32 count = 0;
u16* msgChar = LOAD_ASSET(msgPtr); u16* msgChar = LOAD_ASSET(msgPtr);
if (CVarGetInteger("gLevelSelector", 0) && gCurrentPlanet == 6) { if (CVarGetInteger("gLevelSelector", 0) && gCurrentLevel == 6) {
return 0; return 0;
} }

View File

@ -8,7 +8,7 @@ Vtx D_Vtx_800DAC80[] = {
Gfx D_Gfx_800DACA0[] = { Gfx D_Gfx_800DACA0[] = {
// unused // unused
gsSPVertex(D_Vtx_800DAC80, 2, 0), gsSPVertex(D_Vtx_800DAC80, 2, 0),
gsSPLine3D(0, 1, 0), // gsSPLine3D(0, 1, 0),
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };

View File

@ -14,7 +14,7 @@
static OSTime gLastOSTime = 0; static OSTime gLastOSTime = 0;
static float gFrameTime = 0.0f; static float gFrameTime = 0.0f;
static u16 gFrames = 0; static u16 gFrames = 0;
static u16 gFPS = 0; u16 gFPS = 0;
static u8 gRenderFPS = false; static u8 gRenderFPS = false;
static void CalculateFrameTimeFromOSTime(OSTime diff) { static void CalculateFrameTimeFromOSTime(OSTime diff) {
@ -29,20 +29,20 @@ static void Play_RenderFps(void) {
gRenderFPS ^= 1; gRenderFPS ^= 1;
} }
if (gRenderFPS) { if (gRenderFPS) {
OSTime newTime = osGetTime(); // OSTime newTime = osGetTime();
CalculateFrameTimeFromOSTime(newTime - gLastOSTime); // CalculateFrameTimeFromOSTime(newTime - gLastOSTime);
// If frame time is longer or equal to a second, update FPS counter. // // If frame time is longer or equal to a second, update FPS counter.
if (gFrameTime >= 1.0f) { // if (gFrameTime >= 1.0f) {
gFPS = gFrames; // gFPS = gFrames;
gFrames = 0; // gFrames = 0;
gFrameTime -= 1.0f; // gFrameTime -= 1.0f;
} // }
/* Draw */ /* Draw */
RCP_SetupDL(&gMasterDisp, SETUPDL_83); RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 0, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 0, 255);
Graphics_DisplaySmallText(FPS_COUNTER_X_POS, FPS_COUNTER_Y_POS, 1.0f, 1.0f, "FPS:"); Graphics_DisplaySmallText(FPS_COUNTER_X_POS, FPS_COUNTER_Y_POS, 1.0f, 1.0f, "FPS:");
Graphics_DisplaySmallNumber(FPS_COUNTER_X_POS + 35, FPS_COUNTER_Y_POS, gFPS); Graphics_DisplaySmallNumber(FPS_COUNTER_X_POS + 35, FPS_COUNTER_Y_POS, gFPS);
gLastOSTime = newTime; // gLastOSTime = newTime;
} }
} }

View File

@ -2838,7 +2838,11 @@ void Title_StarfoxLogo_Draw(void) {
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255);
// LTodo: Validate this // LTodo: Validate this
<<<<<<< HEAD
Lib_TextureRect_RGBA16(&gMasterDisp, aTitleStarfoxLogoTex, 236, 60, sTitleStarfoxLogoXpos, sTitleStarfoxLogoYpos, 1.0f, 1.0f); Lib_TextureRect_RGBA16(&gMasterDisp, aTitleStarfoxLogoTex, 236, 60, sTitleStarfoxLogoXpos, sTitleStarfoxLogoYpos, 1.0f, 1.0f);
=======
TextureRect_RGBA16(&gMasterDisp, gTitleStarfoxLogo, 236, 60, D_menu_801B9054, D_menu_801B9058, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
void Title_64Logo_Draw(void) { void Title_64Logo_Draw(void) {
@ -2884,21 +2888,36 @@ void Title_PressStart_Draw(void) {
RCP_SetupDL(&gMasterDisp, SETUPDL_85); RCP_SetupDL(&gMasterDisp, SETUPDL_85);
gDPSetPrimColor(gMasterDisp++, 0, 0, 60, 60, 255, 200); gDPSetPrimColor(gMasterDisp++, 0, 0, 60, 60, 255, 200);
<<<<<<< HEAD
Lib_TextureRect_CI8(&gMasterDisp, aNoControllerBgTex, aNoControllerBgTLUT, 32, 32, sNoControllerBgXpos, Lib_TextureRect_CI8(&gMasterDisp, aNoControllerBgTex, aNoControllerBgTLUT, 32, 32, sNoControllerBgXpos,
sNoControllerBgYpos, sNoControllerBgXscale, sNoControllerBgYscale); sNoControllerBgYpos, sNoControllerBgXscale, sNoControllerBgYscale);
// No Controller // No Controller
=======
TextureRect_CI8(&gMasterDisp, D_TITLE_601D750, D_TITLE_601DB50, 32, 32, D_menu_801AE464, D_menu_801AE468,
D_menu_801AE46C, D_menu_801AE470);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
RCP_SetupDL(&gMasterDisp, SETUPDL_83); RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, (s32) sTitleTextPrimCol, (s32) sTitleTextPrimCol, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, (s32) sTitleTextPrimCol, (s32) sTitleTextPrimCol, 255);
<<<<<<< HEAD
Lib_TextureRect_IA8(&gMasterDisp, aTitleNoControllerTex, 176, 24, D_menu_801AE474, Lib_TextureRect_IA8(&gMasterDisp, aTitleNoControllerTex, 176, 24, D_menu_801AE474,
D_menu_801AE478, 1.0f, 1.0f); D_menu_801AE478, 1.0f, 1.0f);
=======
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, (s32) D_menu_801B7BC8, (s32) D_menu_801B7BC8, 255);
TextureRect_IA8(&gMasterDisp, gTitleNoController, 176, 24, D_menu_801AE474, D_menu_801AE478, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} else { } else {
// Press Start // Press Start
RCP_SetupDL(&gMasterDisp, SETUPDL_83); RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, (s32) sTitleTextPrimCol, (s32) sTitleTextPrimCol, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, (s32) sTitleTextPrimCol, (s32) sTitleTextPrimCol, 255);
<<<<<<< HEAD
Lib_TextureRect_IA8(&gMasterDisp, aTitlePressStartTex, 120, 13, 101.0f, yPos, 1.0f, 1.0f); Lib_TextureRect_IA8(&gMasterDisp, aTitlePressStartTex, 120, 13, 101.0f, yPos, 1.0f, 1.0f);
=======
TextureRect_IA8(&gMasterDisp, gTitlePressStart, 120, 13, 101.0f, temp2, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
} }
} }
@ -2909,7 +2928,11 @@ void Title_Copyright_Draw(void) {
RCP_SetupDL(&gMasterDisp, SETUPDL_83); RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255);
<<<<<<< HEAD
Lib_TextureRect_IA8(&gMasterDisp, a1997NintendoTex, 120, 12, 102.0f, 209.0f, 1.0f, 1.0f); Lib_TextureRect_IA8(&gMasterDisp, a1997NintendoTex, 120, 12, 102.0f, 209.0f, 1.0f, 1.0f);
=======
TextureRect_IA8(&gMasterDisp, gTitleNintendoCopyright, 120, 12, 102.0f, 209.0f, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
void Title_TeamName_Draw(void) { void Title_TeamName_Draw(void) {
@ -2938,11 +2961,19 @@ void Title_TeamName_Draw(void) {
break; break;
case 2: case 2:
<<<<<<< HEAD
Lib_TextureRect_IA8(&gMasterDisp, gTitleFalcoCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f); Lib_TextureRect_IA8(&gMasterDisp, gTitleFalcoCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f);
break; break;
case 3: case 3:
Lib_TextureRect_IA8(&gMasterDisp, gTitleFoxCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f); Lib_TextureRect_IA8(&gMasterDisp, gTitleFoxCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f);
=======
TextureRect_IA8(&gMasterDisp, gTitleFalcoCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f);
break;
case 3:
TextureRect_IA8(&gMasterDisp, gTitleFoxCard, 176, 13, temp_fs2, temp, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
break; break;
} }
} }
@ -2984,7 +3015,11 @@ void Title_SunGlare_Draw(void) {
gDPSetColorDither(gMasterDisp++, G_CD_NOISE); gDPSetColorDither(gMasterDisp++, G_CD_NOISE);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, D_menu_801B7BD0); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, D_menu_801B7BD0);
<<<<<<< HEAD
Lib_TextureRect_RGBA16(&gMasterDisp, aTitleSunGlareTex, 32, 32, D_menu_801B9080, D_menu_801B9084, D_menu_801B7BB0, Lib_TextureRect_RGBA16(&gMasterDisp, aTitleSunGlareTex, 32, 32, D_menu_801B9080, D_menu_801B9084, D_menu_801B7BB0,
=======
TextureRect_RGBA16(&gMasterDisp, gTitleSunBeam, 32, 32, D_menu_801B9080, D_menu_801B9084, D_menu_801B7BB0,
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
D_menu_801B7BB4); D_menu_801B7BB4);
D_menu_801B9080 += 1.66f; D_menu_801B9080 += 1.66f;
} }
@ -3107,11 +3142,19 @@ void Title_Logos_Draw(void) {
Lib_TextureRect_CI4(&gMasterDisp, aIntroInTex, aIntroInTLUT, 32, 13, 150.0f, 110.0f, 1.0f, 1.0f); Lib_TextureRect_CI4(&gMasterDisp, aIntroInTex, aIntroInTLUT, 32, 13, 150.0f, 110.0f, 1.0f, 1.0f);
break; break;
<<<<<<< HEAD
case TITLE_LOGO_NINTENDO_64: case TITLE_LOGO_NINTENDO_64:
RCP_SetupDL(&gMasterDisp, 0x53); RCP_SetupDL(&gMasterDisp, 0x53);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, (s32) sStarfoxLogoAlpha); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, (s32) sStarfoxLogoAlpha);
TextureRect_16bRGBA(&gMasterDisp, aTitleN64LogoTex, 128, 88, D_menu_801B9070, TextureRect_16bRGBA(&gMasterDisp, aTitleN64LogoTex, 128, 88, D_menu_801B9070,
D_menu_801B9074, D_menu_801B9078, D_menu_801B907C); D_menu_801B9074, D_menu_801B9078, D_menu_801B907C);
=======
case 1:
RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, (s32) D_menu_801B7BDC);
TextureRect_RGBA16(&gMasterDisp, gTitleNintendo64Logo, 128, 88, D_menu_801B9070, D_menu_801B9074,
D_menu_801B9078, D_menu_801B907C);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
case TITLE_LOGO_NONE: case TITLE_LOGO_NONE:
break; break;
@ -3181,8 +3224,12 @@ void Title_TitleCard_Draw(void) {
RCP_SetupDL(&gMasterDisp, SETUPDL_83); RCP_SetupDL(&gMasterDisp, SETUPDL_83);
gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255);
<<<<<<< HEAD
Lib_TextureRect_IA8(&gMasterDisp, aTitleArwingCardTex, 112, 26, sTitleArwingCardXpos, Lib_TextureRect_IA8(&gMasterDisp, aTitleArwingCardTex, 112, 26, sTitleArwingCardXpos,
sTitleArwingCardYpos, 1.0f, 1.0f); sTitleArwingCardYpos, 1.0f, 1.0f);
=======
TextureRect_IA8(&gMasterDisp, gTitleArwingCard, 112, 26, D_menu_801AE564, D_menu_801AE568, 1.0f, 1.0f);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
} }

View File

@ -1,6 +1,6 @@
#include "Engine.h" #include "Engine.h"
#include "ui/ImguiUI.h" #include "ui/ImguiUI.h"
#include "ZAPDUtils/Utils/StringHelper.h" #include "StringHelper.h"
#include "libultraship/src/Context.h" #include "libultraship/src/Context.h"
#include "resource/type/ResourceType.h" #include "resource/type/ResourceType.h"
#include "resource/importers/AnimFactory.h" #include "resource/importers/AnimFactory.h"
@ -17,6 +17,13 @@
#include "resource/importers/SkeletonFactory.h" #include "resource/importers/SkeletonFactory.h"
#include "resource/importers/Vec3fFactory.h" #include "resource/importers/Vec3fFactory.h"
#include "resource/importers/Vec3sFactory.h" #include "resource/importers/Vec3sFactory.h"
#include <Fast3D/Fast3dWindow.h>
#include <DisplayListFactory.h>
#include <TextureFactory.h>
#include <MatrixFactory.h>
#include <ArrayFactory.h>
#include <BlobFactory.h>
#include <VertexFactory.h>
#include <Fast3D/gfx_pc.h> #include <Fast3D/gfx_pc.h>
#include <Fast3D/gfx_rendering_api.h> #include <Fast3D/gfx_rendering_api.h>
@ -25,6 +32,7 @@
#include <utility> #include <utility>
extern "C" { extern "C" {
extern uint16_t gFPS;
float gInterpolationStep = 0.0f; float gInterpolationStep = 0.0f;
#include <sf64thread.h> #include <sf64thread.h>
#include <macros.h> #include <macros.h>
@ -34,13 +42,13 @@ GameEngine* GameEngine::Instance;
GameEngine::GameEngine() { GameEngine::GameEngine() {
std::vector<std::string> OTRFiles; std::vector<std::string> OTRFiles;
if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("sp.otr"); std::filesystem::exists(cube_path)) { if (const std::string cube_path = Ship::Context::GetPathRelativeToAppDirectory("starship.otr"); std::filesystem::exists(cube_path)) {
OTRFiles.push_back(cube_path); OTRFiles.push_back(cube_path);
} }
if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) {
OTRFiles.push_back(sm64_otr_path); OTRFiles.push_back(sm64_otr_path);
} }
if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) {
if (std::filesystem::is_directory(patches_path)) { if (std::filesystem::is_directory(patches_path)) {
for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) { for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) {
if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
@ -50,7 +58,7 @@ GameEngine::GameEngine() {
} }
} }
this->context = LUS::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3); this->context = Ship::Context::CreateInstance("Starship", "ship", "starship.cfg.json", OTRFiles, {}, 3);
auto loader = context->GetResourceManager()->GetResourceLoader(); auto loader = context->GetResourceManager()->GetResourceLoader();
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryAnimV0>(), RESOURCE_FORMAT_BINARY, "Animation", static_cast<uint32_t>(SF64::ResourceType::AnimData), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryAnimV0>(), RESOURCE_FORMAT_BINARY, "Animation", static_cast<uint32_t>(SF64::ResourceType::AnimData), 0);
@ -58,7 +66,7 @@ GameEngine::GameEngine() {
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryLimbV0>(), RESOURCE_FORMAT_BINARY, "Limb", static_cast<uint32_t>(SF64::ResourceType::Limb), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryLimbV0>(), RESOURCE_FORMAT_BINARY, "Limb", static_cast<uint32_t>(SF64::ResourceType::Limb), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryMessageV0>(), RESOURCE_FORMAT_BINARY, "Message", static_cast<uint32_t>(SF64::ResourceType::Message), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryMessageV0>(), RESOURCE_FORMAT_BINARY, "Message", static_cast<uint32_t>(SF64::ResourceType::Message), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryMessageLookupV0>(), RESOURCE_FORMAT_BINARY, "MessageTable", static_cast<uint32_t>(SF64::ResourceType::MessageTable), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryMessageLookupV0>(), RESOURCE_FORMAT_BINARY, "MessageTable", static_cast<uint32_t>(SF64::ResourceType::MessageTable), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryEnvSettingsV0>(), RESOURCE_FORMAT_BINARY, "EnvSettings", static_cast<uint32_t>(SF64::ResourceType::EnvSettings), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryEnvSettingsV0>(), RESOURCE_FORMAT_BINARY, "EnvSettings", static_cast<uint32_t>(SF64::ResourceType::Environment), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryObjectInitV0>(), RESOURCE_FORMAT_BINARY, "ObjectInit", static_cast<uint32_t>(SF64::ResourceType::ObjectInit), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryObjectInitV0>(), RESOURCE_FORMAT_BINARY, "ObjectInit", static_cast<uint32_t>(SF64::ResourceType::ObjectInit), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryHitboxV0>(), RESOURCE_FORMAT_BINARY, "Hitbox", static_cast<uint32_t>(SF64::ResourceType::Hitbox), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryHitboxV0>(), RESOURCE_FORMAT_BINARY, "Hitbox", static_cast<uint32_t>(SF64::ResourceType::Hitbox), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryScriptV0>(), RESOURCE_FORMAT_BINARY, "Script", static_cast<uint32_t>(SF64::ResourceType::Script), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryScriptV0>(), RESOURCE_FORMAT_BINARY, "Script", static_cast<uint32_t>(SF64::ResourceType::Script), 0);
@ -67,6 +75,13 @@ GameEngine::GameEngine() {
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3fV0>(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast<uint32_t>(SF64::ResourceType::Vec3f), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3fV0>(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast<uint32_t>(SF64::ResourceType::Vec3f), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3sV0>(), RESOURCE_FORMAT_BINARY, "Vec3s", static_cast<uint32_t>(SF64::ResourceType::Vec3s), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3sV0>(), RESOURCE_FORMAT_BINARY, "Vec3s", static_cast<uint32_t>(SF64::ResourceType::Vec3s), 0);
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryGenericArrayV0>(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast<uint32_t>(SF64::ResourceType::GenericArray), 0); loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryGenericArrayV0>(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast<uint32_t>(SF64::ResourceType::GenericArray), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryTextureV0>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(LUS::ResourceType::Texture), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryTextureV1>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(LUS::ResourceType::Texture), 1);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast<uint32_t>(LUS::ResourceType::Vertex), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast<uint32_t>(LUS::ResourceType::DisplayList), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast<uint32_t>(LUS::ResourceType::Matrix), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryArrayV0>(), RESOURCE_FORMAT_BINARY, "Array", static_cast<uint32_t>(LUS::ResourceType::Array), 0);
loader->RegisterResourceFactory(std::make_shared<LUS::ResourceFactoryBinaryBlobV0>(), RESOURCE_FORMAT_BINARY, "Blob", static_cast<uint32_t>(LUS::ResourceType::Blob), 0);
} }
void GameEngine::Create(){ void GameEngine::Create(){
@ -84,7 +99,7 @@ void GameEngine::Destroy(){
bool ShouldClearTextureCacheAtEndOfFrame = false; bool ShouldClearTextureCacheAtEndOfFrame = false;
void GameEngine::StartFrame() const{ void GameEngine::StartFrame() const{
using LUS::KbScancode; using Ship::KbScancode;
const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); const int32_t dwScancode = this->context->GetWindow()->GetLastScancode();
this->context->GetWindow()->SetLastScancode(-1); this->context->GetWindow()->SetLastScancode(-1);
@ -100,10 +115,6 @@ void GameEngine::StartFrame() const{
this->context->GetWindow()->StartFrame(); this->context->GetWindow()->StartFrame();
} }
void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const {
this->context->GetWindow()->MainLoop(run_one_game_iter);
}
void GameEngine::RunCommands(Gfx* Commands) { void GameEngine::RunCommands(Gfx* Commands) {
gfx_run(Commands, {}); gfx_run(Commands, {});
gfx_end_frame(); gfx_end_frame();
@ -115,13 +126,22 @@ void GameEngine::RunCommands(Gfx* Commands) {
} }
void GameEngine::ProcessGfxCommands(Gfx* commands) { void GameEngine::ProcessGfxCommands(Gfx* commands) {
auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow());
if (wnd == nullptr) {
return;
}
gFPS = 30;
wnd->SetRendererUCode(UcodeHandlers::ucode_f3dex);
wnd->SetTargetFps(30);
wnd->SetMaximumFrameLatency(1);
RunCommands(commands); RunCommands(commands);
Instance->context->GetWindow()->SetTargetFps(30);
Instance->context->GetWindow()->SetMaximumFrameLatency(1);
} }
extern "C" uint32_t GameEngine_GetSampleRate() { extern "C" uint32_t GameEngine_GetSampleRate() {
auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer(); auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer();
if (player == nullptr) { if (player == nullptr) {
return 0; return 0;
} }

View File

@ -18,7 +18,7 @@ class GameEngine {
public: public:
static GameEngine* Instance; static GameEngine* Instance;
std::shared_ptr<LUS::Context> context; std::shared_ptr<Ship::Context> context;
GameEngine(); GameEngine();
static void Create(); static void Create();

View File

@ -10,12 +10,12 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
char* imgData = (char*)dl; char* imgData = (char*)dl;
if (GameEngine_OTRSigCheck(imgData) == 1) { if (GameEngine_OTRSigCheck(imgData) == 1) {
auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); auto resource = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
auto res = std::static_pointer_cast<LUS::DisplayList>(resource); auto res = std::static_pointer_cast<LUS::DisplayList>(resource);
dl = &res->Instructions[0]; dl = &res->Instructions[0];
dl->words.trace.file = imgData; // dl->words.trace.file = imgData;
dl->words.trace.idx = 0; // dl->words.trace.idx = 0;
dl->words.trace.valid = true; // dl->words.trace.valid = true;
} }
__gSPDisplayList(pkt, dl); __gSPDisplayList(pkt, dl);
@ -34,7 +34,7 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
auto data = reinterpret_cast<char*>(texAddr); auto data = reinterpret_cast<char*>(texAddr);
if (texAddr != 0 && GameEngine_OTRSigCheck(data)) { if (texAddr != 0 && GameEngine_OTRSigCheck(data)) {
const auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(data); const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data);
const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type); const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type);
switch(type) { switch(type) {

View File

@ -41,7 +41,9 @@ int main(int argc, char *argv[]) {
Lib_FillScreen(1); Lib_FillScreen(1);
Main_Initialize(); Main_Initialize();
Main_ThreadEntry(NULL); Main_ThreadEntry(NULL);
GameEngine::Instance->ProcessFrame(push_frame); while (WindowIsRunning()) {
push_frame();
}
GameEngine::Instance->Destroy(); GameEngine::Instance->Destroy();
return 0; return 0;
} }

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryAnimV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryAnimV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto anim = std::make_shared<Animation>(file->InitData); auto anim = std::make_shared<Animation>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
int16_t frameCount = reader->ReadInt16(); int16_t frameCount = reader->ReadInt16();
int16_t limbCount = reader->ReadInt16(); int16_t limbCount = reader->ReadInt16();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryAnimV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryAnimV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryColPolyV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryColPolyV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto colPoly = std::make_shared<ColPoly>(file->InitData); auto colPoly = std::make_shared<ColPoly>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto colPolysCount = reader->ReadUInt32(); auto colPolysCount = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryColPolyV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryColPolyV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -6,13 +6,13 @@
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryEnvSettingsV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryEnvSettingsV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto env = std::make_shared<EnvSettings>(file->InitData); auto env = std::make_shared<EnvSettings>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
env->mSettings.type = reader->ReadInt32(); env->mSettings.type = reader->ReadInt32();
env->mSettings.unk_04 = reader->ReadInt32(); env->mSettings.unk_04 = reader->ReadInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryEnvSettingsV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryEnvSettingsV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto arr = std::make_shared<GenericArray>(file->InitData); auto arr = std::make_shared<GenericArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto type = reader->ReadUInt32(); auto type = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryGenericArrayV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryGenericArrayV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryHitboxV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryHitboxV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto hitbox = std::make_shared<Hitbox>(file->InitData); auto hitbox = std::make_shared<Hitbox>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto count = reader->ReadUInt32(); auto count = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryHitboxV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryHitboxV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -7,15 +7,16 @@
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryLimbV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryLimbV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto limb = std::make_shared<Limb>(file->InitData); auto limb = std::make_shared<Limb>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
limb->mData.dList = LoadChild<Gfx*>(reader->ReadUInt64()); uint64_t dlist = reader->ReadUInt64();
limb->mData.dList = LoadChild<Gfx*>(dlist);
limb->mData.trans.x = reader->ReadFloat(); limb->mData.trans.x = reader->ReadFloat();
limb->mData.trans.y = reader->ReadFloat(); limb->mData.trans.y = reader->ReadFloat();
limb->mData.trans.z = reader->ReadFloat(); limb->mData.trans.z = reader->ReadFloat();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryLimbV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryLimbV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryMessageV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMessageV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto msg = std::make_shared<Message>(file->InitData); auto msg = std::make_shared<Message>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto size = reader->ReadUInt32(); auto size = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryMessageV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryMessageV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -5,13 +5,13 @@
#include "ResourceUtil.h" #include "ResourceUtil.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryMessageLookupV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMessageLookupV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto table = std::make_shared<MessageLookup>(file->InitData); auto table = std::make_shared<MessageLookup>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto count = reader->ReadUInt32(); auto count = reader->ReadUInt32();
for (uint32_t i = 0; i < count - 1; i++) { for (uint32_t i = 0; i < count - 1; i++) {

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryMessageLookupV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryMessageLookupV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -6,13 +6,13 @@
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryObjectInitV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryObjectInitV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto obj = std::make_shared<ObjectInit>(file->InitData); auto obj = std::make_shared<ObjectInit>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto count = reader->ReadUInt32(); auto count = reader->ReadUInt32();
for(size_t i = 0; i < count; i++) { for(size_t i = 0; i < count; i++) {

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryObjectInitV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryObjectInitV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -5,11 +5,14 @@
namespace SF64 { namespace SF64 {
template <typename T> T LoadChild(uint64_t crc) { template <typename T> T LoadChild(uint64_t crc) {
if (crc == 0) {
return nullptr;
}
auto path = ResourceGetNameByCrc(crc); auto path = ResourceGetNameByCrc(crc);
if (path == nullptr) { if (path == nullptr) {
return nullptr; return nullptr;
} }
auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr; return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr;
} }
} }

View File

@ -4,13 +4,13 @@
#include "ResourceUtil.h" #include "ResourceUtil.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryScriptCMDV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryScriptCMDV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto cmds = std::make_shared<ScriptCMDs>(file->InitData); auto cmds = std::make_shared<ScriptCMDs>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto size = reader->ReadUInt32(); auto size = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryScriptCMDV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryScriptCMDV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -4,13 +4,13 @@
#include "ResourceUtil.h" #include "ResourceUtil.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryScriptV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryScriptV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto script = std::make_shared<Script>(file->InitData); auto script = std::make_shared<Script>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto size = reader->ReadUInt32(); auto size = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryScriptV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryScriptV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -5,13 +5,13 @@
#include "ResourceUtil.h" #include "ResourceUtil.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto skel = std::make_shared<Skeleton>(file->InitData); auto skel = std::make_shared<Skeleton>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto count = reader->ReadUInt32(); auto count = reader->ReadUInt32();
for(size_t i = 0; i < count; i++) { for(size_t i = 0; i < count; i++) {

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinarySkeletonV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinarySkeletonV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto vec = std::make_shared<Vec3fArray>(file->InitData); auto vec = std::make_shared<Vec3fArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto vecCount = reader->ReadUInt32(); auto vecCount = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryVec3fV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryVec3fV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -3,13 +3,13 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
namespace SF64 { namespace SF64 {
std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr<LUS::File> file) { std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr<Ship::File> file) {
if (!FileHasValidFormatAndReader(file)) { if (!FileHasValidFormatAndReader(file)) {
return nullptr; return nullptr;
} }
auto vec = std::make_shared<Vec3sArray>(file->InitData); auto vec = std::make_shared<Vec3sArray>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
auto vecCount = reader->ReadUInt32(); auto vecCount = reader->ReadUInt32();

View File

@ -4,8 +4,8 @@
#include "ResourceFactoryBinary.h" #include "ResourceFactoryBinary.h"
namespace SF64 { namespace SF64 {
class ResourceFactoryBinaryVec3sV0 : public LUS::ResourceFactoryBinary { class ResourceFactoryBinaryVec3sV0 : public Ship::ResourceFactoryBinary {
public: public:
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
}; };
}; // namespace LUS }; // namespace LUS

View File

@ -21,11 +21,11 @@ struct AnimationData {
/* 0x08 */ JointKey* jointKey; /* 0x08 */ JointKey* jointKey;
}; // size = 0xC }; // size = 0xC
class Animation : public LUS::Resource<AnimationData> { class Animation : public Ship::Resource<AnimationData> {
public: public:
using Resource::Resource; using Resource::Resource;
Animation() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} Animation() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
AnimationData* GetPointer(); AnimationData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -19,11 +19,11 @@ struct ColPolyData {
ColPolyData(Vec3s tri, int16_t unk_06, Vec3s norm, int16_t unk_0E, int32_t dist) : tri(std::move(tri)), unk_06(unk_06), norm(std::move(norm)), unk_0E(unk_0E), dist(dist) {} ColPolyData(Vec3s tri, int16_t unk_06, Vec3s norm, int16_t unk_0E, int32_t dist) : tri(std::move(tri)), unk_06(unk_06), norm(std::move(norm)), unk_0E(unk_0E), dist(dist) {}
}; // size = 0x14 }; // size = 0x14
class ColPoly : public LUS::Resource<ColPolyData> { class ColPoly : public Ship::Resource<ColPolyData> {
public: public:
using Resource::Resource; using Resource::Resource;
ColPoly() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} ColPoly() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
ColPolyData* GetPointer(); ColPolyData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -26,11 +26,11 @@ struct EnvSettingsData {
/* 0x40 */ int32_t ambB; /* 0x40 */ int32_t ambB;
}; };
class EnvSettings : public LUS::Resource<EnvSettingsData> { class EnvSettings : public Ship::Resource<EnvSettingsData> {
public: public:
using Resource::Resource; using Resource::Resource;
EnvSettings() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} EnvSettings() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
EnvSettingsData* GetPointer(); EnvSettingsData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -40,11 +40,11 @@ enum class ArrayType {
u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s, u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s,
}; };
class GenericArray : public LUS::Resource<uint8_t> { class GenericArray : public Ship::Resource<uint8_t> {
public: public:
using Resource::Resource; using Resource::Resource;
GenericArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} GenericArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
uint8_t* GetPointer(); uint8_t* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -4,7 +4,7 @@
#include <Resource.h> #include <Resource.h>
namespace SF64 { namespace SF64 {
class Hitbox : public LUS::Resource<float> { class Hitbox : public Ship::Resource<float> {
public: public:
using Resource::Resource; using Resource::Resource;

View File

@ -23,11 +23,11 @@ struct LimbData {
/* 0x01C */ LimbData* child; /* 0x01C */ LimbData* child;
}; // size = 0x20 }; // size = 0x20
class Limb : public LUS::Resource<LimbData> { class Limb : public Ship::Resource<LimbData> {
public: public:
using Resource::Resource; using Resource::Resource;
Limb() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} Limb() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
LimbData* GetPointer(); LimbData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -10,7 +10,7 @@ typedef struct {
u16* msgPtr; u16* msgPtr;
} MsgLookup; } MsgLookup;
class Message : public LUS::Resource<void> { class Message : public Ship::Resource<void> {
public: public:
using Resource::Resource; using Resource::Resource;
@ -20,7 +20,7 @@ class Message : public LUS::Resource<void> {
std::vector<uint16_t> mMessage; std::vector<uint16_t> mMessage;
}; };
class MessageLookup : public LUS::Resource<MsgLookup> { class MessageLookup : public Ship::Resource<MsgLookup> {
public: public:
using Resource::Resource; using Resource::Resource;

View File

@ -16,11 +16,11 @@ struct ObjectInitData {
/* 0x10 */ int16_t id; /* 0x10 */ int16_t id;
}; // size = 0x14 }; // size = 0x14
class ObjectInit : public LUS::Resource<ObjectInitData> { class ObjectInit : public Ship::Resource<ObjectInitData> {
public: public:
using Resource::Resource; using Resource::Resource;
ObjectInit() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} ObjectInit() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
ObjectInitData* GetPointer(); ObjectInitData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -5,7 +5,7 @@ enum class ResourceType {
// SF64 // SF64
AnimData = 0x414E494D, // ANIM AnimData = 0x414E494D, // ANIM
ColPoly = 0x43504C59, // CPLY ColPoly = 0x43504C59, // CPLY
EnvSettings = 0x454E5653, // ENVS Environment = 0x454E5653, // ENVS
Limb = 0x4C494D42, // LIMB Limb = 0x4C494D42, // LIMB
Message = 0x4D534720, // MSG Message = 0x4D534720, // MSG
MessageTable = 0x4D534754, // MSGT MessageTable = 0x4D534754, // MSGT

View File

@ -4,7 +4,7 @@
#include <Resource.h> #include <Resource.h>
namespace SF64 { namespace SF64 {
class Script : public LUS::Resource<uint16_t*> { class Script : public Ship::Resource<uint16_t*> {
public: public:
using Resource::Resource; using Resource::Resource;
@ -14,7 +14,7 @@ class Script : public LUS::Resource<uint16_t*> {
std::vector<uint16_t*> mScripts; std::vector<uint16_t*> mScripts;
}; };
class ScriptCMDs : public LUS::Resource<uint16_t> { class ScriptCMDs : public Ship::Resource<uint16_t> {
public: public:
using Resource::Resource; using Resource::Resource;

View File

@ -5,11 +5,11 @@
#include <Resource.h> #include <Resource.h>
namespace SF64 { namespace SF64 {
class Skeleton : public LUS::Resource<LimbData*> { class Skeleton : public Ship::Resource<LimbData*> {
public: public:
using Resource::Resource; using Resource::Resource;
Skeleton() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} Skeleton() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
LimbData** GetPointer(); LimbData** GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -11,11 +11,11 @@ struct Vec3fData {
Vec3fData(float x, float y, float z) : x(x), y(y), z(z) {} Vec3fData(float x, float y, float z) : x(x), y(y), z(z) {}
}; };
class Vec3fArray : public LUS::Resource<Vec3fData> { class Vec3fArray : public Ship::Resource<Vec3fData> {
public: public:
using Resource::Resource; using Resource::Resource;
Vec3fArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} Vec3fArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
Vec3fData* GetPointer(); Vec3fData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -11,11 +11,11 @@ struct Vec3sData {
Vec3sData(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} Vec3sData(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {}
}; };
class Vec3sArray : public LUS::Resource<Vec3sData> { class Vec3sArray : public Ship::Resource<Vec3sData> {
public: public:
using Resource::Resource; using Resource::Resource;
Vec3sArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} Vec3sArray() : Resource(std::shared_ptr<Ship::ResourceInitData>()) {}
Vec3sData* GetPointer(); Vec3sData* GetPointer();
size_t GetPointerSize(); size_t GetPointerSize();

View File

@ -3,11 +3,11 @@
#include "ResolutionEditor.h" #include "ResolutionEditor.h"
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <ImGui/imgui.h> #include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include "libultraship/src/Context.h" #include "libultraship/src/Context.h"
#include <ImGui/imgui_internal.h> #include <imgui_internal.h>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include <Fast3D/gfx_pc.h> #include <Fast3D/gfx_pc.h>
#include "port/Engine.h" #include "port/Engine.h"
@ -18,14 +18,14 @@ extern "C" {
namespace GameUI { namespace GameUI {
std::shared_ptr<GameMenuBar> mGameMenuBar; std::shared_ptr<GameMenuBar> mGameMenuBar;
std::shared_ptr<LUS::GuiWindow> mConsoleWindow; std::shared_ptr<Ship::GuiWindow> mConsoleWindow;
std::shared_ptr<LUS::GuiWindow> mStatsWindow; std::shared_ptr<Ship::GuiWindow> mStatsWindow;
std::shared_ptr<LUS::GuiWindow> mInputEditorWindow; std::shared_ptr<Ship::GuiWindow> mInputEditorWindow;
std::shared_ptr<LUS::GuiWindow> mGfxDebuggerWindow; std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow;
std::shared_ptr<AdvancedResolutionSettings::AdvancedResolutionSettingsWindow> mAdvancedResolutionSettingsWindow; std::shared_ptr<AdvancedResolutionSettings::AdvancedResolutionSettingsWindow> mAdvancedResolutionSettingsWindow;
void SetupGuiElements() { void SetupGuiElements() {
auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui();
auto& style = ImGui::GetStyle(); auto& style = ImGui::GetStyle();
style.FramePadding = ImVec2(4.0f, 6.0f); style.FramePadding = ImVec2(4.0f, 6.0f);
@ -112,28 +112,28 @@ void DrawSettingsMenu(){
// audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); // audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f));
// } // }
// //
// static std::unordered_map<LUS::AudioBackend, const char*> audioBackendNames = { // static std::unordered_map<Ship::AudioBackend, const char*> audioBackendNames = {
// { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, // { Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
// { LUS::AudioBackend::PULSE, "PulseAudio" }, // { Ship::AudioBackend::PULSE, "PulseAudio" },
// { LUS::AudioBackend::SDL, "SDL" }, // { Ship::AudioBackend::SDL, "SDL" },
// }; // };
// //
// ImGui::Text("Audio API (Needs reload)"); // ImGui::Text("Audio API (Needs reload)");
// auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); // auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend();
// //
// if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { // if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
// } // }
// if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { // if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) {
// for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { // for (uint8_t i = 0; i < Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) {
// auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; // auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i];
// if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { // if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) {
// LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); // Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(backend);
// } // }
// } // }
// ImGui::EndCombo(); // ImGui::EndCombo();
// } // }
// if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { // if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) {
// UIWidgets::ReEnableComponent(""); // UIWidgets::ReEnableComponent("");
// } // }
// //
@ -175,23 +175,23 @@ void DrawSettingsMenu(){
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
// Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste? // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste?
// LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); // Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
// UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); // UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing");
#ifndef __WIIU__ #ifndef __WIIU__
if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, { if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, {
.tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel" .tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"
})) { })) {
LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1));
} }
#endif #endif
{ // FPS Slider { // FPS Slider
const int minFps = 30; const int minFps = 30;
static int maxFps; static int maxFps;
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
maxFps = 360; maxFps = 360;
} else { } else {
maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
} }
int currentFps = 0; int currentFps = 0;
#ifdef __WIIU__ #ifdef __WIIU__
@ -253,15 +253,15 @@ void DrawSettingsMenu(){
currentFps = 60; currentFps = 60;
} }
CVarSetInteger("gInterpolationFPS", currentFps); CVarSetInteger("gInterpolationFPS", currentFps);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
#else #else
bool matchingRefreshRate = bool matchingRefreshRate =
CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11;
UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, {
.disabled = matchingRefreshRate .disabled = matchingRefreshRate
}); });
#endif #endif
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::Tooltip( UIWidgets::Tooltip(
"Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely "
"visual and does not impact game logic, execution of glitches etc.\n\n" "visual and does not impact game logic, execution of glitches etc.\n\n"
@ -275,13 +275,13 @@ void DrawSettingsMenu(){
} }
} // END FPS Slider } // END FPS Slider
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
if (ImGui::Button("Match Refresh Rate")) { if (ImGui::Button("Match Refresh Rate")) {
int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
if (hz >= 30 && hz <= 360) { if (hz >= 30 && hz <= 360) {
CVarSetInteger("gInterpolationFPS", hz); CVarSetInteger("gInterpolationFPS", hz);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
} }
} else { } else {
@ -290,7 +290,7 @@ void DrawSettingsMenu(){
UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate");
if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) {
UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS",
"##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false);
UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time.");
@ -299,51 +299,51 @@ void DrawSettingsMenu(){
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
static std::unordered_map<LUS::WindowBackend, const char*> windowBackendNames = { static std::unordered_map<Ship::WindowBackend, const char*> windowBackendNames = {
{ LUS::WindowBackend::DX11, "DirectX" }, { Ship::WindowBackend::DX11, "DirectX" },
{ LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, { Ship::WindowBackend::SDL_OPENGL, "OpenGL"},
{ LUS::WindowBackend::SDL_METAL, "Metal" }, { Ship::WindowBackend::SDL_METAL, "Metal" },
{ LUS::WindowBackend::GX2, "GX2"} { Ship::WindowBackend::GX2, "GX2"}
}; };
ImGui::Text("Renderer API (Needs reload)"); ImGui::Text("Renderer API (Needs reload)");
LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend();
LUS::WindowBackend configWindowBackend; Ship::WindowBackend configWindowBackend;
int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1);
if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(LUS::WindowBackend::BACKEND_COUNT)) { if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(Ship::WindowBackend::BACKEND_COUNT)) {
configWindowBackend = static_cast<LUS::WindowBackend>(configWindowBackendId); configWindowBackend = static_cast<Ship::WindowBackend>(configWindowBackendId);
} else { } else {
configWindowBackend = runningWindowBackend; configWindowBackend = runningWindowBackend;
} }
if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f);
} }
if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) {
for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { for (size_t i = 0; i < Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) {
auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; auto backend = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i];
if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) {
LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast<int>(backend)); Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast<int>(backend));
LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name",
windowBackendNames[backend]); windowBackendNames[backend]);
LUS::Context::GetInstance()->GetConfig()->Save(); Ship::Context::GetInstance()->GetConfig()->Save();
} }
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) {
UIWidgets::ReEnableComponent(""); UIWidgets::ReEnableComponent("");
} }
if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false);
} }
if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) {
UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false);
} }
if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) {
UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true);
UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect.");
} }
@ -355,7 +355,7 @@ void DrawSettingsMenu(){
UIWidgets::Spacer(0); UIWidgets::Spacer(0);
LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings();
ImGui::EndMenu(); ImGui::EndMenu();
} }
@ -364,11 +364,11 @@ void DrawSettingsMenu(){
void DrawMenuBarIcon() { void DrawMenuBarIcon() {
static bool gameIconLoaded = false; static bool gameIconLoaded = false;
if (!gameIconLoaded) { if (!gameIconLoaded) {
// LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); // Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png");
gameIconLoaded = false; gameIconLoaded = false;
} }
if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) {
#ifdef __SWITCH__ #ifdef __SWITCH__
ImVec2 iconSize = ImVec2(20.0f, 20.0f); ImVec2 iconSize = ImVec2(20.0f, 20.0f);
float posScale = 1.0f; float posScale = 1.0f;
@ -380,7 +380,7 @@ void DrawMenuBarIcon() {
float posScale = 1.5f; float posScale = 1.5f;
#endif #endif
ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale);
ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize);
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(25, 0) * posScale); ImGui::SetCursorPos(ImVec2(25, 0) * posScale);
} }
@ -400,11 +400,11 @@ void DrawGameMenu() {
#if !defined(__SWITCH__) && !defined(__WIIU__) #if !defined(__SWITCH__) && !defined(__WIIU__)
if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) { if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) {
LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen();
} }
if (UIWidgets::MenuItem("Quit")) { if (UIWidgets::MenuItem("Quit")) {
LUS::Context::GetInstance()->GetWindow()->Close(); Ship::Context::GetInstance()->GetWindow()->Close();
} }
#endif #endif
ImGui::EndMenu(); ImGui::EndMenu();

View File

@ -6,9 +6,9 @@ namespace GameUI {
void Destroy(); void Destroy();
} }
class GameMenuBar : public LUS::GuiMenuBar { class GameMenuBar : public Ship::GuiMenuBar {
public: public:
using LUS::GuiMenuBar::GuiMenuBar; using Ship::GuiMenuBar::GuiMenuBar;
protected: protected:
void DrawElement() override; void DrawElement() override;
void InitElement() override {}; void InitElement() override {};

View File

@ -2,7 +2,7 @@
#include "UIWidgets.h" #include "UIWidgets.h"
#include "libultraship/src/Context.h" #include "libultraship/src/Context.h"
#include <ImGui/imgui.h> #include <imgui.h>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include <graphic/Fast3D/gfx_pc.h> #include <graphic/Fast3D/gfx_pc.h>
@ -40,7 +40,7 @@ namespace AdvancedResolutionSettings {
const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 }; const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 };
const int default_pixelCount = 0; // Default combo list option const int default_pixelCount = 0; // Default combo list option
const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution() const uint32_t minVerticalPixelCount = 240; // see: Ship::AdvancedResolution()
const uint32_t maxVerticalPixelCount = 4320; const uint32_t maxVerticalPixelCount = 4320;
const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider.
@ -104,7 +104,7 @@ namespace AdvancedResolutionSettings {
(CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) &&
CVarGetInteger("gAdvancedResolution.Enabled", 0)) || CVarGetInteger("gAdvancedResolution.Enabled", 0)) ||
CVarGetInteger("gLowResMode", 0))) { CVarGetInteger("gLowResMode", 0))) {
LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1));
} }
UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective " UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective "
"form of anti-aliasing"); // Description pulled from SohMenuBar.cpp "form of anti-aliasing"); // Description pulled from SohMenuBar.cpp

View File

@ -2,7 +2,7 @@
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
namespace AdvancedResolutionSettings { namespace AdvancedResolutionSettings {
class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { class AdvancedResolutionSettingsWindow : public Ship::GuiWindow {
private: private:
bool IsDroppingFrames(); bool IsDroppingFrames();
@ -10,7 +10,7 @@ namespace AdvancedResolutionSettings {
bool IsBoolArrayTrue(bool*); bool IsBoolArrayTrue(bool*);
public: public:
using LUS::GuiWindow::GuiWindow; using Ship::GuiWindow::GuiWindow;
void InitElement() override; void InitElement() override;
void DrawElement() override; void DrawElement() override;

View File

@ -9,8 +9,8 @@
#include "libultraship/src/Context.h" #include "libultraship/src/Context.h"
#include <ImGui/imgui.h> #include <imgui.h>
#include <ImGui/imgui_internal.h> #include <imgui_internal.h>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
#include <libultraship/libultra/types.h> #include <libultraship/libultra/types.h>
@ -205,7 +205,7 @@ namespace UIWidgets {
bool val = (bool)CVarGetInteger(cvarName, defaultValue); bool val = (bool)CVarGetInteger(cvarName, defaultValue);
if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { if (CustomCheckbox(text, &val, disabled, disabledGraphic)) {
CVarSetInteger(cvarName, val); CVarSetInteger(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
changed = true; changed = true;
} }
@ -245,7 +245,7 @@ namespace UIWidgets {
CVarSetInteger(cvarName, i); CVarSetInteger(cvarName, i);
selected = i; selected = i;
changed = true; changed = true;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
} }
} }
@ -258,7 +258,7 @@ namespace UIWidgets {
if (disabledValue >= 0 && selected != disabledValue) { if (disabledValue >= 0 && selected != disabledValue) {
CVarSetInteger(cvarName, disabledValue); CVarSetInteger(cvarName, disabledValue);
changed = true; changed = true;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
} }
@ -347,7 +347,7 @@ namespace UIWidgets {
if (changed) { if (changed) {
CVarSetInteger(cvarName, val); CVarSetInteger(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
return changed; return changed;
@ -423,7 +423,7 @@ namespace UIWidgets {
if (changed) { if (changed) {
CVarSetFloat(cvarName, val); CVarSetFloat(cvarName, val);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
} }
return changed; return changed;
@ -470,7 +470,7 @@ namespace UIWidgets {
int val = CVarGetInteger(cvarName, 0); int val = CVarGetInteger(cvarName, 0);
if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { if (ImGui::RadioButton(make_invisible.c_str(), id == val)) {
CVarSetInteger(cvarName, id); CVarSetInteger(cvarName, id);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
ret = true; ret = true;
} }
ImGui::SameLine(); ImGui::SameLine();
@ -497,7 +497,7 @@ namespace UIWidgets {
CVarSetColor(cvarName, colorsRGBA); CVarSetColor(cvarName, colorsRGBA);
CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode.
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
changed = true; changed = true;
} }
Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color");
@ -673,7 +673,7 @@ namespace UIWidgets {
return dirty; return dirty;
} }
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options) { bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<Ship::GuiWindow> windowPtr, const ButtonOptions& options) {
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0));
std::string buttonText = label; std::string buttonText = label;
bool dirty = false; bool dirty = false;
@ -763,7 +763,7 @@ namespace UIWidgets {
bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); bool value = (bool)CVarGetInteger(cvarName, options.defaultValue);
if (Checkbox(label, &value, options)) { if (Checkbox(label, &value, options)) {
CVarSetInteger(cvarName, value); CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
return dirty; return dirty;
@ -867,7 +867,7 @@ namespace UIWidgets {
uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex); uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex);
if (Combobox(label, &value, comboArray, options)) { if (Combobox(label, &value, comboArray, options)) {
CVarSetInteger(cvarName, value); CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
return dirty; return dirty;
@ -914,7 +914,7 @@ namespace UIWidgets {
if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) {
*value -= options.step; *value -= options.step;
if (*value < min) *value = min; if (*value < min) *value = min;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
ImGui::SameLine(0, 3.0f); ImGui::SameLine(0, 3.0f);
@ -923,7 +923,7 @@ namespace UIWidgets {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
} }
if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) {
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
if (options.showButtons) { if (options.showButtons) {
@ -932,7 +932,7 @@ namespace UIWidgets {
if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) {
*value += options.step; *value += options.step;
if (*value > max) *value = max; if (*value > max) *value = max;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
} }
@ -953,7 +953,7 @@ namespace UIWidgets {
int32_t value = CVarGetInteger(cvarName, defaultValue); int32_t value = CVarGetInteger(cvarName, defaultValue);
if (SliderInt(label, &value, min, max, options)) { if (SliderInt(label, &value, min, max, options)) {
CVarSetInteger(cvarName, value); CVarSetInteger(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
return dirty; return dirty;
@ -985,7 +985,7 @@ namespace UIWidgets {
if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) {
*value -= options.step; *value -= options.step;
if (*value < min) *value = min; if (*value < min) *value = min;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
ImGui::SameLine(0, 3.0f); ImGui::SameLine(0, 3.0f);
@ -995,7 +995,7 @@ namespace UIWidgets {
} }
if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) {
*value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
if (options.showButtons) { if (options.showButtons) {
@ -1004,7 +1004,7 @@ namespace UIWidgets {
if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) {
*value += options.step; *value += options.step;
if (*value > max) *value = max; if (*value > max) *value = max;
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
} }
@ -1025,7 +1025,7 @@ namespace UIWidgets {
float value = CVarGetFloat(cvarName, defaultValue); float value = CVarGetFloat(cvarName, defaultValue);
if (SliderFloat(label, &value, min, max, options)) { if (SliderFloat(label, &value, min, max, options)) {
CVarSetFloat(cvarName, value); CVarSetFloat(cvarName, value);
LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick();
dirty = true; dirty = true;
} }
return dirty; return dirty;

View File

@ -3,9 +3,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <span> #include <span>
#include <stdint.h> #include <cstdint>
#define IMGUI_DEFINE_MATH_OPERATORS #define IMGUI_DEFINE_MATH_OPERATORS
#include <ImGui/imgui.h> #include <imgui.h>
#include <libultraship/libultraship.h> #include <libultraship/libultraship.h>
namespace UIWidgets { namespace UIWidgets {
@ -25,7 +25,7 @@ namespace UIWidgets {
} }
return 1; return 1;
} }
}; };
// MARK: - Enums // MARK: - Enums
@ -65,17 +65,17 @@ namespace UIWidgets {
bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false);
bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false);
bool EnhancementCombobox(const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); bool EnhancementCombobox(const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1);
bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1);
void PaddedText(const char* text, bool padTop = true, bool padBottom = true); void PaddedText(const char* text, bool padTop = true, bool padBottom = true);
bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = "");
bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "");
bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = "");
bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "");
bool EnhancementRadioButton(const char* text, const char* cvarName, int id); bool EnhancementRadioButton(const char* text, const char* cvarName, int id);
bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha); bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
@ -141,7 +141,7 @@ namespace UIWidgets {
void PushStyleButton(const ImVec4& color = Colors::Gray); void PushStyleButton(const ImVec4& color = Colors::Gray);
void PopStyleButton(); void PopStyleButton();
bool Button(const char* label, const ButtonOptions& options = {}); bool Button(const char* label, const ButtonOptions& options = {});
bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options = {}); bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<Ship::GuiWindow> windowPtr, const ButtonOptions& options = {});
struct CheckboxOptions { struct CheckboxOptions {
const ImVec4 color = Colors::Indigo; const ImVec4 color = Colors::Indigo;

View File

@ -59,6 +59,9 @@ void Controller_Init(void) {
} }
} }
// LTODO: Fix this
#define osContGetStatus(x) true
void Controller_UpdateInput(void) { void Controller_UpdateInput(void) {
s32 i; s32 i;
@ -97,7 +100,11 @@ void Controller_ReadData(void) {
void Save_ReadData(void) { void Save_ReadData(void) {
if ((gStartNMI == 0) && (Save_ReadEeprom(&gSaveIOBuffer) == 0)) { if ((gStartNMI == 0) && (Save_ReadEeprom(&gSaveIOBuffer) == 0)) {
<<<<<<< HEAD
osSendMesg(&gSaveMesgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_NOBLOCK); osSendMesg(&gSaveMesgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_NOBLOCK);
=======
osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_SUCCESS), OS_MESG_PRI_NORMAL);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
return; return;
} }
osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL); osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL);
@ -105,7 +112,11 @@ void Save_ReadData(void) {
void Save_WriteData(void) { void Save_WriteData(void) {
if ((gStartNMI == 0) && (Save_WriteEeprom(&gSaveIOBuffer) == 0)) { if ((gStartNMI == 0) && (Save_WriteEeprom(&gSaveIOBuffer) == 0)) {
<<<<<<< HEAD
osSendMesg(&gSaveMesgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_NOBLOCK); osSendMesg(&gSaveMesgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_NOBLOCK);
=======
osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_SUCCESS), OS_MESG_PRI_NORMAL);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
return; return;
} }
osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL); osSendMesg(&gSaveMesgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL);

View File

@ -15,32 +15,32 @@ OSMesgQueue gPiMgrCmdQueue; // 800E2010
OSMesg sPiMgrCmdBuff[50]; // 800E2028 OSMesg sPiMgrCmdBuff[50]; // 800E2028
OSMesgQueue gDmaMesgQueue; OSMesgQueue gDmaMesgQueue;
void* sDmaMsgBuff[1]; OSMesg sDmaMsgBuff[1];
OSIoMesg gDmaIOMsg; OSIoMesg gDmaIOMsg;
OSMesgQueue gSerialEventQueue; OSMesgQueue gSerialEventQueue;
void* sSerialEventBuff[1]; OSMesg sSerialEventBuff[1];
OSMesgQueue gMainThreadMesgQueue; OSMesgQueue gMainThreadMesgQueue;
void* sMainThreadMsgBuff[32]; OSMesg sMainThreadMsgBuff[32];
OSMesgQueue gTaskMesgQueue; OSMesgQueue gTaskMesgQueue;
void* sTaskMsgBuff[16]; OSMesg sTaskMsgBuff[16];
OSMesgQueue gAudioVImesgQueue; OSMesgQueue gAudioVImesgQueue;
void* sAudioVImsgBuff[1]; OSMesg sAudioVImsgBuff[1];
OSMesgQueue gAudioTaskMesgQueue; OSMesgQueue gAudioTaskMesgQueue;
void* sAudioTaskMsgBuff[1]; OSMesg sAudioTaskMsgBuff[1];
OSMesgQueue gGfxVImesgQueue; OSMesgQueue gGfxVImesgQueue;
void* sGfxVImsgBuff[4]; OSMesg sGfxVImsgBuff[4];
OSMesgQueue gGfxTaskMesgQueue; OSMesgQueue gGfxTaskMesgQueue;
void* sGfxTaskMsgBuff[2]; OSMesg sGfxTaskMsgBuff[2];
OSMesgQueue gSerialThreadMesgQueue; OSMesgQueue gSerialThreadMesgQueue;
void* sSerialThreadMsgBuff[8]; OSMesg sSerialThreadMsgBuff[8];
OSMesgQueue gControllerMesgQueue; OSMesgQueue gControllerMesgQueue;
void* sControllerMsgBuff[1]; OSMesg sControllerMsgBuff[1];
OSMesgQueue gSaveMesgQueue; OSMesgQueue gSaveMesgQueue;
void* sSaveMsgBuff[1]; OSMesg sSaveMsgBuff[1];
OSMesgQueue gTimerTaskMesgQueue; OSMesgQueue gTimerTaskMesgQueue;
void* sTimerTaskMsgBuff[16]; OSMesg sTimerTaskMsgBuff[16];
OSMesgQueue gTimerWaitMesgQueue; OSMesgQueue gTimerWaitMesgQueue;
void* sTimerWaitMsgBuff[1]; OSMesg sTimerWaitMsgBuff[1];
GfxPool gGfxPools[2]; GfxPool gGfxPools[2];
@ -103,8 +103,9 @@ void Main_Initialize(void) {
} }
void Audio_ThreadEntry(void* arg0) { void Audio_ThreadEntry(void* arg0) {
SPTask* task; // SPTask* task;
<<<<<<< HEAD
AudioLoad_Init(); AudioLoad_Init();
Audio_InitSounds(); Audio_InitSounds();
@ -128,6 +129,30 @@ void Audio_ThreadEntry(void* arg0) {
} }
MQ_WAIT_FOR_MESG(&gAudioVImesgQueue, NULL); MQ_WAIT_FOR_MESG(&gAudioVImesgQueue, NULL);
} }
=======
// AudioLoad_Init();
// Audio_InitSounds();
// task = AudioThread_CreateTask();
// if (task != NULL) {
// task->msgQueue = &gAudioTaskMsgQueue;
// task->msg = OS_MESG_32(TASK_MESG_1);
// osWritebackDCacheAll();
// osSendMesg(&gTaskMsgQueue, OS_MESG_PTR(task), OS_MESG_PRI_NORMAL);
// }
// while (true) {
// task = AudioThread_CreateTask();
// if (task != NULL) {
// task->msgQueue = &gAudioTaskMsgQueue;
// task->msg = OS_MESG_32(TASK_MESG_1);
// osWritebackDCacheAll();
// }
// MQ_GET_MESG(&gAudioTaskMesgQueue, NULL);
// if (task != NULL) {
// osSendMesg(&gTaskMsgQueue, OS_MESG_PTR(task), OS_MESG_PRI_NORMAL);
// }
// MQ_WAIT_FOR_MESG(&gAudioVImesgQueue, NULL);
// }
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
void Graphics_SetTask(void) { void Graphics_SetTask(void) {
@ -213,9 +238,15 @@ void SerialInterface_ThreadUpdate() {
void Timer_ThreadEntry(void* arg0) { void Timer_ThreadEntry(void* arg0) {
OSMesg sp24; OSMesg sp24;
<<<<<<< HEAD
while (true) { while (true) {
MQ_WAIT_FOR_MESG(&gTimerTaskMesgQueue, &sp24); MQ_WAIT_FOR_MESG(&gTimerTaskMesgQueue, &sp24);
// Timer_CompleteTask(sp24); // Timer_CompleteTask(sp24);
=======
while (1) {
osRecvMesg(&gTimerTaskMesgQueue, &sp24, OS_MESG_BLOCK);
// Timer_CompleteTask(sp24.ptr);
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
} }
} }
@ -227,10 +258,10 @@ void Graphics_ThreadEntry(void* arg0) {
u8 validVIsPerFrame; u8 validVIsPerFrame;
Game_Initialize(); Game_Initialize();
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL); osSendMesg(&gSerialThreadMesgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL);
Graphics_InitializeTask(gSysFrameCount); Graphics_InitializeTask(gSysFrameCount);
{ {
gSPSegment(gUnkDisp1++, 0, 0); __gSPSegment(gUnkDisp1++, 0, 0);
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1); gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1);
Game_Update(); Game_Update();
gSPEndDisplayList(gUnkDisp1++); gSPEndDisplayList(gUnkDisp1++);
@ -254,15 +285,15 @@ void Graphics_ThreadUpdate() {
gSysFrameCount++; gSysFrameCount++;
Graphics_InitializeTask(gSysFrameCount); Graphics_InitializeTask(gSysFrameCount);
osRecvMesg(&gControllerMsgQueue, NULL, OS_MESG_NOBLOCK); osRecvMesg(&gControllerMesgQueue, NULL, OS_MESG_NOBLOCK);
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_RUMBLE), OS_MESG_PRI_NORMAL); osSendMesg(&gSerialThreadMesgQueue, OS_MESG_32(SI_RUMBLE), OS_MESG_PRI_NORMAL);
Controller_UpdateInput(); Controller_UpdateInput();
Controller_ReadData(); Controller_ReadData();
Controller_Rumble(); Controller_Rumble();
osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL); osSendMesg(&gSerialThreadMesgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL);
Main_SetVIMode(); Main_SetVIMode();
{ {
gSPSegment(gUnkDisp1++, 0, 0); __gSPSegment(gUnkDisp1++, 0, 0);
gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1); gSPDisplayList(gMasterDisp++, gGfxPool->unkDL1);
Game_Update(); Game_Update();
if (gStartNMI == 1) { if (gStartNMI == 1) {
@ -274,7 +305,7 @@ void Graphics_ThreadUpdate() {
gDPFullSync(gMasterDisp++); gDPFullSync(gMasterDisp++);
gSPEndDisplayList(gMasterDisp++); gSPEndDisplayList(gMasterDisp++);
} }
osRecvMesg(&gGfxTaskMsgQueue, NULL, OS_MESG_BLOCK); osRecvMesg(&gGfxTaskMesgQueue, NULL, OS_MESG_BLOCK);
Graphics_SetTask(); Graphics_SetTask();
if (GfxDebuggerIsDebuggingRequested()) { if (GfxDebuggerIsDebuggingRequested()) {
@ -310,16 +341,16 @@ void Main_InitMesgQueues(void) {
osCreateMesgQueue(&gGfxTaskMesgQueue, sGfxTaskMsgBuff, ARRAY_COUNT(sGfxTaskMsgBuff)); osCreateMesgQueue(&gGfxTaskMesgQueue, sGfxTaskMsgBuff, ARRAY_COUNT(sGfxTaskMsgBuff));
osCreateMesgQueue(&gSerialEventQueue, sSerialEventBuff, ARRAY_COUNT(sSerialEventBuff)); osCreateMesgQueue(&gSerialEventQueue, sSerialEventBuff, ARRAY_COUNT(sSerialEventBuff));
osSetEventMesg(OS_EVENT_SI, &gSerialEventQueue, OS_MESG_PTR(NULL)); osSetEventMesg(OS_EVENT_SI, &gSerialEventQueue, OS_MESG_PTR(NULL));
osCreateMesgQueue(&gMainThreadMsgQueue, sMainThreadMsgBuff, ARRAY_COUNT(sMainThreadMsgBuff)); osCreateMesgQueue(&gMainThreadMesgQueue, sMainThreadMsgBuff, ARRAY_COUNT(sMainThreadMsgBuff));
osViSetEvent(&gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_VI), 1); osViSetEvent(&gMainThreadMesgQueue, OS_MESG_32(EVENT_MESG_VI), 1);
osSetEventMesg(OS_EVENT_SP, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_SP)); osSetEventMesg(OS_EVENT_SP, &gMainThreadMesgQueue, OS_MESG_32(EVENT_MESG_SP));
osSetEventMesg(OS_EVENT_DP, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_DP)); osSetEventMesg(OS_EVENT_DP, &gMainThreadMesgQueue, OS_MESG_32(EVENT_MESG_DP));
osSetEventMesg(OS_EVENT_PRENMI, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_PRENMI)); osSetEventMesg(OS_EVENT_PRENMI, &gMainThreadMesgQueue, OS_MESG_32(EVENT_MESG_PRENMI));
osCreateMesgQueue(&gTimerTaskMsgQueue, sTimerTaskMsgBuff, ARRAY_COUNT(sTimerTaskMsgBuff)); osCreateMesgQueue(&gTimerTaskMesgQueue, sTimerTaskMsgBuff, ARRAY_COUNT(sTimerTaskMsgBuff));
osCreateMesgQueue(&gTimerWaitMsgQueue, sTimerWaitMsgBuff, ARRAY_COUNT(sTimerWaitMsgBuff)); osCreateMesgQueue(&gTimerWaitMesgQueue, sTimerWaitMsgBuff, ARRAY_COUNT(sTimerWaitMsgBuff));
osCreateMesgQueue(&gSerialThreadMsgQueue, sSerialThreadMsgBuff, ARRAY_COUNT(sSerialThreadMsgBuff)); osCreateMesgQueue(&gSerialThreadMesgQueue, sSerialThreadMsgBuff, ARRAY_COUNT(sSerialThreadMsgBuff));
osCreateMesgQueue(&gControllerMsgQueue, sControllerMsgBuff, ARRAY_COUNT(sControllerMsgBuff)); osCreateMesgQueue(&gControllerMesgQueue, sControllerMsgBuff, ARRAY_COUNT(sControllerMsgBuff));
osCreateMesgQueue(&gSaveMsgQueue, sSaveMsgBuff, ARRAY_COUNT(sSaveMsgBuff)); osCreateMesgQueue(&gSaveMesgQueue, sSaveMsgBuff, ARRAY_COUNT(sSaveMsgBuff));
} }
void Main_HandleRDP(void) { void Main_HandleRDP(void) {
@ -356,6 +387,7 @@ void Main_HandleRSP(void) {
// } // }
} }
<<<<<<< HEAD
void Main_GetNewTasks(void) { void Main_GetNewTasks(void) {
u8 i; u8 i;
SPTask** audioTask; SPTask** audioTask;
@ -413,6 +445,8 @@ void Main_GetNewTasks(void) {
} }
} }
=======
>>>>>>> edd7dba2 (Fixed all remaining compilation issues)
void Main_StartNextTask(void) { void Main_StartNextTask(void) {
if (sAudioTasks[0] != NULL) { if (sAudioTasks[0] != NULL) {
if (gCurrentTask != NULL) { if (gCurrentTask != NULL) {

View File

@ -1,6 +1,6 @@
#include "sys.h" #include "sys.h"
#define qs1616(e) ((s32) ((e) * 0x00010000)) #define qs1616(e) ((s32) ((e) *0x00010000))
#define IPART(x) ((qs1616(x) >> 16) & 0xFFFF) #define IPART(x) ((qs1616(x) >> 16) & 0xFFFF)
#define FPART(x) (qs1616(x) & 0xFFFF) #define FPART(x) (qs1616(x) & 0xFFFF)
@ -17,12 +17,8 @@
} \ } \
} }
Mtx gIdentityMtx = gdSPDefMtx( Mtx gIdentityMtx =
1.0f, 0.0f, 0.0f, 0.0f, gdSPDefMtx(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);
Matrix gIdentityMatrix = { { Matrix gIdentityMatrix = { {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
@ -32,9 +28,9 @@ Matrix gIdentityMatrix = { {
} }; } };
Matrix* gGfxMatrix; Matrix* gGfxMatrix;
Matrix sGfxMatrixStack[0x150]; Matrix sGfxMatrixStack[0x20];
Matrix* gCalcMatrix; Matrix* gCalcMatrix;
Matrix sCalcMatrixStack[0x150]; Matrix sCalcMatrixStack[0x20];
// Copies src Matrix into dst // Copies src Matrix into dst
void Matrix_Copy(Matrix* dst, Matrix* src) { void Matrix_Copy(Matrix* dst, Matrix* src) {
@ -65,211 +61,72 @@ void Matrix_Mult(Matrix* mtx, Matrix* tf, u8 mode) {
f32 ry; f32 ry;
f32 rz; f32 rz;
f32 rw; f32 rw;
s32 i0;
//---COL1--- s32 i1;
f32 cx = mfB->xx; s32 i2;
f32 cy = mfB->xy; s32 i3;
f32 cz = mfB->xz;
f32 cw = mfB->xw;
//--------
rx = mfA->xx;
ry = mfA->yx;
rz = mfA->zx;
rw = mfA->wx;
dest->xx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xy;
ry = mfA->yy;
rz = mfA->zy;
rw = mfA->wy;
dest->xy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xz;
ry = mfA->yz;
rz = mfA->zz;
rw = mfA->wz;
dest->xz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xw;
ry = mfA->yw;
rz = mfA->zw;
rw = mfA->ww;
dest->xw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
//---2Col---
cx = mfB->yx;
cy = mfB->yy;
cz = mfB->yz;
cw = mfB->yw;
//--------
rx = mfA->xx;
ry = mfA->yx;
rz = mfA->zx;
rw = mfA->wx;
dest->yx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xy;
ry = mfA->yy;
rz = mfA->zy;
rw = mfA->wy;
dest->yy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xz;
ry = mfA->yz;
rz = mfA->zz;
rw = mfA->wz;
dest->yz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xw;
ry = mfA->yw;
rz = mfA->zw;
rw = mfA->ww;
dest->yw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
//---3Col---
cx = mfB->zx;
cy = mfB->zy;
cz = mfB->zz;
cw = mfB->zw;
//--------
rx = mfA->xx;
ry = mfA->yx;
rz = mfA->zx;
rw = mfA->wx;
dest->zx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xy;
ry = mfA->yy;
rz = mfA->zy;
rw = mfA->wy;
dest->zy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xz;
ry = mfA->yz;
rz = mfA->zz;
rw = mfA->wz;
dest->zz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xw;
ry = mfA->yw;
rz = mfA->zw;
rw = mfA->ww;
dest->zw = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
//---4Col---
cx = mfB->wx;
cy = mfB->wy;
cz = mfB->wz;
cw = mfB->ww;
//--------
rx = mfA->xx;
ry = mfA->yx;
rz = mfA->zx;
rw = mfA->wx;
dest->wx = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xy;
ry = mfA->yy;
rz = mfA->zy;
rw = mfA->wy;
dest->wy = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xz;
ry = mfA->yz;
rz = mfA->zz;
rw = mfA->wz;
dest->wz = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
rx = mfA->xw;
ry = mfA->yw;
rz = mfA->zw;
rw = mfA->ww;
dest->ww = (cx * rx) + (cy * ry) + (cz * rz) + (cw * rw);
}
void Matrix_MtxFCopy(MtxF* dest, MtxF* src) {
dest->xx = src->xx;
dest->yx = src->yx;
dest->zx = src->zx;
dest->wx = src->wx;
dest->xy = src->xy;
dest->yy = src->yy;
dest->zy = src->zy;
dest->wy = src->wy;
dest->xx = src->xx;
dest->yx = src->yx;
dest->zx = src->zx;
dest->wx = src->wx;
dest->xy = src->xy;
dest->yy = src->yy;
dest->zy = src->zy;
dest->wy = src->wy;
dest->xz = src->xz;
dest->yz = src->yz;
dest->zz = src->zz;
dest->wz = src->wz;
dest->xw = src->xw;
dest->yw = src->yw;
dest->zw = src->zw;
dest->ww = src->ww;
dest->xz = src->xz;
dest->yz = src->yz;
dest->zz = src->zz;
dest->wz = src->wz;
dest->xw = src->xw;
dest->yw = src->yw;
dest->zw = src->zw;
dest->ww = src->ww;
}
// Copies tf into mtx (MTXMODE_NEW) or applies it to mtx (MTXMODE_APPLY)
void Matrix_Mult(Matrix* mtx, Matrix* tf, u8 mode) {
MtxF* cmf = mtx->m;
if (mode == 1) { if (mode == 1) {
MtxFMtxFMult(cmf, tf->m, cmf); rx = mtx->m[0][0];
ry = mtx->m[1][0];
rz = mtx->m[2][0];
rw = mtx->m[3][0];
for (i0 = 0; i0 < 4; i0++) {
mtx->m[i0][0] = (rx * tf->m[i0][0]) + (ry * tf->m[i0][1]) + (rz * tf->m[i0][2]) + (rw * tf->m[i0][3]);
}
rx = mtx->m[0][1];
ry = mtx->m[1][1];
rz = mtx->m[2][1];
rw = mtx->m[3][1];
for (i1 = 0; i1 < 4; i1++) {
mtx->m[i1][1] = (rx * tf->m[i1][0]) + (ry * tf->m[i1][1]) + (rz * tf->m[i1][2]) + (rw * tf->m[i1][3]);
}
rx = mtx->m[0][2];
ry = mtx->m[1][2];
rz = mtx->m[2][2];
rw = mtx->m[3][2];
for (i2 = 0; i2 < 4; i2++) {
mtx->m[i2][2] = (rx * tf->m[i2][0]) + (ry * tf->m[i2][1]) + (rz * tf->m[i2][2]) + (rw * tf->m[i2][3]);
}
rx = mtx->m[0][3];
ry = mtx->m[1][3];
rz = mtx->m[2][3];
rw = mtx->m[3][3];
for (i3 = 0; i3 < 4; i3++) {
mtx->m[i3][3] = (rx * tf->m[i3][0]) + (ry * tf->m[i3][1]) + (rz * tf->m[i3][2]) + (rw * tf->m[i3][3]);
}
} else { } else {
Matrix_MtxFCopy(cmf, tf->m); Matrix_Copy(mtx, tf);
} }
} }
// Creates a translation matrix in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY) // Creates a translation matrix in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY)
void Matrix_Translate(Matrix* mtx, f32 x, f32 y, f32 z, u8 mode) { void Matrix_Translate(Matrix* mtx, f32 x, f32 y, f32 z, u8 mode) {
MtxF* cmf = mtx->m; f32 rx;
f32 tempX; f32 ry;
f32 tempY; s32 i;
if (mode == 1) { if (mode == 1) {
tempX = cmf->xx; for (i = 0; i < 4; i++) {
tempY = cmf->xy; rx = mtx->m[0][i];
cmf->xw += tempX * x + tempY * y + cmf->xz * z; ry = mtx->m[1][i];
tempX = cmf->yx;
tempY = cmf->yy; mtx->m[3][i] += (rx * x) + (ry * y) + (mtx->m[2][i] * z);
cmf->yw += tempX * x + tempY * y + cmf->yz * z; }
tempX = cmf->zx;
tempY = cmf->zy;
cmf->zw += tempX * x + tempY * y + cmf->zz * z;
tempX = cmf->wx;
tempY = cmf->wy;
cmf->ww += tempX * x + tempY * y + cmf->wz * z;
} else { } else {
cmf->yx = 0.0f; mtx->m[3][0] = x;
cmf->zx = 0.0f; mtx->m[3][1] = y;
cmf->wx = 0.0f; mtx->m[3][2] = z;
cmf->xy = 0.0f; mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] =
cmf->zy = 0.0f; mtx->m[2][1] = mtx->m[2][3] = 0.0f;
cmf->wy = 0.0f; mtx->m[0][0] = mtx->m[1][1] = mtx->m[2][2] = mtx->m[3][3] = 1.0f;
cmf->xz = 0.0f;
cmf->yz = 0.0f;
cmf->wz = 0.0f;
cmf->xx = 1.0f;
cmf->yy = 1.0f;
cmf->zz = 1.0f;
cmf->ww = 1.0f;
cmf->xw = x;
cmf->yw = y;
cmf->zw = z;
} }
} }
@ -280,35 +137,21 @@ void Matrix_Scale(Matrix* mtx, f32 xScale, f32 yScale, f32 zScale, u8 mode) {
s32 i; s32 i;
if (mode == 1) { if (mode == 1) {
cmf->xx *= x; for (i = 0; i < 4; i++) {
cmf->yx *= x; rx = mtx->m[0][i];
cmf->zx *= x; ry = mtx->m[1][i];
cmf->xy *= y;
cmf->yy *= y; mtx->m[0][i] = rx * xScale;
cmf->zy *= y; mtx->m[1][i] = ry * yScale;
cmf->xz *= z; mtx->m[2][i] *= zScale;
cmf->yz *= z; }
cmf->zz *= z;
cmf->wx *= x;
cmf->wy *= y;
cmf->wz *= z;
} else { } else {
cmf->yx = 0.0f; mtx->m[0][0] = xScale;
cmf->zx = 0.0f; mtx->m[1][1] = yScale;
cmf->wx = 0.0f; mtx->m[2][2] = zScale;
cmf->xy = 0.0f; mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] =
cmf->zy = 0.0f; mtx->m[2][1] = mtx->m[2][3] = mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f;
cmf->wy = 0.0f; mtx->m[3][3] = 1.0f;
cmf->xz = 0.0f;
cmf->yz = 0.0f;
cmf->wz = 0.0f;
cmf->xw = 0.0f;
cmf->yw = 0.0f;
cmf->zw = 0.0f;
cmf->ww = 1.0f;
cmf->xx = x;
cmf->yy = y;
cmf->zz = z;
} }
} }
@ -320,60 +163,23 @@ void Matrix_RotateX(Matrix* mtx, f32 angle, u8 mode) {
f32 rz; f32 rz;
s32 i; s32 i;
sn = __sinf(angle);
cs = __cosf(angle);
if (mode == 1) { if (mode == 1) {
if (x != 0) { for (i = 0; i < 4; i++) {
cmf = mtx->m; ry = mtx->m[1][i];
rz = mtx->m[2][i];
sin = __sinf(x); mtx->m[1][i] = (ry * cs) + (rz * sn);
cos = __cosf(x); mtx->m[2][i] = (rz * cs) - (ry * sn);
tempY = cmf->xy;
tempZ = cmf->xz;
cmf->xy = tempY * cos + tempZ * sin;
cmf->xz = tempZ * cos - tempY * sin;
tempY = cmf->yy;
tempZ = cmf->yz;
cmf->yy = tempY * cos + tempZ * sin;
cmf->yz = tempZ * cos - tempY * sin;
tempY = cmf->zy;
tempZ = cmf->zz;
cmf->zy = tempY * cos + tempZ * sin;
cmf->zz = tempZ * cos - tempY * sin;
tempY = cmf->wy;
tempZ = cmf->wz;
cmf->wy = tempY * cos + tempZ * sin;
cmf->wz = tempZ * cos - tempY * sin;
} }
} else { } else {
cmf = mtx->m; mtx->m[1][1] = mtx->m[2][2] = cs;
mtx->m[1][2] = sn;
if (x != 0) { mtx->m[2][1] = -sn;
sin = __sinf(x); mtx->m[0][0] = mtx->m[3][3] = 1.0f;
cos = __cosf(x); mtx->m[0][1] = mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][3] = mtx->m[2][0] = mtx->m[2][3] =
} else { mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f;
sin = zero;
cos = one;
}
cmf->xx = one;
cmf->yx = zero;
cmf->zx = zero;
cmf->wx = zero;
cmf->xy = zero;
cmf->yy = cos;
cmf->zy = sin;
cmf->wy = zero;
cmf->xz = zero;
cmf->yz = -sin;
cmf->zz = cos;
cmf->wz = zero;
cmf->xw = zero;
cmf->yw = zero;
cmf->zw = zero;
cmf->ww = one;
} }
} }
@ -385,60 +191,23 @@ void Matrix_RotateY(Matrix* mtx, f32 angle, u8 mode) {
f32 rz; f32 rz;
s32 i; s32 i;
sn = __sinf(angle);
cs = __cosf(angle);
if (mode == 1) { if (mode == 1) {
if (y != 0.0f) { for (i = 0; i < 4; i++) {
cmf = mtx->m; rx = mtx->m[0][i];
rz = mtx->m[2][i];
sin = __sinf(y); mtx->m[0][i] = (rx * cs) - (rz * sn);
cos = __cosf(y); mtx->m[2][i] = (rx * sn) + (rz * cs);
tempX = cmf->xx;
tempZ = cmf->xz;
cmf->xx = tempX * cos - tempZ * sin;
cmf->xz = tempX * sin + tempZ * cos;
tempX = cmf->yx;
tempZ = cmf->yz;
cmf->yx = tempX * cos - tempZ * sin;
cmf->yz = tempX * sin + tempZ * cos;
tempX = cmf->zx;
tempZ = cmf->zz;
cmf->zx = tempX * cos - tempZ * sin;
cmf->zz = tempX * sin + tempZ * cos;
tempX = cmf->wx;
tempZ = cmf->wz;
cmf->wx = tempX * cos - tempZ * sin;
cmf->wz = tempX * sin + tempZ * cos;
} }
} else { } else {
cmf = mtx->m; mtx->m[0][0] = mtx->m[2][2] = cs;
mtx->m[0][2] = -sn;
if (y != 0.0f) { mtx->m[2][0] = sn;
sin = __sinf(y); mtx->m[1][1] = mtx->m[3][3] = 1.0f;
cos = __cosf(y); mtx->m[0][1] = mtx->m[0][3] = mtx->m[1][0] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][1] = mtx->m[2][3] =
} else { mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f;
cos = one;
sin = zero;
}
cmf->yx = zero;
cmf->wx = zero;
cmf->xy = zero;
cmf->zy = zero;
cmf->wy = zero;
cmf->yz = zero;
cmf->wz = zero;
cmf->xw = zero;
cmf->yw = zero;
cmf->zw = zero;
cmf->yy = one;
cmf->ww = one;
cmf->xx = cos;
cmf->zz = cos;
cmf->zx = -sin;
cmf->xz = sin;
} }
} }
@ -450,154 +219,117 @@ void Matrix_RotateZ(Matrix* mtx, f32 angle, u8 mode) {
f32 ry; f32 ry;
s32 i; s32 i;
sn = __sinf(angle);
cs = __cosf(angle);
if (mode == 1) { if (mode == 1) {
if (z != 0) { for (i = 0; i < 4; i++) {
cmf = mtx->m; rx = mtx->m[0][i];
ry = mtx->m[1][i];
sin = __sinf(z); mtx->m[0][i] = (rx * cs) + (ry * sn);
cos = __cosf(z); mtx->m[1][i] = (ry * cs) - (rx * sn);
tempX = cmf->xx;
tempY = cmf->xy;
cmf->xx = tempX * cos + tempY * sin;
cmf->xy = tempY * cos - tempX * sin;
tempX = cmf->yx;
tempY = cmf->yy;
cmf->yx = tempX * cos + tempY * sin;
cmf->yy = tempY * cos - tempX * sin;
tempX = cmf->zx;
tempY = cmf->zy;
cmf->zx = tempX * cos + tempY * sin;
cmf->zy = tempY * cos - tempX * sin;
tempX = cmf->wx;
tempY = cmf->wy;
cmf->wx = tempX * cos + tempY * sin;
cmf->wy = tempY * cos - tempX * sin;
} }
} else { } else {
cmf = mtx->m; mtx->m[0][0] = mtx->m[1][1] = cs;
mtx->m[0][1] = sn;
if (z != 0) { mtx->m[1][0] = -sn;
sin = __sinf(z); mtx->m[2][2] = mtx->m[3][3] = 1.0f;
cos = __cosf(z); mtx->m[0][2] = mtx->m[0][3] = mtx->m[1][2] = mtx->m[1][3] = mtx->m[2][0] = mtx->m[2][1] = mtx->m[2][3] =
} else { mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f;
sin = 0.0f;
cos = 1.0f;
}
cmf->zx = 0.0f;
cmf->wx = 0.0f;
cmf->zy = 0.0f;
cmf->wy = 0.0f;
cmf->xz = 0.0f;
cmf->yz = 0.0f;
cmf->wz = 0.0f;
cmf->xw = 0.0f;
cmf->yw = 0.0f;
cmf->zw = 0.0f;
cmf->zz = 1.0f;
cmf->ww = 1.0f;
cmf->xx = cos;
cmf->yy = cos;
cmf->yx = sin;
cmf->xy = -sin;
} }
} }
// Creates rotation matrix about a given vector axis in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY). // Creates rotation matrix about a given vector axis in mtx (MTXF_NEW) or applies one to mtx (MTXF_APPLY).
// The vector specifying the axis does not need to be a unit vector. // The vector specifying the axis does not need to be a unit vector.
void Matrix_RotateAxis(Matrix* mtx, f32 angle, f32 x, f32 y, f32 z, u8 mode) { void Matrix_RotateAxis(Matrix* mtx, f32 angle, f32 axisX, f32 axisY, f32 axisZ, u8 mode) {
MtxF* cmf; f32 rx;
f32 sin; f32 ry;
f32 cos; f32 rz;
f32 versin; f32 norm;
f32 temp1; f32 cxx;
f32 temp2; f32 cyx;
f32 temp3; f32 czx;
f32 temp4; f32 cxy;
f32 cyy;
f32 czy;
f32 cxz;
f32 cyz;
f32 czz;
f32 xx;
f32 yy;
f32 zz;
f32 xy;
f32 yz;
f32 xz;
f32 sinA;
f32 cosA;
if (mode == 1) { norm = sqrtf((axisX * axisX) + (axisY * axisY) + (axisZ * axisZ));
if (angle != 0) { if (norm != 0.0) {
cmf = mtx->m; axisX /= norm;
axisY /= norm;
axisZ /= norm;
sinA = __sinf(angle);
cosA = __cosf(angle);
xx = axisX * axisX;
yy = axisY * axisY;
zz = axisZ * axisZ;
xy = axisX * axisY;
yz = axisY * axisZ;
xz = axisX * axisZ;
sin = __sinf(angle); if (mode == 1) {
cos = __cosf(angle); cxx = (1.0f - xx) * cosA + xx;
cyx = (1.0f - cosA) * xy + axisZ * sinA;
czx = (1.0f - cosA) * xz - axisY * sinA;
temp1 = cmf->xx; cxy = (1.0f - cosA) * xy - axisZ * sinA;
temp2 = cmf->xy; cyy = (1.0f - yy) * cosA + yy;
temp3 = cmf->xz; czy = (1.0f - cosA) * yz + axisX * sinA;
temp4 = (x * temp1 + y * temp2 + z * temp3) * (1.0f - cos);
cmf->xx = temp1 * cos + x * temp4 + sin * (temp2 * z - temp3 * y);
cmf->xy = temp2 * cos + y * temp4 + sin * (temp3 * x - temp1 * z);
cmf->xz = temp3 * cos + z * temp4 + sin * (temp1 * y - temp2 * x);
temp1 = cmf->yx; cxz = (1.0f - cosA) * xz + axisY * sinA;
temp2 = cmf->yy; cyz = (1.0f - cosA) * yz - axisX * sinA;
temp3 = cmf->yz; czz = (1.0f - zz) * cosA + zz;
temp4 = (x * temp1 + y * temp2 + z * temp3) * (1.0f - cos);
cmf->yx = temp1 * cos + x * temp4 + sin * (temp2 * z - temp3 * y);
cmf->yy = temp2 * cos + y * temp4 + sin * (temp3 * x - temp1 * z);
cmf->yz = temp3 * cos + z * temp4 + sin * (temp1 * y - temp2 * x);
temp1 = cmf->zx; // loop doesn't seem to work here.
temp2 = cmf->zy; rx = mtx->m[0][0];
temp3 = cmf->zz; ry = mtx->m[0][1];
temp4 = (x * temp1 + y * temp2 + z * temp3) * (1.0f - cos); rz = mtx->m[0][2];
cmf->zx = temp1 * cos + x * temp4 + sin * (temp2 * z - temp3 * y); mtx->m[0][0] = (rx * cxx) + (ry * cxy) + (rz * cxz);
cmf->zy = temp2 * cos + y * temp4 + sin * (temp3 * x - temp1 * z); mtx->m[0][1] = (rx * cyx) + (ry * cyy) + (rz * cyz);
cmf->zz = temp3 * cos + z * temp4 + sin * (temp1 * y - temp2 * x); mtx->m[0][2] = (rx * czx) + (ry * czy) + (rz * czz);
}
} else {
cmf = mtx->m;
if (angle != 0) { rx = mtx->m[1][0];
sin = __sinf(angle); ry = mtx->m[1][1];
cos = __cosf(angle); rz = mtx->m[1][2];
versin = 1.0f - cos; mtx->m[1][0] = (rx * cxx) + (ry * cxy) + (rz * cxz);
mtx->m[1][1] = (rx * cyx) + (ry * cyy) + (rz * cyz);
mtx->m[1][2] = (rx * czx) + (ry * czy) + (rz * czz);
cmf->xx = x * x * versin + cos; rx = mtx->m[2][0];
cmf->yy = y * y * versin + cos; ry = mtx->m[2][1];
cmf->zz = z * z * versin + cos; rz = mtx->m[2][2];
mtx->m[2][0] = (rx * cxx) + (ry * cxy) + (rz * cxz);
if (0) {} mtx->m[2][1] = (rx * cyx) + (ry * cyy) + (rz * cyz);
mtx->m[2][2] = (rx * czx) + (ry * czy) + (rz * czz);
temp2 = x * versin * y;
temp3 = z * sin;
cmf->yx = temp2 + temp3;
cmf->xy = temp2 - temp3;
temp2 = x * versin * z;
temp3 = y * sin;
cmf->zx = temp2 - temp3;
cmf->xz = temp2 + temp3;
temp2 = y * versin * z;
temp3 = x * sin;
cmf->zy = temp2 + temp3;
cmf->yz = temp2 - temp3;
cmf->wx = cmf->wy = cmf->wz = cmf->xw = cmf->yw = cmf->zw = 0.0f;
cmf->ww = 1.0f;
} else { } else {
cmf->xx = 1.0f; mtx->m[0][0] = (1.0f - xx) * cosA + xx;
cmf->yx = 0.0f; mtx->m[0][1] = (1.0f - cosA) * xy + axisZ * sinA;
cmf->zx = 0.0f; mtx->m[0][2] = (1.0f - cosA) * xz - axisY * sinA;
cmf->wx = 0.0f; mtx->m[0][3] = 0.0f;
cmf->xy = 0.0f;
cmf->yy = 1.0f; mtx->m[1][0] = (1.0f - cosA) * xy - axisZ * sinA;
cmf->zy = 0.0f; mtx->m[1][1] = (1.0f - yy) * cosA + yy;
cmf->wy = 0.0f; mtx->m[1][2] = (1.0f - cosA) * yz + axisX * sinA;
cmf->xz = 0.0f; mtx->m[1][3] = 0.0f;
cmf->yz = 0.0f;
cmf->zz = 1.0f; mtx->m[2][0] = (1.0f - cosA) * xz + axisY * sinA;
cmf->wz = 0.0f; mtx->m[2][1] = (1.0f - cosA) * yz - axisX * sinA;
cmf->xw = 0.0f; mtx->m[2][2] = (1.0f - zz) * cosA + zz;
cmf->yw = 0.0f; mtx->m[2][3] = 0.0f;
cmf->zw = 0.0f;
cmf->ww = 1.0f; mtx->m[3][0] = mtx->m[3][1] = mtx->m[3][2] = 0.0f;
mtx->m[3][3] = 1.0f;
} }
} }
} }