refresh 6
This commit is contained in:
1 parent
9273f38df1
commit
9a801cb96d
236 files changed
+17101
-4820
No files matched your search
+249
-17
@@ -4,6 +4,40 @@
|
||||
#include "data.h"
|
||||
#include "effects.h"
|
||||
|
||||
extern struct OSMesgQueue *OSMesgQueue0;
|
||||
extern struct OSMesgQueue *OSMesgQueue1;
|
||||
extern struct OSMesgQueue *OSMesgQueue2;
|
||||
extern struct OSMesgQueue *OSMesgQueue3;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct ReverbSettingsEU sReverbSettings[] = {
|
||||
{ 0x04, 0x0c, 0x2fff },
|
||||
{ 0x04, 0x0a, 0x47ff },
|
||||
{ 0x04, 0x10, 0x2fff },
|
||||
{ 0x04, 0x0e, 0x3fff },
|
||||
{ 0x04, 0x0c, 0x4fff },
|
||||
{ 0x04, 0x0a, 0x37ff }
|
||||
};
|
||||
struct AudioSessionSettingsEU gAudioSessionPresets[] = {
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[2], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[3], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[4], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
|
||||
0x00004400, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00004000, 0x00006e00,
|
||||
0x00003f00, 0x00002a00 },
|
||||
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00004100, 0x00006e00,
|
||||
0x00004400, 0x00002a80 },
|
||||
{ 0x00007d00, 0x01, 0x14, 0x01, 0x00, &sReverbSettings[5], 0x7fff, 0x0000, 0x00003500, 0x00006280,
|
||||
0x00004000, 0x00001b00 }
|
||||
};
|
||||
#endif
|
||||
|
||||
// Format:
|
||||
// - frequency
|
||||
// - max number of simultaneous notes
|
||||
@@ -15,6 +49,7 @@
|
||||
// - memory used for persistent banks
|
||||
// - memory used for temporary sequences
|
||||
// - memory used for temporary banks
|
||||
#ifndef VERSION_EU
|
||||
struct AudioSessionSettings gAudioSessionPresets[18] = {
|
||||
#ifdef VERSION_JP
|
||||
{ 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
|
||||
@@ -46,8 +81,9 @@ struct AudioSessionSettings gAudioSessionPresets[18] = {
|
||||
{ 32000, 8, 1, 0x0800, 0x2FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
#endif
|
||||
// gAudioCosineTable[k] = round((2**15 - 1) * cos(pi/2 * k / 127)). Unused.
|
||||
#ifndef VERSION_EU
|
||||
u16 gAudioCosineTable[128] = {
|
||||
0x7FFF, 32764, 32757, 32744, 32727, 32704, 32677, 32644, 32607, 32564, 32517, 32464, 32407,
|
||||
32344, 32277, 32205, 32127, 32045, 31958, 31866, 31770, 31668, 31561, 31450, 31334, 31213,
|
||||
@@ -60,11 +96,17 @@ u16 gAudioCosineTable[128] = {
|
||||
9196, 8806, 8415, 8023, 7630, 7235, 6839, 6442, 6044, 5646, 5246, 4845, 4444,
|
||||
4042, 3640, 3237, 2833, 2429, 2025, 1620, 1216, 810, 405, 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
// Transforms a pitch scale factor in -127..127 into a frequency scale factor
|
||||
// between -1 and +1 octave.
|
||||
// gPitchBendFrequencyScale[k] = 0.5 * 2^(k/127)
|
||||
#ifdef VERSION_EU
|
||||
f32 gPitchBendFrequencyScale[256] = {
|
||||
0.5f,
|
||||
#else
|
||||
f32 gPitchBendFrequencyScale[255] = {
|
||||
#endif
|
||||
0.5f, 0.502736f, 0.505488f, 0.508254f, 0.511036f, 0.513833f, 0.516645f, 0.519472f, 0.522315f,
|
||||
0.525174f, 0.528048f, 0.530938f, 0.533843f, 0.536765f, 0.539702f, 0.542656f, 0.545626f, 0.548612f,
|
||||
0.551614f, 0.554633f, 0.557669f, 0.560721f, 0.563789f, 0.566875f, 0.569977f, 0.573097f, 0.576233f,
|
||||
@@ -127,15 +169,176 @@ u8 gDefaultShortNoteDurationTable[16] = {
|
||||
229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0,
|
||||
};
|
||||
|
||||
#ifndef VERSION_EU
|
||||
// gVibratoCurve[k] = k*8
|
||||
s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
|
||||
#endif
|
||||
|
||||
struct AdsrEnvelope gDefaultEnvelope[] = {
|
||||
{ BSWAP16(4), BSWAP16(32000) }, // go from 0 to 32000 over the course of 16ms
|
||||
{ BSWAP16(1000), BSWAP16(32000) }, // stay there for 4.16 seconds
|
||||
{ BSWAP16(ADSR_HANG), 0 } // then continue staying there
|
||||
{ BSWAP16(ADSR_HANG), 0 } // then continue staying there
|
||||
};
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct NoteSubEu gZeroNoteSub = { 0 };
|
||||
struct NoteSubEu gDefaultNoteSub = { 1, 1 };
|
||||
|
||||
s16 sSawtoothWaves[256] = {
|
||||
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239,
|
||||
11263, 0x2FFF, 13311, 0x37FF, 15359, 0x3FFF, 17407, 0x47FF, 19455, 0x4FFF, 21503,
|
||||
22527, 23551, 24575, 25599, 26623, 27647, 28671, 29695, 30719, 31743, -0x7FFF,
|
||||
-31743, -30719, -29695, -28671, -27647, -26623, -25599, -24575, -23551, -22527, -21503,
|
||||
-0x4FFF, -19455, -0x47FF, -17407, -0x3FFF, -15359, -0x37FF, -13311, -0x2FFF, -11263, -10239,
|
||||
-9215, -8191, -7167, -6143, -5119, -4095, -3071, -2047, -1023,
|
||||
0, 0x7FF, 0xFFF, 0x17FF, 0x1FFF, 0x27FF, 0x2FFF, 0x37FF, 0x3FFF, 0x47FF, 0x4FFF,
|
||||
0x57FF, 0x5FFF, 0x67FF, 0x6FFF, 0x77FF, 0x8001, 0x8801, 0x9001, 0x9801, 0xa001, 0xa801,
|
||||
0xb001, 0xb801, 0xc001, 0xc801, 0xd001, 0xd801, 0xe001, 0xe801, 0xf001, 0xf801, 0x0000,
|
||||
0x07ff, 0x0fff, 0x17ff, 0x1fff, 0x27ff, 0x2fff, 0x37ff, 0x3fff, 0x47ff, 0x4fff, 0x57ff,
|
||||
0x5fff, 0x67ff, 0x6fff, 0x77ff, 0x8001, 0x8801, 0x9001, 0x9801, 0xa001, 0xa801, 0xb001,
|
||||
0xb801, 0xc001, 0xc801, 0xd001, 0xd801, 0xe001, 0xe801, 0xf001, 0xf801,
|
||||
0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff,
|
||||
0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001,
|
||||
0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff,
|
||||
0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001,
|
||||
0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff,
|
||||
0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001,
|
||||
0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff,
|
||||
0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x8001, 0xa001, 0xc001, 0xe001
|
||||
};
|
||||
s16 sTriangleWaves[256] = {
|
||||
0x0000, 0x07ff, 0x0fff, 0x17ff, 0x1fff, 0x27ff, 0x2fff, 0x37ff, 0x3fff, 0x47ff, 0x4fff, 0x57ff,
|
||||
0x5fff, 0x67ff, 0x6fff, 0x77ff, 0x7fff, 0x77ff, 0x6fff, 0x67ff, 0x5fff, 0x57ff, 0x4fff, 0x47ff,
|
||||
0x3fff, 0x37ff, 0x2fff, 0x27ff, 0x1fff, 0x17ff, 0x0fff, 0x07ff, 0x0000, 0xf801, 0xf001, 0xe801,
|
||||
0xe001, 0xd801, 0xd001, 0xc801, 0xc001, 0xb801, 0xb001, 0xa801, 0xa001, 0x9801, 0x9001, 0x8801,
|
||||
0x8001, 0x8801, 0x9001, 0x9801, 0xa001, 0xa801, 0xb001, 0xb801, 0xc001, 0xc801, 0xd001, 0xd801,
|
||||
0xe001, 0xe801, 0xf001, 0xf801, 0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff,
|
||||
0x7fff, 0x6fff, 0x5fff, 0x4fff, 0x3fff, 0x2fff, 0x1fff, 0x0fff, 0x0000, 0xf001, 0xe001, 0xd001,
|
||||
0xc001, 0xb001, 0xa001, 0x9001, 0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001,
|
||||
0x0000, 0x0fff, 0x1fff, 0x2fff, 0x3fff, 0x4fff, 0x5fff, 0x6fff, 0x7fff, 0x6fff, 0x5fff, 0x4fff,
|
||||
0x3fff, 0x2fff, 0x1fff, 0x0fff, 0x0000, 0xf001, 0xe001, 0xd001, 0xc001, 0xb001, 0xa001, 0x9001,
|
||||
0x8001, 0x9001, 0xa001, 0xb001, 0xc001, 0xd001, 0xe001, 0xf001, 0x0000, 0x1fff, 0x3fff, 0x5fff,
|
||||
0x7fff, 0x5fff, 0x3fff, 0x1fff, 0x0000, 0xe001, 0xc001, 0xa001, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x1fff, 0x3fff, 0x5fff, 0x7fff, 0x5fff, 0x3fff, 0x1fff, 0x0000, 0xe001, 0xc001, 0xa001,
|
||||
0x8001, 0xa001, 0xc001, 0xe001, 0x0000, 0x1fff, 0x3fff, 0x5fff, 0x7fff, 0x5fff, 0x3fff, 0x1fff,
|
||||
0x0000, 0xe001, 0xc001, 0xa001, 0x8001, 0xa001, 0xc001, 0xe001, 0x0000, 0x1fff, 0x3fff, 0x5fff,
|
||||
0x7fff, 0x5fff, 0x3fff, 0x1fff, 0x0000, 0xe001, 0xc001, 0xa001, 0x8001, 0xa001, 0xc001, 0xe001,
|
||||
0x0000, 0x3fff, 0x7fff, 0x3fff, 0x0000, 0xc001, 0x8001, 0xc001, 0x0000, 0x3fff, 0x7fff, 0x3fff,
|
||||
0x0000, 0xc001, 0x8001, 0xc001, 0x0000, 0x3fff, 0x7fff, 0x3fff, 0x0000, 0xc001, 0x8001, 0xc001,
|
||||
0x0000, 0x3fff, 0x7fff, 0x3fff, 0x0000, 0xc001, 0x8001, 0xc001, 0x0000, 0x3fff, 0x7fff, 0x3fff,
|
||||
0x0000, 0xc001, 0x8001, 0xc001, 0x0000, 0x3fff, 0x7fff, 0x3fff, 0x0000, 0xc001, 0x8001, 0xc001,
|
||||
0x0000, 0x3fff, 0x7fff, 0x3fff, 0x0000, 0xc001, 0x8001, 0xc001, 0x0000, 0x3fff, 0x7fff, 0x3fff,
|
||||
0x0000, 0xc001, 0x8001, 0xc001,
|
||||
};
|
||||
s16 sSineWaves[256] = {
|
||||
0x0000, 0x0c8b, 0x18f8, 0x2527, 0x30fb, 0x3c56, 0x471c, 0x5133, 0x5a81, 0x62f1, 0x6a6c, 0x70e1,
|
||||
0x7640, 0x7a7c, 0x7d89, 0x7f61, 0x7fff, 0x7f61, 0x7d89, 0x7a7c, 0x7640, 0x70e1, 0x6a6c, 0x62f1,
|
||||
0x5a81, 0x5133, 0x471c, 0x3c56, 0x30fb, 0x2527, 0x18f8, 0x0c8b, 0x0000, 0xf375, 0xe708, 0xdad9,
|
||||
0xcf05, 0xc3aa, 0xb8e4, 0xaecd, 0xa57f, 0x9d0f, 0x9594, 0x8f1f, 0x89c0, 0x8584, 0x8277, 0x809f,
|
||||
0x8001, 0x809f, 0x8277, 0x8584, 0x89c0, 0x8f1f, 0x9594, 0x9d0f, 0xa57f, 0xaecd, 0xb8e4, 0xc3aa,
|
||||
0xcf05, 0xdad9, 0xe708, 0xf375, 0x0000, 0x18f8, 0x30fb, 0x471c, 0x5a81, 0x6a6c, 0x7640, 0x7d89,
|
||||
0x7fff, 0x7d89, 0x7640, 0x6a6c, 0x5a81, 0x471c, 0x30fb, 0x18f8, 0x0000, 0xe708, 0xcf05, 0xb8e4,
|
||||
0xa57f, 0x9594, 0x89c0, 0x8277, 0x8001, 0x8277, 0x89c0, 0x9594, 0xa57f, 0xb8e4, 0xcf05, 0xe708,
|
||||
0x0000, 0x18f8, 0x30fb, 0x471c, 0x5a81, 0x6a6c, 0x7640, 0x7d89, 0x7fff, 0x7d89, 0x7640, 0x6a6c,
|
||||
0x5a81, 0x471c, 0x30fb, 0x18f8, 0x0000, 0xe708, 0xcf05, 0xb8e4, 0xa57f, 0x9594, 0x89c0, 0x8277,
|
||||
0x8001, 0x8277, 0x89c0, 0x9594, 0xa57f, 0xb8e4, 0xcf05, 0xe708, 0x0000, 0x30fb, 0x5a81, 0x7640,
|
||||
0x7fff, 0x7640, 0x5a81, 0x30fb, 0x0000, 0xcf05, 0xa57f, 0x89c0, 0x8001, 0x89c0, 0xa57f, 0xcf05,
|
||||
0x0000, 0x30fb, 0x5a81, 0x7640, 0x7fff, 0x7640, 0x5a81, 0x30fb, 0x0000, 0xcf05, 0xa57f, 0x89c0,
|
||||
0x8001, 0x89c0, 0xa57f, 0xcf05, 0x0000, 0x30fb, 0x5a81, 0x7640, 0x7fff, 0x7640, 0x5a81, 0x30fb,
|
||||
0x0000, 0xcf05, 0xa57f, 0x89c0, 0x8001, 0x89c0, 0xa57f, 0xcf05, 0x0000, 0x30fb, 0x5a81, 0x7640,
|
||||
0x7fff, 0x7640, 0x5a81, 0x30fb, 0x0000, 0xcf05, 0xa57f, 0x89c0, 0x8001, 0x89c0, 0xa57f, 0xcf05,
|
||||
0x0000, 0x5a81, 0x7fff, 0x5a81, 0x0000, 0xa57f, 0x8001, 0xa57f, 0x0000, 0x5a81, 0x7fff, 0x5a81,
|
||||
0x0000, 0xa57f, 0x8001, 0xa57f, 0x0000, 0x5a81, 0x7fff, 0x5a81, 0x0000, 0xa57f, 0x8001, 0xa57f,
|
||||
0x0000, 0x5a81, 0x7fff, 0x5a81, 0x0000, 0xa57f, 0x8001, 0xa57f, 0x0000, 0x5a81, 0x7fff, 0x5a81,
|
||||
0x0000, 0xa57f, 0x8001, 0xa57f, 0x0000, 0x5a81, 0x7fff, 0x5a81, 0x0000, 0xa57f, 0x8001, 0xa57f,
|
||||
0x0000, 0x5a81, 0x7fff, 0x5a81, 0x0000, 0xa57f, 0x8001, 0xa57f, 0x0000, 0x5a81, 0x7fff, 0x5a81,
|
||||
0x0000, 0xa57f, 0x8001, 0xa57f,
|
||||
};
|
||||
s16 sSquareWaves[256] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff,
|
||||
0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001,
|
||||
0x8001, 0x8001, 0x8001, 0x8001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x7fff, 0x7fff,
|
||||
0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x8001, 0x8001, 0x8001, 0x8001,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x8001, 0x8001, 0x8001, 0x8001, 0x0000, 0x0000, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x7fff, 0x7fff,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x8001, 0x8001, 0x8001, 0x8001, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x8001, 0x8001, 0x8001, 0x8001,
|
||||
0x0000, 0x0000, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x8001, 0x8001, 0x0000, 0x0000, 0x7fff, 0x7fff,
|
||||
0x0000, 0x0000, 0x8001, 0x8001, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x8001, 0x8001,
|
||||
0x0000, 0x0000, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x8001, 0x8001, 0x0000, 0x0000, 0x7fff, 0x7fff,
|
||||
0x0000, 0x0000, 0x8001, 0x8001, 0x0000, 0x0000, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x8001, 0x8001,
|
||||
0x0000, 0x0000, 0x7fff, 0x7fff, 0x0000, 0x0000, 0x8001, 0x8001, 0x0000, 0x0000, 0x7fff, 0x7fff,
|
||||
0x0000, 0x0000, 0x8001, 0x8001,
|
||||
};
|
||||
s16 sEuUnknownWave6[256] = {
|
||||
0x0000, 0x9ba7, 0x9b41, 0x6c9b, 0x9450, 0xadda, 0x569e, 0x189a, 0x69bf, 0xb79d, 0x6fe9, 0x08ec,
|
||||
0x0d34, 0x1aea, 0xce76, 0xad86, 0x2710, 0xa038, 0x7e28, 0x2fd8, 0x3af8, 0x3bfa, 0xd10b, 0x84c7,
|
||||
0xcd7f, 0x18f4, 0xd4c8, 0x76f8, 0x8994, 0xaa11, 0x73fb, 0x6c01, 0x0000, 0x93ff, 0x8c05, 0x55ef,
|
||||
0x766c, 0x8907, 0x2b38, 0xe70d, 0x3281, 0x7b38, 0x2ef5, 0xc407, 0xc508, 0xd027, 0x81d8, 0x5fc9,
|
||||
0xd8f0, 0x5279, 0x318a, 0xe517, 0xf2cc, 0xf713, 0x9017, 0x4864, 0x9641, 0xe765, 0xa962, 0x5227,
|
||||
0x6bb0, 0x9364, 0x64bf, 0x645a, 0x0000, 0x9b41, 0x9450, 0x569e, 0x69bf, 0x6fe9, 0x0d34, 0xce76,
|
||||
0x2710, 0x7e28, 0x3af8, 0xd10b, 0xcd7f, 0xd4c8, 0x8994, 0x73fb, 0x0000, 0x8c05, 0x766c, 0x2b38,
|
||||
0x3281, 0x2ef5, 0xc508, 0x81d8, 0xd8f0, 0x318a, 0xf2cc, 0x9017, 0x9641, 0xa962, 0x6bb0, 0x64bf,
|
||||
0x0000, 0x9b41, 0x9450, 0x569e, 0x69bf, 0x6fe9, 0x0d34, 0xce76, 0x2710, 0x7e28, 0x3af8, 0xd10b,
|
||||
0xcd7f, 0xd4c8, 0x8994, 0x73fb, 0x0000, 0x8c05, 0x766c, 0x2b38, 0x3281, 0x2ef5, 0xc508, 0x81d8,
|
||||
0xd8f0, 0x318a, 0xf2cc, 0x9017, 0x9641, 0xa962, 0x6bb0, 0x64bf, 0x0000, 0x9450, 0x69bf, 0x0d34,
|
||||
0x2710, 0x3af8, 0xcd7f, 0x8994, 0x0000, 0x766c, 0x3281, 0xc508, 0xd8f0, 0xf2cc, 0x9641, 0x6bb0,
|
||||
0x0000, 0x9450, 0x69bf, 0x0d34, 0x2710, 0x3af8, 0xcd7f, 0x8994, 0x0000, 0x766c, 0x3281, 0xc508,
|
||||
0xd8f0, 0xf2cc, 0x9641, 0x6bb0, 0x0000, 0x9450, 0x69bf, 0x0d34, 0x2710, 0x3af8, 0xcd7f, 0x8994,
|
||||
0x0000, 0x766c, 0x3281, 0xc508, 0xd8f0, 0xf2cc, 0x9641, 0x6bb0, 0x0000, 0x9450, 0x69bf, 0x0d34,
|
||||
0x2710, 0x3af8, 0xcd7f, 0x8994, 0x0000, 0x766c, 0x3281, 0xc508, 0xd8f0, 0xf2cc, 0x9641, 0x6bb0,
|
||||
0x0000, 0x69bf, 0x2710, 0xcd7f, 0x0000, 0x3281, 0xd8f0, 0x9641, 0x0000, 0x69bf, 0x2710, 0xcd7f,
|
||||
0x0000, 0x3281, 0xd8f0, 0x9641, 0x0000, 0x69bf, 0x2710, 0xcd7f, 0x0000, 0x3281, 0xd8f0, 0x9641,
|
||||
0x0000, 0x69bf, 0x2710, 0xcd7f, 0x0000, 0x3281, 0xd8f0, 0x9641, 0x0000, 0x69bf, 0x2710, 0xcd7f,
|
||||
0x0000, 0x3281, 0xd8f0, 0x9641, 0x0000, 0x69bf, 0x2710, 0xcd7f, 0x0000, 0x3281, 0xd8f0, 0x9641,
|
||||
0x0000, 0x69bf, 0x2710, 0xcd7f, 0x0000, 0x3281, 0xd8f0, 0x9641, 0x0000, 0x69bf, 0x2710, 0xcd7f,
|
||||
0x0000, 0x3281, 0xd8f0, 0x9641,
|
||||
};
|
||||
s16 gEuUnknownWave7[256] = {
|
||||
0x0000, 0x3fbc, 0x4eb4, 0x4f21, 0x6a49, 0x806f, 0x7250, 0x6a7b, 0x8d2e, 0xac0a, 0x98d6, 0x7832,
|
||||
0x7551, 0x71ca, 0x4eee, 0x3731, 0x4e20, 0x644d, 0x4a50, 0x23ba, 0x1b09, 0x119a, 0xe914, 0xccbe,
|
||||
0xe14e, 0xf8a3, 0xe47e, 0xc937, 0xd181, 0xde39, 0xcfc6, 0xcf94, 0x0000, 0x306c, 0x303a, 0x21c7,
|
||||
0x2e7f, 0x36c8, 0x1b82, 0x075e, 0x1eb2, 0x3341, 0x16ec, 0xee67, 0xe4f7, 0xdc45, 0xb5b0, 0x9bb4,
|
||||
0xb1e0, 0xc8ce, 0xb112, 0x8e37, 0x8aaf, 0x87cd, 0x672a, 0x53f7, 0x72d2, 0x9584, 0x8db0, 0x7f92,
|
||||
0x95b7, 0xb0de, 0xb14c, 0xc045, 0x0000, 0x4eb4, 0x6a49, 0x7250, 0x8d2e, 0x98d6, 0x7551, 0x4eee,
|
||||
0x4e20, 0x4a50, 0x1b09, 0xe914, 0xe14e, 0xe47e, 0xd181, 0xcfc6, 0x0000, 0x303a, 0x2e7f, 0x1b82,
|
||||
0x1eb2, 0x16ec, 0xe4f7, 0xb5b0, 0xb1e0, 0xb112, 0x8aaf, 0x672a, 0x72d2, 0x8db0, 0x95b7, 0xb14c,
|
||||
0x0000, 0x4eb4, 0x6a49, 0x7250, 0x8d2e, 0x98d6, 0x7551, 0x4eee, 0x4e20, 0x4a50, 0x1b09, 0xe914,
|
||||
0xe14e, 0xe47e, 0xd181, 0xcfc6, 0x0000, 0x303a, 0x2e7f, 0x1b82, 0x1eb2, 0x16ec, 0xe4f7, 0xb5b0,
|
||||
0xb1e0, 0xb112, 0x8aaf, 0x672a, 0x72d2, 0x8db0, 0x95b7, 0xb14c, 0x0000, 0x6a49, 0x8d2e, 0x7551,
|
||||
0x4e20, 0x1b09, 0xe14e, 0xd181, 0x0000, 0x2e7f, 0x1eb2, 0xe4f7, 0xb1e0, 0x8aaf, 0x72d2, 0x95b7,
|
||||
0x0000, 0x6a49, 0x8d2e, 0x7551, 0x4e20, 0x1b09, 0xe14e, 0xd181, 0x0000, 0x2e7f, 0x1eb2, 0xe4f7,
|
||||
0xb1e0, 0x8aaf, 0x72d2, 0x95b7, 0x0000, 0x6a49, 0x8d2e, 0x7551, 0x4e20, 0x1b09, 0xe14e, 0xd181,
|
||||
0x0000, 0x2e7f, 0x1eb2, 0xe4f7, 0xb1e0, 0x8aaf, 0x72d2, 0x95b7, 0x0000, 0x6a49, 0x8d2e, 0x7551,
|
||||
0x4e20, 0x1b09, 0xe14e, 0xd181, 0x0000, 0x2e7f, 0x1eb2, 0xe4f7, 0xb1e0, 0x8aaf, 0x72d2, 0x95b7,
|
||||
0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e,
|
||||
0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2,
|
||||
0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e,
|
||||
0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2,
|
||||
0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e,
|
||||
0x0000, 0x1eb2, 0xb1e0, 0x72d2,
|
||||
};
|
||||
// u8 buffer_remove2[764] = { 0 };
|
||||
s16 *gWaveSamples[6] = { sSawtoothWaves, sTriangleWaves, sSineWaves, sSquareWaves, sEuUnknownWave6, gEuUnknownWave7 };
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
s16 sSineWave[0x40] = {
|
||||
0, 3211, 6392, 9511, 12539, 15446, 18204, 20787, 23169, 25329, 27244,
|
||||
28897, 30272, 31356, 32137, 32609, 0x7FFF, 32609, 32137, 31356, 30272, 28897,
|
||||
@@ -144,6 +347,7 @@ s16 sSineWave[0x40] = {
|
||||
-30272, -31356, -32137, -32609, -0x7FFF, -32609, -32137, -31356, -30272, -28897, -27244,
|
||||
-25329, -23169, -20787, -18204, -15446, -12539, -9511, -6392, -3211,
|
||||
};
|
||||
|
||||
s16 sSquareWave[0x40] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
|
||||
@@ -160,6 +364,7 @@ s16 sTriangleWave[0x40] = {
|
||||
-24575, -26623, -28671, -30719, -0x7FFF, -30719, -28671, -26623, -24575, -22527, -0x4FFF,
|
||||
-0x47FF, -0x3FFF, -0x37FF, -0x2FFF, -0x27FF, -0x1FFF, -0x17FF, -0xFFF, -0x7FF,
|
||||
};
|
||||
|
||||
s16 sSawtoothWave[0x40] = {
|
||||
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239,
|
||||
11263, 0x2FFF, 13311, 0x37FF, 15359, 0x3FFF, 17407, 0x47FF, 19455, 0x4FFF, 21503,
|
||||
@@ -168,10 +373,21 @@ s16 sSawtoothWave[0x40] = {
|
||||
-0x4FFF, -19455, -0x47FF, -17407, -0x3FFF, -15359, -0x37FF, -13311, -0x2FFF, -11263, -10239,
|
||||
-9215, -8191, -7167, -6143, -5119, -4095, -3071, -2047, -1023,
|
||||
};
|
||||
|
||||
s16 *gWaveSamples[4] = { sSawtoothWave, sTriangleWave, sSineWave, sSquareWave };
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u8 euUnknownData_8030194c[4] = { 0x40, 0x20, 0x10, 0x08 };
|
||||
u16 gHeadsetPanQuantization[0x10] = {
|
||||
0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0,
|
||||
};
|
||||
s32 euUnknownData_80301950[32] = { //maybe envelope of some kind?
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0,
|
||||
};
|
||||
#else
|
||||
u16 gHeadsetPanQuantization[10] = { 0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
// Linearly interpolated between
|
||||
// f(0/2 * 127) = 1
|
||||
@@ -238,6 +454,7 @@ f32 gDefaultPanVolume[128] = {
|
||||
0.012368f, 0.0f
|
||||
};
|
||||
|
||||
#ifndef VERSION_EU
|
||||
// gVolRampingLhs136[k] = 2^16 * max(1, (256*k)^(1/17)
|
||||
f32 gVolRampingLhs136[128] = {
|
||||
65536.0f, 90811.555f, 94590.766f, 96873.96f, 98527.26f, 99829.06f, 100905.47f,
|
||||
@@ -363,29 +580,31 @@ f32 gVolRampingRhs128[128] = {
|
||||
0.525077f, 0.524798f, 0.524522f, 0.524247f, 0.523975f, 0.523706f, 0.523439f, 0.523174f, 0.522911f,
|
||||
0.522651f, 0.522393f
|
||||
};
|
||||
#endif
|
||||
|
||||
s16 gTatumsPerBeat = TATUMS_PER_BEAT;
|
||||
s8 gUnusedCount80333EE8 = 16;
|
||||
s32 gAudioHeapSize = DOUBLE_SIZE_ON_64_BIT(0x31150);
|
||||
s32 D_80333EF0 = DOUBLE_SIZE_ON_64_BIT(0x2500);
|
||||
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 };
|
||||
#else
|
||||
s8 sUnused8033EF8 = 24;
|
||||
#endif
|
||||
|
||||
// .bss
|
||||
struct CtlEntry *gCtlEntries;
|
||||
s32 gAiFrequency;
|
||||
u32 D_80226D68;
|
||||
s32 gMaxAudioCmds;
|
||||
|
||||
s32 gMaxSimultaneousNotes;
|
||||
s32 gSamplesPerFrameTarget;
|
||||
s32 gMinAiBufferLength;
|
||||
s16 gTempoInternalToExternal;
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
s8 gSoundMode;
|
||||
|
||||
volatile s32 gAudioFrameCount;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s32 gCurrAudioFrameDmaCount;
|
||||
#else
|
||||
volatile s32 gCurrAudioFrameDmaCount;
|
||||
#endif
|
||||
|
||||
s32 gAudioTaskIndex;
|
||||
s32 gCurrAiBufferIndex;
|
||||
@@ -396,10 +615,23 @@ u64 *gAudioCmd;
|
||||
struct SPTask *gAudioTask;
|
||||
struct SPTask gAudioTasks[2];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
f32 D_EU_802298D0;
|
||||
s32 gRefreshRate;
|
||||
#endif
|
||||
|
||||
u16 *gAiBuffers[NUMAIBUFFERS];
|
||||
s16 gAiBufferLengths[NUMAIBUFFERS];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u32 gAudioRandom;
|
||||
s32 gAudioErrorFlags;
|
||||
u64 gAudioGlobalsEndMarker;
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
u32 gUnused80226E58[0x10];
|
||||
u16 gUnused80226E98[0x10];
|
||||
|
||||
u32 gAudioRandom;
|
||||
#endif
|
||||
+50
-13
@@ -10,10 +10,18 @@
|
||||
#define NUMAIBUFFERS 3
|
||||
|
||||
// constant .data
|
||||
#ifdef VERSION_EU
|
||||
extern struct AudioSessionSettingsEU gAudioSessionPresets[];
|
||||
#else
|
||||
extern struct AudioSessionSettings gAudioSessionPresets[18];
|
||||
#endif
|
||||
extern u16 D_80332388[128]; // unused
|
||||
|
||||
#ifdef VERSION_EU
|
||||
extern f32 gPitchBendFrequencyScale[256];
|
||||
#else
|
||||
extern f32 gPitchBendFrequencyScale[255];
|
||||
#endif
|
||||
extern f32 gNoteFrequencies[128];
|
||||
|
||||
extern u8 gDefaultShortNoteVelocityTable[16];
|
||||
@@ -21,9 +29,22 @@ extern u8 gDefaultShortNoteDurationTable[16];
|
||||
extern s8 gVibratoCurve[16];
|
||||
extern struct AdsrEnvelope gDefaultEnvelope[3];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
extern s16 gEuUnknownWave7[256];
|
||||
extern s16 *gWaveSamples[6];
|
||||
#else
|
||||
extern s16 *gWaveSamples[4];
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
extern u8 euUnknownData_8030194c[4];
|
||||
extern u16 gHeadsetPanQuantization[0x10];
|
||||
extern s32 euUnknownData_80301950[32];
|
||||
extern struct NoteSubEu gZeroNoteSub;
|
||||
extern struct NoteSubEu gDefaultNoteSub;
|
||||
#else
|
||||
extern u16 gHeadsetPanQuantization[10];
|
||||
#endif
|
||||
extern f32 gHeadsetPanVolume[128];
|
||||
extern f32 gStereoPanVolume[128];
|
||||
extern f32 gDefaultPanVolume[128];
|
||||
@@ -43,20 +64,14 @@ extern s32 D_80333EF0; // amount of heap designated to gAudioInitPool, 0x2500
|
||||
extern volatile s32 gAudioLoadLock;
|
||||
|
||||
// .bss
|
||||
extern struct CtlEntry *gCtlEntries;
|
||||
extern s32 gAiFrequency;
|
||||
extern u32 D_80226D68;
|
||||
extern s32 gMaxAudioCmds;
|
||||
|
||||
extern s32 gMaxSimultaneousNotes;
|
||||
extern s32 gSamplesPerFrameTarget;
|
||||
extern s32 gMinAiBufferLength;
|
||||
extern s16 gTempoInternalToExternal;
|
||||
extern s8 gAudioUpdatesPerFrame; // = 4
|
||||
extern s8 gSoundMode;
|
||||
|
||||
extern volatile s32 gAudioFrameCount;
|
||||
extern volatile s32 gCurrAudioFrameDmaCount; // number of DMAs performed during this frame
|
||||
|
||||
// number of DMAs performed during this frame
|
||||
#ifdef VERSION_EU
|
||||
extern s32 gCurrAudioFrameDmaCount;
|
||||
#else
|
||||
extern volatile s32 gCurrAudioFrameDmaCount;
|
||||
#endif
|
||||
|
||||
extern s32 gAudioTaskIndex;
|
||||
extern s32 gCurrAiBufferIndex;
|
||||
@@ -67,12 +82,34 @@ extern u64 *gAudioCmd;
|
||||
extern struct SPTask *gAudioTask;
|
||||
extern struct SPTask gAudioTasks[2];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
extern f32 D_EU_802298D0;
|
||||
extern s32 gRefreshRate;
|
||||
#endif
|
||||
|
||||
extern u16 *gAiBuffers[NUMAIBUFFERS];
|
||||
extern s16 gAiBufferLengths[NUMAIBUFFERS];
|
||||
#ifdef VERSION_EU
|
||||
#define AIBUFFER_LEN (0xa0 * 17)
|
||||
#else
|
||||
#define AIBUFFER_LEN (0xa0 * 16)
|
||||
#endif
|
||||
|
||||
extern u32 gUnused80226E58[0x10];
|
||||
extern u16 gUnused80226E98[0x10];
|
||||
|
||||
extern u32 gAudioRandom;
|
||||
|
||||
//make my life easier
|
||||
#ifdef VERSION_EU
|
||||
#define UNUSED_COUNT_80333EE8 24
|
||||
#define AUDIO_HEAP_SIZE 0x2c500
|
||||
#define D_80333EF0_VAL 0x2c00
|
||||
#else
|
||||
#define UNUSED_COUNT_80333EE8 16
|
||||
#define AUDIO_HEAP_SIZE 0x31150
|
||||
#define D_80333EF0_VAL 0x2500
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* AUDIO_DATA_H */
|
||||
+243
-22
@@ -12,14 +12,59 @@
|
||||
#define US_FLOAT2(x) x
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 arg1) {
|
||||
f32 weight;
|
||||
s32 i;
|
||||
|
||||
if (seqChannel->unk1.as_bitfields.unk0b40 || arg1) {
|
||||
weight = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->unkEu2C;
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
|
||||
weight = seqChannel->seqPlayer->muteVolumeScale * weight;
|
||||
}
|
||||
seqChannel->panChannelWeight = weight;
|
||||
}
|
||||
|
||||
if (seqChannel->unk1.as_bitfields.unk0b20) {
|
||||
seqChannel->pan = seqChannel->unk9 * seqChannel->unkA;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
||||
if (layer && layer->enabled && layer->note) {
|
||||
if (layer->unkEu0b4) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->panChannelWeight;
|
||||
layer->notePan = (seqChannel->pan + layer->euUnk5 * (0x80 - seqChannel->unkA)) >> 7;
|
||||
layer->unkEu0b4 = 0;
|
||||
} else {
|
||||
if (seqChannel->unk1.as_bitfields.unk0b80) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
}
|
||||
if (seqChannel->unk1.as_bitfields.unk0b40 || arg1) {
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->panChannelWeight;
|
||||
}
|
||||
if (seqChannel->unk1.as_bitfields.unk0b20) {
|
||||
layer->notePan = (seqChannel->pan + layer->euUnk5 * (0x80 - seqChannel->unkA)) >> 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
seqChannel->unk1.as_u8 = 0;
|
||||
}
|
||||
#else
|
||||
void func_80319E70(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
s32 i;
|
||||
|
||||
if (seqPlayer->fadeTimer != 0) {
|
||||
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unk_eu = TRUE;
|
||||
#endif
|
||||
|
||||
if (seqPlayer->fadeVolume > US_FLOAT2(1)) {
|
||||
seqPlayer->fadeVolume = US_FLOAT2(1);
|
||||
@@ -29,6 +74,12 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
}
|
||||
|
||||
if (--seqPlayer->fadeTimer == 0) {
|
||||
#ifdef VERSION_EU
|
||||
if (seqPlayer->state == 2) {
|
||||
sequence_player_disable(seqPlayer);
|
||||
return;
|
||||
}
|
||||
#else
|
||||
switch (seqPlayer->state) {
|
||||
case SEQUENCE_PLAYER_STATE_FADE_OUT:
|
||||
sequence_player_disable(seqPlayer);
|
||||
@@ -42,13 +93,23 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
case SEQUENCE_PLAYER_STATE_4:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (seqPlayer->unk_eu) {
|
||||
seqPlayer->unkEu2C = seqPlayer->fadeVolume * seqPlayer->unkEu28;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Process channels
|
||||
for (i = 0; i < CHANNELS_MAX; i++) {
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
|
||||
&& seqPlayer->channels[i]->enabled == TRUE) {
|
||||
#ifdef VERSION_EU
|
||||
sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->unk_eu);
|
||||
#else
|
||||
f32 channelVolume;
|
||||
f32 panLayerWeight;
|
||||
f32 panFromChannel;
|
||||
@@ -72,28 +133,52 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
|
||||
seqLayer->notePan = (seqLayer->pan * panLayerWeight) + panFromChannel;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
seqPlayer->unk_eu = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
f32 get_portamento_freq_scale(struct Portamento *p) {
|
||||
u32 v0;
|
||||
f32 result;
|
||||
#ifndef VERSION_EU
|
||||
if (p->mode == 0) {
|
||||
return 1.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
p->cur += p->speed;
|
||||
v0 = (u32) p->cur;
|
||||
|
||||
if (v0 >= 127) {
|
||||
#ifdef VERSION_EU
|
||||
if (v0 > 127)
|
||||
#else
|
||||
if (v0 >= 127)
|
||||
#endif
|
||||
{
|
||||
v0 = 127;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
result = US_FLOAT(1.0) + p->extent * (gPitchBendFrequencyScale[v0 + 128] - US_FLOAT(1.0));
|
||||
#else
|
||||
result = US_FLOAT(1.0) + p->extent * (gPitchBendFrequencyScale[v0 + 127] - US_FLOAT(1.0));
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s16 get_vibrato_pitch_change(struct VibratoState *vib) {
|
||||
s32 index;
|
||||
vib->time += (s32) vib->rate;
|
||||
index = (vib->time >> 10) & 0x3F;
|
||||
return vib->curve[index] >> 8;
|
||||
}
|
||||
#else
|
||||
s8 get_vibrato_pitch_change(struct VibratoState *vib) {
|
||||
s32 index;
|
||||
vib->time += vib->rate;
|
||||
@@ -118,9 +203,10 @@ s8 get_vibrato_pitch_change(struct VibratoState *vib) {
|
||||
|
||||
return -vib->curve[index];
|
||||
}
|
||||
#endif
|
||||
|
||||
f32 get_vibrato_freq_scale(struct VibratoState *vib) {
|
||||
s8 pitchChange;
|
||||
s32 pitchChange;
|
||||
f32 extent;
|
||||
f32 result;
|
||||
|
||||
@@ -131,37 +217,47 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
|
||||
|
||||
if (vib->extentChangeTimer) {
|
||||
if (vib->extentChangeTimer == 1) {
|
||||
vib->extent = vib->seqChannel->vibratoExtentTarget;
|
||||
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
|
||||
} else {
|
||||
vib->extent +=
|
||||
(vib->seqChannel->vibratoExtentTarget - vib->extent) / vib->extentChangeTimer;
|
||||
((s32) vib->seqChannel->vibratoExtentTarget - vib->extent) / (s32) vib->extentChangeTimer;
|
||||
}
|
||||
|
||||
vib->extentChangeTimer--;
|
||||
} else {
|
||||
if (vib->extent != vib->seqChannel->vibratoExtentTarget) {
|
||||
vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay;
|
||||
if (vib->extentChangeTimer == 0) {
|
||||
vib->extent = vib->seqChannel->vibratoExtentTarget;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
} else if ((s32) vib->extent != (*vib).seqChannel->vibratoExtentTarget) {
|
||||
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
|
||||
}
|
||||
#else
|
||||
} else if ((s32) vib->extent != vib->seqChannel->vibratoExtentTarget) {
|
||||
vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay;
|
||||
if (vib->extentChangeTimer == 0) {
|
||||
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (vib->rateChangeTimer) {
|
||||
if (vib->rateChangeTimer == 1) {
|
||||
vib->rate = vib->seqChannel->vibratoRateTarget;
|
||||
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
|
||||
} else {
|
||||
vib->rate += (vib->seqChannel->vibratoRateTarget - vib->rate) / vib->rateChangeTimer;
|
||||
vib->rate += ((s32) vib->seqChannel->vibratoRateTarget - vib->rate) / (s32) vib->rateChangeTimer;
|
||||
}
|
||||
|
||||
vib->rateChangeTimer--;
|
||||
} else {
|
||||
if (vib->rate != vib->seqChannel->vibratoRateTarget) {
|
||||
vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay;
|
||||
if (vib->rateChangeTimer == 0) {
|
||||
vib->rate = vib->seqChannel->vibratoRateTarget;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
} else if ((s32) vib->rate != (*vib).seqChannel->vibratoRateTarget) {
|
||||
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
|
||||
}
|
||||
#else
|
||||
} else if ((s32) vib->rate != vib->seqChannel->vibratoRateTarget) {
|
||||
vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay;
|
||||
if (vib->rateChangeTimer == 0) {
|
||||
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (vib->extent == 0) {
|
||||
@@ -171,39 +267,76 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib) {
|
||||
pitchChange = get_vibrato_pitch_change(vib);
|
||||
extent = (f32) vib->extent / US_FLOAT(4096.0);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 128] - US_FLOAT(1.0));
|
||||
#else
|
||||
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 127] - US_FLOAT(1.0));
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void note_vibrato_update(struct Note *note) {
|
||||
#ifdef VERSION_EU
|
||||
if (note->portamento.mode != 0) {
|
||||
note->portamentoFreqScale = get_portamento_freq_scale(¬e->portamento);
|
||||
}
|
||||
if (note->vibratoState.active && note->parentLayer != NO_LAYER) {
|
||||
note->vibratoFreqScale = get_vibrato_freq_scale(¬e->vibratoState);
|
||||
}
|
||||
#else
|
||||
if (note->vibratoState.active) {
|
||||
note->portamentoFreqScale = get_portamento_freq_scale(¬e->portamento);
|
||||
if (note->parentLayer != NO_LAYER) {
|
||||
note->vibratoFreqScale = get_vibrato_freq_scale(¬e->vibratoState);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void note_vibrato_init(struct Note *note) {
|
||||
struct VibratoState *vib;
|
||||
struct SequenceChannel *seqChannel;
|
||||
UNUSED struct SequenceChannel *seqChannel;
|
||||
#ifdef VERSION_EU
|
||||
struct NotePlaybackState *seqPlayerState = (struct NotePlaybackState *) ¬e->priority;
|
||||
#endif
|
||||
|
||||
note->vibratoFreqScale = 1.0f;
|
||||
note->portamentoFreqScale = 1.0f;
|
||||
|
||||
vib = ¬e->vibratoState;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (note->parentLayer->seqChannel->vibratoExtentStart == 0
|
||||
&& note->parentLayer->seqChannel->vibratoExtentTarget == 0
|
||||
&& note->parentLayer->portamento.mode == 0) {
|
||||
vib->active = FALSE;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
vib->active = TRUE;
|
||||
vib->time = 0;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
vib->curve = gWaveSamples[2];
|
||||
vib->seqChannel = note->parentLayer->seqChannel;
|
||||
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = FLOAT_CAST(vib->seqChannel->vibratoExtentTarget);
|
||||
} else {
|
||||
vib->extent = FLOAT_CAST(vib->seqChannel->vibratoExtentStart);
|
||||
}
|
||||
|
||||
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = FLOAT_CAST(vib->seqChannel->vibratoRateTarget);
|
||||
} else {
|
||||
vib->rate = FLOAT_CAST(vib->seqChannel->vibratoRateStart);
|
||||
}
|
||||
vib->delay = vib->seqChannel->vibratoDelay;
|
||||
|
||||
seqPlayerState->portamento = seqPlayerState->parentLayer->portamento;
|
||||
#else
|
||||
vib->curve = gVibratoCurve;
|
||||
vib->seqChannel = note->parentLayer->seqChannel;
|
||||
|
||||
seqChannel = vib->seqChannel;
|
||||
|
||||
vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay;
|
||||
@@ -219,40 +352,64 @@ void note_vibrato_init(struct Note *note) {
|
||||
} else {
|
||||
vib->rate = seqChannel->vibratoRateStart;
|
||||
}
|
||||
|
||||
vib->delay = seqChannel->vibratoDelay;
|
||||
|
||||
note->portamento = note->parentLayer->portamento;
|
||||
#endif
|
||||
}
|
||||
|
||||
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, s16 *volOut) {
|
||||
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, UNUSED s16 *volOut) {
|
||||
adsr->action = 0;
|
||||
adsr->state = ADSR_STATE_DISABLED;
|
||||
#ifdef VERSION_EU
|
||||
adsr->delay = 0;
|
||||
adsr->envelope = envelope;
|
||||
adsr->current = 0.0f;
|
||||
#else
|
||||
adsr->initial = 0;
|
||||
adsr->delay = 0;
|
||||
adsr->velocity = 0;
|
||||
adsr->envelope = envelope;
|
||||
adsr->volOut = volOut;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
f32 adsr_update(struct AdsrState *adsr) {
|
||||
#else
|
||||
s32 adsr_update(struct AdsrState *adsr) {
|
||||
#endif
|
||||
u8 action = adsr->action;
|
||||
#ifdef VERSION_EU
|
||||
u8 state = adsr->state;
|
||||
switch (state) {
|
||||
#else
|
||||
switch (adsr->state) {
|
||||
#endif
|
||||
case ADSR_STATE_DISABLED:
|
||||
return 0;
|
||||
|
||||
case ADSR_STATE_INITIAL: {
|
||||
#ifndef VERSION_EU
|
||||
adsr->current = adsr->initial;
|
||||
adsr->target = adsr->initial;
|
||||
#endif
|
||||
if (action & ADSR_ACTION_HANG) {
|
||||
adsr->state = ADSR_STATE_HANG;
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
|
||||
case ADSR_STATE_START_LOOP:
|
||||
adsr->envIndex = 0;
|
||||
#ifndef VERSION_EU
|
||||
adsr->currentHiRes = adsr->current << 0x10;
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_LOOP;
|
||||
// fallthrough
|
||||
|
||||
@@ -273,45 +430,89 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef VERSION_EU
|
||||
if (adsr->delay >= 4) {
|
||||
adsr->delay = adsr->delay * gAudioBufferParameters.updatesPerFrame / 4;
|
||||
}
|
||||
adsr->target = (f32) BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0;
|
||||
adsr->target = adsr->target * adsr->target;
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
#else
|
||||
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_FADE;
|
||||
adsr->envIndex++;
|
||||
break;
|
||||
}
|
||||
if (adsr->state != ADSR_STATE_FADE) {
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_FADE:
|
||||
#ifdef VERSION_EU
|
||||
adsr->current += adsr->velocity;
|
||||
#else
|
||||
adsr->currentHiRes += adsr->velocity;
|
||||
adsr->current = adsr->currentHiRes >> 0x10;
|
||||
#endif
|
||||
if (--adsr->delay <= 0) {
|
||||
adsr->state = ADSR_STATE_LOOP;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_HANG:
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
|
||||
case ADSR_STATE_DECAY:
|
||||
case ADSR_STATE_RELEASE: {
|
||||
adsr->current -= adsr->fadeOutVel;
|
||||
#ifdef VERSION_EU
|
||||
if (adsr->sustain != 0.0f && state == ADSR_STATE_DECAY) {
|
||||
#else
|
||||
if (adsr->sustain != 0 && adsr->state == ADSR_STATE_DECAY) {
|
||||
#endif
|
||||
if (adsr->current < adsr->sustain) {
|
||||
adsr->current = adsr->sustain;
|
||||
#ifdef VERSION_EU
|
||||
adsr->delay = 128;
|
||||
#else
|
||||
adsr->delay = adsr->sustain / 16;
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_SUSTAIN;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (adsr->current < 0) {
|
||||
adsr->current = 0.0f;
|
||||
adsr->state = ADSR_STATE_DISABLED;
|
||||
}
|
||||
#else
|
||||
if (adsr->current < 100) {
|
||||
adsr->current = 0;
|
||||
adsr->state = ADSR_STATE_DISABLED;
|
||||
}
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
case ADSR_STATE_SUSTAIN:
|
||||
@@ -319,10 +520,16 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
if (adsr->delay == 0) {
|
||||
adsr->state = ADSR_STATE_RELEASE;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto CONT;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
CONT:
|
||||
#endif
|
||||
|
||||
if ((action & ADSR_ACTION_DECAY)) {
|
||||
adsr->state = ADSR_STATE_DECAY;
|
||||
@@ -331,9 +538,23 @@ CONT:
|
||||
|
||||
if ((action & ADSR_ACTION_RELEASE)) {
|
||||
adsr->state = ADSR_STATE_RELEASE;
|
||||
#ifdef VERSION_EU
|
||||
adsr->action = action & ~ADSR_ACTION_RELEASE;
|
||||
#else
|
||||
adsr->action = action & ~(ADSR_ACTION_RELEASE | ADSR_ACTION_DECAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (adsr->current < 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (adsr->current > 1.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
return adsr->current;
|
||||
#else
|
||||
*adsr->volOut = adsr->current;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
@@ -35,6 +35,10 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer);
|
||||
void note_vibrato_update(struct Note *note);
|
||||
void note_vibrato_init(struct Note *note);
|
||||
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, s16 *volOut);
|
||||
#ifdef VERSION_EU
|
||||
f32 adsr_update(struct AdsrState *adsr);
|
||||
#else
|
||||
s32 adsr_update(struct AdsrState *adsr);
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_EFFECTS_H */
|
||||
+508
-43
File diff suppressed because it is too large.
Load diff
@@ -33,7 +33,7 @@ void sound_banks_disable(u8 player, u16 bankMask);
|
||||
void sound_banks_enable(u8 player, u16 bankMask);
|
||||
void func_80320A4C(u8 bankIndex, u8 arg1);
|
||||
void play_dialog_sound(u8 dialogID);
|
||||
void play_music(u8 player, u16 seqArgs, s16 fadeTimer);
|
||||
void play_music(u8 player, u16 seqArgs, u16 fadeTimer);
|
||||
void stop_background_music(u16 seqId);
|
||||
void fadeout_background_music(u16 arg0, u16 fadeOut);
|
||||
void drop_queued_background_music(void);
|
||||
@@ -53,4 +53,8 @@ void audio_set_sound_mode(u8 arg0);
|
||||
|
||||
void audio_init(void); // in load.c
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct SPTask *unused_80321460();
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_EXTERNAL_H */
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#ifndef VERSION_EU
|
||||
u64 gAudioGlobalsEndMarker;
|
||||
#endif
|
||||
+396
-145
@@ -5,7 +5,20 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define SEQUENCE_PLAYERS 4
|
||||
#define SEQUENCE_CHANNELS 48
|
||||
#define SEQUENCE_LAYERS 64
|
||||
#else
|
||||
#define SEQUENCE_PLAYERS 3
|
||||
#define SEQUENCE_CHANNELS 32
|
||||
#ifdef VERSION_JP
|
||||
#define SEQUENCE_LAYERS 48
|
||||
#else
|
||||
#define SEQUENCE_LAYERS 52
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define LAYERS_MAX 4
|
||||
#define CHANNELS_MAX 16
|
||||
|
||||
@@ -34,6 +47,7 @@
|
||||
#define TEMPO_SCALE TATUMS_PER_BEAT
|
||||
#endif
|
||||
|
||||
// TODO: US_FLOAT should probably be renamed to JP_DOUBLE since eu seems to use floats too
|
||||
#ifdef VERSION_JP
|
||||
#define US_FLOAT(x) x
|
||||
#else
|
||||
@@ -78,16 +92,24 @@ struct NotePool
|
||||
};
|
||||
|
||||
struct VibratoState {
|
||||
struct SequenceChannel *seqChannel;
|
||||
u32 time;
|
||||
s8 *curve;
|
||||
u8 active;
|
||||
u16 rate;
|
||||
u16 extent;
|
||||
u16 rateChangeTimer;
|
||||
u16 extentChangeTimer;
|
||||
u16 delay;
|
||||
}; // size = 0x18
|
||||
/*0x00, 0x00*/ struct SequenceChannel *seqChannel;
|
||||
/*0x04, 0x04*/ u32 time;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x08*/ s16 *curve;
|
||||
/* , 0x0C*/ f32 extent;
|
||||
/* , 0x10*/ f32 rate;
|
||||
/* , 0x14*/ u8 active;
|
||||
#endif
|
||||
#ifndef VERSION_EU
|
||||
/*0x08, */ s8 *curve;
|
||||
/*0x0C, */ u8 active;
|
||||
/*0x0E, */ u16 rate;
|
||||
/*0x10, */ u16 extent;
|
||||
#endif
|
||||
/*0x12, 0x16*/ u16 rateChangeTimer;
|
||||
/*0x14, 0x18*/ u16 extentChangeTimer;
|
||||
/*0x16, 0x1A*/ u16 delay;
|
||||
}; // size = 0x18, 0x1C on EU
|
||||
|
||||
// Pitch sliding by up to one octave in the positive direction. Negative
|
||||
// direction is "supported" by setting extent to be negative. The code
|
||||
@@ -182,161 +204,329 @@ struct M64ScriptState {
|
||||
|
||||
struct SequencePlayer
|
||||
{
|
||||
/*0x000*/ volatile u8 enabled : 1;
|
||||
/*0x000*/ u8 finished : 1; // never read
|
||||
/*0x000*/ u8 muted : 1;
|
||||
/*0x000*/ u8 seqDmaInProgress : 1;
|
||||
/*0x000*/ u8 bankDmaInProgress : 1;
|
||||
/*0x001*/ s8 seqVariation;
|
||||
/*0x002*/ u8 state;
|
||||
/*0x003*/ u8 noteAllocPolicy;
|
||||
/*0x004*/ u8 muteBehavior;
|
||||
/*0x005*/ u8 seqId;
|
||||
/*0x006*/ u8 defaultBank[1]; // must be an array to get a comparison
|
||||
/*US/JP, EU */
|
||||
#ifdef VERSION_EU
|
||||
/*0x000, 0x000*/ u8 enabled : 1;
|
||||
#else
|
||||
/*0x000, 0x000*/ volatile u8 enabled : 1;
|
||||
#endif
|
||||
/*0x000, 0x000*/ u8 finished : 1; // never read
|
||||
/*0x000, 0x000*/ u8 muted : 1;
|
||||
/*0x000, 0x000*/ u8 seqDmaInProgress : 1;
|
||||
/*0x000, 0x000*/ u8 bankDmaInProgress : 1;
|
||||
#ifdef VERSION_EU
|
||||
/* 0x000*/ u8 unk_eu : 1;
|
||||
#endif
|
||||
#ifndef VERSION_EU
|
||||
/*0x001 */ s8 seqVariation;
|
||||
#endif
|
||||
/*0x002, 0x001*/ u8 state;
|
||||
/*0x003, 0x002*/ u8 noteAllocPolicy;
|
||||
/*0x004, 0x003*/ u8 muteBehavior;
|
||||
/*0x005, 0x004*/ u8 seqId;
|
||||
/*0x006, 0x005*/ u8 defaultBank[1]; // must be an array to get a comparison
|
||||
// to match; other u8's might also be part of that array
|
||||
/*0x007*/ u8 loadingBankId;
|
||||
/*0x008*/ u8 loadingBankNumInstruments;
|
||||
/*0x009*/ u8 loadingBankNumDrums;
|
||||
/*0x00A*/ u16 tempo; // beats per minute in JP, tatums per minute in US
|
||||
/*0x00C*/ u16 tempoAcc;
|
||||
/*0x00E*/ u16 fadeTimer;
|
||||
/*0x010*/ s16 transposition;
|
||||
/*0x012*/ u16 delay;
|
||||
/*0x014*/ u8 *seqData; // buffer of some sort
|
||||
/*0x018*/ f32 fadeVolume; // set to 1.0f
|
||||
/*0x01C*/ f32 fadeVelocity; // set to 0.0f
|
||||
/*0x020*/ f32 volume; // set to 0.0f
|
||||
/*0x024*/ f32 muteVolumeScale; // set to 0.5f
|
||||
/* */ u8 pad1[4];
|
||||
/*0x02C*/ struct SequenceChannel *channels[CHANNELS_MAX];
|
||||
/*0x06C*/ struct M64ScriptState scriptState;
|
||||
/*0x088*/ u8 *shortNoteVelocityTable;
|
||||
/*0x08C*/ u8 *shortNoteDurationTable;
|
||||
/*0x090*/ struct NotePool notePool;
|
||||
/*0x0D0*/ OSMesgQueue seqDmaMesgQueue;
|
||||
/*0x0E8*/ OSMesg seqDmaMesg;
|
||||
/*0x0EC*/ OSIoMesg seqDmaIoMesg;
|
||||
/*0x100*/ OSMesgQueue bankDmaMesgQueue;
|
||||
/*0x118*/ OSMesg bankDmaMesg;
|
||||
/*0x11C*/ OSIoMesg bankDmaIoMesg;
|
||||
/*0x130*/ u8 *bankDmaCurrMemAddr;
|
||||
/*0x134*/ struct AudioBank *loadingBank;
|
||||
/*0x138*/ uintptr_t bankDmaCurrDevAddr;
|
||||
/*0x13C*/ ssize_t bankDmaRemaining;
|
||||
}; // size = 0x140
|
||||
/*0x007, 0x006*/ u8 loadingBankId;
|
||||
#ifndef VERSION_EU
|
||||
/*0x008, ?????*/ u8 loadingBankNumInstruments;
|
||||
/*0x009, ?????*/ u8 loadingBankNumDrums;
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x007*/ s8 seqVariationEu[1];
|
||||
#endif
|
||||
/*0x00A, 0x008*/ u16 tempo; // beats per minute in JP, tatums per minute in US/EU
|
||||
/*0x00C, 0x00A*/ u16 tempoAcc;
|
||||
#ifndef VERSION_EU
|
||||
/*0x00E, 0x010*/ u16 fadeTimer;
|
||||
#endif
|
||||
/*0x010, 0x00C*/ s16 transposition;
|
||||
/*0x012, 0x00E*/ u16 delay;
|
||||
#ifdef VERSION_EU
|
||||
/*0x00E, 0x010*/ u16 fadeTimer;
|
||||
/* , 0x012*/ u16 fadeTimerUnkEu;
|
||||
#endif
|
||||
/*0x014, 0x014*/ u8 *seqData; // buffer of some sort
|
||||
/*0x018, 0x018*/ f32 fadeVolume; // set to 1.0f
|
||||
/*0x01C, 0x01C*/ f32 fadeVelocity; // set to 0.0f
|
||||
/*0x020, 0x020*/ f32 volume; // set to 0.0f
|
||||
/*0x024, 0x024*/ f32 muteVolumeScale; // set to 0.5f
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x028*/ f32 unkEu28;
|
||||
/* , 0x02C*/ f32 unkEu2C;
|
||||
#else
|
||||
/* */ u8 pad2[4];
|
||||
#endif
|
||||
/*0x02C, 0x030*/ struct SequenceChannel *channels[CHANNELS_MAX];
|
||||
/*0x06C, 0x070*/ struct M64ScriptState scriptState;
|
||||
/*0x088, 0x08C*/ u8 *shortNoteVelocityTable;
|
||||
/*0x08C, 0x090*/ u8 *shortNoteDurationTable;
|
||||
/*0x090, 0x094*/ struct NotePool notePool;
|
||||
/*0x0D0, 0x0D4*/ OSMesgQueue seqDmaMesgQueue;
|
||||
/*0x0E8, 0x0EC*/ OSMesg seqDmaMesg;
|
||||
/*0x0EC, 0x0F0*/ OSIoMesg seqDmaIoMesg;
|
||||
/*0x100, 0x108*/ OSMesgQueue bankDmaMesgQueue;
|
||||
/*0x118, 0x120*/ OSMesg bankDmaMesg;
|
||||
/*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg;
|
||||
/*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr;
|
||||
#ifndef VERSION_EU
|
||||
/*0x134, ?????*/ struct AudioBank *loadingBank;
|
||||
#endif
|
||||
/*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr;
|
||||
/*0x13C, 0x144*/ ssize_t bankDmaRemaining;
|
||||
}; // size = 0x140, 0x148 on EU
|
||||
|
||||
struct AdsrSettings
|
||||
{
|
||||
u8 releaseRate;
|
||||
#ifdef VERSION_EU
|
||||
u8 sustain;
|
||||
#else
|
||||
u16 sustain; // sustain level, 2^16 = max
|
||||
#endif
|
||||
struct AdsrEnvelope *envelope;
|
||||
}; // size = 0x8
|
||||
|
||||
struct AdsrState {
|
||||
u8 action;
|
||||
u8 state;
|
||||
s16 initial; // always 0
|
||||
s16 target;
|
||||
s16 current;
|
||||
s16 envIndex;
|
||||
s16 delay;
|
||||
s16 sustain;
|
||||
s16 fadeOutVel;
|
||||
s32 velocity;
|
||||
s32 currentHiRes;
|
||||
s16 *volOut;
|
||||
struct AdsrEnvelope *envelope;
|
||||
}; // size = 0x20
|
||||
/*0x00, 0x00*/ u8 action;
|
||||
/*0x01, 0x01*/ u8 state;
|
||||
#ifndef VERSION_EU
|
||||
/*0x02, */ s16 initial; // always 0
|
||||
/*0x04, */ s16 target;
|
||||
/*0x06, */ s16 current;
|
||||
#endif
|
||||
/*0x08, 0x02*/ s16 envIndex;
|
||||
/*0x0A, 0x04*/ s16 delay;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x08*/ f32 sustain;
|
||||
/* , 0x0C*/ f32 velocity;
|
||||
/* , 0x10*/ f32 fadeOutVel;
|
||||
/* , 0x14*/ f32 current;
|
||||
/* , 0x18*/ f32 target;
|
||||
s32 pad1C;
|
||||
#else
|
||||
/*0x0C, */ s16 sustain;
|
||||
/*0x0E, */ s16 fadeOutVel;
|
||||
/*0x10, */ s32 velocity;
|
||||
/*0x14, */ s32 currentHiRes;
|
||||
/*0x18, */ s16 *volOut;
|
||||
#endif
|
||||
/*0x1C, 0x20*/ struct AdsrEnvelope *envelope;
|
||||
}; // size = 0x20, 0x24 in EU
|
||||
|
||||
struct NoteAttributes
|
||||
{
|
||||
s8 reverb;
|
||||
#ifdef VERSION_EU
|
||||
u8 pan;
|
||||
#endif
|
||||
f32 freqScale;
|
||||
f32 velocity;
|
||||
#ifndef VERSION_EU
|
||||
f32 pan;
|
||||
#endif
|
||||
}; // size = 0x10
|
||||
|
||||
struct SequenceChannel
|
||||
{
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 stopScript : 1;
|
||||
/*0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething
|
||||
/*0x00*/ u8 hasInstrument : 1;
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00*/ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
/*0x00*/ u8 unused : 1; // never read, set to 0
|
||||
/*0x01*/ u8 noteAllocPolicy;
|
||||
/*0x02*/ u8 muteBehavior;
|
||||
/*0x03*/ u8 reverb; // or dry/wet mix
|
||||
/*0x04*/ u8 notePriority; // 0-3
|
||||
/*0x05*/ u8 bankId;
|
||||
/*0x06*/ u8 updatesPerFrameUnused; // never read
|
||||
/*0x08*/ u16 vibratoRateStart; // initially 0x800
|
||||
/*0x0A*/ u16 vibratoExtentStart;
|
||||
/*0x0C*/ u16 vibratoRateTarget; // initially 0x800
|
||||
/*0x0E*/ u16 vibratoExtentTarget;
|
||||
/*0x10*/ u16 vibratoRateChangeDelay;
|
||||
/*0x12*/ u16 vibratoExtentChangeDelay;
|
||||
/*0x14*/ u16 vibratoDelay;
|
||||
/*0x16*/ u16 delay;
|
||||
/*0x18*/ s16 instOrWave; // either 0 (none), instrument index + 1, or
|
||||
/* U/J, EU */
|
||||
/*0x00, 0x00*/ u8 enabled : 1;
|
||||
/*0x00, 0x00*/ u8 finished : 1;
|
||||
/*0x00, 0x00*/ u8 stopScript : 1;
|
||||
/*0x00, 0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething
|
||||
/*0x00, 0x00*/ u8 hasInstrument : 1;
|
||||
/*0x00, 0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00, ????*/ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
/*0x00, ????*/ u8 unused : 1; // never read, set to 0
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x01*/ union {
|
||||
struct {
|
||||
u8 unk0b80 : 1;
|
||||
u8 unk0b40 : 1;
|
||||
u8 unk0b20 : 1;
|
||||
} as_bitfields;
|
||||
u8 as_u8;
|
||||
} unk1;
|
||||
#endif
|
||||
/*0x01, 0x02*/ u8 noteAllocPolicy;
|
||||
/*0x02, 0x03*/ u8 muteBehavior;
|
||||
/*0x03, 0x04*/ u8 reverb; // or dry/wet mix
|
||||
/*0x04, ????*/ u8 notePriority; // 0-3
|
||||
/*0x05, 0x06*/ u8 bankId;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x07*/ u8 reverbIndex;
|
||||
/* , 0x08*/ u8 unk8;
|
||||
/* , 0x09*/ u8 unk9;
|
||||
/* , 0x0A*/ u8 unkA;
|
||||
#else
|
||||
/*0x06, */ u8 updatesPerFrameUnused;
|
||||
#endif
|
||||
/*0x08, 0x0C*/ u16 vibratoRateStart; // initially 0x800
|
||||
/*0x0A, 0x0E*/ u16 vibratoExtentStart;
|
||||
/*0x0C, 0x10*/ u16 vibratoRateTarget; // initially 0x800
|
||||
/*0x0E, 0x12*/ u16 vibratoExtentTarget;
|
||||
/*0x10, 0x14*/ u16 vibratoRateChangeDelay;
|
||||
/*0x12, 0x16*/ u16 vibratoExtentChangeDelay;
|
||||
/*0x14, 0x18*/ u16 vibratoDelay;
|
||||
/*0x16, 0x1A*/ u16 delay;
|
||||
/*0x18, 0x1C*/ s16 instOrWave; // either 0 (none), instrument index + 1, or
|
||||
// 0x80..0x83 for sawtooth/triangle/sine/square waves.
|
||||
/*0x1A*/ s16 transposition;
|
||||
/*0x1C*/ f32 volumeScale;
|
||||
/*0x20*/ f32 volume;
|
||||
/*0x24*/ f32 pan;
|
||||
/*0x28*/ f32 panChannelWeight; // proportion of pan that comes from the channel (0..1)
|
||||
/*0x2C*/ f32 freqScale;
|
||||
/*0x30*/ u8 (*dynTable)[][2];
|
||||
/*0x34*/ struct Note *noteUnused; // never read
|
||||
/*0x38*/ struct SequenceChannelLayer *layerUnused; // never read
|
||||
/*0x3C*/ struct Instrument *instrument;
|
||||
/*0x40*/ struct SequencePlayer *seqPlayer;
|
||||
/*0x44*/ struct SequenceChannelLayer *layers[LAYERS_MAX];
|
||||
/*0x54*/ s8 soundScriptIO[8]; // bridge between sound script and audio lib. For player 2,
|
||||
/*0x1A, 0x1E*/ s16 transposition;
|
||||
/*0x1C, 0x20*/ f32 volumeScale;
|
||||
/*0x20, 0x24*/ f32 volume;
|
||||
#ifndef VERSION_EU
|
||||
/*0x24, 0x28*/ f32 pan;
|
||||
#else
|
||||
/*0x24, 0x28*/ s32 pan;
|
||||
#endif
|
||||
/*0x28, 0x2C*/ f32 panChannelWeight; // proportion of pan that comes from the channel (0..1)
|
||||
/*0x2C, 0x30*/ f32 freqScale;
|
||||
/*0x30, 0x34*/ u8 (*dynTable)[][2];
|
||||
/*0x34, ????*/ struct Note *noteUnused; // never read
|
||||
/*0x38, ????*/ struct SequenceChannelLayer *layerUnused; // never read
|
||||
/*0x3C, 0x40*/ struct Instrument *instrument;
|
||||
/*0x40, 0x44*/ struct SequencePlayer *seqPlayer;
|
||||
/*0x44, 0x48*/ struct SequenceChannelLayer *layers[LAYERS_MAX];
|
||||
/*0x54, 0x58*/ s8 soundScriptIO[8]; // bridge between sound script and audio lib. For player 2,
|
||||
// [0] contains enabled, [4] contains sound ID, [5] contains reverb adjustment
|
||||
/*0x5C*/ struct M64ScriptState scriptState;
|
||||
/*0x78*/ struct AdsrSettings adsr;
|
||||
/*0x80*/ struct NotePool notePool;
|
||||
}; // size = 0xC0
|
||||
/*0x5C, 0x60*/ struct M64ScriptState scriptState;
|
||||
/*0x78, 0x7C*/ struct AdsrSettings adsr;
|
||||
/*0x80, 0x84*/ struct NotePool notePool;
|
||||
}; // size = 0xC0, 0xC4 in EU
|
||||
|
||||
struct SequenceChannelLayer // Maybe SequenceTrack?
|
||||
{
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 stopSomething : 1; // ?
|
||||
/*0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
/*0x01*/ u8 status;
|
||||
/*0x02*/ u8 noteDuration; // set to 0x80
|
||||
/*0x03*/ u8 portamentoTargetNote;
|
||||
/*0x04*/ struct Portamento portamento;
|
||||
/*0x14*/ struct AdsrSettings adsr;
|
||||
/*0x1C*/ u16 portamentoTime;
|
||||
/*0x1E*/ s16 transposition; // #semitones added to play commands
|
||||
/* U/J, EU */
|
||||
/*0x00, 0x00*/ u8 enabled : 1;
|
||||
/*0x00, 0x00*/ u8 finished : 1;
|
||||
/*0x00, 0x00*/ u8 stopSomething : 1; // ?
|
||||
/*0x00, 0x00*/ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x00*/ u8 unkEu0b8 : 1;
|
||||
/* , 0x00*/ u8 unkEu0b4 : 1;
|
||||
/* , 0x00*/ u8 unkEu0b2 : 1;
|
||||
/* , 0x01*/ u8 euUnk1; // euInstOrWave?
|
||||
#endif
|
||||
/*0x01, 0x02*/ u8 status;
|
||||
/*0x02, 0x03*/ u8 noteDuration; // set to 0x80
|
||||
/*0x03, 0x04*/ u8 portamentoTargetNote;
|
||||
#ifdef VERSION_EU
|
||||
/* , 0x05*/ u8 euUnk5; // contains US/JP pan * 128.0f
|
||||
/* , 0x06*/ u8 notePan;
|
||||
#endif
|
||||
/*0x04, 0x08*/ struct Portamento portamento;
|
||||
/*0x14, 0x18*/ struct AdsrSettings adsr;
|
||||
/*0x1C, 0x20*/ u16 portamentoTime;
|
||||
/*0x1E, 0x22*/ s16 transposition; // #semitones added to play commands
|
||||
// (m64 instruction encoding only allows referring to the limited range
|
||||
// 0..0x3f; this makes 0x40..0x7f accessible as well)
|
||||
/*0x20*/ f32 freqScale;
|
||||
/*0x24*/ f32 velocitySquare;
|
||||
/*0x20, 0x24*/ f32 freqScale;
|
||||
/*0x24, 0x28*/ f32 velocitySquare;
|
||||
#ifndef VERSION_EU
|
||||
/*0x28*/ f32 pan;
|
||||
/*0x2C*/ f32 noteVelocity;
|
||||
#endif
|
||||
/*0x2C, 0x2C*/ f32 noteVelocity;
|
||||
#ifndef VERSION_EU
|
||||
/*0x30*/ f32 notePan;
|
||||
/*0x34*/ f32 noteFreqScale;
|
||||
/*0x38*/ s16 shortNoteDefaultPlayPercentage;
|
||||
/*0x3A*/ s16 playPercentage; // it's not really a percentage...
|
||||
/*0x3C*/ s16 delay;
|
||||
/*0x3E*/ s16 duration;
|
||||
/*0x40*/ s16 delayUnused; // set to 'delay', never read
|
||||
/*0x44*/ struct Note *note;
|
||||
/*0x48*/ struct Instrument *instrument;
|
||||
/*0x4C*/ struct AudioBankSound *sound;
|
||||
/*0x50*/ struct SequenceChannel *seqChannel;
|
||||
/*0x54*/ struct M64ScriptState scriptState;
|
||||
/*0x70*/ struct AudioListItem listItem;
|
||||
#endif
|
||||
/*0x34, 0x30*/ f32 noteFreqScale;
|
||||
/*0x38, 0x34*/ s16 shortNoteDefaultPlayPercentage;
|
||||
/*0x3A, 0x36*/ s16 playPercentage; // it's not really a percentage...
|
||||
/*0x3C, 0x38*/ s16 delay;
|
||||
/*0x3E, 0x3A*/ s16 duration;
|
||||
/*0x40, 0x3C*/ s16 delayUnused; // set to 'delay', never read
|
||||
/*0x44, 0x40*/ struct Note *note;
|
||||
/*0x48, 0x44*/ struct Instrument *instrument;
|
||||
/*0x4C, 0x48*/ struct AudioBankSound *sound;
|
||||
/*0x50, 0x4C*/ struct SequenceChannel *seqChannel;
|
||||
/*0x54, 0x50*/ struct M64ScriptState scriptState;
|
||||
/*0x70, 0x6C*/ struct AudioListItem listItem;
|
||||
#ifdef VERSION_EU
|
||||
u8 pad2[4];
|
||||
#endif
|
||||
}; // size = 0x80
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct NoteSynthesisState
|
||||
{
|
||||
/*0x00*/ u8 restart;
|
||||
/*0x01*/ u8 sampleDmaIndex;
|
||||
/*0x02*/ u8 prevHeadsetPanRight;
|
||||
/*0x03*/ u8 prevHeadsetPanLeft;
|
||||
/* */ u16 samplePosFrac; //?
|
||||
/*0x08*/ s32 samplePosInt;
|
||||
/*0x0C*/ struct NoteSynthesisBuffers *synthesisBuffers;
|
||||
/*0x10*/ s16 curVolLeft;
|
||||
/*0x12*/ s16 curVolRight;
|
||||
};
|
||||
struct NotePlaybackState
|
||||
{
|
||||
/* U/J, EU */
|
||||
/*0x04, 0x00*/ u8 priority;
|
||||
/* 0x01*/ u8 waveId;
|
||||
/* 0x02*/ u8 sampleCountIndex;
|
||||
/*0x08, 0x04*/ s16 adsrVolScale;
|
||||
/*0x18, 0x08*/ f32 portamentoFreqScale;
|
||||
/*0x1C, 0x0C*/ f32 vibratoFreqScale;
|
||||
/*0x28, 0x10*/ struct SequenceChannelLayer *prevParentLayer;
|
||||
/*0x2C, 0x14*/ struct SequenceChannelLayer *parentLayer;
|
||||
/*0x30, 0x18*/ struct SequenceChannelLayer *wantedParentLayer;
|
||||
/* , 0x1C*/ struct NoteAttributes attributes;
|
||||
/*0x54, 0x28*/ struct AdsrState adsr;
|
||||
/*0x74, 0x4C*/ struct Portamento portamento;
|
||||
/*0x84, 0x5C*/ struct VibratoState vibratoState;
|
||||
};
|
||||
struct NoteSubEu
|
||||
{
|
||||
/*0x00*/ volatile u8 enabled : 1;
|
||||
/*0x00*/ u8 needsInit : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 envMixerNeedsInit : 1;
|
||||
/*0x00*/ u8 stereoStrongRight : 1;
|
||||
/*0x00*/ u8 stereoStrongLeft : 1;
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00*/ u8 usesHeadsetPanEffects : 1;
|
||||
/*0x01*/ u8 unk1b567 : 3;
|
||||
/*0x01*/ u8 unk1b234 : 3;
|
||||
/*0x01*/ u8 isSyntheticWave : 1;
|
||||
/*0x01*/ u8 hasTwoAdpcmParts : 1;
|
||||
/*0x02*/ u8 bankId;
|
||||
/*0x03*/ u8 headsetPanRight;
|
||||
/*0x04*/ u8 headsetPanLeft;
|
||||
/*0x05*/ u8 reverbVol;
|
||||
/*0x06*/ u16 targetVolLeft;
|
||||
/*0x08*/ u16 targetVolRight;
|
||||
/*0x0A*/ u16 resamplingRateFixedPoint; // stored as signed but loaded as u16
|
||||
/*0x0C*/ union {
|
||||
s16 *samples;
|
||||
struct AudioBankSound *audioBankSound;
|
||||
} sound;
|
||||
};
|
||||
struct Note
|
||||
{
|
||||
/* U/J, EU */
|
||||
/*0xA4, 0x00*/ struct AudioListItem listItem;
|
||||
/* 0x10*/ struct NoteSynthesisState synthesisState;
|
||||
u8 pad0[12];
|
||||
/*0x04, 0x30*/ u8 priority;
|
||||
/* 0x31*/ u8 waveId;
|
||||
/* 0x32*/ u8 sampleCountIndex;
|
||||
/*0x08, 0x34*/ s16 adsrVolScale;
|
||||
/*0x18, 0x38*/ f32 portamentoFreqScale;
|
||||
/*0x1C, 0x3C*/ f32 vibratoFreqScale;
|
||||
/*0x28, 0x40*/ struct SequenceChannelLayer *prevParentLayer;
|
||||
/*0x2C, 0x44*/ struct SequenceChannelLayer *parentLayer;
|
||||
/*0x30, 0x48*/ struct SequenceChannelLayer *wantedParentLayer;
|
||||
/* , 0x4C*/ struct NoteAttributes attributes;
|
||||
/*0x54, 0x58*/ struct AdsrState adsr;
|
||||
/*0x74, 0x7C*/ struct Portamento portamento;
|
||||
/*0x84, 0x8C*/ struct VibratoState vibratoState;
|
||||
u8 pad3[8];
|
||||
/* , 0xB0*/ struct NoteSubEu noteSubEu;
|
||||
}; // size = 0xC0
|
||||
#else
|
||||
struct Note
|
||||
{
|
||||
/* U/J, EU */
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 needsInit : 1;
|
||||
/*0x00*/ u8 restart : 1;
|
||||
@@ -348,24 +538,24 @@ struct Note
|
||||
/*0x01*/ u8 usesHeadsetPanEffects;
|
||||
/*0x02*/ u8 unk2;
|
||||
/*0x03*/ u8 sampleDmaIndex;
|
||||
/*0x04*/ u8 priority;
|
||||
/*0x04, 0x30*/ u8 priority;
|
||||
/*0x05*/ u8 sampleCount; // 0, 8, 16, 32 or 64
|
||||
/*0x06*/ u8 instOrWave;
|
||||
/*0x07*/ u8 bankId;
|
||||
/*0x07*/ u8 bankId; // in NoteSubEu on EU
|
||||
/*0x08*/ s16 adsrVolScale;
|
||||
/* */ u8 pad1[2];
|
||||
/*0x0C*/ u16 headsetPanRight;
|
||||
/*0x0E*/ u16 headsetPanLeft;
|
||||
/*0x0C, 0xB3*/ u16 headsetPanRight;
|
||||
/*0x0E, 0xB4*/ u16 headsetPanLeft;
|
||||
/*0x10*/ u16 prevHeadsetPanRight;
|
||||
/*0x12*/ u16 prevHeadsetPanLeft;
|
||||
/*0x14*/ s32 samplePosInt;
|
||||
/*0x18*/ f32 portamentoFreqScale;
|
||||
/*0x1C*/ f32 vibratoFreqScale;
|
||||
/*0x18, 0x38*/ f32 portamentoFreqScale;
|
||||
/*0x1C, 0x3C*/ f32 vibratoFreqScale;
|
||||
/*0x20*/ u16 samplePosFrac;
|
||||
/*0x24*/ struct AudioBankSound *sound;
|
||||
/*0x28*/ struct SequenceChannelLayer *prevParentLayer;
|
||||
/*0x2C*/ struct SequenceChannelLayer *parentLayer;
|
||||
/*0x30*/ struct SequenceChannelLayer *wantedParentLayer;
|
||||
/*0x28, 0x40*/ struct SequenceChannelLayer *prevParentLayer;
|
||||
/*0x2C, 0x44*/ struct SequenceChannelLayer *parentLayer;
|
||||
/*0x30, 0x48*/ struct SequenceChannelLayer *wantedParentLayer;
|
||||
/*0x34*/ struct NoteSynthesisBuffers *synthesisBuffers;
|
||||
/*0x38*/ f32 frequency;
|
||||
/*0x3C*/ u16 targetVolLeft;
|
||||
@@ -373,16 +563,17 @@ struct Note
|
||||
/*0x40*/ u8 reverb;
|
||||
/*0x41*/ u8 unused1; // never read, set to 0x3f
|
||||
/*0x44*/ struct NoteAttributes attributes;
|
||||
/*0x54*/ struct AdsrState adsr;
|
||||
/*0x74*/ struct Portamento portamento;
|
||||
/*0x84*/ struct VibratoState vibratoState;
|
||||
/*0x54, 0x58*/ struct AdsrState adsr;
|
||||
/*0x74, 0x7C*/ struct Portamento portamento;
|
||||
/*0x84, 0x8C*/ struct VibratoState vibratoState;
|
||||
/*0x9C*/ s16 curVolLeft;
|
||||
/*0x9E*/ s16 curVolRight;
|
||||
/*0xA0*/ s16 reverbVol;
|
||||
/*0xA2*/ s16 unused2; // never read, set to 0
|
||||
/*0xA4*/ struct AudioListItem listItem;
|
||||
/* */ u8 pad2[0xc];
|
||||
/*0xA4, 0x00*/ struct AudioListItem listItem;
|
||||
/* */ u8 pad2[0xc];
|
||||
}; // size = 0xC0
|
||||
#endif
|
||||
|
||||
struct NoteSynthesisBuffers
|
||||
{
|
||||
@@ -392,7 +583,32 @@ struct NoteSynthesisBuffers
|
||||
s16 panResampleState[0x10];
|
||||
s16 panSamplesBuffer[0x20];
|
||||
s16 dummyResampleState[0x10];
|
||||
#ifndef VERSION_EU
|
||||
s16 samples[0x40];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ReverbSettingsEU
|
||||
{
|
||||
u8 downsampleRate;
|
||||
u8 windowSize; // To be multiplied by 64
|
||||
u16 gain;
|
||||
};
|
||||
|
||||
struct AudioSessionSettingsEU
|
||||
{
|
||||
u32 frequency;
|
||||
u8 unk1; // always 1
|
||||
u8 maxSimultaneousNotes;
|
||||
u8 numReverbs; // always 1
|
||||
u8 unk2; // always 0
|
||||
struct ReverbSettingsEU *reverbSettings;
|
||||
u16 volume;
|
||||
u16 unk3; // always 0
|
||||
u32 persistentSeqMem;
|
||||
u32 persistentBankMem;
|
||||
u32 temporarySeqMem;
|
||||
u32 temporaryBankMem;
|
||||
};
|
||||
|
||||
struct AudioSessionSettings
|
||||
@@ -409,4 +625,39 @@ struct AudioSessionSettings
|
||||
/*0x18*/ u32 temporaryBankMem;
|
||||
}; // size = 0x1C
|
||||
|
||||
struct AudioBufferParametersEU {
|
||||
/*0x00*/ s16 presetUnk4; // audio frames per vsync?
|
||||
/*0x02*/ u16 frequency;
|
||||
/*0x04*/ u16 aiFrequency; // ?16
|
||||
/*0x06*/ s16 samplesPerFrameTarget;
|
||||
/*0x08*/ s16 maxAiBufferLength;
|
||||
/*0x0A*/ s16 minAiBufferLength;
|
||||
/*0x0C*/ s16 updatesPerFrame;
|
||||
/*0x0E*/ s16 samplesPerUpdate;
|
||||
/*0x10*/ s16 samplesPerUpdateMax;
|
||||
/*0x12*/ s16 samplesPerUpdateMin;
|
||||
/*0x14*/ f32 resampleRate; // contains 32000.0f / frequency
|
||||
/*0x18*/ f32 updatesPerFrameInv; // 1.0f / updatesPerFrame
|
||||
/*0x1C*/ f32 unkUpdatesPerFrameScaled; // 3.0f / (1280.0f * updatesPerFrame)
|
||||
};
|
||||
|
||||
struct EuAudioCmd {
|
||||
union {
|
||||
struct {
|
||||
u8 op;
|
||||
u8 arg1;
|
||||
u8 arg2;
|
||||
u8 arg3;
|
||||
} s;
|
||||
s32 first;
|
||||
} u;
|
||||
union {
|
||||
s32 as_s32;
|
||||
u32 as_u32;
|
||||
f32 as_f32;
|
||||
u8 as_u8;
|
||||
s8 as_s8;
|
||||
} u2;
|
||||
};
|
||||
|
||||
#endif /* AUDIO_INTERNAL_H */
|
||||
+353
-113
@@ -18,16 +18,20 @@ struct SharedDma {
|
||||
/*0xE*/ u8 ttl; // duration after which the DMA can be discarded
|
||||
}; // size = 0x10
|
||||
|
||||
struct Note *gNotes;
|
||||
struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
struct SequenceChannel gSequenceChannels[32];
|
||||
// EU only
|
||||
void func_802ada64(void);
|
||||
s32 func_eu_802E2AA0(void);
|
||||
|
||||
#ifdef VERSION_JP
|
||||
struct SequenceChannelLayer gSequenceLayers[48];
|
||||
#else
|
||||
struct SequenceChannelLayer gSequenceLayers[52];
|
||||
struct Note *gNotes;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
static u8 pad[4];
|
||||
#endif
|
||||
|
||||
struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
struct SequenceChannel gSequenceChannels[SEQUENCE_CHANNELS];
|
||||
struct SequenceChannelLayer gSequenceLayers[SEQUENCE_LAYERS];
|
||||
|
||||
struct SequenceChannel gSequenceChannelNone;
|
||||
struct AudioListItem gLayerFreeList;
|
||||
struct NotePool gNoteFreeLists;
|
||||
@@ -35,6 +39,7 @@ struct NotePool gNoteFreeLists;
|
||||
OSMesgQueue gCurrAudioFrameDmaQueue;
|
||||
OSMesg gCurrAudioFrameDmaMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE];
|
||||
OSIoMesg gCurrAudioFrameDmaIoMesgBufs[AUDIO_FRAME_DMA_QUEUE_SIZE];
|
||||
|
||||
OSMesgQueue gAudioDmaMesgQueue;
|
||||
OSMesg gAudioDmaMesg;
|
||||
OSIoMesg gAudioDmaIoMesg;
|
||||
@@ -52,12 +57,44 @@ u8 sSampleDmaReuseQueueTail2;
|
||||
u8 sSampleDmaReuseQueueHead1;
|
||||
u8 sSampleDmaReuseQueueHead2;
|
||||
|
||||
// bss correct up to here
|
||||
|
||||
ALSeqFile *gSeqFileHeader;
|
||||
ALSeqFile *gAlCtlHeader;
|
||||
ALSeqFile *gAlTbl;
|
||||
u8 *gAlBankSets;
|
||||
u16 gSequenceCount;
|
||||
|
||||
struct CtlEntry *gCtlEntries;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u32 padEuBss1;
|
||||
struct AudioBufferParametersEU gAudioBufferParameters;
|
||||
#else
|
||||
s32 gAiFrequency;
|
||||
#endif
|
||||
|
||||
u32 D_80226D68;
|
||||
s32 gMaxAudioCmds;
|
||||
s32 gMaxSimultaneousNotes;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s16 gTempoInternalToExternal;
|
||||
#else
|
||||
s32 gSamplesPerFrameTarget;
|
||||
s32 gMinAiBufferLength;
|
||||
|
||||
s16 gTempoInternalToExternal;
|
||||
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
#endif
|
||||
|
||||
s8 gSoundMode;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
#endif
|
||||
|
||||
extern u64 gAudioGlobalsStartMarker;
|
||||
extern u64 gAudioGlobalsEndMarker;
|
||||
|
||||
@@ -66,6 +103,7 @@ extern u8 gSoundDataRaw[]; // sound_data.tbl
|
||||
extern u8 gMusicData[]; // sequences.s
|
||||
extern u8 gBankSetsData[]; // bank_sets.s
|
||||
|
||||
|
||||
/**
|
||||
* Performs an immediate DMA copy
|
||||
*/
|
||||
@@ -88,9 +126,12 @@ void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQ
|
||||
* Performs a partial asynchronous (normal priority) DMA copy. This is limited
|
||||
* to 0x1000 bytes transfer at once.
|
||||
*/
|
||||
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue,
|
||||
OSIoMesg *mesg) {
|
||||
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) {
|
||||
#ifdef VERSION_EU
|
||||
ssize_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining);
|
||||
#else
|
||||
ssize_t transfer = (*remaining < 0x1000 ? *remaining : 0x1000);
|
||||
#endif
|
||||
*remaining -= transfer;
|
||||
osInvalDCache(*vAddr, transfer);
|
||||
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue);
|
||||
@@ -102,7 +143,11 @@ void decrease_sample_dma_ttls() {
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < sSampleDmaListSize1; i++) {
|
||||
#ifdef VERSION_EU
|
||||
struct SharedDma *temp = &sSampleDmas[i];
|
||||
#else
|
||||
struct SharedDma *temp = sSampleDmas + i;
|
||||
#endif
|
||||
if (temp->ttl != 0) {
|
||||
temp->ttl--;
|
||||
if (temp->ttl == 0) {
|
||||
@@ -113,7 +158,11 @@ void decrease_sample_dma_ttls() {
|
||||
}
|
||||
|
||||
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
|
||||
#ifdef VERSION_EU
|
||||
struct SharedDma *temp = &sSampleDmas[i];
|
||||
#else
|
||||
struct SharedDma *temp = sSampleDmas + i;
|
||||
#endif
|
||||
if (temp->ttl != 0) {
|
||||
temp->ttl--;
|
||||
if (temp->ttl == 0) {
|
||||
@@ -138,7 +187,11 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
|
||||
if (arg2 != 0 || *arg3 >= sSampleDmaListSize1) {
|
||||
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
|
||||
#ifdef VERSION_EU
|
||||
dma = &sSampleDmas[i];
|
||||
#else
|
||||
dma = sSampleDmas + i;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have a DMA request for this memory range.
|
||||
@@ -155,7 +208,11 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
}
|
||||
dma->ttl = 60;
|
||||
*arg3 = (u8) i;
|
||||
#ifdef VERSION_EU
|
||||
return &dma->buffer[(devAddr - dma->source)];
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +225,12 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
hasDma = TRUE;
|
||||
}
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
dma = sSampleDmas;
|
||||
dma += *arg3;
|
||||
#else
|
||||
dma = sSampleDmas + *arg3;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have DMA for this memory range.
|
||||
@@ -176,6 +238,10 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
// Move the DMA out of the reuse queue, by swapping it with the
|
||||
// tail, and then incrementing the tail.
|
||||
if (dma->reuseIndex != sSampleDmaReuseQueueTail1) {
|
||||
#ifdef VERSION_EU
|
||||
if (1) {
|
||||
}
|
||||
#endif
|
||||
sSampleDmaReuseQueue1[dma->reuseIndex] =
|
||||
sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1];
|
||||
sSampleDmas[sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1]].reuseIndex =
|
||||
@@ -184,7 +250,11 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
sSampleDmaReuseQueueTail1++;
|
||||
}
|
||||
dma->ttl = 2;
|
||||
#ifdef VERSION_EU
|
||||
return dma->buffer + (devAddr - dma->source);
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,26 +271,45 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
|
||||
dma->ttl = 2;
|
||||
dma->source = dmaDevAddr;
|
||||
dma->sizeUnused = transfer;
|
||||
#ifndef VERSION_JP
|
||||
#ifdef VERSION_US
|
||||
osInvalDCache(dma->buffer, transfer);
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount++], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*arg3 = dmaIndex;
|
||||
return (devAddr - dmaDevAddr) + dma->buffer;
|
||||
#else
|
||||
gCurrAudioFrameDmaCount++;
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount - 1], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*arg3 = dmaIndex;
|
||||
return dma->buffer + (devAddr - dmaDevAddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
// called from sound_reset
|
||||
void init_sample_dma_buffers(UNUSED s32 arg0) {
|
||||
s32 i;
|
||||
#ifdef VERSION_EU
|
||||
#define j i
|
||||
#else
|
||||
s32 j;
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
D_80226D68 = 0x400;
|
||||
for (i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++) {
|
||||
#else
|
||||
D_80226D68 = 144 * 9;
|
||||
for (i = 0; i < gMaxSimultaneousNotes * 3; i++) {
|
||||
#endif
|
||||
sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, D_80226D68);
|
||||
if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto out1;
|
||||
#endif
|
||||
}
|
||||
sSampleDmas[gSampleDmaNumListItems].source = 0;
|
||||
sSampleDmas[gSampleDmaNumListItems].sizeUnused = 0;
|
||||
@@ -229,7 +318,9 @@ void init_sample_dma_buffers(UNUSED s32 arg0) {
|
||||
sSampleDmas[gSampleDmaNumListItems].bufSize = D_80226D68;
|
||||
gSampleDmaNumListItems++;
|
||||
}
|
||||
#ifndef VERSION_EU
|
||||
out1:
|
||||
#endif
|
||||
|
||||
for (i = 0; (u32) i < gSampleDmaNumListItems; i++) {
|
||||
sSampleDmaReuseQueue1[i] = (u8) i;
|
||||
@@ -244,11 +335,19 @@ out1:
|
||||
sSampleDmaReuseQueueHead1 = (u8) gSampleDmaNumListItems;
|
||||
sSampleDmaListSize1 = gSampleDmaNumListItems;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
D_80226D68 = 0x200;
|
||||
#else
|
||||
D_80226D68 = 160 * 9;
|
||||
#endif
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, D_80226D68);
|
||||
if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
|
||||
#ifdef VERSION_EU
|
||||
break;
|
||||
#else
|
||||
goto out2;
|
||||
#endif
|
||||
}
|
||||
sSampleDmas[gSampleDmaNumListItems].source = 0;
|
||||
sSampleDmas[gSampleDmaNumListItems].sizeUnused = 0;
|
||||
@@ -257,7 +356,9 @@ out1:
|
||||
sSampleDmas[gSampleDmaNumListItems].bufSize = D_80226D68;
|
||||
gSampleDmaNumListItems++;
|
||||
}
|
||||
#ifndef VERSION_EU
|
||||
out2:
|
||||
#endif
|
||||
|
||||
for (i = sSampleDmaListSize1; (u32) i < gSampleDmaNumListItems; i++) {
|
||||
sSampleDmaReuseQueue2[i - sSampleDmaListSize1] = (u8) i;
|
||||
@@ -272,6 +373,9 @@ out2:
|
||||
|
||||
sSampleDmaReuseQueueTail2 = 0;
|
||||
sSampleDmaReuseQueueHead2 = gSampleDmaNumListItems - sSampleDmaListSize1;
|
||||
#ifdef VERSION_EU
|
||||
#undef j
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef static
|
||||
@@ -279,122 +383,177 @@ out2:
|
||||
#undef static
|
||||
#endif
|
||||
|
||||
static void unused_80317844(void) {
|
||||
// With -O2 -framepointer, this never-invoked static function gets *almost*
|
||||
// optimized out, regardless of contents, leaving only "jr $ra, nop".
|
||||
// If not declared as static, it unnecessarily moves the stack pointer up
|
||||
// and down by 8.
|
||||
}
|
||||
#ifndef VERSION_EU
|
||||
// This function gets optimized out on US due to being static and never called
|
||||
static
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums) {
|
||||
// Make pointers into real pointers rather than indices
|
||||
struct Instrument *instrument;
|
||||
struct Instrument **itInstrs;
|
||||
u32 i;
|
||||
uintptr_t memBase = (uintptr_t) mem;
|
||||
uintptr_t offsetBase = (uintptr_t) offset;
|
||||
void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED u8 *offsetBase) {
|
||||
struct AudioBankSample *sample;
|
||||
void *patched;
|
||||
UNUSED u8 *mem; // unused on US
|
||||
|
||||
#define INIT_SOUND(sound) \
|
||||
{ \
|
||||
struct AudioBankSample **itSample = &sound.sample; \
|
||||
if ((*itSample) != 0) { \
|
||||
/* Making these volatile gives correct codegen further down; it makes \
|
||||
* lw/addiu/sw's happen in source order, and uses two registers... \
|
||||
* It looks odd, though, so maybe they should not be volatile. \
|
||||
* It might also be causing the extra register use. \
|
||||
* Presumably sample and sample2 ought to have different types, \
|
||||
* but that doesn't matter for codegen. */ \
|
||||
volatile struct AudioBankSample *sample, *sample2; \
|
||||
*itSample = (void *) (memBase + (uintptr_t)(*itSample)); \
|
||||
sample = *itSample; \
|
||||
sample2 = *itSample; \
|
||||
if (sample2->loaded == FALSE) { \
|
||||
void *a = sample2->sampleAddr; \
|
||||
void *b = sample->loop; \
|
||||
void *c = sample->book; \
|
||||
sample->sampleAddr = (void *) (offsetBase + (uintptr_t) a); \
|
||||
sample->loop = (void *) (memBase + (uintptr_t) b); \
|
||||
sample->book = (void *) (memBase + (uintptr_t) c); \
|
||||
sample->loaded = TRUE; \
|
||||
} \
|
||||
} \
|
||||
#define PATCH(x, base) (patched = (void *)((uintptr_t) (x) + (uintptr_t) base))
|
||||
|
||||
if (sound->sample != NULL) {
|
||||
sample = sound->sample = PATCH(sound->sample, memBase);
|
||||
if (sample->loaded == 0) {
|
||||
sample->sampleAddr = PATCH(sample->sampleAddr, offsetBase);
|
||||
sample->loop = PATCH(sample->loop, memBase);
|
||||
sample->book = PATCH(sample->book, memBase);
|
||||
sample->loaded = 1;
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
else if (sample->loaded == 0x80) {
|
||||
PATCH(sample->sampleAddr, offsetBase);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, sample->sampleSize);
|
||||
if (mem == NULL) {
|
||||
sample->sampleAddr = patched;
|
||||
sample->loaded = 1;
|
||||
} else {
|
||||
audio_dma_copy_immediate((uintptr_t) patched, mem, sample->sampleSize);
|
||||
sample->loaded = 0x81;
|
||||
sample->sampleAddr = mem;
|
||||
}
|
||||
sample->loop = PATCH(sample->loop, memBase);
|
||||
sample->book = PATCH(sample->book, memBase);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mem->drums != NULL) {
|
||||
if (numDrums != 0) {
|
||||
mem->drums = (struct Drum **) (memBase + (uintptr_t) mem->drums);
|
||||
if (numDrums != 0) {
|
||||
for (i = 0; i < numDrums; i++) {
|
||||
#if 0
|
||||
// This doesn't work: Taking the address to mem->drums[i]
|
||||
// does an sll to figure out the lower loop limit.
|
||||
volatile struct Drum *drum, *drum2;
|
||||
struct Drum **h = &mem->drums[i];
|
||||
if (*h == 0) continue;
|
||||
{
|
||||
*h = (void *)(memBase + (uintptr_t)*h);
|
||||
drum = *h;
|
||||
drum2 = *h;
|
||||
if (drum2->loaded == FALSE)
|
||||
{
|
||||
void *d;
|
||||
INIT_SOUND(((struct Drum *)drum2)->sound);
|
||||
d = drum2->envelope;
|
||||
drum->loaded = TRUE;
|
||||
drum->envelope = (void *) (memBase + (uintptr_t)d);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Neither does this: Using mem->drums[i] directly
|
||||
// deduplicates it -- drum and drum2 end up in the same
|
||||
// register.
|
||||
struct Drum **drums = mem->drums;
|
||||
uintptr_t h = (uintptr_t) drums[i];
|
||||
if (h != 0) {
|
||||
volatile struct Drum *drum, *drum2;
|
||||
drums[i] = (struct Drum *) (memBase + h);
|
||||
drum = drums[i];
|
||||
drum2 = drums[i];
|
||||
if (drum->loaded == FALSE) {
|
||||
void *d;
|
||||
INIT_SOUND(((struct Drum *) drum)->sound);
|
||||
d = drum->envelope;
|
||||
drum2->loaded = TRUE;
|
||||
drum2->envelope = (void *) (memBase + (uintptr_t) d);
|
||||
}
|
||||
}
|
||||
#undef PATCH
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
#define PATCH_SOUND(_sound, mem, offset) \
|
||||
{ \
|
||||
struct AudioBankSound *sound = _sound; \
|
||||
struct AudioBankSample *sample; \
|
||||
void *patched; \
|
||||
if ((*sound).sample != (void *) 0) \
|
||||
{ \
|
||||
patched = (void *)(((unsigned int)(*sound).sample) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sound).sample = patched; \
|
||||
sample = (*sound).sample; \
|
||||
if ((*sample).loaded == 0) \
|
||||
{ \
|
||||
patched = (void *)(((unsigned int)(*sample).sampleAddr) + ((unsigned int) offset)); \
|
||||
(*sample).sampleAddr = patched; \
|
||||
patched = (void *)(((unsigned int)(*sample).loop) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sample).loop = patched; \
|
||||
patched = (void *)(((unsigned int)(*sample).book) + ((unsigned int)((unsigned char *) mem))); \
|
||||
(*sample).book = patched; \
|
||||
(*sample).loaded = 1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
// on US/JP this inlines patch_sound, using some -sopt compiler flag
|
||||
void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums) {
|
||||
struct Instrument *instrument;
|
||||
struct Instrument **itInstrs;
|
||||
struct Instrument **end;
|
||||
struct AudioBank *temp;
|
||||
u32 i;
|
||||
void *patched;
|
||||
struct Drum *drum;
|
||||
struct Drum **drums;
|
||||
#ifdef VERSION_EU
|
||||
u32 numDrums2;
|
||||
#endif
|
||||
|
||||
#define PATCH(x, base) (patched = (void *)((uintptr_t) (x) + (uintptr_t) base))
|
||||
#define PATCH_MEM(x) x = PATCH(x, mem)
|
||||
|
||||
drums = mem->drums;
|
||||
#ifndef VERSION_EU
|
||||
if (drums != NULL && numDrums > 0) {
|
||||
mem->drums = (void *)((unsigned int) drums + (unsigned int) mem);
|
||||
if (numDrums > 0) //! unneeded when -sopt is enabled
|
||||
for (i = 0; i < numDrums; i++) {
|
||||
#else
|
||||
numDrums2 = numDrums;
|
||||
if (drums != NULL && numDrums2 > 0) {
|
||||
mem->drums = PATCH(drums, mem);
|
||||
for (i = 0; i < numDrums2; i++) {
|
||||
#endif
|
||||
patched = mem->drums[i];
|
||||
if (patched != NULL) {
|
||||
drum = PATCH(patched, mem);
|
||||
mem->drums[i] = drum;
|
||||
if (drum->loaded == 0) {
|
||||
#ifndef VERSION_EU
|
||||
//! copt replaces drum with 'patched' for these two lines
|
||||
PATCH_SOUND(&(*(struct Drum *)patched).sound, mem, offset);
|
||||
patched = (*(struct Drum *)patched).envelope;
|
||||
drum->envelope = (void *)((uintptr_t) mem + (uintptr_t) patched);
|
||||
#else
|
||||
patch_sound(&drum->sound, (u8 *) mem, offset);
|
||||
patched = drum->envelope;
|
||||
drum->envelope = (void *)((uintptr_t) patched + (uintptr_t) mem);
|
||||
#endif
|
||||
drum->loaded = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((numInstruments >= 1) && (numInstruments >= 1) != 0) {
|
||||
itInstrs = mem->instruments;
|
||||
//! Doesn't affect EU, but required for US/JP
|
||||
temp = &*mem;
|
||||
#ifndef VERSION_EU
|
||||
if (numInstruments >= 1)
|
||||
#endif
|
||||
if (numInstruments > 0) {
|
||||
//! Doesn't affect EU, but required for US/JP
|
||||
struct Instrument **tempInst;
|
||||
itInstrs = temp->instruments;
|
||||
tempInst = temp->instruments;
|
||||
end = numInstruments + tempInst;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
l2:
|
||||
#else
|
||||
do {
|
||||
if (*itInstrs) {
|
||||
*itInstrs = (void *) (memBase + (uintptr_t) *itInstrs);
|
||||
#endif
|
||||
if (*itInstrs != NULL) {
|
||||
*itInstrs = (void *)((uintptr_t) *itInstrs + (uintptr_t) mem);
|
||||
instrument = *itInstrs;
|
||||
|
||||
if (instrument->loaded == FALSE) {
|
||||
INIT_SOUND(instrument->lowNotesSound);
|
||||
INIT_SOUND(instrument->normalNotesSound);
|
||||
INIT_SOUND(instrument->highNotesSound);
|
||||
|
||||
instrument->loaded = TRUE;
|
||||
instrument->envelope = (void *) (memBase + (uintptr_t) instrument->envelope);
|
||||
if (instrument->loaded == 0) {
|
||||
#ifndef VERSION_EU
|
||||
PATCH_SOUND(&instrument->lowNotesSound, (u8 *) mem, offset);
|
||||
PATCH_SOUND(&instrument->normalNotesSound, (u8 *) mem, offset);
|
||||
PATCH_SOUND(&instrument->highNotesSound, (u8 *) mem, offset);
|
||||
#else
|
||||
patch_sound(&instrument->lowNotesSound, (u8 *) mem, offset);
|
||||
patch_sound(&instrument->normalNotesSound, (u8 *) mem, offset);
|
||||
patch_sound(&instrument->highNotesSound, (u8 *) mem, offset);
|
||||
#endif
|
||||
patched = instrument->envelope;
|
||||
#ifndef VERSION_EU
|
||||
instrument->envelope = (void *)((uintptr_t) mem + (uintptr_t) patched);
|
||||
#else
|
||||
instrument->envelope = (void *)((uintptr_t) patched + (uintptr_t) mem);
|
||||
#endif
|
||||
instrument->loaded = 1;
|
||||
}
|
||||
}
|
||||
itInstrs++;
|
||||
} while (itInstrs != &mem->instruments[numInstruments]);
|
||||
}
|
||||
#undef INIT_SOUND
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
//! goto generated by copt, required to match US/JP
|
||||
if (end != itInstrs) {
|
||||
goto l2;
|
||||
}
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/patch_audio_bank.s")
|
||||
} while (end != itInstrs);
|
||||
#endif
|
||||
}
|
||||
#undef PATCH_MEM
|
||||
#undef PATCH
|
||||
#undef PATCH_SOUND
|
||||
}
|
||||
|
||||
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
UNUSED u32 pad1[4];
|
||||
@@ -437,6 +596,9 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
struct AudioBank *ret;
|
||||
u8 *ctlData;
|
||||
OSMesgQueue *mesgQueue;
|
||||
#ifdef VERSION_EU
|
||||
UNUSED u32 pad3;
|
||||
#endif
|
||||
|
||||
alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
alloc = ALIGN16(alloc);
|
||||
@@ -451,15 +613,29 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
numInstruments = buf[0];
|
||||
numDrums = buf[1];
|
||||
seqPlayer->loadingBankId = (u8) bankId;
|
||||
#ifdef VERSION_EU
|
||||
gCtlEntries[bankId].numInstruments = numInstruments;
|
||||
gCtlEntries[bankId].numDrums = numDrums;
|
||||
gCtlEntries[bankId].instruments = ret->instruments;
|
||||
gCtlEntries[bankId].drums = 0;
|
||||
seqPlayer->bankDmaCurrMemAddr = (u8 *) ret;
|
||||
seqPlayer->bankDmaCurrDevAddr = (uintptr_t)(ctlData + 0x10);
|
||||
seqPlayer->bankDmaRemaining = alloc;
|
||||
if (1) {
|
||||
}
|
||||
#else
|
||||
seqPlayer->loadingBankNumInstruments = numInstruments;
|
||||
seqPlayer->loadingBankNumDrums = numDrums;
|
||||
seqPlayer->bankDmaCurrMemAddr = (u8 *) ret;
|
||||
seqPlayer->loadingBank = ret;
|
||||
seqPlayer->bankDmaCurrDevAddr = (uintptr_t)(ctlData + 0x10);
|
||||
seqPlayer->bankDmaRemaining = alloc;
|
||||
#endif
|
||||
mesgQueue = &seqPlayer->bankDmaMesgQueue;
|
||||
osCreateMesgQueue(mesgQueue, &seqPlayer->bankDmaMesg, 1);
|
||||
#ifndef VERSION_EU
|
||||
seqPlayer->bankDmaMesg = NULL;
|
||||
#endif
|
||||
seqPlayer->bankDmaInProgress = TRUE;
|
||||
audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr,
|
||||
&seqPlayer->bankDmaRemaining, mesgQueue, &seqPlayer->bankDmaIoMesg);
|
||||
@@ -502,12 +678,16 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
|
||||
if (seqLength <= 0x40) {
|
||||
// Immediately load short sequenece
|
||||
audio_dma_copy_immediate((uintptr_t) seqData, ptr, seqLength);
|
||||
if (1) {
|
||||
gSeqLoadStatus[seqId] = SOUND_LOAD_STATUS_COMPLETE;
|
||||
}
|
||||
} else {
|
||||
audio_dma_copy_immediate((uintptr_t) seqData, ptr, 0x40);
|
||||
mesgQueue = &seqPlayer->seqDmaMesgQueue;
|
||||
osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1);
|
||||
#ifndef VERSION_EU
|
||||
seqPlayer->seqDmaMesg = NULL;
|
||||
#endif
|
||||
seqPlayer->seqDmaInProgress = TRUE;
|
||||
audio_dma_copy_async((uintptr_t)(seqData + 0x40), (u8 *) ptr + 0x40, seqLength - 0x40, mesgQueue,
|
||||
&seqPlayer->seqDmaIoMesg);
|
||||
@@ -525,13 +705,23 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) {
|
||||
|
||||
*nullCount = 0;
|
||||
*nonNullCount = 0;
|
||||
#ifdef VERSION_EU
|
||||
offset = ((u16 *) gAlBankSets)[seqId];
|
||||
for (i = gAlBankSets[offset++], ret = 0; i != 0; i--) {
|
||||
bankId = gAlBankSets[offset++];
|
||||
#else
|
||||
offset = ((u16 *) gAlBankSets)[seqId] + 1;
|
||||
for (i = gAlBankSets[offset - 1], ret = 0; i != 0; i--) {
|
||||
offset++;
|
||||
bankId = gAlBankSets[offset - 1];
|
||||
#endif
|
||||
|
||||
if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) {
|
||||
#ifdef VERSION_EU
|
||||
temp = get_bank_or_seq(&gBankLoadedPool, 2, bankId);
|
||||
#else
|
||||
temp = get_bank_or_seq(&gBankLoadedPool, 2, gAlBankSets[offset - 1]);
|
||||
#endif
|
||||
} else {
|
||||
temp = NULL;
|
||||
}
|
||||
@@ -553,13 +743,23 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *arg1) {
|
||||
u16 offset;
|
||||
u8 i;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
offset = ((u16 *) gAlBankSets)[seqId];
|
||||
for (i = gAlBankSets[offset++]; i != 0; i--) {
|
||||
bankId = gAlBankSets[offset++];
|
||||
#else
|
||||
offset = ((u16 *) gAlBankSets)[seqId] + 1;
|
||||
for (i = gAlBankSets[offset - 1]; i != 0; i--) {
|
||||
offset++;
|
||||
bankId = gAlBankSets[offset - 1];
|
||||
#endif
|
||||
|
||||
if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) {
|
||||
#ifdef VERSION_EU
|
||||
ret = get_bank_or_seq(&gBankLoadedPool, 2, bankId);
|
||||
#else
|
||||
ret = get_bank_or_seq(&gBankLoadedPool, 2, gAlBankSets[offset - 1]);
|
||||
#endif
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
@@ -670,10 +870,20 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
|
||||
}
|
||||
|
||||
void audio_init() {
|
||||
#ifdef VERSION_EU
|
||||
UNUSED s8 pad[16];
|
||||
#else
|
||||
UNUSED s8 pad[32];
|
||||
u8 buf[0x10];
|
||||
#endif
|
||||
s32 i, j, k;
|
||||
s32 lim1, lim2, lim3;
|
||||
UNUSED s32 lim1; // lim1 unused in EU
|
||||
#ifdef VERSION_EU
|
||||
u8 buf[0x10];
|
||||
s32 UNUSED lim2, lim3;
|
||||
#else
|
||||
s32 lim2, lim3;
|
||||
#endif
|
||||
u32 size;
|
||||
u64 *ptr64;
|
||||
void *data;
|
||||
@@ -681,6 +891,7 @@ void audio_init() {
|
||||
|
||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
lim1 = gUnusedCount80333EE8;
|
||||
for (i = 0; i < lim1; i++) {
|
||||
gUnused80226E58[i] = 0;
|
||||
@@ -699,9 +910,26 @@ void audio_init() {
|
||||
i++;
|
||||
ptr64[i] = 0;
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < gAudioHeapSize / 8; i++) {
|
||||
((u64 *) gAudioHeap)[i] = 0;
|
||||
}
|
||||
|
||||
lim3 = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) &gAudioGlobalsStartMarker) / 8;
|
||||
ptr64 = &gAudioGlobalsStartMarker;
|
||||
for (k = lim3; k >= 0; k--) {
|
||||
*ptr64++ = 0;
|
||||
}
|
||||
|
||||
D_EU_802298D0 = 20.03042f;
|
||||
gRefreshRate = 50;
|
||||
func_802ada64();
|
||||
if (k) {
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < NUMAIBUFFERS; i++) {
|
||||
gAiBufferLengths[i] = 0x00a0;
|
||||
gAiBufferLengths[i] = 0xa0;
|
||||
}
|
||||
|
||||
gAudioFrameCount = 0;
|
||||
@@ -720,21 +948,32 @@ void audio_init() {
|
||||
sound_init_main_pools(D_80333EF0);
|
||||
|
||||
for (i = 0; i < NUMAIBUFFERS; i++) {
|
||||
gAiBuffers[i] = soundAlloc(&gAudioInitPool, 0xa00);
|
||||
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
|
||||
|
||||
for (j = 0; j < 0x500; j++) {
|
||||
for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
|
||||
gAiBuffers[i][j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
gAudioResetPresetIdToLoad = 0;
|
||||
gAudioResetStatus = 1;
|
||||
func_eu_802E2AA0();
|
||||
#else
|
||||
audio_reset_session(&gAudioSessionPresets[0]);
|
||||
#endif
|
||||
|
||||
// Load header for sequence data (assets/music_data.sbk.s)
|
||||
gSeqFileHeader = (ALSeqFile *) buf;
|
||||
data = gMusicData;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, 0x10);
|
||||
gSequenceCount = gSeqFileHeader->seqCount;
|
||||
#ifdef VERSION_EU
|
||||
size = gSequenceCount * sizeof(ALSeqData) + 4;
|
||||
size = ALIGN16(size);
|
||||
#else
|
||||
size = ALIGN16(gSequenceCount * sizeof(ALSeqData) + 4);
|
||||
#endif
|
||||
gSeqFileHeader = soundAlloc(&gAudioInitPool, size);
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, size);
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
@@ -766,3 +1005,4 @@ void audio_init() {
|
||||
init_sequence_players();
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
|
||||
+17
-7
@@ -18,13 +18,8 @@ extern struct Note *gNotes;
|
||||
// gSequencePlayers[2] is sound
|
||||
extern struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
|
||||
extern struct SequenceChannel gSequenceChannels[32];
|
||||
|
||||
#ifdef VERSION_JP
|
||||
extern struct SequenceChannelLayer gSequenceLayers[48];
|
||||
#else
|
||||
extern struct SequenceChannelLayer gSequenceLayers[52];
|
||||
#endif
|
||||
extern struct SequenceChannel gSequenceChannels[SEQUENCE_CHANNELS];
|
||||
extern struct SequenceChannelLayer gSequenceLayers[SEQUENCE_LAYERS];
|
||||
|
||||
extern struct SequenceChannel gSequenceChannelNone;
|
||||
|
||||
@@ -36,6 +31,21 @@ extern u32 gSampleDmaNumListItems;
|
||||
extern ALSeqFile *gAlTbl;
|
||||
extern u8 *gAlBankSets;
|
||||
|
||||
extern struct CtlEntry *gCtlEntries;
|
||||
#ifdef VERSION_EU
|
||||
extern struct AudioBufferParametersEU gAudioBufferParameters;
|
||||
#endif
|
||||
extern s32 gAiFrequency;
|
||||
extern u32 D_80226D68;
|
||||
extern s32 gMaxAudioCmds;
|
||||
|
||||
extern s32 gMaxSimultaneousNotes;
|
||||
extern s32 gSamplesPerFrameTarget;
|
||||
extern s32 gMinAiBufferLength;
|
||||
extern s16 gTempoInternalToExternal;
|
||||
extern s8 gAudioUpdatesPerFrame; // = 4
|
||||
extern s8 gSoundMode;
|
||||
|
||||
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg);
|
||||
void decrease_sample_dma_ttls(void);
|
||||
void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3);
|
||||
|
||||
+348
-9
@@ -22,9 +22,11 @@ struct PoolSplit2 {
|
||||
u32 wantTemporary;
|
||||
}; // size = 0x8
|
||||
|
||||
#ifndef VERSION_EU
|
||||
s16 gVolume;
|
||||
s8 gReverbDownsampleRate;
|
||||
u8 sReverbDownsampleRateLog; // never read
|
||||
#endif
|
||||
|
||||
struct SoundAllocPool gAudioSessionPool;
|
||||
struct SoundAllocPool gAudioInitPool;
|
||||
@@ -33,6 +35,7 @@ u8 sAudioMemoryPad[0x20]; // probably two unused pools
|
||||
struct SoundAllocPool gSeqAndBankPool;
|
||||
struct SoundAllocPool gPersistentCommonPool;
|
||||
struct SoundAllocPool gTemporaryCommonPool;
|
||||
|
||||
struct SoundMultiPool gSeqLoadedPool;
|
||||
struct SoundMultiPool gBankLoadedPool;
|
||||
struct SoundMultiPool gUnusedLoadedPool;
|
||||
@@ -45,10 +48,108 @@ struct PoolSplit sTemporaryCommonPoolSplit;
|
||||
u8 gBankLoadStatus[0x40];
|
||||
u8 gSeqLoadStatus[0x100];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
volatile u8 gAudioResetStatus;
|
||||
u8 gAudioResetPresetIdToLoad;
|
||||
s32 gAudioResetFadeOutFramesLeft;
|
||||
#endif
|
||||
|
||||
u8 gAudioUnusedBuffer[0x1000];
|
||||
|
||||
extern s32 gMaxAudioCmds;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
/**
|
||||
* Assuming 'k' in [9, 24],
|
||||
* Computes a newton's method step for f(x) = x^k - d
|
||||
*/
|
||||
f64 root_newton_step(f64 x, s32 k, f64 d)
|
||||
{
|
||||
f64 deg2 = x * x;
|
||||
f64 deg4 = deg2 * deg2;
|
||||
f64 deg8 = deg4 * deg4;
|
||||
s32 degree = k - 9;
|
||||
f64 fx;
|
||||
|
||||
f64 deriv = deg8;
|
||||
if (degree & 1) {
|
||||
deriv *= x;
|
||||
}
|
||||
if (degree & 2) {
|
||||
deriv *= deg2;
|
||||
}
|
||||
if (degree & 4) {
|
||||
deriv *= deg4;
|
||||
}
|
||||
if (degree & 8) {
|
||||
deriv *= deg8;
|
||||
}
|
||||
fx = deriv * x - d;
|
||||
deriv = k * deriv;
|
||||
return x - fx / deriv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assuming 'k' in [9, 24],
|
||||
* Computes d ^ (1/k)
|
||||
*
|
||||
* @return the root, or 1.0 if d is 0
|
||||
*/
|
||||
f64 kth_root(f64 d, s32 k)
|
||||
{
|
||||
f64 root = 1.5;
|
||||
f64 next;
|
||||
f64 diff;
|
||||
s32 i;
|
||||
if (d == 0.0) {
|
||||
root = 1.0;
|
||||
} else {
|
||||
for (i = 0; i < 64; i++) {
|
||||
if (1) {
|
||||
}
|
||||
next = root_newton_step(root, k, d);
|
||||
diff = next - root;
|
||||
|
||||
if (diff < 0) {
|
||||
diff = -diff;
|
||||
}
|
||||
|
||||
if (diff < 1e-07) {
|
||||
root = next;
|
||||
break;
|
||||
} else {
|
||||
root = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void func_eu_802e1cd0(s32 UNUSED unused, s32 len) {
|
||||
s32 i;
|
||||
s32 step;
|
||||
s32 d;
|
||||
s32 k = len / 8;
|
||||
|
||||
for (step = 0, i = 0; i < 0x400; step += 32, i++) {
|
||||
d = step;
|
||||
if (step == 0) {
|
||||
d = 1;
|
||||
}
|
||||
|
||||
gLeftVolRampings[0][i] = kth_root( d, k - 1);
|
||||
gRightVolRampings[0][i] = kth_root(1.0 / d, k - 1) * 65536.0;
|
||||
gLeftVolRampings[1][i] = kth_root( d, k);
|
||||
gRightVolRampings[1][i] = kth_root(1.0 / d, k) * 65536.0;
|
||||
gLeftVolRampings[2][i] = kth_root( d, k + 1);
|
||||
gRightVolRampings[2][i] = kth_root(1.0 / d, k + 1) * 65536.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void reset_bank_and_seq_load_status(void) {
|
||||
s32 i;
|
||||
|
||||
@@ -67,7 +168,11 @@ void discard_bank(s32 bankId) {
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
struct Note *note = &gNotes[i];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (note->noteSubEu.bankId == bankId) {
|
||||
#else
|
||||
if (note->bankId == bankId) {
|
||||
#endif
|
||||
if (note->priority >= NOTE_PRIORITY_MIN) {
|
||||
note->parentLayer->enabled = FALSE;
|
||||
note->parentLayer->finished = TRUE;
|
||||
@@ -84,15 +189,35 @@ void discard_sequence(s32 seqId) {
|
||||
|
||||
for (i = 0; i < SEQUENCE_PLAYERS; i++) {
|
||||
if (gSequencePlayers[i].enabled && gSequencePlayers[i].seqId == seqId) {
|
||||
#ifdef VERSION_EU
|
||||
sequence_player_disable(&gSequencePlayers[i]);
|
||||
#else
|
||||
sequence_player_disable(gSequencePlayers + i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
|
||||
#ifdef VERSION_EU
|
||||
u8 *start;
|
||||
u8 *pos;
|
||||
u32 alignedSize = ALIGN16(size);
|
||||
|
||||
start = pool->cur;
|
||||
if (start + alignedSize <= pool->start + pool->size) {
|
||||
pool->cur += alignedSize;
|
||||
for (pos = start; pos < pool->cur; pos++) {
|
||||
*pos = 0;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
return start;
|
||||
#else
|
||||
u8 *start;
|
||||
s32 last;
|
||||
s32 i;
|
||||
u8 *start;
|
||||
|
||||
if ((pool->cur + ALIGN16(size) <= pool->size + pool->start)) {
|
||||
start = pool->cur;
|
||||
@@ -104,8 +229,8 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return start;
|
||||
#endif
|
||||
}
|
||||
|
||||
void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size) {
|
||||
@@ -125,7 +250,11 @@ void temporary_pool_clear(struct TemporaryPool *temporary) {
|
||||
temporary->pool.cur = temporary->pool.start;
|
||||
temporary->nextSide = 0;
|
||||
temporary->entries[0].ptr = temporary->pool.start;
|
||||
#ifdef VERSION_EU
|
||||
temporary->entries[1].ptr = temporary->pool.start + temporary->pool.size;
|
||||
#else
|
||||
temporary->entries[1].ptr = temporary->pool.size + temporary->pool.start;
|
||||
#endif
|
||||
temporary->entries[0].id = -1;
|
||||
temporary->entries[1].id = -1;
|
||||
}
|
||||
@@ -174,8 +303,14 @@ void temporary_pools_init(struct PoolSplit *a) {
|
||||
temporary_pool_clear(&gUnusedLoadedPool.temporary);
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
static void unused_803163D4() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/alloc_bank_or_seq.s")
|
||||
#else
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id) {
|
||||
@@ -332,10 +467,11 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/alloc_bank_or_seq.s")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id) {
|
||||
u32 i;
|
||||
void *ret;
|
||||
UNUSED void *ret;
|
||||
struct TemporaryPool *temporary = &arg0->temporary;
|
||||
|
||||
if (arg1 == 0) {
|
||||
@@ -357,19 +493,118 @@ void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id) {
|
||||
}
|
||||
|
||||
if (arg1 == 2) {
|
||||
#ifdef VERSION_EU
|
||||
return get_bank_or_seq(arg0, 0, id);
|
||||
#else
|
||||
// Prevent tail call optimization by using a temporary.
|
||||
// (Did they compile with -Wo,-notail?)
|
||||
ret = get_bank_or_seq(arg0, 0, id);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void func_eu_802e27e4_unused(f32 arg0, f32 arg1, u16 *arg2) {
|
||||
s32 i;
|
||||
f32 tmp[16];
|
||||
|
||||
tmp[0] = (f32) (arg1 * 262159.0f);
|
||||
tmp[8] = (f32) (arg0 * 262159.0f);
|
||||
tmp[1] = (f32) ((arg1 * arg0) * 262159.0f);
|
||||
tmp[9] = (f32) (((arg0 * arg0) + arg1) * 262159.0f);
|
||||
|
||||
for (i = 2; i < 8; i++) {
|
||||
//! @bug they probably meant to store the value to tmp[i] and tmp[8 + i]
|
||||
arg2[i] = arg1 * tmp[i - 2] + arg0 * tmp[i - 1];
|
||||
arg2[8 + i] = arg1 * tmp[6 + i] + arg0 * tmp[7 + i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
arg2[i] = tmp[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
}
|
||||
|
||||
for (i = 8; i < 16; i += 4) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void decrease_reverb_gain(void) {
|
||||
s32 i;
|
||||
for (i = 0; i < gNumSynthesisReverbs; i++) {
|
||||
gSynthesisReverbs[i].reverbGain -= gSynthesisReverbs[i].reverbGain / 8;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void decrease_reverb_gain(void) {
|
||||
gSynthesisReverb.reverbGain -= gSynthesisReverb.reverbGain / 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s32 func_eu_802E2AA0(void) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
switch (gAudioResetStatus) {
|
||||
case 5:
|
||||
for (i = 0; i < SEQUENCE_PLAYERS; i++) {
|
||||
sequence_player_disable(&gSequencePlayers[i]);
|
||||
}
|
||||
gAudioResetFadeOutFramesLeft = 4;
|
||||
gAudioResetStatus--;
|
||||
break;
|
||||
case 4:
|
||||
if (gAudioResetFadeOutFramesLeft != 0) {
|
||||
gAudioResetFadeOutFramesLeft--;
|
||||
decrease_reverb_gain();
|
||||
} else {
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
if (gNotes[i].noteSubEu.enabled && gNotes[i].adsr.state != ADSR_STATE_DISABLED) {
|
||||
gNotes[i].adsr.fadeOutVel = gAudioBufferParameters.updatesPerFrameInv;
|
||||
gNotes[i].adsr.action |= ADSR_ACTION_RELEASE;
|
||||
}
|
||||
}
|
||||
gAudioResetFadeOutFramesLeft = 16;
|
||||
gAudioResetStatus--;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (gAudioResetFadeOutFramesLeft != 0) {
|
||||
gAudioResetFadeOutFramesLeft--;
|
||||
decrease_reverb_gain();
|
||||
} else {
|
||||
for (i = 0; i < NUMAIBUFFERS; i++) {
|
||||
for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
|
||||
gAiBuffers[i][j] = 0;
|
||||
}
|
||||
}
|
||||
gAudioResetFadeOutFramesLeft = 4;
|
||||
gAudioResetStatus--;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (gAudioResetFadeOutFramesLeft != 0) {
|
||||
gAudioResetFadeOutFramesLeft--;
|
||||
} else {
|
||||
gAudioResetStatus--;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
audio_reset_session();
|
||||
gAudioResetStatus = 0;
|
||||
}
|
||||
if (gAudioResetStatus < 3) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Waits until a specified number of audio frames have been created
|
||||
*/
|
||||
@@ -380,21 +615,37 @@ void wait_for_audio_frames(s32 frames) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
s8 updatesPerFrame;
|
||||
#else
|
||||
void audio_reset_session(void) {
|
||||
// TODO: verify compilation again and try to match better
|
||||
struct AudioSessionSettingsEU *preset = &gAudioSessionPresets[gAudioResetPresetIdToLoad];
|
||||
struct ReverbSettingsEU *reverbSettings;
|
||||
#endif
|
||||
s16 *mem;
|
||||
#ifndef VERSION_EU
|
||||
s8 updatesPerFrame;
|
||||
s32 reverbWindowSize;
|
||||
s32 k;
|
||||
#endif
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 k;
|
||||
s32 persistentMem;
|
||||
s32 temporaryMem;
|
||||
s32 totalMem;
|
||||
s32 wantMisc;
|
||||
#ifndef VERSION_EU
|
||||
s32 frames;
|
||||
s32 remainingDmas;
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
struct SynthesisReverb *reverb;
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
decrease_reverb_gain();
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
@@ -445,13 +696,40 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
gCurrAudioFrameDmaCount = 0;
|
||||
|
||||
for (j = 0; j < NUMAIBUFFERS; j++) {
|
||||
for (k = 0; k < 0x500; k++) {
|
||||
for (k = 0; k < (s32) (AIBUFFER_LEN / sizeof(s16)); k++) {
|
||||
gAiBuffers[j][k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
gSampleDmaNumListItems = 0;
|
||||
#ifdef VERSION_EU
|
||||
gAudioBufferParameters.frequency = preset->frequency;
|
||||
gAudioBufferParameters.aiFrequency = osAiSetFrequency(gAudioBufferParameters.frequency);
|
||||
gAudioBufferParameters.samplesPerFrameTarget = ALIGN16(gAudioBufferParameters.frequency / gRefreshRate);
|
||||
gAudioBufferParameters.minAiBufferLength = gAudioBufferParameters.samplesPerFrameTarget - 0x10;
|
||||
gAudioBufferParameters.maxAiBufferLength = gAudioBufferParameters.samplesPerFrameTarget + 0x10;
|
||||
gAudioBufferParameters.updatesPerFrame = (gAudioBufferParameters.samplesPerFrameTarget + 0x10) / 160 + 1;
|
||||
gAudioBufferParameters.samplesPerUpdate = (gAudioBufferParameters.samplesPerFrameTarget / gAudioBufferParameters.updatesPerFrame) & 0xfff8;
|
||||
gAudioBufferParameters.samplesPerUpdateMax = gAudioBufferParameters.samplesPerUpdate + 8;
|
||||
gAudioBufferParameters.samplesPerUpdateMin = gAudioBufferParameters.samplesPerUpdate - 8;
|
||||
gAudioBufferParameters.resampleRate = 32000.0f / FLOAT_CAST(gAudioBufferParameters.frequency);
|
||||
gAudioBufferParameters.unkUpdatesPerFrameScaled = (3.0f / 1280.0f) / gAudioBufferParameters.updatesPerFrame;
|
||||
gAudioBufferParameters.updatesPerFrameInv = 1.0f / gAudioBufferParameters.updatesPerFrame;
|
||||
|
||||
gMaxSimultaneousNotes = preset->maxSimultaneousNotes;
|
||||
gVolume = preset->volume;
|
||||
gTempoInternalToExternal = (u32) (gAudioBufferParameters.updatesPerFrame * 2880000.0f / gTatumsPerBeat / D_EU_802298D0);
|
||||
|
||||
gAudioBufferParameters.presetUnk4 = preset->unk1;
|
||||
gAudioBufferParameters.samplesPerFrameTarget *= gAudioBufferParameters.presetUnk4;
|
||||
gAudioBufferParameters.maxAiBufferLength *= gAudioBufferParameters.presetUnk4;
|
||||
gAudioBufferParameters.minAiBufferLength *= gAudioBufferParameters.presetUnk4;
|
||||
gAudioBufferParameters.updatesPerFrame *= gAudioBufferParameters.presetUnk4;
|
||||
|
||||
gMaxAudioCmds = gMaxSimultaneousNotes * 0x10 * gAudioBufferParameters.updatesPerFrame + preset->numReverbs * 0x20 + 0x300;
|
||||
#else
|
||||
reverbWindowSize = preset->reverbWindowSize;
|
||||
gAiFrequency = osAiSetFrequency(preset->frequency);
|
||||
gMaxSimultaneousNotes = preset->maxSimultaneousNotes;
|
||||
@@ -492,10 +770,16 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
#else
|
||||
gTempoInternalToExternal = (u32)(updatesPerFrame * 2880000.0f / gTatumsPerBeat / 16.713f);
|
||||
#endif
|
||||
|
||||
gMaxAudioCmds = gMaxSimultaneousNotes * 20 * updatesPerFrame + 320;
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentSeqMem + preset->persistentBankMem);
|
||||
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporarySeqMem + preset->temporaryBankMem);
|
||||
#else
|
||||
persistentMem = DOUBLE_SIZE_ON_64_BIT(preset->persistentBankMem + preset->persistentSeqMem);
|
||||
temporaryMem = DOUBLE_SIZE_ON_64_BIT(preset->temporaryBankMem + preset->temporarySeqMem);
|
||||
#endif
|
||||
totalMem = persistentMem + temporaryMem;
|
||||
wantMisc = gAudioSessionPool.size - totalMem - 0x100;
|
||||
sSessionPoolSplit.wantSeq = wantMisc;
|
||||
@@ -514,14 +798,60 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
temporary_pools_init(&sTemporaryCommonPoolSplit);
|
||||
reset_bank_and_seq_load_status();
|
||||
|
||||
#ifndef VERSION_EU
|
||||
for (j = 0; j < 2; j++) {
|
||||
gAudioCmdBuffers[j] = soundAlloc(&gNotesAndBuffersPool, gMaxAudioCmds * sizeof(u64));
|
||||
}
|
||||
#endif
|
||||
|
||||
gNotes = soundAlloc(&gNotesAndBuffersPool, gMaxSimultaneousNotes * sizeof(struct Note));
|
||||
note_init_all();
|
||||
init_note_free_list();
|
||||
|
||||
#ifdef VERSION_EU
|
||||
gNoteSubsEu = soundAlloc(&gNotesAndBuffersPool, (gAudioBufferParameters.updatesPerFrame * gMaxSimultaneousNotes) * sizeof(struct NoteSubEu));
|
||||
|
||||
for (j = 0; j != 2; j++) {
|
||||
gAudioCmdBuffers[j] = soundAlloc(&gNotesAndBuffersPool, gMaxAudioCmds * sizeof(u64));
|
||||
}
|
||||
|
||||
for (j = 0; j < 4; j++) {
|
||||
gSynthesisReverbs[j].useReverb = 0;
|
||||
}
|
||||
gNumSynthesisReverbs = preset->numReverbs;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
reverb = &gSynthesisReverbs[j];
|
||||
reverbSettings = &preset->reverbSettings[j];
|
||||
reverb->windowSize = reverbSettings->windowSize * 64;
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
reverb->reverbGain = reverbSettings->gain;
|
||||
reverb->useReverb = 8;
|
||||
reverb->ringBuffer.left = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->ringBuffer.right = soundAlloc(&gNotesAndBuffersPool, reverb->windowSize * 2);
|
||||
reverb->nextRingBufferPos = 0;
|
||||
reverb->unkC = 0;
|
||||
reverb->curFrame = 0;
|
||||
reverb->bufSizePerChannel = reverb->windowSize;
|
||||
reverb->framesLeftToIgnore = 2;
|
||||
if (reverb->downsampleRate != 1) {
|
||||
reverb->resampleFlags = A_INIT;
|
||||
reverb->resampleRate = 0x8000 / reverb->downsampleRate;
|
||||
reverb->resampleStateLeft = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->resampleStateRight = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk24 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
reverb->unk28 = soundAlloc(&gNotesAndBuffersPool, 16 * sizeof(s16));
|
||||
for (i = 0; i < gAudioBufferParameters.updatesPerFrame; i++) {
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[0][i].toDownsampleLeft = mem;
|
||||
reverb->items[0][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
reverb->items[1][i].toDownsampleLeft = mem;
|
||||
reverb->items[1][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
if (reverbWindowSize == 0) {
|
||||
gSynthesisReverb.useReverb = 0;
|
||||
} else {
|
||||
@@ -544,17 +874,26 @@ void audio_reset_session(struct AudioSessionSettings *preset) {
|
||||
for (i = 0; i < gAudioUpdatesPerFrame; i++) {
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
gSynthesisReverb.items[0][i].toDownsampleLeft = mem;
|
||||
gSynthesisReverb.items[0][i].toDownsampleRight = mem + 0xA0;
|
||||
gSynthesisReverb.items[0][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
mem = soundAlloc(&gNotesAndBuffersPool, DEFAULT_LEN_2CH);
|
||||
gSynthesisReverb.items[1][i].toDownsampleLeft = mem;
|
||||
gSynthesisReverb.items[1][i].toDownsampleRight = mem + 0xA0;
|
||||
gSynthesisReverb.items[1][i].toDownsampleRight = mem + DEFAULT_LEN_1CH / sizeof(s16);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
init_sample_dma_buffers(gMaxSimultaneousNotes);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
func_eu_802e1cd0(0, gAudioBufferParameters.samplesPerUpdate);
|
||||
#endif
|
||||
|
||||
osWritebackDCacheAll();
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -55,11 +55,17 @@ extern struct SoundMultiPool gSeqLoadedPool;
|
||||
extern struct SoundMultiPool gBankLoadedPool;
|
||||
extern u8 gBankLoadStatus[64];
|
||||
extern u8 gSeqLoadStatus[256];
|
||||
extern volatile u8 gAudioResetStatus;
|
||||
extern u8 gAudioResetPresetIdToLoad;
|
||||
|
||||
void *soundAlloc(struct SoundAllocPool *pool, u32 size);
|
||||
void sound_init_main_pools(s32 sizeForAudioInitPool);
|
||||
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id);
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 arg2);
|
||||
#ifdef VERSION_EU
|
||||
void audio_reset_session(void);
|
||||
#else
|
||||
void audio_reset_session(struct AudioSessionSettings *preset);
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_MEMORY_H */
|
||||
+450
-3
@@ -8,8 +8,166 @@
|
||||
#include "playback.h"
|
||||
#include "synthesis.h"
|
||||
#include "effects.h"
|
||||
#include "external.h"
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb) {
|
||||
struct NoteSubEu *sub = ¬e->noteSubEu;
|
||||
f32 volRight, volLeft;
|
||||
u16 unkMask = ~0x80;
|
||||
|
||||
pan &= unkMask;
|
||||
if (sub->stereoHeadsetEffects && gSoundMode == SOUND_MODE_HEADSET) {
|
||||
s32 smallPanIndex = pan >> 3;
|
||||
if (smallPanIndex > 0xf) {
|
||||
smallPanIndex = 0xf;
|
||||
}
|
||||
|
||||
sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex];
|
||||
sub->headsetPanRight = gHeadsetPanQuantization[15 - smallPanIndex];
|
||||
sub->stereoStrongRight = FALSE;
|
||||
sub->stereoStrongLeft = FALSE;
|
||||
sub->usesHeadsetPanEffects = TRUE;
|
||||
|
||||
volLeft = gHeadsetPanVolume[pan];
|
||||
volRight = gHeadsetPanVolume[127 - pan];
|
||||
} else if (sub->stereoHeadsetEffects && gSoundMode == SOUND_MODE_STEREO) {
|
||||
u8 strongLeft = FALSE;
|
||||
u8 strongRight = FALSE;
|
||||
sub->headsetPanLeft = 0;
|
||||
sub->headsetPanRight = 0;
|
||||
sub->usesHeadsetPanEffects = FALSE;
|
||||
|
||||
volLeft = gStereoPanVolume[pan];
|
||||
volRight = gStereoPanVolume[127 - pan];
|
||||
if (pan < 0x20) {
|
||||
strongLeft = TRUE;
|
||||
} else if (pan > 0x60) {
|
||||
strongRight = TRUE;
|
||||
}
|
||||
|
||||
sub->stereoStrongRight = strongRight;
|
||||
sub->stereoStrongLeft = strongLeft;
|
||||
} else if (gSoundMode == SOUND_MODE_MONO) {
|
||||
volLeft = 0.707f;
|
||||
volRight = 0.707f;
|
||||
} else {
|
||||
volLeft = gDefaultPanVolume[pan];
|
||||
volRight = gDefaultPanVolume[127 - pan];
|
||||
}
|
||||
|
||||
velocity = MAX(0.0f, velocity);
|
||||
velocity = MIN(32767.f, velocity);
|
||||
|
||||
sub->targetVolLeft = ((s32) (velocity * volLeft) & 0xffff) >> 5;
|
||||
sub->targetVolRight = ((s32) (velocity * volRight) & 0xffff) >> 5;
|
||||
|
||||
if (sub->reverbVol != reverb) {
|
||||
sub->reverbVol = reverb;
|
||||
sub->envMixerNeedsInit = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sub->needsInit) {
|
||||
sub->envMixerNeedsInit = TRUE;
|
||||
} else {
|
||||
sub->envMixerNeedsInit = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void note_set_resampling_rate(struct Note *note, f32 resamplingRateInput) {
|
||||
f32 resamplingRate = 0.0f;
|
||||
struct NoteSubEu *tempSub = ¬e->noteSubEu;
|
||||
|
||||
if (resamplingRateInput < 0.0f) {
|
||||
resamplingRateInput = 0.0f;
|
||||
}
|
||||
if (resamplingRateInput < 2.0f) {
|
||||
tempSub->hasTwoAdpcmParts = 0;
|
||||
|
||||
if (1.99996f < resamplingRateInput) {
|
||||
resamplingRate = 1.99996f;
|
||||
} else {
|
||||
resamplingRate = resamplingRateInput;
|
||||
}
|
||||
|
||||
} else {
|
||||
tempSub->hasTwoAdpcmParts = 1;
|
||||
if (3.99992f < resamplingRateInput) {
|
||||
resamplingRate = 1.99996f;
|
||||
} else {
|
||||
resamplingRate = resamplingRateInput * 0.5f;
|
||||
}
|
||||
}
|
||||
note->noteSubEu.resamplingRateFixedPoint = (s32) (resamplingRate * 32768.0f);
|
||||
}
|
||||
|
||||
struct AudioBankSound *func_eu_802e4e5c(struct Instrument *instrument, s32 semitone) {
|
||||
struct AudioBankSound *sound;
|
||||
if (semitone < instrument->normalRangeLo) {
|
||||
sound = &instrument->lowNotesSound;
|
||||
} else if (semitone <= instrument->normalRangeHi) {
|
||||
sound = &instrument->normalNotesSound;
|
||||
} else {
|
||||
sound = &instrument->highNotesSound;
|
||||
}
|
||||
return sound;
|
||||
}
|
||||
|
||||
struct Instrument *func_eu_802e4e98(s32 bankId, s32 instId) {
|
||||
struct Instrument *inst;
|
||||
|
||||
if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) {
|
||||
gAudioErrorFlags = bankId + 0x10000000;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (instId >= gCtlEntries[bankId].numInstruments) {
|
||||
gAudioErrorFlags = ((bankId << 8) + instId) + 0x3000000;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inst = gCtlEntries[bankId].instruments[instId];
|
||||
if (inst == NULL) {
|
||||
gAudioErrorFlags = ((bankId << 8) + instId) + 0x1000000;
|
||||
return inst;
|
||||
}
|
||||
|
||||
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))) {
|
||||
return inst;
|
||||
}
|
||||
|
||||
gAudioErrorFlags = ((bankId << 8) + instId) + 0x2000000;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct Drum *func_eu_802e4fb8(s32 bankId, s32 drumId) {
|
||||
struct Drum *drum;
|
||||
if (drumId >= gCtlEntries[bankId].numDrums) {
|
||||
gAudioErrorFlags = ((bankId << 8) + drumId) + 0x4000000;
|
||||
return 0;
|
||||
}
|
||||
if ((uintptr_t) gCtlEntries[bankId].drums < 0x80000000U) {
|
||||
return 0;
|
||||
}
|
||||
drum = gCtlEntries[bankId].drums[drumId];
|
||||
if (drum == NULL) {
|
||||
gAudioErrorFlags = ((bankId << 8) + drumId) + 0x5000000;
|
||||
}
|
||||
return drum;
|
||||
}
|
||||
#endif // VERSION_EU
|
||||
|
||||
#ifdef VERSION_EU
|
||||
void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer);
|
||||
#else
|
||||
s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer);
|
||||
#endif
|
||||
|
||||
void note_init(struct Note *note) {
|
||||
if (note->parentLayer->adsr.releaseRate == 0) {
|
||||
@@ -18,24 +176,59 @@ void note_init(struct Note *note) {
|
||||
adsr_init(¬e->adsr, note->parentLayer->adsr.envelope, ¬e->adsrVolScale);
|
||||
}
|
||||
note->adsr.state = ADSR_STATE_INITIAL;
|
||||
#ifdef VERSION_EU
|
||||
note->noteSubEu = gDefaultNoteSub;
|
||||
#else
|
||||
note_init_volume(note);
|
||||
note_enable(note);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define note_disable2 note_disable
|
||||
void note_disable(struct Note *note) {
|
||||
if (note->noteSubEu.needsInit == TRUE) {
|
||||
note->noteSubEu.needsInit = FALSE;
|
||||
} else {
|
||||
note_set_vel_pan_reverb(note, 0, 0x40, 0);
|
||||
}
|
||||
note->priority = NOTE_PRIORITY_DISABLED;
|
||||
note->parentLayer = NO_LAYER;
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
note->noteSubEu.enabled = FALSE;
|
||||
note->noteSubEu.finished = FALSE;
|
||||
}
|
||||
#else
|
||||
void note_disable2(struct Note *note) {
|
||||
note_disable(note);
|
||||
}
|
||||
#endif // VERSION_EU
|
||||
|
||||
void process_notes(void) {
|
||||
f32 scale;
|
||||
f32 frequency;
|
||||
#ifndef VERSION_EU
|
||||
u8 reverb;
|
||||
#endif
|
||||
f32 velocity;
|
||||
#ifndef VERSION_EU
|
||||
f32 pan;
|
||||
f32 cap;
|
||||
#endif
|
||||
struct Note *note;
|
||||
#ifdef VERSION_EU
|
||||
struct NotePlaybackState *playbackState;
|
||||
struct NoteSubEu *noteSubEu;
|
||||
UNUSED u8 pad[12];
|
||||
u8 reverb;
|
||||
UNUSED u8 pad3;
|
||||
u8 pan;
|
||||
u8 unk;
|
||||
#endif
|
||||
struct NoteAttributes *attributes;
|
||||
#ifndef VERSION_EU
|
||||
struct AudioListItem *it;
|
||||
#endif
|
||||
s32 i;
|
||||
|
||||
// Macro versions of audio_list_push_front and audio_list_remove
|
||||
@@ -52,6 +245,100 @@ void process_notes(void) {
|
||||
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
note = &gNotes[i];
|
||||
#ifdef VERSION_EU
|
||||
playbackState = (struct NotePlaybackState *) ¬e->priority;
|
||||
if (note->parentLayer != NO_LAYER) {
|
||||
if ((uintptr_t) playbackState->parentLayer < 0x7fffffffU) {
|
||||
continue;
|
||||
}
|
||||
if (!playbackState->parentLayer->enabled && playbackState->priority >= NOTE_PRIORITY_MIN) {
|
||||
goto c;
|
||||
} else if (playbackState->parentLayer->seqChannel->seqPlayer == NULL) {
|
||||
sequence_channel_disable(playbackState->parentLayer->seqChannel);
|
||||
playbackState->priority = NOTE_PRIORITY_STOPPING;
|
||||
continue;
|
||||
} else if (playbackState->parentLayer->seqChannel->seqPlayer->muted) {
|
||||
if ((playbackState->parentLayer->seqChannel->muteBehavior
|
||||
& (MUTE_BEHAVIOR_STOP_SCRIPT | MUTE_BEHAVIOR_STOP_NOTES))) {
|
||||
goto c;
|
||||
}
|
||||
}
|
||||
goto d;
|
||||
if (1) {
|
||||
c:
|
||||
seq_channel_layer_note_release(playbackState->parentLayer);
|
||||
audio_list_remove(¬e->listItem);
|
||||
audio_list_push_front(¬e->listItem.pool->decaying, ¬e->listItem);
|
||||
playbackState->priority = NOTE_PRIORITY_STOPPING;
|
||||
}
|
||||
} else if (playbackState->priority >= NOTE_PRIORITY_MIN) {
|
||||
continue;
|
||||
}
|
||||
d:
|
||||
if (playbackState->priority != NOTE_PRIORITY_DISABLED) {
|
||||
noteSubEu = ¬e->noteSubEu;
|
||||
if (playbackState->priority == NOTE_PRIORITY_STOPPING || noteSubEu->finished) {
|
||||
if (playbackState->adsr.state == ADSR_STATE_DISABLED || noteSubEu->finished) {
|
||||
if (playbackState->wantedParentLayer != NO_LAYER) {
|
||||
note_disable(note);
|
||||
if (playbackState->wantedParentLayer->seqChannel != NULL) {
|
||||
note_init_for_layer(note, playbackState->wantedParentLayer);
|
||||
note_vibrato_init(note);
|
||||
audio_list_remove(¬e->listItem);
|
||||
audio_list_push_back(¬e->listItem.pool->active, ¬e->listItem);
|
||||
playbackState->wantedParentLayer = NO_LAYER;
|
||||
// don't skip
|
||||
} else {
|
||||
note_disable(note);
|
||||
audio_list_remove(¬e->listItem);
|
||||
audio_list_push_back(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
playbackState->wantedParentLayer = NO_LAYER;
|
||||
goto skip;
|
||||
}
|
||||
} else {
|
||||
note_disable(note);
|
||||
audio_list_remove(¬e->listItem);
|
||||
audio_list_push_back(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
if (1) {
|
||||
}
|
||||
} else if (playbackState->adsr.state == ADSR_STATE_DISABLED) {
|
||||
note_disable(note);
|
||||
audio_list_remove(¬e->listItem);
|
||||
audio_list_push_back(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
goto skip;
|
||||
}
|
||||
|
||||
scale = adsr_update(&playbackState->adsr);
|
||||
note_vibrato_update(note);
|
||||
attributes = &playbackState->attributes;
|
||||
if (playbackState->priority == NOTE_PRIORITY_STOPPING) {
|
||||
frequency = attributes->freqScale;
|
||||
velocity = attributes->velocity;
|
||||
pan = attributes->pan;
|
||||
reverb = attributes->reverb;
|
||||
if (1) {
|
||||
}
|
||||
unk = noteSubEu->unk1b234;
|
||||
} else {
|
||||
frequency = playbackState->parentLayer->noteFreqScale;
|
||||
velocity = playbackState->parentLayer->noteVelocity;
|
||||
pan = playbackState->parentLayer->notePan;
|
||||
reverb = playbackState->parentLayer->seqChannel->reverb;
|
||||
unk = playbackState->parentLayer->seqChannel->unk8 & 0x7; // bitfield?
|
||||
}
|
||||
|
||||
frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
|
||||
frequency *= gAudioBufferParameters.resampleRate;
|
||||
velocity = velocity * scale * scale;
|
||||
note_set_resampling_rate(note, frequency);
|
||||
note_set_vel_pan_reverb(note, velocity, pan, reverb);
|
||||
noteSubEu->unk1b234 = unk;
|
||||
skip:;
|
||||
}
|
||||
#else
|
||||
if (note->priority != NOTE_PRIORITY_DISABLED) {
|
||||
if (note->priority == NOTE_PRIORITY_STOPPING || note->finished) {
|
||||
if (note->adsrVolScale == 0 || note->finished) {
|
||||
@@ -116,6 +403,7 @@ void process_notes(void) {
|
||||
note_set_vel_pan_reverb(note, velocity, pan, reverb);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#undef PREPEND
|
||||
#undef POP
|
||||
@@ -132,15 +420,23 @@ void seq_channel_layer_decay_release_internal(struct SequenceChannelLayer *seqLa
|
||||
note = seqLayer->note;
|
||||
attributes = ¬e->attributes;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (seqLayer->seqChannel != NULL && seqLayer->seqChannel->noteAllocPolicy == 0) {
|
||||
seqLayer->note = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (note->wantedParentLayer == seqLayer) {
|
||||
note->wantedParentLayer = NO_LAYER;
|
||||
}
|
||||
|
||||
if (note->parentLayer != seqLayer) {
|
||||
#ifdef VERSION_EU
|
||||
if (note->parentLayer == NO_LAYER && note->wantedParentLayer == NO_LAYER && note->prevParentLayer == seqLayer && target != ADSR_STATE_DECAY) {
|
||||
note->adsr.fadeOutVel = gAudioBufferParameters.updatesPerFrameInv;
|
||||
note->adsr.action |= ADSR_ACTION_RELEASE;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,16 +452,29 @@ void seq_channel_layer_decay_release_internal(struct SequenceChannelLayer *seqLa
|
||||
note->prevParentLayer = note->parentLayer;
|
||||
note->parentLayer = NO_LAYER;
|
||||
if (target == ADSR_STATE_RELEASE) {
|
||||
#ifdef VERSION_EU
|
||||
note->adsr.fadeOutVel = gAudioBufferParameters.updatesPerFrameInv;
|
||||
#else
|
||||
note->adsr.fadeOutVel = 0x8000 / gAudioUpdatesPerFrame;
|
||||
#endif
|
||||
note->adsr.action |= ADSR_ACTION_RELEASE;
|
||||
} else {
|
||||
note->adsr.action |= ADSR_ACTION_DECAY;
|
||||
#ifdef VERSION_EU
|
||||
if (seqLayer->adsr.releaseRate == 0) {
|
||||
note->adsr.fadeOutVel = seqLayer->seqChannel->adsr.releaseRate * gAudioBufferParameters.unkUpdatesPerFrameScaled;
|
||||
} else {
|
||||
note->adsr.fadeOutVel = seqLayer->adsr.releaseRate * gAudioBufferParameters.unkUpdatesPerFrameScaled;
|
||||
}
|
||||
note->adsr.sustain = (FLOAT_CAST(seqLayer->seqChannel->adsr.sustain) * note->adsr.current) / 256.0f;
|
||||
#else
|
||||
if (seqLayer->adsr.releaseRate == 0) {
|
||||
note->adsr.fadeOutVel = seqLayer->seqChannel->adsr.releaseRate * 24;
|
||||
} else {
|
||||
note->adsr.fadeOutVel = seqLayer->adsr.releaseRate * 24;
|
||||
}
|
||||
note->adsr.sustain = (note->adsr.current * seqLayer->seqChannel->adsr.sustain) / 0x10000;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +492,43 @@ void seq_channel_layer_note_release(struct SequenceChannelLayer *seqLayer) {
|
||||
seq_channel_layer_decay_release_internal(seqLayer, ADSR_STATE_RELEASE);
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERSION_EU
|
||||
s32 build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer, s32 waveId) {
|
||||
f32 freqScale;
|
||||
f32 ratio;
|
||||
u8 sampleCountIndex;
|
||||
|
||||
if (waveId < 128) {
|
||||
waveId = 128;
|
||||
}
|
||||
|
||||
freqScale = seqLayer->freqScale;
|
||||
if (seqLayer->portamento.mode != 0 && 0.0f < seqLayer->portamento.extent) {
|
||||
freqScale *= (seqLayer->portamento.extent + 1.0f);
|
||||
}
|
||||
if (freqScale < 1.0f) {
|
||||
sampleCountIndex = 0;
|
||||
ratio = 1.0465f;
|
||||
} else if (freqScale < 2.0f) {
|
||||
sampleCountIndex = 1;
|
||||
ratio = 0.52325f;
|
||||
} else if (freqScale < 4.0f) {
|
||||
sampleCountIndex = 2;
|
||||
ratio = 0.26263f;
|
||||
} else {
|
||||
sampleCountIndex = 3;
|
||||
ratio = 0.13081f;
|
||||
}
|
||||
seqLayer->freqScale *= ratio;
|
||||
note->waveId = waveId;
|
||||
note->sampleCountIndex = sampleCountIndex;
|
||||
|
||||
note->noteSubEu.sound.samples = &gWaveSamples[waveId - 128][sampleCountIndex * 64];
|
||||
|
||||
return sampleCountIndex;
|
||||
}
|
||||
#else
|
||||
void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
@@ -237,8 +583,20 @@ void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLay
|
||||
|
||||
osWritebackDCache(note->synthesisBuffers->samples, sizeof(note->synthesisBuffers->samples));
|
||||
}
|
||||
#endif
|
||||
|
||||
void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
#ifdef VERSION_EU
|
||||
s32 sampleCountIndex;
|
||||
s32 waveSampleCountIndex;
|
||||
s32 waveId = seqLayer->euUnk1;
|
||||
if (waveId == 0xff) {
|
||||
waveId = seqLayer->seqChannel->instOrWave;
|
||||
}
|
||||
sampleCountIndex = note->sampleCountIndex;
|
||||
waveSampleCountIndex = build_synthetic_wave(note, seqLayer, waveId);
|
||||
note->synthesisState.samplePosInt = note->synthesisState.samplePosInt * euUnknownData_8030194c[waveSampleCountIndex] / euUnknownData_8030194c[sampleCountIndex];
|
||||
#else
|
||||
s32 sampleCount = note->sampleCount;
|
||||
build_synthetic_wave(note, seqLayer);
|
||||
if (sampleCount != 0) {
|
||||
@@ -246,6 +604,7 @@ void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLaye
|
||||
} else {
|
||||
note->samplePosInt = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void init_note_list(struct AudioListItem *list) {
|
||||
@@ -281,7 +640,7 @@ void note_pool_clear(struct NotePool *pool) {
|
||||
struct AudioListItem *source;
|
||||
struct AudioListItem *cur;
|
||||
struct AudioListItem *dest;
|
||||
s32 j;
|
||||
UNUSED s32 j; // unused in EU
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
switch (i) {
|
||||
@@ -306,6 +665,16 @@ void note_pool_clear(struct NotePool *pool) {
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
for (;;) {
|
||||
cur = source->next;
|
||||
if (cur == source || cur == NULL) {
|
||||
break;
|
||||
}
|
||||
audio_list_remove(cur);
|
||||
audio_list_push_back(dest, cur);
|
||||
}
|
||||
#else
|
||||
j = 0;
|
||||
do {
|
||||
cur = source->next;
|
||||
@@ -316,6 +685,7 @@ void note_pool_clear(struct NotePool *pool) {
|
||||
audio_list_push_back(dest, cur);
|
||||
j++;
|
||||
} while (j <= gMaxSimultaneousNotes);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,14 +772,60 @@ struct Note *pop_node_with_value_less_equal(struct AudioListItem *list, s32 limi
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (best == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (limit <= ((struct Note *) best->u.value)->priority) {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
if (limit < ((struct Note *) best->u.value)->priority) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
audio_list_remove(best);
|
||||
return best->u.value;
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
UNUSED s32 pad[4];
|
||||
s16 instId;
|
||||
struct NoteSubEu *sub = ¬e->noteSubEu;
|
||||
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
note->parentLayer = seqLayer;
|
||||
note->priority = seqLayer->seqChannel->notePriority;
|
||||
seqLayer->unkEu0b4 = TRUE;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded"
|
||||
seqLayer->note = note;
|
||||
seqLayer->seqChannel->noteUnused = note;
|
||||
seqLayer->seqChannel->layerUnused = seqLayer;
|
||||
seqLayer->noteVelocity = 0.0f;
|
||||
note_init(note);
|
||||
instId = seqLayer->euUnk1;
|
||||
if (instId == 0xff) {
|
||||
instId = seqLayer->seqChannel->instOrWave;
|
||||
}
|
||||
sub->sound.audioBankSound = seqLayer->sound;
|
||||
|
||||
if (instId >= 0x80) {
|
||||
sub->isSyntheticWave = TRUE;
|
||||
} else {
|
||||
sub->isSyntheticWave = FALSE;
|
||||
}
|
||||
|
||||
if (sub->isSyntheticWave) {
|
||||
build_synthetic_wave(note, seqLayer, instId);
|
||||
}
|
||||
sub->bankId = seqLayer->seqChannel->bankId;
|
||||
sub->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects;
|
||||
sub->unk1b567 = seqLayer->seqChannel->reverbIndex & 3;
|
||||
}
|
||||
#else
|
||||
s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
note->parentLayer = seqLayer;
|
||||
@@ -431,6 +847,7 @@ s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer
|
||||
note_init(note);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void func_80319728(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
seq_channel_layer_note_release(note->parentLayer);
|
||||
@@ -440,18 +857,25 @@ void func_80319728(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
void note_release_and_take_ownership(struct Note *note, struct SequenceChannelLayer *seqLayer) {
|
||||
note->wantedParentLayer = seqLayer;
|
||||
note->priority = NOTE_PRIORITY_STOPPING;
|
||||
#ifdef VERSION_EU
|
||||
note->adsr.fadeOutVel = gAudioBufferParameters.updatesPerFrameInv;
|
||||
#else
|
||||
note->adsr.fadeOutVel = 0x8000 / gAudioUpdatesPerFrame;
|
||||
#endif
|
||||
note->adsr.action |= ADSR_ACTION_RELEASE;
|
||||
}
|
||||
|
||||
struct Note *alloc_note_from_disabled(struct NotePool *pool, struct SequenceChannelLayer *seqLayer) {
|
||||
struct Note *note = audio_list_pop_back(&pool->disabled);
|
||||
if (note != NULL) {
|
||||
#ifdef VERSION_EU
|
||||
note_init_for_layer(note, seqLayer);
|
||||
#else
|
||||
if (note_init_for_layer(note, seqLayer) == TRUE) {
|
||||
audio_list_push_front(&gNoteFreeLists.disabled, ¬e->listItem);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
audio_list_push_front(&pool->active, ¬e->listItem);
|
||||
}
|
||||
return note;
|
||||
@@ -482,10 +906,18 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
|
||||
if (policy & NOTE_ALLOC_LAYER) {
|
||||
ret = seqLayer->note;
|
||||
if (ret != NULL && ret->prevParentLayer == seqLayer) {
|
||||
if (ret != NULL && ret->prevParentLayer == seqLayer
|
||||
#ifdef VERSION_EU
|
||||
&& ret->wantedParentLayer == NO_LAYER
|
||||
#endif
|
||||
) {
|
||||
note_release_and_take_ownership(ret, seqLayer);
|
||||
audio_list_remove(&ret->listItem);
|
||||
#ifdef VERSION_EU
|
||||
audio_list_push_back(&ret->listItem.pool->releasing, &ret->listItem);
|
||||
#else
|
||||
audio_list_push_back(&gNoteFreeLists.releasing, &ret->listItem);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -538,6 +970,7 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
void reclaim_notes(void) {
|
||||
struct Note *note;
|
||||
s32 i;
|
||||
@@ -574,6 +1007,8 @@ void reclaim_notes(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void note_init_all(void) {
|
||||
struct Note *note;
|
||||
@@ -581,14 +1016,21 @@ void note_init_all(void) {
|
||||
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
note = &gNotes[i];
|
||||
#ifdef VERSION_EU
|
||||
note->noteSubEu = gZeroNoteSub;
|
||||
#else
|
||||
note->enabled = FALSE;
|
||||
note->stereoStrongRight = FALSE;
|
||||
note->stereoStrongLeft = FALSE;
|
||||
note->stereoHeadsetEffects = FALSE;
|
||||
#endif
|
||||
note->priority = NOTE_PRIORITY_DISABLED;
|
||||
note->parentLayer = NO_LAYER;
|
||||
note->wantedParentLayer = NO_LAYER;
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
#ifdef VERSION_EU
|
||||
note->waveId = 0;
|
||||
#else
|
||||
note->reverb = 0;
|
||||
note->usesHeadsetPanEffects = FALSE;
|
||||
note->sampleCount = 0;
|
||||
@@ -597,6 +1039,7 @@ void note_init_all(void) {
|
||||
note->targetVolRight = 0;
|
||||
note->frequency = 0.0f;
|
||||
note->unused1 = 0x3f;
|
||||
#endif
|
||||
note->attributes.velocity = 0.0f;
|
||||
note->adsrVolScale = 0;
|
||||
note->adsr.state = ADSR_STATE_DISABLED;
|
||||
@@ -604,6 +1047,10 @@ void note_init_all(void) {
|
||||
note->vibratoState.active = FALSE;
|
||||
note->portamento.cur = 0.0f;
|
||||
note->portamento.speed = 0.0f;
|
||||
#ifdef VERSION_EU
|
||||
note->synthesisState.synthesisBuffers = soundAlloc(&gNotesAndBuffersPool, sizeof(struct NoteSynthesisBuffers));
|
||||
#else
|
||||
note->synthesisBuffers = soundAlloc(&gNotesAndBuffersPool, sizeof(struct NoteSynthesisBuffers));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,15 @@ struct Note *alloc_note(struct SequenceChannelLayer *seqLayer);
|
||||
void reclaim_notes(void);
|
||||
void note_init_all(void);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct AudioBankSound *func_eu_802e4e5c(struct Instrument *instrument, s32 semitone);
|
||||
struct Drum *func_eu_802e4fb8(s32 bankId, s32 drumId);
|
||||
void note_init_volume(struct Note *note);
|
||||
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb);
|
||||
void note_set_frequency(struct Note *note, f32 frequency);
|
||||
void note_enable(struct Note *note);
|
||||
void note_disable(struct Note *note);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _AUDIO_PLAYBACK_H */
|
||||
@@ -0,0 +1,326 @@
|
||||
#include <ultra64.h>
|
||||
#include "internal.h"
|
||||
#include "load.h"
|
||||
#include "data.h"
|
||||
#include "seqplayer.h"
|
||||
#include "synthesis.h"
|
||||
|
||||
#ifdef VERSION_EU
|
||||
|
||||
#ifdef __sgi
|
||||
#define stubbed_printf
|
||||
#else
|
||||
#define stubbed_printf(...)
|
||||
#endif
|
||||
|
||||
#define SAMPLES_TO_OVERPRODUCE 0x10
|
||||
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x40
|
||||
|
||||
#ifdef VERSION_JP
|
||||
typedef u16 FadeT;
|
||||
#else
|
||||
typedef s32 FadeT;
|
||||
#endif
|
||||
|
||||
extern volatile u8 gAudioResetStatus;
|
||||
extern u8 gAudioResetPresetIdToLoad;
|
||||
extern OSMesgQueue *OSMesgQueues[];
|
||||
extern struct EuAudioCmd sAudioCmd[0x100];
|
||||
|
||||
void func_8031D690(s32 player, FadeT fadeInTime);
|
||||
void sequence_player_fade_out_internal(s32 player, FadeT fadeOutTime);
|
||||
void func_802ad668(void);
|
||||
void decrease_sample_dma_ttls(void);
|
||||
s32 func_eu_802E2AA0(void);
|
||||
void func_802ad7ec(u32);
|
||||
|
||||
struct SPTask *create_next_audio_frame_task(void) {
|
||||
u32 samplesRemainingInAI;
|
||||
s32 writtenCmds;
|
||||
s32 index;
|
||||
OSTask_t *task;
|
||||
s32 flags;
|
||||
u16 *currAiBuffer;
|
||||
s32 oldDmaCount;
|
||||
OSMesg sp30;
|
||||
OSMesg sp2C;
|
||||
|
||||
gAudioFrameCount++;
|
||||
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0) {
|
||||
stubbed_printf("DAC:Lost 1 Frame.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
osSendMesg(OSMesgQueues[0], (OSMesg) gAudioFrameCount, 0);
|
||||
|
||||
gAudioTaskIndex ^= 1;
|
||||
gCurrAiBufferIndex++;
|
||||
gCurrAiBufferIndex %= NUMAIBUFFERS;
|
||||
index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS;
|
||||
samplesRemainingInAI = osAiGetLength() / 4;
|
||||
|
||||
if (gAiBufferLengths[index] != 0) {
|
||||
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
|
||||
}
|
||||
|
||||
oldDmaCount = gCurrAudioFrameDmaCount;
|
||||
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) {
|
||||
stubbed_printf("DMA: Request queue over.( %d )\n", oldDmaCount);
|
||||
}
|
||||
gCurrAudioFrameDmaCount = 0;
|
||||
|
||||
decrease_sample_dma_ttls();
|
||||
if (osRecvMesg(OSMesgQueues[2], &sp30, 0) != -1) {
|
||||
gAudioResetPresetIdToLoad = (u8) (s32) sp30;
|
||||
gAudioResetStatus = 5;
|
||||
}
|
||||
|
||||
if (gAudioResetStatus != 0) {
|
||||
if (func_eu_802E2AA0() == 0) {
|
||||
if (gAudioResetStatus == 0) {
|
||||
osSendMesg(OSMesgQueues[3], (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gAudioTask = &gAudioTasks[gAudioTaskIndex];
|
||||
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
|
||||
index = gCurrAiBufferIndex;
|
||||
currAiBuffer = gAiBuffers[index];
|
||||
|
||||
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI +
|
||||
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE;
|
||||
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
|
||||
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
|
||||
}
|
||||
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
|
||||
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
|
||||
}
|
||||
|
||||
if (osRecvMesg(OSMesgQueues[1], &sp2C, OS_MESG_NOBLOCK) != -1) {
|
||||
func_802ad7ec((u32) sp2C);
|
||||
}
|
||||
|
||||
flags = 0;
|
||||
gAudioCmd = synthesis_execute(gAudioCmd, &writtenCmds, currAiBuffer, gAiBufferLengths[index]);
|
||||
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
|
||||
gAudioRandom = gAudioRandom + writtenCmds / 8;
|
||||
|
||||
index = gAudioTaskIndex;
|
||||
gAudioTask->msgqueue = NULL;
|
||||
gAudioTask->msg = NULL;
|
||||
|
||||
task = &gAudioTask->task.t;
|
||||
task->type = M_AUDTASK;
|
||||
task->flags = flags;
|
||||
task->ucode_boot = rspF3DBootStart;
|
||||
task->ucode_boot_size = (u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart;
|
||||
task->ucode = rspAspMainStart;
|
||||
task->ucode_data = rspAspMainDataStart;
|
||||
task->ucode_size = 0x800; // (this size is ignored)
|
||||
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
|
||||
task->dram_stack = NULL;
|
||||
task->dram_stack_size = 0;
|
||||
task->output_buff = NULL;
|
||||
task->output_buff_size = NULL;
|
||||
task->data_ptr = gAudioCmdBuffers[index];
|
||||
task->data_size = writtenCmds * sizeof(u64);
|
||||
task->yield_data_ptr = NULL;
|
||||
task->yield_data_size = 0;
|
||||
return gAudioTask;
|
||||
}
|
||||
|
||||
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
|
||||
s32 i;
|
||||
|
||||
switch (cmd->u.s.op) {
|
||||
case 0x81:
|
||||
preload_sequence(cmd->u.s.arg2, 3);
|
||||
break;
|
||||
|
||||
case 0x82:
|
||||
case 0x88:
|
||||
// load_sequence(arg1, arg2, 0);
|
||||
load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3);
|
||||
func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32);
|
||||
break;
|
||||
|
||||
case 0x83:
|
||||
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) {
|
||||
if (cmd->u2.as_s32 == 0) {
|
||||
sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]);
|
||||
}
|
||||
else {
|
||||
sequence_player_fade_out_internal(cmd->u.s.arg1, cmd->u2.as_s32);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xf0:
|
||||
gSoundMode = cmd->u2.as_s32;
|
||||
break;
|
||||
|
||||
case 0xf1:
|
||||
for (i = 0; i < 4; i++) {
|
||||
gSequencePlayers[i].muted = TRUE;
|
||||
gSequencePlayers[i].unk_eu = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xf2:
|
||||
for (i = 0; i < 4; i++) {
|
||||
gSequencePlayers[i].muted = FALSE;
|
||||
gSequencePlayers[i].unk_eu = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const char undefportcmd[] = "Undefined Port Command %d\n";
|
||||
|
||||
extern OSMesgQueue *OSMesgQueues[];
|
||||
extern u8 D_EU_80302010;
|
||||
extern u8 D_EU_80302014;
|
||||
extern OSMesg OSMesg0;
|
||||
extern OSMesg OSMesg1;
|
||||
extern OSMesg OSMesg2;
|
||||
extern OSMesg OSMesg3;
|
||||
|
||||
void sequence_player_fade_out_internal(s32 player, FadeT fadeOutTime) {
|
||||
if (fadeOutTime == 0) {
|
||||
fadeOutTime = 1;
|
||||
}
|
||||
gSequencePlayers[player].fadeVelocity = -(gSequencePlayers[player].fadeVolume / fadeOutTime);
|
||||
gSequencePlayers[player].state = 2;
|
||||
gSequencePlayers[player].fadeTimer = fadeOutTime;
|
||||
|
||||
}
|
||||
|
||||
void func_8031D690(s32 player, FadeT fadeInTime) {
|
||||
if (fadeInTime != 0) {
|
||||
gSequencePlayers[player].state = 1;
|
||||
gSequencePlayers[player].fadeTimerUnkEu = fadeInTime;
|
||||
gSequencePlayers[player].fadeTimer = fadeInTime;
|
||||
gSequencePlayers[player].fadeVolume = 0.0f;
|
||||
gSequencePlayers[player].fadeVelocity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void func_802ad668(void) {
|
||||
D_EU_80302010 = 0;
|
||||
D_EU_80302014 = 0;
|
||||
osCreateMesgQueue(OSMesgQueues[0], &OSMesg0, 1);
|
||||
osCreateMesgQueue(OSMesgQueues[1], &OSMesg1, 4);
|
||||
osCreateMesgQueue(OSMesgQueues[2], &OSMesg2, 1);
|
||||
osCreateMesgQueue(OSMesgQueues[3], &OSMesg3, 1);
|
||||
}
|
||||
|
||||
void func_802ad6f0(s32 arg0, s32 *arg1) {
|
||||
struct EuAudioCmd *cmd = &sAudioCmd[D_EU_80302010 & 0xff];
|
||||
cmd->u.first = arg0;
|
||||
cmd->u2.as_u32 = *arg1;
|
||||
D_EU_80302010++;
|
||||
}
|
||||
|
||||
void func_802ad728(u32 arg0, f32 arg1) {
|
||||
func_802ad6f0(arg0, (s32*) &arg1);
|
||||
}
|
||||
|
||||
void func_802ad74c(u32 arg0, u32 arg1) {
|
||||
func_802ad6f0(arg0, (s32*) &arg1);
|
||||
}
|
||||
|
||||
void func_802ad770(u32 arg0, s8 arg1) {
|
||||
s32 sp1C = arg1 << 24;
|
||||
func_802ad6f0(arg0, &sp1C);
|
||||
}
|
||||
|
||||
void func_802ad7a0(void) {
|
||||
osSendMesg(OSMesgQueues[1],
|
||||
(OSMesg)(u32)((D_EU_80302014 & 0xff) << 8 | (D_EU_80302010 & 0xff)),
|
||||
OS_MESG_NOBLOCK);
|
||||
D_EU_80302014 = D_EU_80302010;
|
||||
}
|
||||
|
||||
void func_802ad7ec(u32 arg0) {
|
||||
struct EuAudioCmd *cmd;
|
||||
struct SequencePlayer *seqPlayer;
|
||||
struct SequenceChannel *chan;
|
||||
u8 end = arg0 & 0xff;
|
||||
u8 i = (arg0 >> 8) & 0xff;
|
||||
|
||||
for (;;) {
|
||||
if (i == end) break;
|
||||
cmd = &sAudioCmd[i++ & 0xff];
|
||||
|
||||
if (cmd->u.s.arg1 < SEQUENCE_PLAYERS) {
|
||||
seqPlayer = &gSequencePlayers[cmd->u.s.arg1];
|
||||
if ((cmd->u.s.op & 0x80) != 0) {
|
||||
eu_process_audio_cmd(cmd);
|
||||
}
|
||||
else if ((cmd->u.s.op & 0x40) != 0) {
|
||||
switch (cmd->u.s.op) {
|
||||
case 0x41:
|
||||
seqPlayer->unkEu28 = cmd->u2.as_f32;
|
||||
seqPlayer->unk_eu = TRUE;
|
||||
break;
|
||||
|
||||
case 0x47:
|
||||
seqPlayer->tempo = cmd->u2.as_s32 * TATUMS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case 0x48:
|
||||
seqPlayer->transposition = cmd->u2.as_s8;
|
||||
break;
|
||||
|
||||
case 0x46:
|
||||
seqPlayer->seqVariationEu[cmd->u.s.arg3] = cmd->u2.as_s8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) {
|
||||
chan = seqPlayer->channels[cmd->u.s.arg2];
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(chan))
|
||||
{
|
||||
switch (cmd->u.s.op) {
|
||||
case 1:
|
||||
chan->volumeScale = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
break;
|
||||
case 2:
|
||||
chan->volume = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b40 = TRUE;
|
||||
break;
|
||||
case 3:
|
||||
chan->unk9 = cmd->u2.as_s8;
|
||||
chan->unk1.as_bitfields.unk0b20 = TRUE;
|
||||
break;
|
||||
case 4:
|
||||
chan->freqScale = cmd->u2.as_f32;
|
||||
chan->unk1.as_bitfields.unk0b80 = TRUE;
|
||||
break;
|
||||
case 5:
|
||||
chan->reverb = cmd->u2.as_s8;
|
||||
break;
|
||||
case 6:
|
||||
if (cmd->u.s.arg3 < 8) {
|
||||
chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
chan->stopSomething2 = cmd->u2.as_s8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmd->u.s.op = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void func_802ada64(void) {
|
||||
func_802ad668();
|
||||
}
|
||||
|
||||
#endif
|
||||
+644
-12
File diff suppressed because it is too large.
Load diff
+661
-13
@@ -8,6 +8,7 @@
|
||||
#include "seqplayer.h"
|
||||
#include "external.h"
|
||||
|
||||
|
||||
#define DMEM_ADDR_TEMP 0x0
|
||||
#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x180
|
||||
#define DMEM_ADDR_ADPCM_RESAMPLED 0x20
|
||||
@@ -35,9 +36,6 @@
|
||||
|
||||
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
|
||||
|
||||
struct SynthesisReverb gSynthesisReverb;
|
||||
u8 sAudioSynthesisPad[0x20];
|
||||
|
||||
struct VolumeChange {
|
||||
u16 sourceLeft;
|
||||
u16 sourceRight;
|
||||
@@ -46,6 +44,13 @@ struct VolumeChange {
|
||||
};
|
||||
|
||||
u64 *synthesis_do_one_audio_update(u16 *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 *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);
|
||||
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 *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);
|
||||
@@ -54,7 +59,89 @@ u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32
|
||||
u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf,
|
||||
s32 headsetPanSettings, struct VolumeChange *vol);
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32 flags, s32 leftRight);
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
struct SynthesisReverb gSynthesisReverbs[4];
|
||||
u8 sAudioSynthesisPad[0x10];
|
||||
s16 gVolume;
|
||||
s8 gUseReverb;
|
||||
s8 gNumSynthesisReverbs;
|
||||
struct NoteSubEu *gNoteSubsEu;
|
||||
f32 gLeftVolRampings[3][1024];
|
||||
f32 gRightVolRampings[3][1024];
|
||||
f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above
|
||||
f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above
|
||||
#else
|
||||
struct SynthesisReverb gSynthesisReverb;
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
u8 sAudioSynthesisPad[0x20];
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/prepare_reverb_ring_buffer.s")
|
||||
#else
|
||||
// Equivalent functionality as the US/JP version,
|
||||
// just that the reverb structure is chosen from an array with index
|
||||
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) {
|
||||
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
|
||||
struct ReverbRingBufferItem *item;
|
||||
s32 srcPos;
|
||||
s32 dstPos;
|
||||
s32 nSamples;
|
||||
//s32 numSamplesAfterDownsampling;
|
||||
s32 excessiveSamples;
|
||||
if (reverb->downsampleRate != 1) {
|
||||
if (reverb->framesLeftToIgnore == 0) {
|
||||
// Now that the RSP has finished, downsample the samples produced two frames ago by skipping
|
||||
// samples.
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
|
||||
// Touches both left and right since they are adjacent in memory
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
|
||||
for (srcPos = 0, dstPos = 0; dstPos < item->lengths[0] / 2;
|
||||
srcPos += reverb->downsampleRate, dstPos++) {
|
||||
reverb->ringBuffer.left[dstPos + item->startPos] =
|
||||
item->toDownsampleLeft[srcPos];
|
||||
reverb->ringBuffer.right[dstPos + item->startPos] =
|
||||
item->toDownsampleRight[srcPos];
|
||||
}
|
||||
for (dstPos = 0; dstPos < item->lengths[1] / 2; srcPos += reverb->downsampleRate, dstPos++) {
|
||||
reverb->ringBuffer.left[dstPos] = item->toDownsampleLeft[srcPos];
|
||||
reverb->ringBuffer.right[dstPos] = item->toDownsampleRight[srcPos];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//numSamplesAfterDownsampling =
|
||||
nSamples = chunkLen / reverb->downsampleRate;
|
||||
excessiveSamples =
|
||||
(nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
if (excessiveSamples < 0) {
|
||||
// There is space in the ring buffer before it wraps around
|
||||
item->lengths[0] = nSamples * 2;
|
||||
item->lengths[1] = 0;
|
||||
item->startPos = (s32) reverb->nextRingBufferPos;
|
||||
reverb->nextRingBufferPos += nSamples;
|
||||
} else {
|
||||
// Ring buffer wrapped around
|
||||
//nSamples = numSamplesAfterDownsampling - excessiveSamples;
|
||||
item->lengths[0] = (nSamples - excessiveSamples) * 2;
|
||||
item->lengths[1] = excessiveSamples * 2;
|
||||
item->startPos = reverb->nextRingBufferPos;
|
||||
reverb->nextRingBufferPos = excessiveSamples;
|
||||
}
|
||||
// These fields are never read later
|
||||
item->numSamplesAfterDownsampling = nSamples;
|
||||
item->chunkLen = chunkLen;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex) {
|
||||
struct ReverbRingBufferItem *item;
|
||||
s32 srcPos;
|
||||
@@ -107,7 +194,50 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex) {
|
||||
item->numSamplesAfterDownsampling = numSamplesAfterDownsampling;
|
||||
item->chunkLen = chunkLen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 len, s32 reverbIndex) {
|
||||
// aSetBuffer, aLoadBuffer, aSetBuffer, aLoadBuffer
|
||||
aSetBuffer(cmd++, 0, addr, 0, len);
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[srcOffset]));
|
||||
|
||||
aSetBuffer(cmd++, 0, addr + DEFAULT_LEN_1CH, 0, len);
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[srcOffset]));
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
u64 *synthesis_save_reverb_ring_buffer(u64 *cmd, u16 addr, u16 destOffset, s32 len, s32 reverbIndex) {
|
||||
aSetBuffer(cmd++, 0, 0, addr, len);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[destOffset]));
|
||||
|
||||
aSetBuffer(cmd++, 0, 0, addr + DEFAULT_LEN_1CH, len);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[destOffset]));
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void synthesis_load_note_subs_eu(s32 updateIndex) {
|
||||
struct NoteSubEu *src;
|
||||
struct NoteSubEu *dest;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
src = &gNotes[i].noteSubEu;
|
||||
dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
|
||||
if (src->enabled) {
|
||||
*dest = *src;
|
||||
src->needsInit = 0;
|
||||
} else {
|
||||
dest->enabled = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
s32 get_volume_ramping(u16 sourceVol, u16 targetVol, s32 arg2) {
|
||||
// This roughly computes 2^16 * (targetVol / sourceVol) ^ (8 / arg2),
|
||||
// but with discretizations of targetVol, sourceVol and arg2.
|
||||
@@ -128,7 +258,77 @@ s32 get_volume_ramping(u16 sourceVol, u16 targetVol, s32 arg2) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_execute.s")
|
||||
#else
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
s32 nextVolRampTable;
|
||||
s32 temp;
|
||||
s32 i;
|
||||
s32 remaining;
|
||||
f32 *leftVolRamp;
|
||||
f32 *rightVolRamp;
|
||||
s32 chunkLen;
|
||||
s32 j;
|
||||
u32 *aiBufPtr;
|
||||
u64 *cmd = cmdBuf;
|
||||
|
||||
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
process_sequences(i - 1);
|
||||
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i);
|
||||
}
|
||||
aSegment(cmd++, 0, 0);
|
||||
remaining = bufLen;
|
||||
aiBufPtr = (u32 *) aiBuf;
|
||||
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
if (i == 1) {
|
||||
leftVolRamp = gLeftVolRampings[nextVolRampTable];
|
||||
rightVolRamp = gRightVolRampings[nextVolRampTable];
|
||||
chunkLen = remaining;
|
||||
} else {
|
||||
temp = remaining / i;
|
||||
if (temp >= gAudioBufferParameters.samplesPerUpdateMax) {
|
||||
leftVolRamp = gLeftVolRampings[2];
|
||||
rightVolRamp = gRightVolRampings[2];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMax;
|
||||
nextVolRampTable = 2;
|
||||
} else if (temp <= gAudioBufferParameters.samplesPerUpdateMin) {
|
||||
leftVolRamp = gLeftVolRampings[0];
|
||||
rightVolRamp = gRightVolRampings[0];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdateMin;
|
||||
nextVolRampTable = 0;
|
||||
} else {
|
||||
leftVolRamp = gLeftVolRampings[1];
|
||||
rightVolRamp = gRightVolRampings[1];
|
||||
chunkLen = gAudioBufferParameters.samplesPerUpdate;
|
||||
nextVolRampTable = 1;
|
||||
}
|
||||
}
|
||||
gCurrentLeftVolRamping = leftVolRamp;
|
||||
gCurrentRightVolRamping = rightVolRamp;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
if (gSynthesisReverbs[j].useReverb != 0) {
|
||||
prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j);
|
||||
}
|
||||
}
|
||||
cmd = synthesis_do_one_audio_update((u16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
|
||||
remaining -= chunkLen;
|
||||
aiBufPtr += chunkLen;
|
||||
}
|
||||
for (i = 0; i < gNumSynthesisReverbs; i++) {
|
||||
if (gSynthesisReverbs[i].framesLeftToIgnore != 0) {
|
||||
gSynthesisReverbs[i].framesLeftToIgnore--;
|
||||
}
|
||||
gSynthesisReverbs[i].curFrame ^= 1;
|
||||
}
|
||||
*writtenCmds = cmd - cmdBuf;
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
// bufLen will be divisible by 16
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
s32 chunkLen;
|
||||
@@ -168,7 +368,176 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *aiBuf, s32 bufLen) {
|
||||
*writtenCmds = cmd - cmdBuf;
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_resample_and_mix_reverb.s")
|
||||
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex);
|
||||
#else
|
||||
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex) {
|
||||
struct ReverbRingBufferItem *item; // sp5C
|
||||
s16 temp_t9; // sp5a
|
||||
s16 sp58; // sp58
|
||||
struct SynthesisReverb *reverb;
|
||||
|
||||
reverb = &gSynthesisReverbs[reverbIndex];
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
|
||||
aClearBuffer(cmd++, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
if (reverb->downsampleRate == 1) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengths[0], reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengths[0], 0, item->lengths[1], reverbIndex);
|
||||
}
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, 0x7fff, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + reverb->reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
} else {
|
||||
temp_t9 = (item->startPos & 7) * 2;
|
||||
sp58 = ALIGN(temp_t9 + item->lengths[0], 4);
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, 0x20, (item->startPos - temp_t9 / 2), DEFAULT_LEN_1CH, reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
cmd = synthesis_load_reverb_ring_buffer(cmd, 0x20 + sp58, 0, DEFAULT_LEN_1CH - sp58, reverbIndex);
|
||||
}
|
||||
|
||||
aSetBuffer(cmd++, 0, temp_t9 + DMEM_ADDR_ADPCM_RESAMPLED, DMEM_ADDR_WET_LEFT_CH, bufLen * 2);
|
||||
aResample(cmd++, reverb->resampleFlags, reverb->resampleRate, VIRTUAL_TO_PHYSICAL2(reverb->resampleStateLeft));
|
||||
|
||||
aSetBuffer(cmd++, 0, temp_t9 + DMEM_ADDR_ADPCM_RESAMPLED2, DMEM_ADDR_WET_RIGHT_CH, bufLen * 2);
|
||||
aResample(cmd++, reverb->resampleFlags, reverb->resampleRate, VIRTUAL_TO_PHYSICAL2(reverb->resampleStateRight));
|
||||
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, 0x7fff, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH);
|
||||
aMix(cmd++, 0, 0x8000 + reverb->reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH);
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/func_eu_802e00d8.s")
|
||||
u64 *func_eu_802e00d8(u64 *cmd, s16 reverbIndex, s16 updateIndex);
|
||||
#else
|
||||
u64 *func_eu_802e00d8(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
|
||||
struct SynthesisReverb *reverb;
|
||||
struct ReverbRingBufferItem *item;
|
||||
|
||||
reverb = &gSynthesisReverbs[reverbIndex];
|
||||
item = &reverb->items[reverb->curFrame][updateIndex];
|
||||
if (reverb->useReverb != 0) {
|
||||
if (reverb->downsampleRate == 1) {
|
||||
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengths[0], reverbIndex);
|
||||
if (item->lengths[1] != 0) {
|
||||
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengths[0], 0, item->lengths[1], reverbIndex);
|
||||
}
|
||||
} else {
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(reverb->items[reverb->curFrame][updateIndex].toDownsampleLeft));
|
||||
reverb->resampleFlags = 0;
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#ifndef NON_MATCHING
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_do_one_audio_update.s")
|
||||
#else
|
||||
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
|
||||
u8 sp84[60];
|
||||
struct SynthesisReverb *sp60;
|
||||
s32 temp_lo;
|
||||
s32 temp_lo_2;
|
||||
u8 temp_v1;
|
||||
u8 temp_v1_2;
|
||||
struct NoteSubEu *temp_t5;
|
||||
struct NoteSubEu *temp_v0;
|
||||
s32 phi_s1;
|
||||
s16 phi_s2;
|
||||
s16 phi_s3;
|
||||
s32 phi_s1_2;
|
||||
s32 phi_v1_2;
|
||||
s32 phi_s1_3;
|
||||
s16 phi_s3_2;
|
||||
s32 phi_s1_4;
|
||||
u8 *phi_s0_2;
|
||||
s32 bufLen2;
|
||||
|
||||
if (gNumSynthesisReverbs == 0) {
|
||||
phi_s2 = 0;
|
||||
for (phi_s1 = 0; phi_s1 < gMaxSimultaneousNotes; phi_s1++) {
|
||||
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + phi_s1].enabled) {
|
||||
sp84[phi_s2++] = phi_s1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
phi_s2 = 0;
|
||||
for (phi_s3 = 0; phi_s3 < gNumSynthesisReverbs; phi_s3++) {
|
||||
for (phi_s1_2 = 0; phi_s1_2 < gMaxSimultaneousNotes; phi_s1_2++) {
|
||||
temp_v0 = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + phi_s1_2];
|
||||
if (temp_v0->enabled) {
|
||||
if (phi_s3 == temp_v0->unk1b567) {
|
||||
sp84[phi_s2++] = phi_s1_2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
phi_v1_2 = gMaxSimultaneousNotes * updateIndex;
|
||||
for (phi_s1_3 = 0; phi_s1_3 < gMaxSimultaneousNotes; phi_s1_3++) {
|
||||
if (gNoteSubsEu[phi_v1_2].enabled) {
|
||||
if (temp_v0->unk1b567 >= gNumSynthesisReverbs) {
|
||||
sp84[phi_s2++] = phi_s1_3;
|
||||
}
|
||||
}
|
||||
phi_v1_2++;
|
||||
}
|
||||
}
|
||||
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
phi_s1_4 = 0;
|
||||
for (phi_s3_2 = 0; phi_s3_2 < gNumSynthesisReverbs; phi_s3_2++) {
|
||||
sp60 = &gSynthesisReverbs[phi_s3_2];
|
||||
gUseReverb = sp60->useReverb;
|
||||
if (gUseReverb != 0) {
|
||||
cmd = synthesis_resample_and_mix_reverb(cmd, bufLen, phi_s3_2, (s16) updateIndex);
|
||||
}
|
||||
for (; phi_s1_4 < phi_s2; phi_s1_4++) {
|
||||
temp_v1 = sp84[phi_s1_4];
|
||||
temp_lo = updateIndex * gMaxSimultaneousNotes;
|
||||
if (phi_s3_2 == gNoteSubsEu[temp_v1 + temp_lo].unk1b567) {
|
||||
cmd = synthesis_process_note(&gNotes[temp_v1], &gNoteSubsEu[temp_v1 + temp_lo], &gNotes[temp_v1].synthesisState, aiBuf, bufLen, cmd);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sp60->useReverb != 0) {
|
||||
cmd = func_eu_802e00d8(cmd, phi_s3_2, (s16) updateIndex);
|
||||
}
|
||||
}
|
||||
phi_s0_2 = &sp84[phi_s1_4];
|
||||
for (; phi_s1_4 < phi_s2; phi_s1_4++) {
|
||||
temp_v1_2 = *phi_s0_2;
|
||||
temp_lo_2 = updateIndex * gMaxSimultaneousNotes;
|
||||
temp_t5 = &gNoteSubsEu[temp_v1_2 + temp_lo_2];
|
||||
if (IS_BANK_LOAD_COMPLETE(temp_t5->bankId) == TRUE) {
|
||||
cmd = synthesis_process_note(&gNotes[temp_v1_2], &gNoteSubsEu[temp_v1_2 + temp_lo_2], &gNotes[temp_v1_2].synthesisState, aiBuf, bufLen, cmd);
|
||||
} else {
|
||||
gAudioErrorFlags = (temp_t5->bankId + (phi_s1_4 << 8)) + 0x10000000;
|
||||
}
|
||||
phi_s0_2++;
|
||||
}
|
||||
bufLen2 = bufLen * 2;
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, bufLen2);
|
||||
aInterleave(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH);
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, bufLen2 * 2);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(aiBuf));
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateIndex) {
|
||||
UNUSED s32 pad1[1];
|
||||
s16 ra;
|
||||
@@ -241,11 +610,17 @@ u64 *synthesis_do_one_audio_update(u16 *aiBuf, s32 bufLen, u64 *cmd, u32 updateI
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
#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) {
|
||||
#else
|
||||
u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
s32 noteIndex; // sp174
|
||||
struct Note *note; // s7
|
||||
#endif
|
||||
struct AudioBankSample *audioBookSample; // sp164
|
||||
struct AdpcmLoop *loopInfo; // sp160
|
||||
s16 *curLoadedBook; // sp15C
|
||||
@@ -284,28 +659,56 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
u32 samplesLenFixedPoint; // v1_1
|
||||
s32 nSamplesInThisIteration; // v1_2
|
||||
u32 a3;
|
||||
#ifndef VERSION_EU
|
||||
s32 t9;
|
||||
#endif
|
||||
u8 *v0_2;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
f32 resamplingRate; // f12
|
||||
#endif
|
||||
UNUSED s32 temp;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
curLoadedBook = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef VERSION_EU
|
||||
for (noteIndex = 0, curLoadedBook = NULL; noteIndex < gMaxSimultaneousNotes; noteIndex++) {
|
||||
note = &gNotes[noteIndex];
|
||||
if (IS_BANK_LOAD_COMPLETE(note->bankId) == FALSE) {
|
||||
gAudioErrorFlags = (note->bankId << 8) + noteIndex + 0x1000000;
|
||||
} else if (note->enabled) {
|
||||
#else
|
||||
if (noteSubEu->enabled) {
|
||||
#endif
|
||||
// This matches much much better if enabled is volatile... but that
|
||||
// breaks other functions (e.g. note_enable). Can we achieve the
|
||||
// volatile effect in some other way?
|
||||
flags = 0;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->needsInit == TRUE) {
|
||||
#else
|
||||
if (note->needsInit == TRUE) {
|
||||
#endif
|
||||
flags = A_INIT;
|
||||
#ifndef VERSION_EU
|
||||
note->samplePosInt = 0;
|
||||
note->samplePosFrac = 0;
|
||||
#else
|
||||
synthesisState->restart = FALSE;
|
||||
synthesisState->samplePosInt = 0;
|
||||
synthesisState->samplePosFrac = 0;
|
||||
synthesisState->curVolLeft = 1;
|
||||
synthesisState->curVolRight = 1;
|
||||
synthesisState->prevHeadsetPanRight = 0;
|
||||
synthesisState->prevHeadsetPanLeft = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (note->frequency < US_FLOAT(2.0)) {
|
||||
nParts = 1;
|
||||
if (note->frequency > US_FLOAT(1.99996)) {
|
||||
@@ -324,7 +727,21 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
resamplingRateFixedPoint = (u16)(s32)(resamplingRate * 32768.0f);
|
||||
samplesLenFixedPoint = note->samplePosFrac + (resamplingRateFixedPoint * bufLen) * 2;
|
||||
note->samplePosFrac = samplesLenFixedPoint; // 16-bit store, can't reuse
|
||||
#else
|
||||
resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint;
|
||||
nParts = noteSubEu->hasTwoAdpcmParts + 1;
|
||||
samplesLenFixedPoint = synthesisState->samplePosFrac + (resamplingRateFixedPoint * bufLen) * 2;
|
||||
synthesisState->samplePosFrac = samplesLenFixedPoint;
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->isSyntheticWave) {
|
||||
noteSamplesDmemAddrBeforeResampling =
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + synthesisState->samplePosInt * 2;
|
||||
synthesisState->samplePosInt += (samplesLenFixedPoint >> 10);
|
||||
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, samplesLenFixedPoint >> 10);
|
||||
}
|
||||
#else
|
||||
if (note->sound == NULL) {
|
||||
// A wave synthesis note (not ADPCM)
|
||||
// samplesLenFixedPoint >> 0x10 stored in s0
|
||||
@@ -333,10 +750,16 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + note->samplePosInt * 2;
|
||||
note->samplePosInt += (samplesLenFixedPoint >> 0x10);
|
||||
flags = 0;
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
// ADPCM note
|
||||
|
||||
#ifdef VERSION_EU
|
||||
audioBookSample = noteSubEu->sound.audioBankSound->sample;
|
||||
#else
|
||||
audioBookSample = note->sound->sample;
|
||||
#endif
|
||||
|
||||
// sp58 is a low-numbered register, so possibly a temporary.
|
||||
// Should it be used for samplesLenFixedPoint >> 0x10 above as well? But then
|
||||
@@ -378,6 +801,12 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
aLoadADPCM(cmd++, nEntries * 16, VIRTUAL_TO_PHYSICAL2(curLoadedBook));
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->unk1b234) {
|
||||
curLoadedBook = (s16 *) &euUnknownData_80301950; // what's this? never read
|
||||
}
|
||||
#endif
|
||||
|
||||
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
|
||||
s32 samplesRemaining; // v1
|
||||
s32 s0;
|
||||
@@ -385,12 +814,23 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
noteFinished = FALSE;
|
||||
restart = FALSE;
|
||||
nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed;
|
||||
#ifdef VERSION_EU
|
||||
s2 = synthesisState->samplePosInt & 0xf;
|
||||
samplesRemaining = endPos - synthesisState->samplePosInt;
|
||||
#else
|
||||
s2 = note->samplePosInt & 0xf;
|
||||
samplesRemaining = endPos - note->samplePosInt;
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (s2 == 0 && !synthesisState->restart) {
|
||||
s2 = 16;
|
||||
}
|
||||
#else
|
||||
if (s2 == 0 && !note->restart) {
|
||||
s2 = 16;
|
||||
}
|
||||
#endif
|
||||
s6 = 16 - s2; // a1
|
||||
|
||||
if (nSamplesToProcess < samplesRemaining) {
|
||||
@@ -419,9 +859,20 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
|
||||
if (t0 != 0) {
|
||||
// maybe keep a var for t0 * 9?
|
||||
#ifdef VERSION_EU
|
||||
if (audioBookSample->loaded == 0x81) {
|
||||
v0_2 = sampleAddr + (synthesisState->samplePosInt - s2 + 0x10) / 16 * 9;
|
||||
} else {
|
||||
v0_2 = dma_sample_data(
|
||||
(uintptr_t) (sampleAddr + (synthesisState->samplePosInt - s2 + 0x10) / 16 * 9),
|
||||
t0 * 9, flags, &synthesisState->sampleDmaIndex);
|
||||
a3 = (u32)((uintptr_t) v0_2 & 0xf);
|
||||
}
|
||||
#else
|
||||
v0_2 = dma_sample_data(
|
||||
(uintptr_t) (sampleAddr + (note->samplePosInt - s2 + 0x10) / 16 * 9),
|
||||
t0 * 9, flags, ¬e->sampleDmaIndex);
|
||||
#endif
|
||||
a3 = (u32)((uintptr_t) v0_2 & 0xf);
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA, 0, t0 * 9 + a3);
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(v0_2 - a3));
|
||||
@@ -430,6 +881,28 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
a3 = 0;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (synthesisState->restart != FALSE) {
|
||||
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
|
||||
flags = A_LOOP; // = 2
|
||||
synthesisState->restart = FALSE;
|
||||
}
|
||||
|
||||
if (nAdpcmSamplesProcessed == 0) {
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA + a3,
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE, s0 * 2);
|
||||
aADPCMdec(cmd++, flags,
|
||||
VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
sp130 = s2 * 2;
|
||||
} else {
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_COMPRESSED_ADPCM_DATA + a3,
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + ALIGN(s5, 5), s0 * 2);
|
||||
aADPCMdec(cmd++, flags,
|
||||
VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
|
||||
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + ALIGN(s5, 5) + (s2 * 2),
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (s0 + s6_2 - s3) * 2);
|
||||
}
|
||||
#else
|
||||
if (note->restart != FALSE) {
|
||||
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
|
||||
flags = A_LOOP; // = 2
|
||||
@@ -450,6 +923,7 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + ALIGN(s5, 5) + (s2 * 2),
|
||||
DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (s0 + s6_2 - s3) * 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
nAdpcmSamplesProcessed = nAdpcmSamplesProcessed + s0 + s6_2 - s3;
|
||||
nSamplesInThisIteration = s0 + s6_2 - s3;
|
||||
@@ -476,17 +950,32 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
if (noteFinished) {
|
||||
aClearBuffer(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5,
|
||||
(samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
|
||||
#ifdef VERSION_EU
|
||||
noteSubEu->finished = 1;
|
||||
noteSubEu->finished = 1;
|
||||
noteSubEu->enabled = 0;
|
||||
#else
|
||||
note->samplePosInt = 0;
|
||||
note->finished = 1;
|
||||
note->enabled = 0;
|
||||
#endif
|
||||
break; // goto? doesn't matter, though
|
||||
}
|
||||
#ifdef VERSION_EU
|
||||
if (restart) {
|
||||
synthesisState->restart = TRUE;
|
||||
synthesisState->samplePosInt = loopInfo->start;
|
||||
} else {
|
||||
synthesisState->samplePosInt += nSamplesToProcess;
|
||||
}
|
||||
#else
|
||||
if (restart) {
|
||||
note->restart = TRUE;
|
||||
note->samplePosInt = loopInfo->start;
|
||||
} else {
|
||||
note->samplePosInt += nSamplesToProcess;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (nParts) {
|
||||
@@ -499,14 +988,24 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
case 0:
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_UNCOMPRESSED_NOTE + sp130,
|
||||
DMEM_ADDR_ADPCM_RESAMPLED, samplesLenAdjusted + 4);
|
||||
#ifdef VERSION_EU
|
||||
aResample(cmd++, A_INIT, 0xff60,
|
||||
VIRTUAL_TO_PHYSICAL2(
|
||||
synthesisState->synthesisBuffers->dummyResampleState));
|
||||
#else
|
||||
aResample(cmd++, A_INIT, 0xff60,
|
||||
VIRTUAL_TO_PHYSICAL2(
|
||||
note->synthesisBuffers->dummyResampleState));
|
||||
#endif
|
||||
resampledTempLen = samplesLenAdjusted + 4;
|
||||
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_ADPCM_RESAMPLED + 4;
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->finished != 0) {
|
||||
#else
|
||||
if (note->finished != 0) {
|
||||
#endif
|
||||
aClearBuffer(cmd++,
|
||||
DMEM_ADDR_ADPCM_RESAMPLED + samplesLenAdjusted + 4,
|
||||
DMEM_ADDR_ADPCM_RESAMPLED + resampledTempLen,
|
||||
samplesLenAdjusted + 0x10);
|
||||
}
|
||||
break;
|
||||
@@ -514,9 +1013,15 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
case 1:
|
||||
aSetBuffer(cmd++, 0, DMEM_ADDR_UNCOMPRESSED_NOTE + sp130,
|
||||
DMEM_ADDR_ADPCM_RESAMPLED2, samplesLenAdjusted + 8);
|
||||
#ifdef VERSION_EU
|
||||
aResample(cmd++, A_INIT, 0xff60,
|
||||
VIRTUAL_TO_PHYSICAL2(
|
||||
synthesisState->synthesisBuffers->dummyResampleState));
|
||||
#else
|
||||
aResample(cmd++, A_INIT, 0xff60,
|
||||
VIRTUAL_TO_PHYSICAL2(
|
||||
note->synthesisBuffers->dummyResampleState));
|
||||
#endif
|
||||
aDMEMMove(cmd++, DMEM_ADDR_ADPCM_RESAMPLED2 + 4,
|
||||
DMEM_ADDR_ADPCM_RESAMPLED + resampledTempLen,
|
||||
samplesLenAdjusted + 4);
|
||||
@@ -524,7 +1029,11 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->finished != 0) {
|
||||
#else
|
||||
if (note->finished != 0) {
|
||||
#endif
|
||||
// ("break;" doesn't match)
|
||||
flags = 0;
|
||||
goto out;
|
||||
@@ -535,6 +1044,12 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
}
|
||||
out:
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->needsInit == TRUE) {
|
||||
flags = A_INIT;
|
||||
noteSubEu->needsInit = FALSE;
|
||||
}
|
||||
#else
|
||||
if (note->needsInit == TRUE) {
|
||||
flags = A_INIT;
|
||||
note->needsInit = FALSE;
|
||||
@@ -542,20 +1057,42 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
|
||||
cmd = final_resample(cmd, note, bufLen * 2, resamplingRateFixedPoint,
|
||||
noteSamplesDmemAddrBeforeResampling, flags);
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
if (note->headsetPanRight != 0 || note->prevHeadsetPanRight != 0) {
|
||||
s0 = 1;
|
||||
} else if (note->headsetPanLeft != 0 || note->prevHeadsetPanLeft != 0) {
|
||||
s0 = 2;
|
||||
#else
|
||||
if (note->noteSubEu.headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0) {
|
||||
s0 = 1;
|
||||
} else if (note->noteSubEu.headsetPanLeft != 0 || synthesisState->prevHeadsetPanLeft != 0) {
|
||||
s0 = 2;
|
||||
#endif
|
||||
} else {
|
||||
s0 = 0;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
cmd = final_resample(cmd, synthesisState, bufLen * 2, resamplingRateFixedPoint,
|
||||
noteSamplesDmemAddrBeforeResampling, flags);
|
||||
cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, 0, s0);
|
||||
#else
|
||||
cmd = process_envelope(cmd, note, bufLen, 0, s0, flags);
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->usesHeadsetPanEffects) {
|
||||
cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, bufLen * 2, flags, s0);
|
||||
}
|
||||
#else
|
||||
if (note->usesHeadsetPanEffects) {
|
||||
cmd = note_apply_headset_pan_effects(cmd, note, bufLen * 2, flags, s0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef VERSION_EU
|
||||
}
|
||||
|
||||
t9 = bufLen * 2;
|
||||
@@ -564,20 +1101,44 @@ u64 *synthesis_process_notes(u16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
t9 *= 2;
|
||||
aSetBuffer(cmd++, 0, 0, DMEM_ADDR_TEMP, t9);
|
||||
aSaveBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(aiBuf));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
#elif defined(VERSION_JP)
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_jp.s")
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_us.s")
|
||||
#endif
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#elif defined(VERSION_JP)
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_jp.s")
|
||||
#elif defined(VERSION_US)
|
||||
GLOBAL_ASM("asm/non_matchings/synthesis_process_notes_us.s")
|
||||
#elif defined(VERSION_EU)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/synthesis_process_note.s")
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) {
|
||||
s32 a3;
|
||||
s32 i;
|
||||
s32 repeats;
|
||||
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0, /*count*/ 128);
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples));
|
||||
synthesisState->samplePosInt &= 0x3f;
|
||||
a3 = 64 - synthesisState->samplePosInt;
|
||||
if (a3 < nSamplesToLoad) {
|
||||
repeats = (nSamplesToLoad - a3 + 63) / 64;
|
||||
for (i = 0; i < repeats; i++) {
|
||||
aDMEMMove(cmd++,
|
||||
/*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE,
|
||||
/*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + (1 + i) * 128,
|
||||
/*count*/ 128);
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#else
|
||||
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) {
|
||||
s32 a3;
|
||||
s32 i;
|
||||
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0,
|
||||
/*count*/ sizeof(note->synthesisBuffers->samples)); // interesting that it's 128...
|
||||
/*count*/ sizeof(note->synthesisBuffers->samples));
|
||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->samples));
|
||||
note->samplePosInt = (note->sampleCount - 1) & note->samplePosInt;
|
||||
a3 = 64 - note->samplePosInt;
|
||||
@@ -592,13 +1153,23 @@ u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) {
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags) {
|
||||
aSetBuffer(cmd++, /*flags*/ 0, dmemIn, /*dmemout*/ 0, count);
|
||||
aResample(cmd++, flags, pitch, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->finalResampleState));
|
||||
return cmd;
|
||||
}
|
||||
#else
|
||||
u64 *final_resample(u64 *cmd, struct Note *note, s32 count, u16 pitch, u16 dmemIn, u32 flags) {
|
||||
aSetBuffer(cmd++, /*flags*/ 0, dmemIn, /*dmemout*/ 0, count);
|
||||
aResample(cmd++, flags, pitch, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->finalResampleState));
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings,
|
||||
UNUSED u32 flags) {
|
||||
UNUSED u8 pad[16];
|
||||
@@ -618,6 +1189,31 @@ u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf
|
||||
u8 mixerFlags;
|
||||
UNUSED u8 pad2[8];
|
||||
s32 rampLeft, rampRight;
|
||||
#else
|
||||
u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings) {
|
||||
UNUSED u8 pad1[20];
|
||||
u16 sourceRight;
|
||||
u16 sourceLeft;
|
||||
UNUSED u8 pad2[4];
|
||||
u16 targetLeft;
|
||||
u16 targetRight;
|
||||
s32 mixerFlags;
|
||||
s32 rampLeft;
|
||||
s32 rampRight;
|
||||
|
||||
sourceLeft = synthesisState->curVolLeft;
|
||||
sourceRight = synthesisState->curVolRight;
|
||||
targetLeft = (note->targetVolLeft << 5);
|
||||
targetRight = (note->targetVolRight << 5);
|
||||
if (targetLeft == 0) {
|
||||
targetLeft++;
|
||||
}
|
||||
if (targetRight == 0) {
|
||||
targetRight++;
|
||||
}
|
||||
synthesisState->curVolLeft = targetLeft;
|
||||
synthesisState->curVolRight = targetRight;
|
||||
#endif
|
||||
|
||||
// For aEnvMixer, five buffers and count are set using aSetBuffer.
|
||||
// in, dry left, count without A_AUX flag.
|
||||
@@ -663,24 +1259,49 @@ u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (targetLeft == sourceLeft && targetRight == sourceRight && !note->envMixerNeedsInit) {
|
||||
#else
|
||||
if (vol->sourceLeft == vol->targetLeft && vol->sourceRight == vol->targetRight
|
||||
&& !note->envMixerNeedsInit) {
|
||||
#endif
|
||||
mixerFlags = A_CONTINUE;
|
||||
} else {
|
||||
mixerFlags = A_INIT;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
rampLeft = gCurrentLeftVolRamping[targetLeft >> 5] * gCurrentRightVolRamping[sourceLeft >> 5];
|
||||
rampRight = gCurrentLeftVolRamping[targetRight >> 5] * gCurrentRightVolRamping[sourceRight >> 5];
|
||||
#else
|
||||
rampLeft = get_volume_ramping(vol->sourceLeft, vol->targetLeft, nSamples);
|
||||
rampRight = get_volume_ramping(vol->sourceRight, vol->targetRight, nSamples);
|
||||
#endif
|
||||
|
||||
// The operation's parameters change meanings depending on flags
|
||||
#ifdef VERSION_EU
|
||||
aSetVolume(cmd++, A_VOL | A_LEFT, sourceLeft, 0, 0);
|
||||
aSetVolume(cmd++, A_VOL | A_RIGHT, sourceRight, 0, 0);
|
||||
aSetVolume32(cmd++, A_RATE | A_LEFT, targetLeft, rampLeft);
|
||||
aSetVolume32(cmd++, A_RATE | A_RIGHT, targetRight, rampRight);
|
||||
aSetVolume(cmd++, A_AUX, gVolume, 0, note->reverbVol << 8);
|
||||
#else
|
||||
aSetVolume(cmd++, A_VOL | A_LEFT, vol->sourceLeft, 0, 0);
|
||||
aSetVolume(cmd++, A_VOL | A_RIGHT, vol->sourceRight, 0, 0);
|
||||
aSetVolume32(cmd++, A_RATE | A_LEFT, vol->targetLeft, rampLeft);
|
||||
aSetVolume32(cmd++, A_RATE | A_RIGHT, vol->targetRight, rampRight);
|
||||
aSetVolume(cmd++, A_AUX, gVolume, 0, note->reverbVol);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (gUseReverb && note->reverbVol != 0) {
|
||||
aEnvMixer(cmd++, mixerFlags | A_AUX,
|
||||
VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->mixEnvelopeState));
|
||||
#else
|
||||
if (gSynthesisReverb.useReverb && note->reverb) {
|
||||
aEnvMixer(cmd++, mixerFlags | A_AUX,
|
||||
VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->mixEnvelopeState));
|
||||
#endif
|
||||
if (note->stereoStrongRight) {
|
||||
aSetBuffer(cmd++, 0, 0, 0, nSamples * 2);
|
||||
// 0x8000 is -100%, so subtract sound instead of adding...
|
||||
@@ -696,7 +1317,11 @@ u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf
|
||||
/*out*/ DMEM_ADDR_WET_RIGHT_CH);
|
||||
}
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
aEnvMixer(cmd++, mixerFlags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->mixEnvelopeState));
|
||||
#else
|
||||
aEnvMixer(cmd++, mixerFlags, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->mixEnvelopeState));
|
||||
#endif
|
||||
if (note->stereoStrongRight) {
|
||||
aSetBuffer(cmd++, 0, 0, 0, nSamples * 2);
|
||||
aMix(cmd++, 0, /*gain*/ 0x8000, /*in*/ DMEM_ADDR_STEREO_STRONG_TEMP_DRY,
|
||||
@@ -710,25 +1335,43 @@ u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf
|
||||
return cmd;
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
GLOBAL_ASM("asm/non_matchings/eu/audio/note_apply_headset_pan_effects.s")
|
||||
#else
|
||||
#ifdef VERSION_EU
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) {
|
||||
#else
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32 flags, s32 leftRight) {
|
||||
#endif
|
||||
u16 dest;
|
||||
u16 prevPanShift;
|
||||
u16 panShift;
|
||||
u16 pitch; // t2
|
||||
#ifndef VERSION_EU
|
||||
UNUSED s32 padding[11];
|
||||
#endif
|
||||
|
||||
switch (leftRight) {
|
||||
case 1:
|
||||
dest = DMEM_ADDR_LEFT_CH;
|
||||
note->prevHeadsetPanLeft = 0;
|
||||
#ifndef VERSION_EU
|
||||
panShift = note->headsetPanRight;
|
||||
#else
|
||||
panShift = noteSubEu->headsetPanRight;
|
||||
#endif
|
||||
prevPanShift = note->prevHeadsetPanRight;
|
||||
note->prevHeadsetPanRight = panShift;
|
||||
break;
|
||||
case 2:
|
||||
dest = DMEM_ADDR_RIGHT_CH;
|
||||
note->prevHeadsetPanRight = 0;
|
||||
#ifndef VERSION_EU
|
||||
panShift = note->headsetPanLeft;
|
||||
#else
|
||||
panShift = noteSubEu->headsetPanLeft;
|
||||
#endif
|
||||
|
||||
prevPanShift = note->prevHeadsetPanLeft;
|
||||
note->prevHeadsetPanLeft = panShift;
|
||||
break;
|
||||
@@ -787,6 +1430,10 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(VERSION_EU)
|
||||
// Moved to playback.c in EU
|
||||
|
||||
void note_init_volume(struct Note *note) {
|
||||
note->targetVolLeft = 0;
|
||||
@@ -899,3 +1546,4 @@ void note_disable(struct Note *note) {
|
||||
note->parentLayer = NO_LAYER;
|
||||
note->prevParentLayer = NO_LAYER;
|
||||
}
|
||||
#endif
|
||||
+37
-14
@@ -6,7 +6,11 @@
|
||||
#define DEFAULT_LEN_1CH 0x140
|
||||
#define DEFAULT_LEN_2CH 0x280
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define MAX_UPDATES_PER_FRAME 5
|
||||
#else
|
||||
#define MAX_UPDATES_PER_FRAME 4
|
||||
#endif
|
||||
|
||||
struct ReverbRingBufferItem
|
||||
{
|
||||
@@ -20,33 +24,52 @@ struct ReverbRingBufferItem
|
||||
|
||||
struct SynthesisReverb
|
||||
{
|
||||
u8 resampleFlags;
|
||||
u8 useReverb;
|
||||
u8 framesLeftToIgnore;
|
||||
u8 curFrame;
|
||||
u16 reverbGain;
|
||||
u16 resampleRate;
|
||||
s32 nextRingBufferPos;
|
||||
s32 unkC; // never read
|
||||
s32 bufSizePerChannel;
|
||||
/*0x00, 0x00*/ u8 resampleFlags;
|
||||
/*0x01, 0x01*/ u8 useReverb;
|
||||
/*0x02, 0x02*/ u8 framesLeftToIgnore;
|
||||
/*0x03, 0x03*/ u8 curFrame;
|
||||
#ifdef VERSION_EU
|
||||
/* 0x04*/ u8 downsampleRate;
|
||||
/* 0x06*/ u16 windowSize; // same as bufSizePerChannel
|
||||
#endif
|
||||
/*0x04, 0x08*/ u16 reverbGain;
|
||||
/*0x06, 0x0A*/ u16 resampleRate;
|
||||
/*0x08, 0x0C*/ s32 nextRingBufferPos;
|
||||
/*0x0C, 0x10*/ s32 unkC; // never read
|
||||
/*0x10, 0x14*/ s32 bufSizePerChannel;
|
||||
struct
|
||||
{
|
||||
s16 *left;
|
||||
s16 *right;
|
||||
} ringBuffer;
|
||||
s16 *resampleStateLeft;
|
||||
s16 *resampleStateRight;
|
||||
s16 *unk24; // never read
|
||||
s16 *unk28; // never read
|
||||
struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME];
|
||||
/*0x1C, 0x20*/ s16 *resampleStateLeft;
|
||||
/*0x20, 0x24*/ s16 *resampleStateRight;
|
||||
/*0x24, 0x28*/ s16 *unk24; // never read
|
||||
/*0x28, 0x2C*/ s16 *unk28; // never read
|
||||
/*0x2C, 0x30*/ struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME];
|
||||
#ifdef VERSION_EU
|
||||
u8 pad[16];
|
||||
#endif
|
||||
}; // 0xCC <= size <= 0x100
|
||||
#if defined(VERSION_EU)
|
||||
extern struct SynthesisReverb gSynthesisReverbs[4];
|
||||
extern s8 gNumSynthesisReverbs;
|
||||
extern struct NoteSubEu *gNoteSubsEu;
|
||||
extern f32 gLeftVolRampings[3][1024];
|
||||
extern f32 gRightVolRampings[3][1024];
|
||||
extern f32 *gCurrentLeftVolRamping; // Points to any of the three left buffers above
|
||||
extern f32 *gCurrentRightVolRamping; // Points to any of the three right buffers above
|
||||
#else
|
||||
extern struct SynthesisReverb gSynthesisReverb;
|
||||
#endif
|
||||
|
||||
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, u16 *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);
|
||||
void note_set_frequency(struct Note *note, f32 frequency);
|
||||
void note_enable(struct Note *note);
|
||||
void note_disable(struct Note *note);
|
||||
#endif
|
||||
|
||||
#endif /* AUDIO_SYNTHESIS_H */
|
||||
+19
-14
@@ -3,8 +3,25 @@
|
||||
#include "buffers.h"
|
||||
|
||||
ALIGNED8 u8 gDecompressionHeap[0xD000];
|
||||
|
||||
#ifdef VERSION_EU
|
||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800];
|
||||
#else
|
||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200)];
|
||||
#endif
|
||||
|
||||
ALIGNED8 u8 gIdleThreadStack[0x800];
|
||||
ALIGNED8 u8 gThread3Stack[0x2000];
|
||||
ALIGNED8 u8 gThread4Stack[0x2000];
|
||||
ALIGNED8 u8 gThread5Stack[0x2000];
|
||||
// 0x400 bytes
|
||||
ALIGNED8 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
// 0xc00 bytes for f3dex, 0x900 otherwise
|
||||
ALIGNED8 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
// 0x200 bytes
|
||||
ALIGNED8 struct SaveBuffer gSaveBuffer;
|
||||
// 0x190a0 bytes
|
||||
struct GfxPool gGfxPools[2];
|
||||
|
||||
|
||||
// Yield buffer for audio, 0x400 bytes. Stubbed out post-JP since the audio
|
||||
// task never yields.
|
||||
@@ -14,23 +31,11 @@ ALIGNED8 u8 gAudioSPTaskYieldBuffer[OS_YIELD_AUDIO_SIZE];
|
||||
|
||||
// Probably Thread 2 stack space. Unreferenced, and stubbed out with f3dex to
|
||||
// avoid an overflowing .buffers segment.
|
||||
#ifndef F3DEX_GBI_SHARED
|
||||
#if !defined(F3DEX_GBI_SHARED) && !defined(VERSION_EU)
|
||||
ALIGNED8 u8 gUnusedThread2Stack[0x1400];
|
||||
#endif
|
||||
|
||||
ALIGNED8 u8 gIdleThreadStack[0x800];
|
||||
ALIGNED8 u8 gThread3Stack[0x2000];
|
||||
ALIGNED8 u8 gThread4Stack[0x2000];
|
||||
ALIGNED8 u8 gThread5Stack[0x2000];
|
||||
|
||||
// 0xc00 bytes for f3dex, 0x900 otherwise
|
||||
ALIGNED8 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
|
||||
// 0x200 bytes
|
||||
ALIGNED8 struct SaveBuffer gSaveBuffer;
|
||||
|
||||
// 0x400 bytes
|
||||
ALIGNED8 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
|
||||
// 0x190a0 bytes
|
||||
struct GfxPool gGfxPools[2];
|
||||
@@ -44,6 +44,7 @@ GeoLayoutCommandProc GeoLayoutJumpTable[] = {
|
||||
geo_layout_cmd_node_culling_radius,
|
||||
};
|
||||
|
||||
struct GraphNode gObjParentGraphNode;
|
||||
struct AllocOnlyPool *gGraphNodePool;
|
||||
struct GraphNode *gCurRootGraphNode;
|
||||
|
||||
@@ -98,7 +99,6 @@ s16 gGeoLayoutStackIndex; // similar to SP register in MIPS
|
||||
UNUSED s16 D_8038BD7C;
|
||||
s16 gGeoLayoutReturnIndex; // similar to RA register in MIPS
|
||||
u8 *gGeoLayoutCommand;
|
||||
struct GraphNode gObjParentGraphNode;
|
||||
|
||||
u32 unused_8038B894[3] = { 0 };
|
||||
|
||||
|
||||
@@ -372,7 +372,11 @@ static void level_cmd_end_area(void) {
|
||||
|
||||
static void level_cmd_load_model_from_dl(void) {
|
||||
s16 val1 = CMD_GET(s16, 2) & 0x0FFF;
|
||||
#ifdef VERSION_EU
|
||||
s16 val2 = (CMD_GET(s16, 2) & 0xFFFF) >> 12;
|
||||
#else
|
||||
s16 val2 = CMD_GET(u16, 2) >> 12;
|
||||
#endif
|
||||
void *val3 = CMD_GET(void *, 4);
|
||||
|
||||
if (val1 < 256) {
|
||||
@@ -401,7 +405,11 @@ static void level_cmd_23(void) {
|
||||
} arg2;
|
||||
|
||||
s16 model = CMD_GET(s16, 2) & 0x0FFF;
|
||||
#ifdef VERSION_EU
|
||||
s16 arg0H = (CMD_GET(s16, 2) & 0xFFFF) >> 12;
|
||||
#else
|
||||
s16 arg0H = CMD_GET(u16, 2) >> 12;
|
||||
#endif
|
||||
void *arg1 = CMD_GET(void *, 4);
|
||||
// load an f32, but using an integer load instruction for some reason (hence the union)
|
||||
arg2.i = CMD_GET(s32, 8);
|
||||
|
||||
@@ -159,17 +159,12 @@ void mtxf_copy(Mat4 dest, Mat4 src) {
|
||||
void mtxf_identity(Mat4 mtx) {
|
||||
register s32 i;
|
||||
register f32 *dest;
|
||||
|
||||
// Note: These loops need to be on one line to match on PAL
|
||||
// initialize everything except the first and last cells to 0
|
||||
// (this need to be on one line to match on PAL)
|
||||
for (dest = (f32 *) mtx + 1, i = 0; i < 14; dest++, i++) {
|
||||
*dest = 0;
|
||||
}
|
||||
for (dest = (f32 *) mtx + 1, i = 0; i < 14; dest++, i++) *dest = 0;
|
||||
|
||||
// initialize the diagonal cells to 1
|
||||
for (dest = (f32 *) mtx, i = 0; i < 4; dest += 5, i++) {
|
||||
*dest = 1;
|
||||
}
|
||||
for (dest = (f32 *) mtx, i = 0; i < 4; dest += 5, i++) *dest = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "surface_collision.h"
|
||||
#include "surface_load.h"
|
||||
#include "game/object_list_processor.h"
|
||||
#include "game/room.h"
|
||||
|
||||
/**************************************************
|
||||
* WALLS *
|
||||
@@ -21,6 +20,9 @@
|
||||
*/
|
||||
static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
|
||||
struct WallCollisionData *data) {
|
||||
#ifdef VERSION_EU
|
||||
UNUSED u8 pad;
|
||||
#endif
|
||||
register f32 offset;
|
||||
register f32 radius = data->radius;
|
||||
register struct Surface *surf;
|
||||
@@ -60,12 +62,8 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
|
||||
// the fact they are floating point, certain floating point positions
|
||||
// along the seam of two walls may collide with neither wall or both walls.
|
||||
if (surf->flags & SURFACE_FLAG_X_PROJECTION) {
|
||||
w1 = -surf->vertex1[2];
|
||||
w2 = -surf->vertex2[2];
|
||||
w3 = -surf->vertex3[2];
|
||||
y1 = surf->vertex1[1];
|
||||
y2 = surf->vertex2[1];
|
||||
y3 = surf->vertex3[1];
|
||||
w1 = -surf->vertex1[2]; w2 = -surf->vertex2[2]; w3 = -surf->vertex3[2];
|
||||
y1 = surf->vertex1[1]; y2 = surf->vertex2[1]; y3 = surf->vertex3[1];
|
||||
|
||||
if (surf->normal.x > 0.0f) {
|
||||
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) > 0.0f) {
|
||||
@@ -89,12 +87,8 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
w1 = surf->vertex1[0];
|
||||
w2 = surf->vertex2[0];
|
||||
w3 = surf->vertex3[0];
|
||||
y1 = surf->vertex1[1];
|
||||
y2 = surf->vertex2[1];
|
||||
y3 = surf->vertex3[1];
|
||||
w1 = surf->vertex1[0]; w2 = surf->vertex2[0]; w3 = surf->vertex3[0];
|
||||
y1 = surf->vertex1[1]; y2 = surf->vertex2[1]; y3 = surf->vertex3[1];
|
||||
|
||||
if (surf->normal.z > 0.0f) {
|
||||
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) > 0.0f) {
|
||||
@@ -370,7 +364,7 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil) {
|
||||
/**
|
||||
* Find the height of the highest floor below an object.
|
||||
*/
|
||||
static f32 unused_obj_find_floor_height(struct Object *obj) {
|
||||
f32 unused_obj_find_floor_height(struct Object *obj) {
|
||||
struct Surface *floor;
|
||||
f32 floorHeight = find_floor(obj->oPosX, obj->oPosY, obj->oPosZ, &floor);
|
||||
return floorHeight;
|
||||
@@ -496,7 +490,7 @@ f32 find_floor_height(f32 x, f32 y, f32 z) {
|
||||
* Find the highest dynamic floor under a given position. Perhaps originally static and
|
||||
* and dynamic floors were checked separately.
|
||||
*/
|
||||
static f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
|
||||
f32 unused_find_dynamic_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor) {
|
||||
struct SurfaceNode *surfaceList;
|
||||
struct Surface *floor;
|
||||
f32 floorHeight = -11000.0f;
|
||||
@@ -749,10 +743,12 @@ void debug_surface_list_info(f32 xPos, f32 zPos) {
|
||||
* An unused function that finds and interacts with any type of surface.
|
||||
* Perhaps an original implementation of surfaces before they were more specialized.
|
||||
*/
|
||||
static s32 unused_resolve_floor_or_ceil_collisions(s32 checkCeil, f32 *px, f32 *py, f32 *pz, f32 radius,
|
||||
s32 unused_resolve_floor_or_ceil_collisions(s32 checkCeil, f32 *px, f32 *py, f32 *pz, f32 radius,
|
||||
struct Surface **psurface, f32 *surfaceHeight) {
|
||||
f32 nx, ny, nz, oo;
|
||||
f32 x = *px, y = *py, z = *pz;
|
||||
f32 x = *px;
|
||||
f32 y = *py;
|
||||
f32 z = *pz;
|
||||
f32 offset, distance;
|
||||
|
||||
*psurface = NULL;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "surface_collision.h"
|
||||
#include "game/mario.h"
|
||||
#include "game/object_list_processor.h"
|
||||
#include "game/room.h"
|
||||
#include "surface_load.h"
|
||||
|
||||
s32 unused8038BE90;
|
||||
@@ -601,17 +600,19 @@ static void unused_80383604(void) {
|
||||
/**
|
||||
* Applies an object's tranformation to the object's vertices.
|
||||
*/
|
||||
static void transform_object_vertices(s16 **data, s16 *vertexData) {
|
||||
void transform_object_vertices(s16 **data, s16 *vertexData) {
|
||||
register s16 *vertices;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
register f32 vx, vy, vz;
|
||||
register s32 numVertices;
|
||||
|
||||
register f32 vx;
|
||||
register f32 vy;
|
||||
register f32 vz;
|
||||
#else
|
||||
register s32 numVertices;
|
||||
register f32 vx, vy, vz;
|
||||
#endif
|
||||
|
||||
Mat4 *objectTransform;
|
||||
Mat4 m;
|
||||
UNUSED s16 unused;
|
||||
|
||||
objectTransform = &gCurrentObject->transform;
|
||||
|
||||
@@ -646,7 +647,7 @@ static void transform_object_vertices(s16 **data, s16 *vertexData) {
|
||||
* Load in the surfaces for the gCurrentObject. This includes setting the flags,
|
||||
* exertion, and room.
|
||||
*/
|
||||
static void load_object_surfaces(s16 **data, s16 *vertexData) {
|
||||
void load_object_surfaces(s16 **data, s16 *vertexData) {
|
||||
s32 surfaceType;
|
||||
s32 i;
|
||||
s32 numSurfaces;
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ void print_intro_text(void) {
|
||||
#endif
|
||||
} else {
|
||||
#ifdef VERSION_EU
|
||||
print_text_centered(20, 20, "START");
|
||||
print_text(20, 20, "START");
|
||||
#else
|
||||
print_text_centered(60, 38, "PRESS");
|
||||
print_text_centered(60, 20, "START");
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "platform_displacement.h"
|
||||
#include "interaction.h"
|
||||
#include "ingame_menu.h"
|
||||
#include "room.h"
|
||||
#include "rendering_graph_node.h"
|
||||
#include "level_table.h"
|
||||
|
||||
@@ -211,10 +210,8 @@ Gfx *Geo18_802B1BB0(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) {
|
||||
#include "behaviors/boo_cage.inc.c"
|
||||
|
||||
// not in behavior file
|
||||
void func_802B2328(
|
||||
s32 n, s32 a1, s32 a2,
|
||||
s32 r) // n is the number of objects to spawn, r if the rate of change of phase (frequency?)
|
||||
{
|
||||
// n is the number of objects to spawn, r if the rate of change of phase (frequency?)
|
||||
void func_802B2328(s32 n, s32 a1, s32 a2, s32 r) {
|
||||
s32 i;
|
||||
s16 separation = 0x10000 / n; // Evenly spread around a circle
|
||||
for (i = 0; i < n; i++) {
|
||||
@@ -222,6 +219,10 @@ void func_802B2328(
|
||||
coss(D_8035FF10 + i * separation) * a1, o, MODEL_NONE, bhvSparkleSpawn);
|
||||
}
|
||||
|
||||
if (1)
|
||||
{
|
||||
}
|
||||
|
||||
D_8035FF10 += r * 0x100;
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ void bhv_racing_penguin_init(void);
|
||||
void bhv_racing_penguin_update(void);
|
||||
void bhv_penguin_race_finish_line_update(void);
|
||||
void bhv_penguin_race_shortcut_check_update(void);
|
||||
void bhv_coffin_manager_loop(void);
|
||||
void bhv_coffin_spawner_loop(void);
|
||||
void bhv_coffin_loop(void);
|
||||
void bhv_clam_loop(void);
|
||||
void bhv_skeeter_update(void);
|
||||
|
||||
@@ -58,7 +58,7 @@ void bhv_activated_back_and_forth_platform_init(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Activated back-and-forth platform update function.
|
||||
* Activated back-and-forth platform update function.
|
||||
*/
|
||||
void bhv_activated_back_and_forth_platform_update(void) {
|
||||
UNUSED s32 unused[3];
|
||||
|
||||
@@ -99,7 +99,7 @@ void BobombChaseMarioLoop(void) {
|
||||
void BobombLaunchedLoop(void) {
|
||||
s16 collisionFlags = 0;
|
||||
collisionFlags = object_step();
|
||||
if ((collisionFlags & 0x1) == 1)
|
||||
if ((collisionFlags & OBJ_COL_FLAG_GROUNDED) == OBJ_COL_FLAG_GROUNDED)
|
||||
o->oAction = BOBOMB_ACT_EXPLODE; /* bit 0 */
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ void BobombBuddyIdleLoop(void) {
|
||||
|
||||
/**
|
||||
* Function for the Bob-omb Buddy cannon guy.
|
||||
* dialogFirstText is the first dialogID called when Bob-omb Buddy
|
||||
* dialogFirstText is the first dialogID called when Bob-omb Buddy
|
||||
* starts to talk to Mario to prepare the cannon(s) for him.
|
||||
* Then the camera goes to the nearest cannon, to play the "prepare cannon" cutscene
|
||||
* dialogSecondText is called after Bob-omb Buddy has the cannon(s) ready and
|
||||
@@ -361,7 +361,8 @@ void BobombBuddyTalkLoop(void) {
|
||||
|
||||
switch (o->oBobombBuddyRole) {
|
||||
case BOBOMB_BUDDY_ROLE_ADVICE:
|
||||
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, o->oBehParams2ndByte) != BOBOMB_BUDDY_BP_STYPE_GENERIC) {
|
||||
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, o->oBehParams2ndByte)
|
||||
!= BOBOMB_BUDDY_BP_STYPE_GENERIC) {
|
||||
set_mario_npc_dialog(0);
|
||||
|
||||
o->activeFlags &= ~0x20; /* bit 5 */
|
||||
|
||||
@@ -541,14 +541,11 @@ static void ActionBooGivingStar1(void) {
|
||||
f32 sp1C;
|
||||
|
||||
if (o->oHealth == 3) {
|
||||
sp22 = 0x180;
|
||||
sp1C = 0.5f;
|
||||
sp22 = 0x180; sp1C = 0.5f;
|
||||
} else if (o->oHealth == 2) {
|
||||
sp22 = 0x240;
|
||||
sp1C = 0.6f;
|
||||
sp22 = 0x240; sp1C = 0.6f;
|
||||
} else {
|
||||
sp22 = 0x300;
|
||||
sp1C = 0.8f;
|
||||
sp22 = 0x300; sp1C = 0.8f;
|
||||
}
|
||||
|
||||
boo_chase_mario(-100.0f, sp22, sp1C);
|
||||
|
||||
@@ -831,9 +831,9 @@ s32 func_802B5F20(void) {
|
||||
|
||||
void func_802B60B8(void) {
|
||||
obj_scale(0);
|
||||
o->oForwardVel = 0.0f;
|
||||
o->oVelY = 0.0f;
|
||||
o->oGravity = 0.0f;
|
||||
o->oForwardVel = 0;
|
||||
o->oVelY = 0;
|
||||
o->oGravity = 0;
|
||||
}
|
||||
|
||||
s32 func_802B6120(void) {
|
||||
@@ -1448,7 +1448,7 @@ void bhv_flame_bowser_loop(void) {
|
||||
obj_become_tangible();
|
||||
if (o->oTimer > o->oFlameUnkF4 * 10 + 5.0f) {
|
||||
o->oFlameUnkF4 -= 0.15;
|
||||
if (o->oFlameUnkF4 <= 0.0f)
|
||||
if (o->oFlameUnkF4 <= 0)
|
||||
func_802B7A58();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +177,10 @@ void BullyStep(void) {
|
||||
|
||||
void BullySpawnCoin(void) {
|
||||
struct Object *coin = spawn_object(o, MODEL_YELLOW_COIN, bhvMovingYellowCoin);
|
||||
#ifdef VERSION_JP
|
||||
#ifdef VERSION_JP //TODO: maybe move this ifdef logic to the header?
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT);
|
||||
#elif VERSION_EU
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT_EU);
|
||||
#else
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT_2);
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,7 @@ void ButterflyStep(s32 speed) {
|
||||
o->oPosZ += o->oVelZ;
|
||||
|
||||
if (o->oAction == BUTTERFLY_ACT_FOLLOW_MARIO)
|
||||
o->oPosY -= o->oVelY + coss((s32)(yPhase * 655.36)) * 20.0f / 4.0f;
|
||||
o->oPosY -= o->oVelY + coss((s32)(yPhase * 655.36)) * 20.0f / 4;
|
||||
else
|
||||
o->oPosY -= o->oVelY;
|
||||
|
||||
|
||||
@@ -50,18 +50,26 @@ void func_802F09C0(void) {
|
||||
case SURFACE_MOVING_QUICKSAND:
|
||||
o->oAction = 11;
|
||||
o->oMoveAngleYaw = (sObjFloor->force & 0xFF) << 8;
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
o->oForwardVel = 8 - ((sObjFloor->force & 0xff00) >> 8) * 2;
|
||||
#else
|
||||
o->oForwardVel = -((sObjFloor->force & 0xff00) >> 8) * 2 + 8;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SURFACE_INSTANT_QUICKSAND:
|
||||
o->oAction = 12;
|
||||
o->oForwardVel = 0;
|
||||
o->oForwardVel = 0.0f;
|
||||
break;
|
||||
|
||||
case SURFACE_INSTANT_MOVING_QUICKSAND:
|
||||
o->oAction = 13;
|
||||
o->oMoveAngleYaw = (sObjFloor->force & 0xFF) << 8;
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
o->oForwardVel = 8 - ((sObjFloor->force & 0xff00) >> 8) * 2;
|
||||
#else
|
||||
o->oForwardVel = -((sObjFloor->force & 0xff00) >> 8) * 2 + 8;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ static void chain_chomp_released_lunge_around(void) {
|
||||
o->oHomeX = 1450.0f;
|
||||
o->oHomeZ = 562.0f;
|
||||
o->oMoveAngleYaw = obj_angle_to_home();
|
||||
o->oForwardVel = obj_lateral_dist_to_home() / 8.0f;
|
||||
o->oForwardVel = obj_lateral_dist_to_home() / 8;
|
||||
o->oVelY = 50.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static void cloud_act_main(void) {
|
||||
cloud_fwoosh_update();
|
||||
}
|
||||
|
||||
localOffset = 2.0f * coss(localOffsetPhase) * o->header.gfx.scale[0];
|
||||
localOffset = 2 * coss(localOffsetPhase) * o->header.gfx.scale[0];
|
||||
|
||||
o->oPosX = o->oCloudCenterX + localOffset;
|
||||
o->oPosY = o->oCloudCenterY + localOffset + 12.0f * o->header.gfx.scale[0];
|
||||
@@ -193,7 +193,7 @@ void bhv_cloud_part_update(void) {
|
||||
}
|
||||
|
||||
// Move back and forth along (1, 1, 1)
|
||||
localOffset = 2.0f * coss(localOffsetPhase) * size;
|
||||
localOffset = 2 * coss(localOffsetPhase) * size;
|
||||
|
||||
cloudRadius = 25.0f * size;
|
||||
|
||||
|
||||
@@ -1,80 +1,112 @@
|
||||
// coffin.inc.c
|
||||
/**
|
||||
* Behavior for bhvCoffinSpawner and bhvCoffin.
|
||||
* The coffins are spawned by a singular spawner,
|
||||
* with half being able to stand up.
|
||||
* Coffins unload after leaving the room.
|
||||
*/
|
||||
|
||||
struct Struct80331C00 {
|
||||
s16 unk00;
|
||||
s16 unk02;
|
||||
/**
|
||||
* Struct with s16 values for a horizontal position.
|
||||
*/
|
||||
struct LateralPosition {
|
||||
s16 x;
|
||||
s16 z;
|
||||
};
|
||||
|
||||
struct Struct80331C00 D_80331C00[] = {
|
||||
{ 0x019C, 0xFF6A }, { 0x02FA, 0xFF6A }, { 0x0458, 0xFF6A },
|
||||
{ 0x019C, 0x0096 }, { 0x02FA, 0x0096 }, { 0x0458, 0x0096 },
|
||||
/**
|
||||
* Array of positions for all coffins relative to their spawner.
|
||||
*/
|
||||
struct LateralPosition coffinRelativePos[] = {
|
||||
{ 412, -150 }, { 762, -150 }, { 1112, -150 },
|
||||
{ 412, 150 }, { 762, 150 }, { 1112, 150 },
|
||||
};
|
||||
|
||||
void bhv_coffin_manager_loop(void) {
|
||||
struct Object *val0C;
|
||||
s32 val08;
|
||||
s16 val06;
|
||||
/**
|
||||
* Loop behavior for the object that spawns the six coffins in BBH.
|
||||
* Loads the coffins when in the room, they unload themselves.
|
||||
*/
|
||||
void bhv_coffin_spawner_loop(void) {
|
||||
struct Object *coffin;
|
||||
s32 i;
|
||||
s16 relativeZ;
|
||||
|
||||
if (o->oAction == 0) {
|
||||
if (!(o->activeFlags & 0x0008)) {
|
||||
for (val08 = 0; val08 < 6; val08++) {
|
||||
val06 = D_80331C00[val08].unk02;
|
||||
if (o->oAction == COFFIN_SPAWNER_ACT_COFFINS_UNLOADED) {
|
||||
if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
relativeZ = coffinRelativePos[i].z;
|
||||
|
||||
val0C = spawn_object_relative(val08 & 0x00000001, D_80331C00[val08].unk00, 0, val06, o,
|
||||
// Behavior param of 0 for all even i, 1 for all odd
|
||||
coffin = spawn_object_relative(i & 1, coffinRelativePos[i].x, 0, relativeZ, o,
|
||||
MODEL_BBH_WOODEN_TOMB, bhvCoffin);
|
||||
if (val0C != NULL) {
|
||||
if (val06 > 0) {
|
||||
val0C->oFaceAngleYaw = 0x8000;
|
||||
|
||||
// Never true, game would enter a while(1) before it could.
|
||||
// Possible a remnant of days this didn't happen.
|
||||
if (coffin != NULL) {
|
||||
// Rotate the coffin 180 degrees if its on the other side of the room.
|
||||
if (relativeZ > 0) {
|
||||
coffin->oFaceAngleYaw = 0x8000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
o->oAction += 1;
|
||||
}
|
||||
} else if (o->activeFlags & 0x0008) {
|
||||
o->oAction = 0;
|
||||
} else if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) {
|
||||
o->oAction = COFFIN_SPAWNER_ACT_COFFINS_UNLOADED;
|
||||
}
|
||||
}
|
||||
|
||||
void coffin_act_0(void) {
|
||||
f32 val14;
|
||||
f32 val10;
|
||||
f32 val0C;
|
||||
f32 val08;
|
||||
f32 val04;
|
||||
f32 val00;
|
||||
/**
|
||||
* The main action for the coffins. Coffins with COFFIN_BP_STATIC skip the behavior, while
|
||||
* the other coffins will enter a standing action when Mario is near.
|
||||
* Also controls laying the coffin down after it has stood up.
|
||||
*/
|
||||
void coffin_act_idle(void) {
|
||||
f32 yawCos;
|
||||
f32 yawSin;
|
||||
f32 dx;
|
||||
f32 dz;
|
||||
f32 distForwards;
|
||||
f32 distSideways;
|
||||
|
||||
if (o->oBehParams2ndByte != 0) {
|
||||
if (o->oBehParams2ndByte != COFFIN_BP_STATIC) {
|
||||
// Lay down if standing
|
||||
if (o->oFaceAnglePitch != 0) {
|
||||
o->oAngleVelPitch = approach_s16_symmetric(o->oAngleVelPitch, -2000, 200);
|
||||
|
||||
// If the coffin landed...
|
||||
if (obj_face_pitch_approach(0, -o->oAngleVelPitch)) {
|
||||
PlaySound2(SOUND_GENERAL_ELEVATOR_MOVE_2);
|
||||
obj_perform_position_op(0);
|
||||
o->oMoveAngleYaw = o->oFaceAngleYaw - 0x4000;
|
||||
|
||||
// This bit changes the coffin's position,
|
||||
// spawns dust there, then resets the position.
|
||||
obj_perform_position_op(POS_OP_SAVE_POSITION);
|
||||
o->oMoveAngleYaw = o->oFaceAngleYaw - 0x4000;
|
||||
obj_set_dist_from_home(200.0f);
|
||||
func_802ADA94();
|
||||
obj_perform_position_op(2);
|
||||
obj_perform_position_op(POS_OP_RESTORE_POSITION);
|
||||
}
|
||||
|
||||
o->oTimer = 0;
|
||||
} else {
|
||||
val14 = coss(o->oFaceAngleYaw);
|
||||
val10 = sins(o->oFaceAngleYaw);
|
||||
// Yaw never changes and is aligned, so yawCos = 1 or -1, yawSin = 0
|
||||
yawCos = coss(o->oFaceAngleYaw);
|
||||
yawSin = sins(o->oFaceAngleYaw);
|
||||
|
||||
val0C = gMarioObject->oPosX - o->oPosX;
|
||||
val08 = gMarioObject->oPosZ - o->oPosZ;
|
||||
dx = gMarioObject->oPosX - o->oPosX;
|
||||
dz = gMarioObject->oPosZ - o->oPosZ;
|
||||
|
||||
val04 = val0C * val14 + val08 * val10;
|
||||
val00 = val08 * val14 - val0C * val10;
|
||||
distForwards = dx * yawCos + dz * yawSin;
|
||||
distSideways = dz * yawCos - dx * yawSin;
|
||||
|
||||
// This checks a box around the coffin and if it has been a bit since it stood up.
|
||||
// It also checks in the case Mario is squished, so he doesn't get permanently squished.
|
||||
if (o->oTimer > 60
|
||||
&& (o->oDistanceToMario > 100.0f || gMarioState->action == ACT_SQUISHED)) {
|
||||
if (gMarioObject->oPosY - o->oPosY < 200.0f && absf(val04) < 140.0f) {
|
||||
if (val00 < 150.0f && val00 > -450.0f) {
|
||||
if (gMarioObject->oPosY - o->oPosY < 200.0f && absf(distForwards) < 140.0f) {
|
||||
if (distSideways < 150.0f && distSideways > -450.0f) {
|
||||
PlaySound2(SOUND_GENERAL_BUTTON_PRESS_2_LOWPRIO);
|
||||
o->oAction = 1;
|
||||
o->oAction = COFFIN_ACT_STAND_UP;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,18 +116,24 @@ void coffin_act_0(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void coffin_act_1(void) {
|
||||
/**
|
||||
* Stand up the coffin and keep it standing until the timer hits 60.
|
||||
*/
|
||||
void coffin_act_stand_up(void) {
|
||||
// Stand up
|
||||
if (o->oFaceAnglePitch != 0x4000) {
|
||||
o->oAngleVelPitch = approach_s16_symmetric(o->oAngleVelPitch, 1000, 200);
|
||||
obj_face_pitch_approach(0x4000, o->oAngleVelPitch);
|
||||
} else {
|
||||
// Stay standing
|
||||
if (o->oTimer > 60) {
|
||||
o->oAction = 0;
|
||||
o->oAction = COFFIN_ACT_IDLE;
|
||||
o->oFaceAngleRoll = 0;
|
||||
} else if (o->oTimer > 30) {
|
||||
if (gGlobalTimer % 4 == 0) {
|
||||
PlaySound2(SOUND_GENERAL_ELEVATOR_MOVE_2);
|
||||
}
|
||||
// Shake the coffin while its standing
|
||||
o->oFaceAngleRoll = 400 * (gGlobalTimer % 2) - 200;
|
||||
}
|
||||
|
||||
@@ -103,18 +141,24 @@ void coffin_act_1(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main behavior for each coffin. Unloads the coffin if the spawner enters
|
||||
* that action.
|
||||
*/
|
||||
void bhv_coffin_loop(void) {
|
||||
if (o->parentObj->oAction == 0) {
|
||||
// Gotta save those 6 object slots
|
||||
if (o->parentObj->oAction == COFFIN_SPAWNER_ACT_COFFINS_UNLOADED) {
|
||||
mark_object_for_deletion(o);
|
||||
} else {
|
||||
// Scale the coffin vertically? Must have thought it was too short?
|
||||
o->header.gfx.scale[1] = 1.1f;
|
||||
|
||||
switch (o->oAction) {
|
||||
case 0:
|
||||
coffin_act_0();
|
||||
case COFFIN_ACT_IDLE:
|
||||
coffin_act_idle();
|
||||
break;
|
||||
case 1:
|
||||
coffin_act_1();
|
||||
case COFFIN_ACT_STAND_UP:
|
||||
coffin_act_stand_up();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,10 @@ void bhv_coin_loop(void) {
|
||||
}
|
||||
}
|
||||
if (o->oTimer == 0)
|
||||
#ifndef VERSION_JP
|
||||
#ifdef VERSION_US
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT_2);
|
||||
#elif VERSION_EU
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT_EU);
|
||||
#else
|
||||
PlaySound2(SOUND_GENERAL_COIN_SPURT);
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// door.c.inc
|
||||
|
||||
s32 D_8032F300[][2] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { -1, 0 }, };
|
||||
struct DoorAction
|
||||
{
|
||||
u32 flag;
|
||||
s32 action;
|
||||
};
|
||||
|
||||
struct DoorAction D_8032F300[] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { -1, 0 }, };
|
||||
|
||||
s32 D_8032F328[] = { SOUND_GENERAL_OPEN_WOOD_DOOR, SOUND_GENERAL_OPEN_IRON_DOOR };
|
||||
|
||||
@@ -39,13 +45,15 @@ void func_802AC1CC(void) {
|
||||
|
||||
void bhv_door_loop(void) {
|
||||
s32 sp1C = 0;
|
||||
while (D_8032F300[sp1C][0] != -1) {
|
||||
if (obj_clear_interact_status_flag(D_8032F300[sp1C][0])) {
|
||||
|
||||
while (D_8032F300[sp1C].flag != (u32)~0) {
|
||||
if (obj_clear_interact_status_flag(D_8032F300[sp1C].flag)) {
|
||||
func_802AC0B8();
|
||||
obj_change_action(D_8032F300[sp1C][1]);
|
||||
obj_change_action(D_8032F300[sp1C].action);
|
||||
}
|
||||
sp1C++;
|
||||
}
|
||||
|
||||
switch (o->oAction) {
|
||||
case 0:
|
||||
set_obj_animation_and_sound_state(0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
static void dorrie_raise_head(void) {
|
||||
void dorrie_raise_head(void) {
|
||||
s16 startAngle;
|
||||
f32 xzDisp;
|
||||
f32 yDisp;
|
||||
@@ -15,7 +15,7 @@ static void dorrie_raise_head(void) {
|
||||
gMarioObject->oPosZ + xzDisp * coss(o->oMoveAngleYaw));
|
||||
}
|
||||
|
||||
static void dorrie_act_move(void) {
|
||||
void dorrie_act_move(void) {
|
||||
s16 startYaw;
|
||||
s16 targetYaw;
|
||||
s16 targetSpeed;
|
||||
@@ -54,13 +54,13 @@ static void dorrie_act_move(void) {
|
||||
o->oAngleVelYaw = o->oMoveAngleYaw - startYaw;
|
||||
}
|
||||
|
||||
static void dorrie_begin_head_raise(s32 liftingMario) {
|
||||
void dorrie_begin_head_raise(s32 liftingMario) {
|
||||
o->oDorrieLiftingMario = liftingMario;
|
||||
o->oAction = DORRIE_ACT_RAISE_HEAD;
|
||||
o->oDorrieHeadRaiseSpeed = 0;
|
||||
}
|
||||
|
||||
static void dorrie_act_lower_head(void) {
|
||||
void dorrie_act_lower_head(void) {
|
||||
if (func_802F92EC(2, 35)) {
|
||||
func_8029F6F0();
|
||||
|
||||
@@ -92,7 +92,7 @@ static void dorrie_act_lower_head(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void dorrie_act_raise_head(void) {
|
||||
void dorrie_act_raise_head(void) {
|
||||
o->collisionData = segmented_to_virtual(dorrie_seg6_collision_0600F644);
|
||||
if (func_8029F788()) {
|
||||
o->oAction = DORRIE_ACT_MOVE;
|
||||
|
||||
@@ -88,12 +88,12 @@ void bhv_elevator_init(void) {
|
||||
if (sp1C == 0) {
|
||||
o->oElevatorUnkF4 = D_8032F38C[o->oBehParams2ndByte * 3];
|
||||
o->oElevatorUnkF8 = o->oHomeY;
|
||||
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2.0f;
|
||||
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2;
|
||||
o->oElevatorUnk100 = obj_has_behavior(bhvRrElevatorPlatform);
|
||||
} else {
|
||||
o->oElevatorUnkF4 = D_8032F38C[o->oBehParams2ndByte * 3];
|
||||
o->oElevatorUnkF8 = D_8032F38C[o->oBehParams2ndByte * 3 + 1];
|
||||
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2.0f;
|
||||
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2;
|
||||
o->oElevatorUnk100 = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static void enemy_lakitu_update_speed_and_angle(void) {
|
||||
}
|
||||
|
||||
// Change move angle toward mario faster when farther from mario
|
||||
turnSpeed = (s16)(distToMario * 2.0f);
|
||||
turnSpeed = (s16)(distToMario * 2);
|
||||
clamp_s16(&turnSpeed, 0xC8, 0xFA0);
|
||||
obj_rotate_yaw_toward(o->oAngleToMario, turnSpeed);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,7 @@ void bhv_fire_piranha_plant_init(void) {
|
||||
o->oNumLootCoins = 2;
|
||||
}
|
||||
}
|
||||
|
||||
sNumKilledFirePiranhaPlants = 0;
|
||||
sNumActiveFirePiranhaPlants = 0;
|
||||
sNumActiveFirePiranhaPlants = sNumKilledFirePiranhaPlants = 0;
|
||||
}
|
||||
|
||||
static void fire_piranha_plant_act_hide(void) {
|
||||
@@ -114,7 +112,7 @@ static void fire_piranha_plant_act_grow(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (o->oFirePiranhaPlantScale > o->oFirePiranhaPlantNeutralScale / 2.0f) {
|
||||
} else if (o->oFirePiranhaPlantScale > o->oFirePiranhaPlantNeutralScale / 2) {
|
||||
obj_become_tangible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,28 +9,16 @@ void ActionFish0(void) {
|
||||
struct Object *sp28;
|
||||
switch (o->oBehParams2ndByte) {
|
||||
case 0:
|
||||
model = MODEL_FISH;
|
||||
sp38 = 20;
|
||||
sp30 = 1500.0f;
|
||||
sp2C = blue_fish_seg3_anims_0301C2B0;
|
||||
model = MODEL_FISH; sp38 = 20; sp30 = 1500.0f; sp2C = blue_fish_seg3_anims_0301C2B0;
|
||||
break;
|
||||
case 1:
|
||||
model = MODEL_FISH;
|
||||
sp38 = 5;
|
||||
sp30 = 1500.0f;
|
||||
sp2C = blue_fish_seg3_anims_0301C2B0;
|
||||
model = MODEL_FISH; sp38 = 5; sp30 = 1500.0f; sp2C = blue_fish_seg3_anims_0301C2B0;
|
||||
break;
|
||||
case 2:
|
||||
model = MODEL_CYAN_FISH;
|
||||
sp38 = 20;
|
||||
sp30 = 1500.0f;
|
||||
sp2C = cyan_fish_seg6_anims_0600E264;
|
||||
model = MODEL_CYAN_FISH; sp38 = 20; sp30 = 1500.0f; sp2C = cyan_fish_seg6_anims_0600E264;
|
||||
break;
|
||||
case 3:
|
||||
model = MODEL_CYAN_FISH;
|
||||
sp38 = 5;
|
||||
sp30 = 1500.0f;
|
||||
sp2C = cyan_fish_seg6_anims_0600E264;
|
||||
model = MODEL_CYAN_FISH; sp38 = 5; sp30 = 1500.0f; sp2C = cyan_fish_seg6_anims_0600E264;
|
||||
break;
|
||||
}
|
||||
if (o->oDistanceToMario < sp30 || gCurrLevelNum == LEVEL_SA) {
|
||||
|
||||
@@ -17,10 +17,10 @@ f32 func_802F54F8(void) {
|
||||
}
|
||||
|
||||
void func_802F55CC(void) {
|
||||
s16 sp6 = (gMarioObject->header.gfx.pos[0] - o->oPosX) * coss(-o->oMoveAngleYaw)
|
||||
+ (gMarioObject->header.gfx.pos[2] - o->oPosZ) * sins(-o->oMoveAngleYaw);
|
||||
s16 sp4 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-o->oMoveAngleYaw)
|
||||
- (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-o->oMoveAngleYaw);
|
||||
s16 sp6 = (gMarioObject->header.gfx.pos[0] - o->oPosX) * coss(-1*o->oMoveAngleYaw)
|
||||
+ (gMarioObject->header.gfx.pos[2] - o->oPosZ) * sins(-1*o->oMoveAngleYaw);
|
||||
s16 sp4 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-1*o->oMoveAngleYaw)
|
||||
- (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-1*o->oMoveAngleYaw);
|
||||
|
||||
if (gMarioObject->platform == o) {
|
||||
o->oFaceAnglePitch = sp4 * 2;
|
||||
|
||||
@@ -85,8 +85,7 @@ void bhv_goomba_triplet_spawner_update(void) {
|
||||
0x10000
|
||||
/ (((o->oBehParams2ndByte & GOOMBA_TRIPLET_SPAWNER_BP_EXTRA_GOOMBAS_MASK) >> 2) + 3);
|
||||
|
||||
goombaFlag = 1 << 8;
|
||||
for (angle = 0; angle < 0xFFFF; angle += dAngle, goombaFlag <<= 1) {
|
||||
for (angle = 0, goombaFlag = 1 << 8; angle < 0xFFFF; angle += dAngle, goombaFlag <<= 1) {
|
||||
// Only spawn goombas which haven't been killed yet
|
||||
if (!(o->oBehParams & goombaFlag)) {
|
||||
dx = 500.0f * coss(angle);
|
||||
|
||||
@@ -61,9 +61,9 @@ void HootFreeStep(s16 fastOscY, s32 speed) {
|
||||
|
||||
o->oPosX += o->oVelX;
|
||||
if (fastOscY == 0)
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp26 * 3276.8)) * 50.0f / 4.0f;
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp26 * 3276.8)) * 50.0f / 4;
|
||||
else
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp26 * 6553.6)) * 50.0f / 4.0f;
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp26 * 6553.6)) * 50.0f / 4;
|
||||
o->oPosZ += o->oVelZ;
|
||||
|
||||
find_floor_height_and_data(o->oPosX, o->oPosY, o->oPosZ, &sp2c);
|
||||
@@ -104,7 +104,7 @@ void HootCarryStep(s32 speed, UNUSED f32 xPrev, UNUSED f32 zPrev) {
|
||||
o->oVelZ = coss(yaw) * hSpeed;
|
||||
|
||||
o->oPosX += o->oVelX;
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp22 * 6553.6)) * 50.0f / 4.0f;
|
||||
o->oPosY -= o->oVelY + coss((s32)(sp22 * 6553.6)) * 50.0f / 4;
|
||||
o->oPosZ += o->oVelZ;
|
||||
|
||||
if (sp22 == 0)
|
||||
|
||||
@@ -118,7 +118,11 @@ void bhv_intro_lakitu_loop(void) {
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
#ifdef VERSION_EU
|
||||
if (gCutsceneTimer > 599) {
|
||||
#else
|
||||
if (gCutsceneTimer > 720) {
|
||||
#endif
|
||||
gCurrentObject->oAction += 1;
|
||||
gCurrentObject->oIntroLakituUnk100 = 1400.f;
|
||||
gCurrentObject->oIntroLakituUnk104 = -4096.f;
|
||||
|
||||
@@ -121,7 +121,7 @@ static void klepto_change_target(void) {
|
||||
o->oHomeY = sKleptoTargetPositions[o->oKleptoTargetNumber][1] + o->oKleptoUnkF8;
|
||||
o->oHomeZ = sKleptoTargetPositions[o->oKleptoTargetNumber][2];
|
||||
|
||||
o->oKleptoUnkFC = obj_lateral_dist_to_home() / 2.0f;
|
||||
o->oKleptoUnkFC = obj_lateral_dist_to_home() / 2;
|
||||
}
|
||||
|
||||
static void klepto_circle_target(f32 radius, f32 targetSpeed) {
|
||||
|
||||
@@ -127,7 +127,7 @@ void MoneybagMoveAroundLoop(void) {
|
||||
MoneybagCheckMarioCollision();
|
||||
|
||||
if (!is_point_within_radius_of_mario(o->oHomeX, o->oHomeY, o->oHomeZ, 800)
|
||||
&& ((collisionFlags & 0x9) == 9))
|
||||
&& ((collisionFlags & OBJ_COL_FLAGS_LANDED) == OBJ_COL_FLAGS_LANDED))
|
||||
o->oAction = MONEYBAG_ACT_RETURN_HOME;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,11 +178,25 @@ void bhv_monty_mole_hole_update(void) {
|
||||
|
||||
/**
|
||||
* Spawn dirt particles when rising out of the ground.
|
||||
*
|
||||
* TODO: (Scrub C) monty_mole_spawn_dirt_particles, water_bomb_spawn_explode_particles, and
|
||||
* func_80306ED4 all have similar issues with their functions, none of which match legitimately.
|
||||
*/
|
||||
static void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) {
|
||||
void monty_mole_spawn_dirt_particles(s8 offsetY, s8 velYBase) {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
sMontyMoleRiseFromGroundParticles.offsetY = offsetY;
|
||||
sMontyMoleRiseFromGroundParticles.velYBase = velYBase;
|
||||
obj_spawn_particles(&sMontyMoleRiseFromGroundParticles);
|
||||
#else
|
||||
s8 tempVelYBase = velYBase;
|
||||
s8 tempOffsetY = offsetY;
|
||||
|
||||
do {
|
||||
sMontyMoleRiseFromGroundParticles.offsetY = tempOffsetY;
|
||||
sMontyMoleRiseFromGroundParticles.velYBase = tempVelYBase;
|
||||
obj_spawn_particles(&sMontyMoleRiseFromGroundParticles);
|
||||
} while (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
struct ObjectHitbox sMrBlizzardHitbox = {
|
||||
/* interactType: */ INTERACT_MR_BLIZZARD,
|
||||
/* downOffset: */ 24,
|
||||
@@ -38,13 +37,34 @@ struct ObjectHitbox sMrBlizzardSnowballHitbox = {
|
||||
/* hurtboxHeight: */ 25,
|
||||
};
|
||||
|
||||
static void func_80306ED4(s8 arg0, s8 arg1, s8 arg2, s8 arg3, s8 arg4) {
|
||||
D_80331A00.count = arg0;
|
||||
D_80331A00.offsetY = arg1;
|
||||
D_80331A00.forwardVelBase = arg2;
|
||||
D_80331A00.velYBase = arg3;
|
||||
D_80331A00.sizeBase = arg4;
|
||||
/**
|
||||
* TODO: (Scrub C) monty_mole_spawn_dirt_particles, water_bomb_spawn_explode_particles, and
|
||||
* func_80306ED4 all have similar issues with their functions, none of which match legitimately.
|
||||
*/
|
||||
void func_80306ED4(s8 count, s8 offsetY, s8 forwardVelBase, s8 velYBase, s8 sizeBase) {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
D_80331A00.count = count;
|
||||
D_80331A00.offsetY = offsetY;
|
||||
D_80331A00.forwardVelBase = forwardVelBase;
|
||||
D_80331A00.velYBase = velYBase;
|
||||
D_80331A00.sizeBase = sizeBase;
|
||||
obj_spawn_particles(&D_80331A00);
|
||||
#else
|
||||
s8 tempSizeBase = sizeBase;
|
||||
s8 tempVelYBase = velYBase;
|
||||
s8 tempForwardVelBase = forwardVelBase;
|
||||
s8 tempOffsetY = offsetY;
|
||||
s8 tempCount = count;
|
||||
|
||||
do {
|
||||
D_80331A00.count = tempCount;
|
||||
D_80331A00.offsetY = tempOffsetY;
|
||||
D_80331A00.forwardVelBase = tempForwardVelBase;
|
||||
D_80331A00.velYBase = tempVelYBase;
|
||||
D_80331A00.sizeBase = tempSizeBase;
|
||||
obj_spawn_particles(&D_80331A00);
|
||||
} while (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void bhv_mr_blizzard_init(void) {
|
||||
|
||||
@@ -106,7 +106,7 @@ void piranha_plant_act_sleeping(void) {
|
||||
* to the biting state.
|
||||
*/
|
||||
void piranha_plant_act_woken_up(void) {
|
||||
#if BUGFIX_PIRANHA_PLANT_SLEEP_DAMAGE
|
||||
#if BUGFIX_PIRANHA_PLANT_SLEEP_DAMAGE || defined(VERSION_EU)
|
||||
/**
|
||||
* Make Piranha Plants damage the player while awake. This call is only
|
||||
* necessary in the US version because it is set to 3 by default and is
|
||||
|
||||
@@ -64,7 +64,7 @@ void bhv_pokey_body_part_update(void) {
|
||||
o->parentObj->oPokeyAliveBodyPartFlags | 1 << (o->oBehParams2ndByte - 1);
|
||||
|
||||
o->parentObj->oPokeyAliveBodyPartFlags =
|
||||
o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ 0xFFFFFFFF);
|
||||
o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ ~0);
|
||||
|
||||
o->oBehParams2ndByte -= 1;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void bhv_pokey_body_part_update(void) {
|
||||
}
|
||||
|
||||
o->parentObj->oPokeyAliveBodyPartFlags =
|
||||
o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ 0xFFFFFFFF);
|
||||
o->parentObj->oPokeyAliveBodyPartFlags & ((1 << o->oBehParams2ndByte) ^ ~0);
|
||||
} else if (o->parentObj->oPokeyHeadWasKilled) {
|
||||
obj_become_intangible();
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ void func_802F238C(void) {
|
||||
f32 sp24;
|
||||
|
||||
if (gMarioObject->platform == o) {
|
||||
sp24 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-o->oMoveAngleYaw)
|
||||
- (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-o->oMoveAngleYaw);
|
||||
sp24 = (gMarioObject->header.gfx.pos[2] - o->oPosZ) * coss(-1*o->oMoveAngleYaw)
|
||||
- (gMarioObject->header.gfx.pos[0] - o->oPosX) * sins(-1*o->oMoveAngleYaw);
|
||||
if (sp24 > 0)
|
||||
o->oAngleVelPitch += 0x10;
|
||||
else
|
||||
|
||||
@@ -100,7 +100,7 @@ static void ttc_moving_bar_act_extend(void) {
|
||||
&& o->oTTCMovingBarSpeed > -8.0f && o->oTTCMovingBarSpeed < 8.0f) {
|
||||
// Begin retracting
|
||||
o->oAction = TTC_MOVING_BAR_ACT_RETRACT;
|
||||
o->oTTCMovingBarSpeed = 0;
|
||||
o->oTTCMovingBarSpeed = 0.0f;
|
||||
} else {
|
||||
f32 accel;
|
||||
|
||||
|
||||
@@ -21,13 +21,6 @@ static s16 sTTCTreadmillSpeeds[] = {
|
||||
/* TTC_SPEED_STOPPED */ 0,
|
||||
};
|
||||
|
||||
// TODO: bss
|
||||
|
||||
/**
|
||||
* The treadmill that plays sounds and controls the others on random setting.
|
||||
*/
|
||||
struct Object *sMasterTreadmill;
|
||||
|
||||
extern s16 ttc_movtex_tris_big_surface_treadmill[];
|
||||
extern s16 ttc_movtex_tris_small_surface_treadmill[];
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ void ActionTuxiesMother2(void) {
|
||||
f32 sp24;
|
||||
UNUSED s32 unused;
|
||||
struct Object *sp1C = obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp24);
|
||||
UNUSED s32 unused2;
|
||||
|
||||
if (obj_find_nearby_held_actor(bhvUnused20E0, 1000.0f) != NULL) {
|
||||
if (o->oSubAction == 0) {
|
||||
set_obj_animation_and_sound_state(0);
|
||||
|
||||
@@ -1,102 +1,156 @@
|
||||
// tweester.c.inc
|
||||
/**
|
||||
* Behavior file for bhvTweester and bhvTweesterSandParticle
|
||||
* Tweester swaps between twhree action- an idle action, a chasing
|
||||
* Mario action, and an action that hides it. At certain times the
|
||||
* Tweester spawns the sand particles also in this file.
|
||||
*/
|
||||
|
||||
struct ObjectHitbox sTweesterHitbox = {
|
||||
/* interactType: */ INTERACT_TORNADO,
|
||||
/* downOffset: */ 0,
|
||||
/* interactType: */ INTERACT_TORNADO,
|
||||
/* downOffset: */ 0,
|
||||
/* damageOrCoinValue: */ 0,
|
||||
/* health: */ 0,
|
||||
/* numLootCoins: */ 0,
|
||||
/* radius: */ 1500,
|
||||
/* height: */ 4000,
|
||||
/* hurtboxRadius: */ 0,
|
||||
/* hurtboxHeight: */ 0,
|
||||
/* health: */ 0,
|
||||
/* numLootCoins: */ 0,
|
||||
/* radius: */ 1500,
|
||||
/* height: */ 4000,
|
||||
/* hurtboxRadius: */ 0,
|
||||
/* hurtboxHeight: */ 0,
|
||||
};
|
||||
|
||||
void func_802C231C(f32 a0) {
|
||||
s16 sp6 = 0x2C00;
|
||||
f32 sp0 = a0 * 0.4;
|
||||
o->header.gfx.scale[0] = (((coss(o->oTweesterUnkF4) + 1.0) * 0.5 * 0.3) + 1.0) * sp0;
|
||||
o->header.gfx.scale[1] = (((-coss(o->oTweesterUnkF4) + 1.0) * 0.5 * 0.5) + 0.5) * sp0;
|
||||
o->header.gfx.scale[2] = (((coss(o->oTweesterUnkF4) + 1.0) * 0.5 * 0.3) + 1.0) * sp0;
|
||||
o->oTweesterUnkF4 += 0x200;
|
||||
/**
|
||||
* Controls the scaling of the tweester as well as
|
||||
* its forward velocity.
|
||||
*/
|
||||
void tweester_scale_and_move(f32 preScale) {
|
||||
s16 dYaw = 0x2C00;
|
||||
f32 scale = preScale * 0.4;
|
||||
|
||||
o->header.gfx.scale[0]
|
||||
= (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale;
|
||||
o->header.gfx.scale[1]
|
||||
= ((-coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.5 + 0.5) * scale;
|
||||
o->header.gfx.scale[2]
|
||||
= (( coss(o->oTweesterScaleTimer) + 1.0) * 0.5 * 0.3 + 1.0) * scale;
|
||||
|
||||
o->oTweesterScaleTimer += 0x200;
|
||||
o->oForwardVel = 14.0f;
|
||||
o->oFaceAngleYaw += sp6;
|
||||
o->oFaceAngleYaw += dYaw;
|
||||
}
|
||||
|
||||
void ActionTweester0(void) {
|
||||
if (o->oSubAction == 0) {
|
||||
/**
|
||||
* Tweester's idle action. Basically stays in active until Mario enters a 1500
|
||||
* radius, at which point it appears and grows for 60 frames at which point it
|
||||
* it enters the chasing action.
|
||||
*/
|
||||
void tweester_act_idle(void) {
|
||||
if (o->oSubAction == TWEESTER_SUB_ACT_WAIT) {
|
||||
obj_become_tangible();
|
||||
obj_set_pos_to_home();
|
||||
obj_scale(0);
|
||||
o->oTweesterUnkF8 = 0;
|
||||
|
||||
// Hard to have any idea of this purpose, only set here.
|
||||
o->oTweesterUnused = 0;
|
||||
|
||||
// If Mario is within range, change to the growth sub-action.
|
||||
if (o->oDistanceToMario < 1500.0f)
|
||||
o->oSubAction++;
|
||||
|
||||
o->oTimer = 0;
|
||||
} else {
|
||||
PlaySound(SOUND_ENV_WIND1);
|
||||
func_802C231C(o->oTimer / 60.0f);
|
||||
tweester_scale_and_move(o->oTimer / 60.0f);
|
||||
if (o->oTimer > 59)
|
||||
o->oAction = 1;
|
||||
o->oAction = TWEESTER_ACT_CHASE;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTweester1(void) {
|
||||
f32 sp1C = o->oBehParams2ndByte * 0x64;
|
||||
o->oUnk1BC = obj_angle_to_home();
|
||||
/**
|
||||
* Action where the tweester "chases" Mario.
|
||||
* After Mario is twirling, then return home.
|
||||
*/
|
||||
void tweester_act_chase(void) {
|
||||
f32 activationRadius = o->oBehParams2ndByte * 100;
|
||||
|
||||
o->oAngleToHome = obj_angle_to_home();
|
||||
PlaySound(SOUND_ENV_WIND1);
|
||||
if (obj_lateral_dist_from_mario_to_home() < sp1C && o->oSubAction == 0) {
|
||||
|
||||
if (obj_lateral_dist_from_mario_to_home() < activationRadius
|
||||
&& o->oSubAction == TWEESTER_SUB_ACT_CHASE) {
|
||||
|
||||
o->oForwardVel = 20.0f;
|
||||
obj_rotate_yaw_toward(o->oAngleToMario, 0x200);
|
||||
print_debug_top_down_objectinfo("off ", 0);
|
||||
|
||||
if (gMarioStates->action == ACT_TWIRLING)
|
||||
o->oSubAction++;
|
||||
} else {
|
||||
o->oForwardVel = 20.0f;
|
||||
obj_rotate_yaw_toward(o->oUnk1BC, 0x200);
|
||||
obj_rotate_yaw_toward(o->oAngleToHome, 0x200);
|
||||
|
||||
if (obj_lateral_dist_to_home() < 200.0f)
|
||||
o->oAction = 2;
|
||||
o->oAction = TWEESTER_ACT_HIDE;
|
||||
}
|
||||
|
||||
if (o->oDistanceToMario > 3000.0f)
|
||||
o->oAction = 2;
|
||||
o->oAction = TWEESTER_ACT_HIDE;
|
||||
|
||||
obj_update_floor_and_walls();
|
||||
if (o->oMoveFlags & 0x200)
|
||||
if (o->oMoveFlags & OBJ_MOVE_HIT_WALL)
|
||||
o->oMoveAngleYaw = o->oWallAngle;
|
||||
|
||||
obj_move_standard(60);
|
||||
func_802C231C(1.0f);
|
||||
spawn_object(o, MODEL_SAND_DUST, bhvTornadoSandParticle);
|
||||
tweester_scale_and_move(1.0f);
|
||||
spawn_object(o, MODEL_SAND_DUST, bhvTweesterSandParticle);
|
||||
}
|
||||
|
||||
void ActionTweester2(void) {
|
||||
f32 sp1C = 60.0f - o->oTimer;
|
||||
if (sp1C >= 0.0f)
|
||||
func_802C231C(sp1C / 60.0f);
|
||||
/**
|
||||
* Shrinks the tweester until it is invisible, then returns to the idle
|
||||
* action if Mario is 2500 units away or 12 seconds passed.
|
||||
*/
|
||||
void tweester_act_hide(void) {
|
||||
f32 shrinkTimer = 60.0f - o->oTimer;
|
||||
|
||||
if (shrinkTimer >= 0.0f)
|
||||
tweester_scale_and_move(shrinkTimer / 60.0f);
|
||||
else {
|
||||
obj_become_intangible();
|
||||
if (obj_lateral_dist_from_mario_to_home() > 2500.0f)
|
||||
o->oAction = 0;
|
||||
o->oAction = TWEESTER_ACT_IDLE;
|
||||
if (o->oTimer > 360)
|
||||
o->oAction = 0;
|
||||
o->oAction = TWEESTER_ACT_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
void (*sTweesterActions[])(void) = { ActionTweester0, ActionTweester1, ActionTweester2 };
|
||||
// Array of Tweester action functions.
|
||||
void (*sTweesterActions[])(void) = { tweester_act_idle, tweester_act_chase, tweester_act_hide };
|
||||
|
||||
/**
|
||||
* Loop behavior for Tweester.
|
||||
* Loads the hitbox and calls its relevant action.
|
||||
*/
|
||||
void bhv_tweester_loop(void) {
|
||||
set_object_hitbox(o, &sTweesterHitbox);
|
||||
obj_call_action_function(sTweesterActions);
|
||||
o->oInteractStatus = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop behavior for the particles Tweesters create.
|
||||
* Floats upwards semi-randomly.
|
||||
*/
|
||||
void bhv_tweester_sand_particle_loop(void) {
|
||||
o->oMoveAngleYaw += 0x3700;
|
||||
o->oForwardVel += 15.0f;
|
||||
o->oPosY += 22.0f;
|
||||
|
||||
obj_scale(RandomFloat() + 1.0);
|
||||
|
||||
if (o->oTimer == 0) {
|
||||
translate_object_xz_random(o, 100.0f);
|
||||
o->oFaceAnglePitch = RandomU16();
|
||||
o->oFaceAngleYaw = RandomU16();
|
||||
}
|
||||
|
||||
if (o->oTimer > 15)
|
||||
mark_object_for_deletion(o);
|
||||
}
|
||||
@@ -96,12 +96,28 @@ void bhv_water_bomb_spawner_update(void) {
|
||||
|
||||
/**
|
||||
* Spawn particles when the water bomb explodes.
|
||||
*
|
||||
* TODO: (Scrub C) monty_mole_spawn_dirt_particles, water_bomb_spawn_explode_particles, and
|
||||
* func_80306ED4 all have similar issues with their functions, none of which match legitimately.
|
||||
*/
|
||||
static void water_bomb_spawn_explode_particles(s8 offsetY, s8 forwardVelRange, s8 velYBase) {
|
||||
void water_bomb_spawn_explode_particles(s8 offsetY, s8 forwardVelRange, s8 velYBase) {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
sWaterBombExplodeParticles.offsetY = offsetY;
|
||||
sWaterBombExplodeParticles.forwardVelRange = forwardVelRange;
|
||||
sWaterBombExplodeParticles.velYBase = velYBase;
|
||||
obj_spawn_particles(&sWaterBombExplodeParticles);
|
||||
#else
|
||||
s8 tempVelYBase = velYBase;
|
||||
s8 tempForwardVelRange = forwardVelRange;
|
||||
s8 tempOffsetY = offsetY;
|
||||
|
||||
do {
|
||||
sWaterBombExplodeParticles.offsetY = tempOffsetY;
|
||||
sWaterBombExplodeParticles.forwardVelRange = tempForwardVelRange;
|
||||
sWaterBombExplodeParticles.velYBase = tempVelYBase;
|
||||
obj_spawn_particles(&sWaterBombExplodeParticles);
|
||||
} while (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,7 +115,7 @@ void bhv_wiggler_body_part_update(void) {
|
||||
/**
|
||||
* Initialize the segment data and spawn the body part objects.
|
||||
*/
|
||||
static void wiggler_init_segments(void) {
|
||||
void wiggler_init_segments(void) {
|
||||
s32 i;
|
||||
struct ChainSegment *segments;
|
||||
struct Object *bodyPart;
|
||||
@@ -127,14 +127,14 @@ static void wiggler_init_segments(void) {
|
||||
// represents body part i.
|
||||
o->oWigglerSegments = segments;
|
||||
for (i = 0; i <= 3; i++) {
|
||||
chain_segment_init(&segments[i]);
|
||||
chain_segment_init(segments + i);
|
||||
|
||||
segments[i].posX = o->oPosX;
|
||||
segments[i].posY = o->oPosY;
|
||||
segments[i].posZ = o->oPosZ;
|
||||
(segments + i)->posX = o->oPosX;
|
||||
(segments + i)->posY = o->oPosY;
|
||||
(segments + i)->posZ = o->oPosZ;
|
||||
|
||||
segments[i].pitch = o->oFaceAnglePitch;
|
||||
segments[i].yaw = o->oFaceAngleYaw;
|
||||
(segments + i)->pitch = o->oFaceAnglePitch;
|
||||
(segments + i)->yaw = o->oFaceAngleYaw;
|
||||
}
|
||||
|
||||
o->header.gfx.unk38.animFrame = -1;
|
||||
@@ -152,6 +152,10 @@ static void wiggler_init_segments(void) {
|
||||
o->oAction = WIGGLER_ACT_WALK;
|
||||
obj_unhide();
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU) || defined(AVOID_UB)
|
||||
o->oHealth = 4; // This fixes Wiggler reading UB on his first frame of his acceleration, as his health is not set.
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +165,7 @@ static void wiggler_init_segments(void) {
|
||||
* for a body part to get stuck on geometry and separate from the rest of the
|
||||
* body.
|
||||
*/
|
||||
static void wiggler_update_segments(void) {
|
||||
void wiggler_update_segments(void) {
|
||||
struct ChainSegment *prevBodyPart;
|
||||
struct ChainSegment *bodyPart;
|
||||
f32 dx;
|
||||
@@ -230,8 +234,8 @@ static void wiggler_act_walk(void) {
|
||||
} else {
|
||||
//! Every object's health is initially 2048, and wiggler's doesn't change
|
||||
// to 4 until after this runs the first time. It indexes out of bounds
|
||||
// and uses the value 113762.3 for one frame on US. This is fixed down
|
||||
// below in bhv_wiggler_update if AVOID_UB is defined.
|
||||
// and uses the value 113762.3 for one frame on US. This is fixed up
|
||||
// in wiggler_init_segments if AVOID_UB is defined.
|
||||
obj_forward_vel_approach(sWigglerSpeeds[o->oHealth - 1], 1.0f);
|
||||
|
||||
if (o->oWigglerWalkAwayFromWallTimer != 0) {
|
||||
@@ -280,7 +284,6 @@ static void wiggler_act_walk(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Squish and unsquish, then show text and enter either the walking or shrinking
|
||||
* action.
|
||||
@@ -399,10 +402,6 @@ void bhv_wiggler_update(void) {
|
||||
// PARTIAL_UPDATE
|
||||
|
||||
if (o->oAction == WIGGLER_ACT_UNINITIALIZED) {
|
||||
#ifdef AVOID_UB
|
||||
// See comment in wiggler_act_walk
|
||||
o->oHealth = 4;
|
||||
#endif
|
||||
wiggler_init_segments();
|
||||
} else {
|
||||
if (o->oAction == WIGGLER_ACT_FALL_THROUGH_FLOOR) {
|
||||
|
||||
+585
-426
File diff suppressed because it is too large.
Load diff
+5
-11
@@ -339,22 +339,12 @@ struct HandheldShakePoint
|
||||
/*0x08*/ Vec3s point;
|
||||
}; // size = 0x10
|
||||
|
||||
// Camera command procedures are marked as returning s32, but none of them
|
||||
// actually return a value. This causes undefined behavior, which we'd rather
|
||||
// avoid on modern GCC. Hence, typedef. Interestingly, the void vs s32
|
||||
// difference doesn't affect -g codegen, only -O2.
|
||||
#ifdef AVOID_UB
|
||||
typedef void CmdRet;
|
||||
#else
|
||||
typedef s32 CmdRet;
|
||||
#endif
|
||||
|
||||
// These are the same type, but the name that is used depends on context.
|
||||
/**
|
||||
* A function that is called by CameraTriggers and cutscene shots.
|
||||
* These are concurrent: multiple CameraEvents can occur on the same frame.
|
||||
*/
|
||||
typedef CmdRet (*CameraEvent)(struct Camera *c);
|
||||
typedef BAD_RETURN(s32) (*CameraEvent)(struct Camera *c);
|
||||
/**
|
||||
* The same type as a CameraEvent, but because these are generally longer, and happen in sequential
|
||||
* order, they're are called "shots," a term taken from cinematography.
|
||||
@@ -667,6 +657,10 @@ struct LakituState
|
||||
// bss order hack to not affect BSS order. if possible, remove me, but it will be hard to match otherwise
|
||||
#ifndef INCLUDED_FROM_CAMERA_C
|
||||
// BSS
|
||||
extern s16 sSelectionFlags;
|
||||
extern s16 sCameraSideCFlags;
|
||||
extern s16 sCameraSoundFlags;
|
||||
extern u16 sCButtonsPressed;
|
||||
extern struct PlayerCameraState gPlayerCameraState[2];
|
||||
extern struct LakituState gLakituState;
|
||||
extern s16 gCameraMovementFlags;
|
||||
|
||||
+32
-28
@@ -8,33 +8,7 @@
|
||||
|
||||
s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char *fmt, va_list args);
|
||||
|
||||
const char *const gCauseDesc[18] = {
|
||||
"Interrupt",
|
||||
"TLB modification",
|
||||
"TLB exception on load",
|
||||
"TLB exception on store",
|
||||
"Address error on load",
|
||||
"Address error on store",
|
||||
"Bus error on inst.",
|
||||
"Bus error on data",
|
||||
"System call exception",
|
||||
"Breakpoint exception",
|
||||
"Reserved instruction",
|
||||
"Coprocessor unusable",
|
||||
"Arithmetic overflow",
|
||||
"Trap exception",
|
||||
"Virtual coherency on inst.",
|
||||
"Floating point exception",
|
||||
"Watchpoint exception",
|
||||
"Virtual coherency on data",
|
||||
};
|
||||
|
||||
const char *const gFpcsrDesc[6] = {
|
||||
"Unimplemented operation", "Invalid operation", "Division by zero", "Overflow", "Underflow",
|
||||
"Inexact operation",
|
||||
};
|
||||
|
||||
const u8 gCrashScreenCharToGlyph[128] = {
|
||||
u8 gCrashScreenCharToGlyph[128] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, 43, -1, -1, 37, 38, -1, 42,
|
||||
-1, 39, 44, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 36, -1, -1, -1, -1, 40, -1, 10,
|
||||
@@ -44,7 +18,7 @@ const u8 gCrashScreenCharToGlyph[128] = {
|
||||
};
|
||||
|
||||
// Bit-compressed font. '#' = 1, '.' = 0
|
||||
const u32 gCrashScreenFont[7 * 9] = {
|
||||
u32 gCrashScreenFont[7 * 9 + 1] = {
|
||||
0x70871c30, // .###.. ..#... .###.. .###.. ..##.. ..
|
||||
0x8988a250, // #...#. .##... #...#. #...#. .#.#.. ..
|
||||
0x88808290, // #...#. ..#... ....#. ....#. #..#.. ..
|
||||
@@ -116,8 +90,38 @@ const u32 gCrashScreenFont[7 * 9] = {
|
||||
0x20821000, // ..#... ..#... ..#... .#.... ...... ..
|
||||
0x00022200, // ...... ...... ..#... #...#. ...... ..
|
||||
0x20800020, // ..#... ..#... ...... ...... ..#... ..
|
||||
0x00000000,
|
||||
};
|
||||
|
||||
|
||||
char *gCauseDesc[18] = {
|
||||
"Interrupt",
|
||||
"TLB modification",
|
||||
"TLB exception on load",
|
||||
"TLB exception on store",
|
||||
"Address error on load",
|
||||
"Address error on store",
|
||||
"Bus error on inst.",
|
||||
"Bus error on data",
|
||||
"System call exception",
|
||||
"Breakpoint exception",
|
||||
"Reserved instruction",
|
||||
"Coprocessor unusable",
|
||||
"Arithmetic overflow",
|
||||
"Trap exception",
|
||||
"Virtual coherency on inst.",
|
||||
"Floating point exception",
|
||||
"Watchpoint exception",
|
||||
"Virtual coherency on data",
|
||||
};
|
||||
|
||||
char *gFpcsrDesc[6] = {
|
||||
"Unimplemented operation", "Invalid operation", "Division by zero", "Overflow", "Underflow",
|
||||
"Inexact operation",
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern u64 osClockRate;
|
||||
|
||||
struct {
|
||||
|
||||
+3
-2
@@ -11,7 +11,6 @@
|
||||
#include "main.h"
|
||||
#include "debug.h"
|
||||
#include "object_list_processor.h"
|
||||
#include "room.h"
|
||||
#include "behavior_data.h"
|
||||
|
||||
#define DEBUG_INFO_NOFLAGS (0 << 0)
|
||||
@@ -205,7 +204,7 @@ void print_mapinfo(void) {
|
||||
struct Surface *pfloor;
|
||||
UNUSED f32 bgY;
|
||||
UNUSED f32 water;
|
||||
// s32 area;
|
||||
UNUSED s32 area;
|
||||
// s32 angY;
|
||||
//
|
||||
// angY = gCurrentObject->oMoveAngleYaw / 182.044000;
|
||||
@@ -523,6 +522,7 @@ void try_do_mario_debug_object_spawn(void) {
|
||||
|
||||
// TODO: figure out what this is
|
||||
static void Unknown802CA8B4(void) {
|
||||
#ifndef VERSION_EU
|
||||
if (gCurrentObject->oMoveFlags & OBJ_MOVE_LANDED) {
|
||||
print_debug_top_down_objectinfo("BOUND %x", gCurrentObject->oMoveFlags);
|
||||
}
|
||||
@@ -550,6 +550,7 @@ static void Unknown802CA8B4(void) {
|
||||
if (gCurrentObject->oMoveFlags & OBJ_MOVE_8) {
|
||||
print_debug_top_down_objectinfo("OUT SCOPE %x", gCurrentObject->oMoveFlags);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// unused, what is this?
|
||||
|
||||
+10
-3
@@ -175,9 +175,17 @@ void create_task_structure(void) {
|
||||
gGfxSPTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE;
|
||||
gGfxSPTask->task.t.dram_stack = (u64 *) gGfxSPTaskStack;
|
||||
gGfxSPTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8;
|
||||
#ifdef VERSION_EU
|
||||
// terrible hack
|
||||
gGfxSPTask->task.t.output_buff =
|
||||
(u64 *)((u8 *) gGfxSPTaskOutputBuffer - 0x670 + 0x280);
|
||||
gGfxSPTask->task.t.output_buff_size =
|
||||
(u64 *)((u8 *) gGfxSPTaskOutputBuffer+ 0x280 + 0x17790);
|
||||
#else
|
||||
gGfxSPTask->task.t.output_buff = gGfxSPTaskOutputBuffer;
|
||||
gGfxSPTask->task.t.output_buff_size =
|
||||
(u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer));
|
||||
#endif
|
||||
gGfxSPTask->task.t.data_ptr = (u64 *) &gGfxPool->buffer;
|
||||
gGfxSPTask->task.t.data_size = entries * sizeof(Gfx);
|
||||
gGfxSPTask->task.t.yield_data_ptr = (u64 *) gGfxSPTaskYieldBuffer;
|
||||
@@ -223,9 +231,8 @@ void func_80247D84(void) {
|
||||
sp18 += D_8032C648++ * (SCREEN_WIDTH / 4);
|
||||
|
||||
for (sp24 = 0; sp24 < ((SCREEN_HEIGHT / 16) + 1); sp24++) {
|
||||
for (sp20 = 0; sp20 < (SCREEN_WIDTH / 4); sp20++) {
|
||||
*sp18++ = 0;
|
||||
}
|
||||
// Must be on one line to match -O2
|
||||
for (sp20 = 0; sp20 < (SCREEN_WIDTH / 4); sp20++) *sp18++ = 0;
|
||||
sp18 += ((SCREEN_WIDTH / 4) * 14);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-39
@@ -381,54 +381,30 @@ void envfx_bubbles_update_switch(s32 mode, Vec3s camTo, Vec3s vertex1, Vec3s ver
|
||||
switch (mode) {
|
||||
case ENVFX_FLOWERS:
|
||||
envfx_update_flower(camTo);
|
||||
vertex1[0] = 50;
|
||||
vertex1[1] = 0;
|
||||
vertex1[2] = 0;
|
||||
vertex2[0] = 0;
|
||||
vertex2[1] = 75;
|
||||
vertex2[2] = 0;
|
||||
vertex3[0] = -50;
|
||||
vertex3[1] = 0;
|
||||
vertex3[2] = 0;
|
||||
vertex1[0] = 50; vertex1[1] = 0; vertex1[2] = 0;
|
||||
vertex2[0] = 0; vertex2[1] = 75; vertex2[2] = 0;
|
||||
vertex3[0] = -50; vertex3[1] = 0; vertex3[2] = 0;
|
||||
break;
|
||||
|
||||
case ENVFX_LAVA_BUBBLES:
|
||||
envfx_update_lava(camTo);
|
||||
vertex1[0] = 100;
|
||||
vertex1[1] = 0;
|
||||
vertex1[2] = 0;
|
||||
vertex2[0] = 0;
|
||||
vertex2[1] = 150;
|
||||
vertex2[2] = 0;
|
||||
vertex3[0] = -100;
|
||||
vertex3[1] = 0;
|
||||
vertex3[2] = 0;
|
||||
vertex1[0] = 100; vertex1[1] = 0; vertex1[2] = 0;
|
||||
vertex2[0] = 0; vertex2[1] = 150; vertex2[2] = 0;
|
||||
vertex3[0] = -100; vertex3[1] = 0; vertex3[2] = 0;
|
||||
break;
|
||||
|
||||
case ENVFX_WHIRLPOOL_BUBBLES:
|
||||
envfx_update_whirlpool();
|
||||
vertex1[0] = 40;
|
||||
vertex1[1] = 0;
|
||||
vertex1[2] = 0;
|
||||
vertex2[0] = 0;
|
||||
vertex2[1] = 60;
|
||||
vertex2[2] = 0;
|
||||
vertex3[0] = -40;
|
||||
vertex3[1] = 0;
|
||||
vertex3[2] = 0;
|
||||
vertex1[0] = 40; vertex1[1] = 0; vertex1[2] = 0;
|
||||
vertex2[0] = 0; vertex2[1] = 60; vertex2[2] = 0;
|
||||
vertex3[0] = -40; vertex3[1] = 0; vertex3[2] = 0;
|
||||
break;
|
||||
|
||||
case ENVFX_JETSTREAM_BUBBLES:
|
||||
envfx_update_jetstream();
|
||||
vertex1[0] = 40;
|
||||
vertex1[1] = 0;
|
||||
vertex1[2] = 0;
|
||||
vertex2[0] = 0;
|
||||
vertex2[1] = 60;
|
||||
vertex2[2] = 0;
|
||||
vertex3[0] = -40;
|
||||
vertex3[1] = 0;
|
||||
vertex3[2] = 0;
|
||||
vertex1[0] = 40; vertex1[1] = 0; vertex1[2] = 0;
|
||||
vertex2[0] = 0; vertex2[1] = 60; vertex2[2] = 0;
|
||||
vertex3[0] = -40; vertex3[1] = 0; vertex3[2] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -441,7 +417,7 @@ void envfx_bubbles_update_switch(s32 mode, Vec3s camTo, Vec3s vertex1, Vec3s ver
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
void append_bubble_vertex_buffer(Gfx *gfx, s32 index, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3,
|
||||
Vtx *template);
|
||||
GLOBAL_ASM("asm/non_matchings/append_bubble_vertex_buffer_eu.s")
|
||||
GLOBAL_ASM("asm/non_matchings/eu/append_bubble_vertex_buffer.s")
|
||||
#else
|
||||
void append_bubble_vertex_buffer(Gfx *gfx, s32 index, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3,
|
||||
Vtx *template) {
|
||||
@@ -518,8 +494,8 @@ Gfx *envfx_update_bubble_particles(s32 mode, UNUSED Vec3s marioPos, Vec3s camFro
|
||||
|
||||
Gfx *gfxStart;
|
||||
|
||||
gfxStart = alloc_display_list(
|
||||
((sBubbleParticleMaxCount / 5) * 10 + sBubbleParticleMaxCount + 3) * sizeof(Gfx));
|
||||
gfxStart = alloc_display_list(((sBubbleParticleMaxCount / 5) * 10 + sBubbleParticleMaxCount + 3)
|
||||
* sizeof(Gfx));
|
||||
if (gfxStart == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+3
-11
@@ -219,11 +219,7 @@ void envfx_update_snow_normal(s32 snowCylinderX, s32 snowCylinderY, s32 snowCyli
|
||||
(gEnvFxBuffer + i)->isAlive = 1;
|
||||
} else {
|
||||
(gEnvFxBuffer + i)->xPos += RandomFloat() * 2 - 1.0f + (s16)(deltaX / 1.2);
|
||||
#ifdef VERSION_EU
|
||||
(gEnvFxBuffer + i)->yPos -= (s16)(deltaY * 0.8) + 2;
|
||||
#else
|
||||
(gEnvFxBuffer + i)->yPos -= -(s16)(deltaY * 0.8) + 2;
|
||||
#endif
|
||||
(gEnvFxBuffer + i)->yPos -= 2 -(s16)(deltaY * 0.8);
|
||||
(gEnvFxBuffer + i)->zPos += RandomFloat() * 2 - 1.0f + (s16)(deltaZ / 1.2);
|
||||
}
|
||||
}
|
||||
@@ -257,11 +253,7 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy
|
||||
(gEnvFxBuffer + i)->isAlive = 1;
|
||||
} else {
|
||||
(gEnvFxBuffer + i)->xPos += RandomFloat() * 2 - 1.0f + (s16)(deltaX / 1.2) + 20.0f;
|
||||
#ifdef VERSION_EU
|
||||
(gEnvFxBuffer + i)->yPos -= (s16)(deltaY * 0.8) + 5;
|
||||
#else
|
||||
(gEnvFxBuffer + i)->yPos -= -(s16)(deltaY * 0.8) + 5;
|
||||
#endif
|
||||
(gEnvFxBuffer + i)->yPos -= 5 -(s16)(deltaY * 0.8);
|
||||
(gEnvFxBuffer + i)->zPos += RandomFloat() * 2 - 1.0f + (s16)(deltaZ / 1.2);
|
||||
}
|
||||
}
|
||||
@@ -351,7 +343,7 @@ void rotate_triangle_vertices(Vec3s vertex1, Vec3s vertex2, Vec3s vertex3, s16 p
|
||||
*/
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
void append_snowflake_vertex_buffer(Gfx *gfx, s32 index, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3);
|
||||
GLOBAL_ASM("asm/non_matchings/append_snowflake_vertex_buffer_eu.s")
|
||||
GLOBAL_ASM("asm/non_matchings/eu/append_snowflake_vertex_buffer.s")
|
||||
#else
|
||||
void append_snowflake_vertex_buffer(Gfx *gfx, s32 index, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3) {
|
||||
s32 i = 0;
|
||||
|
||||
+6
-7
@@ -21,8 +21,14 @@
|
||||
// FIXME: I'm not sure all of these variables belong in this file, but I don't
|
||||
// know of a good way to split them
|
||||
struct Controller gControllers[3];
|
||||
struct SPTask *gGfxSPTask;
|
||||
Gfx *gDisplayListHead;
|
||||
u8 *gGfxPoolEnd;
|
||||
struct GfxPool *gGfxPool;
|
||||
OSContStatus gControllerStatuses[4];
|
||||
OSContPad gControllerPads[4];
|
||||
u8 gControllerBits;
|
||||
s8 gEepromProbe;
|
||||
OSMesgQueue gGameVblankQueue;
|
||||
OSMesgQueue D_80339CB8;
|
||||
OSMesg D_80339CD0;
|
||||
@@ -32,13 +38,6 @@ uintptr_t gPhysicalFrameBuffers[3];
|
||||
uintptr_t gPhysicalZBuffer;
|
||||
void *D_80339CF0;
|
||||
void *D_80339CF4;
|
||||
struct SPTask *gGfxSPTask;
|
||||
Gfx *gDisplayListHead;
|
||||
u8 *gGfxPoolEnd;
|
||||
struct GfxPool *gGfxPool;
|
||||
u8 gControllerBits;
|
||||
s8 gEepromProbe;
|
||||
|
||||
struct MarioAnimation D_80339D10;
|
||||
struct MarioAnimation gDemo;
|
||||
UNUSED u8 filler80339D30[0x90];
|
||||
|
||||
+4
-1
@@ -210,8 +210,11 @@ Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, UNUSED f3
|
||||
displayListHead = displayList;
|
||||
|
||||
generatedNode->fnNode.node.flags = (generatedNode->fnNode.node.flags & 0xFF) | 0x100;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
gSPDisplayList(displayListHead++, dl_cake_end_screen);
|
||||
#else
|
||||
gSPDisplayList(displayListHead++, dl_proj_mtx_fullscreen);
|
||||
#endif
|
||||
#ifdef VERSION_EU
|
||||
switch (eu_get_language()) {
|
||||
case LANGUAGE_ENGLISH:
|
||||
|
||||
@@ -22,4 +22,15 @@ extern Gfx *geo_exec_flying_carpet_timer_update(s32 callContext, struct GraphNod
|
||||
extern Gfx *geo_exec_flying_carpet_create(s32 callContext, struct GraphNode *node, f32 mtx[4][4]);
|
||||
extern Gfx *geo_exec_cake_end_screen(s32 callContext, struct GraphNode *node, f32 mtx[4][4]);
|
||||
|
||||
#define gLoadBlockTexture(dl, width, height, format, image) \
|
||||
{ \
|
||||
gDPSetTextureImage((dl), (format), G_IM_SIZ_16b, 1, (image)); \
|
||||
gDPTileSync((dl)); \
|
||||
gDPSetTile((dl), (format), G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, \
|
||||
G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD); \
|
||||
gDPLoadSync((dl)); \
|
||||
gDPLoadBlock((dl), G_TX_LOADTILE, 0, 0, (width) * (height) - 1, CALC_DXT((width), G_IM_SIZ_16b_BYTES)) \
|
||||
}
|
||||
|
||||
|
||||
#endif /* _TRANSPARENT_TEXTURE_H */
|
||||
+24
-34
@@ -35,6 +35,10 @@ u16 gDialogColorFadeTimer;
|
||||
s8 gLastDialogLineNum;
|
||||
s32 gDialogVariable;
|
||||
u16 gDialogTextAlpha;
|
||||
#ifdef VERSION_EU
|
||||
s16 gDialogX; // D_8032F69A
|
||||
s16 gDialogY; // D_8032F69C
|
||||
#endif
|
||||
s16 gCutsceneMsgXOffset;
|
||||
s16 gCutsceneMsgYOffset;
|
||||
s8 gRedCoinsCollected;
|
||||
@@ -106,18 +110,15 @@ s8 gDialogBoxType = DIALOG_TYPE_ROTATE;
|
||||
s16 gDialogID = -1;
|
||||
s16 gLastDialogPageStrPos = 0;
|
||||
s16 gDialogTextPos = 0; // EU: D_802FD64C
|
||||
#ifdef VERSION_EU
|
||||
s32 gInGameLanguage = 0;
|
||||
#endif
|
||||
s8 gDialogLineNum = 1;
|
||||
s8 gLastDialogResponse = 0;
|
||||
u8 gMenuHoldKeyIndex = 0;
|
||||
u8 gMenuHoldKeyTimer = 0;
|
||||
s32 gDialogResponse = 0;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
// TODO: where do these belong?
|
||||
s16 gDialogX; // D_8032F69A
|
||||
s16 gDialogY; // D_8032F69C
|
||||
s32 gInGameLanguage;
|
||||
#endif
|
||||
|
||||
void create_dl_identity_matrix(void) {
|
||||
Mtx *matrix = (Mtx *) alloc_display_list(sizeof(Mtx));
|
||||
@@ -126,26 +127,10 @@ void create_dl_identity_matrix(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
matrix->m[0][0] = 0x00010000;
|
||||
matrix->m[1][0] = 0x00000000;
|
||||
matrix->m[2][0] = 0x00000000;
|
||||
matrix->m[3][0] = 0x00000000;
|
||||
|
||||
matrix->m[0][1] = 0x00000000;
|
||||
matrix->m[1][1] = 0x00010000;
|
||||
matrix->m[2][1] = 0x00000000;
|
||||
matrix->m[3][1] = 0x00000000;
|
||||
|
||||
matrix->m[0][2] = 0x00000001;
|
||||
matrix->m[1][2] = 0x00000000;
|
||||
matrix->m[2][2] = 0x00000000;
|
||||
matrix->m[3][2] = 0x00000000;
|
||||
|
||||
matrix->m[0][3] = 0x00000000;
|
||||
matrix->m[1][3] = 0x00000001;
|
||||
matrix->m[2][3] = 0x00000000;
|
||||
matrix->m[3][3] = 0x00000000;
|
||||
|
||||
matrix->m[0][0] = 0x00010000; matrix->m[1][0] = 0x00000000; matrix->m[2][0] = 0x00000000; matrix->m[3][0] = 0x00000000;
|
||||
matrix->m[0][1] = 0x00000000; matrix->m[1][1] = 0x00010000; matrix->m[2][1] = 0x00000000; matrix->m[3][1] = 0x00000000;
|
||||
matrix->m[0][2] = 0x00000001; matrix->m[1][2] = 0x00000000; matrix->m[2][2] = 0x00000000; matrix->m[3][2] = 0x00000000;
|
||||
matrix->m[0][3] = 0x00000000; matrix->m[1][3] = 0x00000001; matrix->m[2][3] = 0x00000000; matrix->m[3][3] = 0x00000000;
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
}
|
||||
@@ -877,8 +862,7 @@ void int_to_str(s32 num, u8 *dst) {
|
||||
s8 pos = 0;
|
||||
|
||||
if (num > 999) {
|
||||
dst[0] = 0x00;
|
||||
dst[1] = DIALOG_CHAR_TERMINATOR;
|
||||
dst[0] = 0x00; dst[1] = DIALOG_CHAR_TERMINATOR;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1196,7 @@ u32 ensure_nonnegative(s16 value) {
|
||||
#if defined(VERSION_EU) && !defined(NON_MATCHING)
|
||||
// TODO: EU is not quite matching
|
||||
void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 lowerBound);
|
||||
GLOBAL_ASM("asm/non_matchings/handle_dialog_text_and_pages_eu.s")
|
||||
GLOBAL_ASM("asm/non_matchings/eu/handle_dialog_text_and_pages.s")
|
||||
#else
|
||||
#ifdef VERSION_JP
|
||||
void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog)
|
||||
@@ -1833,9 +1817,15 @@ void render_dialog_entries(void) {
|
||||
if (gLastDialogPageStrPos == -1 && gLastDialogResponse == 1) {
|
||||
render_dialog_triangle_choice();
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#undef BORDER_HEIGHT
|
||||
#define BORDER_HEIGHT 8
|
||||
#endif
|
||||
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 2, 2, SCREEN_WIDTH - BORDER_HEIGHT/2, SCREEN_HEIGHT - BORDER_HEIGHT/2);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#undef BORDER_HEIGHT
|
||||
#define BORDER_HEIGHT 1
|
||||
#endif
|
||||
if (gLastDialogPageStrPos != -1 && gDialogBoxState == DIALOG_STATE_VERTICAL) {
|
||||
render_dialog_string_color(dialog->linesPerBox);
|
||||
}
|
||||
@@ -1943,11 +1933,11 @@ void do_cutscene_handler(void) {
|
||||
break;
|
||||
case LANGUAGE_FRENCH:
|
||||
x = get_str_x_pos_from_center(gCutsceneMsgXOffset, gEndCutsceneStringsFr[gCutsceneMsgIndex], 10.0f);
|
||||
print_generic_string(x, 240 - gCutsceneMsgYOffset, gEndCutsceneStringsFr[gCutsceneMsgIndex + 8]);
|
||||
print_generic_string(x, 240 - gCutsceneMsgYOffset, gEndCutsceneStringsFr[gCutsceneMsgIndex]);
|
||||
break;
|
||||
case LANGUAGE_GERMAN:
|
||||
x = get_str_x_pos_from_center(gCutsceneMsgXOffset, gEndCutsceneStringsDe[gCutsceneMsgIndex], 10.0f);
|
||||
print_generic_string(x, 240 - gCutsceneMsgYOffset, gEndCutsceneStringsDe[gCutsceneMsgIndex + 16]);
|
||||
print_generic_string(x, 240 - gCutsceneMsgYOffset, gEndCutsceneStringsDe[gCutsceneMsgIndex]);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
@@ -2806,7 +2796,7 @@ void render_course_complete_lvl_info_and_hud_str(void) {
|
||||
u8 textCatch[] = { TEXT_CATCH };
|
||||
u8 textClear[] = { TEXT_CLEAR };
|
||||
#elif defined(VERSION_EU)
|
||||
UNUSED u8 textClear[] = { TEXT_CLEAR }; // unused in EU
|
||||
UNUSED u8 textCatch[] = { TEXT_CATCH }; // unused in EU
|
||||
u8 textSymStar[] = { GLYPH_STAR, GLYPH_SPACE };
|
||||
#define textCourse gTextCourseArr[gInGameLanguage]
|
||||
#else
|
||||
|
||||
@@ -273,9 +273,12 @@ void mario_drop_held_object(struct MarioState *m) {
|
||||
|
||||
set_object_held_state(m->heldObj, bhvCarrySomething4);
|
||||
|
||||
m->heldObj->oPosX = m->marioBodyState->unk18[0];
|
||||
// ! When dropping an object instead of throwing it, it will be put at Mario's
|
||||
// y-positon instead of the HOLP's y-position. This fact is often exploited when
|
||||
// cloning objects.
|
||||
m->heldObj->oPosX = m->marioBodyState->heldObjLastPosition[0];
|
||||
m->heldObj->oPosY = m->pos[1];
|
||||
m->heldObj->oPosZ = m->marioBodyState->unk18[2];
|
||||
m->heldObj->oPosZ = m->marioBodyState->heldObjLastPosition[2];
|
||||
|
||||
m->heldObj->oMoveAngleYaw = m->faceAngle[1];
|
||||
|
||||
@@ -291,9 +294,9 @@ void mario_throw_held_object(struct MarioState *m) {
|
||||
|
||||
set_object_held_state(m->heldObj, bhvCarrySomething5);
|
||||
|
||||
m->heldObj->oPosX = m->marioBodyState->unk18[0] + 32.0f * sins(m->faceAngle[1]);
|
||||
m->heldObj->oPosY = m->marioBodyState->unk18[1];
|
||||
m->heldObj->oPosZ = m->marioBodyState->unk18[2] + 32.0f * coss(m->faceAngle[1]);
|
||||
m->heldObj->oPosX = m->marioBodyState->heldObjLastPosition[0] + 32.0f * sins(m->faceAngle[1]);
|
||||
m->heldObj->oPosY = m->marioBodyState->heldObjLastPosition[1];
|
||||
m->heldObj->oPosZ = m->marioBodyState->heldObjLastPosition[2] + 32.0f * coss(m->faceAngle[1]);
|
||||
|
||||
m->heldObj->oMoveAngleYaw = m->faceAngle[1];
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ extern u32 mario_check_object_grab(struct MarioState *);
|
||||
extern u32 get_door_save_file_flag(struct Object *);
|
||||
extern void mario_process_interactions(struct MarioState *);
|
||||
extern void mario_handle_special_floors(struct MarioState *);
|
||||
extern void init_bully_collision_data(
|
||||
extern BAD_RETURN(s32) init_bully_collision_data(
|
||||
struct BullyCollisionData *data,
|
||||
f32 posX,
|
||||
f32 posZ,
|
||||
|
||||
+33
-17
@@ -83,6 +83,7 @@ const char *credits06[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMA
|
||||
const char *credits07[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" };
|
||||
const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA",
|
||||
"KATSUHIKO KANNO" };
|
||||
#ifdef VERSION_US
|
||||
const char *credits09[] = { "1SOUND COMPOSER", "KOJI KONDO" };
|
||||
const char *credits10[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI",
|
||||
"HIDEAKI SHIMIZU" }; // as well as sound effects and sound programmer
|
||||
@@ -93,13 +94,33 @@ const char *credits14[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" };
|
||||
const char *credits15[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" };
|
||||
const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO",
|
||||
"HIRO YAMADA" }; // ...in order to make room for these 2 new lines
|
||||
#else // VERSION_EU
|
||||
const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO",
|
||||
"YOJI INAGAKI", "HIDEAKI SHIMIZU" };
|
||||
const char *credits10[] = { "63-D ANIMATORS", "ADDITIONAL GRAPHICS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA",
|
||||
"MASANAO ARIMOTO" };
|
||||
const char *credits11[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" };
|
||||
const char *credits12[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" };
|
||||
const char *credits13[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" };
|
||||
const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO",
|
||||
"HIRO YAMADA" };
|
||||
const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF",
|
||||
"KENJI HARAGUCHI" };
|
||||
const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG",
|
||||
"THOMAS SPINDLER" };
|
||||
#endif
|
||||
const char *credits17[] = { "4MARIO VOICE", "PEACH VOICE", "CHARLES MARTINET", "LESLIE SWAN" };
|
||||
const char *credits18[] = { "3SPECIAL THANKS TO", "EAD STAFF", "ALL NINTENDO PERSONNEL",
|
||||
"MARIO CLUB STAFF" };
|
||||
#ifdef VERSION_US
|
||||
"MARIO CLUB STAFF" };
|
||||
#else // VERSION_EU
|
||||
"SUPER MARIO CLUB STAFF" };
|
||||
#endif
|
||||
const char *credits19[] = { "1PRODUCER", "SHIGERU MIYAMOTO" };
|
||||
const char *credits20[] = { "1EXECUTIVE PRODUCER", "HIROSHI YAMAUCHI" };
|
||||
#endif
|
||||
|
||||
|
||||
struct CreditsEntry sCreditsSequence[] = {
|
||||
{ LEVEL_CASTLE_GROUNDS, 1, 1, -128, { 0, 8000, 0 }, NULL },
|
||||
{ LEVEL_BOB, 1, 1, 117, { 713, 3918, -3889 }, credits01 },
|
||||
@@ -127,36 +148,31 @@ struct CreditsEntry sCreditsSequence[] = {
|
||||
};
|
||||
|
||||
struct MarioState gMarioStates[1];
|
||||
struct MarioState *gMarioState = &gMarioStates[0];
|
||||
|
||||
u8 unused1[4] = { 0 };
|
||||
|
||||
s8 D_8032C9E0 = 0;
|
||||
|
||||
struct HudDisplay gHudDisplay;
|
||||
s16 sCurrPlayMode;
|
||||
u16 D_80339ECA;
|
||||
|
||||
s16 sTransitionTimer;
|
||||
void (*sTransitionUpdate)(s16 *);
|
||||
|
||||
u8 unused3[4];
|
||||
|
||||
struct WarpDest sWarpDest;
|
||||
|
||||
s16 D_80339EE0;
|
||||
|
||||
s16 sDelayedWarpOp;
|
||||
s16 sDelayedWarpTimer;
|
||||
s16 sSourceWarpNodeId;
|
||||
s32 sDelayedWarpArg;
|
||||
#ifdef VERSION_EU
|
||||
s16 unusedEULevelUpdateBss1;
|
||||
#endif
|
||||
s8 sTimerRunning;
|
||||
s8 gShouldNotPlayCastleMusic;
|
||||
|
||||
struct MarioState *gMarioState = &gMarioStates[0];
|
||||
u8 unused1[4] = { 0 };
|
||||
s8 D_8032C9E0 = 0;
|
||||
u8 unused3[4];
|
||||
u8 unused4[2];
|
||||
|
||||
s8 sTimerRunning;
|
||||
|
||||
struct HudDisplay gHudDisplay;
|
||||
|
||||
s8 gShouldNotPlayCastleMusic;
|
||||
|
||||
void basic_update(s16 *arg);
|
||||
|
||||
@@ -685,7 +701,7 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||
switch (warpOp) {
|
||||
case WARP_OP_DEMO_NEXT:
|
||||
case WARP_OP_DEMO_END:
|
||||
sDelayedWarpTimer = 20;
|
||||
do {sDelayedWarpTimer = 20;} while (0);
|
||||
sSourceWarpNodeId = WARP_NODE_F0;
|
||||
gSavedCourseNum = 0;
|
||||
val04 = FALSE;
|
||||
|
||||
+7
-5
@@ -25,6 +25,10 @@ OSThread gIdleThread;
|
||||
OSThread gMainThread;
|
||||
OSThread gGameLoopThread;
|
||||
OSThread gSoundThread;
|
||||
OSIoMesg gDmaIoMesg;
|
||||
OSMesg D_80339BEC;
|
||||
OSMesgQueue gDmaMesgQueue;
|
||||
OSMesgQueue gSIEventMesgQueue;
|
||||
OSMesgQueue gPIMesgQueue;
|
||||
OSMesgQueue gIntrMesgQueue;
|
||||
OSMesgQueue gSPTaskMesgQueue;
|
||||
@@ -33,10 +37,6 @@ OSMesg gPIMesgBuf[32];
|
||||
OSMesg gSIEventMesgBuf[1];
|
||||
OSMesg gIntrMesgBuf[16];
|
||||
OSMesg gUnknownMesgBuf[16];
|
||||
OSIoMesg gDmaIoMesg;
|
||||
OSMesg D_80339BEC;
|
||||
OSMesgQueue gDmaMesgQueue;
|
||||
OSMesgQueue gSIEventMesgQueue;
|
||||
|
||||
struct VblankHandler *gVblankHandler1 = NULL;
|
||||
struct VblankHandler *gVblankHandler2 = NULL;
|
||||
@@ -408,8 +408,10 @@ void thread1_idle(UNUSED void *arg) {
|
||||
} else {
|
||||
osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]);
|
||||
}
|
||||
#else
|
||||
#elif defined(VERSION_JP)
|
||||
osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
|
||||
#else // VERSION_EU
|
||||
osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]);
|
||||
#endif
|
||||
osViBlack(TRUE);
|
||||
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON);
|
||||
|
||||
+7
-6
@@ -350,7 +350,8 @@ void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits) {
|
||||
void play_mario_sound(struct MarioState *m, s32 actionSound, s32 marioSound) {
|
||||
if (actionSound == SOUND_ACTION_TERRAIN_JUMP) {
|
||||
play_mario_action_sound(
|
||||
m, (m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_JUMP : SOUND_ACTION_TERRAIN_JUMP, 1);
|
||||
m, (m->flags & MARIO_METAL_CAP) ? (s32)SOUND_ACTION_METAL_JUMP
|
||||
: (s32)SOUND_ACTION_TERRAIN_JUMP, 1);
|
||||
} else {
|
||||
play_sound_if_no_flag(m, actionSound, MARIO_ACTION_SOUND_PLAYED);
|
||||
}
|
||||
@@ -1214,7 +1215,7 @@ void squish_mario_model(struct MarioState *m) {
|
||||
}
|
||||
// If timer is less than 16, rubber-band Mario's size scale up and down.
|
||||
else if (m->squishTimer <= 16) {
|
||||
m->squishTimer--;
|
||||
m->squishTimer -= 1;
|
||||
|
||||
m->marioObj->header.gfx.scale[1] =
|
||||
1.0f - ((sSquishScaleOverTime[15 - m->squishTimer] * 0.6f) / 100.0f);
|
||||
@@ -1223,7 +1224,7 @@ void squish_mario_model(struct MarioState *m) {
|
||||
|
||||
m->marioObj->header.gfx.scale[2] = m->marioObj->header.gfx.scale[0];
|
||||
} else {
|
||||
m->squishTimer--;
|
||||
m->squishTimer -= 1;
|
||||
|
||||
vec3f_set(m->marioObj->header.gfx.scale, 1.4f, 0.4f, 1.4f);
|
||||
}
|
||||
@@ -1525,7 +1526,7 @@ void mario_reset_bodystate(struct MarioState *m) {
|
||||
bodyState->eyeState = MARIO_EYES_BLINK;
|
||||
bodyState->handState = MARIO_HAND_FISTS;
|
||||
bodyState->modelState = 0;
|
||||
bodyState->unk07 = 0;
|
||||
bodyState->wingFlutter = FALSE;
|
||||
|
||||
m->flags &= ~MARIO_METAL_SHOCK;
|
||||
}
|
||||
@@ -1650,7 +1651,7 @@ void mario_update_hitbox_and_cap_model(struct MarioState *m) {
|
||||
|
||||
if ((m->flags & MARIO_TELEPORTING) && (m->fadeWarpOpacity != 0xFF)) {
|
||||
bodyState->modelState &= ~0xFF;
|
||||
bodyState->modelState |= (m->fadeWarpOpacity | 0x100);
|
||||
bodyState->modelState |= (0x100 | m->fadeWarpOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1820,7 +1821,7 @@ void init_mario(void) {
|
||||
|
||||
mario_reset_bodystate(gMarioState);
|
||||
update_mario_info_for_cam(gMarioState);
|
||||
gMarioState->marioBodyState->unk0B = 0;
|
||||
gMarioState->marioBodyState->punchState = 0;
|
||||
|
||||
gMarioState->marioObj->oPosX = gMarioState->pos[0];
|
||||
gMarioState->marioObj->oPosY = gMarioState->pos[1];
|
||||
|
||||
@@ -442,13 +442,9 @@ s32 act_jump(struct MarioState *m) {
|
||||
}
|
||||
|
||||
s32 act_double_jump(struct MarioState *m) {
|
||||
s32 animation;
|
||||
|
||||
if (m->vel[1] >= 0.0f) {
|
||||
animation = MARIO_ANIM_DOUBLE_JUMP_RISE;
|
||||
} else {
|
||||
animation = MARIO_ANIM_DOUBLE_JUMP_FALL;
|
||||
}
|
||||
s32 animation = (m->vel[1] >= 0.0f)
|
||||
? MARIO_ANIM_DOUBLE_JUMP_RISE
|
||||
: MARIO_ANIM_DOUBLE_JUMP_FALL;
|
||||
|
||||
if (check_kick_or_dive_in_air(m)) {
|
||||
return TRUE;
|
||||
@@ -906,7 +902,7 @@ s32 act_ground_pound(struct MarioState *m) {
|
||||
play_sound(SOUND_ACTION_SPIN, m->marioObj->header.gfx.cameraToObject);
|
||||
}
|
||||
|
||||
m->actionTimer += 1;
|
||||
m->actionTimer++;
|
||||
if (m->actionTimer >= m->marioObj->header.gfx.unk38.curAnim->unk08 + 4) {
|
||||
play_sound(SOUND_MARIO_GROUND_POUND_WAH, m->marioObj->header.gfx.cameraToObject);
|
||||
m->actionState = 1;
|
||||
@@ -1577,7 +1573,7 @@ s32 act_jump_kick(struct MarioState *m) {
|
||||
|
||||
animFrame = m->marioObj->header.gfx.unk38.animFrame;
|
||||
if (animFrame == 0) {
|
||||
m->marioBodyState->unk0B = 0x86;
|
||||
m->marioBodyState->punchState = (2 << 6) | 6;
|
||||
}
|
||||
if (animFrame >= 0 && animFrame < 8) {
|
||||
m->flags |= MARIO_KICKING;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "sm64.h"
|
||||
#include "game.h"
|
||||
#include "sound_init.h"
|
||||
@@ -418,7 +418,7 @@ s32 act_reading_npc_dialog(struct MarioState *m) {
|
||||
}
|
||||
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
|
||||
vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
||||
vec3s_set(m->marioBodyState->unk12, m->actionTimer, 0, 0);
|
||||
vec3s_set(m->marioBodyState->headAngle, m->actionTimer, 0, 0);
|
||||
|
||||
if (m->actionState != 8) {
|
||||
m->actionState++;
|
||||
@@ -499,7 +499,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) {
|
||||
}
|
||||
}
|
||||
// apply head turn
|
||||
vec3s_set(m->marioBodyState->unk12, m->actionTimer, 0, 0);
|
||||
vec3s_set(m->marioBodyState->headAngle, m->actionTimer, 0, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1651,9 +1651,15 @@ static void intro_cutscene_hide_hud_and_mario(struct MarioState *m) {
|
||||
advance_cutscene_step(m);
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_SPAWN_PIPE 47
|
||||
#else
|
||||
#define TIMER_SPAWN_PIPE 37
|
||||
#endif
|
||||
|
||||
static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) {
|
||||
if ((s16) m->statusForCamera->cameraEvent != CAM_EVENT_START_INTRO) {
|
||||
if (m->actionTimer++ == 37) {
|
||||
if (m->actionTimer++ == TIMER_SPAWN_PIPE) {
|
||||
sIntroWarpPipeObj =
|
||||
spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_CASTLE_GROUNDS_WARP_PIPE,
|
||||
bhvStaticObject, -1328, 60, 4664, 0, 180, 0);
|
||||
@@ -1661,6 +1667,13 @@ static void intro_cutscene_peach_lakitu_scene(struct MarioState *m) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef TIMER_SPAWN_PIPE
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_RAISE_PIPE 28
|
||||
#else
|
||||
#define TIMER_RAISE_PIPE 38
|
||||
#endif
|
||||
|
||||
static void intro_cutscene_raise_pipe(struct MarioState *m) {
|
||||
sIntroWarpPipeObj->oPosY = camera_approach_f32_symmetric(sIntroWarpPipeObj->oPosY, 260.0f, 10.0f);
|
||||
@@ -1669,11 +1682,12 @@ static void intro_cutscene_raise_pipe(struct MarioState *m) {
|
||||
play_sound(SOUND_MENU_EXIT_PIPE, sIntroWarpPipeObj->header.gfx.cameraToObject);
|
||||
}
|
||||
|
||||
if (m->actionTimer++ == 38) {
|
||||
if (m->actionTimer++ == TIMER_RAISE_PIPE) {
|
||||
m->vel[1] = 60.0f;
|
||||
advance_cutscene_step(m);
|
||||
}
|
||||
}
|
||||
#undef TIMER_RAISE_PIPE
|
||||
|
||||
static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) {
|
||||
if (m->actionTimer == 25) {
|
||||
@@ -1683,9 +1697,15 @@ static void intro_cutscene_jump_out_of_pipe(struct MarioState *m) {
|
||||
if (m->actionTimer++ >= 118) {
|
||||
m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE;
|
||||
|
||||
play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED);
|
||||
#ifndef VERSION_JP
|
||||
#ifdef VERSION_EU
|
||||
// For some reason these calls were swapped.
|
||||
play_sound_if_no_flag(m, SOUND_ACTION_HIT_3, MARIO_ACTION_SOUND_PLAYED);
|
||||
play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED);
|
||||
#else
|
||||
play_sound_if_no_flag(m, SOUND_MARIO_YAHOO, MARIO_MARIO_SOUND_PLAYED);
|
||||
#ifndef VERSION_JP
|
||||
play_sound_if_no_flag(m, SOUND_ACTION_HIT_3, MARIO_ACTION_SOUND_PLAYED);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
set_mario_animation(m, MARIO_ANIM_SINGLE_JUMP);
|
||||
@@ -1920,10 +1940,15 @@ static s32 act_jumbo_star_cutscene(struct MarioState *m) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// TODO: (Scrub C) This function almost certainly has a version that matches for both -g and -O2
|
||||
static void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius) {
|
||||
s16 offsetX = radius * coss(sSparkleGenTheta) * sins(sSparkleGenPhi);
|
||||
s16 offsetY = radius * sins(sSparkleGenTheta);
|
||||
s16 offsetZ = radius * coss(sSparkleGenTheta) * coss(sSparkleGenPhi);
|
||||
#ifdef VERSION_EU
|
||||
s16 dTheta = 0x3800;
|
||||
s16 dPhi = 0x6000;
|
||||
#endif
|
||||
|
||||
spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_NONE, bhvSparkleSpawn, x + offsetX, y + offsetY,
|
||||
z + offsetZ, 0, 0, 0);
|
||||
@@ -1936,10 +1961,16 @@ static void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius) {
|
||||
spawn_object_abs_with_rot(gCurrentObject, 0, MODEL_NONE, bhvSparkleSpawn, x - offsetX, y - offsetY,
|
||||
z - offsetZ, 0, 0, 0);
|
||||
|
||||
#ifdef VERSION_EU
|
||||
sSparkleGenTheta += dTheta;
|
||||
sSparkleGenPhi += dPhi;
|
||||
#else
|
||||
sSparkleGenTheta += 0x3800;
|
||||
sSparkleGenPhi += 0x6000;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// not sure what this does, returns the height of the floor, but idk about the
|
||||
// other stuff (animation related?)
|
||||
static f32 func_8025BC14(struct Object *o) {
|
||||
@@ -2012,6 +2043,14 @@ static void end_peach_cutscene_summon_jumbo_star(struct MarioState *m) {
|
||||
play_sound(SOUND_AIR_PEACH_TWINKLE, sEndJumboStarObj->header.gfx.cameraToObject);
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_FADE_IN_PEACH 201
|
||||
#define TIMER_DESCEND_PEACH 280
|
||||
#else
|
||||
#define TIMER_FADE_IN_PEACH 276
|
||||
#define TIMER_DESCEND_PEACH 355
|
||||
#endif
|
||||
|
||||
// free peach from the stained glass window
|
||||
static void end_peach_cutscene_spawn_peach(struct MarioState *m) {
|
||||
if (m->actionTimer == 1) {
|
||||
@@ -2046,13 +2085,15 @@ static void end_peach_cutscene_spawn_peach(struct MarioState *m) {
|
||||
sEndToadAnims[0] = 4;
|
||||
sEndToadAnims[1] = 5;
|
||||
}
|
||||
if (m->actionTimer >= 276) {
|
||||
|
||||
if (m->actionTimer >= TIMER_FADE_IN_PEACH) {
|
||||
sEndPeachObj->oOpacity = camera_approach_f32_symmetric(sEndPeachObj->oOpacity, 255.0f, 2.0f);
|
||||
}
|
||||
if (m->actionTimer >= 40) {
|
||||
generate_yellow_sparkles(0, 2628, -1300, 150.0f);
|
||||
}
|
||||
if (m->actionTimer == 355) {
|
||||
|
||||
if (m->actionTimer == TIMER_DESCEND_PEACH) {
|
||||
advance_cutscene_step(m);
|
||||
}
|
||||
// probably added sounds later and missed the previous >= 40 check
|
||||
@@ -2061,6 +2102,12 @@ static void end_peach_cutscene_spawn_peach(struct MarioState *m) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_RUN_TO_PEACH 531
|
||||
#else
|
||||
#define TIMER_RUN_TO_PEACH 584
|
||||
#endif
|
||||
|
||||
// descend peach
|
||||
static void end_peach_cutscene_descend_peach(struct MarioState *m) {
|
||||
generate_yellow_sparkles(0, sEndPeachObj->oPosY, -1300, 150.0f);
|
||||
@@ -2082,11 +2129,13 @@ static void end_peach_cutscene_descend_peach(struct MarioState *m) {
|
||||
|
||||
play_sound(SOUND_AIR_PEACH_TWINKLE, sEndPeachObj->header.gfx.cameraToObject);
|
||||
|
||||
if (m->actionTimer >= 584) {
|
||||
if (m->actionTimer >= TIMER_RUN_TO_PEACH) {
|
||||
advance_cutscene_step(m);
|
||||
}
|
||||
}
|
||||
|
||||
#undef TIMER_RUN_TO_PEACH
|
||||
|
||||
// mario runs to peach
|
||||
static void end_peach_cutscene_run_to_peach(struct MarioState *m) {
|
||||
struct Surface *surf;
|
||||
@@ -2170,6 +2219,14 @@ static void end_peach_cutscene_dialog_1(struct MarioState *m) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_SOMETHING_SPECIAL 150
|
||||
#define TIMER_PEACH_KISS 260
|
||||
#else
|
||||
#define TIMER_SOMETHING_SPECIAL 130
|
||||
#define TIMER_PEACH_KISS 200
|
||||
#endif
|
||||
|
||||
// dialog 2
|
||||
// "...and it's all thanks to you!"
|
||||
// "Thank you Mario!"
|
||||
@@ -2196,19 +2253,22 @@ static void end_peach_cutscene_dialog_2(struct MarioState *m) {
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 130:
|
||||
case TIMER_SOMETHING_SPECIAL:
|
||||
set_cutscene_message(160, 227, 4, 40);
|
||||
#ifndef VERSION_JP
|
||||
play_sound(SOUND_PEACH_SOMETHING_SPECIAL, sEndPeachObj->header.gfx.cameraToObject);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 200:
|
||||
case TIMER_PEACH_KISS:
|
||||
advance_cutscene_step(m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#undef TIMER_SOMETHING_SPECIAL
|
||||
#undef TIMER_PEACH_KISS
|
||||
|
||||
static void end_peach_cutscene_kiss_from_peach(struct MarioState *m) {
|
||||
sEndPeachAnimation = 10;
|
||||
|
||||
@@ -2439,6 +2499,16 @@ static s32 act_end_peach_cutscene(struct MarioState *m) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef VERSION_EU
|
||||
#define TIMER_CREDITS_SHOW 51
|
||||
#define TIMER_CREDITS_PROGRESS 80
|
||||
#define TIMER_CREDITS_WARP 160
|
||||
#else
|
||||
#define TIMER_CREDITS_SHOW 61
|
||||
#define TIMER_CREDITS_PROGRESS 90
|
||||
#define TIMER_CREDITS_WARP 200
|
||||
#endif
|
||||
|
||||
static s32 act_credits_cutscene(struct MarioState *m) {
|
||||
s32 width;
|
||||
s32 height;
|
||||
@@ -2461,7 +2531,7 @@ static s32 act_credits_cutscene(struct MarioState *m) {
|
||||
}
|
||||
}
|
||||
|
||||
if (m->actionTimer >= 61) {
|
||||
if (m->actionTimer >= TIMER_CREDITS_SHOW) {
|
||||
if (m->actionState < 40) {
|
||||
m->actionState += 2;
|
||||
}
|
||||
@@ -2479,15 +2549,15 @@ static s32 act_credits_cutscene(struct MarioState *m) {
|
||||
func_8027A220(&sEndCutsceneVp, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (m->actionTimer == 90) {
|
||||
if (m->actionTimer == TIMER_CREDITS_PROGRESS) {
|
||||
reset_cutscene_msg_fade();
|
||||
}
|
||||
|
||||
if (m->actionTimer >= 90) {
|
||||
if (m->actionTimer >= TIMER_CREDITS_PROGRESS) {
|
||||
sDispCreditsEntry = gCurrCreditsEntry;
|
||||
}
|
||||
|
||||
if (m->actionTimer++ == 200) {
|
||||
if (m->actionTimer++ == TIMER_CREDITS_WARP) {
|
||||
level_trigger_warp(m, 24);
|
||||
}
|
||||
|
||||
|
||||
@@ -738,12 +738,12 @@ void func_80265C28(struct MarioState *m, s16 startYaw) {
|
||||
val00 = 0;
|
||||
}
|
||||
|
||||
val0C->unkC[2] = approach_s32(val0C->unkC[2], val02, 0x400, 0x400);
|
||||
val0C->unkC[0] = approach_s32(val0C->unkC[0], val00, 0x400, 0x400);
|
||||
val0C->torsoAngle[2] = approach_s32(val0C->torsoAngle[2], val02, 0x400, 0x400);
|
||||
val0C->torsoAngle[0] = approach_s32(val0C->torsoAngle[0], val00, 0x400, 0x400);
|
||||
;
|
||||
} else {
|
||||
val0C->unkC[2] = 0;
|
||||
val0C->unkC[0] = 0;
|
||||
val0C->torsoAngle[2] = 0;
|
||||
val0C->torsoAngle[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,11 +771,11 @@ void func_80265DBC(struct MarioState *m, s16 startYaw) {
|
||||
val02 = 0;
|
||||
}
|
||||
|
||||
val0C->unkC[2] = approach_s32(val0C->unkC[2], val04, 0x200, 0x200);
|
||||
val0C->unkC[0] = approach_s32(val0C->unkC[0], val02, 0x200, 0x200);
|
||||
val0C->unk12[2] = -val0C->unkC[2];
|
||||
val0C->torsoAngle[2] = approach_s32(val0C->torsoAngle[2], val04, 0x200, 0x200);
|
||||
val0C->torsoAngle[0] = approach_s32(val0C->torsoAngle[0], val02, 0x200, 0x200);
|
||||
val0C->headAngle[2] = -val0C->torsoAngle[2];
|
||||
|
||||
marioObj->header.gfx.angle[2] = val0C->unkC[2];
|
||||
marioObj->header.gfx.angle[2] = val0C->torsoAngle[2];
|
||||
marioObj->header.gfx.pos[1] += 45.0f;
|
||||
}
|
||||
|
||||
@@ -1351,8 +1351,8 @@ s32 act_burning_ground(struct MarioState *m) {
|
||||
|
||||
void func_80267814(struct MarioState *m) {
|
||||
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
||||
m->marioBodyState->unkC[0] = (s32)(5461.3335f * m->intendedMag / 32.0f * coss(intendedDYaw));
|
||||
m->marioBodyState->unkC[2] = (s32)(-(5461.3335f * m->intendedMag / 32.0f * sins(intendedDYaw)));
|
||||
m->marioBodyState->torsoAngle[0] = (s32)(5461.3335f * m->intendedMag / 32.0f * coss(intendedDYaw));
|
||||
m->marioBodyState->torsoAngle[2] = (s32)(-(5461.3335f * m->intendedMag / 32.0f * sins(intendedDYaw)));
|
||||
}
|
||||
|
||||
void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation) {
|
||||
|
||||
@@ -55,7 +55,7 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
|
||||
}
|
||||
|
||||
if (m->actionArg == 2) {
|
||||
m->marioBodyState->unk0B = 4;
|
||||
m->marioBodyState->punchState = (0 << 6) | 4;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -91,7 +91,7 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
|
||||
}
|
||||
|
||||
if (m->actionArg == 5) {
|
||||
m->marioBodyState->unk0B = 68;
|
||||
m->marioBodyState->punchState = (1 << 6) | 4;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -114,7 +114,7 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
|
||||
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
|
||||
animFrame = set_mario_animation(m, MARIO_ANIM_GROUND_KICK);
|
||||
if (animFrame == 0) {
|
||||
m->marioBodyState->unk0B = 134;
|
||||
m->marioBodyState->punchState = (2 << 6) | 6;
|
||||
}
|
||||
|
||||
if (animFrame >= 0 && animFrame < 8) {
|
||||
|
||||
@@ -1059,7 +1059,7 @@ s32 act_first_person(struct MarioState *m) {
|
||||
s16 sp1A;
|
||||
s16 sp18;
|
||||
|
||||
sp1C = 0U < (m->input & (INPUT_UNKNOWN_10 | 0xC));
|
||||
sp1C = 0 != (m->input & (INPUT_UNKNOWN_10 | 0xC));
|
||||
if (m->actionState == 0) {
|
||||
func_80248C28(2);
|
||||
set_camera_mode(m->area->camera, CAMERA_MODE_C_UP, 0x10);
|
||||
|
||||
@@ -193,7 +193,7 @@ static u32 perform_water_step(struct MarioState *m) {
|
||||
return stepResult;
|
||||
}
|
||||
|
||||
static void func_80270504(struct MarioState *m) {
|
||||
static BAD_RETURN(u32) func_80270504(struct MarioState *m) {
|
||||
struct Object *marioObj = m->marioObj;
|
||||
|
||||
if (marioObj->header.gfx.angle[0] > 0) {
|
||||
@@ -302,7 +302,7 @@ static void update_swimming_pitch(struct MarioState *m) {
|
||||
}
|
||||
|
||||
static void common_idle_step(struct MarioState *m, s32 animation, s32 arg) {
|
||||
s16 *val = &m->marioBodyState->unk12[0];
|
||||
s16 *val = &m->marioBodyState->headAngle[0];
|
||||
|
||||
update_swimming_yaw(m);
|
||||
update_swimming_pitch(m);
|
||||
@@ -472,7 +472,7 @@ static void common_swimming_step(struct MarioState *m, s16 swimStrength) {
|
||||
}
|
||||
|
||||
func_80270504(m);
|
||||
m->marioBodyState->unk12[0] = approach_s32(m->marioBodyState->unk12[0], 0, 0x200, 0x200);
|
||||
m->marioBodyState->headAngle[0] = approach_s32(m->marioBodyState->headAngle[0], 0, 0x200, 0x200);
|
||||
|
||||
func_802710CC(m);
|
||||
set_swimming_at_surface_particles(m, PARTICLE_10);
|
||||
@@ -482,9 +482,7 @@ static void func_802713A8(struct MarioState *m) {
|
||||
s16 animFrame = m->marioObj->header.gfx.unk38.animFrame;
|
||||
|
||||
// (this need to be on one line to match on PAL)
|
||||
if (animFrame == 0 || animFrame == 12) {
|
||||
play_sound(SOUND_ACTION_UNKNOWN434, m->marioObj->header.gfx.cameraToObject);
|
||||
}
|
||||
if (animFrame == 0 || animFrame == 12) play_sound(SOUND_ACTION_UNKNOWN434, m->marioObj->header.gfx.cameraToObject);
|
||||
}
|
||||
|
||||
static s32 check_water_jump(struct MarioState *m) {
|
||||
@@ -793,7 +791,7 @@ static s32 act_water_throw(struct MarioState *m) {
|
||||
set_mario_animation(m, MARIO_ANIM_WATER_THROW_OBJ);
|
||||
play_sound_if_no_flag(m, SOUND_ACTION_SWIM, MARIO_ACTION_SOUND_PLAYED);
|
||||
|
||||
m->marioBodyState->unk12[0] = approach_s32(m->marioBodyState->unk12[0], 0, 0x200, 0x200);
|
||||
m->marioBodyState->headAngle[0] = approach_s32(m->marioBodyState->headAngle[0], 0, 0x200, 0x200);
|
||||
|
||||
if (m->actionTimer++ == 5) {
|
||||
mario_throw_held_object(m);
|
||||
@@ -817,7 +815,7 @@ static s32 act_water_punch(struct MarioState *m) {
|
||||
perform_water_step(m);
|
||||
func_80270504(m);
|
||||
|
||||
m->marioBodyState->unk12[0] = approach_s32(m->marioBodyState->unk12[0], 0, 0x200, 0x200);
|
||||
m->marioBodyState->headAngle[0] = approach_s32(m->marioBodyState->headAngle[0], 0, 0x200, 0x200);
|
||||
|
||||
play_sound_if_no_flag(m, SOUND_ACTION_SWIM, MARIO_ACTION_SOUND_PLAYED);
|
||||
|
||||
@@ -857,7 +855,7 @@ static void common_water_knockback_step(struct MarioState *m, s32 animation, u32
|
||||
perform_water_step(m);
|
||||
set_mario_animation(m, animation);
|
||||
|
||||
m->marioBodyState->unk12[0] = 0;
|
||||
m->marioBodyState->headAngle[0] = 0;
|
||||
|
||||
if (is_anim_at_end(m)) {
|
||||
if (arg3 > 0) {
|
||||
@@ -895,7 +893,7 @@ static s32 act_water_shocked(struct MarioState *m) {
|
||||
|
||||
stationary_slow_down(m);
|
||||
perform_water_step(m);
|
||||
m->marioBodyState->unk12[0] = 0;
|
||||
m->marioBodyState->headAngle[0] = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1513,8 +1511,8 @@ s32 mario_execute_submerged_action(struct MarioState *m) {
|
||||
|
||||
m->quicksandDepth = 0.0f;
|
||||
|
||||
m->marioBodyState->unk12[1] = 0;
|
||||
m->marioBodyState->unk12[2] = 0;
|
||||
m->marioBodyState->headAngle[1] = 0;
|
||||
m->marioBodyState->headAngle[2] = 0;
|
||||
|
||||
/* clang-format off */
|
||||
switch (m->action) {
|
||||
|
||||
+237
-152
@@ -52,11 +52,26 @@ enum UnlockDoorStarStates {
|
||||
UNLOCK_DOOR_STAR_DONE
|
||||
};
|
||||
|
||||
static s8 D_8032CDF0[7] = { 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x01 };
|
||||
static s8 D_8032CDF8[] = { 0x0a, 0x0c, 0x10, 0x18, 0x0a, 0x0a, 0x0a, 0x0e, 0x14, 0x1e,
|
||||
0x0a, 0x0a, 0x0a, 0x10, 0x14, 0x1a, 0x1a, 0x14, 0x00, 0x00 };
|
||||
struct GraphNodeObject D_80339FE0;
|
||||
/**
|
||||
* The eye texture on succesive frames of Mario's blink animation.
|
||||
* He intentionally blinks twice each time.
|
||||
*/
|
||||
static s8 gMarioBlinkAnimation[7] = { 1, 2, 1, 0, 1, 2, 1 };
|
||||
|
||||
/**
|
||||
* The scale values per frame for Mario's foot/hand for his attack animation
|
||||
* There are 3 scale animations in groups of 6 frames.
|
||||
* The first animation starts at frame index 3 and goes down, the others start at frame index 5.
|
||||
* The values get divided by 10 before assigning, so e.g. 12 gives a scale factor 1.2.
|
||||
* All combined, this means e.g. the first animation scales Mario's fist by {2.4, 1.6, 1.2, 1.0} on
|
||||
* succesive frames.
|
||||
*/
|
||||
static s8 gMarioAttackScaleAnimation[3 * 6] = {
|
||||
10, 12, 16, 24, 10, 10, 10, 14, 20, 30, 10, 10, 10, 16, 20, 26, 26, 20,
|
||||
};
|
||||
|
||||
struct MarioBodyState gBodyStates[2]; // 2nd is never accessed in practice, most likely Luigi related
|
||||
struct GraphNodeObject gMirrorMario; // copy of Mario's geo node for drawing mirror Mario
|
||||
|
||||
// This whole file is weirdly organized. It has to be the same file due
|
||||
// to rodata boundries and function aligns, which means the programmer
|
||||
@@ -64,23 +79,25 @@ struct MarioBodyState gBodyStates[2]; // 2nd is never accessed in practice, most
|
||||
// (message NPC related things, the mario head geo, and mario geo
|
||||
// functions)
|
||||
|
||||
// mario head geo
|
||||
Gfx *Geo18_802764B0(s32 callContext, struct GraphNode *node, Mat4 *c) {
|
||||
Gfx *sp24 = NULL;
|
||||
s16 sp22 = 0;
|
||||
struct GraphNodeGenerated *sp1C = (struct GraphNodeGenerated *) node;
|
||||
UNUSED Mat4 *sp18 = c;
|
||||
/**
|
||||
* Geo node script that draws Mario's head on the title screen.
|
||||
*/
|
||||
Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c) {
|
||||
Gfx *gfx = NULL;
|
||||
s16 sfx = 0;
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
UNUSED Mat4 *transform = c;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
if (gPlayer1Controller->controllerData != NULL && gWarpTransition.isActive == 0) {
|
||||
gd_copy_p1_contpad(gPlayer1Controller->controllerData);
|
||||
}
|
||||
sp24 = (Gfx *) PHYSICAL_TO_VIRTUAL(gdm_gettestdl(sp1C->parameter));
|
||||
gfx = (Gfx *) PHYSICAL_TO_VIRTUAL(gdm_gettestdl(asGenerated->parameter));
|
||||
D_8032C6A0 = gd_vblank;
|
||||
sp22 = gd_sfx_to_play();
|
||||
play_menu_sounds(sp22);
|
||||
sfx = gd_sfx_to_play();
|
||||
play_menu_sounds(sfx);
|
||||
}
|
||||
return sp24;
|
||||
return gfx;
|
||||
}
|
||||
|
||||
static void bhvToadMessage_faded(void) {
|
||||
@@ -108,7 +125,8 @@ static void bhvToadMessage_opaque(void) {
|
||||
}
|
||||
|
||||
static void bhvToadMessage_talking(void) {
|
||||
if (obj_update_dialog_with_cutscene(3, 1, CUTSCENE_DIALOG, gCurrentObject->oToadMessageDialogId) != 0) {
|
||||
if (obj_update_dialog_with_cutscene(3, 1, CUTSCENE_DIALOG, gCurrentObject->oToadMessageDialogId)
|
||||
!= 0) {
|
||||
gCurrentObject->oToadMessageRecentlyTalked = 1;
|
||||
gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
|
||||
switch (gCurrentObject->oToadMessageDialogId) {
|
||||
@@ -141,7 +159,7 @@ static void bhvToadMessage_fading(void) {
|
||||
}
|
||||
|
||||
void bhvToadMessage_loop(void) {
|
||||
if (gCurrentObject->header.gfx.node.flags & 1) {
|
||||
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) {
|
||||
gCurrentObject->oInteractionSubtype = 0;
|
||||
switch (gCurrentObject->oToadMessageState) {
|
||||
case TOAD_MESSAGE_FADED:
|
||||
@@ -279,174 +297,219 @@ void bhvUnlockDoorStar_loop(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static Gfx *func_802769E0(struct GraphNodeGenerated *node, s16 b) {
|
||||
Gfx *sp2C;
|
||||
Gfx *sp28 = NULL;
|
||||
/**
|
||||
* Generate a display list that sets the correct blend mode and color for
|
||||
* mirror Mario.
|
||||
*/
|
||||
static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
|
||||
Gfx *gfx;
|
||||
Gfx *gfxHead = NULL;
|
||||
|
||||
if (b == 255) {
|
||||
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | 0x100;
|
||||
sp28 = alloc_display_list(2 * sizeof(*sp28));
|
||||
sp2C = sp28;
|
||||
if (alpha == 255) {
|
||||
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8);
|
||||
gfxHead = alloc_display_list(2 * sizeof(*gfxHead));
|
||||
gfx = gfxHead;
|
||||
} else {
|
||||
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | 0x500;
|
||||
sp28 = alloc_display_list(3 * sizeof(*sp28));
|
||||
sp2C = sp28;
|
||||
gDPSetAlphaCompare(sp2C++, G_AC_DITHER);
|
||||
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | (LAYER_TRANSPARENT << 8);
|
||||
gfxHead = alloc_display_list(3 * sizeof(*gfxHead));
|
||||
gfx = gfxHead;
|
||||
gDPSetAlphaCompare(gfx++, G_AC_DITHER);
|
||||
}
|
||||
gDPSetEnvColor(sp2C++, 255, 255, 255, b);
|
||||
gSPEndDisplayList(sp2C);
|
||||
return sp28;
|
||||
gDPSetEnvColor(gfx++, 255, 255, 255, alpha);
|
||||
gSPEndDisplayList(gfx);
|
||||
return gfxHead;
|
||||
}
|
||||
|
||||
Gfx *Geo18_802770A4(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
/**
|
||||
* Sets the correct blend mode and color for mirror Mario.
|
||||
*/
|
||||
Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
UNUSED u8 unused1[4];
|
||||
Gfx *sp28 = NULL;
|
||||
struct GraphNodeGenerated *sp24 = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *sp20 = &gBodyStates[sp24->parameter];
|
||||
s16 sp1E;
|
||||
Gfx *gfx = NULL;
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
|
||||
s16 alpha;
|
||||
UNUSED u8 unused2[4];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
sp1E = (sp20->modelState & 0x100) ? (sp20->modelState & 0xFF) : 255;
|
||||
sp28 = func_802769E0(sp24, sp1E);
|
||||
alpha = (bodyState->modelState & 0x100) ? (bodyState->modelState & 0xFF) : 255;
|
||||
gfx = make_gfx_mario_alpha(asGenerated, alpha);
|
||||
}
|
||||
return sp28;
|
||||
return gfx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if Mario is standing or running for the level of detail of his model.
|
||||
* If Mario is standing still, he is always high poly. If he is running,
|
||||
* his level of detail depends on the distance to the camera.
|
||||
*/
|
||||
Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx) {
|
||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
|
||||
struct MarioBodyState *sp0 = &gBodyStates[switchCase->numCases];
|
||||
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
// assign result. 0 if moving, 1 if stationary.
|
||||
switchCase->selectedCase = ((sp0->action & ACT_FLAG_STATIONARY) == FALSE);
|
||||
switchCase->selectedCase = ((bodyState->action & ACT_FLAG_STATIONARY) == FALSE);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geo node script that makes Mario blink
|
||||
*/
|
||||
Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
|
||||
struct MarioBodyState *sp8 = &gBodyStates[switchCase->numCases];
|
||||
s16 sp6;
|
||||
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
||||
s16 blinkFrame;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
if (sp8->eyeState == 0) {
|
||||
sp6 = ((switchCase->numCases * 32 + gAreaUpdateCounter) >> 1) & 0x1F;
|
||||
if (sp6 < 7) {
|
||||
switchCase->selectedCase = D_8032CDF0[sp6];
|
||||
if (bodyState->eyeState == 0) {
|
||||
blinkFrame = ((switchCase->numCases * 32 + gAreaUpdateCounter) >> 1) & 0x1F;
|
||||
if (blinkFrame < 7) {
|
||||
switchCase->selectedCase = gMarioBlinkAnimation[blinkFrame];
|
||||
} else {
|
||||
switchCase->selectedCase = 0;
|
||||
}
|
||||
} else {
|
||||
switchCase->selectedCase = sp8->eyeState - 1;
|
||||
switchCase->selectedCase = bodyState->eyeState - 1;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Gfx *Geo18_80277294(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeGenerated *sp24 = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *sp20 = &gBodyStates[sp24->parameter];
|
||||
s32 action = sp20->action;
|
||||
/**
|
||||
* Makes Mario's upper body tilt depending on the rotation stored in his bodyState
|
||||
*/
|
||||
Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
|
||||
s32 action = bodyState->action;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
struct GraphNodeRotation *sp18 = (struct GraphNodeRotation *) node->next;
|
||||
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
|
||||
|
||||
if (action != 0x00840452 && action != 0x00840454 && action != 0x04000440
|
||||
&& action != 0x20810446) {
|
||||
vec3s_copy(sp20->unkC, gVec3sZero);
|
||||
if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING
|
||||
&& action != ACT_RIDING_SHELL_GROUND) {
|
||||
vec3s_copy(bodyState->torsoAngle, gVec3sZero);
|
||||
}
|
||||
sp18->rotation[0] = sp20->unkC[1];
|
||||
sp18->rotation[1] = sp20->unkC[2];
|
||||
sp18->rotation[2] = sp20->unkC[0];
|
||||
rotNode->rotation[0] = bodyState->torsoAngle[1];
|
||||
rotNode->rotation[1] = bodyState->torsoAngle[2];
|
||||
rotNode->rotation[2] = bodyState->torsoAngle[0];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Gfx *Geo18_802773A4(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeGenerated *sp2C = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *sp28 = &gBodyStates[sp2C->parameter];
|
||||
s32 action = sp28->action;
|
||||
/**
|
||||
* Makes Mario's head rotate with the camera angle when in C-up mode
|
||||
*/
|
||||
Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
|
||||
s32 action = bodyState->action;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
struct GraphNodeRotation *sp20 = (struct GraphNodeRotation *) node->next;
|
||||
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
|
||||
struct Camera *camera = gCurGraphNodeCamera->config.camera;
|
||||
|
||||
if (camera->mode == CAMERA_MODE_C_UP) {
|
||||
sp20->rotation[0] = gPlayerCameraState->headRotation[1];
|
||||
sp20->rotation[2] = gPlayerCameraState->headRotation[0];
|
||||
} else if (action & 0x20000000) {
|
||||
sp20->rotation[0] = sp28->unk12[1];
|
||||
sp20->rotation[1] = sp28->unk12[2];
|
||||
sp20->rotation[2] = sp28->unk12[0];
|
||||
rotNode->rotation[0] = gPlayerCameraState->headRotation[1];
|
||||
rotNode->rotation[2] = gPlayerCameraState->headRotation[0];
|
||||
} else if (action & ACT_FLAG_WATER_OR_TEXT) {
|
||||
rotNode->rotation[0] = bodyState->headAngle[1];
|
||||
rotNode->rotation[1] = bodyState->headAngle[2];
|
||||
rotNode->rotation[2] = bodyState->headAngle[0];
|
||||
} else {
|
||||
vec3s_set(sp28->unk12, 0, 0, 0);
|
||||
vec3s_set(sp20->rotation, 0, 0, 0);
|
||||
vec3s_set(bodyState->headAngle, 0, 0, 0);
|
||||
vec3s_set(rotNode->rotation, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch between hand models.
|
||||
* Possible options are described in the MarioHandGSCId enum.
|
||||
*/
|
||||
Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
|
||||
struct MarioBodyState *sp0 = &gBodyStates[0];
|
||||
struct MarioBodyState *bodyState = &gBodyStates[0];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
if (sp0->handState == 0) {
|
||||
switchCase->selectedCase = ((sp0->action & ACT_FLAG_SWIMMING_OR_FLYING) != 0);
|
||||
if (bodyState->handState == MARIO_HAND_FISTS) {
|
||||
// switch between fists (0) and open (1)
|
||||
switchCase->selectedCase = ((bodyState->action & ACT_FLAG_SWIMMING_OR_FLYING) != 0);
|
||||
} else {
|
||||
if (switchCase->numCases == 0) {
|
||||
switchCase->selectedCase = (sp0->handState < 5) ? sp0->handState : 1;
|
||||
switchCase->selectedCase =
|
||||
(bodyState->handState < 5) ? bodyState->handState : MARIO_HAND_OPEN;
|
||||
} else {
|
||||
switchCase->selectedCase = (sp0->handState < 2) ? sp0->handState : 0;
|
||||
switchCase->selectedCase =
|
||||
(bodyState->handState < 2) ? bodyState->handState : MARIO_HAND_FISTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Gfx *Geo18_802775CC(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
static s16 D_8032CE0C = 0;
|
||||
struct GraphNodeGenerated *spC = (struct GraphNodeGenerated *) node;
|
||||
struct GraphNodeScale *sp8 = (struct GraphNodeScale *) node->next;
|
||||
struct MarioBodyState *sp4 = &gBodyStates[0];
|
||||
/**
|
||||
* Increase Mario's hand / foot size when he punches / kicks.
|
||||
* Since animation geo nodes only support rotation, this scaling animation
|
||||
* was scripted separately. The node with this script should be placed before
|
||||
* a scaling node containing the hand / foot geo layout.
|
||||
* ! Since the animation gets updated in GEO_CONTEXT_RENDER, drawing Mario multiple times
|
||||
* (such as in the mirror room) results in a faster and desynced punch / kick animation.
|
||||
*/
|
||||
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
static s16 sMarioAttackAnimCounter = 0;
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next;
|
||||
struct MarioBodyState *bodyState = &gBodyStates[0];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
sp8->scale = 1.0f;
|
||||
if (spC->parameter == sp4->unk0B >> 6) {
|
||||
if (D_8032CE0C != gAreaUpdateCounter && (sp4->unk0B & 0x3F) > 0) {
|
||||
sp4->unk0B -= 1;
|
||||
D_8032CE0C = gAreaUpdateCounter;
|
||||
scaleNode->scale = 1.0f;
|
||||
if (asGenerated->parameter == bodyState->punchState >> 6) {
|
||||
if (sMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0) {
|
||||
bodyState->punchState -= 1;
|
||||
sMarioAttackAnimCounter = gAreaUpdateCounter;
|
||||
}
|
||||
sp8->scale = D_8032CDF8[spC->parameter * 6 + (sp4->unk0B & 0x3F)] / 10.0f;
|
||||
scaleNode->scale =
|
||||
gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)]
|
||||
/ 10.0f;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch between normal cap, wing cap, vanish cap and metal cap.
|
||||
*/
|
||||
Gfx *geo_switch_mario_cap_effect(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
|
||||
struct MarioBodyState *sp0 = &gBodyStates[switchCase->numCases];
|
||||
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
switchCase->selectedCase = sp0->modelState >> 8;
|
||||
switchCase->selectedCase = bodyState->modelState >> 8;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether Mario's head is drawn with or without a cap on.
|
||||
* Also sets the visibility of the wing cap wings on or off.
|
||||
*/
|
||||
Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNode *next = node->next;
|
||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
|
||||
struct MarioBodyState *sp4 = &gBodyStates[switchCase->numCases];
|
||||
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
switchCase->selectedCase = sp4->capState & 1;
|
||||
switchCase->selectedCase = bodyState->capState & 1;
|
||||
while (next != node) {
|
||||
if (next->type == 21) {
|
||||
if (sp4->capState & 2) {
|
||||
next->flags |= 1;
|
||||
if (next->type == GRAPH_NODE_TYPE_TRANSLATION_ROTATION) {
|
||||
if (bodyState->capState & 2) {
|
||||
next->flags |= GRAPH_RENDER_ACTIVE;
|
||||
} else {
|
||||
next->flags &= ~1;
|
||||
next->flags &= ~GRAPH_RENDER_ACTIVE;
|
||||
}
|
||||
}
|
||||
next = next->next;
|
||||
@@ -455,117 +518,139 @@ Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Gfx *Geo18_80277824(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
s16 spE;
|
||||
struct GraphNodeGenerated *sp8 = (struct GraphNodeGenerated *) node;
|
||||
/**
|
||||
* Geo node script that makes the wings on Mario's wing cap flap.
|
||||
* Should be placed before a rotation node.
|
||||
*/
|
||||
Gfx *geo_mario_rotate_wing_cap_wings(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
s16 rotX;
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
struct GraphNodeRotation *sp4 = (struct GraphNodeRotation *) node->next;
|
||||
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
|
||||
|
||||
if (gBodyStates[sp8->parameter >> 1].unk07 == 0) {
|
||||
spE = (coss((gAreaUpdateCounter & 0xF) << 12) + 1.0f) * 4096.0f;
|
||||
if (gBodyStates[asGenerated->parameter >> 1].wingFlutter == FALSE) {
|
||||
rotX = (coss((gAreaUpdateCounter & 0xF) << 12) + 1.0f) * 4096.0f;
|
||||
} else {
|
||||
spE = (coss((gAreaUpdateCounter & 7) << 13) + 1.0f) * 6144.0f;
|
||||
rotX = (coss((gAreaUpdateCounter & 7) << 13) + 1.0f) * 6144.0f;
|
||||
}
|
||||
if (!(sp8->parameter & 1)) {
|
||||
sp4->rotation[0] = -spE;
|
||||
if (!(asGenerated->parameter & 1)) {
|
||||
rotNode->rotation[0] = -rotX;
|
||||
} else {
|
||||
sp4->rotation[0] = spE;
|
||||
rotNode->rotation[0] = rotX;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *c) {
|
||||
struct GraphNodeHeldObject *sp2C = (struct GraphNodeHeldObject *) b;
|
||||
Mat4 *sp28 = c;
|
||||
struct MarioState *sp24 = &gMarioStates[sp2C->playerIndex];
|
||||
/**
|
||||
* Geo node that updates the held object node and the HOLP.
|
||||
*/
|
||||
Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *mtx) {
|
||||
struct GraphNodeHeldObject *asHeldObj = (struct GraphNodeHeldObject *) b;
|
||||
Mat4 *curTransform = mtx;
|
||||
struct MarioState *marioState = &gMarioStates[asHeldObj->playerIndex];
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER) {
|
||||
sp2C->objNode = NULL;
|
||||
if (sp24->heldObj != NULL) {
|
||||
sp2C->objNode = sp24->heldObj;
|
||||
switch (sp24->marioBodyState->grabPos) {
|
||||
asHeldObj->objNode = NULL;
|
||||
if (marioState->heldObj != NULL) {
|
||||
asHeldObj->objNode = marioState->heldObj;
|
||||
switch (marioState->marioBodyState->grabPos) {
|
||||
case GRAB_POS_LIGHT_OBJ:
|
||||
if (sp24->action & ACT_FLAG_THROWING) {
|
||||
vec3s_set(sp2C->translation, 50, 0, 0);
|
||||
if (marioState->action & ACT_FLAG_THROWING) {
|
||||
vec3s_set(asHeldObj->translation, 50, 0, 0);
|
||||
} else {
|
||||
vec3s_set(sp2C->translation, 50, 0, 110);
|
||||
vec3s_set(asHeldObj->translation, 50, 0, 110);
|
||||
}
|
||||
break;
|
||||
case GRAB_POS_HEAVY_OBJ:
|
||||
vec3s_set(sp2C->translation, 145, -173, 180);
|
||||
vec3s_set(asHeldObj->translation, 145, -173, 180);
|
||||
break;
|
||||
case GRAB_POS_BOWSER:
|
||||
vec3s_set(sp2C->translation, 80, -270, 1260);
|
||||
vec3s_set(asHeldObj->translation, 80, -270, 1260);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (callContext == GEO_CONTEXT_HELD_OBJ) {
|
||||
get_pos_from_transform_mtx(sp24->marioBodyState->unk18, *sp28, gCurGraphNodeCamera->matrixPtr);
|
||||
// ! The HOLP is set here, which is why it only updates when the held object is drawn.
|
||||
// This is why it won't update during a pause buffered hitstun or when the camera is very far
|
||||
// away.
|
||||
get_pos_from_transform_mtx(marioState->marioBodyState->heldObjLastPosition, *curTransform,
|
||||
gCurGraphNodeCamera->matrixPtr);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// X position of the mirror
|
||||
#define MIRROR_X 4331.53
|
||||
|
||||
/**
|
||||
* Geo node that creates a clone of Mario's geo node and updates it to becomes
|
||||
* a mirror image of the player.
|
||||
*/
|
||||
Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
f32 sp34;
|
||||
struct Object *sp30 = gMarioStates->marioObj;
|
||||
f32 mirroredX;
|
||||
struct Object *mario = gMarioStates->marioObj;
|
||||
|
||||
switch (callContext) {
|
||||
case GEO_CONTEXT_CREATE:
|
||||
init_graph_node_object(NULL, &D_80339FE0, NULL, gVec3fZero, gVec3sZero, gVec3fOne);
|
||||
init_graph_node_object(NULL, &gMirrorMario, NULL, gVec3fZero, gVec3sZero, gVec3fOne);
|
||||
break;
|
||||
case GEO_CONTEXT_AREA_LOAD:
|
||||
geo_add_child(node, &D_80339FE0.node);
|
||||
geo_add_child(node, &gMirrorMario.node);
|
||||
break;
|
||||
case GEO_CONTEXT_AREA_UNLOAD:
|
||||
geo_remove_child(&D_80339FE0.node);
|
||||
geo_remove_child(&gMirrorMario.node);
|
||||
break;
|
||||
case GEO_CONTEXT_RENDER:
|
||||
if (sp30->header.gfx.pos[0] > 1700.0f) {
|
||||
if (mario->header.gfx.pos[0] > 1700.0f) {
|
||||
// TODO: Is this a geo layout copy or a graph node copy?
|
||||
D_80339FE0.sharedChild = sp30->header.gfx.sharedChild;
|
||||
D_80339FE0.unk18 = sp30->header.gfx.unk18;
|
||||
vec3s_copy(D_80339FE0.angle, sp30->header.gfx.angle);
|
||||
vec3f_copy(D_80339FE0.pos, sp30->header.gfx.pos);
|
||||
vec3f_copy(D_80339FE0.scale, sp30->header.gfx.scale);
|
||||
gMirrorMario.sharedChild = mario->header.gfx.sharedChild;
|
||||
gMirrorMario.unk18 = mario->header.gfx.unk18;
|
||||
vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle);
|
||||
vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos);
|
||||
vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale);
|
||||
// FIXME: why does this set unk38, an inline struct, to a ptr to another one? wrong
|
||||
// GraphNode types again?
|
||||
D_80339FE0.unk38 = *(struct GraphNodeObject_sub *) &sp30->header.gfx.unk38.animID;
|
||||
sp34 = 4331.53 - D_80339FE0.pos[0];
|
||||
D_80339FE0.pos[0] = sp34 + 4331.53;
|
||||
D_80339FE0.angle[1] = -D_80339FE0.angle[1];
|
||||
D_80339FE0.scale[0] *= -1.0f;
|
||||
gMirrorMario.unk38 = *(struct GraphNodeObject_sub *) &mario->header.gfx.unk38.animID;
|
||||
mirroredX = MIRROR_X - gMirrorMario.pos[0];
|
||||
gMirrorMario.pos[0] = mirroredX + MIRROR_X;
|
||||
gMirrorMario.angle[1] = -gMirrorMario.angle[1];
|
||||
gMirrorMario.scale[0] *= -1.0f;
|
||||
// FIXME: Why doesn't this match?
|
||||
// D_80339FE0.node.flags |= 1;
|
||||
((s16 *) &D_80339FE0)[1] |= 1;
|
||||
// gMirrorMario.node.flags |= 1;
|
||||
((s16 *) &gMirrorMario)[1] |= 1;
|
||||
} else {
|
||||
// FIXME: Why doesn't this match?
|
||||
// D_80339FE0.node.flags &= ~1;
|
||||
((s16 *) &D_80339FE0)[1] &= ~1;
|
||||
// gMirrorMario.node.flags &= ~1;
|
||||
((s16 *) &gMirrorMario)[1] &= ~1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since Mirror Mario has an x scale of -1, the mesh becomes inside out.
|
||||
* This node corrects that by changing the culling mode accordingly.
|
||||
*/
|
||||
Gfx *geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
|
||||
struct GraphNodeGenerated *sp34 = (struct GraphNodeGenerated *) node;
|
||||
Gfx *sp30 = NULL;
|
||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||
Gfx *gfx = NULL;
|
||||
|
||||
if (callContext == GEO_CONTEXT_RENDER && gCurGraphNodeObject == &D_80339FE0) {
|
||||
sp30 = alloc_display_list(3 * sizeof(*sp30));
|
||||
if (callContext == GEO_CONTEXT_RENDER && gCurGraphNodeObject == &gMirrorMario) {
|
||||
gfx = alloc_display_list(3 * sizeof(*gfx));
|
||||
|
||||
if (sp34->parameter == 0) {
|
||||
gSPClearGeometryMode(&sp30[0], G_CULL_BACK);
|
||||
gSPSetGeometryMode(&sp30[1], G_CULL_FRONT);
|
||||
gSPEndDisplayList(&sp30[2]);
|
||||
if (asGenerated->parameter == 0) {
|
||||
gSPClearGeometryMode(&gfx[0], G_CULL_BACK);
|
||||
gSPSetGeometryMode(&gfx[1], G_CULL_FRONT);
|
||||
gSPEndDisplayList(&gfx[2]);
|
||||
} else {
|
||||
gSPClearGeometryMode(&sp30[0], G_CULL_FRONT);
|
||||
gSPSetGeometryMode(&sp30[1], G_CULL_BACK);
|
||||
gSPEndDisplayList(&sp30[2]);
|
||||
gSPClearGeometryMode(&gfx[0], G_CULL_FRONT);
|
||||
gSPSetGeometryMode(&gfx[1], G_CULL_BACK);
|
||||
gSPEndDisplayList(&gfx[2]);
|
||||
}
|
||||
sp34->fnNode.node.flags = (sp34->fnNode.node.flags & 0xFF) | 0x100;
|
||||
asGenerated->fnNode.node.flags = (asGenerated->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8);
|
||||
}
|
||||
return sp30;
|
||||
return gfx;
|
||||
}
|
||||
@@ -3,26 +3,25 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
extern struct GraphNodeObject D_80339FE0;
|
||||
extern struct GraphNodeObject gMirrorMario;
|
||||
extern struct MarioBodyState gBodyStates[2];
|
||||
|
||||
extern Gfx *Geo18_802764B0(s32 a, struct GraphNode *b, Mat4 *c);
|
||||
extern Gfx *geo_draw_mario_head_goddard(s32 a, struct GraphNode *b, Mat4 *c);
|
||||
extern void bhvToadMessage_loop(void);
|
||||
extern void bhvToadMessage_init(void);
|
||||
extern void bhvUnlockDoorStar_init(void);
|
||||
extern void bhvUnlockDoorStar_loop(void);
|
||||
extern Gfx *Geo18_802770A4(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mirror_mario_set_alpha(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_stand_run(s32 run, struct GraphNode *node, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *c);
|
||||
extern Gfx *Geo18_80277294(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *Geo18_802773A4(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mario_tilt_torso(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mario_head_rotation(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_hand(s32 run, struct GraphNode *node, UNUSED Mat4 *c);
|
||||
extern Gfx *Geo18_802775CC(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mario_hand_foot_scaler(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_cap_effect(s32 run, struct GraphNode *node, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_cap_on_off(s32 run, struct GraphNode *node, UNUSED Mat4 *c);
|
||||
extern Gfx *Geo18_80277824(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mario_rotate_wing_cap_wings(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *c);
|
||||
extern Gfx *Geo1C_8027795C(s32 a, struct GraphNode *b, Mat4 *c);
|
||||
extern Gfx *geo_render_mirror_mario(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
extern Gfx *geo_mirror_mario_backface_culling(s32 a, struct GraphNode *b, UNUSED Mat4 *c);
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollision
|
||||
//! Bully battery
|
||||
}
|
||||
|
||||
void init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, f32 forwardVel,
|
||||
s16 yaw, f32 conversionRatio, f32 radius) {
|
||||
BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
|
||||
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius) {
|
||||
if (forwardVel < 0.0f) {
|
||||
forwardVel *= -1.0f;
|
||||
yaw += 0x8000;
|
||||
@@ -564,7 +564,7 @@ void apply_gravity(struct MarioState *m) {
|
||||
m->vel[1] = -16.0f;
|
||||
}
|
||||
} else if ((m->flags & MARIO_WING_CAP) && m->vel[1] < 0.0f && (m->input & INPUT_A_DOWN)) {
|
||||
m->marioBodyState->unk07 = 1;
|
||||
m->marioBodyState->wingFlutter = TRUE;
|
||||
|
||||
m->vel[1] -= 2.0f;
|
||||
if (m->vel[1] < -37.5f) {
|
||||
|
||||
+20
-11
@@ -42,13 +42,13 @@ struct MemoryBlock {
|
||||
u32 size;
|
||||
};
|
||||
|
||||
static uintptr_t sSegmentTable[32];
|
||||
extern uintptr_t sSegmentTable[32];
|
||||
extern u32 sPoolFreeSpace;
|
||||
extern u8 *sPoolStart;
|
||||
extern u8 *sPoolEnd;
|
||||
extern struct MainPoolBlock *sPoolListHeadL;
|
||||
extern struct MainPoolBlock *sPoolListHeadR;
|
||||
|
||||
static u32 sPoolFreeSpace;
|
||||
static u8 *sPoolStart;
|
||||
static u8 *sPoolEnd;
|
||||
static struct MainPoolBlock *sPoolListHeadL;
|
||||
static struct MainPoolBlock *sPoolListHeadR;
|
||||
|
||||
/**
|
||||
* Memory pool for small graphical effects that aren't connected to Objects.
|
||||
@@ -56,6 +56,14 @@ static struct MainPoolBlock *sPoolListHeadR;
|
||||
*/
|
||||
struct MemoryPool *gEffectsMemoryPool;
|
||||
|
||||
uintptr_t sSegmentTable[32];
|
||||
u32 sPoolFreeSpace;
|
||||
u8 *sPoolStart;
|
||||
u8 *sPoolEnd;
|
||||
struct MainPoolBlock *sPoolListHeadL;
|
||||
struct MainPoolBlock *sPoolListHeadR;
|
||||
|
||||
|
||||
static struct MainPoolState *gMainPoolState = NULL;
|
||||
|
||||
uintptr_t set_segment_base_addr(s32 segment, void *addr) {
|
||||
@@ -151,14 +159,14 @@ u32 main_pool_free(void *addr) {
|
||||
}
|
||||
sPoolListHeadL = block;
|
||||
sPoolListHeadL->next = NULL;
|
||||
sPoolFreeSpace += (u8 *) oldListHead - (u8 *) sPoolListHeadL;
|
||||
sPoolFreeSpace += (uintptr_t) oldListHead - (uintptr_t) sPoolListHeadL;
|
||||
} else {
|
||||
while (oldListHead->prev != NULL) {
|
||||
oldListHead = oldListHead->prev;
|
||||
}
|
||||
sPoolListHeadR = block->next;
|
||||
sPoolListHeadR->prev = NULL;
|
||||
sPoolFreeSpace += (u8 *) sPoolListHeadR - (u8 *) oldListHead;
|
||||
sPoolFreeSpace += (uintptr_t) sPoolListHeadR - (uintptr_t) oldListHead;
|
||||
}
|
||||
return sPoolFreeSpace;
|
||||
}
|
||||
@@ -537,9 +545,10 @@ s32 func_80278AD4(struct MarioAnimation *a, u32 index) {
|
||||
u32 size;
|
||||
|
||||
if (index < sp20->count) {
|
||||
addr = sp20->srcAddr + sp20->anim[index].offset;
|
||||
size = sp20->anim[index].size;
|
||||
|
||||
do {
|
||||
addr = sp20->srcAddr + sp20->anim[index].offset;
|
||||
size = sp20->anim[index].size;
|
||||
} while (0);
|
||||
if (a->currentAnimAddr != addr) {
|
||||
dma_read((u8 *) a->targetAnim, addr, addr + size);
|
||||
a->currentAnimAddr = addr;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "engine/surface_collision.h"
|
||||
#include "geo_misc.h"
|
||||
#include "rendering_graph_node.h"
|
||||
#include "room.h"
|
||||
#include "object_list_processor.h"
|
||||
|
||||
/**
|
||||
* This file contains functions for generating display lists with moving textures
|
||||
@@ -448,19 +448,9 @@ Gfx *movtex_gen_from_quad(s16 y, struct MovtexQuad *quad) {
|
||||
if (textureId == TEXTURE_MIST) { // an ia16 texture
|
||||
if (0) {
|
||||
}
|
||||
gDPSetTextureImage(gfx++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gMovtexIdToTexture[textureId]);
|
||||
gDPTileSync(gfx++);
|
||||
gDPSetTile(gfx++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0,
|
||||
G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
|
||||
gDPLoadSync(gfx++);
|
||||
gDPLoadBlock(gfx++, G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES));
|
||||
gLoadBlockTexture(gfx++, 32, 32, G_IM_FMT_IA, gMovtexIdToTexture[textureId]);
|
||||
} else { // any rgba16 texture
|
||||
gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gMovtexIdToTexture[textureId]);
|
||||
gDPTileSync(gfx++);
|
||||
gDPSetTile(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0,
|
||||
G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
|
||||
gDPLoadSync(gfx++);
|
||||
gDPLoadBlock(gfx++, G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES));
|
||||
gLoadBlockTexture(gfx++, 32, 32, G_IM_FMT_RGBA, gMovtexIdToTexture[textureId]);
|
||||
if (0) {
|
||||
}
|
||||
}
|
||||
@@ -830,12 +820,7 @@ Gfx *movtex_gen_list(s16 *movtexVerts, struct MovtexObject *movtexList, s8 attrL
|
||||
}
|
||||
|
||||
gSPDisplayList(gfx++, movtexList->beginDl);
|
||||
gDPSetTextureImage(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gMovtexIdToTexture[movtexList->textureId]);
|
||||
gDPTileSync(gfx++);
|
||||
gDPSetTile(gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0,
|
||||
G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
|
||||
gDPLoadSync(gfx++);
|
||||
gDPLoadBlock(gfx++, G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES));
|
||||
gLoadBlockTexture(gfx++, 32, 32, G_IM_FMT_RGBA, gMovtexIdToTexture[movtexList->textureId]);
|
||||
gSPVertex(gfx++, VIRTUAL_TO_PHYSICAL2(verts), movtexList->vtx_count, 0);
|
||||
gSPDisplayList(gfx++, movtexList->triDl);
|
||||
gSPDisplayList(gfx++, movtexList->endDl);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "behavior_actions.h"
|
||||
#include "spawn_object.h"
|
||||
#include "spawn_sound.h"
|
||||
#include "room.h"
|
||||
#include "envfx_bubbles.h"
|
||||
#include "ingame_menu.h"
|
||||
#include "interaction.h"
|
||||
@@ -148,7 +147,7 @@ s32 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ)
|
||||
hitbox.x = objNewX;
|
||||
hitbox.y = objY;
|
||||
hitbox.z = objNewZ;
|
||||
hitbox.offsetY = o->hitboxHeight / 2.0f;
|
||||
hitbox.offsetY = o->hitboxHeight / 2;
|
||||
hitbox.radius = o->hitboxRadius;
|
||||
|
||||
if (find_wall_collisions(&hitbox) != 0) {
|
||||
@@ -275,7 +274,7 @@ void calc_new_obj_vel_and_pos_y(struct Surface *objFloor, f32 objFloorY, f32 obj
|
||||
|
||||
// Bounces an object if the ground is hit fast enough.
|
||||
if (o->oVelY < -17.5) {
|
||||
o->oVelY = -(o->oVelY / 2.0f);
|
||||
o->oVelY = -(o->oVelY / 2);
|
||||
} else {
|
||||
o->oVelY = 0;
|
||||
}
|
||||
@@ -413,7 +412,7 @@ void obj_splash(s32 waterY, s32 objY) {
|
||||
* Generic object move function. Handles walls, water, floors, and gravity.
|
||||
* Returns flags for certain interactions.
|
||||
*/
|
||||
s32 object_step(void) {
|
||||
s16 object_step(void) {
|
||||
f32 objX = o->oPosX;
|
||||
f32 objY = o->oPosY;
|
||||
f32 objZ = o->oPosZ;
|
||||
@@ -463,15 +462,9 @@ s32 object_step(void) {
|
||||
/**
|
||||
* Takes an object step but does not orient with the object's floor.
|
||||
* Used for boulders, falling pillars, and the rolling snowman body.
|
||||
*
|
||||
* TODO: Fix fake EU matching.
|
||||
*/
|
||||
s32 object_step_without_floor_orient(void) {
|
||||
#ifdef VERSION_EU
|
||||
s32 collisionFlags = 0;
|
||||
#else
|
||||
s16 object_step_without_floor_orient(void) {
|
||||
s16 collisionFlags = 0;
|
||||
#endif
|
||||
sOrientObjWithFloor = FALSE;
|
||||
collisionFlags = object_step();
|
||||
sOrientObjWithFloor = TRUE;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "spawn_sound.h"
|
||||
#include "geo_misc.h"
|
||||
#include "save_file.h"
|
||||
#include "room.h"
|
||||
#include "level_table.h"
|
||||
|
||||
extern struct Animation *wiggler_seg5_anims_0500C874[];
|
||||
@@ -113,6 +112,12 @@ extern struct Animation *spiny_seg5_anims_05016EAC[];
|
||||
|
||||
#define o gCurrentObject
|
||||
|
||||
/**
|
||||
* The treadmill that plays sounds and controls the others on random setting.
|
||||
*/
|
||||
struct Object *sMasterTreadmill;
|
||||
|
||||
|
||||
f32 sObjSavedPosX;
|
||||
f32 sObjSavedPosY;
|
||||
f32 sObjSavedPosZ;
|
||||
@@ -165,7 +170,9 @@ static s32 obj_is_near_to_and_facing_mario(f32 maxDist, s16 maxAngleDiff) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void obj_perform_position_op(s32 op) {
|
||||
//! Although having no return value, this function
|
||||
//! must be u32 to match other functions on -O2.
|
||||
static BAD_RETURN(u32) obj_perform_position_op(s32 op) {
|
||||
switch (op) {
|
||||
case POS_OP_SAVE_POSITION:
|
||||
sObjSavedPosX = o->oPosX;
|
||||
@@ -655,17 +662,27 @@ static s32 obj_resolve_collisions_and_turn(s16 targetYaw, s16 turnSpeed) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Likely scrub C, needs true matching code.
|
||||
static void obj_die_if_health_non_positive(void) {
|
||||
#ifdef VERSION_EU
|
||||
s32 new_var;
|
||||
#endif
|
||||
|
||||
if (o->oHealth <= 0) {
|
||||
if (o->oDeathSound == 0) {
|
||||
func_802A3034(SOUND_OBJ_DEFAULT_DEATH);
|
||||
} else if (o->oDeathSound > 0) {
|
||||
#ifdef VERSION_EU
|
||||
new_var = o->oDeathSound;
|
||||
func_802A3034(new_var);
|
||||
#else
|
||||
func_802A3034(o->oDeathSound);
|
||||
#endif
|
||||
} else {
|
||||
func_802A3004();
|
||||
}
|
||||
|
||||
if (o->oNumLootCoins < 0) {
|
||||
if ((s32)o->oNumLootCoins < 0) {
|
||||
spawn_object(o, MODEL_BLUE_COIN, bhvMrIBlueCoin);
|
||||
} else {
|
||||
spawn_object_loot_yellow_coins(o, o->oNumLootCoins, 20.0f);
|
||||
|
||||
+103
-19
@@ -23,7 +23,6 @@
|
||||
#include "obj_behaviors.h"
|
||||
#include "interaction.h"
|
||||
#include "object_list_processor.h"
|
||||
#include "room.h"
|
||||
#include "level_table.h"
|
||||
#include "dialog_ids.h"
|
||||
|
||||
@@ -396,10 +395,8 @@ s16 angle_to_object(struct Object *obj1, struct Object *obj2) {
|
||||
f32 z1, x1, z2, x2;
|
||||
s16 angle;
|
||||
|
||||
z1 = obj1->oPosZ;
|
||||
z2 = obj2->oPosZ;
|
||||
x1 = obj1->oPosX;
|
||||
x2 = obj2->oPosX;
|
||||
z1 = obj1->oPosZ; z2 = obj2->oPosZ; //ordering of instructions..
|
||||
x1 = obj1->oPosX; x2 = obj2->oPosX;
|
||||
|
||||
angle = atan2s(z2 - z1, x2 - x1);
|
||||
return angle;
|
||||
@@ -982,19 +979,17 @@ void func_8029F684(f32 f12, f32 f14) {
|
||||
}
|
||||
}
|
||||
|
||||
void func_8029F6F0(void) {
|
||||
BAD_RETURN(s16) func_8029F6F0(void) {
|
||||
if (o->header.gfx.unk38.animFrame >= 0) {
|
||||
o->header.gfx.unk38.animFrame--;
|
||||
}
|
||||
}
|
||||
|
||||
void func_8029F728(void) {
|
||||
BAD_RETURN(s32) func_8029F728(void) {
|
||||
s32 sp4 = o->header.gfx.unk38.animFrame;
|
||||
s32 sp0 = o->header.gfx.unk38.curAnim->unk08 - 2;
|
||||
|
||||
if (sp4 == sp0) {
|
||||
o->header.gfx.unk38.animFrame--;
|
||||
}
|
||||
|
||||
if (sp4 == sp0) o->header.gfx.unk38.animFrame--;
|
||||
}
|
||||
|
||||
s32 func_8029F788(void) {
|
||||
@@ -1203,19 +1198,19 @@ struct Surface *obj_update_floor_height_and_get_floor(void) {
|
||||
static void apply_drag_to_value(f32 *value, f32 dragStrength) {
|
||||
f32 decel;
|
||||
|
||||
if (*value != 0.0f) {
|
||||
if (*value != 0) {
|
||||
//! Can overshoot if |*value| > 1/(dragStrength * 0.0001)
|
||||
decel = (*value) * (*value) * (dragStrength * 0.0001L);
|
||||
|
||||
if (*value > 0) {
|
||||
*value -= decel;
|
||||
if (*value < 0.001L) {
|
||||
*value = 0.0f;
|
||||
*value = 0;
|
||||
}
|
||||
} else {
|
||||
*value += decel;
|
||||
if (*value > -0.001L) {
|
||||
*value = 0.0f;
|
||||
*value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1828,8 +1823,9 @@ void obj_move_standard(s16 steepSlopeAngleDegrees) {
|
||||
// Objects that do this will be marked with //PARTIAL_UPDATE.
|
||||
if (!(o->activeFlags & (ACTIVE_FLAG_FAR_AWAY | ACTIVE_FLAG_IN_DIFFERENT_ROOM))) {
|
||||
if (steepSlopeAngleDegrees < 0) {
|
||||
careAboutEdgesAndSteepSlopes = TRUE;
|
||||
steepSlopeAngleDegrees = -steepSlopeAngleDegrees;
|
||||
// clang-format off
|
||||
careAboutEdgesAndSteepSlopes = TRUE; steepSlopeAngleDegrees = -steepSlopeAngleDegrees;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
steepSlopeNormalY = coss(steepSlopeAngleDegrees * (0x10000 / 360));
|
||||
@@ -2065,7 +2061,7 @@ void chain_segment_init(struct ChainSegment *segment) {
|
||||
}
|
||||
|
||||
f32 random_f32_around_zero(f32 diameter) {
|
||||
return RandomFloat() * diameter - diameter / 2.0f;
|
||||
return RandomFloat() * diameter - diameter / 2;
|
||||
}
|
||||
|
||||
void scale_object_random(struct Object *obj, f32 rangeLength, f32 minScale) {
|
||||
@@ -2102,10 +2098,75 @@ void func_802A2A38(void) {
|
||||
o->oPosZ += o->oVelZ;
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
//this is a test to see if object is possibly built wrong
|
||||
//it matches
|
||||
struct Object_test
|
||||
{
|
||||
/*0x000*/ struct ObjectNode header;
|
||||
/*0x068*/ struct Object *parentObj;
|
||||
/*0x06C*/ struct Object *prevObj;
|
||||
/*0x070*/ u32 collidedObjInteractTypes;
|
||||
/*0x074*/ s16 activeFlags;
|
||||
/*0x076*/ s16 numCollidedObjs;
|
||||
/*0x078*/ struct Object *collidedObjs[4];
|
||||
/*0x088*/
|
||||
union
|
||||
{
|
||||
struct {
|
||||
u8 pad[0xF*4];
|
||||
s32 MoveAnglePitch;
|
||||
s32 MoveAngleYaw;
|
||||
s32 MoveAngleRoll;
|
||||
u8 pad2[0x4B*4-0xF*4-3*4];
|
||||
struct {
|
||||
u32 WallAngle;
|
||||
} special;
|
||||
} moving;
|
||||
// Object fields. See object_fields.h.
|
||||
u32 asU32[0x50];
|
||||
s32 asS32[0x50];
|
||||
s16 asS16[0x50][2];
|
||||
f32 asF32[0x50];
|
||||
s16 *asS16P[0x50];
|
||||
s32 *asS32P[0x50];
|
||||
struct Animation **asAnims[0x50];
|
||||
struct Waypoint *asWaypoint[0x50];
|
||||
struct ChainSegment *asChainSegment[0x50];
|
||||
struct Object *asObject[0x50];
|
||||
struct Surface *asSurface[0x50];
|
||||
void *asVoidPtr[0x50];
|
||||
const void *asConstVoidPtr[0x50];
|
||||
} rawData;
|
||||
/*0x1C8*/ u32 unused1;
|
||||
/*0x1CC*/ const BehaviorScript *behScript;
|
||||
/*0x1D0*/ u32 stackIndex;
|
||||
/*0x1D4*/ uintptr_t stack[8];
|
||||
/*0x1F4*/ s16 unk1F4;
|
||||
/*0x1F6*/ s16 respawnInfoType;
|
||||
/*0x1F8*/ f32 hitboxRadius;
|
||||
/*0x1FC*/ f32 hitboxHeight;
|
||||
/*0x200*/ f32 hurtboxRadius;
|
||||
/*0x204*/ f32 hurtboxHeight;
|
||||
/*0x208*/ f32 hitboxDownOffset;
|
||||
/*0x20C*/ const BehaviorScript *behavior;
|
||||
/*0x210*/ u32 unused2;
|
||||
/*0x214*/ struct Object *platform;
|
||||
/*0x218*/ void *collisionData;
|
||||
/*0x21C*/ Mat4 transform;
|
||||
/*0x25C*/ void *respawnInfo;
|
||||
};
|
||||
|
||||
s16 obj_reflect_move_angle_off_wall(void) {
|
||||
s16 angle = ((struct Object_test*)o)->rawData.moving.special.WallAngle - (s16) ((struct Object_test*)o)->rawData.moving.MoveAngleYaw + (s16) ((struct Object_test*)o)->rawData.moving.special.WallAngle +0x8000;
|
||||
return angle;
|
||||
}
|
||||
#else
|
||||
s16 obj_reflect_move_angle_off_wall(void) {
|
||||
s16 angle = o->oWallAngle - ((s16) o->oMoveAngleYaw - (s16) o->oWallAngle) + 0x8000;
|
||||
return angle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void obj_spawn_particles(struct SpawnParticlesInfo *info) {
|
||||
struct Object *particle;
|
||||
@@ -2285,7 +2346,7 @@ s32 func_802A32E0(void) {
|
||||
return spF;
|
||||
}
|
||||
|
||||
static void nop_802A3380(UNUSED s32 sp0, UNUSED s32 sp4) {
|
||||
void nop_802A3380(UNUSED s32 sp0, UNUSED s32 sp4) {
|
||||
}
|
||||
|
||||
void func_802A3398(s32 a0, s32 a1, f32 sp10, f32 sp14) {
|
||||
@@ -2312,7 +2373,7 @@ void func_802A3470(void) {
|
||||
obj_scale(gDebugInfo[5][3] / 100.0f + 1.0l);
|
||||
}
|
||||
|
||||
static void nop_802A3544(void) {
|
||||
void nop_802A3544(void) {
|
||||
}
|
||||
|
||||
s32 obj_is_mario_on_platform(void) {
|
||||
@@ -2860,6 +2921,28 @@ s32 obj_check_grabbed_mario(void) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU) // Fake match
|
||||
s32 player_performed_grab_escape_action(void) {
|
||||
s32 result = FALSE;
|
||||
s32 grabEscape = TRUE;
|
||||
// using register here causes less differences with non-EU versions
|
||||
register f32 stickMag = gPlayer1Controller->stickMag;
|
||||
if (stickMag < 30.0f) {
|
||||
sGrabReleaseState = 0;
|
||||
}
|
||||
|
||||
if (sGrabReleaseState == 0 && stickMag > 40.0f) {
|
||||
sGrabReleaseState = grabEscape;
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (gPlayer1Controller->buttonPressed & A_BUTTON) {
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
s32 player_performed_grab_escape_action(void) {
|
||||
s32 result = FALSE;
|
||||
|
||||
@@ -2878,6 +2961,7 @@ s32 player_performed_grab_escape_action(void) {
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
void obj_unused_play_footstep_sound(s32 animFrame1, s32 animFrame2, s32 sound) {
|
||||
if (obj_check_anim_frame(animFrame1) || obj_check_anim_frame(animFrame2)) {
|
||||
|
||||
@@ -74,7 +74,7 @@ extern struct GraphNode **gLoadedGraphNodes;
|
||||
// extern ? D_8032F134;
|
||||
// extern const char* D_803366B0;
|
||||
// extern ? sKingBobombActions;
|
||||
extern s16 gMarioShotFromCannon;
|
||||
// extern s16 gMarioShotFromCannon;
|
||||
// extern ? sOpenedCannonActions;
|
||||
// extern ? D_803366B4;
|
||||
// extern ? D_803366BC;
|
||||
@@ -88,7 +88,7 @@ extern s16 gMarioShotFromCannon;
|
||||
// extern ? D_8032F284;
|
||||
// extern ? D_8032F294;
|
||||
// extern ? sCoinInsideBooActions;
|
||||
extern s16 D_8035FEE4;
|
||||
// extern s16 D_8035FEE4;
|
||||
// extern ? sGrindelThwompActions;
|
||||
// extern ? sTumblingBridgeParams;
|
||||
// extern ? sTumblingBridgeActions;
|
||||
@@ -240,8 +240,8 @@ struct Object* obj_find_nearby_held_actor(const BehaviorScript *,f32);
|
||||
// extern ? obj_reset_timer_and_subaction(?);
|
||||
void obj_change_action(s32);
|
||||
void func_8029F684(f32,f32);
|
||||
void func_8029F6F0(void);
|
||||
extern void func_8029F728(void);
|
||||
BAD_RETURN(s16) func_8029F6F0(void);
|
||||
extern BAD_RETURN(s32) func_8029F728(void);
|
||||
extern s32 func_8029F788(void);
|
||||
extern s32 func_8029F828(void);
|
||||
extern s32 obj_check_anim_frame(s32);
|
||||
|
||||
@@ -17,14 +17,9 @@
|
||||
#include "object_helpers.h"
|
||||
#include "platform_displacement.h"
|
||||
#include "engine/surface_load.h"
|
||||
#include "room.h"
|
||||
#include "object_list_processor.h"
|
||||
#include "mario.h"
|
||||
|
||||
/**
|
||||
* Nodes used to represent the doubly linked object lists.
|
||||
*/
|
||||
struct ObjectNode gObjectListArray[16];
|
||||
|
||||
/**
|
||||
* Flags controlling what debug info is displayed.
|
||||
@@ -148,6 +143,29 @@ s32 gNumStaticSurfaces;
|
||||
*/
|
||||
struct MemoryPool *gObjectMemoryPool;
|
||||
|
||||
|
||||
s16 gCheckingSurfaceCollisionsForCamera;
|
||||
s16 gFindFloorIncludeSurfaceIntangible;
|
||||
s16 *gEnvironmentRegions;
|
||||
s32 gEnvironmentLevels[20];
|
||||
s8 gDoorAdjacentRooms[60][2];
|
||||
s16 gMarioCurrentRoom;
|
||||
s16 D_8035FEE2;
|
||||
s16 D_8035FEE4;
|
||||
s16 gTHIWaterDrained;
|
||||
s16 gTTCSpeedSetting;
|
||||
s16 gMarioShotFromCannon;
|
||||
s16 gCCMEnteredSlide;
|
||||
s16 gNumRoomedObjectsInMarioRoom;
|
||||
s16 gNumRoomedObjectsNotInMarioRoom;
|
||||
s16 gWDWWaterLevelChanging;
|
||||
s16 gMarioOnMerryGoRound;
|
||||
|
||||
/**
|
||||
* Nodes used to represent the doubly linked object lists.
|
||||
*/
|
||||
struct ObjectNode gObjectListArray[16];
|
||||
|
||||
/**
|
||||
* The order that object lists are processed in a frame.
|
||||
*/
|
||||
|
||||
@@ -96,6 +96,23 @@ extern s32 gNumStaticSurfaces;
|
||||
|
||||
extern struct MemoryPool *gObjectMemoryPool;
|
||||
|
||||
extern s16 gCheckingSurfaceCollisionsForCamera;
|
||||
extern s16 gFindFloorIncludeSurfaceIntangible;
|
||||
extern s16 *gEnvironmentRegions;
|
||||
extern s32 gEnvironmentLevels[20];
|
||||
extern s8 gDoorAdjacentRooms[60][2];
|
||||
extern s16 gMarioCurrentRoom;
|
||||
extern s16 D_8035FEE2;
|
||||
extern s16 D_8035FEE4;
|
||||
extern s16 gTHIWaterDrained;
|
||||
extern s16 gTTCSpeedSetting;
|
||||
extern s16 gMarioShotFromCannon;
|
||||
extern s16 gCCMEnteredSlide;
|
||||
extern s16 gNumRoomedObjectsInMarioRoom;
|
||||
extern s16 gNumRoomedObjectsNotInMarioRoom;
|
||||
extern s16 gWDWWaterLevelChanging;
|
||||
extern s16 gMarioOnMerryGoRound;
|
||||
|
||||
|
||||
void bhv_mario_update(void);
|
||||
void set_object_respawn_info_bits(struct Object *obj, u8 bits);
|
||||
|
||||
@@ -605,12 +605,7 @@ void *func_802D3CF0(u8 *img, s16 tWidth, s16 tHeight, s16 *d, s16 e, s16 f, u8 g
|
||||
if (verts == NULL || sp80 == NULL) {
|
||||
}
|
||||
|
||||
gDPSetTextureImage(sp7C++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, img);
|
||||
gDPTileSync(sp7C++);
|
||||
gDPSetTile(sp7C++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0,
|
||||
G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD);
|
||||
gDPLoadSync(sp7C++);
|
||||
gDPLoadBlock(sp7C++, G_TX_LOADTILE, 0, 0, tWidth * tHeight - 1, CALC_DXT(tWidth, G_IM_SIZ_16b_BYTES))
|
||||
gLoadBlockTexture(sp7C++, tWidth, tHeight, G_IM_FMT_RGBA, img);
|
||||
|
||||
for (sp9E = 0; sp9E < sp90; sp9E++) {
|
||||
sp9A = e * 3 + sp9E * 15 + 2;
|
||||
|
||||
+2
-6
@@ -83,9 +83,7 @@ void format_integer(s32 n, s32 base, char *dest, s32 *totalLength, u8 width, s8
|
||||
|
||||
// Add leading pad to fit width.
|
||||
if (width > numDigits) {
|
||||
for (len = 0; len < width - numDigits; len++) {
|
||||
dest[len] = pad;
|
||||
}
|
||||
for (len = 0; len < width - numDigits; len++) dest[len] = pad;
|
||||
|
||||
// Needs 1 length to print negative prefix.
|
||||
if (negative == TRUE) {
|
||||
@@ -117,9 +115,7 @@ void format_integer(s32 n, s32 base, char *dest, s32 *totalLength, u8 width, s8
|
||||
{
|
||||
numDigits = 1;
|
||||
if (width > numDigits) {
|
||||
for (len = 0; len < width - numDigits; len++) {
|
||||
dest[len] = pad;
|
||||
}
|
||||
for (len = 0; len < width - numDigits; len++) dest[len] = pad;
|
||||
}
|
||||
dest[len] = '0';
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "sm64.h"
|
||||
#include "room.h"
|
||||
|
||||
s16 gCheckingSurfaceCollisionsForCamera;
|
||||
s16 gFindFloorIncludeSurfaceIntangible;
|
||||
s16 *gEnvironmentRegions;
|
||||
s32 gEnvironmentLevels[20];
|
||||
s8 gDoorAdjacentRooms[60][2];
|
||||
s16 gMarioCurrentRoom;
|
||||
s16 D_8035FEE2;
|
||||
s16 D_8035FEE4;
|
||||
s16 gTHIWaterDrained;
|
||||
s16 gTTCSpeedSetting;
|
||||
s16 gMarioShotFromCannon;
|
||||
s16 gCCMEnteredSlide;
|
||||
s16 gNumRoomedObjectsInMarioRoom;
|
||||
s16 gNumRoomedObjectsNotInMarioRoom;
|
||||
s16 gWDWWaterLevelChanging;
|
||||
s16 gMarioOnMerryGoRound;
|
||||
@@ -1,23 +0,0 @@
|
||||
#ifndef ROOM_H
|
||||
#define ROOM_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
extern s16 gCheckingSurfaceCollisionsForCamera;
|
||||
extern s16 gFindFloorIncludeSurfaceIntangible;
|
||||
extern s16 *gEnvironmentRegions;
|
||||
extern s32 gEnvironmentLevels[20];
|
||||
extern s8 gDoorAdjacentRooms[60][2];
|
||||
extern s16 gMarioCurrentRoom;
|
||||
extern s16 D_8035FEE2;
|
||||
extern s16 D_8035FEE4;
|
||||
extern s16 gTHIWaterDrained;
|
||||
extern s16 gTTCSpeedSetting;
|
||||
extern s16 gMarioShotFromCannon;
|
||||
extern s16 gCCMEnteredSlide;
|
||||
extern s16 gNumRoomedObjectsInMarioRoom;
|
||||
extern s16 gNumRoomedObjectsNotInMarioRoom;
|
||||
extern s16 gWDWWaterLevelChanging;
|
||||
extern s16 gMarioOnMerryGoRound;
|
||||
|
||||
#endif /* ROOM_H */
|
||||
@@ -96,7 +96,7 @@ static s32 write_eeprom_data(void *buffer, s32 size) {
|
||||
* Sum the bytes in data to data + size - 2. The last two bytes are ignored
|
||||
* because that is where the checksum is stored.
|
||||
*/
|
||||
static s32 calc_checksum(u8 *data, s32 size) {
|
||||
static u16 calc_checksum(u8 *data, s32 size) {
|
||||
u16 chksum = 0;
|
||||
|
||||
while (size-- > 2) {
|
||||
@@ -262,7 +262,8 @@ void save_file_erase(s32 fileIndex) {
|
||||
save_file_do_save(fileIndex);
|
||||
}
|
||||
|
||||
void save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
|
||||
//! Needs to be s32 to match on -O2, despite no return value.
|
||||
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
|
||||
UNUSED s32 pad;
|
||||
|
||||
touch_high_score_ages(destFileIndex);
|
||||
@@ -448,18 +449,18 @@ s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse)
|
||||
return save_file_get_course_star_count(fileIndex, -1) + count;
|
||||
}
|
||||
|
||||
void save_file_set_flags(s32 flags) {
|
||||
void save_file_set_flags(u32 flags) {
|
||||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= (flags | SAVE_FLAG_FILE_EXISTS);
|
||||
gSaveFileModified = TRUE;
|
||||
}
|
||||
|
||||
void save_file_clear_flags(s32 flags) {
|
||||
void save_file_clear_flags(u32 flags) {
|
||||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags &= ~flags;
|
||||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= SAVE_FLAG_FILE_EXISTS;
|
||||
gSaveFileModified = TRUE;
|
||||
}
|
||||
|
||||
s32 save_file_get_flags(void) {
|
||||
u32 save_file_get_flags(void) {
|
||||
if (gCurrCreditsEntry != 0 || gCurrDemoInput != NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -470,8 +471,8 @@ s32 save_file_get_flags(void) {
|
||||
* Return the bitset of obtained stars in the specified course.
|
||||
* If course is -1, return the bitset of obtained castle secret stars.
|
||||
*/
|
||||
s32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) {
|
||||
s32 starFlags;
|
||||
u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) {
|
||||
u32 starFlags;
|
||||
|
||||
if (courseIndex == -1) {
|
||||
starFlags = (gSaveBuffer.files[fileIndex][0].flags >> 24) & 0x7F;
|
||||
@@ -486,7 +487,7 @@ s32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) {
|
||||
* Add to the bitset of obtained stars in the specified course.
|
||||
* If course is -1, add ot the bitset of obtained castle secret stars.
|
||||
*/
|
||||
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, s32 starFlags) {
|
||||
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags) {
|
||||
if (courseIndex == -1) {
|
||||
gSaveBuffer.files[fileIndex][0].flags |= starFlags << 24;
|
||||
} else {
|
||||
|
||||
@@ -123,7 +123,7 @@ extern s8 gSaveFileModified;
|
||||
|
||||
void save_file_do_save(s32 fileIndex);
|
||||
void save_file_erase(s32 fileIndex);
|
||||
void save_file_copy(s32 srcFileIndex, s32 destFileIndex);
|
||||
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex);
|
||||
void save_file_load_all(void);
|
||||
void save_file_reload(void);
|
||||
void save_file_collect_star_or_key(s16 coinScore, s16 starIndex);
|
||||
@@ -131,11 +131,11 @@ s32 save_file_exists(s32 fileIndex);
|
||||
u32 save_file_get_max_coin_score(s32 courseIndex);
|
||||
s32 save_file_get_course_star_count(s32 fileIndex, s32 courseIndex);
|
||||
s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse);
|
||||
void save_file_set_flags(s32 flags);
|
||||
void save_file_clear_flags(s32 flags);
|
||||
s32 save_file_get_flags(void);
|
||||
s32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex);
|
||||
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, s32 starFlags);
|
||||
void save_file_set_flags(u32 flags);
|
||||
void save_file_clear_flags(u32 flags);
|
||||
u32 save_file_get_flags(void);
|
||||
u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex);
|
||||
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags);
|
||||
s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex);
|
||||
s32 save_file_is_cannon_unlocked(void);
|
||||
void save_file_set_cannon_unlocked(void);
|
||||
|
||||
Loaded 100 of 236 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user