Refresh 10

This commit is contained in:
n64
2020-06-02 12:44:34 -04:00
parent e58669b4b3
commit d43d9b7f20
444 changed files with 30163 additions and 7628 deletions
+9 -9
View File
@@ -1,5 +1,4 @@
#include <ultra64.h>
#include <macros.h>
#include "data.h"
#include "effects.h"
@@ -587,11 +586,12 @@ s8 gUnusedCount80333EE8 = UNUSED_COUNT_80333EE8;
s32 gAudioHeapSize = DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE);
s32 D_80333EF0 = DOUBLE_SIZE_ON_64_BIT(D_80333EF0_VAL);
volatile s32 gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
#ifdef VERSION_EU
u8 bufferDelete2[12] = { 0 };
u8 D_EU_80302010 = 0;
u8 D_EU_80302014 = 0;
struct OSMesgQueue *OSMesgQueues[4] = { &OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3 }; // { 0x80332e40, 0x80332e58, 0x80332e70, 0x80332e88 };
struct OSMesgQueue *OSMesgQueues[4] = { &OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3 };
#else
s8 sUnused8033EF8 = 24;
#endif
@@ -620,18 +620,18 @@ f32 D_EU_802298D0;
s32 gRefreshRate;
#endif
u16 *gAiBuffers[NUMAIBUFFERS];
s16 *gAiBuffers[NUMAIBUFFERS];
s16 gAiBufferLengths[NUMAIBUFFERS];
#ifdef VERSION_EU
u32 gAudioRandom;
s32 gAudioErrorFlags;
u64 gAudioGlobalsEndMarker;
#endif
#ifndef VERSION_EU
u32 gUnused80226E58[0x10];
u16 gUnused80226E98[0x10];
#endif
u32 gAudioRandom;
#ifdef VERSION_EU
s32 gAudioErrorFlags;
#endif
u64 gAudioGlobalsEndMarker;
+5 -2
View File
@@ -1,7 +1,10 @@
#ifndef AUDIO_DATA_H
#define AUDIO_DATA_H
#include <PR/ultratypes.h>
#include "internal.h"
#include "types.h"
#define AUDIO_LOCK_UNINITIALIZED 0
#define AUDIO_LOCK_NOT_LOADING 0x76557364
@@ -87,7 +90,7 @@ extern f32 D_EU_802298D0;
extern s32 gRefreshRate;
#endif
extern u16 *gAiBuffers[NUMAIBUFFERS];
extern s16 *gAiBuffers[NUMAIBUFFERS];
extern s16 gAiBufferLengths[NUMAIBUFFERS];
#ifdef VERSION_EU
#define AIBUFFER_LEN (0xa0 * 17)
@@ -112,4 +115,4 @@ extern u32 gAudioRandom;
#endif
#endif /* AUDIO_DATA_H */
#endif // AUDIO_DATA_H
-1
View File
@@ -1,5 +1,4 @@
#include <ultra64.h>
#include <macros.h>
#include "effects.h"
#include "load.h"
+3 -1
View File
@@ -1,6 +1,8 @@
#ifndef AUDIO_EFFECTS_H
#define AUDIO_EFFECTS_H
#include <PR/ultratypes.h>
#include "internal.h"
#include "platform_info.h"
@@ -41,4 +43,4 @@ f32 adsr_update(struct AdsrState *adsr);
s32 adsr_update(struct AdsrState *adsr);
#endif
#endif /* AUDIO_EFFECTS_H */
#endif // AUDIO_EFFECTS_H
+8 -11
View File
@@ -7,14 +7,11 @@
#include "external.h"
#include "playback.h"
#include "synthesis.h"
#include "game/mario.h"
#include "game/level_update.h"
#include "game/area.h"
#include "game/object_list_processor.h"
#include "game/camera.h"
#include "seq_ids.h"
#include "dialog_ids.h"
#include "level_table.h"
#ifdef VERSION_EU
#define EU_FLOAT(x) x ## f
@@ -490,7 +487,7 @@ u8 sUnused8033323C = 0; // never read, set to 0
// bss
#ifndef VERSION_EU
u16 *gCurrAiBuffer;
s16 *gCurrAiBuffer;
#endif
struct Sound sSoundRequests[0x100];
// Curiously, this has size 3, despite SEQUENCE_PLAYERS == 4 on EU
@@ -1019,7 +1016,7 @@ void func_8031E16C(u8 bankIndex) {
val = (gSoundBanks[bankIndex][soundIndex].soundBits & SOUNDARGS_MASK_PRIORITY)
>> SOUNDARGS_SHIFT_PRIORITY;
if (gSoundBanks[bankIndex][soundIndex].soundBits & SOUND_PL_BITFLAG_UNK4) {
if (gSoundBanks[bankIndex][soundIndex].soundBits & SOUND_NO_PRIORITY_LOSS) {
gSoundBanks[bankIndex][soundIndex].priority = 0x4c * (0xff - val);
} else if (*gSoundBanks[bankIndex][soundIndex].z > 0.0f) {
gSoundBanks[bankIndex][soundIndex].priority =
@@ -1163,7 +1160,7 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) {
s32 div = bankIndex < 3 ? 2 : 3;
#endif
if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK1)) {
if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_NO_VOLUME_LOSS)) {
#ifdef VERSION_JP
f0 = D_80332028[gCurrLevelNum];
if (f0 < gSoundBanks[bankIndex][item].distance) {
@@ -1186,7 +1183,7 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) {
}
#endif
if (gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK2) {
if (gSoundBanks[bankIndex][item].soundBits & SOUND_VIBRATO) {
#ifdef VERSION_JP
if (intensity != 0.0)
#else
@@ -1206,9 +1203,9 @@ f32 get_sound_dynamics(u8 bankIndex, u8 item, f32 arg2) {
f32 get_sound_freq_scale(u8 bankIndex, u8 item) {
f32 f2;
if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK8)) {
if (!(gSoundBanks[bankIndex][item].soundBits & SOUND_NO_FREQUENCY_LOSS)) {
f2 = gSoundBanks[bankIndex][item].distance / AUDIO_MAX_DISTANCE;
if (gSoundBanks[bankIndex][item].soundBits & SOUND_PL_BITFLAG_UNK2) {
if (gSoundBanks[bankIndex][item].soundBits & SOUND_VIBRATO) {
f2 += (f32)(gAudioRandom & 0xff) / US_FLOAT(64.0);
}
} else {
@@ -1308,7 +1305,7 @@ void update_game_sound(void) {
switch (bankIndex) {
case 1:
if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_PL_BITFLAG_UNK8)) {
if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_NO_FREQUENCY_LOSS)) {
if (D_80363808[bankIndex] > 8) {
#ifdef VERSION_EU
func_802ad728(0x02020000 | ((channelIndex & 0xff) << 8),
@@ -1465,7 +1462,7 @@ void update_game_sound(void) {
// computes function arguments in the wrong order).
switch (bankIndex) {
case 1:
if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_PL_BITFLAG_UNK8)) {
if (!(gSoundBanks[bankIndex][index].soundBits & SOUND_NO_FREQUENCY_LOSS)) {
if (D_80363808[bankIndex] > 8) {
#ifdef VERSION_EU
func_802ad728(0x02020000 | ((channelIndex & 0xff) << 8),
+5 -3
View File
@@ -1,6 +1,8 @@
#ifndef AUDIO_EXTERNAL_H
#define AUDIO_EXTERNAL_H
#include <PR/ultratypes.h>
#include "types.h"
// Sequence arguments, passed to play_sequence. seqId may be bit-OR'ed with
@@ -52,13 +54,13 @@ void play_star_fanfare(void);
void play_power_star_jingle(u8 arg0);
void play_race_fanfare(void);
void play_toads_jingle(void);
void sound_reset(u8 arg0);
void sound_reset(u8 presetId);
void audio_set_sound_mode(u8 arg0);
void audio_init(void); // in load.c
#ifdef VERSION_EU
struct SPTask *unused_80321460();
struct SPTask *unused_80321460(void);
#endif
#endif /* AUDIO_EXTERNAL_H */
#endif // AUDIO_EXTERNAL_H
-5
View File
@@ -1,5 +0,0 @@
#include <ultra64.h>
#ifndef VERSION_EU
u64 gAudioGlobalsEndMarker;
#endif
+1 -2
View File
@@ -1,5 +1,4 @@
#include <ultra64.h>
#include <macros.h>
#include "heap.h"
#include "data.h"
@@ -303,7 +302,7 @@ void temporary_pools_init(struct PoolSplit *a) {
}
#ifndef VERSION_EU
static void unused_803163D4() {
static void unused_803163D4(void) {
}
#endif
+3 -1
View File
@@ -1,6 +1,8 @@
#ifndef AUDIO_HEAP_H
#define AUDIO_HEAP_H
#include <PR/ultratypes.h>
#include "internal.h"
#define SOUND_LOAD_STATUS_NOT_LOADED 0
@@ -69,4 +71,4 @@ void audio_reset_session(void);
void audio_reset_session(struct AudioSessionSettings *preset);
#endif
#endif /* AUDIO_HEAP_H */
#endif // AUDIO_HEAP_H
+2 -2
View File
@@ -113,7 +113,7 @@ struct VibratoState {
// Pitch sliding by up to one octave in the positive direction. Negative
// direction is "supported" by setting extent to be negative. The code
// exterpolates exponentially in the wrong direction in that case, but that
// extrapolates exponentially in the wrong direction in that case, but that
// doesn't prevent seqplayer from doing it, AFAICT.
struct Portamento {
u8 mode; // bit 0x80 denotes something; the rest are an index 0-5
@@ -689,4 +689,4 @@ struct EuAudioCmd {
} u2;
};
#endif /* AUDIO_INTERNAL_H */
#endif // AUDIO_INTERNAL_H
+12 -4
View File
@@ -1,9 +1,9 @@
#include <ultra64.h>
#include <macros.h>
#include "load.h"
#include "heap.h"
#include "data.h"
#include "external.h"
#include "heap.h"
#include "load.h"
#include "seqplayer.h"
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
@@ -868,6 +868,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
seqPlayer->scriptState.pc = sequenceData;
}
// (void) must be omitted from parameters
void audio_init() {
#ifdef VERSION_EU
UNUSED s8 pad[16];
@@ -884,7 +885,7 @@ void audio_init() {
s32 lim2, lim3;
#endif
u32 size;
u64 *ptr64;
UNUSED u64 *ptr64;
void *data;
UNUSED s32 pad2;
@@ -902,6 +903,8 @@ void audio_init() {
((u64 *) gAudioHeap)[i] = 0;
}
#ifdef TARGET_N64
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
i = 0;
lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
ptr64 = &gAudioGlobalsStartMarker - 1;
@@ -909,16 +912,21 @@ void audio_init() {
i++;
ptr64[i] = 0;
}
#endif
#else
for (i = 0; i < gAudioHeapSize / 8; i++) {
((u64 *) gAudioHeap)[i] = 0;
}
#ifdef TARGET_N64
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
ptr64 = &gAudioGlobalsStartMarker;
for (k = lim3; k >= 0; k--) {
*ptr64++ = 0;
}
#endif
D_EU_802298D0 = 20.03042f;
gRefreshRate = 50;
+3 -1
View File
@@ -1,6 +1,8 @@
#ifndef AUDIO_LOAD_H
#define AUDIO_LOAD_H
#include <PR/ultratypes.h>
#include "internal.h"
#define AUDIO_FRAME_DMA_QUEUE_SIZE 0x40
@@ -54,4 +56,4 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
void preload_sequence(u32 seqId, u8 preloadMask);
void load_sequence(u32 player, u32 seqId, s32 loadAsync);
#endif /* AUDIO_LOAD_H */
#endif // AUDIO_LOAD_H
+5 -3
View File
@@ -1,5 +1,4 @@
#include <ultra64.h>
#include <macros.h>
#include "heap.h"
#include "data.h"
@@ -152,9 +151,11 @@ struct Drum *get_drum(s32 bankId, s32 drumId) {
gAudioErrorFlags = ((bankId << 8) + drumId) + 0x4000000;
return 0;
}
#ifndef NO_SEGMENTED_MEMORY
if ((uintptr_t) gCtlEntries[bankId].drums < 0x80000000U) {
return 0;
}
#endif
drum = gCtlEntries[bankId].drums[drumId];
if (drum == NULL) {
gAudioErrorFlags = ((bankId << 8) + drumId) + 0x5000000;
@@ -248,9 +249,11 @@ void process_notes(void) {
#ifdef VERSION_EU
playbackState = (struct NotePlaybackState *) &note->priority;
if (note->parentLayer != NO_LAYER) {
#ifndef NO_SEGMENTED_MEMORY
if ((uintptr_t) playbackState->parentLayer < 0x7fffffffU) {
continue;
}
#endif
if (!playbackState->parentLayer->enabled && playbackState->priority >= NOTE_PRIORITY_MIN) {
goto c;
} else if (playbackState->parentLayer->seqChannel->seqPlayer == NULL) {
@@ -765,8 +768,7 @@ struct Note *pop_node_with_value_less_equal(struct AudioListItem *list, s32 limi
return NULL;
}
best = cur;
for (; cur != list; cur = cur->next) {
for (best = cur; cur != list; cur = cur->next) {
if (((struct Note *) best->u.value)->priority >= ((struct Note *) cur->u.value)->priority) {
best = cur;
}
+5 -3
View File
@@ -1,5 +1,7 @@
#ifndef _AUDIO_PLAYBACK_H
#define _AUDIO_PLAYBACK_H
#ifndef AUDIO_PLAYBACK_H
#define AUDIO_PLAYBACK_H
#include <PR/ultratypes.h>
#include "internal.h"
@@ -40,4 +42,4 @@ void note_disable(struct Note *note);
#endif
#endif /* _AUDIO_PLAYBACK_H */
#endif // AUDIO_PLAYBACK_H
+1 -1
View File
@@ -40,7 +40,7 @@ struct SPTask *create_next_audio_frame_task(void) {
s32 index;
OSTask_t *task;
s32 flags;
u16 *currAiBuffer;
s16 *currAiBuffer;
s32 oldDmaCount;
OSMesg sp30;
OSMesg sp2C;
@@ -0,0 +1,527 @@
//! Copt inlining for US/JP. Here be dragons
#include <ultra64.h>
#include <macros.h>
#include "heap.h"
#include "data.h"
#include "load.h"
#include "seqplayer.h"
#include "external.h"
#include "effects.h"
#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80)
#define PORTAMENTO_MODE(x) ((x).mode & ~0x80)
#define PORTAMENTO_MODE_1 1
#define PORTAMENTO_MODE_2 2
#define PORTAMENTO_MODE_3 3
#define PORTAMENTO_MODE_4 4
#define PORTAMENTO_MODE_5 5
#define COPT 0
#if COPT
#define M64_READ_U8(state, dst) \
dst = m64_read_u8(state);
#else
#define M64_READ_U8(state, dst) \
{ \
u8 * _ptr_pc; \
u8 _pc; \
_ptr_pc = (*state).pc; \
((*state).pc)++; \
_pc = *_ptr_pc; \
dst = _pc; \
}
#endif
#if COPT
#define M64_READ_S16(state, dst) \
dst = m64_read_s16(state);
#else
#define M64_READ_S16(state, dst) \
{ \
s16 _ret; \
_ret = *(*state).pc << 8; \
((*state).pc)++; \
_ret = *(*state).pc | _ret; \
((*state).pc)++; \
dst = _ret; \
}
#endif
#if COPT
#define M64_READ_COMPRESSED_U16(state, dst) \
dst = m64_read_compressed_u16(state);
#else
#define M64_READ_COMPRESSED_U16(state, dst) \
{ \
u16 ret = *(state->pc++); \
if (ret & 0x80) { \
ret = (ret << 8) & 0x7f00; \
ret = *(state->pc++) | ret; \
} \
dst = ret; \
}
#endif
#if COPT
#define GET_INSTRUMENT(seqChannel, instId, _instOut, _adsr, dst, l) \
dst = get_instrument(seqChannel, instId, _instOut, _adsr);
#else
#define GET_INSTRUMENT(seqChannel, instId, _instOut, _adsr, dst, l) \
{ \
struct AdsrSettings *adsr = _adsr; \
struct Instrument **instOut = _instOut;\
u8 _instId = instId; \
struct Instrument *inst; \
UNUSED u32 pad; \
/* copt inlines instId here */ \
if (instId >= gCtlEntries[(*seqChannel).bankId].numInstruments) { \
_instId = gCtlEntries[(*seqChannel).bankId].numInstruments; \
if (_instId == 0) { \
dst = 0; \
goto ret ## l; \
} \
_instId--; \
} \
inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \
if (inst == NULL) { \
while (_instId != 0xff) { \
inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \
if (inst != NULL) { \
goto gi ## l; \
} \
_instId--; \
} \
gi ## l:; \
} \
if (((uintptr_t) gBankLoadedPool.persistent.pool.start <= (uintptr_t) inst \
&& (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.persistent.pool.start \
+ gBankLoadedPool.persistent.pool.size)) \
|| ((uintptr_t) gBankLoadedPool.temporary.pool.start <= (uintptr_t) inst \
&& (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.temporary.pool.start \
+ gBankLoadedPool.temporary.pool.size))) { \
(*adsr).envelope = (*inst).envelope; \
(*adsr).releaseRate = (*inst).releaseRate; \
*instOut = inst; \
_instId++; \
goto ret ## l; \
} \
gAudioErrorFlags = _instId + 0x20000; \
*instOut = NULL; \
ret ## l: ; \
}
#endif
#ifdef VERSION_EU
#define PORTAMENTO_TGT_NOTE cmd
#define DRUM_INDEX cmd
#define SEMITONE cmd
#define USED_SEMITONE vel
#else
#define PORTAMENTO_TGT_NOTE portamentoTargetNote
#define DRUM_INDEX cmdSemitone
#define SEMITONE cmdSemitone
#define USED_SEMITONE usedSemitone
#endif
void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
struct SequencePlayer *seqPlayer; // sp5C, t4
struct SequenceChannel *seqChannel; // sp58, t5
struct M64ScriptState *state; // v0
struct Portamento *portamento; // v0
struct AudioBankSound *sound; // v0
struct Instrument *instrument; // v1
struct Drum *drum;
UNUSED s32 pad[1];
u8 sameSound; // sp3F
UNUSED u8 allocNewNote; // sp3D, t0
u8 cmd; // a0 sp3E, EU s2
UNUSED u8 loBits;
u16 sp3A; // t2, a0, a1
UNUSED s32 pad2[1];
s32 vel; // sp30, t3
UNUSED s32 pad3[1];
f32 freqScale; // sp28, f0
f32 sp24;
u8 temp8;
UNUSED u8 semitone; // v0
s32 usedSemitone; // a1
f32 temp_f12;
f32 temp_f2;
s32 temp_a0_5;
UNUSED u8 drumIndex; // t0
UNUSED s32 cmdBase; // t1
u8 temp_a0_6;
u8 portamentoTargetNote; // t7
UNUSED s32 bankId; // a3
u8 instId; // v0
u8 cmdSemitone; // v1
f32 tuning; // f0
// inlined copt var that gets pulled out to the rest of the function
unsigned char _Kqi6;
//! Copt: manually inline these functions in the scope of this routine
#ifdef __sgi
#pragma inline routine(m64_read_u8)
#pragma inline routine(m64_read_compressed_u16)
#pragma inline routine(m64_read_s16)
#pragma inline routine(get_instrument)
#endif
sameSound = TRUE;
if (layer->enabled == FALSE) {
return;
}
if (layer->delay > 1) {
layer->delay--;
if (!layer->stopSomething && layer->delay <= layer->duration) {
seq_channel_layer_note_decay(layer);
layer->stopSomething = TRUE;
}
return;
}
if (!layer->continuousNotes) {
seq_channel_layer_note_decay(layer);
}
if (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_1 ||
PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2) {
layer->portamento.mode = 0;
}
seqChannel = (*(layer)).seqChannel;
seqPlayer = (*(seqChannel)).seqPlayer;
for (;;) {
state = &layer->scriptState;
//M64_READ_U8(state, cmd);
// manually inlined because we need _Kqi6 :(
{
u8 *_ptr_pc;
_ptr_pc = (*state).pc;
((*state).pc)++;
//cmd = *_ptr_pc;
_Kqi6 = *_ptr_pc;
cmd = _Kqi6;
}
if (cmd <= 0xc0) {
break;
}
switch (_Kqi6)
{
case 0xff: // layer_end; function return or end of script
if (state->depth == 0) {
// N.B. this function call is *not* inlined even though it's
// within the same file, unlike in the rest of this function.
seq_channel_layer_disable(layer);
return;
}
state->depth--, state->pc = state->stack[state->depth];
break;
case 0xfc: // layer_call
M64_READ_S16(state, sp3A);
state->depth++, state->stack[state->depth - 1] = state->pc;
state->pc = seqPlayer->seqData + sp3A;
break;
case 0xf8: // layer_loop; loop start, N iterations (or 256 if N = 0)
M64_READ_U8(state, state->remLoopIters[state->depth])
state->depth++, state->stack[state->depth - 1] = state->pc;
break;
case 0xf7: // layer_loopend
if (--state->remLoopIters[state->depth - 1] != 0) {
state->pc = state->stack[state->depth - 1];
} else {
state->depth--;
}
break;
case 0xfb: // layer_jump
M64_READ_S16(state, sp3A);
state->pc = seqPlayer->seqData + sp3A;
break;
case 0xc1: // layer_setshortnotevelocity
case 0xca: // layer_setpan
temp_a0_5 = *(state->pc++);
if (cmd == 0xc1) {
layer->velocitySquare = (f32)(temp_a0_5 * temp_a0_5);
} else {
layer->pan = (f32) temp_a0_5 / US_FLOAT(128.0);
}
break;
case 0xc2: // layer_transpose; set transposition in semitones
case 0xc9: // layer_setshortnoteduration
temp_a0_6 = *(state->pc++);
if (cmd == 0xc9) {
layer->noteDuration = temp_a0_6;
} else {
layer->transposition = temp_a0_6;
}
break;
case 0xc4: // layer_somethingon
case 0xc5: // layer_somethingoff
//! copt needs a ternary:
//layer->continuousNotes = (cmd == 0xc4) ? TRUE : FALSE;
if (cmd == 0xc4) {
temp8 = TRUE;
} else {
temp8 = FALSE;
}
layer->continuousNotes = temp8;
seq_channel_layer_note_decay(layer);
break;
case 0xc3: // layer_setshortnotedefaultplaypercentage
M64_READ_COMPRESSED_U16(state, sp3A)
layer->shortNoteDefaultPlayPercentage = sp3A;
break;
case 0xc6: // layer_setinstr
M64_READ_U8(state, instId);
if (instId < 127) {
GET_INSTRUMENT(seqChannel, instId, &(*layer).instrument, &(*layer).adsr, instId, 1);
}
break;
case 0xc7: // layer_portamento
M64_READ_U8(state, (*layer).portamento.mode);
M64_READ_U8(state, PORTAMENTO_TGT_NOTE);
PORTAMENTO_TGT_NOTE = PORTAMENTO_TGT_NOTE + (*layer).transposition + (*seqPlayer).transposition + (*seqChannel).transposition;
if (PORTAMENTO_TGT_NOTE >= 0x80) {
PORTAMENTO_TGT_NOTE = 0;
}
layer->portamentoTargetNote = PORTAMENTO_TGT_NOTE;
// If special, the next param is u8 instead of var
if (PORTAMENTO_IS_SPECIAL((*(layer)).portamento)) {
layer->portamentoTime = *((state)->pc++);
break;
}
M64_READ_COMPRESSED_U16(state, sp3A)
layer->portamentoTime = sp3A;
break;
case 0xc8: // layer_disableportamento
layer->portamento.mode = 0;
break;
default:
switch (cmd & 0xf0) {
case 0xd0: // layer_setshortnotevelocityfromtable
sp3A = seqPlayer->shortNoteVelocityTable[cmd & 0xf];
(*(layer)).velocitySquare = (f32)(sp3A * sp3A);
break;
case 0xe0: // layer_setshortnotedurationfromtable
(*(layer)).noteDuration = seqPlayer->shortNoteDurationTable[cmd & 0xf];
break;
}
}
}
if (cmd == 0xc0) // layer_delay
{
M64_READ_COMPRESSED_U16(state, layer->delay);
layer->stopSomething = TRUE;
} else {
layer->stopSomething = FALSE;
if (seqChannel->largeNotes == TRUE) {
switch (cmd & 0xc0) {
case 0x00: // layer_note0 (play percentage, velocity, duration)
M64_READ_COMPRESSED_U16(state, sp3A)
vel = *((*state).pc++);
layer->noteDuration = *(state->pc++);
layer->playPercentage = sp3A;
goto l1090;
case 0x40: // layer_note1 (play percentage, velocity)
M64_READ_COMPRESSED_U16(state, sp3A)
vel = *(state->pc++);
layer->noteDuration = 0;
layer->playPercentage = sp3A;
goto l1090;
case 0x80: // layer_note2 (velocity, duration; uses last play percentage)
sp3A = layer->playPercentage;
vel = *(state->pc++);
layer->noteDuration = *(state->pc++);
goto l1090;
}
l1090:
cmdSemitone = (cmd - (cmd & 0xc0));
layer->velocitySquare = vel * vel;
} else {
switch (cmd & 0xc0) {
case 0x00: // play note, type 0 (play percentage)
M64_READ_COMPRESSED_U16(state, sp3A)
layer->playPercentage = sp3A;
break;
case 0x40: // play note, type 1 (uses default play percentage)
sp3A = layer->shortNoteDefaultPlayPercentage;
break;
case 0x80: // play note, type 2 (uses last play percentage)
sp3A = layer->playPercentage;
break;
}
cmdSemitone = cmd - (cmd & 0xc0);
}
layer->delay = sp3A;
layer->duration = layer->noteDuration * sp3A / 256;
if ((seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_NOTES) != 0)
|| seqChannel->stopSomething2
|| !seqChannel->hasInstrument
) {
layer->stopSomething = TRUE;
} else {
if (seqChannel->instOrWave == 0) { // drum
//DRUM_INDEX = cmdSemitone;
DRUM_INDEX += (*seqChannel).transposition + (*layer).transposition;
if (DRUM_INDEX >= gCtlEntries[seqChannel->bankId].numDrums) {
DRUM_INDEX = gCtlEntries[seqChannel->bankId].numDrums;
if (DRUM_INDEX == 0) {
// this goto looks a bit like a function return...
layer->stopSomething = TRUE;
goto skip;
}
DRUM_INDEX--;
}
drum = gCtlEntries[seqChannel->bankId].drums[DRUM_INDEX];
if (drum == NULL) {
layer->stopSomething = TRUE;
} else {
layer->adsr.envelope = drum->envelope;
layer->adsr.releaseRate = drum->releaseRate;
layer->pan = FLOAT_CAST(drum->pan) / US_FLOAT(128.0);
layer->sound = &drum->sound;
layer->freqScale = layer->sound->tuning;
}
skip:;
} else { // instrument
//SEMITONE = cmdSemitone;
SEMITONE += (*(seqPlayer)).transposition + (*(seqChannel)).transposition + (*(layer)).transposition;
if (SEMITONE >= 0x80) {
layer->stopSomething = TRUE;
} else {
instrument = layer->instrument;
if (instrument == NULL) {
instrument = seqChannel->instrument;
}
if (layer->portamento.mode != 0) {
//! copt needs a ternary:
//usedSemitone = (layer->portamentoTargetNote < SEMITONE) ? SEMITONE : layer->portamentoTargetNote;
if (layer->portamentoTargetNote < SEMITONE) {
USED_SEMITONE = SEMITONE;
} else {
USED_SEMITONE = layer->portamentoTargetNote;
}
if (instrument != NULL) {
sound = (u8) USED_SEMITONE < instrument->normalRangeLo ? &instrument->lowNotesSound
: (u8) USED_SEMITONE <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
sameSound = (sound == (*layer).sound);
layer->sound = sound;
tuning = (*sound).tuning;
} else {
layer->sound = NULL;
tuning = 1.0f;
}
temp_f2 = gNoteFrequencies[SEMITONE] * tuning;
temp_f12 = gNoteFrequencies[layer->portamentoTargetNote] * tuning;
portamento = &layer->portamento;
switch (PORTAMENTO_MODE(layer->portamento)) {
case PORTAMENTO_MODE_1:
case PORTAMENTO_MODE_3:
case PORTAMENTO_MODE_5:
sp24 = temp_f2;
freqScale = temp_f12;
goto l13cc;
case PORTAMENTO_MODE_2:
case PORTAMENTO_MODE_4:
freqScale = temp_f2;
sp24 = temp_f12;
goto l13cc;
}
l13cc:
portamento->extent = sp24 / freqScale - US_FLOAT(1.0);
if (PORTAMENTO_IS_SPECIAL((*(layer)).portamento)) {
portamento->speed = US_FLOAT(32512.0) * FLOAT_CAST((*(seqPlayer)).tempo)
/ ((f32)(*(layer)).delay * (f32) gTempoInternalToExternal
* FLOAT_CAST((*(layer)).portamentoTime));
} else {
portamento->speed = US_FLOAT(127.0) / FLOAT_CAST((*(layer)).portamentoTime);
}
portamento->cur = 0.0f;
layer->freqScale = freqScale;
if (PORTAMENTO_MODE((*(layer)).portamento) == PORTAMENTO_MODE_5) {
layer->portamentoTargetNote = SEMITONE;
}
} else if (instrument != NULL) {
sound = SEMITONE < instrument->normalRangeLo ?
&instrument->lowNotesSound : SEMITONE <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
sameSound = (sound == (*(layer)).sound);
layer->sound = sound;
layer->freqScale = gNoteFrequencies[SEMITONE] * (*(sound)).tuning;
} else {
layer->sound = NULL;
layer->freqScale = gNoteFrequencies[SEMITONE];
}
}
}
layer->delayUnused = layer->delay;
}
}
if (layer->stopSomething == TRUE) {
if (layer->note != NULL || layer->continuousNotes) {
seq_channel_layer_note_decay(layer);
}
return;
}
cmd = FALSE;
if (!layer->continuousNotes) {
cmd = TRUE;
} else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) {
cmd = TRUE;
} else if (sameSound == FALSE) {
seq_channel_layer_note_decay(layer);
cmd = TRUE;
} else if (layer->sound == NULL) {
init_synthetic_wave(layer->note, layer);
}
if (cmd != FALSE) {
(*(layer)).note = alloc_note(layer);
}
if (layer->note != NULL && layer->note->parentLayer == layer) {
note_vibrato_init(layer->note);
}
}
+159 -305
View File
@@ -1,12 +1,11 @@
#include <ultra64.h>
#include <macros.h>
#include <PR/ultratypes.h>
#include "heap.h"
#include "data.h"
#include "effects.h"
#include "external.h"
#include "heap.h"
#include "load.h"
#include "seqplayer.h"
#include "external.h"
#include "effects.h"
#define PORTAMENTO_IS_SPECIAL(x) ((x).mode & 0x80)
#define PORTAMENTO_MODE(x) ((x).mode & ~0x80)
@@ -378,62 +377,57 @@ u16 m64_read_compressed_u16(struct M64ScriptState *state) {
return ret;
}
#ifdef NON_MATCHING
#if defined(VERSION_EU)
void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
struct SequencePlayer *seqPlayer; // sp5C, t4
struct SequenceChannel *seqChannel; // sp58, t5
#ifdef VERSION_EU
UNUSED u64 pad0;
#endif
struct M64ScriptState *state; // v0
#ifndef VERSION_EU
struct AdsrSettings *adsr; // v0
#endif
struct Portamento *portamento; // v0
#ifndef VERSION_EU
struct Instrument **instOut; // a1
struct Instrument *inst; // a0
#endif
struct AudioBankSound *sound; // v0
struct Instrument *instrument; // v1
struct Drum *drum;
#ifdef VERSION_EU
u16 sp3A; // t2, a0, a1
s32 sameSound;
UNUSED s32 pad[1];
#else
UNUSED s32 pad[1];
u8 sameSound; // sp3F
#endif
u8 cmd; // a0
u8 allocNewNote; // sp3D, t0
u8 loBits;
UNUSED u8 allocNewNote; // sp3D, t0
u8 cmd; // a0 sp3E, EU s2
UNUSED u8 loBits;
#ifndef VERSION_EU
u16 sp3A; // t2, a0, a1
#endif
UNUSED s32 pad2[1];
s32 vel; // sp30, t3
UNUSED s32 pad3[1];
#ifdef VERSION_EU
f32 velFloat;
UNUSED f32 velFloat;
#endif
f32 freqScale; // sp28, f0
#ifndef VERSION_EU
f32 sp24;
#endif
#ifdef VERSION_EU
s8 temp8;
#else
u8 temp8;
#endif
#ifndef VERSION_EU
u8 *old;
u8 *old2;
#endif
u8 semitone; // v0
u8 usedSemitone; // a1
UNUSED u8 temp8;
UNUSED u8 semitone; // v0
UNUSED s32 usedSemitone; // a1
f32 temp_f12;
f32 temp_f2;
s32 temp_a0_5;
u8 drumIndex; // t0
s32 cmdBase; // t1
UNUSED u8 drumIndex; // t0
UNUSED s32 cmdBase; // t1
u8 temp_a0_6;
u8 portamentoTargetNote; // t7
UNUSED u8 portamentoTargetNote; // t7
#ifndef VERSION_EU
s32 bankId; // a3
UNUSED s32 bankId; // a3
#endif
u8 instId; // v0
s32 cmdSemitone; // v1
UNUSED u8 instId; // v0
UNUSED u8 cmdSemitone; // v1
f32 tuning; // f0
sameSound = TRUE;
@@ -461,20 +455,14 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
seqChannel = layer->seqChannel;
seqPlayer = seqChannel->seqPlayer;
#ifdef VERSION_EU
layer->notePropertiesNeedInit = TRUE;
#endif
for (;;) {
// (Moving state outside the loop improves initial regalloc, but is wrong)
state = &layer->scriptState;
#ifdef VERSION_EU
cmd = m64_read_u8(state);
#else
old2 = state->pc++;
cmd = *old2;
#endif
if (cmd <= 0xc0) {
break;
}
@@ -487,41 +475,22 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
seq_channel_layer_disable(layer);
return;
}
state->depth--, state->pc = state->stack[state->depth];
state->pc = state->stack[--state->depth];
break;
case 0xfc: // layer_call
// Something is wrong with the codegen here... It almost looks like
// it's inlining m64_read_s16, but it lacks a s16 cast.
// Maybe they did macro-based inlining since there are more layers
// than channels or sequences, making the code hotter.
#ifdef VERSION_EU
sp3A = m64_read_s16(state);
state->stack[state->depth++] = state->pc;
#else
sp3A = *(state->pc++) << 8;
sp3A = *(state->pc++) | sp3A;
state->depth++;
state->stack[state->depth - 1] = state->pc;
#endif
state->pc = seqPlayer->seqData + sp3A;
break;
case 0xf8: // layer_loop; loop start, N iterations (or 256 if N = 0)
#ifdef VERSION_EU
state->remLoopIters[state->depth] = m64_read_u8(state);
state->stack[state->depth++] = state->pc;
#else
old = state->pc++;
state->remLoopIters[state->depth] = *old;
state->depth++;
state->stack[state->depth - 1] = state->pc;
#endif
break;
case 0xf7: // layer_loopend
state->remLoopIters[state->depth - 1]--;
if (state->remLoopIters[state->depth - 1] != 0) {
if (--state->remLoopIters[state->depth - 1] != 0) {
state->pc = state->stack[state->depth - 1];
} else {
state->depth--;
@@ -529,19 +498,13 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
break;
case 0xfb: // layer_jump
#ifdef VERSION_EU
sp3A = m64_read_s16(state);
#else
sp3A = *(state->pc++) << 8;
sp3A = *(state->pc++) | sp3A;
#endif
state->pc = seqPlayer->seqData + sp3A;
break;
#ifdef VERSION_EU
case 0xf4:
temp8 = m64_read_u8(state);
state->pc += temp8;
state->pc += (s8)m64_read_u8(state);
break;
#endif
@@ -571,151 +534,71 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
case 0xc4: // layer_somethingon
case 0xc5: // layer_somethingoff
#ifdef VERSION_EU
if (cmd == 0xc4) {
layer->continuousNotes = TRUE;
} else {
layer->continuousNotes = FALSE;
}
#else
if (cmd == 0xc4) {
temp8 = TRUE;
} else {
temp8 = FALSE;
}
layer->continuousNotes = temp8;
#endif
seq_channel_layer_note_decay(layer);
break;
case 0xc3: // layer_setshortnotedefaultplaypercentage
// This doesn't match very well... sp3A is definitely set here
// (it's falsely preserved until after the loop), but maybe there's
// also inlining going on, with sp3A as a temp variable being used
// for no good reason? Or it could just be a macro.
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
layer->shortNoteDefaultPlayPercentage = sp3A;
break;
case 0xc6: // layer_setinstr
#ifdef VERSION_EU
instId = m64_read_u8(state);
cmd = m64_read_u8(state);
#ifndef VERSION_EU
if (cmd < 127) {
cmd = get_instrument(seqChannel, cmd, &layer->instrument, &layer->adsr);
}
#else
old = state->pc++;
instId = *old;
#endif
// The rest of this case is identical to
// if (instId < 0x7f) {
// get_instrument(seqChannel, instId, &layer->instrument, &layer->adsr);
// }
// except without seqChannelCpy...
// interestingly, get_instrument comes just *after* this function,
// which I think wouldn't be the case with __inline (maybe if they
// both inline a common helper?)
if (instId >= 0x7f) {
#ifdef VERSION_EU
if (instId == 0x7f) {
if (cmd >= 0x7f) {
if (cmd == 0x7f) {
layer->instOrWave = 0;
} else {
layer->instOrWave = instId;
layer->instOrWave = cmd;
layer->instrument = NULL;
}
if (instId != 0xff) {
break;
if (1) {
}
if (cmd == 0xff) {
layer->adsr.releaseRate = 0;
}
layer->adsr.releaseRate = 0;
#endif
break;
}
#ifdef VERSION_EU
instId = get_instrument(seqChannel, instId, &layer->instrument, &layer->adsr);
layer->instOrWave = instId;
if (instId == 0) {
cmd = get_instrument(seqChannel, cmd, &layer->instrument, &layer->adsr);
layer->instOrWave = cmd;
if (cmd == 0) {
layer->instOrWave = 0xff;
}
//layer->instOrWave = instId == 0 ? 0xff : instId;
break;
#else
bankId = seqChannel->bankId; // maybe a temp, to match get_instrument
if (instId >= gCtlEntries[bankId].numInstruments) {
instId = gCtlEntries[bankId].numInstruments;
if (instId == 0) {
break;
}
instId--;
}
instOut = &layer->instrument;
inst = gCtlEntries[bankId].instruments[instId];
if (inst == NULL) {
while (instId != 0xff) {
inst = gCtlEntries[bankId].instruments[instId];
if (inst != NULL) {
break;
}
instId--;
}
}
adsr = &layer->adsr;
if (((uintptr_t) gBankLoadedPool.persistent.pool.start <= (uintptr_t) inst
&& (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.persistent.pool.start
+ gBankLoadedPool.persistent.pool.size))
|| ((uintptr_t) gBankLoadedPool.temporary.pool.start <= (uintptr_t) inst
&& (uintptr_t) inst <= (uintptr_t)(gBankLoadedPool.temporary.pool.start
+ gBankLoadedPool.temporary.pool.size))) {
adsr->envelope = inst->envelope;
adsr->releaseRate = inst->releaseRate;
*instOut = inst;
// instId++;
} else {
gAudioErrorFlags = instId + 0x20000;
*instOut = NULL;
}
#endif
break;
case 0xc7: // layer_portamento
#ifdef VERSION_EU
layer->portamento.mode = m64_read_u8(state);
portamentoTargetNote = m64_read_u8(state) + seqChannel->transposition +
// cmd is reused for the portamento's semitone
cmd = m64_read_u8(state) + seqChannel->transposition +
layer->transposition + seqPlayer->transposition;
#else
old = state->pc++;
layer->portamento.mode = *old;
old = state->pc++;
portamentoTargetNote = *old + seqChannel->transposition +
layer->transposition + seqPlayer->transposition;
#endif
if (portamentoTargetNote >= 0x80) {
portamentoTargetNote = 0;
if (cmd >= 0x80) {
cmd = 0;
}
layer->portamentoTargetNote = portamentoTargetNote;
layer->portamentoTargetNote = cmd;
// If special, the next param is u8 instead of var
if (PORTAMENTO_IS_SPECIAL(layer->portamento)) {
layer->portamentoTime = *(state->pc++);
layer->portamentoTime = *((state)->pc++);
break;
}
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
layer->portamentoTime = sp3A;
break;
@@ -736,104 +619,58 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
#endif
default:
loBits = cmd & 0xf;
switch (cmd & 0xf0) {
case 0xd0: // layer_setshortnotevelocityfromtable
sp3A = seqPlayer->shortNoteVelocityTable[loBits];
sp3A = seqPlayer->shortNoteVelocityTable[cmd & 0xf];
layer->velocitySquare = (f32)(sp3A * sp3A);
break;
case 0xe0: // layer_setshortnotedurationfromtable
layer->noteDuration = seqPlayer->shortNoteDurationTable[loBits];
layer->noteDuration = seqPlayer->shortNoteDurationTable[cmd & 0xf];
break;
}
}
}
state = &layer->scriptState;
if (cmd == 0xc0) // layer_delay
{
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
layer->delay = sp3A;
if (cmd == 0xc0) { // layer_delay
layer->delay = m64_read_compressed_u16(state);
layer->stopSomething = TRUE;
} else {
layer->stopSomething = FALSE;
if (seqChannel->largeNotes == TRUE) {
cmdBase = cmd & 0xc0;
// phi_a0_3 = sp3A; // real assignment, or same vars?
state = &layer->scriptState;
switch (cmdBase) {
switch (cmd & 0xc0) {
case 0x00: // layer_note0 (play percentage, velocity, duration)
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
vel = *(state->pc++);
layer->noteDuration = *(state->pc++);
layer->playPercentage = sp3A;
break;
case 0x40: // layer_note1 (play percentage, velocity)
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
vel = *(state->pc++);
layer->noteDuration = 0;
layer->playPercentage = sp3A;
break;
case 0x80: // layer_note2 (velocity, duration; uses last play percentage)
sp3A = layer->playPercentage;
vel = *(state->pc++);
layer->noteDuration = *(state->pc++);
sp3A = layer->playPercentage;
break;
}
// the remaining bits are used for the semitone
cmd -= (cmd & 0xc0);
#ifdef VERSION_EU
velFloat = (f32) vel;
layer->velocitySquare = velFloat * velFloat;
cmdSemitone = (cmd - (cmd & 0xc0)) & 0xff;
layer->velocitySquare = (f32)(vel) * (f32)vel;
#else
layer->velocitySquare = vel * vel;
cmdSemitone = cmd - cmdBase;
#endif
} else {
cmdBase = cmd & 0xc0;
state = &layer->scriptState;
// phi_a0_3 = sp3A;
switch (cmdBase) {
switch (cmd & 0xc0) {
case 0x00: // play note, type 0 (play percentage)
#ifdef VERSION_EU
sp3A = m64_read_compressed_u16(state);
#else
sp3A = *(state->pc++);
if (sp3A & 0x80) {
sp3A = (sp3A << 8) & 0x7f00;
sp3A = *(state->pc++) | sp3A;
}
#endif
layer->playPercentage = sp3A;
break;
@@ -846,11 +683,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
break;
}
#ifdef VERSION_EU
cmdSemitone = (cmd - (cmd & 0xc0)) & 0xff;
#else
cmdSemitone = cmd - cmdBase;
#endif
// the remaining bits are used for the semitone
cmd -= cmd & 0xc0;
}
layer->delay = sp3A;
@@ -868,23 +702,31 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
layer->stopSomething = TRUE;
} else {
#ifdef VERSION_EU
if ((layer->instOrWave == 0xff ? seqChannel->instOrWave : layer->instOrWave) == 0) {
drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition;
drum = get_drum(seqChannel->bankId, drumIndex);
s32 temp = layer->instOrWave;
if (temp == 0xff) temp = seqChannel->instOrWave;
if (temp == 0)
#else
if (seqChannel->instOrWave == 0) { // drum
drumIndex = cmdSemitone + seqChannel->transposition + layer->transposition;
if (drumIndex >= gCtlEntries[seqChannel->bankId].numDrums) {
drumIndex = gCtlEntries[seqChannel->bankId].numDrums;
if (drumIndex == 0) {
if (seqChannel->instOrWave == 0)
#endif
{ // drum
// cmd is reused for the drum semitone
cmd += seqChannel->transposition + layer->transposition;
#ifdef VERSION_EU
drum = get_drum(seqChannel->bankId, cmd);
#else
if (cmd >= gCtlEntries[seqChannel->bankId].numDrums) {
cmd = gCtlEntries[seqChannel->bankId].numDrums;
if (cmd == 0) {
// this goto looks a bit like a function return...
layer->stopSomething = TRUE;
goto skip;
}
drumIndex--;
cmd--;
}
drum = gCtlEntries[seqChannel->bankId].drums[drumIndex];
drum = gCtlEntries[seqChannel->bankId].drums[cmd];
#endif
if (drum == NULL) {
layer->stopSomething = TRUE;
@@ -905,40 +747,39 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
skip:;
#endif
} else { // instrument
semitone = cmdSemitone + seqPlayer->transposition + seqChannel->transposition
+ layer->transposition;
if (semitone >= 0x80) {
// cmd is reused for the instrument semitone
cmd += seqPlayer->transposition + seqChannel->transposition + layer->transposition;
if (cmd >= 0x80) {
layer->stopSomething = TRUE;
} else {
#ifdef VERSION_EU
if (layer->instOrWave == 0xff) {
if (layer->instOrWave == 0xffu) {
instrument = seqChannel->instrument;
} else {
instrument = layer->instrument;
}
#else
instrument = layer->instrument;
if (layer->instrument == NULL) {
if (instrument == NULL) {
instrument = seqChannel->instrument;
}
#endif
if (layer->portamento.mode != 0) {
usedSemitone = layer->portamentoTargetNote;
if (usedSemitone < semitone) {
usedSemitone = semitone;
if (layer->portamentoTargetNote < cmd) {
vel = cmd;
} else {
vel = layer->portamentoTargetNote;
}
if (instrument != NULL) {
#ifdef VERSION_EU
sound = instrument_get_audio_bank_sound(instrument, usedSemitone);
sound = instrument_get_audio_bank_sound(instrument, vel);
#else
if (usedSemitone < instrument->normalRangeLo) {
sound = &instrument->lowNotesSound;
} else if (usedSemitone <= instrument->normalRangeHi) {
sound = &instrument->normalNotesSound;
} else {
sound = &instrument->highNotesSound;
}
sound = (u8) vel < instrument->normalRangeLo ? &instrument->lowNotesSound
: (u8) vel <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
#endif
sameSound = (sound == layer->sound);
layer->sound = sound;
@@ -948,7 +789,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
tuning = 1.0f;
}
temp_f2 = gNoteFrequencies[semitone] * tuning;
temp_f2 = gNoteFrequencies[cmd] * tuning;
temp_f12 = gNoteFrequencies[layer->portamentoTargetNote] * tuning;
portamento = &layer->portamento;
@@ -961,12 +802,16 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
#endif
freqScale = temp_f12;
break;
case PORTAMENTO_MODE_2:
case PORTAMENTO_MODE_4:
#ifdef VERSION_EU
default:
#endif
freqScale = temp_f2;
#ifndef VERSION_EU
sp24 = temp_f12;
#endif
freqScale = temp_f2;
break;
}
@@ -975,6 +820,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
#else
portamento->extent = sp24 / freqScale - US_FLOAT(1.0);
#endif
if (PORTAMENTO_IS_SPECIAL(layer->portamento)) {
portamento->speed = US_FLOAT(32512.0) * FLOAT_CAST(seqPlayer->tempo)
/ ((f32) layer->delay * (f32) gTempoInternalToExternal
@@ -985,26 +831,22 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
portamento->cur = 0.0f;
layer->freqScale = freqScale;
if (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_5) {
layer->portamentoTargetNote = semitone;
layer->portamentoTargetNote = cmd;
}
} else if (instrument != NULL) {
#ifdef VERSION_EU
sound = instrument_get_audio_bank_sound(instrument, semitone);
sound = instrument_get_audio_bank_sound(instrument, cmd);
#else
if (semitone < instrument->normalRangeLo) {
sound = &instrument->lowNotesSound;
} else if (semitone <= instrument->normalRangeHi) {
sound = &instrument->normalNotesSound;
} else {
sound = &instrument->highNotesSound;
}
sound = cmd < instrument->normalRangeLo ?
&instrument->lowNotesSound : cmd <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
#endif
sameSound = (sound == layer->sound);
layer->sound = sound;
layer->freqScale = sound->tuning * gNoteFrequencies[semitone];
layer->freqScale = gNoteFrequencies[cmd] * sound->tuning;
} else {
layer->sound = NULL;
layer->freqScale = gNoteFrequencies[semitone];
layer->freqScale = gNoteFrequencies[cmd];
}
}
}
@@ -1019,44 +861,46 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
return;
}
cmd = FALSE;
if (!layer->continuousNotes) {
allocNewNote = TRUE;
cmd = TRUE;
} else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) {
allocNewNote = TRUE;
cmd = TRUE;
} else if (sameSound == FALSE) {
seq_channel_layer_note_decay(layer);
allocNewNote = TRUE;
cmd = TRUE;
}
#ifdef VERSION_EU
} else if (layer != layer->note->parentLayer) {
allocNewNote = TRUE;
else if (layer != layer->note->parentLayer) {
cmd = TRUE;
}
#endif
} else {
allocNewNote = FALSE;
if (layer->sound == NULL) {
init_synthetic_wave(layer->note, layer);
}
else if (layer->sound == NULL) {
init_synthetic_wave(layer->note, layer);
}
if (allocNewNote != FALSE) {
if (cmd != FALSE) {
layer->note = alloc_note(layer);
}
if (layer->note != NULL && layer->note->parentLayer == layer) {
note_vibrato_init(layer->note);
}
#ifdef VERSION_EU
if (seqChannel) {
}
#endif
}
#elif defined(VERSION_EU)
GLOBAL_ASM("asm/non_matchings/eu/audio/seq_channel_layer_process_script.s")
#elif defined(NON_MATCHING)
// US/JP version with macros to simulate inlining by copt. Edit if you dare.
#include "seq_channel_layer_process_script.h"
#elif defined(VERSION_JP)
GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_jp.s")
#else
GLOBAL_ASM("asm/non_matchings/seq_channel_layer_process_script_us.s")
#endif
u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut,
struct AdsrSettings *adsr)
{
u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrument **instOut, struct AdsrSettings *adsr) {
struct Instrument *inst;
#ifdef VERSION_EU
inst = get_instrument_inner(seqChannel->bankId, instId);
@@ -1142,19 +986,21 @@ void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume)
}
#ifdef NON_MATCHING
//rodata: 0xf3e30
void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
u16 sp5A;
s8 value; // sp53
u8 sp38;
u8 cmd; // v1, s1
u8 loBits; // t0, a0
struct M64ScriptState *state;
struct SequencePlayer *seqPlayer;
u16 sp5A;
UNUSED u8 t0;
UNUSED u8 sp38;
u8 cmd; // v1, s1
u8 loBits; // t0, a0
s32 offset;
s8 value; // sp53, 4b
u8 temp;
s8 tempSigned;
s32 offset;
UNUSED u8 temp2;
s32 i;
u8 temp2;
#ifdef VERSION_EU
u8 *arr;
#endif
@@ -1216,16 +1062,18 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
// towards the bottom of the function)
if (cmd > 0xc0) {
switch (cmd) {
#ifdef VERSION_EU
case 0xff: // chan_end
#ifdef VERSION_EU
if (state->depth == 0) {
sequence_channel_disable(seqChannel);
goto out;
} else {
state->depth--, state->pc = state->stack[state->depth];
state->pc = state->stack[--state->depth];
}
#endif
break;
#ifdef VERSION_EU
case 0xfe: // chan_delay1
goto out;
@@ -1463,7 +1311,8 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
break;
case 0xc6: // chan_setbank; switch bank within set
temp = m64_read_u8(state);
{
u8 temp = m64_read_u8(state);
// Switch to the temp's (0-indexed) bank in this sequence's
// bank set. Note that in the binary format (not in the JSON!)
// the banks are listed backwards, so we counts from the back.
@@ -1474,14 +1323,18 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
if (get_bank_or_seq(&gBankLoadedPool, 2, temp) != NULL) {
seqChannel->bankId = temp;
}
}
break;
case 0xc7: // chan_writeseq; write to sequence data (!)
// sp38 doesn't go on the stack
{
u8 sp38;
u8 temp;
sp38 = value;
temp2 = m64_read_u8(state);
sp5A = m64_read_s16(state);
seqPlayer->seqData[sp5A] = sp38 + temp2;
temp = m64_read_u8(state);
seqPlayer->seqData[(u16)m64_read_s16(state)] = sp38 + temp;
}
break;
case 0xc8: // chan_subtract
@@ -1676,6 +1529,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
seq_channel_layer_process_script(seqChannel->layers[i]);
}
}
#undef loBits
}
#elif defined(VERSION_EU)
+6 -4
View File
@@ -1,7 +1,9 @@
#ifndef _AUDIO_SEQPLAYER_H
#define _AUDIO_SEQPLAYER_H
#ifndef AUDIO_SEQPLAYER_H
#define AUDIO_SEQPLAYER_H
#include "types.h"
#include <PR/ultratypes.h>
#include "internal.h"
#include "playback.h"
void seq_channel_layer_disable(struct SequenceChannelLayer *seqPlayer);
@@ -13,4 +15,4 @@ void process_sequences(s32 iterationsRemaining);
void init_sequence_player(u32 player);
void init_sequence_players(void);
#endif /* _AUDIO_SEQPLAYER_H */
#endif // AUDIO_SEQPLAYER_H
+11 -12
View File
@@ -1,5 +1,4 @@
#include <ultra64.h>
#include <macros.h>
#include "synthesis.h"
#include "heap.h"
@@ -43,15 +42,15 @@ struct VolumeChange {
u16 targetRight;
};
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex);
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex);
#ifdef VERSION_EU
u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, u16 *aiBuf, s32 bufLen, u64 *cmd);
u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, u64 *cmd);
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad);
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags);
u64 *process_envelope(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight);
#else
u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd);
u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd);
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad);
u64 *final_resample(u64 *cmd, struct Note *note, s32 count, u16 pitch, u16 dmemIn, u32 flags);
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings,
@@ -255,7 +254,7 @@ s32 get_volume_ramping(u16 sourceVol, u16 targetVol, s32 arg2) {
#ifdef VERSION_EU
//TODO: (Scrub C) pointless mask and whitespace
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
s32 i, j;
f32 *leftVolRamp;
f32 *rightVolRamp;
@@ -290,7 +289,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j);
}
}
cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
bufLen -= chunkLen;
aiBufPtr += chunkLen;
}
@@ -306,7 +305,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
}
#else
// bufLen will be divisible by 16
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
s32 chunkLen;
s32 i;
u32 *aiBufPtr = (u32 *) aiBuf;
@@ -332,7 +331,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
if (gSynthesisReverb.useReverb != 0) {
prepare_reverb_ring_buffer(chunkLen, gAudioUpdatesPerFrame - i);
}
cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioUpdatesPerFrame - i);
cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioUpdatesPerFrame - i);
bufLen -= chunkLen;
aiBufPtr += chunkLen;
}
@@ -416,7 +415,7 @@ u64 *synthesis_save_reverb_samples(u64 *cmdBuf, s16 reverbIndex, s16 updateIndex
#endif
#ifdef VERSION_EU
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
struct NoteSubEu *noteSubEu;
u8 noteIndices[56];
s32 temp;
@@ -495,7 +494,7 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
return cmd;
}
#else
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
UNUSED s32 pad1[1];
s16 ra;
s16 t4;
@@ -572,10 +571,10 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
#ifdef VERSION_EU
// Processes just one note, not all
u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED u16 *aiBuf, s32 bufLen, u64 *cmd) {
u64 *synthesis_process_note(struct Note *note, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 bufLen, u64 *cmd) {
UNUSED s32 pad0[3];
#else
u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
s32 noteIndex; // sp174
struct Note *note; // s7
UNUSED u8 pad0[0x08];
+2 -2
View File
@@ -63,7 +63,7 @@ extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers
extern struct SynthesisReverb gSynthesisReverb;
#endif
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen);
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen);
#ifndef VERSION_EU
void note_init_volume(struct Note *note);
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb);
@@ -72,4 +72,4 @@ void note_enable(struct Note *note);
void note_disable(struct Note *note);
#endif
#endif /* AUDIO_SYNTHESIS_H */
#endif // AUDIO_SYNTHESIS_H
+3 -2
View File
@@ -1,7 +1,8 @@
#ifndef BUFFERS_H
#define BUFFERS_H
#include "types.h"
#include <PR/ultratypes.h>
#include "game/save_file.h"
#include "game/game_init.h"
@@ -29,4 +30,4 @@ extern u8 gGfxSPTaskStack[];
extern struct GfxPool gGfxPools[2];
#endif
#endif // BUFFERS_H
+1 -1
View File
@@ -1,6 +1,6 @@
#include <ultra64.h>
#include "sm64.h"
#include "config.h"
// 0x70800 bytes
#ifdef AVOID_UB
+5 -1
View File
@@ -1,6 +1,10 @@
#ifndef FRAMEBUFFERS_H
#define FRAMEBUFFERS_H
#include <PR/ultratypes.h>
#include "config.h"
// level_script.c assumes that the frame buffers are adjacent, while game.c's
// -g codegen implies that they are separate variables. This is impossible to
// reconcile without undefined behavior. Avoid that when possible.
@@ -15,4 +19,4 @@ extern u16 gFrameBuffer1[SCREEN_WIDTH * SCREEN_HEIGHT];
extern u16 gFrameBuffer2[SCREEN_WIDTH * SCREEN_HEIGHT];
#endif
#endif
#endif // FRAMEBUFFERS_H
+7
View File
@@ -1,5 +1,12 @@
#include <ultra64.h>
#include "gfx_output_buffer.h"
#ifdef VERSION_EU
// 0x17e00 bytes, aligned to a 0x200-byte boundary through sm64.ld. The alignment
// wastes 0x100 bytes of space.
u64 gGfxSPTaskOutputBuffer[0x2fc0];
#else
// 0x1f000 bytes, aligned to a 0x1000-byte boundary through sm64.ld. (This results
// in a bunch of unused space: ~0x100 in JP, ~0x300 in US.)
u64 gGfxSPTaskOutputBuffer[0x3e00];
#endif
+7 -1
View File
@@ -1,6 +1,12 @@
#ifndef GFX_OUTPUT_BUFFER_H
#define GFX_OUTPUT_BUFFER_H
extern u64 gGfxSPTaskOutputBuffer[0x3e00];
#include <PR/ultratypes.h>
#ifdef VERSION_EU
extern u64 gGfxSPTaskOutputBuffer[0x2fc0];
#else
extern u64 gGfxSPTaskOutputBuffer[0x3e00];
#endif
#endif // GFX_OUTPUT_BUFFER_H
+1
View File
@@ -1,5 +1,6 @@
#include <ultra64.h>
#include "config.h"
#include "zbuffer.h"
ALIGNED8 u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
+4 -2
View File
@@ -1,9 +1,11 @@
#ifndef ZBUFFER_H
#define ZBUFFER_H
#include "types.h"
#include <PR/ultratypes.h>
#include "config.h"
#include "macros.h"
extern u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
#endif
#endif // ZBUFFER_H
+29 -27
View File
@@ -1,16 +1,18 @@
#include <ultra64.h>
#include "sm64.h"
#include "behavior_data.h"
#include "behavior_script.h"
#include "game/area.h"
#include "game/behavior_actions.h"
#include "game/game_init.h"
#include "game/mario.h"
#include "game/memory.h"
#include "game/obj_behaviors_2.h"
#include "game/object_helpers.h"
#include "game/object_list_processor.h"
#include "graph_node.h"
#include "surface_collision.h"
#include "game/object_helpers.h"
#include "game/mario.h"
#include "game/game_init.h"
#include "game/obj_behaviors_2.h"
#include "behavior_data.h"
#include "game/object_list_processor.h"
// Macros for retrieving arguments from behavior scripts.
#define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused
@@ -63,7 +65,7 @@ u16 random_u16(void) {
return gRandomSeed16;
}
// Generate a pseudorandom float from 0 to 1.
// Generate a pseudorandom float in the range [0, 1).
f32 random_float(void) {
f32 rnd = random_u16();
return rnd / (double) 0x10000;
@@ -98,10 +100,10 @@ static void cur_obj_bhv_stack_push(uintptr_t bhvAddr) {
// Retrieve the last behavior command address from the object's behavior stack.
static uintptr_t cur_obj_bhv_stack_pop(void) {
uintptr_t bhvAddr;
gCurrentObject->bhvStackIndex--;
bhvAddr = gCurrentObject->bhvStack[gCurrentObject->bhvStackIndex];
return bhvAddr;
}
@@ -115,7 +117,7 @@ static void stub_behavior_script_1(void) {
// Usage: HIDE()
static s32 bhv_cmd_hide(void) {
cur_obj_hide();
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
@@ -124,7 +126,7 @@ static s32 bhv_cmd_hide(void) {
// Usage: DISABLE_RENDERING()
static s32 bhv_cmd_disable_rendering(void) {
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
@@ -133,7 +135,7 @@ static s32 bhv_cmd_disable_rendering(void) {
// Usage: BILLBOARD()
static s32 bhv_cmd_billboard(void) {
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD;
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
@@ -142,9 +144,9 @@ static s32 bhv_cmd_billboard(void) {
// Usage: SET_MODEL(modelID)
static s32 bhv_cmd_set_model(void) {
s32 modelID = BHV_CMD_GET_2ND_S16(0);
gCurrentObject->header.gfx.sharedChild = gLoadedGraphNodes[modelID];
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
@@ -195,7 +197,7 @@ static s32 bhv_cmd_spawn_child_with_param(void) {
// Command 0x1D: Exits the behavior script and despawns the object.
// Usage: DEACTIVATE()
static s32 bhv_cmd_deactivate(void) {
gCurrentObject->activeFlags = 0;
gCurrentObject->activeFlags = ACTIVE_FLAG_DEACTIVATED;
return BHV_PROC_BREAK;
}
@@ -216,7 +218,7 @@ static s32 bhv_cmd_break_unused(void) {
static s32 bhv_cmd_call(void) {
const BehaviorScript *jumpAddress;
gCurBhvCommand++;
cur_obj_bhv_stack_push(BHV_CMD_GET_ADDR_OF_CMD(1)); // Store address of the next bhv command in the stack.
jumpAddress = segmented_to_virtual(BHV_CMD_GET_VPTR(0));
gCurBhvCommand = jumpAddress; // Jump to the new address.
@@ -300,7 +302,7 @@ static s32 bhv_cmd_begin_repeat(void) {
static s32 bhv_cmd_end_repeat(void) {
u32 count = cur_obj_bhv_stack_pop(); // Retrieve loop count from the stack.
count--;
if (count != 0) {
gCurBhvCommand = (const BehaviorScript *) cur_obj_bhv_stack_pop(); // Jump back to the first command in the loop
// Save address and count to the stack again
@@ -320,7 +322,7 @@ static s32 bhv_cmd_end_repeat(void) {
static s32 bhv_cmd_end_repeat_continue(void) {
u32 count = cur_obj_bhv_stack_pop();
count--;
if (count != 0) {
gCurBhvCommand = (const BehaviorScript *) cur_obj_bhv_stack_pop(); // Jump back to the first command in the loop
// Save address and count to the stack again
@@ -546,7 +548,7 @@ static s32 bhv_cmd_drop_to_floor(void) {
f32 x = gCurrentObject->oPosX;
f32 y = gCurrentObject->oPosY;
f32 z = gCurrentObject->oPosZ;
f32 floor = find_floor_height(x, y + 200.0f, z);
gCurrentObject->oPosY = floor;
gCurrentObject->oMoveFlags |= OBJ_MOVE_ON_GROUND;
@@ -665,7 +667,7 @@ static s32 bhv_cmd_nop_4(void) {
static s32 bhv_cmd_begin(void) {
// These objects were likely very early objects, which is why this code is here
// instead of in the respective behavior scripts.
// Initiate the room if the object is a haunted chair or the mad piano.
if (cur_obj_has_behavior(bhvHauntedChair)) {
bhv_init_room();
@@ -696,7 +698,7 @@ static void bhv_cmd_set_int_random_from_table(s32 tableSize) {
}
cur_obj_set_int(field, table[(s32)(tableSize * random_float())]);
// Does not increment gCurBhvCommand or return a bhv status
}
@@ -719,7 +721,7 @@ static s32 bhv_cmd_set_int_random_from_table(void) {
// Set the field to a random entry of the table.
cur_obj_set_int(field, table[(s32)(tableSize * random_float())]);
gCurBhvCommand += (tableSize / 2) + 1;
return BHV_PROC_CONTINUE;
}
@@ -729,9 +731,9 @@ static s32 bhv_cmd_set_int_random_from_table(void) {
// Usage: LOAD_COLLISION_DATA(collisionData)
static s32 bhv_cmd_load_collision_data(void) {
u32 *collisionData = segmented_to_virtual(BHV_CMD_GET_VPTR(1));
gCurrentObject->collisionData = collisionData;
gCurBhvCommand += 2;
return BHV_PROC_CONTINUE;
}
@@ -742,7 +744,7 @@ static s32 bhv_cmd_set_home(void) {
gCurrentObject->oHomeX = gCurrentObject->oPosX;
gCurrentObject->oHomeY = gCurrentObject->oPosY;
gCurrentObject->oHomeZ = gCurrentObject->oPosZ;
gCurBhvCommand++;
return BHV_PROC_CONTINUE;
}
@@ -815,9 +817,9 @@ static s32 bhv_cmd_parent_bit_clear(void) {
// Usage: SPAWN_WATER_DROPLET(dropletParams)
static s32 bhv_cmd_spawn_water_droplet(void) {
struct WaterDropletParams *dropletParams = BHV_CMD_GET_VPTR(1);
spawn_water_droplet(gCurrentObject, dropletParams);
gCurBhvCommand += 2;
return BHV_PROC_CONTINUE;
}
+5 -4
View File
@@ -1,5 +1,7 @@
#ifndef _BEHAVIOR_SCRIPT_H_
#define _BEHAVIOR_SCRIPT_H_
#ifndef BEHAVIOR_SCRIPT_H
#define BEHAVIOR_SCRIPT_H
#include <PR/ultratypes.h>
#define BHV_PROC_CONTINUE 0
#define BHV_PROC_BREAK 1
@@ -21,9 +23,8 @@ u16 random_u16(void);
float random_float(void);
s32 random_sign(void);
void obj_update_gfx_pos_and_angle(struct Object *);
void stub_behavior_script_2(void);
void cur_obj_update(void);
#endif /* _BEHAVIOR_SCRIPT_H_ */
#endif // BEHAVIOR_SCRIPT_H
+1 -1
View File
@@ -210,7 +210,7 @@ void geo_layout_cmd_node_root(void) {
// number of entries to allocate for gGeoViews array
// at least 2 are allocated by default
// cmd+0x02 = 0x00: mario face, 0x0A: all other levels
// cmd+0x02 = 0x00: Mario face, 0x0A: all other levels
gGeoNumViews = cur_geo_cmd_s16(0x02) + 2;
graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height);
+8 -4
View File
@@ -1,14 +1,18 @@
#ifndef _GEO_LAYOUT_H_
#define _GEO_LAYOUT_H_
#ifndef GEO_LAYOUT_H
#define GEO_LAYOUT_H
#include <PR/ultratypes.h>
#include "game/memory.h"
#include "macros.h"
#include "types.h"
#define GEO_CMD_FLAGS_RESET 0
#define GEO_CMD_FLAGS_SET 1
#define GEO_CMD_FLAGS_CLEAR 2
#define CMD_SIZE_SHIFT (sizeof(void *) >> 3)
#define CMD_PROCESS_OFFSET(offset) ((offset & 3) | ((offset & ~3) << CMD_SIZE_SHIFT))
#define CMD_PROCESS_OFFSET(offset) (((offset) & 3) | (((offset) & ~3) << CMD_SIZE_SHIFT))
#define cur_geo_cmd_u8(offset) \
(gGeoLayoutCommand[CMD_PROCESS_OFFSET(offset)])
@@ -80,4 +84,4 @@ void geo_layout_cmd_node_culling_radius(void);
struct GraphNode *process_geo_layout(struct AllocOnlyPool *a0, void *segptr);
#endif /* _GEO_LAYOUT_H_ */
#endif // GEO_LAYOUT_H
+71 -73
View File
@@ -1,29 +1,12 @@
#ifndef _GRAPH_NODE_H_
#define _GRAPH_NODE_H_
#ifndef GRAPH_NODE_H
#define GRAPH_NODE_H
#include <PR/ultratypes.h>
#include <PR/gbi.h>
#include "types.h"
#include "game/memory.h"
struct AllocOnlyPool;
extern struct GraphNodeMasterList *gCurGraphNodeMasterList;
extern struct GraphNodePerspective *gCurGraphNodeCamFrustum;
extern struct GraphNodeCamera *gCurGraphNodeCamera;
extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject;
extern u16 gAreaUpdateCounter;
extern struct GraphNode *gCurRootGraphNode;
extern struct GraphNode *gCurGraphNodeList[];
extern s16 gCurGraphNodeIndex;
extern struct GraphNode gObjParentGraphNode;
extern Vec3f gVec3fZero;
extern Vec3s gVec3sZero;
extern Vec3f gVec3fOne;
extern Vec3s gVec3sOne;
#define GRAPH_RENDER_ACTIVE (1 << 0)
#define GRAPH_RENDER_CHILDREN_FIRST (1 << 1)
#define GRAPH_RENDER_BILLBOARD (1 << 2)
@@ -249,7 +232,7 @@ struct GraphNodeRotation
* data. This animation data is not stored in the node itself but in global
* variables that are set when object nodes are processed if the object has
* animation.
* Usef for Mario, enemies and anything else with animation data.
* Used for Mario, enemies and anything else with animation data.
* The display list can be null, in which case it won't draw anything itself.
*/
struct GraphNodeAnimatedPart
@@ -332,7 +315,7 @@ struct GraphNodeGenerated
};
/** GraphNode that draws a background image or a rectangle of a color.
* Drawn in an orthgraphic projection, used for skyboxes.
* Drawn in an orthographic projection, used for skyboxes.
*/
struct GraphNodeBackground
{
@@ -353,84 +336,99 @@ struct GraphNodeHeldObject
/** A node that allows an object to specify a different culling radius than the
* default one of 300. For this to work, it needs to be a direct child of the
* object node. Used for very large objects, such as shockwave rings that Bowser
* creates, tornados, the big eel.
* object node. Used for very large objects, such as shock wave rings that Bowser
* creates, tornadoes, the big eel.
*/
struct GraphNodeCullingRadius
{
/*0x00*/ struct GraphNode node;
/*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustrum culling
/*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustum culling
u8 pad1E[2];
};
void init_scene_graph_node_links(struct GraphNode *, s32);
extern struct GraphNodeMasterList *gCurGraphNodeMasterList;
extern struct GraphNodePerspective *gCurGraphNodeCamFrustum;
extern struct GraphNodeCamera *gCurGraphNodeCamera;
extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject;
extern u16 gAreaUpdateCounter;
struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *, struct GraphNodeRoot *,
s16, s16 x, s16 y, s16 width, s16 height);
struct GraphNodeOrthoProjection *init_graph_node_ortho_projection(struct AllocOnlyPool *, struct GraphNodeOrthoProjection *, f32);
struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool, struct GraphNodePerspective *sp1c,
f32 sp20, s16 sp26, s16 sp2a, GraphNodeFunc sp2c, s32 sp30);
struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool, struct GraphNodeStart *sp1c);
struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool, struct GraphNodeMasterList *, s16 sp22);
extern struct GraphNode *gCurRootGraphNode;
extern struct GraphNode *gCurGraphNodeList[];
extern s16 gCurGraphNodeIndex;
extern Vec3f gVec3fZero;
extern Vec3s gVec3sZero;
extern Vec3f gVec3fOne;
extern Vec3s gVec3sOne;
void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type);
struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode,
s16 areaIndex, s16 x, s16 y, s16 width, s16 height);
struct GraphNodeOrthoProjection *init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode, f32 scale);
struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode,
f32 fov, s16 near, s16 far, GraphNodeFunc nodeFunc, s32 unused);
struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool, struct GraphNodeStart *graphNode);
struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool, struct GraphNodeMasterList *graphNode, s16 on);
struct GraphNodeLevelOfDetail *init_graph_node_render_range(struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode,
s16 minDistance, s16 maxDistance);
s16 minDistance, s16 maxDistance);
struct GraphNodeSwitchCase *init_graph_node_switch_case(struct AllocOnlyPool *pool, struct GraphNodeSwitchCase *graphNode,
s16 numCases, s16 sp26, GraphNodeFunc nodeFunc, s32 sp2c);
struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool, struct GraphNodeCamera * sp1c,
f32 *sp20, f32 *sp24, GraphNodeFunc sp28, s32 sp2c);
struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(struct AllocOnlyPool *pool,
struct GraphNodeTranslationRotation *graphNode, s32 drawingLayer, void *displayList, Vec3s sp28, Vec3s sp2c);
s16 numCases, s16 selectedCase, GraphNodeFunc nodeFunc, s32 unused);
struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool, struct GraphNodeCamera *graphNode,
f32 *pos, f32 *focus, GraphNodeFunc func, s32 mode);
struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(struct AllocOnlyPool *pool, struct GraphNodeTranslationRotation *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation, Vec3s rotation);
struct GraphNodeTranslation *init_graph_node_translation(struct AllocOnlyPool *pool, struct GraphNodeTranslation *graphNode,
s32 drawingLayer, void *displayList, Vec3s sp28);
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeRotation *init_graph_node_rotation(struct AllocOnlyPool *pool, struct GraphNodeRotation *graphNode,
s32 drawingLayer, void *displayList, Vec3s sp28);
struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool,
struct GraphNodeScale *graphNode, s32 drawingLayer, void *displayList, f32 sp28);
s32 drawingLayer, void *displayList, Vec3s rotation);
struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool, struct GraphNodeScale *graphNode,
s32 drawingLayer, void *displayList, f32 scale);
struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool, struct GraphNodeObject *graphNode,
struct GraphNode *sp20, Vec3f pos, Vec3s angle, Vec3f scale);
struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *sp1c,
s16 sp22);
struct GraphNode *sharedChild, Vec3f pos, Vec3s angle, Vec3f scale);
struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *graphNode, s16 radius);
struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode,
s32 drawingLayer, void *displayList, Vec3s relativePos);
struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool,
struct GraphNodeBillboard *graphNode, s32 drawingLayer, void *displayList, Vec3s sp28);
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool, struct GraphNodeBillboard *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeDisplayList *init_graph_node_display_list(struct AllocOnlyPool *pool, struct GraphNodeDisplayList *graphNode,
s32 drawingLayer, void *displayList);
struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool, struct GraphNodeShadow *sp1c,
s16 sp22, u8 sp27, u8 sp2b);
s32 drawingLayer, void *displayList);
struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool, struct GraphNodeShadow *graphNode,
s16 shadowScale, u8 shadowSolidity, u8 shadowType);
struct GraphNodeObjectParent *init_graph_node_object_parent(struct AllocOnlyPool *pool, struct GraphNodeObjectParent *sp1c,
struct GraphNode *sp20);
struct GraphNode *sharedChild);
struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool, struct GraphNodeGenerated *sp1c,
GraphNodeFunc sp20, s32 sp24);
GraphNodeFunc gfxFunc, s32 parameter);
struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *pool, struct GraphNodeBackground *sp1c,
u16 sp22, GraphNodeFunc sp24, s32 sp28);
u16 background, GraphNodeFunc backgroundFunc, s32 zero);
struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool, struct GraphNodeHeldObject *sp1c,
struct Object *objNode, Vec3s translation, GraphNodeFunc nodeFunc, s32 playerIndex);
struct Object *objNode, Vec3s translation,
GraphNodeFunc nodeFunc, s32 playerIndex);
struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode);
struct GraphNode *geo_remove_child(struct GraphNode *graphNode);
struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild);
struct GraphNode *geo_add_child(struct GraphNode *, struct GraphNode *);
struct GraphNode *geo_remove_child(struct GraphNode *);
struct GraphNode *geo_make_first_child(struct GraphNode *a0);
void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext);
void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 callContext);
void geo_call_global_function_nodes_helper(struct GraphNode *, s32);
void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 sp1c);
void geo_reset_object_node(struct GraphNodeObject *sp20);
void geo_obj_init(struct GraphNodeObject *sp18, void *sp1c, Vec3f sp20, Vec3s sp24);
void geo_obj_init_spawninfo(struct GraphNodeObject *sp18, struct SpawnInfo *sp1c);
void geo_reset_object_node(struct GraphNodeObject *graphNode);
void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle);
void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo *spawn);
void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr);
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel);
s32 retrieve_animation_index(s32 a0, u16 **a1);
s32 retrieve_animation_index(s32 frame, u16 **attributes);
s16 geo_update_animation_frame(struct GraphNodeObject_sub *a0, s32* a1);
void geo_retreive_animation_translation(struct GraphNodeObject *sp28, Vec3f sp2c);
s16 geo_update_animation_frame(struct GraphNodeObject_sub *obj, s32 *accelAssist);
void geo_retreive_animation_translation(struct GraphNodeObject *obj, Vec3f position);
struct GraphNodeRoot *geo_find_root(struct GraphNode *graphNode);
// graph_node_manager
s16 *read_vec3s_to_vec3f(Vec3f, s16 *src);
s16 *read_vec3s(Vec3s dst, s16 *src);
s16 *read_vec3s_angle(Vec3s dst, s16 *src);
void register_scene_graph_node(struct GraphNode *graphNode);
void register_scene_graph_node(struct GraphNode *);
#endif /* _GRAPH_NODE_H_ */
#endif // GRAPH_NODE_H
+3 -8
View File
@@ -1,13 +1,8 @@
#include <ultra64.h>
#include "sm64.h"
#include <PR/ultratypes.h>
#include "types.h"
#include "game/level_update.h"
#include "math_util.h"
#include "game/memory.h"
#include "graph_node.h"
#include "game/rendering_graph_node.h"
#include "game/area.h"
#include "geo_layout.h"
#if IS_64_BIT
static s16 next_s16_in_geo_script(s16 **src) {
+28 -4
View File
@@ -1,4 +1,7 @@
#include <ultra64.h>
#ifdef NO_SEGMENTED_MEMORY
#include <string.h>
#endif
#include "sm64.h"
#include "audio/external.h"
@@ -17,13 +20,11 @@
#include "geo_layout.h"
#include "graph_node.h"
#include "level_script.h"
#include "level_misc_macros.h"
#include "math_util.h"
#include "surface_collision.h"
#include "surface_load.h"
#define CMD_SIZE_SHIFT (sizeof(void *) >> 3)
#define CMD_PROCESS_OFFSET(offset) ((offset & 3) | ((offset & ~3) << CMD_SIZE_SHIFT))
#define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd))
// These are equal
@@ -353,7 +354,7 @@ static void level_cmd_begin_area(void) {
sCurrAreaIndex = areaIndex;
screenArea->areaIndex = areaIndex;
gAreas[areaIndex].unk04 = (struct GraphNode *) screenArea;
gAreas[areaIndex].unk04 = screenArea;
if (node != NULL) {
gAreas[areaIndex].camera = (struct Camera *) node->config.camera;
@@ -601,7 +602,18 @@ static void level_cmd_set_gamma(void) {
static void level_cmd_set_terrain_data(void) {
if (sCurrAreaIndex != -1) {
#ifndef NO_SEGMENTED_MEMORY
gAreas[sCurrAreaIndex].terrainData = segmented_to_virtual(CMD_GET(void *, 4));
#else
Collision *data;
u32 size;
// The game modifies the terrain data and must be reset upon level reload.
data = segmented_to_virtual(CMD_GET(void *, 4));
size = get_area_terrain_size(data) * sizeof(Collision);
gAreas[sCurrAreaIndex].terrainData = alloc_only_pool_alloc(sLevelPool, size);
memcpy(gAreas[sCurrAreaIndex].terrainData, data, size);
#endif
}
sCurrentCmd = CMD_NEXT;
}
@@ -615,7 +627,19 @@ static void level_cmd_set_rooms(void) {
static void level_cmd_set_macro_objects(void) {
if (sCurrAreaIndex != -1) {
#ifndef NO_SEGMENTED_MEMORY
gAreas[sCurrAreaIndex].macroObjects = segmented_to_virtual(CMD_GET(void *, 4));
#else
// The game modifies the macro object data (for example marking coins as taken),
// so it must be reset when the level reloads.
MacroObject *data = segmented_to_virtual(CMD_GET(void *, 4));
s32 len = 0;
while (data[len++] != MACRO_OBJECT_END()) {
len += 4;
}
gAreas[sCurrAreaIndex].macroObjects = alloc_only_pool_alloc(sLevelPool, len * sizeof(MacroObject));
memcpy(gAreas[sCurrAreaIndex].macroObjects, data, len * sizeof(MacroObject));
#endif
}
sCurrentCmd = CMD_NEXT;
}
+8 -4
View File
@@ -1,8 +1,12 @@
#ifndef _LEVEL_SCRIPT_H
#define _LEVEL_SCRIPT_H
#ifndef LEVEL_SCRIPT_H
#define LEVEL_SCRIPT_H
struct LevelCommand *level_script_execute(struct LevelCommand *cmd);
#include <PR/ultratypes.h>
struct LevelCommand;
extern u8 level_script_entry[];
#endif /* _LEVEL_SCRIPT_H */
struct LevelCommand *level_script_execute(struct LevelCommand *cmd);
#endif // LEVEL_SCRIPT_H
+3 -3
View File
@@ -557,7 +557,7 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
* Convert float matrix 'src' to fixed point matrix 'dest'.
* The float matrix may not contain entries larger than 65536 or the console
* crashes. The fixed point matrix has entries with a 16-bit integer part, so
* the floating point numbers are multipled by 2^16 before being cast to a s32
* the floating point numbers are multiplied by 2^16 before being cast to a s32
* integer. If this doesn't fit, the N64 and iQue consoles will throw an
* exception. On Wii and Wii U Virtual Console the value will simply be clamped
* and no crashes occur.
@@ -758,7 +758,7 @@ f32 atan2f(f32 y, f32 x) {
* value t in [0, 1] and gSplineState. Given the current control point P, these
* weights are for P[0], P[1], P[2] and P[3] to obtain an interpolated point.
* The weights naturally sum to 1, and they are also always in range [0, 1] so
* the inteprolated point will never overshoot. The curve is guaranteed to go
* the interpolated point will never overshoot. The curve is guaranteed to go
* through the first and last point, but not through intermediate points.
*
* gSplineState ensures that the curve is clamped: the first two points
@@ -820,7 +820,7 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) {
/**
* Initialize a spline animation.
* 'keyframes' should be an array of (s, x, y, z) vectors
* 'keyFrames' should be an array of (s, x, y, z) vectors
* s: the speed of the keyframe in 1000/frames, e.g. s=100 means the keyframe lasts 10 frames
* (x, y, z): point in 3D space on the curve
* The array should end with three entries with s=0 (infinite keyframe duration).
+25 -22
View File
@@ -1,5 +1,8 @@
#ifndef _MATH_UTIL_H_
#define _MATH_UTIL_H_
#ifndef MATH_UTIL_H
#define MATH_UTIL_H
#include <PR/ultratypes.h>
#include "types.h"
/*
@@ -43,29 +46,29 @@ void *vec3f_to_vec3s(Vec3s dest, Vec3f a);
void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c);
void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b);
void *vec3f_normalize(Vec3f dest);
void mtxf_copy(f32 dest[4][4], f32 src[4][4]);
void mtxf_identity(f32 mtx[4][4]);
void mtxf_translate(f32 a[4][4], Vec3f b);
void mtxf_lookat(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d);
void mtxf_rotate_zxy_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c);
void mtxf_rotate_xyz_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c);
void mtxf_billboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d);
void mtxf_align_terrain_normal(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d);
void mtxf_align_terrain_triangle(f32 mtx[4][4], Vec3f b, s16 c, f32 d);
void mtxf_mul(f32 dest[4][4], f32 a[4][4], f32 b[4][4]);
void mtxf_scale_vec3f(f32 a[4][4], f32 b[4][4], Vec3f c);
void mtxf_mul_vec3s(f32 a[4][4], Vec3s b);
void mtxf_to_mtx(Mtx *a, f32 b[4][4]);
void mtxf_rotate_xy(Mtx *a, s16 b);
void get_pos_from_transform_mtx(Vec3f a, f32 b[4][4], f32 c[4][4]);
void mtxf_copy(Mat4 dest, Mat4 src);
void mtxf_identity(Mat4 mtx);
void mtxf_translate(Mat4 dest, Vec3f b);
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll);
void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate);
void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c);
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s);
void mtxf_mul_vec3s(Mat4 mtx, Vec3s b);
void mtxf_to_mtx(Mtx *dest, Mat4 src);
void mtxf_rotate_xy(Mtx *mtx, s16 angle);
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
s16 atan2s(f32 a, f32 b);
s16 atan2s(f32 y, f32 x);
f32 atan2f(f32 a, f32 b);
void spline_get_weights(Vec4f a, f32 b, UNUSED s32 c);
void anim_spline_init(Vec4s *a);
s32 anim_spline_poll(Vec3f a);
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
void anim_spline_init(Vec4s *keyFrames);
s32 anim_spline_poll(Vec3f result);
#endif
#endif // MATH_UTIL_H
+12 -16
View File
@@ -1,17 +1,15 @@
#include <ultra64.h>
#include <PR/ultratypes.h>
#include "sm64.h"
#include "game/level_update.h"
#include "game/debug.h"
#include "game/camera.h"
#include "game/level_update.h"
#include "game/mario.h"
#include "behavior_script.h"
#include "game/object_list_processor.h"
#include "surface_collision.h"
#include "surface_load.h"
#include "game/object_list_processor.h"
/**************************************************
* WALLS *
* WALLS *
**************************************************/
/**
@@ -219,14 +217,13 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
}
/**************************************************
* CEILINGS *
* CEILINGS *
**************************************************/
/**
* Iterate through the list of ceilings and find the first ceiling over a given point.
*/
static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z,
f32 *pheight) {
static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, f32 *pheight) {
register struct Surface *surf;
register s32 x1, z1, x2, z2, x3, z3;
struct Surface *ceil = NULL;
@@ -355,7 +352,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
}
/**************************************************
* FLOORS *
* FLOORS *
**************************************************/
/**
@@ -399,8 +396,7 @@ f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometr
/**
* Iterate through the list of floors and find the first floor under a given point.
*/
static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z,
f32 *pheight) {
static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32 x, s32 y, s32 z, f32 *pheight) {
register struct Surface *surf;
register s32 x1, z1, x2, z2, x3, z3;
f32 nx, ny, nz;
@@ -484,7 +480,7 @@ f32 find_floor_height(f32 x, f32 y, f32 z) {
}
/**
* Find the highest dynamic floor under a given position. Perhaps originally static and
* Find the highest dynamic floor under a given position. Perhaps originally static
* and dynamic floors were checked separately.
*/
f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
@@ -584,7 +580,7 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
}
/**************************************************
* ENVIRONMENTAL BOXES *
* ENVIRONMENTAL BOXES *
**************************************************/
/**
@@ -663,7 +659,7 @@ f32 find_poison_gas_level(f32 x, f32 z) {
}
/**************************************************
* DEBUG *
* DEBUG *
**************************************************/
/**
@@ -741,7 +737,7 @@ void debug_surface_list_info(f32 xPos, f32 zPos) {
* Perhaps an original implementation of surfaces before they were more specialized.
*/
s32 unused_resolve_floor_or_ceil_collisions(s32 checkCeil, f32 *px, f32 *py, f32 *pz, f32 radius,
struct Surface **psurface, f32 *surfaceHeight) {
struct Surface **psurface, f32 *surfaceHeight) {
f32 nx, ny, nz, oo;
f32 x = *px;
f32 y = *py;
+7 -4
View File
@@ -1,5 +1,9 @@
#ifndef _SURFACE_COLLISION_H
#define _SURFACE_COLLISION_H
#ifndef SURFACE_COLLISION_H
#define SURFACE_COLLISION_H
#include <PR/ultratypes.h>
#include "types.h"
#define LEVEL_BOUNDARY_MAX 0x2000
#define CELL_SIZE 0x400
@@ -33,5 +37,4 @@ f32 find_water_level(f32 x, f32 z);
f32 find_poison_gas_level(f32 x, f32 z);
void debug_surface_list_info(f32 xPos, f32 zPos);
#endif /* _SURFACE_COLLISION_H */
#endif // SURFACE_COLLISION_H
+56 -7
View File
@@ -1,4 +1,4 @@
#include <ultra64.h>
#include <PR/ultratypes.h>
#include "prevent_bss_reordering.h"
@@ -491,8 +491,7 @@ static s16 *read_vertex_data(s16 **data) {
}
/**
* Loads in special environmental regions, such as water,
* poison gas, and JRB fog.
* Loads in special environmental regions, such as water, poison gas, and JRB fog.
*/
static void load_environmental_regions(s16 **data) {
s32 numRegions;
@@ -533,6 +532,57 @@ void alloc_surface_pools(void) {
reset_red_coins_collected();
}
#ifdef NO_SEGMENTED_MEMORY
/**
* Get the size of the terrain data, to get the correct size when copying later.
*/
u32 get_area_terrain_size(s16 *data) {
s16 *startPos = data;
s32 end = FALSE;
s16 terrainLoadType;
s32 numVertices;
s32 numRegions;
s32 numSurfaces;
s16 hasForce;
while (!end) {
terrainLoadType = *data++;
switch (terrainLoadType) {
case TERRAIN_LOAD_VERTICES:
numVertices = *data++;
data += 3 * numVertices;
break;
case TERRAIN_LOAD_OBJECTS:
data += get_special_objects_size(data);
break;
case TERRAIN_LOAD_ENVIRONMENT:
numRegions = *data++;
data += 6 * numRegions;
break;
case TERRAIN_LOAD_CONTINUE:
continue;
case TERRAIN_LOAD_END:
end = TRUE;
break;
default:
numSurfaces = *data++;
hasForce = surface_has_force(terrainLoadType);
data += (3 + hasForce) * numSurfaces;
break;
}
}
return data - startPos;
}
#endif
/**
* Process the level file, loading in vertices, surfaces, some objects, and environmental
* boxes (water, gas, JRB fog).
@@ -550,7 +600,7 @@ void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects
clear_static_surfaces();
// A while loop interating through each section of the level data. Sections of data
// A while loop iterating through each section of the level data. Sections of data
// are prefixed by a terrain "type." This type is reused for surfaces as the surface
// type.
while (TRUE) {
@@ -607,7 +657,7 @@ static void unused_80383604(void) {
}
/**
* Applies an object's tranformation to the object's vertices.
* Applies an object's transformation to the object's vertices.
*/
void transform_object_vertices(s16 **data, s16 *vertexData) {
register s16 *vertices;
@@ -647,8 +697,7 @@ void transform_object_vertices(s16 **data, s16 *vertexData) {
}
/**
* Load in the surfaces for the gCurrentObject. This includes setting the flags,
* exertion, and room.
* Load in the surfaces for the gCurrentObject. This includes setting the flags, exertion, and room.
*/
void load_object_surfaces(s16 **data, s16 *vertexData) {
s32 surfaceType;
+8 -3
View File
@@ -1,5 +1,7 @@
#ifndef _SURFACE_LOAD_H
#define _SURFACE_LOAD_H
#ifndef SURFACE_LOAD_H
#define SURFACE_LOAD_H
#include <PR/ultratypes.h>
#include "types.h"
@@ -28,8 +30,11 @@ extern struct Surface *sSurfacePool;
extern s16 sSurfacePoolSize;
void alloc_surface_pools(void);
#ifdef NO_SEGMENTED_MEMORY
u32 get_area_terrain_size(s16 *data);
#endif
void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects);
void clear_dynamic_surfaces(void);
void load_object_collision_model(void);
#endif
#endif // SURFACE_LOAD_H
+24 -22
View File
@@ -1,7 +1,9 @@
#include <ultra64.h>
#include <PR/ultratypes.h>
#include "prevent_bss_reordering.h"
#include "area.h"
#include "sm64.h"
#include "gfx_dimensions.h"
#include "behavior_data.h"
#include "game_init.h"
#include "object_list_processor.h"
@@ -49,7 +51,7 @@ u8 gWarpTransBlue = 0;
s16 gCurrSaveFileNum = 1;
s16 gCurrLevelNum = LEVEL_MIN;
/*
/*
* The following two tables are used in get_mario_spawn_type() to determine spawn type
* from warp behavior.
* When looping through sWarpBhvSpawnTable, if the behavior function in the table matches
@@ -58,20 +60,20 @@ s16 gCurrLevelNum = LEVEL_MIN;
// D_8032CE9C
const BehaviorScript *sWarpBhvSpawnTable[] = {
bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp,
bhvWarpPipe, bhvFadingWarp, bhvWarps60, bhvWarps64,
bhvWarps68, bhvWarps6C, bhvDeathWarp, bhvWarps74,
bhvWarps78, bhvWarps94, bhvWarps7C, bhvPaintingDeathWarp,
bhvWarps88, bhvWarps84, bhvWarps8C, bhvWarps90,
bhvDoorWarp, bhvStar, bhvExitPodiumWarp, bhvWarp,
bhvWarpPipe, bhvFadingWarp, bhvInstantActiveWarp, bhvAirborneWarp,
bhvHardAirKnockBackWarp, bhvSpinAirborneCircleWarp, bhvDeathWarp, bhvSpinAirborneWarp,
bhvFlyingWarp, bhvSwimmingWarp, bhvPaintingStarCollectWarp, bhvPaintingDeathWarp,
bhvAirborneStarCollectWarp, bhvAirborneDeathWarp, bhvLaunchStarCollectWarp, bhvLaunchDeathWarp,
};
// D_8032CEEC
u8 sSpawnTypeFromWarpBhv[] = {
MARIO_SPAWN_UNKNOWN_01, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03,
MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_04, MARIO_SPAWN_UNKNOWN_10, MARIO_SPAWN_UNKNOWN_12,
MARIO_SPAWN_UNKNOWN_13, MARIO_SPAWN_UNKNOWN_14, MARIO_SPAWN_DEATH, MARIO_SPAWN_UNKNOWN_16,
MARIO_SPAWN_UNKNOWN_17, MARIO_SPAWN_UNKNOWN_11, MARIO_SPAWN_UNKNOWN_20, MARIO_SPAWN_PAINTING_DEATH,
MARIO_SPAWN_UNKNOWN_22, MARIO_SPAWN_UNKNOWN_23, MARIO_SPAWN_UNKNOWN_24, MARIO_SPAWN_UNKNOWN_25,
MARIO_SPAWN_DOOR_WARP, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03,
MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_TELEPORT, MARIO_SPAWN_INSTANT_ACTIVE, MARIO_SPAWN_AIRBORNE,
MARIO_SPAWN_HARD_AIR_KNOCKBACK, MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE, MARIO_SPAWN_DEATH, MARIO_SPAWN_SPIN_AIRBORNE,
MARIO_SPAWN_FLYING, MARIO_SPAWN_SWIMMING, MARIO_SPAWN_PAINTING_STAR_COLLECT, MARIO_SPAWN_PAINTING_DEATH,
MARIO_SPAWN_AIRBORNE_STAR_COLLECT, MARIO_SPAWN_AIRBORNE_DEATH, MARIO_SPAWN_LAUNCH_STAR_COLLECT, MARIO_SPAWN_LAUNCH_DEATH,
};
Vp D_8032CF00 = { {
@@ -111,9 +113,9 @@ void print_intro_text(void) {
if ((gGlobalTimer & 0x1F) < 20) {
if (gControllerBits == 0) {
#ifdef VERSION_EU
print_text_centered(160, 20, gNoControllerMsg[language]);
print_text_centered(SCREEN_WIDTH / 2, 20, gNoControllerMsg[language]);
#else
print_text_centered(160, 20, "NO CONTROLLER");
print_text_centered(SCREEN_WIDTH / 2, 20, "NO CONTROLLER");
#endif
} else {
#ifdef VERSION_EU
@@ -162,7 +164,7 @@ void load_obj_warp_nodes(void) {
do {
struct Object *sp1C = sp20;
if (sp1C->activeFlags && get_mario_spawn_type(sp1C) != 0) {
if (sp1C->activeFlags != ACTIVE_FLAG_DEACTIVATED && get_mario_spawn_type(sp1C) != 0) {
sp24 = area_get_warp_node_from_params(sp1C);
if (sp24 != NULL) {
sp24->object = sp1C;
@@ -207,14 +209,14 @@ void clear_area_graph_nodes(void) {
s32 i;
if (gCurrentArea != NULL) {
geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_UNLOAD);
geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_UNLOAD);
gCurrentArea = NULL;
gWarpTransition.isActive = FALSE;
}
for (i = 0; i < 8; i++) {
if (gAreaData[i].unk04 != NULL) {
geo_call_global_function_nodes(gAreaData[i].unk04, GEO_CONTEXT_AREA_INIT);
geo_call_global_function_nodes(&gAreaData[i].unk04->node, GEO_CONTEXT_AREA_INIT);
gAreaData[i].unk04 = NULL;
}
}
@@ -235,14 +237,14 @@ void load_area(s32 index) {
}
load_obj_warp_nodes();
geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_LOAD);
geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_LOAD);
}
}
void unload_area(void) {
if (gCurrentArea != NULL) {
unload_objects_from_area(0, gCurrentArea->index);
geo_call_global_function_nodes(gCurrentArea->unk04, GEO_CONTEXT_AREA_UNLOAD);
geo_call_global_function_nodes(&gCurrentArea->unk04->node, GEO_CONTEXT_AREA_UNLOAD);
gCurrentArea->flags = 0;
gCurrentArea = NULL;
@@ -331,7 +333,7 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) {
if (transType & 1) // Is the image fading in?
{
gWarpTransition.data.startTexRadius = SCREEN_WIDTH;
gWarpTransition.data.startTexRadius = GFX_DIMENSIONS_FULL_RADIUS;
if (transType >= 0x0F) {
gWarpTransition.data.endTexRadius = 16;
} else {
@@ -344,7 +346,7 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) {
} else {
gWarpTransition.data.startTexRadius = 0;
}
gWarpTransition.data.endTexRadius = SCREEN_WIDTH;
gWarpTransition.data.endTexRadius = GFX_DIMENSIONS_FULL_RADIUS;
}
}
}
@@ -380,7 +382,7 @@ void render_game(void) {
if (gPauseScreenMode != 0) {
gSaveOptSelectIndex = gPauseScreenMode;
}
if (D_8032CE78 != NULL) {
make_viewport_clip_rect(D_8032CE78);
} else
+9 -5
View File
@@ -1,7 +1,11 @@
#ifndef _AREA_H
#define _AREA_H
#ifndef AREA_H
#define AREA_H
#include <PR/ultratypes.h>
#include "types.h"
#include "camera.h"
#include "engine/graph_node.h"
struct WarpNode
{
@@ -61,7 +65,7 @@ struct Area
/*0x00*/ s8 index;
/*0x01*/ s8 flags; // Only has 1 flag: 0x01 = Is this the active area?
/*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31)
/*0x04*/ struct GraphNode *unk04; // geometry layout data
/*0x04*/ struct GraphNodeRoot *unk04; // geometry layout data
/*0x08*/ s16 *terrainData; // collision data (set from level script cmd 0x2E)
/*0x0C*/ s8 *surfaceRooms; // (set from level script cmd 0x2F)
/*0x10*/ s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39)
@@ -114,6 +118,7 @@ struct WarpTransition
/*0x04*/ struct WarpTransitionData data;
};
extern struct GraphNode **gLoadedGraphNodes;
extern struct SpawnInfo gPlayerSpawnInfos[];
extern struct GraphNode *D_8033A160[];
extern struct Area gAreaData[];
@@ -150,5 +155,4 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);
void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 blue, s16 delay);
void render_game(void);
#endif
#endif // AREA_H
+41 -54
View File
@@ -1,40 +1,46 @@
#include <ultra64.h>
#include <PR/ultratypes.h>
#include "sm64.h"
#include "types.h"
#include "actors/common1.h"
#include "actors/group12.h"
#include "actors/group13.h"
#include "area.h"
#include "audio/external.h"
#include "behavior_actions.h"
#include "game_init.h"
#include "main.h"
#include "mario.h"
#include "engine/behavior_script.h"
#include "engine/math_util.h"
#include "object_helpers.h"
#include "behavior_data.h"
#include "obj_behaviors.h"
#include "camera.h"
#include "debug.h"
#include "dialog_ids.h"
#include "engine/behavior_script.h"
#include "engine/graph_node.h"
#include "engine/math_util.h"
#include "engine/surface_collision.h"
#include "engine/surface_load.h"
#include "game_init.h"
#include "ingame_menu.h"
#include "interaction.h"
#include "level_table.h"
#include "level_update.h"
#include "audio/external.h"
#include "seq_ids.h"
#include "dialog_ids.h"
#include "save_file.h"
#include "area.h"
#include "engine/graph_node.h"
#include "camera.h"
#include "spawn_object.h"
#include "levels/bob/header.h"
#include "levels/castle_inside/header.h"
#include "levels/hmc/header.h"
#include "main.h"
#include "mario.h"
#include "mario_actions_cutscene.h"
#include "object_list_processor.h"
#include "spawn_sound.h"
#include "debug.h"
#include "object_constants.h"
#include "mario_step.h"
#include "obj_behaviors.h"
#include "obj_behaviors_2.h"
#include "object_constants.h"
#include "object_helpers.h"
#include "object_list_processor.h"
#include "paintings.h"
#include "platform_displacement.h"
#include "interaction.h"
#include "ingame_menu.h"
#include "rendering_graph_node.h"
#include "level_table.h"
#include "save_file.h"
#include "seq_ids.h"
#include "sm64.h"
#include "spawn_object.h"
#include "spawn_sound.h"
#include "thread6.h"
#define o gCurrentObject
@@ -79,31 +85,12 @@ struct Struct8032F754 {
f32 unk2;
};
struct Struct8032FCE8 {
s16 unk0;
s16 unk1;
void *unk2;
struct OpenableGrill {
s16 halfWidth;
s16 modelID;
const Collision *collision;
};
extern void bhv_pole_base_loop();
extern s16 gDebugInfo[][8];
extern s8 gDoorAdjacentRooms[][2];
extern u8 inside_castle_seg7_collision_ddd_warp_2[];
extern u8 inside_castle_seg7_collision_ddd_warp[];
extern s32 gDialogResponse;
extern s32 gObjCutsceneDone;
extern u8 gRecentCutscene;
extern s8 *D_8032F96C[];
extern s16 bowser_seg6_unkmoveshorts_060576FC[];
extern struct Animation *blue_fish_seg3_anims_0301C2B0[];
extern struct Animation *cyan_fish_seg6_anims_0600E264[];
extern struct Animation *blue_fish_seg3_anims_0301C2B0[];
void common_anchor_mario_behavior(f32, f32, s32);
s32 mario_moving_fast_enough_to_make_piranha_plant_bite(void);
void obj_set_secondary_camera_focus(void);
s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP };
// Boo Roll
@@ -133,14 +120,14 @@ s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046,
struct SpawnParticlesInfo D_8032F270 = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
// generate_wind_puffs/dust (something like that)
void spawn_mist_particles_variable(s32 sp18, s32 sp1C, f32 sp20) {
D_8032F270.sizeBase = sp20;
D_8032F270.sizeRange = sp20 / 20.0;
D_8032F270.offsetY = sp1C;
if (sp18 == 0) {
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) {
D_8032F270.sizeBase = size;
D_8032F270.sizeRange = size / 20.0;
D_8032F270.offsetY = offsetY;
if (count == 0) {
D_8032F270.count = 20;
} else if (sp18 > 20) {
D_8032F270.count = sp18;
} else if (count > 20) {
D_8032F270.count = count;
} else {
D_8032F270.count = 4;
}
+31 -28
View File
@@ -1,21 +1,21 @@
#ifndef _BEHAVIOR_ACTIONS_H
#define _BEHAVIOR_ACTIONS_H
#ifndef BEHAVIOR_ACTIONS_H
#define BEHAVIOR_ACTIONS_H
extern void spawn_mist_particles_variable(s32,s32,f32);
extern void bhv_spawn_star_no_level_exit(u32);
extern void bhv_star_door_loop_2();
extern void spawn_triangle_break_particles(s16,s16,f32,s16);
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size);
void bhv_spawn_star_no_level_exit(u32);
void bhv_star_door_loop_2(void);
void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16 triAnimState);
extern void spawn_mist_from_global(void);
extern void clear_particle_flags(u32);
extern void spawn_wind_particles(s16,s16);
extern s32 check_if_moving_over_floor(f32,f32);
extern s32 arc_to_goal_pos(f32*,f32*,f32,f32);
void vec3f_copy_2(Vec3f dest,Vec3f src);
extern void tox_box_move(f32,f32,s16,s16);
extern void play_penguin_walking_sound(s32);
extern s32 update_angle_from_move_flags(s32*);
extern void cur_obj_spawn_strong_wind_particles(s32, f32, f32, f32, f32);
void spawn_mist_from_global(void);
void clear_particle_flags(u32 flags);
void spawn_wind_particles(s16 pitch, s16 yaw);
s32 check_if_moving_over_floor(f32 a0, f32 a1);
s32 arc_to_goal_pos(Vec3f a0, Vec3f a1, f32 yVel, f32 gravity);
void vec3f_copy_2(Vec3f dest, Vec3f src);
void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll);
void play_penguin_walking_sound(s32 walk);
s32 update_angle_from_move_flags(s32 *angle);
void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ);
void bhv_cap_switch_loop(void);
void bhv_tiny_star_particles_init(void);
@@ -51,6 +51,7 @@ void bhv_fish_group_loop(void);
void bhv_cannon_base_loop(void);
void bhv_cannon_barrel_loop(void);
void bhv_cannon_base_unused_loop(void);
void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30);
void bhv_chuckya_loop(void);
void bhv_chuckya_anchor_mario_loop(void);
void bhv_rotating_platform_loop(void);
@@ -190,6 +191,7 @@ void bhv_lll_sinking_square_platforms_loop(void);
void bhv_koopa_shell_loop(void);
void bhv_koopa_shell_flame_loop(void);
void bhv_tox_box_loop(void);
s32 mario_moving_fast_enough_to_make_piranha_plant_bite(void);
void bhv_piranha_plant_loop(void);
void bhv_lll_bowser_puzzle_piece_loop(void);
void bhv_lll_bowser_puzzle_loop(void);
@@ -227,6 +229,7 @@ void bhv_boo_with_cage_loop(void);
void bhv_boo_init(void);
void bhv_big_boo_loop(void);
void bhv_courtyard_boo_triplet_init(void);
void obj_set_secondary_camera_focus(void);
void bhv_boo_loop(void);
void bhv_boo_boss_spawned_bridge_loop(void);
void bhv_bbh_tilting_trap_platform_loop(void);
@@ -549,28 +552,28 @@ void bhv_dust_smoke_loop(void);
void bhv_yoshi_loop(void);
void bhv_volcano_trap_loop(void);
extern Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
// Bowser
extern Gfx *geo_bits_bowser_coloring(s32 a0, struct GraphNode *node, UNUSED s32 a2);
extern Gfx *geo_update_body_rot_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
extern Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx);
Gfx *geo_bits_bowser_coloring(s32 run, struct GraphNode *node, UNUSED s32 a2);
Gfx *geo_update_body_rot_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx);
// Tuxie
extern Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx);
Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx);
// Cap switch
extern Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
// Snufit
extern Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
extern Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_snufit_scale_body(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
// Bowser key cutscene
extern Gfx *geo_scale_bowser_key(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]);
Gfx *geo_scale_bowser_key(s32 run, struct GraphNode *node, UNUSED f32 mtx[4][4]);
// Water splash
extern struct WaterDropletParams sShallowWaterSplashDropletParams;
extern struct WaterDropletParams sShallowWaterWaveDropletParams;
extern struct WaterDropletParams gShallowWaterSplashDropletParams;
extern struct WaterDropletParams gShallowWaterWaveDropletParams;
#endif // _BEHAVIOR_ACTIONS_H
#endif // BEHAVIOR_ACTIONS_H
+1 -1
View File
@@ -16,7 +16,7 @@
* move off of it. To do this, they changed it to a bhvPlatformOnTrack, but
* forgot to remove its entry in this table.
*/
static void *sActivatedBackAndForthPlatformCollisionModels[] = {
static void const *sActivatedBackAndForthPlatformCollisionModels[] = {
/* ACTIVATED_BF_PLAT_TYPE_BITS_ARROW_PLAT */ bits_seg7_collision_0701AD54,
/* ACTIVATED_BF_PLAT_TYPE_BITFS_MESH_PLAT */ bitfs_seg7_collision_070157E0,
/* ACTIVATED_BF_PLAT_TYPE_BITFS_ELEVATOR */ bitfs_seg7_collision_07015124
@@ -1,7 +1,7 @@
// animated_floor_switch.inc.c
struct Struct80331A54 {
void *unk00;
const void *unk00;
s16 unk04;
};
+6 -6
View File
@@ -37,7 +37,7 @@ void bobomb_act_explode(void) {
bobomb_spawn_coin();
create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -128,7 +128,7 @@ void generic_bobomb_free_loop(void) {
break;
case BOBOMB_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000);
break;
}
@@ -155,7 +155,7 @@ void stationary_bobomb_free_loop(void) {
break;
case BOBOMB_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
create_respawner(MODEL_BLACK_BOBOMB, bhvBobomb, 3000);
break;
}
@@ -346,7 +346,7 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) {
case BOBOMB_BUDDY_CANNON_STOP_TALKING:
set_mario_npc_dialog(0);
o->activeFlags &= ~0x20; /* bit 5 */
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED;
o->oInteractStatus = 0;
o->oAction = BOBOMB_BUDDY_ACT_IDLE;
@@ -357,7 +357,7 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) {
void bobomb_buddy_act_talk(void) {
if (set_mario_npc_dialog(1) == 2) {
o->activeFlags |= 0x20; /* bit 5 */
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
switch (o->oBobombBuddyRole) {
case BOBOMB_BUDDY_ROLE_ADVICE:
@@ -365,7 +365,7 @@ void bobomb_buddy_act_talk(void) {
!= BOBOMB_BUDDY_BP_STYPE_GENERIC) {
set_mario_npc_dialog(0);
o->activeFlags &= ~0x20; /* bit 5 */
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED;
o->oInteractStatus = 0;
o->oAction = BOBOMB_BUDDY_ACT_IDLE;
+98 -98
View File
@@ -191,7 +191,7 @@ static void boo_move_during_hit(s32 roll, f32 fVel) {
// This is such a small change that the Y position only changes by 5 units.
// It's completely unnoticable in-game.
s32 oscillationVel = o->oTimer * 0x800 + 0x800;
o->oForwardVel = fVel;
o->oVelY = coss(oscillationVel);
o->oMoveAngleYaw = o->oBooMoveYawDuringHit;
@@ -237,11 +237,11 @@ static s32 boo_update_after_bounced_on(f32 a0) {
// called iff big boo nonlethally hit
static s32 big_boo_update_during_nonlethal_hit(f32 a0) {
boo_stop();
if (o->oTimer == 0) {
boo_set_move_yaw_for_during_hit(TRUE);
}
if (o->oTimer < 32) {
boo_move_during_hit(TRUE, D_8032F0CC[o->oTimer]/5000.0f * a0);
} else if (o->oTimer < 48) {
@@ -249,12 +249,12 @@ static s32 big_boo_update_during_nonlethal_hit(f32 a0) {
} else {
cur_obj_become_tangible();
boo_reset_after_hit();
o->oAction = 1;
return TRUE;
}
return FALSE;
}
@@ -279,7 +279,7 @@ static s32 boo_update_during_death(void) {
if (o->oBooParentBigBoo != NULL) {
parentBigBoo = o->oBooParentBigBoo;
#ifndef VERSION_JP
if (!cur_obj_has_behavior(bhvBoo)) {
parentBigBoo->oBigBooNumMinionBoosKilled++;
@@ -288,7 +288,7 @@ static s32 boo_update_during_death(void) {
parentBigBoo->oBigBooNumMinionBoosKilled++;
#endif
}
return TRUE;
}
}
@@ -310,25 +310,25 @@ static s32 obj_has_attack_type(u32 attackType) {
static s32 boo_get_attack_status(void) {
s32 attackStatus = BOO_NOT_ATTACKED;
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
if ((o->oInteractStatus & INT_STATUS_WAS_ATTACKED) && obj_has_attack_type(ATTACK_FROM_ABOVE) == FALSE) {
cur_obj_become_intangible();
o->oInteractStatus = 0;
cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_SHORT);
attackStatus = BOO_ATTACKED;
} else {
cur_obj_play_sound_2(SOUND_OBJ_BOO_BOUNCE_TOP);
o->oInteractStatus = 0;
attackStatus = BOO_BOUNCED_ON;
}
}
return attackStatus;
}
@@ -336,28 +336,28 @@ static s32 boo_get_attack_status(void) {
static void boo_chase_mario(f32 a0, s16 a1, f32 a2) {
f32 sp1C;
s16 sp1A;
if (boo_vanish_or_appear()) {
o->oInteractType = 0x8000;
if (cur_obj_lateral_dist_from_mario_to_home() > 1500.0f) {
sp1A = cur_obj_angle_to_home();
} else {
sp1A = o->oAngleToMario;
}
cur_obj_rotate_yaw_toward(sp1A, a1);
o->oVelY = 0.0f;
if (mario_is_in_air_action() == 0) {
sp1C = o->oPosY - gMarioObject->oPosY;
if (a0 < sp1C && sp1C < 500.0f) {
o->oVelY = increment_velocity_toward_range(o->oPosY, gMarioObject->oPosY + 50.0f, 10.f, 2.0f);
}
}
cur_obj_set_vel_from_mario_vel(10.0f - o->oBooNegatedAggressiveness, a2);
if (o->oForwardVel != 0.0f) {
boo_oscillate(FALSE);
}
@@ -372,19 +372,19 @@ static void boo_chase_mario(f32 a0, s16 a1, f32 a2) {
static void boo_act_0(void) {
o->activeFlags |= ACTIVE_FLAG_MOVE_THROUGH_GRATE;
if (o->oBehParams2ndByte == 2) {
o->oRoom = 10;
}
cur_obj_set_pos_to_home();
o->oMoveAngleYaw = o->oBooInitialMoveYaw;
boo_stop();
o->oBooParentBigBoo = cur_obj_nearest_object_with_behavior(bhvGhostHuntBigBoo);
o->oBooBaseScale = 1.0f;
o->oBooTargetOpacity = 0xFF;
if (boo_should_be_active()) {
// Condition is met if the object is bhvBalconyBigBoo or bhvMerryGoRoundBoo
if (o->oBehParams2ndByte == 2) {
@@ -410,27 +410,27 @@ static void boo_act_5(void) {
static void boo_act_1(void) {
s32 attackStatus;
if (o->oTimer == 0) {
o->oBooNegatedAggressiveness = -random_float() * 5.0f;
o->oBooTurningSpeed = (s32)(random_float() * 128.0f);
}
boo_chase_mario(-100.0f, o->oBooTurningSpeed + 0x180, 0.5f);
attackStatus = boo_get_attack_status();
if (boo_should_be_stopped()) {
o->oAction = 0;
}
if (attackStatus == BOO_BOUNCED_ON) {
o->oAction = 2;
}
if (attackStatus == BOO_ATTACKED) {
o->oAction = 3;
}
if (attackStatus == BOO_ATTACKED) {
create_sound_spawner(SOUND_OBJ_DYING_ENEMY1);
}
@@ -467,7 +467,7 @@ static void boo_act_4(void) {
if (cur_obj_update_dialog(2, 2, dialogID, 0)) {
create_sound_spawner(SOUND_OBJ_DYING_ENEMY1);
obj_mark_for_deletion(o);
if (dialogID == DIALOG_108) { // If the Big Boo should spawn, play the jingle
play_puzzle_jingle();
}
@@ -485,18 +485,18 @@ static void (*sBooActions[])(void) = {
void bhv_boo_loop(void) {
//PARTIAL_UPDATE
cur_obj_update_floor_and_walls();
cur_obj_call_action_function(sBooActions);
cur_obj_move_standard(78);
boo_approach_target_opacity_and_update_scale();
if (obj_has_behavior(o->parentObj, bhvMerryGoRoundBooManager)) {
if (o->activeFlags == 0) {
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED) {
o->parentObj->oMerryGoRoundBooManagerNumBoosKilled++;
}
}
o->oInteractStatus = 0;
}
@@ -507,25 +507,25 @@ static void big_boo_act_0(void) {
// redundant? this is also done in behavior_data.s
o->oBigBooNumMinionBoosKilled = 10;
}
o->oBooParentBigBoo = NULL;
#ifndef VERSION_JP
if (boo_should_be_active() && gDebugInfo[5][0] + 5 <= o->oBigBooNumMinionBoosKilled) {
#else
if (boo_should_be_active() && o->oBigBooNumMinionBoosKilled >= 5) {
#endif
o->oAction = 1;
cur_obj_set_pos_to_home();
o->oMoveAngleYaw = o->oBooInitialMoveYaw;
cur_obj_unhide();
o->oBooTargetOpacity = 0xFF;
o->oBooBaseScale = 3.0f;
o->oHealth = 3;
cur_obj_scale(3.0f);
cur_obj_become_tangible();
} else {
@@ -539,7 +539,7 @@ static void big_boo_act_1(void) {
s32 attackStatus;
s16 sp22;
f32 sp1C;
if (o->oHealth == 3) {
sp22 = 0x180; sp1C = 0.5f;
} else if (o->oHealth == 2) {
@@ -547,11 +547,11 @@ static void big_boo_act_1(void) {
} else {
sp22 = 0x300; sp1C = 0.8f;
}
boo_chase_mario(-100.0f, sp22, sp1C);
attackStatus = boo_get_attack_status();
// redundant; this check is in boo_should_be_stopped
if (cur_obj_has_behavior(bhvMerryGoRoundBigBoo)) {
if (gMarioOnMerryGoRound == FALSE) {
@@ -560,15 +560,15 @@ static void big_boo_act_1(void) {
} else if (boo_should_be_stopped()) {
o->oAction = 0;
}
if (attackStatus == BOO_BOUNCED_ON) {
o->oAction = 2;
}
if (attackStatus == BOO_ATTACKED) {
o->oAction = 3;
}
if (attackStatus == 1) {
create_sound_spawner(SOUND_OBJ_THWOMP);
}
@@ -604,15 +604,15 @@ static void big_boo_act_3(void) {
if (o->oTimer == 0) {
o->oHealth--;
}
if (o->oHealth == 0) {
if (boo_update_during_death()) {
cur_obj_disable();
o->oAction = 4;
obj_set_angle(o, 0, 0, 0);
if (o->oBehParams2ndByte == 0) {
big_boo_spawn_ghost_hunt_star();
} else if (o->oBehParams2ndByte == 1) {
@@ -626,7 +626,7 @@ static void big_boo_act_3(void) {
spawn_mist_particles();
o->oBooBaseScale -= 0.5;
}
if (big_boo_update_during_nonlethal_hit(40.0f)) {
o->oAction = 1;
}
@@ -637,17 +637,17 @@ static void big_boo_act_4(void) {
#ifndef VERSION_JP
boo_stop();
#endif
if (o->oBehParams2ndByte == 0) {
obj_set_pos(o, 973, 0, 626);
if (o->oTimer > 60 && o->oDistanceToMario < 600.0f) {
obj_set_pos(o, 973, 0, 717);
spawn_object_relative(0, 0, 0, 0, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
spawn_object_relative(1, 0, 0, -200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
spawn_object_relative(2, 0, 0, 200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
obj_mark_for_deletion(o);
}
} else {
@@ -665,15 +665,15 @@ static void (*sBooGivingStarActions[])(void) = {
void bhv_big_boo_loop(void) {
//PARTIAL_UPDATE
obj_set_hitbox(o, &sBooGivingStarHitbox);
o->oGraphYOffset = o->oBooBaseScale * 60.0f;
cur_obj_update_floor_and_walls();
cur_obj_call_action_function(sBooGivingStarActions);
cur_obj_move_standard(78);
boo_approach_target_opacity_and_update_scale();
o->oInteractStatus = 0;
}
@@ -682,10 +682,10 @@ static void boo_with_cage_act_0(void) {
o->oBooParentBigBoo = NULL;
o->oBooTargetOpacity = 0xFF;
o->oBooBaseScale = 2.0f;
cur_obj_scale(2.0f);
cur_obj_become_tangible();
if (boo_should_be_active()) {
o->oAction = 1;
}
@@ -695,17 +695,17 @@ static void boo_with_cage_act_1(void) {
s32 attackStatus;
boo_chase_mario(100.0f, 512, 0.5f);
attackStatus = boo_get_attack_status();
if (boo_should_be_stopped()) {
o->oAction = 0;
}
if (attackStatus == BOO_BOUNCED_ON) {
o->oAction = 2;
}
if (attackStatus == BOO_ATTACKED) {
o->oAction = 3;
}
@@ -725,7 +725,7 @@ static void boo_with_cage_act_3(void) {
void bhv_boo_with_cage_init(void) {
struct Object* cage;
if (gHudDisplay.stars < 12) {
obj_mark_for_deletion(o);
} else {
@@ -744,7 +744,7 @@ static void (*sBooWithCageActions[])(void) = {
void bhv_boo_with_cage_loop(void)
{
//PARTIAL_UPDATE
cur_obj_update_floor_and_walls();
cur_obj_call_action_function(sBooWithCageActions);
cur_obj_move_standard(78);
@@ -764,16 +764,16 @@ void bhv_merry_go_round_boo_manager_loop(void) {
o->oMerryGoRoundBooManagerNumBoosSpawned++;
}
}
o->oAction++;
}
if (o->oMerryGoRoundBooManagerNumBoosKilled > 4) {
struct Object *boo = spawn_object(o, MODEL_BOO, bhvMerryGoRoundBigBoo);
obj_copy_behavior_params(boo, o);
o->oAction = 2;
#ifndef VERSION_JP
play_puzzle_jingle();
#else
@@ -781,13 +781,13 @@ void bhv_merry_go_round_boo_manager_loop(void) {
#endif
}
}
break;
case 1:
if (o->oTimer > 60) {
o->oAction = 0;
}
break;
case 2:
break;
@@ -804,43 +804,43 @@ void bhv_animated_texture_loop(void) {
void bhv_boo_in_castle_loop(void) {
s16 targetAngle;
o->oBooBaseScale = 2.0f;
if (o->oAction == 0) {
cur_obj_hide();
if (gHudDisplay.stars < 12) {
obj_mark_for_deletion(o);
}
if (gMarioCurrentRoom == 1) {
o->oAction++;
}
} else if (o->oAction == 1) {
cur_obj_unhide();
o->oOpacity = 180;
if (o->oTimer == 0) {
cur_obj_scale(o->oBooBaseScale);
}
if (o->oDistanceToMario < 1000.0f) {
o->oAction++;
cur_obj_play_sound_2(SOUND_OBJ_BOO_LAUGH_LONG);
}
o->oForwardVel = 0.0f;
targetAngle = o->oAngleToMario;
} else {
cur_obj_forward_vel_approach_upward(32.0f, 1.0f);
o->oHomeX = -1000.0f;
o->oHomeZ = -9000.0f;
targetAngle = cur_obj_angle_to_home();
if (o->oPosZ < -5000.0f) {
if (o->oOpacity > 0) {
o->oOpacity -= 20;
@@ -848,16 +848,16 @@ void bhv_boo_in_castle_loop(void) {
o->oOpacity = 0;
}
}
if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) {
o->oAction = 1;
}
}
o->oVelY = 0.0f;
targetAngle = cur_obj_angle_to_home();
cur_obj_rotate_yaw_toward(targetAngle, 0x5A8);
boo_oscillate(TRUE);
cur_obj_move_using_fvel_and_gravity();
@@ -865,7 +865,7 @@ void bhv_boo_in_castle_loop(void) {
void bhv_boo_boss_spawned_bridge_loop(void) {
f32 targetY;
switch (o->oBehParams2ndByte) {
case 1:
targetY = 0.0f;
@@ -877,7 +877,7 @@ void bhv_boo_boss_spawned_bridge_loop(void) {
targetY = -413.0f;
break;
}
switch(o->oAction) {
case 0:
o->oPosY = o->oHomeY - 620.0f;
@@ -886,28 +886,28 @@ void bhv_boo_boss_spawned_bridge_loop(void) {
case 1:
o->oPosY += 8.0f;
cur_obj_play_sound_1(SOUND_ENV_ELEVATOR2);
if (o->oPosY > targetY) {
o->oPosY = targetY;
o->oAction++;
}
break;
case 2:
if (o->oTimer == 0) {
cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
}
if (cur_obj_move_up_and_down(o->oTimer)) {
o->oAction++;
}
break;
case 3:
if (o->oTimer == 0 && o->oBehParams2ndByte == 1) {
play_puzzle_jingle();
}
break;
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ void boulder_act_1(void) {
o->oForwardVel = 70.0f;
if (o->oPosY < -1000.0f)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_big_boulder_loop(void) {
+1 -1
View File
@@ -1,7 +1,7 @@
// bouncing_fireball.c.inc
void bhv_bouncing_fireball_flame_loop(void) {
o->activeFlags |= 0x400;
o->activeFlags |= ACTIVE_FLAG_UNK10;
cur_obj_update_floor_and_walls();
switch (o->oAction) {
case 0:
+1 -1
View File
@@ -87,7 +87,7 @@ void bhv_bowling_ball_roll_loop(void) {
spawn_mist_particles_variable(0, 0, 92.0f);
}
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) && (o->oVelY > 5.0f))
+9 -9
View File
@@ -160,7 +160,7 @@ void bowser_initialize_action(void) {
o->oAction = 0;
}
void bowser_act_text_wait() // not much
void bowser_act_text_wait(void) // not much
{
o->oForwardVel = 0.0f;
cur_obj_init_animation_with_sound(12);
@@ -295,13 +295,13 @@ void bowser_reset_fallen_off_stage(void) {
}
#endif
void bowser_act_unused_slow_walk() // unused?
void bowser_act_unused_slow_walk(void) // unused?
{
if (cur_obj_init_animation_and_check_if_near_end(12))
o->oAction = 0;
}
void bowser_act_default() // only lasts one frame
void bowser_act_default(void) // only lasts one frame
{
o->oBowserEyesShut = 0;
cur_obj_init_animation_with_sound(12);
@@ -326,7 +326,7 @@ void bowser_act_breath_fire(void) {
o->oAction = 0;
}
void bowser_act_walk_to_mario() // turn towards Mario
void bowser_act_walk_to_mario(void) // turn towards Mario
{
UNUSED s32 facing; // is Bowser facing Mario?
s16 turnSpeed;
@@ -892,7 +892,7 @@ void bowser_act_dead(void) {
if (BITS)
o->oSubAction = 10;
else {
o->activeFlags |= 0x80;
o->activeFlags |= ACTIVE_FLAG_DITHERED_ALPHA;
o->oSubAction++;
}
}
@@ -1258,13 +1258,13 @@ Gfx *geo_switch_bowser_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) {
return NULL;
}
Gfx *geo_bits_bowser_coloring(s32 a0, struct GraphNode *node, UNUSED s32 a2) {
Gfx *geo_bits_bowser_coloring(s32 run, struct GraphNode *node, UNUSED s32 a2) {
Gfx *sp2C = NULL;
Gfx *sp28;
struct Object *sp24;
struct GraphNodeGenerated *sp20;
if (a0 == 1) {
if (run == 1) {
sp24 = (struct Object *) gCurGraphNodeObject;
sp20 = (struct GraphNodeGenerated *) node;
if (gCurGraphNodeHeldObject != 0)
@@ -1379,8 +1379,8 @@ void bowser_flame_despawn(void) {
spawn_object(o, MODEL_YELLOW_COIN, bhvTemporaryYellowCoin);
}
s32 bowser_flame_should_despawn(s32 a0) {
if (a0 < o->oTimer)
s32 bowser_flame_should_despawn(s32 maxTime) {
if (maxTime < o->oTimer)
return 1;
if (o->oFloorType == 1)
return 1;
+4 -4
View File
@@ -4,7 +4,7 @@ void bhv_bowser_bomb_loop(void) {
if (obj_check_if_collided_with_object(o, gMarioObject) == 1) {
o->oInteractStatus &= ~INT_STATUS_INTERACTED;
spawn_object(o, MODEL_EXPLOSION, bhvExplosion);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
if (o->oInteractStatus & INT_STATUS_HIT_MINE)
@@ -12,7 +12,7 @@ void bhv_bowser_bomb_loop(void) {
spawn_object(o, MODEL_BOWSER_FLAMES, bhvBowserBombExplosion);
create_sound_spawner(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION);
set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
set_object_visibility(o, 7000);
@@ -32,7 +32,7 @@ void bhv_bowser_bomb_explosion_loop(void) {
if (o->oTimer % 2 == 0)
o->oAnimState++;
if (o->oTimer == 28)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_bowser_bomb_smoke_loop(void) {
@@ -47,5 +47,5 @@ void bhv_bowser_bomb_smoke_loop(void) {
o->oPosY += o->oVelY;
if (o->oTimer == 28)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
+5 -5
View File
@@ -19,7 +19,7 @@ void bhv_breakable_box_small_init(void) {
cur_obj_scale(0.4f);
obj_set_hitbox(o, &sBreakableBoxSmallHitbox);
o->oAnimState = 1;
o->activeFlags |= 0x200;
o->activeFlags |= ACTIVE_FLAG_UNK9;
}
void small_breakable_box_spawn_dust(void) {
@@ -46,7 +46,7 @@ void small_breakable_box_act_move(void) {
spawn_triangle_break_particles(20, 138, 0.7f, 3);
obj_spawn_yellow_coins(o, 3);
create_sound_spawner(SOUND_GENERAL_BREAK_BOX);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
obj_check_floor_death(sp1E, sObjFloor);
@@ -66,7 +66,7 @@ void breakable_box_small_released_loop(void) {
// Despawn, and create a corkbox respawner
if (o->oBreakableBoxSmallFramesSinceReleased > 900) {
create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -81,7 +81,7 @@ void breakable_box_small_idle_loop(void) {
break;
case 101:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000);
break;
}
@@ -111,7 +111,7 @@ void breakable_box_small_get_thrown(void) {
o->oVelY = 20.0f;
o->oBreakableBoxSmallReleased = 1;
o->oBreakableBoxSmallFramesSinceReleased = 0;
o->activeFlags &= ~0x200;
o->activeFlags &= ~ACTIVE_FLAG_UNK9;
}
void bhv_breakable_box_small_loop(void) {
+1 -1
View File
@@ -19,6 +19,6 @@ void bhv_object_bubble_loop(void) {
bubbleSplash->oPosZ = o->oPosZ;
}
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
+2 -2
View File
@@ -6,13 +6,13 @@ void bhv_white_puff_smoke_init(void) {
}
void bhv_bullet_bill_init(void) {
o->oBulletBillUnkF8 = o->oMoveAngleYaw;
o->oBulletBillInitialMoveYaw = o->oMoveAngleYaw;
}
void bullet_bill_act_0(void) {
cur_obj_become_tangible();
o->oForwardVel = 0.0f;
o->oMoveAngleYaw = o->oBulletBillUnkF8;
o->oMoveAngleYaw = o->oBulletBillInitialMoveYaw;
o->oFaceAnglePitch = 0;
o->oFaceAngleRoll = 0;
o->oMoveFlags = 0;
+2 -2
View File
@@ -253,7 +253,7 @@ void bhv_bully_loop(void) {
break;
case BULLY_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
}
@@ -364,7 +364,7 @@ void bhv_big_bully_with_minions_loop(void) {
break;
case BULLY_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ void bhv_cannon_closed_init(void) {
cannon->oPosZ = o->oHomeZ;
o->oAction = CANNON_TRAP_DOOR_ACT_OPEN;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
+5 -5
View File
@@ -15,7 +15,7 @@ static struct ObjectHitbox sCapHitbox = {
s32 cap_set_hitbox(void) {
obj_set_hitbox(o, &sCapHitbox);
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
o->oInteractStatus = 0;
return 1;
}
@@ -35,7 +35,7 @@ void cap_check_quicksand(void) {
switch (sObjFloor->type) {
case SURFACE_DEATH_PLANE:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
case SURFACE_SHALLOW_QUICKSAND:
@@ -85,14 +85,14 @@ void cap_sink_quicksand(void) {
case 12:
o->oGraphYOffset += -1.0f;
if (o->oTimer >= 21)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
case 13:
o->oGraphYOffset += -6.0f;
if (o->oTimer >= 21)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
o->oFaceAnglePitch = 0x2000;
break;
@@ -254,7 +254,7 @@ void bhv_normal_cap_loop(void) {
if ((s32) o->oForwardVel != 0)
save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ);
if (o->activeFlags == 0)
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED)
normal_cap_set_save_flags();
if (cap_set_hitbox() == 1)
+1 -1
View File
@@ -42,7 +42,7 @@ void cap_switch_act_2(void) {
}
}
void cap_switch_act_3() {
void cap_switch_act_3(void) {
} // dead function
void (*sCapSwitchActions[])(void) = { cap_switch_act_0, cap_switch_act_1,
+1 -1
View File
@@ -2,5 +2,5 @@
void bhv_castle_cannon_grate_init(void) {
if (save_file_get_total_star_count(gCurrSaveFileNum - 1, 0, 24) >= 120)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
+3 -3
View File
@@ -62,7 +62,7 @@ void celeb_star_act_face_camera(void) {
}
if (o->oTimer == 59)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_celebration_star_loop(void) {
@@ -81,10 +81,10 @@ void bhv_celebration_star_sparkle_loop(void) {
o->oPosY -= 15.0f;
if (o->oTimer == 12)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_star_key_collection_puff_spawner_loop(void) {
spawn_mist_particles_variable(0, 10, 30.0f);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
+1 -1
View File
@@ -22,7 +22,7 @@ void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
break;
}
o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw;
if (!o->parentObj->activeFlags)
if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED)
obj_mark_for_deletion(o);
}
+1 -1
View File
@@ -110,7 +110,7 @@ static void cloud_act_main(void) {
if (o->parentObj != o) {
// Despawn if the parent lakitu does
if (o->parentObj->activeFlags == ACTIVE_FLAGS_DEACTIVATED) {
if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED) {
o->oAction = CLOUD_ACT_UNLOAD;
} else {
o->oCloudCenterX = o->parentObj->oPosX;
@@ -46,8 +46,8 @@ void bhv_controllable_platform_sub_loop(void) {
o->oVelX = o->parentObj->oVelX;
o->oVelZ = o->parentObj->oVelZ;
if (o->parentObj->activeFlags == 0)
o->activeFlags = 0;
if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED)
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_controllable_platform_init(void) {
+3 -3
View File
@@ -26,13 +26,13 @@ void bhv_bobomb_explosion_bubble_loop(void) {
o->oBobombExpBubGfxScaleFacY += o->oBobombExpBubGfxExpRateY;
if (o->oPosY > waterY) {
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
o->oPosY += 5.0f;
spawn_object(o, MODEL_SMALL_WATER_SPLASH, bhvObjectWaterSplash);
}
if (o->oTimer >= 61)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
o->oPosY += o->oVelY;
o->oTimer++;
@@ -44,7 +44,7 @@ void bhv_respawner_loop(void) {
if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, o->oRespawnerMinSpawnDist)) {
spawnedObject = spawn_object(o, o->oRespawnerModelToRespawn, o->oRespawnerBehaviorToRespawn);
spawnedObject->oBehParams = o->oBehParams;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ void bhv_dorrie_update(void) {
UNUSED s32 unused2;
f32 maxOffsetY;
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
o->oDorrieForwardDistToMario = o->oDistanceToMario * coss(o->oAngleToMario - o->oMoveAngleYaw);
obj_perform_position_op(0);
+1 -1
View File
@@ -13,7 +13,7 @@ void bhv_lll_drawbridge_spawner_loop(void) {
drawbridge2->oPosX += coss(o->oMoveAngleYaw) * -640.0f;
drawbridge2->oPosZ += sins(o->oMoveAngleYaw) * -640.0f;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_lll_drawbridge_loop(void) {
+3 -3
View File
@@ -42,7 +42,7 @@ void elevator_act_1(void) {
}
}
void elevator_act_2() // Pretty similar code to action 1
void elevator_act_2(void) // Pretty similar code to action 1
{
cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1);
if (o->oTimer == 0 && cur_obj_is_mario_on_platform())
@@ -62,7 +62,7 @@ void elevator_act_2() // Pretty similar code to action 1
}
}
void elevator_act_4() {
void elevator_act_4(void) {
o->oVelY = 0;
if (o->oTimer == 0) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
@@ -72,7 +72,7 @@ void elevator_act_4() {
o->oAction = 1;
}
void elevator_act_3() // nearly identical to action 2
void elevator_act_3(void) // nearly identical to action 2
{
o->oVelY = 0;
if (o->oTimer == 0) {
+1 -1
View File
@@ -17,7 +17,7 @@ void bhv_explosion_loop(void) {
} else
spawn_object(o, MODEL_SMOKE, bhvBobombBullyDeathSmoke);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
o->oOpacity -= 14;
+3 -3
View File
@@ -109,7 +109,7 @@ void bhv_falling_pillar_loop(void) {
spawn_mist_particles_variable(0, 0, 92.0f);
// Go invisible.
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
// Play the hitting the ground sound.
create_sound_spawner(SOUND_GENERAL_BIG_POUND);
@@ -139,6 +139,6 @@ void bhv_falling_pillar_hitbox_loop(void) {
obj_set_hitbox(o, &sFallingPillarHitbox);
// When the pillar goes inactive, the hitboxes also go inactive.
if (o->parentObj->activeFlags == 0)
o->activeFlags = 0;
if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED)
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
+2 -2
View File
@@ -9,8 +9,8 @@
* Properties for the ferris wheel axle and platforms.
*/
struct FerrisWheelProperties {
void *axleCollision;
void *platformCollision;
void const *axleCollision;
void const *platformCollision;
s16 platformModel;
};
+1 -1
View File
@@ -13,7 +13,7 @@ void fish_act_spawn(void) {
s32 schoolQuantity;
s16 model;
f32 minDistToMario;
struct Animation **fishAnimation;
const struct Animation * const*fishAnimation;
struct Object *fishObject;
switch (o->oBehParams2ndByte) {
+1 -1
View File
@@ -100,7 +100,7 @@ static void fly_guy_act_lunge(void) {
cur_obj_rotate_yaw_toward(o->oFaceAngleYaw, 0x800);
obj_face_pitch_approach(o->oFlyGuyLungeTargetPitch, 0x400);
// Range [-0x1000, 0x2000]
// Possible values: {-0x1000, 0x0000, 0x1000}
o->oFlyGuyTargetRoll = 0x1000 * (s16)(random_float() * 3.0f) - 0x1000;
o->oTimer = 0;
} else {
@@ -98,7 +98,7 @@ void flying_bookend_act_3(void) {
}
void bhv_flying_bookend_loop(void) {
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
o->oDeathSound = SOUND_OBJ_POUNDING1;
cur_obj_scale(o->header.gfx.scale[0]);
@@ -130,7 +130,7 @@ void bhv_flying_bookend_loop(void) {
void bhv_bookend_spawn_loop(void) {
struct Object *sp1C;
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
if (o->oTimer > 40 && obj_is_near_to_and_facing_mario(600.0f, 0x2000)) {
sp1C = spawn_object(o, MODEL_BOOKEND, bhvFlyingBookend);
if (sp1C != NULL) {
@@ -145,7 +145,7 @@ void bhv_bookend_spawn_loop(void) {
void bookshelf_manager_act_0(void) {
s32 val04;
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
for (val04 = 0; val04 < 3; val04++) {
spawn_object_relative(val04, D_80331B30[val04].unk00, D_80331B30[val04].unk02, 0, o,
MODEL_BOOKEND, bhvBookSwitch);
@@ -167,7 +167,7 @@ void bookshelf_manager_act_1(void) {
}
void bookshelf_manager_act_2(void) {
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
if (o->oBookSwitchManagerUnkF4 < 0) {
if (o->oTimer > 30) {
o->oBookSwitchManagerUnkF4 = o->oBookSwitchManagerUnkF8 = 0;
+14 -16
View File
@@ -1,9 +1,7 @@
// grill_door.c.inc
extern u8 bob_seg7_collision_gate[];
extern u8 hmc_seg7_collision_0702B65C[];
struct Struct8032FCE8 D_8032FCE8[] = { { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate },
{ 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C } };
struct OpenableGrill gOpenableGrills[] = { { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate },
{ 410, MODEL_HMC_RED_GRILLS, hmc_seg7_collision_0702B65C } };
void bhv_openable_cage_door_loop(void) {
if (gCurrentObject->oAction == 0) {
@@ -18,18 +16,18 @@ void bhv_openable_cage_door_loop(void) {
}
void bhv_openable_grill_loop(void) {
struct Object *sp3C;
s32 sp38;
struct Object *grillObj;
s32 grillIdx;
switch (o->oAction) {
case 0:
sp38 = o->oBehParams2ndByte;
sp3C = spawn_object_relative(-1, D_8032FCE8[sp38].unk0, 0, 0, o, D_8032FCE8[sp38].unk1,
bhvOpenableCageDoor);
sp3C->oMoveAngleYaw += 0x8000;
obj_set_collision_data(sp3C, D_8032FCE8[sp38].unk2);
sp3C = spawn_object_relative(1, -D_8032FCE8[sp38].unk0, 0, 0, o, D_8032FCE8[sp38].unk1,
bhvOpenableCageDoor);
obj_set_collision_data(sp3C, D_8032FCE8[sp38].unk2);
grillIdx = o->oBehParams2ndByte;
grillObj = spawn_object_relative(-1, gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID,
bhvOpenableCageDoor);
grillObj->oMoveAngleYaw += 0x8000;
obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision);
grillObj = spawn_object_relative(1, -gOpenableGrills[grillIdx].halfWidth, 0, 0, o, gOpenableGrills[grillIdx].modelID,
bhvOpenableCageDoor);
obj_set_collision_data(grillObj, gOpenableGrills[grillIdx].collision);
o->oAction++;
break;
case 1:
@@ -38,8 +36,8 @@ void bhv_openable_grill_loop(void) {
o->oAction++;
break;
case 2:
sp3C = o->oOpenableGrillUnkF4;
if (sp3C->oAction == 2) {
grillObj = o->oOpenableGrillUnkF4;
if (grillObj->oAction == 2) {
o->oOpenableGrillUnk88 = 2;
cur_obj_play_sound_2(SOUND_GENERAL_CAGE_OPEN);
o->oAction++;
+1 -1
View File
@@ -128,7 +128,7 @@ void haunted_chair_act_1(void) {
}
void bhv_haunted_chair_loop(void) {
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
switch (o->oAction) {
case 0:
haunted_chair_act_0();
+4 -4
View File
@@ -9,7 +9,7 @@ void bhv_hidden_star_init(void) {
sp30 =
spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0);
sp30->oBehParams = o->oBehParams;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
o->oHiddenStarTriggerCounter = 5 - sp36;
@@ -26,7 +26,7 @@ void bhv_hidden_star_loop(void) {
if (o->oTimer > 2) {
spawn_red_coin_cutscene_star(o->oPosX, o->oPosY, o->oPosZ);
spawn_mist_particles();
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
break;
}
@@ -52,7 +52,7 @@ void bhv_hidden_star_trigger_loop(void) {
#endif
}
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -68,7 +68,7 @@ void bhv_bowser_course_red_coin_star_loop(void) {
if (o->oTimer > 2) {
spawn_no_exit_star(o->oPosX, o->oPosY, o->oPosZ);
spawn_mist_particles();
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
break;
}
+2 -2
View File
@@ -192,7 +192,7 @@ void king_bobomb_act_8(void) {
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
}
void king_bobomb_act_4() { // bobomb been thrown
void king_bobomb_act_4(void) { // bobomb been thrown
if (o->oPosY - o->oHomeY > -100.0f) { // not thrown off hill
if (o->oMoveFlags & 1) {
o->oHealth--;
@@ -220,7 +220,7 @@ void king_bobomb_act_4() { // bobomb been thrown
}
}
void king_bobomb_act_5() { // bobomb returns home
void king_bobomb_act_5(void) { // bobomb returns home
switch (o->oSubAction) {
case 0:
if (o->oTimer == 0)
+1 -1
View File
@@ -53,7 +53,7 @@ static u8 sKoopaShelledAttackHandlers[] = {
struct KoopaTheQuickProperties {
s16 initText;
s16 winText;
void *path;
void const *path;
Vec3s starPos;
};
@@ -3,8 +3,8 @@
void bhv_lll_wood_piece_loop(void) {
if (o->oTimer == 0)
o->oPosY -= 100.0f;
o->oPosY += sins(o->oLllWoodPieceUnkF4) * 3.0f;
o->oLllWoodPieceUnkF4 += 0x400;
o->oPosY += sins(o->oLllWoodPieceOscillationTimer) * 3.0f;
o->oLllWoodPieceOscillationTimer += 0x400;
if (o->parentObj->oAction == 2)
obj_mark_for_deletion(o);
}
@@ -18,7 +18,7 @@ void bhv_lll_floating_wood_bridge_loop(void) {
for (i = 1; i < 4; i++) {
sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, MODEL_LLL_WOOD_BRIDGE,
bhvLllWoodPiece);
sp3C->oLllWoodPieceUnkF4 = i * 4096;
sp3C->oLllWoodPieceOscillationTimer = i * 4096;
}
o->oAction = 1;
}
@@ -6,8 +6,8 @@ void sinking_rectangular_plat_actions(f32 a0, s32 a1) {
o->oAction++;
break;
case 1:
o->oPosY -= sins(o->oLllWoodPieceUnkF4) * a0;
o->oLllWoodPieceUnkF4 += a1;
o->oPosY -= sins(o->oLllWoodPieceOscillationTimer) * a0;
o->oLllWoodPieceOscillationTimer += a1;
break;
case 2:
break;
@@ -21,8 +21,8 @@ void bhv_lll_sinking_rectangular_platform_loop(void) {
if (o->oMoveAngleYaw != 0)
sinking_rectangular_plat_actions(sp1C, sp18);
else {
o->oFaceAnglePitch = sins(o->oLllWoodPieceUnkF4) * 512.0f;
o->oLllWoodPieceUnkF4 += 0x100;
o->oFaceAnglePitch = sins(o->oLllWoodPieceOscillationTimer) * 512.0f;
o->oLllWoodPieceOscillationTimer += 0x100;
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ static void mad_piano_act_attack(void) {
}
void bhv_mad_piano_update(void) {
if (!(o->activeFlags & 0x0008)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
o->oFaceAngleYaw = o->oMoveAngleYaw - 0x4000;
switch (o->oAction) {
+1 -1
View File
@@ -27,7 +27,7 @@ void bhv_mips_init(void) {
#endif
} else {
// No MIPS stars are available, hide MIPS.
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
o->oInteractionSubtype = INT_SUBTYPE_HOLDABLE_NPC;
+3 -3
View File
@@ -166,7 +166,7 @@ void moneybag_act_disappear(void) {
o->oOpacity -= 6;
if (o->oOpacity < 0) {
o->oOpacity = 0;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -175,7 +175,7 @@ void moneybag_act_death(void) {
obj_spawn_yellow_coins(o, 5);
create_sound_spawner(SOUND_GENERAL_SPLATTERING);
spawn_mist_particles();
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -186,7 +186,7 @@ void bhv_moneybag_loop(void) {
o->oOpacity += 12;
if (o->oOpacity >= 256) {
o->oOpacity = 255;
o->parentObj->activeFlags = 0;
o->parentObj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
o->oAction = MONEYBAG_ACT_MOVE_AROUND;
}
break;
+2 -2
View File
@@ -42,7 +42,7 @@ static struct Object *link_objects_with_behavior(const BehaviorScript *behavior)
obj = (struct Object *) listHead->next;
while (obj != (struct Object *) listHead) {
if (obj->behavior == behaviorAddr && obj->activeFlags != ACTIVE_FLAGS_DEACTIVATED) {
if (obj->behavior == behaviorAddr && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) {
obj->parentObj = lastObject;
lastObject = obj;
}
@@ -126,7 +126,7 @@ void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) {
/* sizeBase: */ 10.0f,
/* sizeRange: */ 7.0f,
};
sMontyMoleRiseFromGroundParticles.offsetY = offsetY;
sMontyMoleRiseFromGroundParticles.velYBase = velYBase;
cur_obj_spawn_particles(&sMontyMoleRiseFromGroundParticles);
+5 -5
View File
@@ -49,7 +49,7 @@ void moving_coin_flicker(void) {
void coin_collected(void) {
spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles);
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_moving_yellow_coin_init(void) {
@@ -80,11 +80,11 @@ void bhv_moving_yellow_coin_loop(void) {
break;
case MOV_YCOIN_ACT_LAVA_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
case MOV_YCOIN_ACT_DEATH_PLANE_DEATH:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
}
@@ -206,11 +206,11 @@ void bhv_blue_coin_sliding_loop(void) {
break;
case 100:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
case 101:
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
}
+67 -67
View File
@@ -37,8 +37,8 @@ void mr_blizzard_spawn_white_particles(s8 count, s8 offsetY, s8 forwardVelBase,
void bhv_mr_blizzard_init(void) {
if (o->oBehParams2ndByte == 1) {
o->oAction = 7;
o->oMrBlizzardUnk10C = 24.0f;
o->oMrBlizzardUnk1AC = o->oMoveAngleYaw;
o->oMrBlizzardGraphYOffset = 24.0f;
o->oMrBlizzardTargetMoveYaw = o->oMoveAngleYaw;
} else {
if (o->oBehParams2ndByte != 0) {
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_MR_BLIZZARD) {
@@ -46,19 +46,19 @@ void bhv_mr_blizzard_init(void) {
}
}
o->oMrBlizzardUnk10C = -200.0f;
o->oMrBlizzardUnkF8 = NULL;
o->oMrBlizzardGraphYOffset = -200.0f;
o->oMrBlizzardHeldObj = NULL;
}
}
static void mr_blizzard_act_0(void) {
if (o->oMrBlizzardUnkF8 == NULL && cur_obj_init_anim_check_frame(0, 5)) {
o->oMrBlizzardUnkF8 = spawn_object_relative(0, -70, (s32)(o->oMrBlizzardUnk10C + 153.0f), 0, o,
if (o->oMrBlizzardHeldObj == NULL && cur_obj_init_anim_check_frame(0, 5)) {
o->oMrBlizzardHeldObj = spawn_object_relative(0, -70, (s32)(o->oMrBlizzardGraphYOffset + 153.0f), 0, o,
MODEL_WHITE_PARTICLE, bhvMrBlizzardSnowball);
} else if (cur_obj_check_anim_frame(10)) {
o->prevObj = o->oMrBlizzardUnkF8;
o->prevObj = o->oMrBlizzardHeldObj;
} else if (cur_obj_check_if_near_animation_end()) {
if (o->oMrBlizzardUnk10C < 0.0f) {
if (o->oMrBlizzardGraphYOffset < 0.0f) {
o->oAction = 1;
} else {
o->oAction = 3;
@@ -71,7 +71,7 @@ static void mr_blizzard_act_1(void) {
cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND2);
o->oAction = 2;
o->oMoveAngleYaw = o->oAngleToMario;
o->oMrBlizzardUnkFC = 42.0f;
o->oMrBlizzardGraphYVel = 42.0f;
mr_blizzard_spawn_white_particles(8, -10, 15, 20, 10);
cur_obj_unhide();
@@ -82,19 +82,19 @@ static void mr_blizzard_act_1(void) {
}
static void mr_blizzard_act_2(void) {
if (o->oMrBlizzardUnk100 != 0) {
o->oMrBlizzardUnk100 -= 1;
} else if ((o->oMrBlizzardUnk10C += o->oMrBlizzardUnkFC) > 24.0f) {
o->oPosY += o->oMrBlizzardUnk10C - 24.0f;
o->oMrBlizzardUnk10C = 24.0f;
if (o->oMrBlizzardTimer != 0) {
o->oMrBlizzardTimer -= 1;
} else if ((o->oMrBlizzardGraphYOffset += o->oMrBlizzardGraphYVel) > 24.0f) {
o->oPosY += o->oMrBlizzardGraphYOffset - 24.0f;
o->oMrBlizzardGraphYOffset = 24.0f;
mr_blizzard_spawn_white_particles(8, -20, 20, 15, 10);
o->oAction = 3;
o->oVelY = o->oMrBlizzardUnkFC;
} else if ((o->oMrBlizzardUnkFC -= 10.0f) < 0.0f) {
o->oMrBlizzardUnkFC = 47.0f;
o->oMrBlizzardUnk100 = 5;
o->oVelY = o->oMrBlizzardGraphYVel;
} else if ((o->oMrBlizzardGraphYVel -= 10.0f) < 0.0f) {
o->oMrBlizzardGraphYVel = 47.0f;
o->oMrBlizzardTimer = 5;
}
}
@@ -108,36 +108,36 @@ static void mr_blizzard_act_3(void) {
val06 = o->oAngleToMario - o->oMoveAngleYaw;
if (val06 != 0) {
if (val06 < 0) {
o->oMrBlizzardUnk108 -= 8.0f;
o->oMrBlizzardChangeInDizziness -= 8.0f;
} else {
o->oMrBlizzardUnk108 += 8.0f;
o->oMrBlizzardChangeInDizziness += 8.0f;
}
o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108;
} else if (o->oMrBlizzardUnk104 != 0.0f) {
val00 = o->oMrBlizzardUnk104;
if (o->oMrBlizzardUnk104 < 0.0f) {
approach_f32_ptr(&o->oMrBlizzardUnk108, 1000.0f, 80.0f);
o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness;
} else if (o->oMrBlizzardDizziness != 0.0f) {
val00 = o->oMrBlizzardDizziness;
if (o->oMrBlizzardDizziness < 0.0f) {
approach_f32_ptr(&o->oMrBlizzardChangeInDizziness, 1000.0f, 80.0f);
} else {
approach_f32_ptr(&o->oMrBlizzardUnk108, -1000.0f, 80.0f);
approach_f32_ptr(&o->oMrBlizzardChangeInDizziness, -1000.0f, 80.0f);
}
o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108;
if (val00 * o->oMrBlizzardUnk104 < 0.0f) {
o->oMrBlizzardUnk104 = o->oMrBlizzardUnk108 = 0.0f;
o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness;
if (val00 * o->oMrBlizzardDizziness < 0.0f) {
o->oMrBlizzardDizziness = o->oMrBlizzardChangeInDizziness = 0.0f;
}
}
if (o->oMrBlizzardUnk104 != 0.0f) {
if (o->oMrBlizzardDizziness != 0.0f) {
if (absi(o->oFaceAngleRoll) > 0x3000) {
o->oAction = 6;
o->prevObj = o->oMrBlizzardUnkF8 = NULL;
o->prevObj = o->oMrBlizzardHeldObj = NULL;
cur_obj_become_intangible();
}
} else if (o->oDistanceToMario > 1500.0f) {
o->oAction = 5;
o->oMrBlizzardUnk108 = 300.0f;
o->prevObj = o->oMrBlizzardUnkF8 = NULL;
o->oMrBlizzardChangeInDizziness = 300.0f;
o->prevObj = o->oMrBlizzardHeldObj = NULL;
} else if (o->oTimer > 60 && abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) {
o->oAction = 4;
}
@@ -147,8 +147,8 @@ static void mr_blizzard_act_3(void) {
static void mr_blizzard_act_6(void) {
struct Object *val04;
if (clamp_f32(&o->oMrBlizzardUnk104, -0x4000, 0x4000)) {
if (o->oMrBlizzardUnk108 != 0.0f) {
if (clamp_f32(&o->oMrBlizzardDizziness, -0x4000, 0x4000)) {
if (o->oMrBlizzardChangeInDizziness != 0.0f) {
cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1);
if (o->oAnimState) {
save_file_clear_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
@@ -163,16 +163,16 @@ static void mr_blizzard_act_6(void) {
o->oAnimState = 0;
}
o->oMrBlizzardUnk108 = 0.0f;
o->oMrBlizzardChangeInDizziness = 0.0f;
}
} else {
if (o->oMrBlizzardUnk104 < 0) {
o->oMrBlizzardUnk108 -= 40.0f;
if (o->oMrBlizzardDizziness < 0) {
o->oMrBlizzardChangeInDizziness -= 40.0f;
} else {
o->oMrBlizzardUnk108 += 40.0f;
o->oMrBlizzardChangeInDizziness += 40.0f;
}
o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108;
o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness;
}
if (o->oTimer >= 30) {
@@ -180,9 +180,9 @@ static void mr_blizzard_act_6(void) {
cur_obj_play_sound_2(SOUND_OBJ_ENEMY_DEFEAT_SHRINK);
}
if (o->oMrBlizzardUnkF4 != 0.0f) {
if ((o->oMrBlizzardUnkF4 -= 0.03f) <= 0.0f) {
o->oMrBlizzardUnkF4 = 0.0f;
if (o->oMrBlizzardScale != 0.0f) {
if ((o->oMrBlizzardScale -= 0.03f) <= 0.0f) {
o->oMrBlizzardScale = 0.0f;
if (!(o->oBehParams & 0x0000FF00)) {
obj_spawn_loot_yellow_coins(o, o->oNumLootCoins, 20.0f);
set_object_respawn_info_bits(o, 1);
@@ -192,10 +192,10 @@ static void mr_blizzard_act_6(void) {
cur_obj_init_animation_with_sound(1);
o->oAction = 0;
o->oMrBlizzardUnkF4 = 1.0f;
o->oMrBlizzardUnk10C = -200.0f;
o->oMrBlizzardScale = 1.0f;
o->oMrBlizzardGraphYOffset = -200.0f;
o->oFaceAngleRoll = 0;
o->oMrBlizzardUnk104 = o->oMrBlizzardUnk108 = 0.0f;
o->oMrBlizzardDizziness = o->oMrBlizzardChangeInDizziness = 0.0f;
}
}
}
@@ -203,39 +203,39 @@ static void mr_blizzard_act_6(void) {
static void mr_blizzard_act_4(void) {
if (cur_obj_init_anim_check_frame(1, 7)) {
cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
o->prevObj = o->oMrBlizzardUnkF8 = NULL;
o->prevObj = o->oMrBlizzardHeldObj = NULL;
} else if (cur_obj_check_if_near_animation_end()) {
o->oAction = 0;
}
}
static void mr_blizzard_act_5(void) {
o->oMrBlizzardUnk104 += o->oMrBlizzardUnk108;
o->oMrBlizzardDizziness += o->oMrBlizzardChangeInDizziness;
if (o->oMrBlizzardUnk104 < 0.0f) {
o->oMrBlizzardUnk108 += 150.0f;
if (o->oMrBlizzardDizziness < 0.0f) {
o->oMrBlizzardChangeInDizziness += 150.0f;
} else {
o->oMrBlizzardUnk108 -= 150.0f;
o->oMrBlizzardChangeInDizziness -= 150.0f;
}
if (approach_f32_ptr(&o->oMrBlizzardUnk10C, -200.0f, 4.0f)) {
if (approach_f32_ptr(&o->oMrBlizzardGraphYOffset, -200.0f, 4.0f)) {
o->oAction = 0;
cur_obj_init_animation_with_sound(1);
}
}
static void mr_blizzard_act_7(void) {
if (o->oMrBlizzardUnk100 != 0) {
cur_obj_rotate_yaw_toward(o->oMrBlizzardUnk1AC, 3400);
if (o->oMrBlizzardTimer != 0) {
cur_obj_rotate_yaw_toward(o->oMrBlizzardTargetMoveYaw, 3400);
if (--o->oMrBlizzardUnk100 == 0) {
if (--o->oMrBlizzardTimer == 0) {
cur_obj_play_sound_2(SOUND_OBJ_MR_BLIZZARD_ALERT);
if (o->oMrBlizzardUnk110 > 700) {
o->oMrBlizzardUnk1AC += 0x8000;
if (o->oMrBlizzardDistFromHome > 700) {
o->oMrBlizzardTargetMoveYaw += 0x8000;
o->oVelY = 25.0f;
o->oMrBlizzardUnk100 = 30;
o->oMrBlizzardUnk110 = 0;
o->oMrBlizzardTimer = 30;
o->oMrBlizzardDistFromHome = 0;
} else {
o->oForwardVel = 10.0f;
o->oVelY = 50.0f;
@@ -244,14 +244,14 @@ static void mr_blizzard_act_7(void) {
}
} else if (o->oMoveFlags & 0x00000003) {
cur_obj_play_sound_2(SOUND_OBJ_SNOW_SAND1);
if (o->oMrBlizzardUnk110 != 0) {
o->oMrBlizzardUnk110 = (s32) cur_obj_lateral_dist_to_home();
if (o->oMrBlizzardDistFromHome != 0) {
o->oMrBlizzardDistFromHome = (s32) cur_obj_lateral_dist_to_home();
} else {
o->oMrBlizzardUnk110 = 700;
o->oMrBlizzardDistFromHome = 700;
}
o->oForwardVel = 0.0f;
o->oMrBlizzardUnk100 = 15;
o->oMrBlizzardTimer = 15;
}
}
@@ -285,11 +285,11 @@ void bhv_mr_blizzard_update(void) {
break;
}
o->oFaceAngleRoll = o->oMrBlizzardUnk104;
o->oGraphYOffset = o->oMrBlizzardUnk10C + absf(20.0f * sins(o->oFaceAngleRoll))
- 40.0f * (1.0f - o->oMrBlizzardUnkF4);
o->oFaceAngleRoll = o->oMrBlizzardDizziness;
o->oGraphYOffset = o->oMrBlizzardGraphYOffset + absf(20.0f * sins(o->oFaceAngleRoll))
- 40.0f * (1.0f - o->oMrBlizzardScale);
cur_obj_scale(o->oMrBlizzardUnkF4);
cur_obj_scale(o->oMrBlizzardScale);
cur_obj_move_standard(78);
obj_check_attacks(&sMrBlizzardHitbox, o->oAction);
}
+5 -5
View File
@@ -17,7 +17,7 @@ void mr_i_piranha_particle_act_0(void) {
cur_obj_update_floor_and_walls();
if (0x8000 & o->oInteractStatus)
o->oAction = 1;
else if ((o->oTimer >= 101) || (0x200 & o->oMoveFlags) || (8 & (s16) o->activeFlags)) {
else if ((o->oTimer >= 101) || (0x200 & o->oMoveFlags) || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) {
obj_mark_for_deletion(o);
spawn_mist_particles();
}
@@ -48,7 +48,7 @@ void spawn_mr_i_particle(void) {
void bhv_mr_i_body_loop(void) {
obj_copy_pos_and_angle(o, o->parentObj);
if (!(8 & o->activeFlags)) {
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
obj_copy_scale(o, o->parentObj);
obj_set_parent_relative_pos(o, 0, 0, o->header.gfx.scale[1] * 100.0f);
obj_build_transform_from_pos_and_angle(o, 44, 15);
@@ -63,7 +63,7 @@ void bhv_mr_i_body_loop(void) {
if (o->oAnimState == 15)
o->parentObj->oMrIUnk110 = 0;
}
if (!o->parentObj->activeFlags)
if (o->parentObj->activeFlags == ACTIVE_FLAG_DEACTIVATED)
obj_mark_for_deletion(o);
}
@@ -122,7 +122,7 @@ void mr_i_act_3(void) {
obj_mark_for_deletion(o);
}
void mr_i_act_2() {
void mr_i_act_2(void) {
s16 sp1E;
s16 sp1C;
sp1E = o->oMoveAngleYaw;
@@ -248,7 +248,7 @@ void bhv_mr_i_loop(void) {
obj_set_hitbox(o, &sMrIHitbox);
cur_obj_call_action_function(sMrIActions);
if (o->oAction != 3)
if (o->oDistanceToMario > 3000.0f || o->activeFlags & 8)
if (o->oDistanceToMario > 3000.0f || o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)
o->oAction = 0;
o->oInteractStatus = 0;
}
+6 -6
View File
@@ -6,7 +6,7 @@ void bhv_1up_interact(void) {
if (obj_check_if_collided_with_object(o, gMarioObject) == 1) {
play_sound(SOUND_GENERAL_COLLECT_1UP, gDefaultSoundArgs);
gMarioState->numLives++;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -21,10 +21,10 @@ void bhv_1up_init(void) {
bhv_1up_common_init();
if (o->oBehParams2ndByte == 1) {
if ((save_file_get_flags() & 0x50) == 0)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
} else if (o->oBehParams2ndByte == 2) {
if ((save_file_get_flags() & 0xa0) == 0)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -254,7 +254,7 @@ void bhv_1up_hidden_trigger_loop(void) {
if (sp1C != NULL)
sp1C->o1UpHiddenUnkF4++;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -302,7 +302,7 @@ void bhv_1up_hidden_in_pole_trigger_loop(void) {
;
}
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -315,6 +315,6 @@ void bhv_1up_hidden_in_pole_spawner_loop(void) {
spawn_object_relative(0, 0, sp2F * -200, 0, o, MODEL_NONE, bhvHidden1upInPoleTrigger);
}
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
+1 -1
View File
@@ -15,6 +15,6 @@ void bhv_orange_number_loop(void) {
if (o->oTimer == 35) {
sp1C = spawn_object(o, MODEL_SPARKLES, bhvGoldenCoinSparkles);
sp1C->oPosY -= 30.f;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
+2 -2
View File
@@ -8,7 +8,7 @@
/**
* Collision models for the different types of platforms.
*/
static void *sPlatformOnTrackCollisionModels[] = {
static void const *sPlatformOnTrackCollisionModels[] = {
/* PLATFORM_ON_TRACK_TYPE_CARPET */ rr_seg7_collision_07029038,
/* PLATFORM_ON_TRACK_TYPE_SKI_LIFT */ ccm_seg7_collision_070163F8,
/* PLATFORM_ON_TRACK_TYPE_CHECKERED */ checkerboard_platform_seg8_collision_0800D710,
@@ -18,7 +18,7 @@ static void *sPlatformOnTrackCollisionModels[] = {
/**
* Paths for the different instances of these platforms.
*/
static void *sPlatformOnTrackPaths[] = {
static void const *sPlatformOnTrackPaths[] = {
rr_seg7_trajectory_0702EC3C, rr_seg7_trajectory_0702ECC0, ccm_seg7_trajectory_0701669C,
bitfs_seg7_trajectory_070159AC, hmc_seg7_trajectory_0702B86C, lll_seg7_trajectory_0702856C,
lll_seg7_trajectory_07028660, rr_seg7_trajectory_0702ED9C, rr_seg7_trajectory_0702EEE0,
+1 -1
View File
@@ -79,7 +79,7 @@ void bhv_pyramid_elevator_trajectory_marker_ball_loop(void) {
if (elevator != NULL) {
if (elevator->oAction != PYRAMID_ELEVATOR_IDLE) {
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
}
+3 -3
View File
@@ -87,7 +87,7 @@ void bhv_pyramid_top_explode(void) {
}
// Deactivate the pyramid top.
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
void bhv_pyramid_top_loop(void) {
@@ -137,7 +137,7 @@ void bhv_pyramid_top_fragment_loop(void) {
o->oFaceAnglePitch += 0x1000;
if (o->oTimer == 60) {
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -150,6 +150,6 @@ void bhv_pyramid_pillar_touch_detector_loop(void) {
if (obj_check_if_collided_with_object(o, gMarioObject) == 1) {
// Increase the pyramid top's count of pillars touched.
o->parentObj->oPyramidTopPillarsTouched++;
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
}
@@ -1,6 +1,6 @@
// rotating_octagonal_plat.inc.c
void *D_80331A44[] = {
void const *D_80331A44[] = {
bits_seg7_collision_0701AA84,
rr_seg7_collision_07029508,
};
+6 -6
View File
@@ -12,12 +12,12 @@ struct ObjectHitbox sScuttlebugHitbox = {
/* hurtboxHeight: */ 60,
};
s32 update_angle_from_move_flags(s32 *a0) {
if (o->oMoveFlags & 0x200) {
*a0 = o->oWallAngle;
s32 update_angle_from_move_flags(s32 *angle) {
if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) {
*angle = o->oWallAngle;
return 1;
} else if (o->oMoveFlags & 0x400) {
*a0 = o->oMoveAngleYaw + 0x8000;
} else if (o->oMoveFlags & OBJ_MOVE_HIT_EDGE) {
*angle = o->oMoveAngleYaw + 0x8000;
return -1;
}
return 0;
@@ -110,7 +110,7 @@ void bhv_scuttlebug_loop(void) {
if (o->parentObj != o) {
if (obj_is_hidden(o))
obj_mark_for_deletion(o);
if (o->activeFlags == 0)
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED)
o->parentObj->oScuttlebugSpawnerUnk88 = 1;
}
cur_obj_move_standard(-50);
+1 -1
View File
@@ -6,7 +6,7 @@
/**
* Collision models for the different seesaw platforms.
*/
static void *sSeesawPlatformCollisionModels[] = {
static void const *sSeesawPlatformCollisionModels[] = {
bitdw_seg7_collision_0700F70C, bits_seg7_collision_0701ADD8, bits_seg7_collision_0701AE5C,
bob_seg7_collision_bridge, bitfs_seg7_collision_07015928, rr_seg7_collision_07029750,
rr_seg7_collision_07029858, vcutm_seg7_collision_0700AC44,
+1 -1
View File
@@ -1,6 +1,6 @@
// sliding_platform_2.inc.c
void *D_80331A24[] = {
void const *D_80331A24[] = {
bits_seg7_collision_0701A9A0,
bits_seg7_collision_0701AA0C,
bitfs_seg7_collision_07015714,
+1 -1
View File
@@ -18,7 +18,7 @@ void bhv_sliding_snow_mound_loop(void) {
o->oPosY += o->oVelY;
o->oPosZ = o->oHomeZ - 2.0f;
if (o->oTimer > 50)
o->activeFlags = 0;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
break;
}
}

Some files were not shown because too many files have changed in this diff Show More