summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorMelonSpeedruns <melonspeedruns@outlook.com>2022-05-11 19:01:38 -0400
committerGitHub <noreply@github.com>2022-05-11 19:01:38 -0400
commit888662267f6df66835a4dc39b168ec26602cd7ca (patch)
treed916cf2f7b1a758539c7dd88fedabfe3cb1aa32e /soh/src/code
parente55dcfa0a0d17a0dafaba8826b1d430ef53b771a (diff)
parent3013c18e13c8cdd26dcc3ab46bb53f5936e05d14 (diff)
Merge branch 'HarbourMasters:develop' into develop
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/audio_effects.c6
-rw-r--r--soh/src/code/audio_load.c20
-rw-r--r--soh/src/code/audio_seqplayer.c4
-rw-r--r--soh/src/code/audio_synthesis.c4
-rw-r--r--soh/src/code/padmgr.c2
-rw-r--r--soh/src/code/z_actor.c10
-rw-r--r--soh/src/code/z_bgcheck.c2
-rw-r--r--soh/src/code/z_camera.c2
-rw-r--r--soh/src/code/z_camera_data.inc (renamed from soh/src/code/z_camera_data.c)0
-rw-r--r--soh/src/code/z_demo.c2
-rw-r--r--soh/src/code/z_fbdemo_circle.c4
-rw-r--r--soh/src/code/z_player_lib.c38
-rw-r--r--soh/src/code/z_skelanime.c4
-rw-r--r--soh/src/code/z_vismono.c2
14 files changed, 49 insertions, 51 deletions
diff --git a/soh/src/code/audio_effects.c b/soh/src/code/audio_effects.c
index 4813d1c63..d5aa3644f 100644
--- a/soh/src/code/audio_effects.c
+++ b/soh/src/code/audio_effects.c
@@ -246,7 +246,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
retry:
case ADSR_STATE_LOOP:
- adsr->delay = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].delay);
+ adsr->delay = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].delay);
switch (adsr->delay) {
case ADSR_DISABLE:
adsr->action.s.state = ADSR_STATE_DISABLED;
@@ -255,7 +255,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
adsr->action.s.state = ADSR_STATE_HANG;
break;
case ADSR_GOTO:
- adsr->envIndex = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg);
+ adsr->envIndex = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg);
goto retry;
case ADSR_RESTART:
adsr->action.s.state = ADSR_STATE_INITIAL;
@@ -266,7 +266,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
if (adsr->delay == 0) {
adsr->delay = 1;
}
- adsr->target = (s16)_byteswap_ushort(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
+ adsr->target = (s16)BOMSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
adsr->target = adsr->target * adsr->target;
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
adsr->action.s.state = ADSR_STATE_FADE;
diff --git a/soh/src/code/audio_load.c b/soh/src/code/audio_load.c
index ec8b7be86..7af9037a6 100644
--- a/soh/src/code/audio_load.c
+++ b/soh/src/code/audio_load.c
@@ -1058,7 +1058,7 @@ void AudioLoad_InitSwapFontSampleHeaders(SoundFontSample* sample, uintptr_t romA
size_t maxSoundFontSize = 0x3AA0; // soundFont 0 is the largest size at 0x3AA0
AdpcmLoop* loop;
AdpcmBook* book;
-
+
if (((uintptr_t)sample->loop > maxSoundFontSize) || ((uintptr_t)sample->book > maxSoundFontSize) ) {
bswapSoundFontSample(sample);
@@ -1093,7 +1093,7 @@ void AudioLoad_InitSwapFont(void) {
SoundFontSound* sfxList;
SoundFontSound* sfx;
Instrument** instList;
- Instrument* inst;
+ Instrument* inst;
// Only up to (numFonts - 1) as final font has garbage data to prevent corruption and is never used
for (fontId = 0; fontId < (numFonts - 1); fontId++) {
@@ -1110,12 +1110,12 @@ void AudioLoad_InitSwapFont(void) {
numInstruments = font->numInstruments;
// drums
- ptrs[0] = (void*)_byteswap_ulong((uintptr_t)ptrs[0]);
+ ptrs[0] = (void*)BOMSWAP32((uintptr_t)ptrs[0]);
if ((ptrs[0] != NULL) && (numDrums != 0)) {
drumList = (Drum**)BASE_ROM_OFFSET(ptrs[0]);
for (i = 0; i < numDrums; i++) {
- drumList[i] = (Drum*)_byteswap_ulong((uintptr_t)drumList[i]);
+ drumList[i] = (Drum*)BOMSWAP32((uintptr_t)drumList[i]);
if (drumList[i] != NULL) {
drum = (Drum*)BASE_ROM_OFFSET(drumList[i]);
@@ -1128,7 +1128,7 @@ void AudioLoad_InitSwapFont(void) {
}
// sfxs
- ptrs[1] = (void*)_byteswap_ulong((u32)ptrs[1]);
+ ptrs[1] = (void*)BOMSWAP32((u32)ptrs[1]);
if ((ptrs[1] != NULL) && (numSfxs != 0)) {
sfxList = (SoundFontSound*)BASE_ROM_OFFSET(ptrs[1]);
@@ -1151,7 +1151,7 @@ void AudioLoad_InitSwapFont(void) {
instList = (Instrument**)(&ptrs[2]);
for (i = 0; i < numInstruments; i++) {
- instList[i] = (Instrument*)_byteswap_ulong((uintptr_t)instList[i]);
+ instList[i] = (Instrument*)BOMSWAP32((uintptr_t)instList[i]);
if (instList[i] != NULL) {
inst = BASE_ROM_OFFSET(instList[i]);
@@ -1159,15 +1159,15 @@ void AudioLoad_InitSwapFont(void) {
if (inst->normalRangeLo != 0) {
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->lowNotesSound.sample);
- AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
+ AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
}
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->normalNotesSound.sample);
- AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
-
+ AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
+
if (inst->normalRangeHi != 0x7F) {
sample = (SoundFontSample*)BASE_ROM_OFFSET(inst->highNotesSound.sample);
- AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
+ AudioLoad_InitSwapFontSampleHeaders(sample, romAddr);
}
}
}
diff --git a/soh/src/code/audio_seqplayer.c b/soh/src/code/audio_seqplayer.c
index 03e8842e3..3dd7b811e 100644
--- a/soh/src/code/audio_seqplayer.c
+++ b/soh/src/code/audio_seqplayer.c
@@ -1323,14 +1323,14 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
case 0xB2:
offset = (u16)parameters[0];
// OTRTODO: Byteswap added for quick audio
- channel->unk_22 = _byteswap_ushort(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2)));
+ channel->unk_22 = BOMSWAP16(*(u16*)(seqPlayer->seqData + (uintptr_t)(offset + scriptState->value * 2)));
break;
case 0xB4:
channel->dynTable = (void*)&seqPlayer->seqData[channel->unk_22];
break;
case 0xB5:
// OTRTODO: Byteswap added for quick audio
- channel->unk_22 = _byteswap_ushort(((u16*)(channel->dynTable))[scriptState->value]);
+ channel->unk_22 = BOMSWAP16(((u16*)(channel->dynTable))[scriptState->value]);
break;
case 0xB6:
scriptState->value = (*channel->dynTable)[0][scriptState->value];
diff --git a/soh/src/code/audio_synthesis.c b/soh/src/code/audio_synthesis.c
index e71c6b441..037bd2ec3 100644
--- a/soh/src/code/audio_synthesis.c
+++ b/soh/src/code/audio_synthesis.c
@@ -1162,7 +1162,7 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
if (temp_v0 < nSamplesToLoad) {
repeats = ((nSamplesToLoad - temp_v0 + 0x3F) / 0x40);
if (repeats != 0) {
- aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80, 0x80);
+ aDuplicate(cmd++, repeats, DMEM_UNCOMPRESSED_NOTE, DMEM_UNCOMPRESSED_NOTE + 0x80);
}
}
synthState->samplePosInt = samplePosInt;
@@ -1225,6 +1225,6 @@ Acmd* AudioSynth_NoteApplyHeadsetPanEffects(Acmd* cmd, NoteSubEu* noteSubEu, Not
aSaveBuffer(cmd++, DMEM_NOTE_PAN_TEMP + bufLen, &synthState->synthesisBuffers->panResampleState[0x8],
ALIGN16(panShift));
}
- aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest, 0x7FFF);
+ aAddMixer(cmd++, ALIGN64(bufLen), DMEM_NOTE_PAN_TEMP, dest);
return cmd;
}
diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c
index 08c89869f..b467f5ee6 100644
--- a/soh/src/code/padmgr.c
+++ b/soh/src/code/padmgr.c
@@ -3,7 +3,9 @@
//#include <string.h>
+#ifdef _MSC_VER
extern void* __cdecl memset(_Out_writes_bytes_all_(_Size) void* _Dst, _In_ int _Val, _In_ size_t _Size);
+#endif
s32 D_8012D280 = 1;
diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c
index 9a56000ec..a9f50f687 100644
--- a/soh/src/code/z_actor.c
+++ b/soh/src/code/z_actor.c
@@ -7,13 +7,13 @@
#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "objects/object_bdoor/object_bdoor.h"
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__GNUC__)
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__GNUC__)
#include "textures/place_title_cards/g_pn_49.h"
#include "textures/place_title_cards/g_pn_01.h"
#include "textures/place_title_cards/g_pn_02.h"
@@ -765,7 +765,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx
titleCtx->texture = texture;
titleCtx->isBossCard = true;
- titleCtx->hasTranslation = hasTranslation;
+ titleCtx->hasTranslation = hasTranslation;
titleCtx->x = x;
titleCtx->y = y;
titleCtx->width = width;
@@ -774,7 +774,7 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx
titleCtx->delayTimer = 0;
}
-void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, char* texture, s32 x, s32 y,
+void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y,
s32 width, s32 height, s32 delay) {
SceneTableEntry* loadedScene = globalCtx->loadedScene;
@@ -4272,8 +4272,6 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) {
return ret;
}
-#include "z_cheap_proc.c"
-
u8 func_800353E8(GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c
index 9ce139eed..811b0bea1 100644
--- a/soh/src/code/z_bgcheck.c
+++ b/soh/src/code/z_bgcheck.c
@@ -4031,7 +4031,7 @@ s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
/**
* unused
*/
-u32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
+s32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF;
}
diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c
index 7302f9b21..94faf8124 100644
--- a/soh/src/code/z_camera.c
+++ b/soh/src/code/z_camera.c
@@ -26,7 +26,7 @@ s32 Camera_CheckWater(Camera* camera);
#define FLG_ADJSLOPE (1 << 0)
#define FLG_OFFGROUND (1 << 7)
-#include "z_camera_data.c"
+#include "z_camera_data.inc"
/*===============================================================*/
diff --git a/soh/src/code/z_camera_data.c b/soh/src/code/z_camera_data.inc
index 1f457888e..1f457888e 100644
--- a/soh/src/code/z_camera_data.c
+++ b/soh/src/code/z_camera_data.inc
diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c
index d0145fb43..f6bb7d572 100644
--- a/soh/src/code/z_demo.c
+++ b/soh/src/code/z_demo.c
@@ -2105,7 +2105,7 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) {
}
void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment) {
- if (SEGMENT_NUMBER(segment) != 0)
+ if (SEGMENT_NUMBER(segment) != 0)
{
globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(segment);
} else {
diff --git a/soh/src/code/z_fbdemo_circle.c b/soh/src/code/z_fbdemo_circle.c
index a6a46a0e4..5c8f688fa 100644
--- a/soh/src/code/z_fbdemo_circle.c
+++ b/soh/src/code/z_fbdemo_circle.c
@@ -19,9 +19,9 @@ Gfx __sCircleDList[] = {
G_AC_NONE | G_ZS_PIXEL | G_RM_XLU_SURF | G_RM_XLU_SURF2), // 4
gsDPSetCombineMode(G_CC_BLENDPEDECALA, G_CC_BLENDPEDECALA), // 5
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), // 6
- gsDPLoadTextureBlock(0xF8000000, G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7
+ gsDPLoadTextureBlock(SEG_ADDR(8, 0), G_IM_FMT_I, G_IM_SIZ_8b, 16, 64, 0, G_TX_NOMIRROR | G_TX_WRAP, // 7
G_TX_NOMIRROR | G_TX_CLAMP, 4, 6, G_TX_NOLOD, G_TX_NOLOD),
- gsSPDisplayList(0xF9000000), // 8
+ gsSPDisplayList(SEG_ADDR(9, 0)), // 8
gsSPVertex(sCircleWipeVtx, 32, 0), // 9
gsSP2Triangles(0, 1, 2, 0, 1, 3, 4, 0), // 10
gsSP2Triangles(3, 5, 6, 0, 5, 7, 8, 0), // 11
diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c
index 7f3507abd..355d323e0 100644
--- a/soh/src/code/z_player_lib.c
+++ b/soh/src/code/z_player_lib.c
@@ -654,7 +654,7 @@ u8 sEyeMouthIndexes[][2] = {
* from adult Link's object are used here.
*/
-#if defined(MODDING) || (_MSC_VER)
+#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
//TODO: Formatting
void* sEyeTextures[2][8] = {
{ gLinkAdultEyesOpenTex, gLinkAdultEyesHalfTex, gLinkAdultEyesClosedfTex, gLinkAdultEyesRollLeftTex,
@@ -670,7 +670,7 @@ void* sEyeTextures[] = {
};
#endif
-#if defined(modding) || defined(_MSC_VER)
+#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
void* sMouthTextures[2][4] = {
{
gLinkAdultMouth1Tex,
@@ -726,7 +726,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
if (eyeIndex > 7)
eyeIndex = 7;
-#if defined(MODDING) || (_MSC_VER)
+#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[gSaveContext.linkAge][eyeIndex]));
#else
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[eyeIndex]));
@@ -738,31 +738,29 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
if (mouthIndex > 3)
mouthIndex = 3;
-#if defined(MODDING) || (_MSC_VER)
+#if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[gSaveContext.linkAge][mouthIndex]));
#else
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sMouthTextures[eyeIndex]));
#endif
+ Color_RGB8 sTemp;
+ color = &sTemp;
if (tunic == PLAYER_TUNIC_KOKIRI) {
- Color_RGB8 sTemp = { CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r),
- CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g),
- CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b) };
- color = &sTemp;
+ color->r = CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r);
+ color->g = CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g);
+ color->b = CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b);
} else if (tunic == PLAYER_TUNIC_GORON) {
- Color_RGB8 sTemp = { CVar_GetS32("gTunic_Goron_Red", sTunicColors[PLAYER_TUNIC_GORON].r),
- CVar_GetS32("gTunic_Goron_Green", sTunicColors[PLAYER_TUNIC_GORON].g),
- CVar_GetS32("gTunic_Goron_Blue", sTunicColors[PLAYER_TUNIC_GORON].b) };
- color = &sTemp;
+ color->r = CVar_GetS32("gTunic_Goron_Red", sTunicColors[PLAYER_TUNIC_GORON].r);
+ color->g = CVar_GetS32("gTunic_Goron_Green", sTunicColors[PLAYER_TUNIC_GORON].g);
+ color->b = CVar_GetS32("gTunic_Goron_Blue", sTunicColors[PLAYER_TUNIC_GORON].b);
} else if (tunic == PLAYER_TUNIC_ZORA) {
- Color_RGB8 sTemp = { CVar_GetS32("gTunic_Zora_Red", sTunicColors[PLAYER_TUNIC_ZORA].r),
- CVar_GetS32("gTunic_Zora_Green", sTunicColors[PLAYER_TUNIC_ZORA].g),
- CVar_GetS32("gTunic_Zora_Blue", sTunicColors[PLAYER_TUNIC_ZORA].b) };
- color = &sTemp;
+ color->r = CVar_GetS32("gTunic_Zora_Red", sTunicColors[PLAYER_TUNIC_ZORA].r);
+ color->g = CVar_GetS32("gTunic_Zora_Green", sTunicColors[PLAYER_TUNIC_ZORA].g);
+ color->b = CVar_GetS32("gTunic_Zora_Blue", sTunicColors[PLAYER_TUNIC_ZORA].b);
} else {
- Color_RGB8 sTemp = { CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r),
- CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g),
- CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b) };
- color = &sTemp;
+ color->r = CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r);
+ color->g = CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g);
+ color->b = CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b);
}
gDPSetEnvColor(POLY_OPA_DISP++, color->r, color->g, color->b, 0);
diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c
index 2c03390e9..6dbfac7ef 100644
--- a/soh/src/code/z_skelanime.c
+++ b/soh/src/code/z_skelanime.c
@@ -863,7 +863,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader
char animPath[2048];
- sprintf(animPath, "misc\\link_animetion\\gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000)));
+ sprintf(animPath, "misc/link_animetion/gPlayerAnimData_%06X", (((uintptr_t)linkAnimHeader->segment - 0x07000000)));
//printf("Streaming %s, seg = %08X\n", animPath, linkAnimHeader->segment);
@@ -877,7 +877,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader
{
ramPtr[i] = i * 7;
}*/
-
+
//DmaMgr_SendRequest2(&entry->data.load.req, ram,
//LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame)),
diff --git a/soh/src/code/z_vismono.c b/soh/src/code/z_vismono.c
index 82acc9a17..2af876ad6 100644
--- a/soh/src/code/z_vismono.c
+++ b/soh/src/code/z_vismono.c
@@ -42,7 +42,7 @@ Gfx* VisMono_DrawTexture(VisMono* this, Gfx* gfx)
s32 y;
s32 height = 3;
//u16* tex = D_0F000000;
- u16* tex = 0xFF000000;
+ u16* tex = SEG_ADDR(0xF, 0);
gDPPipeSync(gfx++);
gDPSetOtherMode(gfx++,