Skip to content

Commit

Permalink
Merge branch 'master' into avoid-ub-on-course-segment
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaMech authored Jul 22, 2024
2 parents 371fe06 + 84680fa commit 7dfedc1
Show file tree
Hide file tree
Showing 47 changed files with 455 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/doxygen-and-linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install Doxygen
run: |
sudo apt-get install graphviz doxygen
wget https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz
wget https://www.doxygen.nl/files/doxygen-1.11.0.linux.bin.tar.gz
tar -xzf doxygen-*.linux.bin.tar.gz
- name: make badge
Expand Down
2 changes: 1 addition & 1 deletion docs/basics/controlflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ After boot, the game begins by setting up its four threads; [idle](@ref thread1_

The [idle thread](@ref thread1_idle) allows the cpu to sleep. Without it, if at any time execution of all threads were paused, the cpu would never be able to continue. The idle thread is active if all the other threads are paused.

As such, the [idle thread](@ref thread1_idle) runs the following loop: `while(TRUE);` (it runs in a perpetual loop of nothing; sleep). In mips assembly it looks like this:
As such, the [idle thread](@ref thread1_idle) runs the following loop: `while(true);` (it runs in a perpetual loop of nothing; sleep). In mips assembly it looks like this:
```
.L800005B8:
b .L800005B8
Expand Down
8 changes: 4 additions & 4 deletions enhancements/flycam.patch
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ index 0000000..5569838
+#define SENSITIVITY_X 0.0003f
+#define SENSITIVITY_Y 0.0003f
+
+u32 isFlycam = FALSE;
+u32 isFlycam = false;
+u32 fRankIndex = 0;
+u32 fTargetPlayer = FALSE;
+u32 fTargetPlayer = false;
+u32 fMode; // flycam mode should probably be an enum
+u32 fModeInit = FALSE;
+u32 fModeInit = false;
+
+typedef struct {
+ Vec3f pos;
Expand Down Expand Up @@ -217,7 +217,7 @@ index 0000000..5569838
+ fState.rot[0] = camera->rot[0];
+ fState.rot[1] = camera->rot[1];
+ fState.rot[2] = camera->rot[2];
+ fModeInit = TRUE;
+ fModeInit = true;
+}
+
+void flycam_load_state(Camera *camera) {
Expand Down
7 changes: 4 additions & 3 deletions include/PR/ultratypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#define NULL (void *)0
#endif

#define TRUE 1
#define FALSE 0
#define true 1
#define false 0

typedef signed char s8;
typedef unsigned char u8;
Expand All @@ -17,7 +17,8 @@ typedef unsigned int u32;
typedef signed long long int s64;
typedef unsigned long long int u64;

typedef signed int bool;
#define bool signed int

typedef signed char bool8;
typedef unsigned char ubool8;

Expand Down
12 changes: 6 additions & 6 deletions src/audio/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 reca
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
layer->notePropertiesNeedInit = FALSE;
layer->notePropertiesNeedInit = false;
} else {
if (seqChannel->changes.as_bitfields.freqScale) {
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
Expand All @@ -52,7 +52,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {

if (seqPlayer->fadeRemainingFrames != 0) {
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
seqPlayer->recalculateVolume = TRUE;
seqPlayer->recalculateVolume = true;

if (seqPlayer->fadeVolume > US_FLOAT2(1)) {
seqPlayer->fadeVolume = US_FLOAT2(1);
Expand All @@ -75,13 +75,13 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {

// Process channels
for (i = 0; i < CHANNELS_MAX; i++) {
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
&& seqPlayer->channels[i]->enabled == TRUE) {
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == true
&& seqPlayer->channels[i]->enabled == true) {
sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->recalculateVolume);
}
}

seqPlayer->recalculateVolume = FALSE;
seqPlayer->recalculateVolume = false;
}

f32 get_portamento_freq_scale(struct Portamento *p) {
Expand Down Expand Up @@ -176,7 +176,7 @@ void note_vibrato_init(struct Note *note) {

vib = &note->vibratoState;

vib->active = TRUE;
vib->active = true;
vib->time = 0;

vib->curve = gWaveSamples[2];
Expand Down
26 changes: 13 additions & 13 deletions src/audio/external.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,10 @@ u8 func_800C357C(s32 arg0) {
u8 i;

i = D_800EA1E8;
var_v1 = TRUE;
var_v1 = true;
for(i = D_800EA1E8; i < (s32) D_800EA1E4; i++) {
if ((u32) arg0 == D_80192CD0[i]) {
var_v1 = FALSE;
var_v1 = false;
i = D_800EA1E4;
}
}
Expand Down Expand Up @@ -1237,9 +1237,9 @@ void func_800C4084(u16 bankMask) {

for (bank = 0; bank < SOUND_BANK_COUNT; bank++) {
if (bankMask & 1) {
sSoundBankDisabled[bank] = TRUE;
sSoundBankDisabled[bank] = true;
} else {
sSoundBankDisabled[bank] = FALSE;
sSoundBankDisabled[bank] = false;
}
bankMask = bankMask >> 1;
}
Expand All @@ -1258,7 +1258,7 @@ void play_sound(u32 soundBits, Vec3f *position, u8 cameraId, f32 *arg3, f32 *arg
struct Sound *temp_v0;

bank = soundBits >> 0x1C;
if (sSoundBankDisabled[bank] == FALSE) {
if (sSoundBankDisabled[bank] == false) {
temp_v0 = &sSoundRequests[sSoundRequestCount];
temp_v0->soundBits = soundBits;
temp_v0->position = position;
Expand All @@ -1276,37 +1276,37 @@ void func_800C41CC(u8 arg0, struct SoundCharacteristics *arg1) {
struct Sound *sound;

for (soundId = sNumProcessedSoundRequests; soundId != sSoundRequestCount; soundId++) {
found = FALSE;
found = false;
sound = &sSoundRequests[soundId];
switch (arg0) {
case 0:
if ((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) {
found = TRUE;
found = true;
}
break;
case 1:
if (((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) && (sound->position == arg1->unk00)) {
found = TRUE;
found = true;
}
break;
case 2:
if (sound->position == arg1->unk00) {
found = TRUE;
found = true;
}
break;
case 3:
if ((sound->position == arg1->unk00) && (sound->soundBits == arg1->soundBits)) {
found = TRUE;
found = true;
}
break;
case 4:
if ((sound->cameraId == arg1->cameraId) && (sound->soundBits == arg1->soundBits)) {
found = TRUE;
found = true;
}
break;
case 5:
if (sound->soundBits == arg1->soundBits) {
found = TRUE;
found = true;
}
break;
}
Expand Down Expand Up @@ -1806,7 +1806,7 @@ void sound_init(void) {
sSoundBankUsedListBack[var_v0] = 0;
sSoundBankFreeListFront[var_v0] = 1;
sNumSoundsInBank[var_v0] = 0;
sSoundBankDisabled[var_v0] = FALSE;
sSoundBankDisabled[var_v0] = false;
D_80192C48[var_v0].current = 1.0f;
D_80192C48[var_v0].remainingFrames = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/audio/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ void discard_bank(s32 bankId) {
if (note->priority >= NOTE_PRIORITY_MIN) {
// eu_stubbed_printf_3("Kill Voice %d (ID %d) %d\n", note->waveId, bankId, note->priority);
// eu_stubbed_printf_0("Warning: Running Sequence's data disappear!\n");
note->parentLayer->enabled = FALSE; // is 0x48, should be 0x44
note->parentLayer->finished = TRUE;
note->parentLayer->enabled = false; // is 0x48, should be 0x44
note->parentLayer->finished = true;
}
note_disable(note);
audio_list_remove(&note->listItem);
Expand Down Expand Up @@ -380,7 +380,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
pool = &arg0->temporary.pool;
if (tp->entries[tp->nextSide].id != (s8)-1) {
table[tp->entries[tp->nextSide].id] = SOUND_LOAD_STATUS_NOT_LOADED;
if (isSound == TRUE) {
if (isSound == true) {
discard_bank(tp->entries[tp->nextSide].id);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/audio/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void decrease_sample_dma_ttls() {
}

void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
s32 hasDma = FALSE;
s32 hasDma = false;
struct SharedDma *dma;
uintptr_t dmaDevAddr;
u32 transfer;
Expand Down Expand Up @@ -199,7 +199,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
// TTL 60 is pretty large.
dmaIndex = sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2++];
dma = &sSampleDmas[dmaIndex];
hasDma = TRUE;
hasDma = true;
}
} else {
dma = &sSampleDmas[*dmaIndexRef];
Expand Down Expand Up @@ -231,7 +231,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
// be empty, since TTL 2 is so small.
dmaIndex = sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1++];
dma = &sSampleDmas[dmaIndex];
hasDma = TRUE;
hasDma = true;
}

transfer = dma->bufSize;
Expand Down Expand Up @@ -539,7 +539,7 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
seqPlayer->bankDmaRemaining = alloc;
if (1) { }
osCreateMesgQueue(&seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaMesg, 1);
seqPlayer->bankDmaInProgress = TRUE;
seqPlayer->bankDmaInProgress = true;
audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr, &seqPlayer->bankDmaRemaining, &seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaIoMesg);
if (gBankLoadStatus[bankId] != 5) {
gBankLoadStatus[bankId] = 1;
Expand Down Expand Up @@ -590,7 +590,7 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
audio_dma_copy_immediate(seqData, ptr, 0x00000040U);
mesgQueue = &seqPlayer->seqDmaMesgQueue;
osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1);
seqPlayer->seqDmaInProgress = TRUE;
seqPlayer->seqDmaInProgress = true;
audio_dma_copy_async((uintptr_t) (seqData + 0x40), (u8*) ptr + 0x40, seqLength - 0x40, mesgQueue, &seqPlayer->seqDmaIoMesg);
if (gSeqLoadStatus[seqId] != 5) {
gSeqLoadStatus[seqId] = 1;
Expand All @@ -612,7 +612,7 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) {
for (i = gAlBankSets[offset++], ret = 0; i != 0; i--) {
bankId = gAlBankSets[offset++];

if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) {
if (IS_BANK_LOAD_COMPLETE(bankId) == true) {
temp = get_bank_or_seq(1, 2, bankId);
} else {
temp = NULL;
Expand All @@ -639,7 +639,7 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank) {
for (i = gAlBankSets[offset++]; i != 0; i--) {
bankId = gAlBankSets[offset++];

if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) {
if (IS_BANK_LOAD_COMPLETE(bankId) == true) {
ret = get_bank_or_seq(1, 2, bankId);
} else {
ret = NULL;
Expand Down Expand Up @@ -672,7 +672,7 @@ void preload_sequence(u32 seqId, u8 preloadMask) {

if (preloadMask & PRELOAD_SEQUENCE) {
//! @bug should be IS_SEQ_LOAD_COMPLETE
if (IS_BANK_LOAD_COMPLETE(seqId) == TRUE) {
if (IS_BANK_LOAD_COMPLETE(seqId) == true) {
sequenceData = get_bank_or_seq(0, 2, seqId);
} else {
sequenceData = NULL;
Expand Down Expand Up @@ -753,7 +753,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
init_sequence_player(player);
seqPlayer->scriptState.depth = 0;
seqPlayer->delay = 0;
seqPlayer->enabled = TRUE;
seqPlayer->enabled = true;
seqPlayer->seqData = sequenceData;
seqPlayer->scriptState.pc = sequenceData;
}
Expand Down
Loading

0 comments on commit 7dfedc1

Please sign in to comment.