Merge branch 'develop/2.1.0' of https://github.com/HackerN64/HackerSM64 into develop/2.1.0-four-controllers-base
This commit is contained in:
commit
50b4ebf051
142 files changed
+20123
-3946
No files matched your search
+88
-158
@@ -43,7 +43,7 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
// Each entry represents an array of variable audio buffer sizes / delays for each respective filter.
|
||||
u32 delaysArr[][NUM_ALLPASS] = {
|
||||
u32 sReverbDelaysArr[][NUM_ALLPASS] = {
|
||||
{ /* 0 */
|
||||
4, 4, 4,
|
||||
4, 4, 4,
|
||||
@@ -65,8 +65,7 @@ u32 delaysArr[][NUM_ALLPASS] = {
|
||||
};
|
||||
|
||||
// Each entry represents an array of multipliers applied to the final output of each group of 3 filters.
|
||||
// These values are u8s in spirit, but are set as s32 values to slightly increase performance during calculations.
|
||||
s32 reverbMultsArr[][NUM_ALLPASS / 3] = {
|
||||
u8 sReverbMultsArr[][NUM_ALLPASS / 3] = {
|
||||
/* 0 */ {0x00, 0x00, 0x00, 0x00},
|
||||
/* 1 */ {0xD7, 0x6F, 0x36, 0x22},
|
||||
/* 2 */ {0xCF, 0x73, 0x38, 0x1F},
|
||||
@@ -75,11 +74,11 @@ s32 reverbMultsArr[][NUM_ALLPASS / 3] = {
|
||||
/**
|
||||
* Format:
|
||||
* - useLightweightSettings (Reduce some runtime configurability options in favor of a slight speed boost during processing; Light configurability settings are found in synthesis.h)
|
||||
* - downsampleRate (Higher values exponentially reduce the number of input samples to process, improving perfomance at cost of quality)
|
||||
* - downsampleRate (Higher values exponentially reduce the number of input samples to process, improving perfomance at cost of quality; number <= 0 signifies use of vanilla reverb)
|
||||
* - isMono (Only process reverb on the left channel and share it with the right channel, improving performance at cost of quality)
|
||||
* - filterCount (Number of filters to process data with; in general, more filters means higher quality at the cost of performance demand; always 3 with light settings)
|
||||
*
|
||||
* - windowSize (Size of circular reverb buffer; higher values work better for a more open soundscape, lower is better for a more compact sound)
|
||||
* - windowSize (Size of circular reverb buffer; higher values work better for a more open soundscape, lower is better for a more compact sound; value of 0 disables all reverb)
|
||||
* - gain (Amount of audio retransmitted into the circular reverb buffer, emulating decay; higher values represent a lengthier decay period)
|
||||
* - gainIndex (Advanced parameter; used to tune the outputs of every first two of three filters; overridden when using light settings)
|
||||
* - reverbIndex (Advanced parameter; used to tune the incoming output of every third filter; overridden when using light settings)
|
||||
@@ -94,55 +93,98 @@ s32 reverbMultsArr[][NUM_ALLPASS / 3] = {
|
||||
*/
|
||||
struct BetterReverbSettings gBetterReverbSettings[] = {
|
||||
{ /* Preset 0 - Vanilla Reverb [Default Preset] */
|
||||
.useLightweightSettings = FALSE, // Ignored with vanilla reverb
|
||||
.downsampleRate = -1, // Signifies use of vanilla reverb
|
||||
.isMono = FALSE, // Ignored with vanilla reverb
|
||||
.filterCount = NUM_ALLPASS, // Ignored with vanilla reverb
|
||||
.useLightweightSettings = FALSE, // Ignored with vanilla reverb
|
||||
.downsampleRate = -1, // Signifies use of vanilla reverb
|
||||
.isMono = FALSE, // Ignored with vanilla reverb
|
||||
.filterCount = NUM_ALLPASS, // Ignored with vanilla reverb
|
||||
|
||||
.windowSize = -1, // Use vanilla preset window size
|
||||
.gain = -1, // Use vanilla preset gain value
|
||||
.gainIndex = 0x00, // Ignored with vanilla reverb
|
||||
.reverbIndex = 0x00, // Ignored with vanilla reverb
|
||||
.windowSize = -1, // Use vanilla preset window size
|
||||
.gain = -1, // Use vanilla preset gain value
|
||||
.gainIndex = 0x00, // Ignored with vanilla reverb
|
||||
.reverbIndex = 0x00, // Ignored with vanilla reverb
|
||||
|
||||
.delaysL = delaysArr[0], // Ignored with vanilla reverb
|
||||
.delaysR = delaysArr[0], // Ignored with vanilla reverb
|
||||
.reverbMultsL = reverbMultsArr[0], // Ignored with vanilla reverb
|
||||
.reverbMultsR = reverbMultsArr[0], // Ignored with vanilla reverb
|
||||
.delaysL = sReverbDelaysArr[0], // Ignored with vanilla reverb
|
||||
.delaysR = sReverbDelaysArr[0], // Ignored with vanilla reverb
|
||||
.reverbMultsL = sReverbMultsArr[0], // Ignored with vanilla reverb
|
||||
.reverbMultsR = sReverbMultsArr[0], // Ignored with vanilla reverb
|
||||
},
|
||||
{ /* Preset 1 - Sample Console Configuration */
|
||||
.useLightweightSettings = TRUE,
|
||||
.downsampleRate = 2,
|
||||
.isMono = FALSE,
|
||||
.filterCount = (NUM_ALLPASS - 9), // Ignored with lightweight settings
|
||||
.filterCount = (NUM_ALLPASS - 9), // Ignored with lightweight settings
|
||||
|
||||
.windowSize = 0x0E00,
|
||||
.gain = 0x43FF,
|
||||
.gainIndex = 0xA0, // Ignored with lightweight settings
|
||||
.reverbIndex = 0x30, // Ignored with lightweight settings
|
||||
.gain = 0x2FFF,
|
||||
.gainIndex = 0xA0, // Ignored with lightweight settings
|
||||
.reverbIndex = 0x30, // Ignored with lightweight settings
|
||||
|
||||
.delaysL = delaysArr[1],
|
||||
.delaysR = delaysArr[2],
|
||||
.reverbMultsL = reverbMultsArr[1], // Ignored with lightweight settings
|
||||
.reverbMultsR = reverbMultsArr[2], // Ignored with lightweight settings
|
||||
.delaysL = sReverbDelaysArr[1],
|
||||
.delaysR = sReverbDelaysArr[2],
|
||||
.reverbMultsL = sReverbMultsArr[1], // Ignored with lightweight settings
|
||||
.reverbMultsR = sReverbMultsArr[2], // Ignored with lightweight settings
|
||||
},
|
||||
{ /* Preset 2 - Sample Emulator Configuration (RCVI Hack Only) */
|
||||
{ /* Preset 2 - Sample Emulator Configuration (RCVI Hack or Emulator CPU Overclocking Required!) */
|
||||
.useLightweightSettings = FALSE,
|
||||
.downsampleRate = 1,
|
||||
.isMono = FALSE,
|
||||
.filterCount = NUM_ALLPASS,
|
||||
|
||||
.windowSize = 0x0E00,
|
||||
.gain = 0x28FF,
|
||||
.gain = 0x2AFF,
|
||||
.gainIndex = 0xA0,
|
||||
.reverbIndex = 0x60,
|
||||
.reverbIndex = 0x40,
|
||||
|
||||
.delaysL = delaysArr[1],
|
||||
.delaysR = delaysArr[2],
|
||||
.reverbMultsL = reverbMultsArr[1],
|
||||
.reverbMultsR = reverbMultsArr[2],
|
||||
.delaysL = sReverbDelaysArr[1],
|
||||
.delaysR = sReverbDelaysArr[2],
|
||||
.reverbMultsL = sReverbMultsArr[1],
|
||||
.reverbMultsR = sReverbMultsArr[2],
|
||||
},
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
// Used for A/B comparisons and preset configuration debugging alongside Puppyprint Debug
|
||||
struct BetterReverbSettings gDebugBetterReverbSettings[2] = {
|
||||
{ /* Preset A */
|
||||
.useLightweightSettings = FALSE,
|
||||
.downsampleRate = 2,
|
||||
.isMono = FALSE,
|
||||
.filterCount = (NUM_ALLPASS - 9),
|
||||
|
||||
.windowSize = 0x0E00,
|
||||
.gain = 0x2FFF,
|
||||
.gainIndex = 0xA0,
|
||||
.reverbIndex = 0x30,
|
||||
|
||||
.delaysL = sReverbDelaysArr[1],
|
||||
.delaysR = sReverbDelaysArr[2],
|
||||
.reverbMultsL = sReverbMultsArr[1],
|
||||
.reverbMultsR = sReverbMultsArr[2],
|
||||
},
|
||||
{ /* Preset B */
|
||||
.useLightweightSettings = FALSE,
|
||||
.downsampleRate = 2,
|
||||
.isMono = FALSE,
|
||||
.filterCount = (NUM_ALLPASS - 9),
|
||||
|
||||
.windowSize = 0x0E00,
|
||||
.gain = 0x2FFF,
|
||||
.gainIndex = 0xA0,
|
||||
.reverbIndex = 0x30,
|
||||
|
||||
.delaysL = sReverbDelaysArr[1],
|
||||
.delaysR = sReverbDelaysArr[2],
|
||||
.reverbMultsL = sReverbMultsArr[1],
|
||||
.reverbMultsR = sReverbMultsArr[2],
|
||||
},
|
||||
};
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
|
||||
STATIC_ASSERT(ARRAY_COUNT(gBetterReverbSettings) > 0, "gBetterReverbSettings must contain presets!");
|
||||
STATIC_ASSERT(ARRAY_COUNT(sReverbDelaysArr) > 0, "sReverbDelaysArr must not be empty!");
|
||||
STATIC_ASSERT(ARRAY_COUNT(sReverbMultsArr) > 0, "sReverbMultsArr must not be empty!");
|
||||
|
||||
#endif // BETTER_REVERB
|
||||
|
||||
// Format:
|
||||
// - frequency
|
||||
@@ -613,8 +655,10 @@ u16 gHeadsetPanQuantization[0x10] = {
|
||||
0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0,
|
||||
};
|
||||
#elif !defined(VERSION_SH)
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
u16 gHeadsetPanQuantization[10] = { 0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0 };
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
s16 euUnknownData_80301950[64] = {
|
||||
@@ -623,6 +667,7 @@ s16 euUnknownData_80301950[64] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
// Linearly interpolated between
|
||||
// f(0/2 * 127) = 1
|
||||
// f(1/2 * 127) = 1/sqrt(2)
|
||||
@@ -668,6 +713,7 @@ f32 gStereoPanVolume[128] = {
|
||||
0.242161f, 0.253295f, 0.264429f, 0.275563f, 0.286697f, 0.297831f, 0.308965f, 0.320098f, 0.331232f,
|
||||
0.342366f, 0.3535f
|
||||
};
|
||||
#endif
|
||||
|
||||
// gDefaultVolume[k] = cos(pi/2 * k / 127)
|
||||
f32 gDefaultPanVolume[128] = {
|
||||
@@ -689,131 +735,7 @@ f32 gDefaultPanVolume[128] = {
|
||||
};
|
||||
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
// 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,
|
||||
101824.61f, 102627.57f, 103341.086f, 103983.55f, 104568.164f, 105104.75f, 105600.8f,
|
||||
106062.14f, 106493.46f, 106898.52f, 107280.414f, 107641.73f, 107984.62f, 108310.93f,
|
||||
108622.23f, 108919.875f, 109205.055f, 109478.8f, 109742.0f, 109995.48f, 110239.94f,
|
||||
110476.02f, 110704.305f, 110925.3f, 111139.45f, 111347.21f, 111548.945f, 111745.0f,
|
||||
111935.7f, 112121.35f, 112302.2f, 112478.51f, 112650.51f, 112818.4f, 112982.38f,
|
||||
113142.66f, 113299.37f, 113452.69f, 113602.766f, 113749.734f, 113893.73f, 114034.87f,
|
||||
114173.26f, 114309.02f, 114442.26f, 114573.055f, 114701.5f, 114827.69f, 114951.695f,
|
||||
115073.6f, 115193.47f, 115311.375f, 115427.39f, 115541.56f, 115653.96f, 115764.63f,
|
||||
115873.64f, 115981.04f, 116086.86f, 116191.164f, 116293.99f, 116395.38f, 116495.38f,
|
||||
116594.02f, 116691.34f, 116787.39f, 116882.19f, 116975.77f, 117068.17f, 117159.414f,
|
||||
117249.54f, 117338.57f, 117426.53f, 117513.45f, 117599.35f, 117684.266f, 117768.2f,
|
||||
117851.195f, 117933.266f, 118014.44f, 118094.72f, 118174.14f, 118252.71f, 118330.46f,
|
||||
118407.4f, 118483.55f, 118558.914f, 118633.53f, 118707.4f, 118780.54f, 118852.97f,
|
||||
118924.695f, 118995.74f, 119066.11f, 119135.82f, 119204.88f, 119273.31f, 119341.125f,
|
||||
119408.32f, 119474.92f, 119540.93f, 119606.36f, 119671.22f, 119735.52f, 119799.28f,
|
||||
119862.5f, 119925.195f, 119987.36f, 120049.02f, 120110.18f, 120170.84f, 120231.016f,
|
||||
120290.71f, 120349.945f, 120408.7f, 120467.016f, 120524.875f, 120582.3f, 120639.28f,
|
||||
120695.84f, 120751.984f
|
||||
};
|
||||
|
||||
// gVolRampingRhs136[k] = 1 / max(1, (256*k)^(1/17))
|
||||
f32 gVolRampingRhs136[128] = {
|
||||
1.0f, 0.72167f, 0.692837f, 0.676508f, 0.665156f, 0.656482f, 0.649479f, 0.643616f, 0.638581f,
|
||||
0.634172f, 0.630254f, 0.62673f, 0.62353f, 0.620601f, 0.617902f, 0.615399f, 0.613067f, 0.610885f,
|
||||
0.608835f, 0.606901f, 0.605073f, 0.603339f, 0.60169f, 0.600119f, 0.598618f, 0.597183f, 0.595806f,
|
||||
0.594485f, 0.593215f, 0.591991f, 0.590812f, 0.589674f, 0.588573f, 0.587509f, 0.586478f, 0.585479f,
|
||||
0.58451f, 0.583568f, 0.582654f, 0.581764f, 0.580898f, 0.580055f, 0.579233f, 0.578432f, 0.57765f,
|
||||
0.576887f, 0.576142f, 0.575414f, 0.574701f, 0.574005f, 0.573323f, 0.572656f, 0.572002f, 0.571361f,
|
||||
0.570733f, 0.570118f, 0.569514f, 0.568921f, 0.568339f, 0.567768f, 0.567207f, 0.566656f, 0.566114f,
|
||||
0.565582f, 0.565058f, 0.564543f, 0.564036f, 0.563537f, 0.563046f, 0.562563f, 0.562087f, 0.561618f,
|
||||
0.561156f, 0.560701f, 0.560253f, 0.559811f, 0.559375f, 0.558945f, 0.558521f, 0.558102f, 0.557689f,
|
||||
0.557282f, 0.55688f, 0.556483f, 0.556091f, 0.555704f, 0.555322f, 0.554944f, 0.554571f, 0.554203f,
|
||||
0.553839f, 0.553479f, 0.553123f, 0.552772f, 0.552424f, 0.55208f, 0.55174f, 0.551404f, 0.551071f,
|
||||
0.550742f, 0.550417f, 0.550095f, 0.549776f, 0.549461f, 0.549148f, 0.548839f, 0.548534f, 0.548231f,
|
||||
0.547931f, 0.547634f, 0.54734f, 0.547048f, 0.54676f, 0.546474f, 0.546191f, 0.54591f, 0.545632f,
|
||||
0.545357f, 0.545084f, 0.544813f, 0.544545f, 0.54428f, 0.544016f, 0.543755f, 0.543496f, 0.543239f,
|
||||
0.542985f, 0.542732f
|
||||
};
|
||||
|
||||
// gVolRampingLhs144[k] = 2^16 * max(1, (256*k)^(1/18))
|
||||
f32 gVolRampingLhs144[128] = {
|
||||
65536.0f, 89180.734f, 92681.9f, 94793.33f, 96320.52f, 97522.02f, 98514.84f,
|
||||
99362.14f, 100101.99f, 100759.16f, 101350.664f, 101888.74f, 102382.46f, 102838.75f,
|
||||
103263.016f, 103659.58f, 104031.914f, 104382.89f, 104714.88f, 105029.89f, 105329.61f,
|
||||
105615.5f, 105888.81f, 106150.63f, 106401.914f, 106643.49f, 106876.12f, 107100.44f,
|
||||
107317.05f, 107526.47f, 107729.17f, 107925.6f, 108116.125f, 108301.12f, 108480.88f,
|
||||
108655.72f, 108825.91f, 108991.68f, 109153.28f, 109310.914f, 109464.77f, 109615.04f,
|
||||
109761.88f, 109905.46f, 110045.92f, 110183.41f, 110318.02f, 110449.91f, 110579.17f,
|
||||
110705.914f, 110830.234f, 110952.234f, 111071.99f, 111189.59f, 111305.12f, 111418.64f,
|
||||
111530.23f, 111639.95f, 111747.875f, 111854.05f, 111958.54f, 112061.4f, 112162.67f,
|
||||
112262.42f, 112360.68f, 112457.51f, 112552.93f, 112647.0f, 112739.76f, 112831.23f,
|
||||
112921.46f, 113010.484f, 113098.33f, 113185.02f, 113270.61f, 113355.11f, 113438.555f,
|
||||
113520.97f, 113602.375f, 113682.805f, 113762.27f, 113840.81f, 113918.44f, 113995.18f,
|
||||
114071.055f, 114146.08f, 114220.266f, 114293.65f, 114366.24f, 114438.06f, 114509.12f,
|
||||
114579.44f, 114649.02f, 114717.91f, 114786.086f, 114853.586f, 114920.42f, 114986.6f,
|
||||
115052.14f, 115117.055f, 115181.34f, 115245.04f, 115308.13f, 115370.65f, 115432.59f,
|
||||
115493.98f, 115554.81f, 115615.11f, 115674.875f, 115734.12f, 115792.85f, 115851.08f,
|
||||
115908.82f, 115966.07f, 116022.85f, 116079.16f, 116135.01f, 116190.4f, 116245.35f,
|
||||
116299.87f, 116353.945f, 116407.6f, 116460.84f, 116513.67f, 116566.09f, 116618.125f,
|
||||
116669.76f, 116721.01f
|
||||
};
|
||||
|
||||
// gVolRampingRhs144[k] = 1 / max(1, (256*k)^(1/18))
|
||||
f32 gVolRampingRhs144[128] = {
|
||||
1.0f, 0.734867f, 0.707107f, 0.691357f, 0.680395f, 0.672012f, 0.66524f, 0.659567f, 0.654692f,
|
||||
0.650422f, 0.646626f, 0.643211f, 0.64011f, 0.637269f, 0.634651f, 0.632223f, 0.629961f, 0.627842f,
|
||||
0.625852f, 0.623975f, 0.622199f, 0.620515f, 0.618913f, 0.617387f, 0.615929f, 0.614533f, 0.613196f,
|
||||
0.611912f, 0.610677f, 0.609487f, 0.60834f, 0.607233f, 0.606163f, 0.605128f, 0.604125f, 0.603153f,
|
||||
0.60221f, 0.601294f, 0.600403f, 0.599538f, 0.598695f, 0.597874f, 0.597074f, 0.596294f, 0.595533f,
|
||||
0.59479f, 0.594064f, 0.593355f, 0.592661f, 0.591983f, 0.591319f, 0.590669f, 0.590032f, 0.589408f,
|
||||
0.588796f, 0.588196f, 0.587608f, 0.58703f, 0.586463f, 0.585906f, 0.58536f, 0.584822f, 0.584294f,
|
||||
0.583775f, 0.583265f, 0.582762f, 0.582268f, 0.581782f, 0.581303f, 0.580832f, 0.580368f, 0.579911f,
|
||||
0.57946f, 0.579017f, 0.578579f, 0.578148f, 0.577722f, 0.577303f, 0.576889f, 0.576481f, 0.576078f,
|
||||
0.575681f, 0.575289f, 0.574902f, 0.574519f, 0.574142f, 0.573769f, 0.5734f, 0.573036f, 0.572677f,
|
||||
0.572321f, 0.57197f, 0.571623f, 0.57128f, 0.57094f, 0.570605f, 0.570273f, 0.569945f, 0.56962f,
|
||||
0.569299f, 0.568981f, 0.568667f, 0.568355f, 0.568047f, 0.567743f, 0.567441f, 0.567142f, 0.566846f,
|
||||
0.566553f, 0.566263f, 0.565976f, 0.565692f, 0.56541f, 0.565131f, 0.564854f, 0.56458f, 0.564309f,
|
||||
0.56404f, 0.563773f, 0.563509f, 0.563247f, 0.562987f, 0.56273f, 0.562475f, 0.562222f, 0.561971f,
|
||||
0.561722f, 0.561476f
|
||||
};
|
||||
|
||||
// gVolRampingLhs128[k] = 2^16 * max(1, (256*k)^(1/16))
|
||||
f32 gVolRampingLhs128[128] = {
|
||||
65536.0f, 92681.9f, 96785.28f, 99269.31f, 101070.33f, 102489.78f, 103664.336f,
|
||||
104667.914f, 105545.09f, 106324.92f, 107027.39f, 107666.84f, 108253.95f, 108796.87f,
|
||||
109301.95f, 109774.29f, 110217.98f, 110636.39f, 111032.33f, 111408.164f, 111765.9f,
|
||||
112107.234f, 112433.66f, 112746.46f, 113046.766f, 113335.555f, 113613.72f, 113882.02f,
|
||||
114141.164f, 114391.77f, 114634.414f, 114869.58f, 115097.74f, 115319.31f, 115534.68f,
|
||||
115744.19f, 115948.16f, 116146.875f, 116340.625f, 116529.66f, 116714.195f, 116894.46f,
|
||||
117070.64f, 117242.945f, 117411.52f, 117576.55f, 117738.17f, 117896.54f, 118051.77f,
|
||||
118204.0f, 118353.35f, 118499.92f, 118643.83f, 118785.16f, 118924.01f, 119060.47f,
|
||||
119194.625f, 119326.555f, 119456.336f, 119584.03f, 119709.71f, 119833.445f, 119955.29f,
|
||||
120075.31f, 120193.555f, 120310.08f, 120424.94f, 120538.17f, 120649.836f, 120759.97f,
|
||||
120868.62f, 120975.82f, 121081.62f, 121186.05f, 121289.14f, 121390.94f, 121491.47f,
|
||||
121590.766f, 121688.87f, 121785.79f, 121881.57f, 121976.24f, 122069.82f, 122162.33f,
|
||||
122253.805f, 122344.266f, 122433.73f, 122522.23f, 122609.77f, 122696.4f, 122782.11f,
|
||||
122866.93f, 122950.89f, 123033.99f, 123116.26f, 123197.72f, 123278.37f, 123358.24f,
|
||||
123437.34f, 123515.69f, 123593.3f, 123670.19f, 123746.36f, 123821.84f, 123896.63f,
|
||||
123970.76f, 124044.23f, 124117.04f, 124189.23f, 124260.78f, 124331.73f, 124402.07f,
|
||||
124471.83f, 124540.99f, 124609.59f, 124677.63f, 124745.12f, 124812.055f, 124878.47f,
|
||||
124944.34f, 125009.71f, 125074.57f, 125138.92f, 125202.79f, 125266.164f, 125329.06f,
|
||||
125391.5f, 125453.47f
|
||||
};
|
||||
|
||||
// gVolRampingRhs128[k] = 1 / max(1, (256*k)^(1/16))
|
||||
f32 gVolRampingRhs128[128] = {
|
||||
1.0f, 0.707107f, 0.677128f, 0.660184f, 0.64842f, 0.639439f, 0.632194f, 0.626133f, 0.620929f,
|
||||
0.616375f, 0.612329f, 0.608693f, 0.605391f, 0.60237f, 0.599587f, 0.597007f, 0.594604f, 0.592355f,
|
||||
0.590243f, 0.588251f, 0.586369f, 0.584583f, 0.582886f, 0.581269f, 0.579725f, 0.578247f, 0.576832f,
|
||||
0.575473f, 0.574166f, 0.572908f, 0.571696f, 0.570525f, 0.569394f, 0.5683f, 0.567241f, 0.566214f,
|
||||
0.565218f, 0.564251f, 0.563311f, 0.562398f, 0.561508f, 0.560642f, 0.559799f, 0.558976f, 0.558173f,
|
||||
0.55739f, 0.556625f, 0.555877f, 0.555146f, 0.554431f, 0.553732f, 0.553047f, 0.552376f, 0.551719f,
|
||||
0.551075f, 0.550443f, 0.549823f, 0.549216f, 0.548619f, 0.548033f, 0.547458f, 0.546892f, 0.546337f,
|
||||
0.545791f, 0.545254f, 0.544726f, 0.544206f, 0.543695f, 0.543192f, 0.542696f, 0.542209f, 0.541728f,
|
||||
0.541255f, 0.540788f, 0.540329f, 0.539876f, 0.539429f, 0.538988f, 0.538554f, 0.538125f, 0.537702f,
|
||||
0.537285f, 0.536873f, 0.536467f, 0.536065f, 0.535669f, 0.535277f, 0.534891f, 0.534509f, 0.534131f,
|
||||
0.533759f, 0.53339f, 0.533026f, 0.532666f, 0.53231f, 0.531958f, 0.53161f, 0.531266f, 0.530925f,
|
||||
0.530588f, 0.530255f, 0.529926f, 0.529599f, 0.529277f, 0.528957f, 0.528641f, 0.528328f, 0.528018f,
|
||||
0.527711f, 0.527407f, 0.527106f, 0.526808f, 0.526513f, 0.52622f, 0.525931f, 0.525644f, 0.525359f,
|
||||
0.525077f, 0.524798f, 0.524522f, 0.524247f, 0.523975f, 0.523706f, 0.523439f, 0.523174f, 0.522911f,
|
||||
0.522651f, 0.522393f
|
||||
};
|
||||
#include "volramping.c.in"
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_SH
|
||||
@@ -1034,6 +956,14 @@ s16 gAiBufferLengths[NUMAIBUFFERS];
|
||||
|
||||
u32 gAudioRandom;
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
u8 gBetterReverbPresetCount = ARRAY_COUNT(gBetterReverbSettings);
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
u8 gReverbDelaysArrCount = ARRAY_COUNT(sReverbDelaysArr);
|
||||
u8 gReverbMultsArrCount = ARRAY_COUNT(sReverbMultsArr);
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
#endif // BETTER_REVERB
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
s32 gAudioErrorFlags;
|
||||
#endif
|
||||
|
||||
+25
-7
@@ -22,6 +22,10 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
// Vanilla US/JP uses 7; Vanilla EU opts for 10 here effectively, though that one gets generated at runtime and doesn't use this value.
|
||||
// Total memory usage is calculated by 24*(2^VOL_RAMPING_EXPONENT) bytes. This is not technically on the heap, but it's memory nonetheless.
|
||||
#define VOL_RAMPING_EXPONENT 9
|
||||
|
||||
#define PERSISTENT_SEQ_MEM 0x8200
|
||||
#define PERSISTENT_BANK_MEM 0xDC00
|
||||
#define TEMPORARY_SEQ_MEM 0xE800
|
||||
@@ -29,6 +33,8 @@
|
||||
#define MAX_NUM_SOUNDBANKS 0x100
|
||||
#define EXT_AUDIO_INIT_POOL_SIZE 0x2000
|
||||
#else
|
||||
#define VOL_RAMPING_EXPONENT 7
|
||||
|
||||
#define PERSISTENT_SEQ_MEM 0x4100
|
||||
#define PERSISTENT_BANK_MEM 0x6E00
|
||||
#define TEMPORARY_SEQ_MEM 0x7400
|
||||
@@ -48,8 +54,16 @@ extern struct AudioSessionSettings gAudioSessionSettings;
|
||||
extern struct ReverbSettingsUS gReverbSettings[18];
|
||||
#endif
|
||||
#ifdef BETTER_REVERB
|
||||
extern u8 gBetterReverbPresetCount;
|
||||
extern struct BetterReverbSettings gBetterReverbSettings[];
|
||||
#endif
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
extern struct BetterReverbSettings gDebugBetterReverbSettings[2];
|
||||
extern u32 sReverbDelaysArr[][NUM_ALLPASS];
|
||||
extern u8 sReverbMultsArr[][NUM_ALLPASS / 3];
|
||||
extern u8 gReverbDelaysArrCount;
|
||||
extern u8 gReverbMultsArrCount;
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
#endif // BETTER_REVERB
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
extern f32 gPitchBendFrequencyScale[256];
|
||||
@@ -81,18 +95,22 @@ extern s16 euUnknownData_80301950[64];
|
||||
extern struct NoteSubEu gZeroNoteSub;
|
||||
extern struct NoteSubEu gDefaultNoteSub;
|
||||
#else
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
extern u16 gHeadsetPanQuantization[10];
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
extern f32 gHeadsetPanVolume[128];
|
||||
extern f32 gStereoPanVolume[128];
|
||||
#endif
|
||||
extern f32 gDefaultPanVolume[128];
|
||||
|
||||
extern f32 gVolRampingLhs136[128];
|
||||
extern f32 gVolRampingRhs136[128];
|
||||
extern f32 gVolRampingLhs144[128];
|
||||
extern f32 gVolRampingRhs144[128];
|
||||
extern f32 gVolRampingLhs128[128];
|
||||
extern f32 gVolRampingRhs128[128];
|
||||
extern f32 gVolRampingLhs136[1 << VOL_RAMPING_EXPONENT];
|
||||
extern f32 gVolRampingRhs136[1 << VOL_RAMPING_EXPONENT];
|
||||
extern f32 gVolRampingLhs144[1 << VOL_RAMPING_EXPONENT];
|
||||
extern f32 gVolRampingRhs144[1 << VOL_RAMPING_EXPONENT];
|
||||
extern f32 gVolRampingLhs128[1 << VOL_RAMPING_EXPONENT];
|
||||
extern f32 gVolRampingRhs128[1 << VOL_RAMPING_EXPONENT];
|
||||
|
||||
// non-constant .data
|
||||
extern s16 gTatumsPerBeat;
|
||||
|
||||
+13
-2
@@ -353,7 +353,9 @@ void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, UNUSED s16
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
f32 adsr_update(struct AdsrState *adsr) {
|
||||
#else
|
||||
s32 adsr_update(struct AdsrState *adsr) {
|
||||
s32 adsr_update(struct Note *note) {
|
||||
struct AdsrState *adsr = ¬e->adsr;
|
||||
u8 isInit = FALSE;
|
||||
#endif
|
||||
u8 action = adsr->action;
|
||||
u8 state = adsr->state;
|
||||
@@ -362,6 +364,10 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
return 0;
|
||||
|
||||
case ADSR_STATE_INITIAL:
|
||||
isInit = TRUE;
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_RESTART:
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
adsr->current = adsr->initial;
|
||||
adsr->target = adsr->initial;
|
||||
@@ -401,7 +407,7 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
break;
|
||||
#endif
|
||||
case ADSR_RESTART:
|
||||
adsr->state = ADSR_STATE_INITIAL;
|
||||
adsr->state = ADSR_STATE_RESTART;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -422,6 +428,11 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->target = adsr->target * adsr->target;
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
#else // !(VERSION_EU || VERSION_SH)
|
||||
if (adsr->delay <= 0) {
|
||||
adsr->delay = 1;
|
||||
note->initFullVelocity = isInit;
|
||||
}
|
||||
|
||||
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
|
||||
#endif // !(VERSION_EU || VERSION_SH)
|
||||
|
||||
+4
-3
@@ -15,7 +15,8 @@ enum ADSRStates {
|
||||
ADSR_STATE_HANG,
|
||||
ADSR_STATE_DECAY,
|
||||
ADSR_STATE_RELEASE,
|
||||
ADSR_STATE_SUSTAIN
|
||||
ADSR_STATE_SUSTAIN,
|
||||
ADSR_STATE_RESTART
|
||||
};
|
||||
|
||||
enum ADSRActions {
|
||||
@@ -25,10 +26,10 @@ enum ADSRActions {
|
||||
};
|
||||
|
||||
enum ADSRDelays {
|
||||
ADSR_DISABLE = 0,
|
||||
ADSR_HANG = -1,
|
||||
ADSR_GOTO = -2,
|
||||
ADSR_RESTART = -3,
|
||||
ADSR_DISABLE = -4,
|
||||
};
|
||||
|
||||
enum VibratoModes {
|
||||
@@ -52,7 +53,7 @@ void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, s16 *volOu
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
f32 adsr_update(struct AdsrState *adsr);
|
||||
#else
|
||||
s32 adsr_update(struct AdsrState *adsr);
|
||||
s32 adsr_update(struct Note *note);
|
||||
#endif
|
||||
|
||||
#endif // AUDIO_EFFECTS_H
|
||||
+19
-12
@@ -232,7 +232,7 @@ struct MusicDynamic sMusicDynamics[8] = {
|
||||
#define STUB_LEVEL(_0, _1, _2, _3, echo1, echo2, echo3, _7, _8) { echo1, echo2, echo3 },
|
||||
#define DEFINE_LEVEL(_0, _1, _2, _3, _4, _5, echo1, echo2, echo3, _9, _10) { echo1, echo2, echo3 },
|
||||
|
||||
u8 sLevelAreaReverbs[LEVEL_COUNT][3] = {
|
||||
s8 sLevelAreaReverbs[LEVEL_COUNT][3] = {
|
||||
{ 0x00, 0x00, 0x00 }, // LEVEL_NONE
|
||||
#include "levels/level_defines.h"
|
||||
};
|
||||
@@ -1138,7 +1138,8 @@ static f32 get_sound_freq_scale(u8 bank, u8 item) {
|
||||
static u32 get_sound_reverb(UNUSED u8 bank, UNUSED u8 soundIndex, u8 channelIndex) {
|
||||
u8 area;
|
||||
u8 level;
|
||||
u8 reverb;
|
||||
s8 areaEcho;
|
||||
s16 reverb;
|
||||
|
||||
// Disable level reverb if NO_ECHO is set
|
||||
if (sSoundBanks[bank][soundIndex].soundBits & SOUND_NO_ECHO) {
|
||||
@@ -1152,18 +1153,27 @@ static u32 get_sound_reverb(UNUSED u8 bank, UNUSED u8 soundIndex, u8 channelInde
|
||||
}
|
||||
}
|
||||
|
||||
// reverb = reverb adjustment + level reverb + a volume-dependent value
|
||||
areaEcho = sLevelAreaReverbs[level][area];
|
||||
|
||||
if (gAreaData[gCurrAreaIndex].useEchoOverride && !(sSoundBanks[bank][soundIndex].soundBits & SOUND_NO_ECHO)) {
|
||||
areaEcho = gAreaData[gCurrAreaIndex].echoOverride;
|
||||
}
|
||||
|
||||
// reverb = reverb adjustment + level reverb (or level script override value) + a volume-dependent value
|
||||
// The volume-dependent value is 0 when volume is at maximum, and raises to
|
||||
// LOW_VOLUME_REVERB when the volume is 0
|
||||
reverb = (u8)(u8) gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[5]
|
||||
+ sLevelAreaReverbs[level][area]
|
||||
+ ((1.0f - gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume)
|
||||
* LOW_VOLUME_REVERB);
|
||||
reverb = (s16) ((u8) gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[5]) + areaEcho;
|
||||
|
||||
if (reverb > 0x7f) {
|
||||
// NOTE: In some cases, it may be better to apply this after ensuring reverb is non-negative so the result doesn't end up sounding way too dry.
|
||||
// This has been left as-is however because in most cases where negative reverb is even used, this is probably desirable anyway.
|
||||
reverb += (s16) ((1.0f - gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume) * LOW_VOLUME_REVERB);
|
||||
|
||||
if (reverb < 0 || areaEcho <= -0x80) {
|
||||
reverb = 0;
|
||||
} else if (reverb > 0x7f) {
|
||||
reverb = 0x7f;
|
||||
}
|
||||
return reverb;
|
||||
return (u8) reverb;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1985,7 +1995,6 @@ void sound_init(void) {
|
||||
sLowerBackgroundMusicVolume = FALSE;
|
||||
sSoundBanksThatLowerBackgroundMusic = 0;
|
||||
sCurrentBackgroundMusicSeqId = 0xff;
|
||||
gSoundMode = SOUND_MODE_STEREO;
|
||||
sBackgroundMusicQueueSize = 0;
|
||||
sBackgroundMusicMaxTargetVolume = TARGET_VOLUME_UNSET;
|
||||
D_80332120 = 0;
|
||||
@@ -2187,9 +2196,7 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer) {
|
||||
|
||||
// Abort if the queue is already full.
|
||||
if (sBackgroundMusicQueueSize >= MAX_BACKGROUND_MUSIC_QUEUE_SIZE) {
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
append_puppyprint_log("Sequence queue full, aborting.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <PR/ultratypes.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "level_table.h"
|
||||
|
||||
// Sequence arguments, passed to seq_player_play_sequence. seqId may be bit-OR'ed with
|
||||
// SEQ_VARIATION; this will load the same sequence, but set a variation
|
||||
@@ -34,6 +35,8 @@ extern f32 gGlobalSoundSource[3];
|
||||
// defined in data.c, used by the game
|
||||
extern u32 gAudioRandom;
|
||||
|
||||
extern s8 sLevelAreaReverbs[LEVEL_COUNT][3];
|
||||
|
||||
struct SPTask *create_next_audio_frame_task(void);
|
||||
void play_sound(s32 soundBits, f32 *pos);
|
||||
void audio_signal_game_loop_tick(void);
|
||||
|
||||
+25
-19
@@ -6,9 +6,8 @@
|
||||
#include "synthesis.h"
|
||||
#include "seqplayer.h"
|
||||
#include "effects.h"
|
||||
#include "game/game_init.h"
|
||||
#include "game/emutest.h"
|
||||
#include "game/puppyprint.h"
|
||||
#include "game/vc_check.h"
|
||||
#include "game/debug.h"
|
||||
#include "string.h"
|
||||
|
||||
@@ -1048,8 +1047,20 @@ void init_reverb_us(s32 presetId) {
|
||||
s32 reverbWindowSize = gReverbSettings[presetId].windowSize;
|
||||
gReverbDownsampleRate = gReverbSettings[presetId].downsampleRate;
|
||||
#ifdef BETTER_REVERB
|
||||
// This will likely crash if given an invalid preset value. Adding a safety check here isn't worth the usability interference.
|
||||
struct BetterReverbSettings *betterReverbPreset = &gBetterReverbSettings[gBetterReverbPreset];
|
||||
struct BetterReverbSettings *betterReverbPreset = &gBetterReverbSettings[gBetterReverbPresetValue];
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
if ((s8) gBetterReverbPresetValue < 0 && (s8) gBetterReverbPresetValue >= -ARRAY_COUNT(gDebugBetterReverbSettings)) {
|
||||
betterReverbPreset = &gDebugBetterReverbSettings[ARRAY_COUNT(gDebugBetterReverbSettings) + (s8) gBetterReverbPresetValue];
|
||||
} else if (gBetterReverbPresetValue >= gBetterReverbPresetCount) {
|
||||
#else
|
||||
if (gBetterReverbPresetValue >= gBetterReverbPresetCount) {
|
||||
#endif
|
||||
aggress(gBetterReverbPresetCount > 0, "No BETTER_REVERB presets exist!");
|
||||
|
||||
assert(gBetterReverbPresetValue < gBetterReverbPresetCount, "BETTER_REVERB preset value exceeds total number of available presets!");
|
||||
betterReverbPreset = &gBetterReverbSettings[0];
|
||||
}
|
||||
|
||||
betterReverbLightweight = betterReverbPreset->useLightweightSettings;
|
||||
betterReverbDownsampleRate = betterReverbPreset->downsampleRate;
|
||||
@@ -1058,8 +1069,8 @@ void init_reverb_us(s32 presetId) {
|
||||
betterReverbWindowsSize = betterReverbPreset->windowSize;
|
||||
betterReverbRevIndex = betterReverbPreset->reverbIndex;
|
||||
betterReverbGainIndex = betterReverbPreset->gainIndex;
|
||||
gReverbMultsL = betterReverbPreset->reverbMultsL;
|
||||
gReverbMultsR = betterReverbPreset->reverbMultsR;
|
||||
gReverbMults[SYNTH_CHANNEL_LEFT] = betterReverbPreset->reverbMultsL;
|
||||
gReverbMults[SYNTH_CHANNEL_RIGHT] = betterReverbPreset->reverbMultsR;
|
||||
|
||||
if (betterReverbDownsampleRate <= 0) {
|
||||
toggleBetterReverb = FALSE;
|
||||
@@ -1071,9 +1082,10 @@ void init_reverb_us(s32 presetId) {
|
||||
|
||||
if (betterReverbWindowsSize >= 0) {
|
||||
reverbWindowSize = betterReverbWindowsSize;
|
||||
if (reverbWindowSize < (DEFAULT_LEN_2CH * 2) && betterReverbWindowsSize != 0) // Minimum window size to not overflow
|
||||
reverbWindowSize = (DEFAULT_LEN_2CH * 2);
|
||||
reverbWindowSize /= gReverbDownsampleRate;
|
||||
if (reverbWindowSize < DEFAULT_LEN_2CH && betterReverbWindowsSize != 0) // Minimum window size to not overflow
|
||||
reverbWindowSize = DEFAULT_LEN_2CH;
|
||||
reverbWindowSize = ALIGN16(reverbWindowSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,7 +1150,7 @@ void init_reverb_us(s32 presetId) {
|
||||
if (!gSynthesisReverb.useReverb)
|
||||
toggleBetterReverb = FALSE;
|
||||
|
||||
if (betterReverbPreset->gain > 0)
|
||||
if (betterReverbPreset->gain >= 0)
|
||||
gSynthesisReverb.reverbGain = (u16) betterReverbPreset->gain;
|
||||
|
||||
if (!sAudioIsInitialized)
|
||||
@@ -1158,7 +1170,7 @@ void audio_reset_session(s32 reverbPresetId) {
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
|
||||
if (!gIsVC) {
|
||||
if (!(gEmulator & EMU_WIIVC)) {
|
||||
gAudioFrameCount = 0;
|
||||
while (gAudioFrameCount < 1) {
|
||||
// spin
|
||||
@@ -1312,7 +1324,7 @@ void audio_reset_session(void) {
|
||||
gAudioBufferParameters.minAiBufferLength *= gAudioBufferParameters.presetUnk4;
|
||||
gAudioBufferParameters.updatesPerFrame *= gAudioBufferParameters.presetUnk4;
|
||||
|
||||
if (gIsConsole)
|
||||
if (gEmulator & EMU_CONSOLE)
|
||||
gMaxSimultaneousNotes = MAX_SIMULTANEOUS_NOTES_CONSOLE;
|
||||
else
|
||||
gMaxSimultaneousNotes = MAX_SIMULTANEOUS_NOTES_EMULATOR;
|
||||
@@ -1339,7 +1351,7 @@ void audio_reset_session(void) {
|
||||
gMinAiBufferLength = gSamplesPerFrameTarget - 0x10;
|
||||
gAudioUpdatesPerFrame = updatesPerFrame = gSamplesPerFrameTarget / 160 + 1;
|
||||
|
||||
if (gIsConsole)
|
||||
if (gEmulator & EMU_CONSOLE)
|
||||
gMaxSimultaneousNotes = MAX_SIMULTANEOUS_NOTES_CONSOLE;
|
||||
else
|
||||
gMaxSimultaneousNotes = MAX_SIMULTANEOUS_NOTES_EMULATOR;
|
||||
@@ -1437,13 +1449,7 @@ void audio_reset_session(void) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
#endif
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#ifdef PUPPYPRINT_DEBUG_CYCLES
|
||||
append_puppyprint_log("Audio Initialised in %dc.", (s32)(osGetTime() - first));
|
||||
#else
|
||||
append_puppyprint_log("Audio Initialised in %dus.", (s32)OS_CYCLES_TO_USEC(osGetTime() - first));
|
||||
#endif
|
||||
#endif
|
||||
append_puppyprint_log("Audio Initialised in %d" PP_CYCLE_STRING ".", (s32)PP_CYCLE_CONV(osGetTime() - first));
|
||||
|
||||
sAudioIsInitialized = TRUE;
|
||||
}
|
||||
|
||||
@@ -140,9 +140,11 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id);
|
||||
#endif
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
void init_reverb_eu(void);
|
||||
s32 audio_shut_down_and_reset_step(void);
|
||||
void audio_reset_session(void);
|
||||
#else
|
||||
void init_reverb_us(s32 presetId);
|
||||
void audio_reset_session(s32 reverbPresetId);
|
||||
#endif
|
||||
void discard_bank(s32 bankId);
|
||||
|
||||
+53
-46
@@ -420,7 +420,11 @@ struct SequenceChannel {
|
||||
/*0x00, 0x00*/ u8 stopScript : 1;
|
||||
/*0x00, 0x00*/ u8 stopSomething2 : 1; // sets SequenceChannelLayer.stopSomething
|
||||
/*0x00, 0x00*/ u8 hasInstrument : 1;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
/*0x00, 0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
#else
|
||||
/*0x00, 0x00*/ u8 paddingBit : 1;
|
||||
#endif
|
||||
/*0x00, ????*/ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
/*0x00, ????*/ u8 unused : 1; // never read, set to 0
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
@@ -662,54 +666,57 @@ struct vNote {
|
||||
}; // size = 0xC0
|
||||
struct Note {
|
||||
/* U/J, EU */
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 needsInit : 1;
|
||||
/*0x00*/ u8 restart : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 envMixerNeedsInit : 1;
|
||||
/*0x00*/ u8 stereoStrongRight : 1;
|
||||
/*0x00*/ u8 stereoStrongLeft : 1;
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x01*/ u8 usesHeadsetPanEffects;
|
||||
/*0x02*/ u8 unk2;
|
||||
/*0x03*/ u8 sampleDmaIndex;
|
||||
/*0x04, 0x30*/ u8 priority;
|
||||
/*0x05*/ u8 sampleCount; // 0, 8, 16, 32 or 64
|
||||
/*0x06*/ u8 instOrWave;
|
||||
/*0x07*/ u8 bankId; // in NoteSubEu on EU
|
||||
/*0x00*/ u8 enabled : 1;
|
||||
/*0x00*/ u8 needsInit : 1;
|
||||
/*0x00*/ u8 restart : 1;
|
||||
/*0x00*/ u8 finished : 1;
|
||||
/*0x00*/ u8 envMixerNeedsInit : 1;
|
||||
/*0x00*/ u8 initFullVelocity : 1;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
/*0x00*/ u8 stereoHeadsetEffects : 1;
|
||||
/*0x00*/ u8 usesHeadsetPanEffects : 1;
|
||||
/*0x01*/ u8 stereoStrongRight : 1;
|
||||
/*0x01*/ u8 stereoStrongLeft : 1;
|
||||
#else
|
||||
/* */ u8 pad0[0x01];
|
||||
#endif
|
||||
/*0x02*/ u8 sampleDmaIndex;
|
||||
/*0x03*/ u8 priority;
|
||||
/*0x04*/ u8 sampleCount; // 0, 8, 16, 32 or 64
|
||||
/*0x05*/ u8 instOrWave;
|
||||
/*0x06*/ u8 bankId; // in NoteSubEu on EU
|
||||
/*0x07*/ u8 reverbVol; // Q1.7
|
||||
/*0x08*/ s16 adsrVolScale;
|
||||
/* */ u8 pad1[2];
|
||||
/*0x0C, 0xB3*/ u16 headsetPanRight;
|
||||
/*0x0E, 0xB4*/ u16 headsetPanLeft;
|
||||
/*0x10*/ u16 prevHeadsetPanRight;
|
||||
/*0x12*/ u16 prevHeadsetPanLeft;
|
||||
/*0x14*/ s32 samplePosInt;
|
||||
/*0x18, 0x38*/ f32 portamentoFreqScale;
|
||||
/*0x1C, 0x3C*/ f32 vibratoFreqScale;
|
||||
/*0x20*/ u16 samplePosFrac;
|
||||
/* */ u8 pad2[2];
|
||||
/*0x24*/ struct AudioBankSound *sound;
|
||||
/*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; // Q1.15, but will always be non-negative
|
||||
/*0x3E*/ u16 targetVolRight; // Q1.15, but will always be non-negative
|
||||
/*0x40*/ u8 reverbVol; // Q1.7
|
||||
/*0x41*/ u8 unused1; // never read, set to 0x3f
|
||||
/* */ u8 pad3[2];
|
||||
/*0x44*/ struct NoteAttributes attributes;
|
||||
/*0x54, 0x58*/ struct AdsrState adsr;
|
||||
/*0x74, 0x7C*/ struct Portamento portamento;
|
||||
/*0x84, 0x8C*/ struct VibratoState vibratoState;
|
||||
/*0x0A*/ u16 samplePosFrac;
|
||||
/*0x0C*/ s32 samplePosInt;
|
||||
/*0x10*/ f32 portamentoFreqScale;
|
||||
/*0x14*/ f32 vibratoFreqScale;
|
||||
/*0x18*/ struct AudioBankSound *sound;
|
||||
/*0x1C*/ struct SequenceChannelLayer *prevParentLayer;
|
||||
/*0x20*/ struct SequenceChannelLayer *parentLayer;
|
||||
/*0x24*/ struct SequenceChannelLayer *wantedParentLayer;
|
||||
/*0x28*/ struct NoteSynthesisBuffers *synthesisBuffers;
|
||||
/*0x2C*/ f32 frequency;
|
||||
/*0x30*/ u16 targetVolLeft; // Q1.15, but will always be non-negative
|
||||
/*0x32*/ u16 targetVolRight; // Q1.15, but will always be non-negative
|
||||
/*0x34*/ struct NoteAttributes attributes;
|
||||
/*0x44*/ struct AdsrState adsr;
|
||||
/*0x64*/ struct Portamento portamento;
|
||||
/*0x74*/ struct VibratoState vibratoState;
|
||||
/*0x8C*/ struct AudioListItem listItem;
|
||||
/*0x9C*/ s16 curVolLeft; // Q1.15, but will always be non-negative
|
||||
/*0x9E*/ s16 curVolRight; // Q1.15, but will always be non-negative
|
||||
/*0xA0*/ s16 reverbVolShifted; // Q1.15
|
||||
/*0xA2*/ s16 unused2; // never read, set to 0
|
||||
/*0xA4, 0x00*/ struct AudioListItem listItem;
|
||||
/* */ u8 pad4[0xc];
|
||||
}; // size = 0xC0
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
/*0xA2*/ u16 headsetPanRight;
|
||||
/*0xA4*/ u16 headsetPanLeft;
|
||||
/*0xA6*/ u16 prevHeadsetPanRight;
|
||||
/*0xA8*/ u16 prevHeadsetPanLeft;
|
||||
/* */ u8 align16Padding[0x06];
|
||||
#else
|
||||
/* */ u8 align16Padding[0x0E];
|
||||
#endif
|
||||
}; // size = 0xB0
|
||||
#endif
|
||||
|
||||
struct NoteSynthesisBuffers {
|
||||
@@ -742,8 +749,8 @@ struct BetterReverbSettings {
|
||||
u8 reverbIndex;
|
||||
u32 *delaysL;
|
||||
u32 *delaysR;
|
||||
s32 *reverbMultsL;
|
||||
s32 *reverbMultsR;
|
||||
u8 *reverbMultsL;
|
||||
u8 *reverbMultsR;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
+1
-2
@@ -86,7 +86,7 @@ s16 gTempoInternalToExternal;
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
#endif
|
||||
|
||||
s8 gSoundMode;
|
||||
s8 gSoundMode = SOUND_MODE_STEREO;
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
s8 gAudioUpdatesPerFrame;
|
||||
@@ -855,7 +855,6 @@ void audio_init() {
|
||||
gAudioFrameCount = 0;
|
||||
gAudioTaskIndex = 0;
|
||||
gCurrAiBufferIndex = 0;
|
||||
gSoundMode = 0;
|
||||
gAudioTask = NULL;
|
||||
gAudioTasks[0].task.t.data_size = 0;
|
||||
gAudioTasks[1].task.t.data_size = 0;
|
||||
|
||||
@@ -578,7 +578,7 @@ void process_notes(void) {
|
||||
}
|
||||
}
|
||||
|
||||
adsr_update(¬e->adsr);
|
||||
adsr_update(note);
|
||||
note_vibrato_update(note);
|
||||
attributes = ¬e->attributes;
|
||||
if (note->priority == NOTE_PRIORITY_STOPPING) {
|
||||
@@ -1156,7 +1156,9 @@ s32 note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLayer
|
||||
}
|
||||
|
||||
note->bankId = seqLayer->seqChannel->bankId;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
note->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects;
|
||||
#endif
|
||||
note->sound = seqLayer->sound;
|
||||
seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded"
|
||||
seqLayer->note = note;
|
||||
@@ -1410,9 +1412,12 @@ void note_init_all(void) {
|
||||
note->noteSubEu = gZeroNoteSub;
|
||||
#else
|
||||
note->enabled = FALSE;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
note->stereoStrongRight = FALSE;
|
||||
note->stereoStrongLeft = FALSE;
|
||||
note->stereoHeadsetEffects = FALSE;
|
||||
note->usesHeadsetPanEffects = FALSE;
|
||||
#endif
|
||||
#endif
|
||||
note->priority = NOTE_PRIORITY_DISABLED;
|
||||
#ifdef VERSION_SH
|
||||
@@ -1426,13 +1431,12 @@ void note_init_all(void) {
|
||||
note->vibratoState.active = FALSE;
|
||||
#else
|
||||
note->reverbVol = 0;
|
||||
note->usesHeadsetPanEffects = FALSE;
|
||||
note->initFullVelocity = FALSE;
|
||||
note->sampleCount = 0;
|
||||
note->instOrWave = 0;
|
||||
note->targetVolLeft = 0;
|
||||
note->targetVolRight = 0;
|
||||
note->frequency = 0.0f;
|
||||
note->unused1 = 0x3f;
|
||||
note->vibratoState.activeFlags = VIBMODE_NONE;
|
||||
#endif
|
||||
note->attributes.velocity = 0.0f;
|
||||
|
||||
@@ -27,7 +27,9 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->stopScript = FALSE;
|
||||
seqChannel->stopSomething2 = FALSE;
|
||||
seqChannel->hasInstrument = FALSE;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
seqChannel->stereoHeadsetEffects = FALSE;
|
||||
#endif
|
||||
seqChannel->transposition = 0;
|
||||
seqChannel->largeNotes = FALSE;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
@@ -1867,7 +1869,12 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
#endif
|
||||
|
||||
case 0xd0: // chan_stereoheadseteffects
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
seqChannel->stereoHeadsetEffects = m64_read_u8(state);
|
||||
#else
|
||||
// NOTE: Vanilla music does not use 0xd0, so this is safe to repurpose entirely when ENABLE_STEREO_HEADSET_EFFECTS is disabled.
|
||||
m64_read_u8(state);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 0xd1: // chan_setnoteallocationpolicy
|
||||
|
||||
+224
-248
@@ -38,30 +38,27 @@
|
||||
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \
|
||||
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)));
|
||||
|
||||
#define VOLRAMPING_MASK (~(0x8000 | ((1 << (15 - VOL_RAMPING_EXPONENT)) - 1)))
|
||||
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
// Do not touch these values manually, unless you want potential for problems.
|
||||
u8 gBetterReverbPreset = 0;
|
||||
u8 gBetterReverbPresetValue = 0;
|
||||
u8 toggleBetterReverb = FALSE;
|
||||
u8 betterReverbLightweight = FALSE;
|
||||
u8 monoReverb;
|
||||
s8 betterReverbDownsampleRate;
|
||||
static u8 reverbMultsL[NUM_ALLPASS / 3] = {0};
|
||||
static u8 reverbMultsR[NUM_ALLPASS / 3] = {0};
|
||||
static s32 allpassIdxL[NUM_ALLPASS] = {0};
|
||||
static s32 allpassIdxR[NUM_ALLPASS] = {0};
|
||||
static s32 delaysL[NUM_ALLPASS] = {0};
|
||||
static s32 delaysR[NUM_ALLPASS] = {0};
|
||||
static s32 **delayBufsL;
|
||||
static s32 **delayBufsR;
|
||||
static s32 lastDelayLightL;
|
||||
static s32 lastDelayLightR;
|
||||
static s32 reverbMults[SYNTH_CHANNEL_STEREO_COUNT][NUM_ALLPASS / 3] = {0};
|
||||
static s32 allpassIdx[SYNTH_CHANNEL_STEREO_COUNT][NUM_ALLPASS] = {0};
|
||||
static s32 betterReverbDelays[SYNTH_CHANNEL_STEREO_COUNT][NUM_ALLPASS] = {0};
|
||||
static s32 lastDelayLight[SYNTH_CHANNEL_STEREO_COUNT];
|
||||
static s16 **delayBufs[SYNTH_CHANNEL_STEREO_COUNT];
|
||||
u8 *gReverbMults[SYNTH_CHANNEL_STEREO_COUNT];
|
||||
s32 reverbLastFilterIndex;
|
||||
s32 reverbFilterCount;
|
||||
s32 betterReverbWindowsSize;
|
||||
s32 betterReverbRevIndex; // This one is okay to adjust whenever
|
||||
s32 betterReverbGainIndex; // This one is okay to adjust whenever
|
||||
s32 *gReverbMultsL;
|
||||
s32 *gReverbMultsR;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -81,11 +78,15 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struc
|
||||
#else
|
||||
u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd);
|
||||
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad);
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings,
|
||||
u32 flags);
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings);
|
||||
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);
|
||||
#else
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf);
|
||||
u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, struct VolumeChange *vol);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
@@ -97,149 +98,99 @@ u8 sAudioSynthesisPad[0x20];
|
||||
#endif
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
static void reverb_samples(s16 *outSampleL, s16 *outSampleR, s32 inSampleL, s32 inSampleR) {
|
||||
s32 *curDelaySampleL;
|
||||
s32 *curDelaySampleR;
|
||||
s32 historySampleL;
|
||||
s32 historySampleR;
|
||||
s32 outTmpL = 0;
|
||||
s32 outTmpR = 0;
|
||||
s32 tmpCarryoverL = ((delayBufsL[reverbLastFilterIndex][allpassIdxL[reverbLastFilterIndex]] * betterReverbRevIndex) >> 8) + inSampleL;
|
||||
s32 tmpCarryoverR = ((delayBufsR[reverbLastFilterIndex][allpassIdxR[reverbLastFilterIndex]] * betterReverbRevIndex) >> 8) + inSampleR;
|
||||
s32 i = 0;
|
||||
s32 j = 0;
|
||||
s32 k = 0;
|
||||
static void reverb_samples(s16 *start, s16 *end, s16 *downsampleBuffer, s32 channel) {
|
||||
s16 *curDelaySample;
|
||||
s32 historySample;
|
||||
s32 tmpCarryover;
|
||||
s32 outSampleTotal;
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 k;
|
||||
|
||||
for (; i <= reverbLastFilterIndex; ++i, ++j) {
|
||||
curDelaySampleL = &delayBufsL[i][allpassIdxL[i]];
|
||||
curDelaySampleR = &delayBufsR[i][allpassIdxR[i]];
|
||||
historySampleL = *curDelaySampleL;
|
||||
historySampleR = *curDelaySampleR;
|
||||
s32 downsampleIncrement = gReverbDownsampleRate;
|
||||
s32 *delaysLocal = betterReverbDelays[channel];
|
||||
s32 *reverbMultsLocal = reverbMults[channel];
|
||||
s32 *allpassIdxLocal = allpassIdx[channel];
|
||||
s16 **delayBufsLocal = delayBufs[channel];
|
||||
|
||||
if (j == 2) {
|
||||
j = -1;
|
||||
outTmpL += (historySampleL * reverbMultsL[k ]) >> 8;
|
||||
outTmpR += (historySampleR * reverbMultsR[k++]) >> 8;
|
||||
*curDelaySampleL = tmpCarryoverL;
|
||||
*curDelaySampleR = tmpCarryoverR;
|
||||
if (i != reverbLastFilterIndex) {
|
||||
tmpCarryoverL = ((historySampleL * betterReverbRevIndex) >> 8)/* + inSampleL*/;
|
||||
tmpCarryoverR = ((historySampleR * betterReverbRevIndex) >> 8)/* + inSampleR*/;
|
||||
s32 lastFilterIndex = reverbLastFilterIndex;
|
||||
s32 revIndex = betterReverbRevIndex;
|
||||
s32 gainIndex = betterReverbGainIndex;
|
||||
|
||||
// Set j outside of the loop only. Because we're forcing filter count to always be a multiple of 3, we can count on j always being 0 when exiting the second for loop.
|
||||
j = 0;
|
||||
|
||||
for (; start < end; start++, downsampleBuffer += downsampleIncrement) {
|
||||
tmpCarryover = ((delayBufsLocal[lastFilterIndex][allpassIdxLocal[lastFilterIndex]] * revIndex) >> 8) + *downsampleBuffer;
|
||||
outSampleTotal = 0;
|
||||
i = 0;
|
||||
k = 0;
|
||||
|
||||
for (; i <= lastFilterIndex; ++i, ++j) {
|
||||
curDelaySample = &delayBufsLocal[i][allpassIdxLocal[i]];
|
||||
historySample = *curDelaySample;
|
||||
|
||||
if (j == 2) {
|
||||
j = -1;
|
||||
outSampleTotal += ((historySample * reverbMultsLocal[k++]) >> 8);
|
||||
*curDelaySample = CLAMP_S16(tmpCarryover);
|
||||
if (i != lastFilterIndex)
|
||||
tmpCarryover = ((historySample * revIndex) >> 8)/* + *downsampleBuffer*/;
|
||||
} else {
|
||||
tmpCarryover += (historySample * (-gainIndex)) >> 8;
|
||||
*curDelaySample = CLAMP_S16(tmpCarryover);
|
||||
tmpCarryover = ((tmpCarryover * gainIndex) >> 8) + historySample;
|
||||
}
|
||||
} else {
|
||||
*curDelaySampleL = ((historySampleL * (-betterReverbGainIndex)) >> 8) + tmpCarryoverL;
|
||||
*curDelaySampleR = ((historySampleR * (-betterReverbGainIndex)) >> 8) + tmpCarryoverR;
|
||||
tmpCarryoverL = ((*curDelaySampleL * betterReverbGainIndex) >> 8) + historySampleL;
|
||||
tmpCarryoverR = ((*curDelaySampleR * betterReverbGainIndex) >> 8) + historySampleR;
|
||||
|
||||
if (++allpassIdxLocal[i] == delaysLocal[i]) allpassIdxLocal[i] = 0;
|
||||
}
|
||||
|
||||
if (++allpassIdxL[i] == delaysL[i]) allpassIdxL[i] = 0;
|
||||
if (++allpassIdxR[i] == delaysR[i]) allpassIdxR[i] = 0;
|
||||
*start = CLAMP_S16(outSampleTotal);
|
||||
}
|
||||
|
||||
*outSampleL = CLAMP_S16(outTmpL);
|
||||
*outSampleR = CLAMP_S16(outTmpR);
|
||||
}
|
||||
|
||||
static void reverb_mono_sample(s16 *outSample, s32 inSample) {
|
||||
s32 *curDelaySample;
|
||||
s32 historySample;
|
||||
s32 outTmp = 0;
|
||||
s32 tmpCarryover = ((delayBufsL[reverbLastFilterIndex][allpassIdxL[reverbLastFilterIndex]] * betterReverbRevIndex) >> 8) + inSample;
|
||||
s32 i = 0;
|
||||
s32 j = 0;
|
||||
s32 k = 0;
|
||||
|
||||
for (; i <= reverbLastFilterIndex; ++i, ++j) {
|
||||
curDelaySample = &delayBufsL[i][allpassIdxL[i]];
|
||||
historySample = *curDelaySample;
|
||||
|
||||
if (j == 2) {
|
||||
j = -1;
|
||||
outTmp += ((historySample * reverbMultsL[k++]) >> 8);
|
||||
*curDelaySample = tmpCarryover;
|
||||
if (i != reverbLastFilterIndex)
|
||||
tmpCarryover = ((historySample * betterReverbRevIndex) >> 8)/* + inSample*/;
|
||||
} else {
|
||||
*curDelaySample = ((historySample * (-betterReverbGainIndex)) >> 8) + tmpCarryover;
|
||||
tmpCarryover = ((*curDelaySample * betterReverbGainIndex) >> 8) + historySample;
|
||||
}
|
||||
|
||||
if (++allpassIdxL[i] == delaysL[i]) allpassIdxL[i] = 0;
|
||||
}
|
||||
|
||||
*outSample = CLAMP_S16(outTmp);
|
||||
}
|
||||
|
||||
// Light reverb processing functions!
|
||||
#define FILTERS_MINUS_1 (BETTER_REVERB_FILTER_COUNT_LIGHT - 1)
|
||||
static void reverb_samples_light(s16 *outSampleL, s16 *outSampleR, s32 inSampleL, s32 inSampleR) {
|
||||
s32 *curDelaySampleL;
|
||||
s32 *curDelaySampleR;
|
||||
s32 historySampleL;
|
||||
s32 historySampleR;
|
||||
s32 tmpCarryoverL = (((delayBufsL[FILTERS_MINUS_1][allpassIdxL[FILTERS_MINUS_1]] * BETTER_REVERB_REVERB_INDEX_LIGHT) >> 8) + inSampleL);
|
||||
s32 tmpCarryoverR = (((delayBufsR[FILTERS_MINUS_1][allpassIdxR[FILTERS_MINUS_1]] * BETTER_REVERB_REVERB_INDEX_LIGHT) >> 8) + inSampleR);
|
||||
s32 i = 0;
|
||||
|
||||
for (; i < FILTERS_MINUS_1; ++i) {
|
||||
curDelaySampleL = &delayBufsL[i][allpassIdxL[i]];
|
||||
curDelaySampleR = &delayBufsR[i][allpassIdxR[i]];
|
||||
historySampleL = *curDelaySampleL;
|
||||
historySampleR = *curDelaySampleR;
|
||||
|
||||
*curDelaySampleL = (((historySampleL * (-BETTER_REVERB_GAIN_INDEX_LIGHT)) >> 8) + tmpCarryoverL);
|
||||
*curDelaySampleR = (((historySampleR * (-BETTER_REVERB_GAIN_INDEX_LIGHT)) >> 8) + tmpCarryoverR);
|
||||
tmpCarryoverL = (((*curDelaySampleL * BETTER_REVERB_GAIN_INDEX_LIGHT) >> 8) + historySampleL);
|
||||
tmpCarryoverR = (((*curDelaySampleR * BETTER_REVERB_GAIN_INDEX_LIGHT) >> 8) + historySampleR);
|
||||
|
||||
if (++allpassIdxL[i] == delaysL[i]) allpassIdxL[i] = 0;
|
||||
if (++allpassIdxR[i] == delaysR[i]) allpassIdxR[i] = 0;
|
||||
}
|
||||
|
||||
curDelaySampleL = &delayBufsL[FILTERS_MINUS_1][allpassIdxL[FILTERS_MINUS_1]];
|
||||
curDelaySampleR = &delayBufsR[FILTERS_MINUS_1][allpassIdxR[FILTERS_MINUS_1]];
|
||||
historySampleL = ((*curDelaySampleL * BETTER_REVERB_MULTIPLE_LIGHT) >> 8); // outTmpL variable not needed, as there is no sample addition happening here. Not really a history sample though.
|
||||
historySampleR = ((*curDelaySampleR * BETTER_REVERB_MULTIPLE_LIGHT) >> 8); // outTmpR variable not needed, as there is no sample addition happening here. Not really a history sample though.
|
||||
*curDelaySampleL = tmpCarryoverL;
|
||||
*curDelaySampleR = tmpCarryoverR;
|
||||
|
||||
if (++allpassIdxL[FILTERS_MINUS_1] == lastDelayLightL) allpassIdxL[FILTERS_MINUS_1] = 0;
|
||||
if (++allpassIdxR[FILTERS_MINUS_1] == lastDelayLightR) allpassIdxR[FILTERS_MINUS_1] = 0;
|
||||
|
||||
*outSampleL = CLAMP_S16(historySampleL);
|
||||
*outSampleR = CLAMP_S16(historySampleR);
|
||||
}
|
||||
|
||||
static void reverb_mono_sample_light(s16 *outSample, s32 inSample) {
|
||||
s32 *curDelaySample;
|
||||
static void reverb_samples_light(s16 *start, s16 *end, s16 *downsampleBuffer, s32 channel) {
|
||||
s16 *curDelaySample;
|
||||
s32 historySample;
|
||||
s32 tmpCarryover = (((delayBufsL[FILTERS_MINUS_1][allpassIdxL[FILTERS_MINUS_1]] * BETTER_REVERB_REVERB_INDEX_LIGHT) >> 8) + inSample);
|
||||
s32 i = 0;
|
||||
s32 tmpCarryover;
|
||||
s32 i;
|
||||
|
||||
for (; i < FILTERS_MINUS_1; ++i) {
|
||||
curDelaySample = &delayBufsL[i][allpassIdxL[i]];
|
||||
historySample = *curDelaySample;
|
||||
s32 downsampleIncrement = gReverbDownsampleRate;
|
||||
s32 *delaysLocal = betterReverbDelays[channel];
|
||||
s32 *allpassIdxLocal = allpassIdx[channel];
|
||||
s32 lastDelayLightLocal = lastDelayLight[channel];
|
||||
s16 **delayBufsLocal = delayBufs[channel];
|
||||
|
||||
*curDelaySample = (((historySample * (-BETTER_REVERB_GAIN_INDEX_LIGHT)) >> 8) + tmpCarryover);
|
||||
tmpCarryover = (((*curDelaySample * BETTER_REVERB_GAIN_INDEX_LIGHT) >> 8) + historySample);
|
||||
for (; start < end; start++, downsampleBuffer += downsampleIncrement) {
|
||||
tmpCarryover = (((delayBufsLocal[FILTERS_MINUS_1][allpassIdxLocal[FILTERS_MINUS_1]] * BETTER_REVERB_REVERB_INDEX_LIGHT) >> 8) + *downsampleBuffer);
|
||||
i = 0;
|
||||
|
||||
if (++allpassIdxL[i] == delaysL[i]) allpassIdxL[i] = 0;
|
||||
for (; i < FILTERS_MINUS_1; ++i) {
|
||||
curDelaySample = &delayBufsLocal[i][allpassIdxLocal[i]];
|
||||
historySample = *curDelaySample;
|
||||
|
||||
tmpCarryover += ((historySample * (-BETTER_REVERB_GAIN_INDEX_LIGHT)) >> 8);
|
||||
*curDelaySample = CLAMP_S16(tmpCarryover);
|
||||
tmpCarryover = ((tmpCarryover * BETTER_REVERB_GAIN_INDEX_LIGHT) >> 8) + historySample;
|
||||
|
||||
if (++allpassIdxLocal[i] == delaysLocal[i]) allpassIdxLocal[i] = 0;
|
||||
}
|
||||
|
||||
curDelaySample = &delayBufsLocal[FILTERS_MINUS_1][allpassIdxLocal[FILTERS_MINUS_1]];
|
||||
historySample = ((*curDelaySample * BETTER_REVERB_MULTIPLE_LIGHT) >> 8); // outSampleTotal variable not needed, as there is no sample addition happening here. Not really a history sample though.
|
||||
*curDelaySample = CLAMP_S16(tmpCarryover);
|
||||
|
||||
if (++allpassIdxLocal[FILTERS_MINUS_1] == lastDelayLightLocal) allpassIdxLocal[FILTERS_MINUS_1] = 0;
|
||||
|
||||
*start = CLAMP_S16(historySample);
|
||||
}
|
||||
|
||||
curDelaySample = &delayBufsL[FILTERS_MINUS_1][allpassIdxL[FILTERS_MINUS_1]];
|
||||
historySample = ((*curDelaySample * BETTER_REVERB_MULTIPLE_LIGHT) >> 8); // outTmp variable not needed, as there is no sample addition happening here. Not really a history sample though.
|
||||
*curDelaySample = tmpCarryover;
|
||||
|
||||
if (++allpassIdxL[FILTERS_MINUS_1] == lastDelayLightL) allpassIdxL[FILTERS_MINUS_1] = 0;
|
||||
|
||||
*outSample = CLAMP_S16(historySample);
|
||||
}
|
||||
#undef FILTERS_MINUS_1
|
||||
|
||||
void initialize_better_reverb_buffers(void) {
|
||||
delayBufsL = (s32**) soundAlloc(&gBetterReverbPool, BETTER_REVERB_PTR_SIZE);
|
||||
delayBufsR = &delayBufsL[NUM_ALLPASS];
|
||||
delayBufs[SYNTH_CHANNEL_LEFT] = (s16**) soundAlloc(&gBetterReverbPool, BETTER_REVERB_PTR_SIZE);
|
||||
delayBufs[SYNTH_CHANNEL_RIGHT] = &delayBufs[SYNTH_CHANNEL_LEFT][NUM_ALLPASS];
|
||||
}
|
||||
|
||||
void set_better_reverb_buffers(u32 *inputDelaysL, u32 *inputDelaysR) {
|
||||
@@ -250,7 +201,7 @@ void set_better_reverb_buffers(u32 *inputDelaysL, u32 *inputDelaysR) {
|
||||
if (betterReverbLightweight)
|
||||
filterCount = BETTER_REVERB_FILTER_COUNT_LIGHT;
|
||||
|
||||
gBetterReverbPool.cur = gBetterReverbPool.start + ALIGN16(BETTER_REVERB_PTR_SIZE); // Reset reverb data pool
|
||||
gBetterReverbPool.cur = gBetterReverbPool.start + BETTER_REVERB_PTR_SIZE; // Reset reverb data pool
|
||||
|
||||
// Don't bother setting any buffers if BETTER_REVERB is disabled
|
||||
if (!toggleBetterReverb)
|
||||
@@ -259,21 +210,20 @@ void set_better_reverb_buffers(u32 *inputDelaysL, u32 *inputDelaysR) {
|
||||
// NOTE: Using filterCount over NUM_ALLPASS will report less memory usage with fewer filters, but poses an additional
|
||||
// risk to anybody testing on console with performance compromises, as emulator can be easily overlooked.
|
||||
for (i = 0; i < filterCount; ++i) {
|
||||
delaysL[i] = (s32) (inputDelaysL[i] / gReverbDownsampleRate);
|
||||
delaysR[i] = (s32) (inputDelaysR[i] / gReverbDownsampleRate);
|
||||
delayBufsL[i] = soundAlloc(&gBetterReverbPool, delaysL[i] * sizeof(s32));
|
||||
bufOffset += delaysL[i];
|
||||
delayBufsR[i] = soundAlloc(&gBetterReverbPool, delaysR[i] * sizeof(s32));
|
||||
bufOffset += delaysR[i];
|
||||
betterReverbDelays[SYNTH_CHANNEL_LEFT][i] = (s32) (inputDelaysL[i] / gReverbDownsampleRate);
|
||||
betterReverbDelays[SYNTH_CHANNEL_RIGHT][i] = (s32) (inputDelaysR[i] / gReverbDownsampleRate);
|
||||
delayBufs[SYNTH_CHANNEL_LEFT][i] = soundAlloc(&gBetterReverbPool, betterReverbDelays[SYNTH_CHANNEL_LEFT][i] * sizeof(s16));
|
||||
bufOffset += betterReverbDelays[SYNTH_CHANNEL_LEFT][i];
|
||||
delayBufs[SYNTH_CHANNEL_RIGHT][i] = soundAlloc(&gBetterReverbPool, betterReverbDelays[SYNTH_CHANNEL_RIGHT][i] * sizeof(s16));
|
||||
bufOffset += betterReverbDelays[SYNTH_CHANNEL_RIGHT][i];
|
||||
}
|
||||
|
||||
aggress(bufOffset * sizeof(s32) <= BETTER_REVERB_SIZE - ALIGN16(BETTER_REVERB_PTR_SIZE), "BETTER_REVERB_SIZE is too small for this preset!");
|
||||
aggress(bufOffset * sizeof(s16) <= BETTER_REVERB_SIZE - BETTER_REVERB_PTR_SIZE, "BETTER_REVERB_SIZE is too small for this preset!");
|
||||
|
||||
lastDelayLightL = delaysL[filterCount-1];
|
||||
lastDelayLightR = delaysR[filterCount-1];
|
||||
lastDelayLight[SYNTH_CHANNEL_LEFT] = betterReverbDelays[SYNTH_CHANNEL_LEFT][filterCount-1];
|
||||
lastDelayLight[SYNTH_CHANNEL_RIGHT] = betterReverbDelays[SYNTH_CHANNEL_RIGHT][filterCount-1];
|
||||
|
||||
bzero(allpassIdxL, sizeof(allpassIdxL));
|
||||
bzero(allpassIdxR, sizeof(allpassIdxR));
|
||||
bzero(allpassIdx, sizeof(allpassIdx));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -376,81 +326,57 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex) {
|
||||
}
|
||||
#ifdef BETTER_REVERB
|
||||
else if (toggleBetterReverb) {
|
||||
s32 firstLoopMax;
|
||||
s32 secondLoopMax;
|
||||
s32 loopCounts[2];
|
||||
|
||||
s16 *betterReverbDownsampleBuffers[SYNTH_CHANNEL_STEREO_COUNT][ARRAY_COUNT(loopCounts)]; // StartA and StartB for both channels
|
||||
s16 *betterReverbSampleBuffers[SYNTH_CHANNEL_STEREO_COUNT][ARRAY_COUNT(loopCounts)]; // Output reverb buffers
|
||||
void (*reverbFunc)(s16*, s16*, s16*, s32) = betterReverbLightweight ? reverb_samples_light : reverb_samples; // Function pointers for both heavy and lightweight reverb functions
|
||||
|
||||
item = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
||||
dstPos = item->startPos;
|
||||
firstLoopMax = ((item->lengthA / 2) + item->startPos);
|
||||
secondLoopMax = (item->lengthB / 2);
|
||||
loopCounts[0] = item->lengthA / 2;
|
||||
loopCounts[1] = item->lengthB / 2;
|
||||
|
||||
// This block could be simplified probably with function pointers or rewriting reverb_mono_sample to support L and R individually. Another idea would be to process more than one sample at a time
|
||||
// for each function call. In practice with HackerSM64, these ideas either aren't super trivial to implement efficiently or don't benefit performance at all, so I'm leaving this as it is for now.
|
||||
if (betterReverbLightweight) {
|
||||
if (gSoundMode == SOUND_MODE_MONO || monoReverb) {
|
||||
if (gReverbDownsampleRate != 1) {
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
for (srcPos = 0; dstPos < firstLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_mono_sample_light(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) item->toDownsampleLeft[srcPos] + (s32) item->toDownsampleRight[srcPos]) / 2);
|
||||
bcopy(&gSynthesisReverb.ringBuffer.left[item->startPos], &gSynthesisReverb.ringBuffer.right[item->startPos], (dstPos - item->startPos) * sizeof(s16));
|
||||
if (gReverbDownsampleRate != 1) {
|
||||
// NOTE: / HACKERSM64 TODO: Commenting this check seems to improve runtime by about 100 microseconds (per 30fps frame),
|
||||
// but idk enough about why it was added here in vanilla to comfortably remove it. Is it supposed to act as an
|
||||
// optimization (that isn't actually an optimization) or is it a safety measure since it's loaded from the RSP?
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
}
|
||||
|
||||
betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][0] = &gSynthesisReverb.ringBuffer.left[item->startPos];
|
||||
betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][1] = &gSynthesisReverb.ringBuffer.left[0];
|
||||
betterReverbSampleBuffers[SYNTH_CHANNEL_RIGHT][0] = &gSynthesisReverb.ringBuffer.right[item->startPos];
|
||||
betterReverbSampleBuffers[SYNTH_CHANNEL_RIGHT][1] = &gSynthesisReverb.ringBuffer.right[0];
|
||||
if (gReverbDownsampleRate > 1) {
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][0] = &item->toDownsampleLeft[0];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][1] = &item->toDownsampleLeft[loopCounts[0] * gReverbDownsampleRate];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_RIGHT][0] = &item->toDownsampleRight[0];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_RIGHT][1] = &item->toDownsampleRight[loopCounts[0] * gReverbDownsampleRate];
|
||||
} else {
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][0] = betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][0];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][1] = betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][1];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_RIGHT][0] = betterReverbSampleBuffers[SYNTH_CHANNEL_RIGHT][0];
|
||||
betterReverbDownsampleBuffers[SYNTH_CHANNEL_RIGHT][1] = betterReverbSampleBuffers[SYNTH_CHANNEL_RIGHT][1];
|
||||
}
|
||||
|
||||
for (dstPos = 0; dstPos < secondLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_mono_sample_light(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) item->toDownsampleLeft[srcPos] + (s32) item->toDownsampleRight[srcPos]) / 2);
|
||||
bcopy(gSynthesisReverb.ringBuffer.left, gSynthesisReverb.ringBuffer.right, dstPos * sizeof(s16));
|
||||
} else {
|
||||
for (; dstPos < firstLoopMax; dstPos++)
|
||||
reverb_mono_sample_light(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) gSynthesisReverb.ringBuffer.left[dstPos] + (s32) gSynthesisReverb.ringBuffer.right[dstPos]) / 2);
|
||||
bcopy(&gSynthesisReverb.ringBuffer.left[item->startPos], &gSynthesisReverb.ringBuffer.right[item->startPos], (dstPos - item->startPos) * sizeof(s16));
|
||||
|
||||
for (dstPos = 0; dstPos < secondLoopMax; dstPos++)
|
||||
reverb_mono_sample_light(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) gSynthesisReverb.ringBuffer.left[dstPos] + (s32) gSynthesisReverb.ringBuffer.right[dstPos]) / 2);
|
||||
bcopy(gSynthesisReverb.ringBuffer.left, gSynthesisReverb.ringBuffer.right, dstPos * sizeof(s16));
|
||||
}
|
||||
} else {
|
||||
if (gReverbDownsampleRate != 1) {
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
for (srcPos = 0; dstPos < firstLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_samples_light(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], item->toDownsampleLeft[srcPos], item->toDownsampleRight[srcPos]);
|
||||
for (dstPos = 0; dstPos < secondLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_samples_light(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], item->toDownsampleLeft[srcPos], item->toDownsampleRight[srcPos]);
|
||||
} else {
|
||||
for (; dstPos < firstLoopMax; dstPos++)
|
||||
reverb_samples_light(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], gSynthesisReverb.ringBuffer.left[dstPos], gSynthesisReverb.ringBuffer.right[dstPos]);
|
||||
for (dstPos = 0; dstPos < secondLoopMax; dstPos++)
|
||||
reverb_samples_light(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], gSynthesisReverb.ringBuffer.left[dstPos], gSynthesisReverb.ringBuffer.right[dstPos]);
|
||||
if (gSoundMode == SOUND_MODE_MONO || monoReverb) {
|
||||
for (srcPos = 0; srcPos < ARRAY_COUNT(loopCounts); srcPos++) { // LengthA and LengthB processing
|
||||
s16 *downsampleBufferL = betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][srcPos];
|
||||
s16 *downsampleBufferR = betterReverbDownsampleBuffers[SYNTH_CHANNEL_RIGHT][srcPos];
|
||||
for (dstPos = 0; dstPos < loopCounts[srcPos]; dstPos += gReverbDownsampleRate) { // Individual sample processing
|
||||
downsampleBufferL[dstPos] = ((s32) downsampleBufferL[dstPos] + (s32) downsampleBufferR[dstPos]) >> 1; // Merge stereo samples into left channel
|
||||
}
|
||||
}
|
||||
for (srcPos = 0; srcPos < ARRAY_COUNT(loopCounts); srcPos++) { // LengthA and LengthB processing
|
||||
// Call core reverb processing function, either reverb_samples() or reverb_samples_light()
|
||||
(*reverbFunc)(betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][srcPos], betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][srcPos] + loopCounts[srcPos], betterReverbDownsampleBuffers[SYNTH_CHANNEL_LEFT][srcPos], SYNTH_CHANNEL_LEFT);
|
||||
bcopy(betterReverbSampleBuffers[SYNTH_CHANNEL_LEFT][srcPos], betterReverbSampleBuffers[SYNTH_CHANNEL_RIGHT][srcPos], loopCounts[srcPos] * sizeof(s16));
|
||||
}
|
||||
} else {
|
||||
if (gSoundMode == SOUND_MODE_MONO || monoReverb) {
|
||||
if (gReverbDownsampleRate != 1) {
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
for (srcPos = 0; dstPos < firstLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_mono_sample(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) item->toDownsampleLeft[srcPos] + (s32) item->toDownsampleRight[srcPos]) / 2);
|
||||
bcopy(&gSynthesisReverb.ringBuffer.left[item->startPos], &gSynthesisReverb.ringBuffer.right[item->startPos], (dstPos - item->startPos) * sizeof(s16));
|
||||
|
||||
for (dstPos = 0; dstPos < secondLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_mono_sample(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) item->toDownsampleLeft[srcPos] + (s32) item->toDownsampleRight[srcPos]) / 2);
|
||||
bcopy(gSynthesisReverb.ringBuffer.left, gSynthesisReverb.ringBuffer.right, dstPos * sizeof(s16));
|
||||
} else {
|
||||
for (; dstPos < firstLoopMax; dstPos++)
|
||||
reverb_mono_sample(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) gSynthesisReverb.ringBuffer.left[dstPos] + (s32) gSynthesisReverb.ringBuffer.right[dstPos]) / 2);
|
||||
bcopy(&gSynthesisReverb.ringBuffer.left[item->startPos], &gSynthesisReverb.ringBuffer.right[item->startPos], (dstPos - item->startPos) * sizeof(s16));
|
||||
|
||||
for (dstPos = 0; dstPos < secondLoopMax; dstPos++)
|
||||
reverb_mono_sample(&gSynthesisReverb.ringBuffer.left[dstPos], ((s32) gSynthesisReverb.ringBuffer.left[dstPos] + (s32) gSynthesisReverb.ringBuffer.right[dstPos]) / 2);
|
||||
bcopy(gSynthesisReverb.ringBuffer.left, gSynthesisReverb.ringBuffer.right, dstPos * sizeof(s16));
|
||||
}
|
||||
} else {
|
||||
if (gReverbDownsampleRate != 1) {
|
||||
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
|
||||
for (srcPos = 0; dstPos < firstLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_samples(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], item->toDownsampleLeft[srcPos], item->toDownsampleRight[srcPos]);
|
||||
for (dstPos = 0; dstPos < secondLoopMax; srcPos += gReverbDownsampleRate, dstPos++)
|
||||
reverb_samples(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], item->toDownsampleLeft[srcPos], item->toDownsampleRight[srcPos]);
|
||||
} else {
|
||||
for (; dstPos < firstLoopMax; dstPos++)
|
||||
reverb_samples(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], gSynthesisReverb.ringBuffer.left[dstPos], gSynthesisReverb.ringBuffer.right[dstPos]);
|
||||
for (dstPos = 0; dstPos < secondLoopMax; dstPos++)
|
||||
reverb_samples(&gSynthesisReverb.ringBuffer.left[dstPos], &gSynthesisReverb.ringBuffer.right[dstPos], gSynthesisReverb.ringBuffer.left[dstPos], gSynthesisReverb.ringBuffer.right[dstPos]);
|
||||
for (dstPos = 0; dstPos < SYNTH_CHANNEL_STEREO_COUNT; dstPos++) { // left and right channels
|
||||
for (srcPos = 0; srcPos < ARRAY_COUNT(loopCounts); srcPos++) { // LengthA and LengthB processing
|
||||
// Call core reverb processing function, either reverb_samples() or reverb_samples_light()
|
||||
(*reverbFunc)(betterReverbSampleBuffers[dstPos][srcPos], betterReverbSampleBuffers[dstPos][srcPos] + loopCounts[srcPos], betterReverbDownsampleBuffers[dstPos][srcPos], dstPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,18 +527,18 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
|
||||
|
||||
reverbLastFilterIndex = reverbFilterCount - 1;
|
||||
|
||||
// Update reverbMultsL every audio frame just in case gReverbMults is ever to change.
|
||||
if (gReverbMultsL != NULL && gReverbMultsR != NULL) {
|
||||
// Update reverbMults every audio frame just in case gReverbMults is ever to change.
|
||||
if (gReverbMults[SYNTH_CHANNEL_LEFT] != NULL && gReverbMults[SYNTH_CHANNEL_RIGHT] != NULL) {
|
||||
for (i = 0; i < filterCountDiv3; ++i) {
|
||||
reverbMultsL[i] = gReverbMultsL[i];
|
||||
reverbMultsR[i] = gReverbMultsR[i];
|
||||
reverbMults[SYNTH_CHANNEL_LEFT][i] = gReverbMults[SYNTH_CHANNEL_LEFT][i];
|
||||
reverbMults[SYNTH_CHANNEL_RIGHT][i] = gReverbMults[SYNTH_CHANNEL_RIGHT][i];
|
||||
}
|
||||
}
|
||||
|
||||
// If there's only one reverb multiplier set, adjust these to match so one channel doesn't end up potentially overpowering the other.
|
||||
if (filterCountDiv3 == 1) {
|
||||
reverbMultsL[0] = (reverbMultsR[0] + reverbMultsL[0]) / 2;
|
||||
reverbMultsR[0] = reverbMultsL[0];
|
||||
reverbMults[SYNTH_CHANNEL_LEFT][0] = (reverbMults[SYNTH_CHANNEL_RIGHT][0] + reverbMults[SYNTH_CHANNEL_LEFT][0]) / 2;
|
||||
reverbMults[SYNTH_CHANNEL_RIGHT][0] = reverbMults[SYNTH_CHANNEL_LEFT][0];
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -844,9 +770,9 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
||||
aResample(cmd++, gSynthesisReverb.resampleFlags, (u16) gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateLeft));
|
||||
aSetBuffer(cmd++, 0, t4 + DMEM_ADDR_WET_RIGHT_CH, DMEM_ADDR_RIGHT_CH, bufLen << 1);
|
||||
aResample(cmd++, gSynthesisReverb.resampleFlags, (u16) gSynthesisReverb.resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.resampleStateRight));
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_LEFT_CH, /*out*/ DMEM_ADDR_LEFT_CH);
|
||||
aDMEMMove(cmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
|
||||
aSetBuffer(cmd++, 0, 0, 0, DEFAULT_LEN_2CH);
|
||||
aMix(cmd++, 0, /*gain*/ 0x8000 + gSynthesisReverb.reverbGain, /*in*/ DMEM_ADDR_WET_LEFT_CH, /*out*/ DMEM_ADDR_WET_LEFT_CH);
|
||||
}
|
||||
|
||||
AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING);
|
||||
@@ -921,7 +847,9 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
s32 nSamplesToProcess; // sp10c/a0, spE0
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
s32 leftRight;
|
||||
#endif
|
||||
s32 s3;
|
||||
s32 s5; //s4
|
||||
|
||||
@@ -1206,7 +1134,12 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
|
||||
switch (flags) {
|
||||
case A_INIT: // = 1
|
||||
sp130 = 0;
|
||||
/**
|
||||
* !NOTE: Removing this seems to produce a more accurate waveform, however I have no idea why Nintendo decided to add this originally.
|
||||
* I can only speculate (and hope) that this was just an oversight on their part and this has no reason to exist, given my testing.
|
||||
* I'm leaving it commented out here just in case though.
|
||||
*/
|
||||
// sp130 = 0;
|
||||
s5 = s0 * 2 + s5;
|
||||
break;
|
||||
|
||||
@@ -1332,6 +1265,7 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
aResample(cmd++, flags, resamplingRateFixedPoint, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->finalResampleState));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
#ifdef VERSION_EU
|
||||
if (noteSubEu->headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0) {
|
||||
leftRight = 1;
|
||||
@@ -1351,7 +1285,7 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
#ifdef VERSION_EU
|
||||
cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, 0, leftRight, flags);
|
||||
#else
|
||||
cmd = process_envelope(cmd, note, bufLen, 0, leftRight, flags);
|
||||
cmd = process_envelope(cmd, note, bufLen, 0, leftRight);
|
||||
#endif
|
||||
AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING);
|
||||
|
||||
@@ -1363,6 +1297,11 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd) {
|
||||
if (note->usesHeadsetPanEffects) {
|
||||
cmd = note_apply_headset_pan_effects(cmd, note, bufLen * 2, flags, leftRight);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB);
|
||||
cmd = process_envelope(cmd, note, bufLen, 0);
|
||||
AUDIO_PROFILER_SWITCH(PROFILER_TIME_SUB_AUDIO_SYNTHESIS_ENVELOPE_REVERB, PROFILER_TIME_SUB_AUDIO_SYNTHESIS_PROCESSING);
|
||||
#endif
|
||||
}
|
||||
#ifndef VERSION_EU
|
||||
@@ -1419,20 +1358,38 @@ u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) {
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings,
|
||||
UNUSED u32 flags) {
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf, s32 headsetPanSettings) {
|
||||
#else
|
||||
u64 *process_envelope(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf) {
|
||||
#endif
|
||||
struct VolumeChange vol;
|
||||
vol.sourceLeft = note->curVolLeft;
|
||||
vol.sourceRight = note->curVolRight;
|
||||
if (note->initFullVelocity) {
|
||||
note->initFullVelocity = FALSE;
|
||||
vol.sourceLeft = note->targetVolLeft;
|
||||
vol.sourceRight = note->targetVolRight;
|
||||
} else {
|
||||
vol.sourceLeft = note->curVolLeft;
|
||||
vol.sourceRight = note->curVolRight;
|
||||
}
|
||||
vol.targetLeft = note->targetVolLeft;
|
||||
vol.targetRight = note->targetVolRight;
|
||||
note->curVolLeft = vol.targetLeft;
|
||||
note->curVolRight = vol.targetRight;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
return process_envelope_inner(cmd, note, nSamples, inBuf, headsetPanSettings, &vol);
|
||||
#else
|
||||
return process_envelope_inner(cmd, note, nSamples, inBuf, &vol);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf,
|
||||
s32 headsetPanSettings, struct VolumeChange *vol) {
|
||||
#else
|
||||
u64 *process_envelope_inner(u64 *cmd, struct Note *note, s32 nSamples, u16 inBuf,
|
||||
struct VolumeChange *vol) {
|
||||
#endif
|
||||
u8 mixerFlags;
|
||||
s32 rampLeft, rampRight;
|
||||
#elif defined(VERSION_EU)
|
||||
@@ -1463,6 +1420,7 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
// in, dry left, count without A_AUX flag.
|
||||
// dry right, wet left, wet right with A_AUX flag.
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
if (note->usesHeadsetPanEffects) {
|
||||
aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DEFAULT_LEN_1CH);
|
||||
|
||||
@@ -1502,6 +1460,10 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
aSetBuffer(cmd++, A_AUX, DMEM_ADDR_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_RIGHT_CH);
|
||||
}
|
||||
}
|
||||
#else
|
||||
aSetBuffer(cmd++, 0, inBuf, DMEM_ADDR_LEFT_CH, nSamples * 2);
|
||||
aSetBuffer(cmd++, A_AUX, DMEM_ADDR_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_RIGHT_CH);
|
||||
#endif
|
||||
|
||||
#ifdef VERSION_EU
|
||||
if (targetLeft == sourceLeft && targetRight == sourceRight && !note->envMixerNeedsInit) {
|
||||
@@ -1522,17 +1484,17 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
// but with discretizations of targetVol, sourceVol and arg2.
|
||||
switch (nSamples) {
|
||||
case 128:
|
||||
rampLeft = gVolRampingLhs128[vol->targetLeft >> 8] * gVolRampingRhs128[vol->sourceLeft >> 8];
|
||||
rampRight = gVolRampingLhs128[vol->targetRight >> 8] * gVolRampingRhs128[vol->sourceRight >> 8];
|
||||
rampLeft = gVolRampingLhs128[vol->targetLeft >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs128[vol->sourceLeft >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
rampRight = gVolRampingLhs128[vol->targetRight >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs128[vol->sourceRight >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
break;
|
||||
case 144:
|
||||
rampLeft = gVolRampingLhs144[vol->targetLeft >> 8] * gVolRampingRhs144[vol->sourceLeft >> 8];
|
||||
rampRight = gVolRampingLhs144[vol->targetRight >> 8] * gVolRampingRhs144[vol->sourceRight >> 8];
|
||||
rampLeft = gVolRampingLhs144[vol->targetLeft >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs144[vol->sourceLeft >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
rampRight = gVolRampingLhs144[vol->targetRight >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs144[vol->sourceRight >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
break;
|
||||
case 136:
|
||||
default:
|
||||
rampLeft = gVolRampingLhs136[vol->targetLeft >> 8] * gVolRampingRhs136[vol->sourceLeft >> 8];
|
||||
rampRight = gVolRampingLhs136[vol->targetRight >> 8] * gVolRampingRhs136[vol->sourceRight >> 8];
|
||||
rampLeft = gVolRampingLhs136[vol->targetLeft >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs136[vol->sourceLeft >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
rampRight = gVolRampingLhs136[vol->targetRight >> (15 - VOL_RAMPING_EXPONENT)] * gVolRampingRhs136[vol->sourceRight >> (15 - VOL_RAMPING_EXPONENT)];
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -1553,6 +1515,7 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
#ifdef VERSION_EU
|
||||
if (gUseReverb && note->reverbVol != 0) {
|
||||
aEnvMixer(cmd++, mixerFlags | A_AUX,
|
||||
@@ -1588,9 +1551,16 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
|
||||
/*out*/ DMEM_ADDR_RIGHT_CH);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (gSynthesisReverb.useReverb && note->reverbVol != 0) {
|
||||
mixerFlags |= A_AUX;
|
||||
}
|
||||
aEnvMixer(cmd++, mixerFlags, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->mixEnvelopeState));
|
||||
#endif
|
||||
return cmd;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
#ifdef VERSION_EU
|
||||
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) {
|
||||
#else
|
||||
@@ -1686,6 +1656,7 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct Note *note, s32 bufLen, s32
|
||||
|
||||
return cmd;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef VERSION_EU
|
||||
// Moved to playback.c in EU
|
||||
@@ -1695,7 +1666,6 @@ void note_init_volume(struct Note *note) {
|
||||
note->targetVolRight = 0;
|
||||
note->reverbVol = 0;
|
||||
note->reverbVolShifted = 0;
|
||||
note->unused2 = 0;
|
||||
note->curVolLeft = 1;
|
||||
note->curVolRight = 1;
|
||||
note->frequency = 0.0f;
|
||||
@@ -1704,7 +1674,12 @@ void note_init_volume(struct Note *note) {
|
||||
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverbVol) {
|
||||
f32 volLeft, volRight;
|
||||
s32 panIndex = (s32)(pan * 127.5f) & 127;
|
||||
if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_HEADSET) {
|
||||
|
||||
if (gSoundMode == SOUND_MODE_MONO) {
|
||||
volLeft = 0.707f;
|
||||
volRight = 0.707f;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
} else if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_HEADSET) {
|
||||
s8 smallPanIndex;
|
||||
s8 temp = (s8)(pan * 10.0f);
|
||||
if (temp < 9) {
|
||||
@@ -1734,9 +1709,7 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb
|
||||
}
|
||||
note->stereoStrongRight = strongRight;
|
||||
note->stereoStrongLeft = strongLeft;
|
||||
} else if (gSoundMode == SOUND_MODE_MONO) {
|
||||
volLeft = 0.707f;
|
||||
volRight = 0.707f;
|
||||
#endif
|
||||
} else {
|
||||
volLeft = gDefaultPanVolume[panIndex];
|
||||
volRight = gDefaultPanVolume[127 - panIndex];
|
||||
@@ -1745,8 +1718,8 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb
|
||||
if (velocity < 0) {
|
||||
velocity = 0;
|
||||
}
|
||||
note->targetVolLeft = (u16)(s32)(velocity * volLeft) & ~0x80FF;
|
||||
note->targetVolRight = (u16)(s32)(velocity * volRight) & ~0x80FF;
|
||||
note->targetVolLeft = (u16)(s32)(velocity * volLeft) & VOLRAMPING_MASK;
|
||||
note->targetVolRight = (u16)(s32)(velocity * volRight) & VOLRAMPING_MASK;
|
||||
if (note->targetVolLeft == 0) {
|
||||
note->targetVolLeft++;
|
||||
}
|
||||
@@ -1772,13 +1745,16 @@ void note_enable(struct Note *note) {
|
||||
note->needsInit = TRUE;
|
||||
note->restart = FALSE;
|
||||
note->finished = FALSE;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
note->stereoStrongRight = FALSE;
|
||||
note->stereoStrongLeft = FALSE;
|
||||
note->usesHeadsetPanEffects = FALSE;
|
||||
note->initFullVelocity = FALSE;
|
||||
note->headsetPanLeft = 0;
|
||||
note->headsetPanRight = 0;
|
||||
note->prevHeadsetPanRight = 0;
|
||||
note->prevHeadsetPanLeft = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void note_disable(struct Note *note) {
|
||||
|
||||
+11
-6
@@ -17,6 +17,12 @@
|
||||
#define MAX_UPDATES_PER_FRAME 4
|
||||
#endif
|
||||
|
||||
enum ChannelIndexes {
|
||||
SYNTH_CHANNEL_LEFT,
|
||||
SYNTH_CHANNEL_RIGHT,
|
||||
SYNTH_CHANNEL_STEREO_COUNT,
|
||||
};
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
|
||||
#define REVERB_WINDOW_SIZE_MAX 0x2000
|
||||
@@ -25,13 +31,13 @@
|
||||
/* ------------ BETTER REVERB GENERAL PARAMETERS ------------ */
|
||||
|
||||
#define NUM_ALLPASS 12 // Maximum number of delay filters to use with better reverb; do not change this value if you don't know what you're doing.
|
||||
#define BETTER_REVERB_PTR_SIZE ALIGN16(NUM_ALLPASS * sizeof(s32*) * 2) // Allocation space consumed by dynamically allocated pointers
|
||||
#define BETTER_REVERB_PTR_SIZE ALIGN16(NUM_ALLPASS * sizeof(s16*) * SYNTH_CHANNEL_STEREO_COUNT) // Allocation space consumed by dynamically allocated pointers
|
||||
|
||||
// Size determined by (all delaysL/R values * 8) / (2 ^ Minimum Downsample Factor).
|
||||
// Minimum size requirement determined by ((all delaysL and delaysR values) / (2 ^ (downsampleRate - 1)) * sizeof(s16) + BETTER_REVERB_PTR_SIZE).
|
||||
// The default value can be increased or decreased in conjunction with the values in delaysL/R.
|
||||
// This can be significantly decreased if a downsample rate of 1 is not being used or if filter count is less than NUM_ALLPASS,
|
||||
// as this default is configured to handle the emulator RCVI settings.
|
||||
#define BETTER_REVERB_SIZE ALIGN16(0x1E000 + BETTER_REVERB_PTR_SIZE)
|
||||
#define BETTER_REVERB_SIZE ALIGN16(0xEDE0 + BETTER_REVERB_PTR_SIZE)
|
||||
|
||||
|
||||
/* ------ BETTER REVERB LIGHTWEIGHT PARAMETER OVERRIDES ------ */
|
||||
@@ -48,7 +54,7 @@
|
||||
/* ------------ BETTER REVERB EXTERNED VARIABLES ------------ */
|
||||
|
||||
extern u8 toggleBetterReverb;
|
||||
extern u8 gBetterReverbPreset;
|
||||
extern u8 gBetterReverbPresetValue;
|
||||
extern u8 betterReverbLightweight;
|
||||
extern s8 betterReverbDownsampleRate;
|
||||
extern u8 monoReverb;
|
||||
@@ -56,8 +62,7 @@ extern s32 reverbFilterCount;
|
||||
extern s32 betterReverbWindowsSize;
|
||||
extern s32 betterReverbRevIndex;
|
||||
extern s32 betterReverbGainIndex;
|
||||
extern s32 *gReverbMultsL;
|
||||
extern s32 *gReverbMultsR;
|
||||
extern u8 *gReverbMults[SYNTH_CHANNEL_STEREO_COUNT];
|
||||
|
||||
|
||||
/* ------------ BETTER REVERB EXTERNED FUNCTIONS ------------ */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+3
-27
@@ -15,7 +15,6 @@
|
||||
#include "game/main.h"
|
||||
#include "game/rumble_init.h"
|
||||
#include "game/version.h"
|
||||
#include "game/vc_check.h"
|
||||
#ifdef UNF
|
||||
#include "usb/usb.h"
|
||||
#include "usb/debug.h"
|
||||
@@ -23,8 +22,7 @@
|
||||
#include "game/puppyprint.h"
|
||||
#include "game/puppylights.h"
|
||||
#include "game/profiling.h"
|
||||
|
||||
#include "game/vc_check.h"
|
||||
#include "game/emutest.h"
|
||||
|
||||
// Message IDs
|
||||
enum MessageIDs {
|
||||
@@ -318,21 +316,6 @@ void alert_rcp_hung_up(void) {
|
||||
error("RCP is HUNG UP!! Oh! MY GOD!!");
|
||||
}
|
||||
|
||||
void check_cache_emulation() {
|
||||
// Disable interrupts to ensure that nothing evicts the variable from cache while we're using it.
|
||||
u32 saved = __osDisableInt();
|
||||
// Create a variable with an initial value of 1. This value will remain cached.
|
||||
volatile u8 sCachedValue = 1;
|
||||
// Overwrite the variable directly in RDRAM without going through cache.
|
||||
// This should preserve its value of 1 in dcache if dcache is emulated correctly.
|
||||
*(u8*)(K0_TO_K1(&sCachedValue)) = 0;
|
||||
// Read the variable back from dcache, if it's still 1 then cache is emulated correctly.
|
||||
// If it's zero, then dcache is not emulated correctly.
|
||||
gCacheEmulated = sCachedValue;
|
||||
// Restore interrupts
|
||||
__osRestoreInt(saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the first and last values of the stack.
|
||||
* If they're different, that means an error has occured, so trigger a crash.
|
||||
@@ -366,7 +349,7 @@ void thread3_main(UNUSED void *arg) {
|
||||
setup_mesg_queues();
|
||||
alloc_pool();
|
||||
load_engine_code_segment();
|
||||
gIsVC = IS_VC();
|
||||
detect_emulator();
|
||||
#ifndef UNF
|
||||
crash_screen_init();
|
||||
#endif
|
||||
@@ -384,14 +367,8 @@ void thread3_main(UNUSED void *arg) {
|
||||
osSyncPrintf("Linker : %s\n", __linker__);
|
||||
#endif
|
||||
|
||||
if (IO_READ(DPC_CLOCK_REG) == 0) {
|
||||
gIsConsole = FALSE;
|
||||
if (!(gEmulator & EMU_CONSOLE)) {
|
||||
gBorderHeight = BORDER_HEIGHT_EMULATOR;
|
||||
if (!gIsVC) {
|
||||
check_cache_emulation();
|
||||
} else {
|
||||
gCacheEmulated = FALSE;
|
||||
}
|
||||
#ifdef RCVI_HACK
|
||||
VI.comRegs.vSync = 525*20;
|
||||
change_vi(&VI, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@@ -400,7 +377,6 @@ void thread3_main(UNUSED void *arg) {
|
||||
osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
|
||||
#endif
|
||||
} else {
|
||||
gIsConsole = TRUE;
|
||||
gBorderHeight = BORDER_HEIGHT_CONSOLE;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -419,42 +419,6 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
UNUSED void *dest = NULL;
|
||||
|
||||
#ifdef GZIP
|
||||
u32 compSize = (srcEnd - 4 - srcStart);
|
||||
#else
|
||||
u32 compSize = ALIGN16(srcEnd - srcStart);
|
||||
#endif
|
||||
u8 *compressed = main_pool_alloc(compSize, MEMORY_POOL_RIGHT);
|
||||
#ifdef GZIP
|
||||
// Decompressed size from end of gzip
|
||||
u32 *size = (u32 *) (compressed + compSize);
|
||||
#endif
|
||||
if (compressed != NULL) {
|
||||
#ifdef UNCOMPRESSED
|
||||
dma_read(gDecompressionHeap, srcStart, srcEnd);
|
||||
#else
|
||||
dma_read(compressed, srcStart, srcEnd);
|
||||
#endif
|
||||
#ifdef GZIP
|
||||
expand_gzip(compressed, gDecompressionHeap, compSize, (u32)size);
|
||||
#elif RNC1
|
||||
Propack_UnpackM1(compressed, gDecompressionHeap);
|
||||
#elif RNC2
|
||||
Propack_UnpackM2(compressed, gDecompressionHeap);
|
||||
#elif YAY0
|
||||
slidstart(compressed, gDecompressionHeap);
|
||||
#elif MIO0
|
||||
decompress(compressed, gDecompressionHeap);
|
||||
#endif
|
||||
set_segment_base_addr(segment, gDecompressionHeap);
|
||||
main_pool_free(compressed);
|
||||
}
|
||||
return gDecompressionHeap;
|
||||
}
|
||||
|
||||
void load_engine_code_segment(void) {
|
||||
void *startAddr = (void *) _engineSegmentStart;
|
||||
u32 totalSize = _engineSegmentEnd - _engineSegmentStart;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "config.h"
|
||||
#include "audio/synthesis.h"
|
||||
|
||||
ALIGNED8 u8 gDecompressionHeap[0xD000];
|
||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE)];
|
||||
|
||||
ALIGNED8 u8 gIdleThreadStack[THREAD1_STACK];
|
||||
@@ -20,14 +19,8 @@ ALIGNED8 u8 gThread5Stack[THREAD5_STACK];
|
||||
ALIGNED8 u8 gThread6Stack[THREAD6_STACK];
|
||||
#endif
|
||||
// 0x400 bytes
|
||||
#if UNF
|
||||
ALIGNED16 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
ALIGNED16 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
#else
|
||||
// 0xc00 bytes for f3dex, 0x900 otherwise
|
||||
ALIGNED8 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
ALIGNED8 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
#endif // UNF
|
||||
__attribute__((aligned(32))) u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
__attribute__((aligned(32))) u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
// 0x200 bytes
|
||||
ALIGNED8 struct SaveBuffer gSaveBuffer;
|
||||
// 0x190a0 bytes
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "config.h"
|
||||
#include "audio/data.h"
|
||||
|
||||
extern u8 gDecompressionHeap[];
|
||||
|
||||
extern u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE)];
|
||||
|
||||
extern u8 gIdleThreadStack[THREAD1_STACK];
|
||||
|
||||
@@ -359,7 +359,7 @@ static s32 bhv_cmd_set_int_unused(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x14: Sets the specified field to a random float in the given range.
|
||||
// Command 0x15: Sets the specified field to a random float in the given range.
|
||||
// Usage: SET_RANDOM_FLOAT(field, min, range)
|
||||
static s32 bhv_cmd_set_random_float(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -372,7 +372,7 @@ static s32 bhv_cmd_set_random_float(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x15: Sets the specified field to a random integer in the given range.
|
||||
// Command 0x16: Sets the specified field to a random integer in the given range.
|
||||
// Usage: SET_RANDOM_INT(field, min, range)
|
||||
static s32 bhv_cmd_set_random_int(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -385,7 +385,7 @@ static s32 bhv_cmd_set_random_int(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x13: Gets a random short, right shifts it the specified amount and adds min to it, then sets the specified field to that value.
|
||||
// Command 0x14: Gets a random short, right shifts it the specified amount and adds min to it, then sets the specified field to that value.
|
||||
// Usage: SET_INT_RAND_RSHIFT(field, min, rshift)
|
||||
static s32 bhv_cmd_set_int_rand_rshift(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -398,7 +398,7 @@ static s32 bhv_cmd_set_int_rand_rshift(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x16: Adds a random float in the given range to the specified field.
|
||||
// Command 0x17: Adds a random float in the given range to the specified field.
|
||||
// Usage: ADD_RANDOM_FLOAT(field, min, range)
|
||||
static s32 bhv_cmd_add_random_float(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -411,7 +411,7 @@ static s32 bhv_cmd_add_random_float(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x17: Gets a random short, right shifts it the specified amount and adds min to it, then adds the value to the specified field. Unused.
|
||||
// Command 0x18: Gets a random short, right shifts it the specified amount and adds min to it, then adds the value to the specified field. Unused.
|
||||
// Usage: ADD_INT_RAND_RSHIFT(field, min, rshift)
|
||||
static s32 bhv_cmd_add_int_rand_rshift(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -463,7 +463,20 @@ static s32 bhv_cmd_or_int(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x12: Performs a bit clear with the specified short. Unused.
|
||||
// Command 0x12: Performs a bitwise OR with the specified field and the given (32 bit) integer.
|
||||
// Usually used to set an object's flags which use values above 16 bits.
|
||||
// Usage: OR_LONG(field, value)
|
||||
static s32 bhv_cmd_or_long(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
u32 value = BHV_CMD_GET_U32(1);
|
||||
|
||||
cur_obj_or_int(field, value);
|
||||
|
||||
gCurBhvCommand += 2;
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x13: Performs a bit clear with the specified short. Unused.
|
||||
// Usage: BIT_CLEAR(field, value)
|
||||
static s32 bhv_cmd_bit_clear(void) {
|
||||
u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -510,7 +523,7 @@ static s32 bhv_cmd_drop_to_floor(void) {
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x18: No operation. Unused.
|
||||
// Command 0x19: No operation. Unused.
|
||||
// Usage: CMD_NOP_1(field)
|
||||
static s32 bhv_cmd_nop_1(void) {
|
||||
UNUSED u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -520,15 +533,6 @@ static s32 bhv_cmd_nop_1(void) {
|
||||
}
|
||||
|
||||
// Command 0x1A: No operation. Unused.
|
||||
// Usage: CMD_NOP_3(field)
|
||||
static s32 bhv_cmd_nop_3(void) {
|
||||
UNUSED u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
|
||||
gCurBhvCommand++;
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x19: No operation. Unused.
|
||||
// Usage: CMD_NOP_2(field)
|
||||
static s32 bhv_cmd_nop_2(void) {
|
||||
UNUSED u8 field = BHV_CMD_GET_2ND_U8(0);
|
||||
@@ -773,6 +777,7 @@ static BhvCommandProc BehaviorCmdTable[] = {
|
||||
/*BHV_CMD_ADD_INT */ bhv_cmd_add_int,
|
||||
/*BHV_CMD_SET_INT */ bhv_cmd_set_int,
|
||||
/*BHV_CMD_OR_INT */ bhv_cmd_or_int,
|
||||
/*BHV_CMD_OR_LONG */ bhv_cmd_or_long,
|
||||
/*BHV_CMD_BIT_CLEAR */ bhv_cmd_bit_clear,
|
||||
/*BHV_CMD_SET_INT_RAND_RSHIFT */ bhv_cmd_set_int_rand_rshift,
|
||||
/*BHV_CMD_SET_RANDOM_FLOAT */ bhv_cmd_set_random_float,
|
||||
@@ -781,7 +786,6 @@ static BhvCommandProc BehaviorCmdTable[] = {
|
||||
/*BHV_CMD_ADD_INT_RAND_RSHIFT */ bhv_cmd_add_int_rand_rshift,
|
||||
/*BHV_CMD_NOP_1 */ bhv_cmd_nop_1,
|
||||
/*BHV_CMD_NOP_2 */ bhv_cmd_nop_2,
|
||||
/*BHV_CMD_NOP_3 */ bhv_cmd_nop_3,
|
||||
/*BHV_CMD_SET_MODEL */ bhv_cmd_set_model,
|
||||
/*BHV_CMD_SPAWN_CHILD */ bhv_cmd_spawn_child,
|
||||
/*BHV_CMD_DEACTIVATE */ bhv_cmd_deactivate,
|
||||
|
||||
@@ -261,7 +261,7 @@ void geo_layout_cmd_node_perspective(void) {
|
||||
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
|
||||
}
|
||||
|
||||
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, (f32) fov, near, far, frustumFunc, 0);
|
||||
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, (f32) fov, near, far, frustumFunc);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrt
|
||||
struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool,
|
||||
struct GraphNodePerspective *graphNode,
|
||||
f32 fov, u16 near, u16 far,
|
||||
GraphNodeFunc nodeFunc, s32 unused) {
|
||||
GraphNodeFunc nodeFunc) {
|
||||
if (pool != NULL) {
|
||||
graphNode = alloc_only_pool_alloc(pool, sizeof(struct GraphNodePerspective));
|
||||
}
|
||||
@@ -83,7 +83,6 @@ struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *p
|
||||
graphNode->near = near;
|
||||
graphNode->far = far;
|
||||
graphNode->fnNode.func = nodeFunc;
|
||||
graphNode->unused = unused;
|
||||
|
||||
if (nodeFunc != NULL) {
|
||||
nodeFunc(GEO_CONTEXT_CREATE, &graphNode->fnNode.node, pool);
|
||||
|
||||
@@ -131,10 +131,13 @@ struct GraphNodeOrthoProjection {
|
||||
*/
|
||||
struct GraphNodePerspective {
|
||||
/*0x00*/ struct FnGraphNode fnNode;
|
||||
/*0x18*/ s32 unused;
|
||||
/*0x1C*/ f32 fov; // horizontal field of view in degrees
|
||||
/*0x20*/ u16 near; // near clipping plane
|
||||
/*0x22*/ u16 far; // far clipping plane
|
||||
/*0x18*/ f32 fov; // horizontal field of view in degrees
|
||||
/*0x1C*/ u16 near; // near clipping plane
|
||||
/*0x1E*/ u16 far; // far clipping plane
|
||||
/*0x20*/ f32 halfFovHorizontal;
|
||||
#ifdef VERTICAL_CULLING
|
||||
/*0x24*/ f32 halfFovVertical;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** An entry in the master list. It is a linked list of display lists
|
||||
@@ -369,7 +372,7 @@ void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type);
|
||||
|
||||
struct GraphNodeRoot *init_graph_node_root (struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode, s16 areaIndex, s16 x, s16 y, s16 width, s16 height);
|
||||
struct GraphNodeOrthoProjection *init_graph_node_ortho_projection (struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode, f32 scale);
|
||||
struct GraphNodePerspective *init_graph_node_perspective (struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode, f32 fov, u16 near, u16 far, GraphNodeFunc nodeFunc, s32 unused);
|
||||
struct GraphNodePerspective *init_graph_node_perspective (struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode, f32 fov, u16 near, u16 far, GraphNodeFunc nodeFunc);
|
||||
struct GraphNodeStart *init_graph_node_start (struct AllocOnlyPool *pool, struct GraphNodeStart *graphNode);
|
||||
struct GraphNodeMasterList *init_graph_node_master_list (struct AllocOnlyPool *pool, struct GraphNodeMasterList *graphNode, s16 on);
|
||||
struct GraphNodeLevelOfDetail *init_graph_node_render_range (struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode, s16 minDistance, s16 maxDistance);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "game/puppycam2.h"
|
||||
#include "game/puppyprint.h"
|
||||
#include "game/puppylights.h"
|
||||
#include "game/emutest.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -309,7 +310,7 @@ static void level_cmd_load_mario_head(void) {
|
||||
}
|
||||
|
||||
static void level_cmd_load_yay0_texture(void) {
|
||||
load_segment_decompress_heap(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
|
||||
load_segment_decompress(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
|
||||
@@ -740,7 +741,7 @@ static void level_cmd_set_music(void) {
|
||||
if (sCurrAreaIndex != -1) {
|
||||
gAreas[sCurrAreaIndex].musicParam = CMD_GET(s16, 2);
|
||||
#ifdef BETTER_REVERB
|
||||
if (gIsConsole)
|
||||
if (gEmulator & EMU_CONSOLE)
|
||||
gAreas[sCurrAreaIndex].betterReverbPreset = CMD_GET(u8, 4);
|
||||
else
|
||||
gAreas[sCurrAreaIndex].betterReverbPreset = CMD_GET(u8, 5);
|
||||
@@ -753,10 +754,10 @@ static void level_cmd_set_music(void) {
|
||||
static void level_cmd_set_menu_music(void) {
|
||||
#ifdef BETTER_REVERB
|
||||
// Must come before set_background_music()
|
||||
if (gIsConsole)
|
||||
gBetterReverbPreset = CMD_GET(u8, 4);
|
||||
if (gEmulator & EMU_CONSOLE)
|
||||
gBetterReverbPresetValue = CMD_GET(u8, 4);
|
||||
else
|
||||
gBetterReverbPreset = CMD_GET(u8, 5);
|
||||
gBetterReverbPresetValue = CMD_GET(u8, 5);
|
||||
#endif
|
||||
set_background_music(0, CMD_GET(s16, 2), 0);
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
@@ -826,9 +827,7 @@ static void level_cmd_puppyvolume(void) {
|
||||
if ((sPuppyVolumeStack[gPuppyVolumeCount] = mem_pool_alloc(gPuppyMemoryPool, sizeof(struct sPuppyVolume))) == NULL) {
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
gPuppyError |= PUPPY_ERROR_POOL_FULL;
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
append_puppyprint_log("Puppycamera volume allocation failed.");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -876,9 +875,7 @@ static void level_cmd_puppylight_node(void) {
|
||||
#ifdef PUPPYLIGHTS
|
||||
gPuppyLights[gNumLights] = mem_pool_alloc(gLightsPool, sizeof(struct PuppyLight));
|
||||
if (gPuppyLights[gNumLights] == NULL) {
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
append_puppyprint_log("Puppylight allocation failed.");
|
||||
#endif
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
return;
|
||||
}
|
||||
@@ -908,6 +905,17 @@ static void level_cmd_puppylight_node(void) {
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
|
||||
static void level_cmd_set_echo(void) {
|
||||
if (sCurrAreaIndex >= 0 && sCurrAreaIndex < AREA_COUNT) {
|
||||
gAreaData[sCurrAreaIndex].useEchoOverride = TRUE;
|
||||
if (gEmulator & EMU_CONSOLE)
|
||||
gAreaData[sCurrAreaIndex].echoOverride = CMD_GET(s8, 2);
|
||||
else
|
||||
gAreaData[sCurrAreaIndex].echoOverride = CMD_GET(s8, 3);
|
||||
}
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
|
||||
static void (*LevelScriptJumpTable[])(void) = {
|
||||
/*LEVEL_CMD_LOAD_AND_EXECUTE */ level_cmd_load_and_execute,
|
||||
/*LEVEL_CMD_EXIT_AND_EXECUTE */ level_cmd_exit_and_execute,
|
||||
@@ -974,6 +982,7 @@ static void (*LevelScriptJumpTable[])(void) = {
|
||||
/*LEVEL_CMD_CHANGE_AREA_SKYBOX */ level_cmd_change_area_skybox,
|
||||
/*LEVEL_CMD_PUPPYLIGHT_ENVIRONMENT */ level_cmd_puppylight_environment,
|
||||
/*LEVEL_CMD_PUPPYLIGHT_NODE */ level_cmd_puppylight_node,
|
||||
/*LEVEL_CMD_SET_ECHO */ level_cmd_set_echo,
|
||||
};
|
||||
|
||||
struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
|
||||
|
||||
+3
-11
@@ -1277,7 +1277,6 @@ s32 anim_spline_poll(Vec3f result) {
|
||||
* RAYCASTING *
|
||||
**************************************************/
|
||||
|
||||
#define RAY_OFFSET 30.0f /* How many units to extrapolate surfaces when testing for a raycast */
|
||||
#define RAY_STEPS 4 /* How many steps to do when casting rays, default to quartersteps. */
|
||||
|
||||
/**
|
||||
@@ -1299,14 +1298,6 @@ s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface
|
||||
vec3s_to_vec3f(v0, surface->vertex1);
|
||||
vec3s_to_vec3f(v1, surface->vertex2);
|
||||
vec3s_to_vec3f(v2, surface->vertex3);
|
||||
// Get surface normal and extend it by RAY_OFFSET.
|
||||
Vec3f norm;
|
||||
surface_normal_to_vec3f(norm, surface);
|
||||
vec3_mul_val(norm, RAY_OFFSET);
|
||||
// Move the face forward by RAY_OFFSET.
|
||||
vec3f_add(v0, norm);
|
||||
vec3f_add(v1, norm);
|
||||
vec3f_add(v2, norm);
|
||||
// Make 'e1' (edge 1) the vector from vertex 0 to vertex 1.
|
||||
Vec3f e1;
|
||||
vec3f_diff(e1, v1, v0);
|
||||
@@ -1406,7 +1397,7 @@ void find_surface_on_ray_cell(s32 cellX, s32 cellZ, Vec3f orig, Vec3f normalized
|
||||
}
|
||||
}
|
||||
|
||||
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags) {
|
||||
f32 find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags) {
|
||||
Vec3f normalized_dir;
|
||||
f32 step;
|
||||
s32 i;
|
||||
@@ -1434,7 +1425,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
|
||||
// Don't do DDA if straight down
|
||||
if ((normalized_dir[1] >= NEAR_ONE) || (normalized_dir[1] <= -NEAR_ONE)) {
|
||||
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
|
||||
return;
|
||||
return max_length;
|
||||
}
|
||||
|
||||
// Get cells we cross using DDA
|
||||
@@ -1465,6 +1456,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
|
||||
find_surface_on_ray_cell(cellPrevX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
|
||||
}
|
||||
}
|
||||
return max_length;
|
||||
}
|
||||
|
||||
// Constructs a float in registers, which can be faster than gcc's default of loading a float from rodata.
|
||||
|
||||
+35
-19
@@ -451,27 +451,13 @@ extern f32 gSineTable[];
|
||||
|
||||
#define ABS(x) (((x) > 0) ? (x) : -(x))
|
||||
|
||||
/// From Wiseguy
|
||||
ALWAYS_INLINE s32 roundf(f32 in) {
|
||||
f32 tmp;
|
||||
s32 out;
|
||||
__asm__("round.w.s %0,%1" : "=f" (tmp) : "f" (in ));
|
||||
__asm__("mfc1 %0,%1" : "=r" (out) : "f" (tmp));
|
||||
return out;
|
||||
}
|
||||
extern s32 roundf(f32);
|
||||
// backwards compatibility
|
||||
#define round_float(in) roundf(in)
|
||||
|
||||
/// Absolute value
|
||||
ALWAYS_INLINE f32 absf(f32 in) {
|
||||
f32 out;
|
||||
__asm__("abs.s %0,%1" : "=f" (out) : "f" (in));
|
||||
return out;
|
||||
}
|
||||
ALWAYS_INLINE s32 absi(s32 in) {
|
||||
return ABS(in);
|
||||
}
|
||||
#define abss absi
|
||||
#define absf ABS
|
||||
#define absi ABS
|
||||
#define abss ABS
|
||||
|
||||
#define FLT_IS_NONZERO(x) (absf(x) > NEAR_ZERO)
|
||||
|
||||
@@ -606,6 +592,36 @@ f32 atan2f(f32 a, f32 b);
|
||||
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
|
||||
void anim_spline_init(Vec4s *keyFrames);
|
||||
s32 anim_spline_poll(Vec3f result);
|
||||
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
|
||||
f32 find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
|
||||
|
||||
ALWAYS_INLINE f32 remap(f32 x, f32 fromA, f32 toA, f32 fromB, f32 toB) {
|
||||
return (x - fromA) / (toA - fromA) * (toB - fromB) + fromB;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE f32 lerpf(f32 from, f32 to, f32 amount) {
|
||||
return (from + (to - from) * amount);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE f32 to_smoothstop(f32 x) {
|
||||
f32 sq = sqr(1.0f - x);
|
||||
return 1.0f - sq;
|
||||
}
|
||||
|
||||
// Commonly known as ease-in
|
||||
ALWAYS_INLINE f32 smoothstart(f32 from, f32 to, f32 amount) {
|
||||
return lerpf(from, to, sqr(amount));
|
||||
}
|
||||
|
||||
// Commonly known as ease-out
|
||||
ALWAYS_INLINE f32 smoothstop(f32 from, f32 to, f32 amount) {
|
||||
return lerpf(from, to, to_smoothstop(amount));
|
||||
}
|
||||
|
||||
// Commonly known as ease-in-out
|
||||
ALWAYS_INLINE f32 smoothstep(f32 from, f32 to, f32 amount) {
|
||||
amount = sqr(amount) * (3.0f - 2.0f * amount);
|
||||
|
||||
return lerpf(from, to, amount);
|
||||
}
|
||||
|
||||
#endif // MATH_UTIL_H
|
||||
+32
-17
@@ -14,6 +14,7 @@
|
||||
#include "game/object_list_processor.h"
|
||||
#include "surface_load.h"
|
||||
#include "game/puppyprint.h"
|
||||
#include "game/debug.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -119,6 +120,7 @@ static void clear_static_surfaces(void) {
|
||||
*/
|
||||
static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surface *surface) {
|
||||
struct SurfaceNode *list;
|
||||
s32 priority;
|
||||
s32 sortDir = 1; // highest to lowest, then insertion order (water and floors)
|
||||
s32 listIndex;
|
||||
|
||||
@@ -134,6 +136,7 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
|
||||
sortDir = 0; // insertion order
|
||||
}
|
||||
|
||||
s32 surfacePriority = surface->upperY * sortDir;
|
||||
|
||||
struct SurfaceNode *newNode = alloc_surface_node(dynamic);
|
||||
newNode->surface = surface;
|
||||
@@ -155,18 +158,14 @@ static void add_surface_to_cell(s32 dynamic, s32 cellX, s32 cellZ, struct Surfac
|
||||
}
|
||||
|
||||
// Loop until we find the appropriate place for the surface in the list.
|
||||
if (listIndex == SPATIAL_PARTITION_WATER) {
|
||||
s32 surfacePriority = surface->upperY * sortDir;
|
||||
s32 priority;
|
||||
while (list->next != NULL) {
|
||||
priority = list->next->surface->upperY * sortDir;
|
||||
while (list->next != NULL) {
|
||||
priority = list->next->surface->upperY * sortDir;
|
||||
|
||||
if (surfacePriority > priority) {
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
if (surfacePriority > priority) {
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
newNode->next = list->next;
|
||||
@@ -273,6 +272,7 @@ static struct Surface *read_surface_data(TerrainData *vertexData, TerrainData **
|
||||
|
||||
f32 mag = (sqr(n[0]) + sqr(n[1]) + sqr(n[2]));
|
||||
// This will never need to be run for custom levels because Fast64 does this step before exporting.
|
||||
// assert(mag >= NEAR_ZERO, "Denorm tri was found.");
|
||||
#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS
|
||||
if (mag < NEAR_ZERO) {
|
||||
return NULL;
|
||||
@@ -568,6 +568,8 @@ void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16
|
||||
void clear_dynamic_surfaces(void) {
|
||||
PUPPYPRINT_GET_SNAPSHOT();
|
||||
if (!(gTimeStopState & TIME_STOP_ACTIVE)) {
|
||||
clear_dynamic_surface_references();
|
||||
|
||||
gSurfacesAllocated = gNumStaticSurfaces;
|
||||
gSurfaceNodesAllocated = gNumStaticSurfaceNodes;
|
||||
gDynamicSurfacePoolEnd = gDynamicSurfacePool;
|
||||
@@ -697,13 +699,11 @@ static TerrainData sVertexData[600];
|
||||
void load_object_collision_model(void) {
|
||||
PUPPYPRINT_GET_SNAPSHOT();
|
||||
TerrainData *collisionData = o->collisionData;
|
||||
f32 marioDist = o->oDistanceToMario;
|
||||
|
||||
// On an object's first frame, the distance is set to 19000.0f.
|
||||
// If the distance hasn't been updated, update it now.
|
||||
if (o->oDistanceToMario == 19000.0f) {
|
||||
marioDist = dist_between_objects(o, gMarioObject);
|
||||
}
|
||||
f32 sqrLateralDist;
|
||||
vec3f_get_lateral_dist_squared(&o->oPosVec, &gMarioObject->oPosVec, &sqrLateralDist);
|
||||
|
||||
f32 verticalMarioDiff = gMarioObject->oPosY - o->oPosY;
|
||||
|
||||
#ifdef AUTO_COLLISION_DISTANCE
|
||||
if (!(o->oFlags & OBJ_FLAG_DONT_CALC_COLL_DIST)) {
|
||||
@@ -716,11 +716,17 @@ void load_object_collision_model(void) {
|
||||
if (o->oCollisionDistance > o->oDrawingDistance) {
|
||||
o->oDrawingDistance = o->oCollisionDistance;
|
||||
}
|
||||
|
||||
s32 inColRadius = (
|
||||
(sqrLateralDist < sqr(o->oCollisionDistance))
|
||||
&& (verticalMarioDiff > 0 || verticalMarioDiff > -o->oCollisionDistance)
|
||||
&& (verticalMarioDiff < 0 || verticalMarioDiff < o->oCollisionDistance + 2000.f)
|
||||
);
|
||||
|
||||
// Update if no Time Stop, in range, and in the current room.
|
||||
if (
|
||||
!(gTimeStopState & TIME_STOP_ACTIVE)
|
||||
&& (marioDist < o->oCollisionDistance)
|
||||
&& inColRadius
|
||||
&& !(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)
|
||||
) {
|
||||
collisionData++;
|
||||
@@ -731,6 +737,15 @@ void load_object_collision_model(void) {
|
||||
load_object_surfaces(&collisionData, sVertexData, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
f32 marioDist = o->oDistanceToMario;
|
||||
|
||||
// On an object's first frame, the distance is set to 19000.0f.
|
||||
// If the distance hasn't been updated, update it now.
|
||||
if (marioDist == 19000.0f) {
|
||||
marioDist = dist_between_objects(o, gMarioObject);
|
||||
}
|
||||
|
||||
COND_BIT((marioDist < o->oDrawingDistance), o->header.gfx.node.flags, GRAPH_RENDER_ACTIVE);
|
||||
profiler_collision_update(first);
|
||||
}
|
||||
|
||||
+39
-14
@@ -26,6 +26,9 @@
|
||||
#include "debug_box.h"
|
||||
#include "engine/colors.h"
|
||||
#include "profiling.h"
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
#include "s2d_engine/init.h"
|
||||
#endif
|
||||
|
||||
struct SpawnInfo gPlayerSpawnInfos[1];
|
||||
struct GraphNode *gGraphNodePointers[MODEL_ID_COUNT];
|
||||
@@ -205,6 +208,8 @@ void clear_areas(void) {
|
||||
gAreaData[i].dialog[1] = DIALOG_NONE;
|
||||
gAreaData[i].musicParam = 0;
|
||||
gAreaData[i].musicParam2 = 0;
|
||||
gAreaData[i].useEchoOverride = FALSE;
|
||||
gAreaData[i].echoOverride = 0;
|
||||
#ifdef BETTER_REVERB
|
||||
gAreaData[i].betterReverbPreset = 0;
|
||||
#endif
|
||||
@@ -344,22 +349,34 @@ void play_transition(s16 transType, s16 time, Color red, Color green, Color blue
|
||||
gWarpTransition.data.endTexX = SCREEN_CENTER_X;
|
||||
gWarpTransition.data.endTexY = SCREEN_CENTER_Y;
|
||||
|
||||
gWarpTransition.data.texTimer = 0;
|
||||
gWarpTransition.data.angleSpeed = DEGREES(0);
|
||||
|
||||
s16 fullRadius = GFX_DIMENSIONS_FULL_RADIUS;
|
||||
|
||||
// HackerSM64: this fixes the pop-in with texture transition, comment out this switch
|
||||
// statement if you want to restore the original full radius.
|
||||
switch (transType){
|
||||
case WARP_TRANSITION_TYPE_BOWSER:
|
||||
case WARP_TRANSITION_FADE_INTO_BOWSER:
|
||||
fullRadius *= 4;
|
||||
break;
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_MARIO:
|
||||
case WARP_TRANSITION_FADE_INTO_MARIO:
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_STAR:
|
||||
case WARP_TRANSITION_FADE_INTO_STAR:
|
||||
fullRadius *= 1.5f;
|
||||
break;
|
||||
}
|
||||
|
||||
if (transType & WARP_TRANSITION_FADE_INTO) { // Is the image fading in?
|
||||
gWarpTransition.data.startTexRadius = GFX_DIMENSIONS_FULL_RADIUS;
|
||||
if (transType >= WARP_TRANSITION_FADES_INTO_LARGE) {
|
||||
gWarpTransition.data.endTexRadius = 16;
|
||||
} else {
|
||||
gWarpTransition.data.endTexRadius = 0;
|
||||
}
|
||||
gWarpTransition.data.startTexRadius = fullRadius;
|
||||
gWarpTransition.data.endTexRadius = 0;
|
||||
|
||||
} else { // The image is fading out. (Reverses start & end circles)
|
||||
if (transType >= WARP_TRANSITION_FADES_FROM_LARGE) {
|
||||
gWarpTransition.data.startTexRadius = 16;
|
||||
} else {
|
||||
gWarpTransition.data.startTexRadius = 0;
|
||||
}
|
||||
gWarpTransition.data.endTexRadius = GFX_DIMENSIONS_FULL_RADIUS;
|
||||
gWarpTransition.data.startTexRadius = 0;
|
||||
gWarpTransition.data.endTexRadius = fullRadius;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -414,7 +431,7 @@ void render_game(void) {
|
||||
|
||||
if (gWarpTransition.isActive) {
|
||||
if (gWarpTransDelay == 0) {
|
||||
gWarpTransition.isActive = !render_screen_transition(0, gWarpTransition.type, gWarpTransition.time,
|
||||
gWarpTransition.isActive = !render_screen_transition(gWarpTransition.type, gWarpTransition.time,
|
||||
&gWarpTransition.data);
|
||||
if (!gWarpTransition.isActive) {
|
||||
if (gWarpTransition.type & WARP_TRANSITION_FADE_INTO) {
|
||||
@@ -427,6 +444,14 @@ void render_game(void) {
|
||||
gWarpTransDelay--;
|
||||
}
|
||||
}
|
||||
#ifdef S2DEX_TEXT_ENGINE
|
||||
s2d_init();
|
||||
|
||||
// place any custom text engine code here if not using deferred prints
|
||||
|
||||
s2d_handle_deferred();
|
||||
s2d_stop();
|
||||
#endif
|
||||
} else {
|
||||
render_text_labels();
|
||||
#ifdef PUPPYPRINT
|
||||
|
||||
+4
-2
@@ -73,8 +73,10 @@ struct Area {
|
||||
/*0x34*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30)
|
||||
/*0x36*/ u16 musicParam;
|
||||
/*0x38*/ u16 musicParam2;
|
||||
/*0x3A*/ u8 useEchoOverride; // Should area echo be overridden using echoOverride?
|
||||
/*0x3B*/ s8 echoOverride; // Value used to override the area echo values defined in level_defines.h
|
||||
#ifdef BETTER_REVERB
|
||||
/*0x3A*/ u8 betterReverbPreset;
|
||||
/*0x3C*/ u8 betterReverbPreset;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -91,7 +93,7 @@ struct WarpTransitionData {
|
||||
/*0x0C*/ s16 endTexX;
|
||||
/*0x0E*/ s16 endTexY;
|
||||
|
||||
/*0x10*/ s16 texTimer; // always 0, does seems to affect transition when disabled
|
||||
/*0x10*/ s16 angleSpeed;
|
||||
};
|
||||
|
||||
enum WarpTransitionFadeDirections {
|
||||
|
||||
@@ -380,6 +380,7 @@ void bhv_hidden_red_coin_star_init(void);
|
||||
void bhv_hidden_red_coin_star_loop(void);
|
||||
void bhv_red_coin_init(void);
|
||||
void bhv_red_coin_loop(void);
|
||||
void bhv_bowser_course_red_coin_star_init(void);
|
||||
void bhv_bowser_course_red_coin_star_loop(void);
|
||||
void bhv_hidden_star_init(void);
|
||||
void bhv_hidden_star_loop(void);
|
||||
|
||||
@@ -47,12 +47,24 @@ void bhv_hidden_star_trigger_loop(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void bhv_bowser_course_red_coin_star_init(void) {
|
||||
if (o->oBehParams2ndByte != 0) {
|
||||
o->oHiddenStarTriggerTotal = o->oBehParams2ndByte;
|
||||
o->oHiddenStarTriggerCounter = gRedCoinsCollected;
|
||||
}
|
||||
else {
|
||||
s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin);
|
||||
o->oHiddenStarTriggerTotal = numRedCoinsRemaining + gRedCoinsCollected;
|
||||
o->oHiddenStarTriggerCounter = o->oHiddenStarTriggerTotal - numRedCoinsRemaining;
|
||||
}
|
||||
}
|
||||
|
||||
void bhv_bowser_course_red_coin_star_loop(void) {
|
||||
gRedCoinsCollected = o->oHiddenStarTriggerCounter;
|
||||
|
||||
switch (o->oAction) {
|
||||
case 0:
|
||||
if (o->oHiddenStarTriggerCounter == 8) {
|
||||
if (o->oHiddenStarTriggerCounter == o->oHiddenStarTriggerTotal) {
|
||||
o->oAction = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -361,7 +361,7 @@ void bhv_klepto_update(void) {
|
||||
if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_CAP) {
|
||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
||||
spawn_object(o, MODEL_MARIOS_CAP, bhvNormalCap);
|
||||
} else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR) {
|
||||
} else if (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_STAR || o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR) {
|
||||
spawn_default_star(-5550.0f, 300.0f, -930.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
void bhv_orange_number_init(void) {
|
||||
o->oAnimState = o->oBehParams2ndByte;
|
||||
o->oVelY = 26.0f;
|
||||
o->oHomeY = o->oPosY;
|
||||
}
|
||||
|
||||
void bhv_orange_number_loop(void) {
|
||||
@@ -16,6 +17,13 @@ void bhv_orange_number_loop(void) {
|
||||
o->oVelY = 14.0f;
|
||||
}
|
||||
|
||||
s32 offsetX, offsetZ;
|
||||
offsetX = o->oOrangeNumberOffset * sins(gCamera->nextYaw + 0x4000);
|
||||
offsetZ = o->oOrangeNumberOffset * coss(gCamera->nextYaw + 0x4000);
|
||||
|
||||
o->oPosX = o->oHomeX + offsetX;
|
||||
o->oPosZ = o->oHomeZ + offsetZ;
|
||||
|
||||
if (o->oTimer == 35) {
|
||||
struct Object *sparkleObj = spawn_object(o, MODEL_SPARKLES, bhvCoinSparklesSpawner);
|
||||
sparkleObj->oPosY -= 30.0f;
|
||||
|
||||
@@ -50,18 +50,35 @@ void bhv_red_coin_loop(void) {
|
||||
o->parentObj->oHiddenStarTriggerCounter++;
|
||||
|
||||
// Spawn the orange number counter, as long as it isn't the last coin.
|
||||
if (o->parentObj->oHiddenStarTriggerCounter != 8) {
|
||||
spawn_orange_number(o->parentObj->oHiddenStarTriggerCounter, 0, 0, 0);
|
||||
if (o->parentObj->oHiddenStarTriggerCounter != o->parentObj->oHiddenStarTriggerTotal) {
|
||||
// Cap visible count to 99
|
||||
if (o->parentObj->oHiddenStarTriggerCounter > 99) {
|
||||
spawn_orange_number(9, 28, 0, 0);
|
||||
spawn_orange_number(9, -28, 0, 0);
|
||||
}
|
||||
else if (o->parentObj->oHiddenStarTriggerCounter >= 10) {
|
||||
spawn_orange_number(o->parentObj->oHiddenStarTriggerCounter % 10, 28, 0, 0);
|
||||
spawn_orange_number(o->parentObj->oHiddenStarTriggerCounter / 10, -28, 0, 0);
|
||||
}
|
||||
else {
|
||||
spawn_orange_number(o->parentObj->oHiddenStarTriggerCounter, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JP_RED_COIN_SOUND
|
||||
// For JP version, play an identical sound for all coins.
|
||||
create_sound_spawner(SOUND_GENERAL_RED_COIN);
|
||||
#else
|
||||
// On all versions but the JP version, each coin collected plays a higher noise.
|
||||
play_sound(SOUND_MENU_COLLECT_RED_COIN
|
||||
+ (((u8) o->parentObj->oHiddenStarTriggerCounter - 1) << 16),
|
||||
gGlobalSoundSource);
|
||||
if (o->parentObj->oHiddenStarTriggerTotal - o->parentObj->oHiddenStarTriggerCounter > 7) {
|
||||
// Play the first red coin sound until it gets to the final 8
|
||||
play_sound(SOUND_MENU_COLLECT_RED_COIN, gGlobalSoundSource);
|
||||
}
|
||||
else {
|
||||
// On all versions but the JP version, each coin collected plays a higher noise.
|
||||
play_sound(SOUND_MENU_COLLECT_RED_COIN
|
||||
+ (((u8) 7 - (o->parentObj->oHiddenStarTriggerTotal - o->parentObj->oHiddenStarTriggerCounter)) << 16),
|
||||
gGlobalSoundSource);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -157,14 +157,27 @@ void bhv_hidden_red_coin_star_init(void) {
|
||||
spawn_object(o, MODEL_TRANSPARENT_STAR, bhvRedCoinStarMarker);
|
||||
}
|
||||
|
||||
s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin);
|
||||
if (numRedCoinsRemaining == 0) {
|
||||
starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0);
|
||||
starObj->oBehParams = o->oBehParams;
|
||||
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
// check if bparam2 specifies a total number of coins that should spawn the star
|
||||
if (o->oBehParams2ndByte != 0) {
|
||||
o->oHiddenStarTriggerTotal = o->oBehParams2ndByte;
|
||||
o->oHiddenStarTriggerCounter = gRedCoinsCollected;
|
||||
if (o->oHiddenStarTriggerCounter >= o->oHiddenStarTriggerTotal) {
|
||||
starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0);
|
||||
starObj->oBehParams = o->oBehParams;
|
||||
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
}
|
||||
}
|
||||
|
||||
o->oHiddenStarTriggerCounter = 8 - numRedCoinsRemaining;
|
||||
else {
|
||||
s16 numRedCoinsRemaining = count_objects_with_behavior(bhvRedCoin);
|
||||
if (numRedCoinsRemaining == 0) {
|
||||
starObj = spawn_object_abs_with_rot(o, 0, MODEL_STAR, bhvStar, o->oPosX, o->oPosY, o->oPosZ, 0, 0, 0);
|
||||
starObj->oBehParams = o->oBehParams;
|
||||
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
}
|
||||
o->oHiddenStarTriggerTotal = numRedCoinsRemaining + gRedCoinsCollected;
|
||||
o->oHiddenStarTriggerCounter = o->oHiddenStarTriggerTotal - numRedCoinsRemaining;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bhv_hidden_red_coin_star_loop(void) {
|
||||
@@ -172,7 +185,7 @@ void bhv_hidden_red_coin_star_loop(void) {
|
||||
|
||||
switch (o->oAction) {
|
||||
case HIDDEN_STAR_ACT_INACTIVE:
|
||||
if (o->oHiddenStarTriggerCounter == 8) {
|
||||
if (o->oHiddenStarTriggerCounter == o->oHiddenStarTriggerTotal) {
|
||||
o->oAction = HIDDEN_STAR_ACT_ACTIVE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
#include "emutest.h"
|
||||
|
||||
#include <PR/os_internal_reg.h>
|
||||
#include <PR/os_internal_si.h>
|
||||
#include <PR/os_message.h>
|
||||
#include <PR/os_pi.h>
|
||||
#include <PR/R4300.h>
|
||||
#include <ultra64.h>
|
||||
#include <string.h>
|
||||
#include "emutest_vc.h"
|
||||
#include "types.h"
|
||||
|
||||
extern OSMesgQueue gSIEventMesgQueue;
|
||||
extern u8 __osContPifRam[];
|
||||
extern u8 __osContLastCmd;
|
||||
extern void __osSiGetAccess(void);
|
||||
extern void __osSiRelAccess(void);
|
||||
extern void __osPiGetAccess(void);
|
||||
extern void __osPiRelAccess(void);
|
||||
|
||||
enum Emulator gEmulator = EMU_CONSOLE;
|
||||
|
||||
u32 pj64_get_count_factor_asm(void); // defined in asm/pj64_get_count_factor_asm.s
|
||||
|
||||
static inline u32 check_count_factor() {
|
||||
const u32 saved = __osDisableInt();
|
||||
const u32 cf = pj64_get_count_factor_asm();
|
||||
__osRestoreInt(saved);
|
||||
return cf;
|
||||
}
|
||||
|
||||
static inline enum Emulator get_pj64_version() {
|
||||
// When calling this function, we know that the emulator is some version of Project 64,
|
||||
// and it isn't using the PJ64 4.0 interpreter core. Figure out which version it is.
|
||||
|
||||
// PJ64 4.0 dynarec core doesn't update the COUNT register correctly within recompiled functions
|
||||
if (check_count_factor() == 0) {
|
||||
return EMU_PROJECT64_4;
|
||||
}
|
||||
|
||||
// Instead of implementing this PIF command correctly, PJ64 versions prior to 3.0 just have
|
||||
// a set of hardcoded values for some requests. At least one of these hardcoded values has a
|
||||
// typo in it, making it give an incorrect result.
|
||||
__osSiGetAccess();
|
||||
u32 *pifRam32 = (u32*)__osContPifRam;
|
||||
for (s32 i = 0; i < 15; i++) pifRam32[i] = 0;
|
||||
pifRam32[15] = 2;
|
||||
|
||||
const u8 cicTest[] = {
|
||||
0x0F, 0x0F,
|
||||
0xEC, 0x3C, 0xB6, 0x76, 0xB8, 0x1D, 0xBB, 0x8F,
|
||||
0x6B, 0x3A, 0x80, 0xEC, 0xED, 0xEA, 0x5B
|
||||
};
|
||||
|
||||
memcpy(&__osContPifRam[46], cicTest, 17);
|
||||
|
||||
__osSiRawStartDma(OS_WRITE, __osContPifRam);
|
||||
osRecvMesg(&gSIEventMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
__osContLastCmd = 254;
|
||||
|
||||
__osSiRawStartDma(OS_READ, __osContPifRam);
|
||||
osRecvMesg(&gSIEventMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
const u8 pifCheck = __osContPifRam[54];
|
||||
__osSiRelAccess();
|
||||
|
||||
// check for the typo'd byte
|
||||
return (pifCheck == 0xB0) ? EMU_PROJECT64_1_OR_2 : EMU_PROJECT64_3;
|
||||
}
|
||||
|
||||
static u8 check_cache_emulation() {
|
||||
// Disable interrupts to ensure that nothing evicts the variable from cache while we're using it.
|
||||
u32 saved = __osDisableInt();
|
||||
// Create a variable with an initial value of 1. This value will remain cached.
|
||||
volatile u8 sCachedValue = 1;
|
||||
// Overwrite the variable directly in RDRAM without going through cache.
|
||||
// This should preserve its value of 1 in dcache if dcache is emulated correctly.
|
||||
*(u8*)(K0_TO_K1(&sCachedValue)) = 0;
|
||||
// Read the variable back from dcache, if it's still 1 then cache is emulated correctly.
|
||||
// If it's zero, then dcache is not emulated correctly.
|
||||
const u8 cacheEmulated = sCachedValue;
|
||||
// Restore interrupts
|
||||
__osRestoreInt(saved);
|
||||
return cacheEmulated;
|
||||
}
|
||||
|
||||
void detect_emulator() {
|
||||
if ((u32)IO_READ(DPC_PIPEBUSY_REG) | (u32)IO_READ(DPC_TMEM_REG) | (u32)IO_READ(DPC_BUFBUSY_REG)) {
|
||||
gEmulator = EMU_CONSOLE;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This check forces RTZ bug on vc
|
||||
* If console is N64/adequate Emu round-to-nearest (RTN) rounding mode is used
|
||||
* If console is VC round-to-zero (RTZ) mode is used
|
||||
*
|
||||
* The double value 0.9999999999999999 used is 0x3FEFFFFFFFFFFFFF in binary
|
||||
* Exponent=01111111110, Mantissa=1111111111111111111111111111111111111111111111111111
|
||||
* RTZ will output not 1.0f, RTN will output exactly 1.0f
|
||||
*/
|
||||
if (1.0f != round_double_to_float(0.9999999999999999)) {
|
||||
gEmulator = EMU_WIIVC;
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform a read from unmapped PIF ram.
|
||||
// On console and well behaved emulators, this echos back the lower half of
|
||||
// the requested memory address, repeating it if a whole word is requested.
|
||||
// So in this case, it should result in 0x01040104
|
||||
u32 magic;
|
||||
osPiReadIo(0x1fd00104u, &magic);
|
||||
if (magic == 0u) {
|
||||
// Older versions of mupen (and pre-2.12 ParallelN64) just always read 0
|
||||
gEmulator = EMU_MUPEN_OLD;
|
||||
return;
|
||||
} else if (magic != 0x01040104u) {
|
||||
// cen64 does... something. The result is consistent, but not what it should be
|
||||
gEmulator = EMU_CEN64;
|
||||
return;
|
||||
}
|
||||
|
||||
__osPiGetAccess();
|
||||
while (IO_READ(PI_STATUS_REG) & (PI_STATUS_DMA_BUSY|PI_STATUS_IO_BUSY));
|
||||
const u16 halfMagic = *((volatile u16*)0xbfd00106u);
|
||||
__osPiRelAccess();
|
||||
|
||||
// Now do a halfword read instead.
|
||||
switch (halfMagic) {
|
||||
// This is the correct result (echo back the lower half of the requested address)
|
||||
case 0x0106: {
|
||||
// Test to see if the libpl emulator extension is present.
|
||||
osPiWriteIo(0x1ffb0000u, 0u);
|
||||
osPiReadIo(0x1ffb0000u, &magic);
|
||||
if (magic == 0x00500000u) {
|
||||
// libpl is supported. Must be ParallelN64
|
||||
gEmulator = EMU_PARALLELN64;
|
||||
return;
|
||||
}
|
||||
|
||||
// If the cache is emulated, it's Ares
|
||||
if (check_cache_emulation()) {
|
||||
gEmulator = EMU_ARES;
|
||||
return;
|
||||
}
|
||||
|
||||
// its the Project64 4.0 interpreter core
|
||||
gEmulator = EMU_PROJECT64_4;
|
||||
return;
|
||||
}
|
||||
// This looks like it should be the expected result considering what we got when we
|
||||
// requested the whole word, but that's actually wrong. Later versions of mupen
|
||||
// (and the Simple64 fork of it) get this wrong.
|
||||
case 0x0104:
|
||||
gEmulator = check_cache_emulation() ? EMU_SIMPLE64 : EMU_MUPEN64PLUS_NEXT;
|
||||
return;
|
||||
// If reading a word gives the correct response, but reading a halfword always gives 0,
|
||||
// then we are dealing with some version of Project 64. Call into this helper function
|
||||
// to find out which version we're dealing with.
|
||||
case 0x0000:
|
||||
gEmulator = get_pj64_version();
|
||||
return;
|
||||
// No known emulator gives any other value. If we somehow manage to get here, just return 0
|
||||
default:
|
||||
gEmulator = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef EMUTEST_H
|
||||
#define EMUTEST_H
|
||||
|
||||
enum Emulator {
|
||||
EMU_WIIVC = 0x0001,
|
||||
EMU_PROJECT64_ANY = 0x001E,
|
||||
EMU_PROJECT64_1_OR_2 = 0x0006, // PJ64 1.6 or similar (up to 2.3)
|
||||
EMU_PROJECT64_3 = 0x0008, // PJ64 3.X
|
||||
EMU_PROJECT64_4 = 0x0010, // PJ64 4.0 or later
|
||||
EMU_MUPEN_BASED = 0x0060, // mupen64plus or pre-2.12 paralleln64, but NOT simple64 or new paralleln64
|
||||
EMU_MUPEN_OLD = 0x0020, // Nemu64 and pre-2.12 paralleln64 will also get detected as this
|
||||
EMU_MUPEN64PLUS_NEXT = 0x040,
|
||||
EMU_CEN64 = 0x0080,
|
||||
EMU_SIMPLE64 = 0x0100,
|
||||
EMU_PARALLELN64 = 0x0200, // ParallelN64 2.12 or later
|
||||
EMU_ARES = 0x0400,
|
||||
EMU_CONSOLE = 0x0800
|
||||
};
|
||||
|
||||
// initializes gEmulator
|
||||
extern void detect_emulator();
|
||||
|
||||
/* gEmulator is an enum that identifies the current emulator.
|
||||
* The enum values work as a bitfield, so you can use the & and | operators
|
||||
* to test for multiple emulators or versions at once.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* Test for any version of PJ64:
|
||||
* if (gEmulator & EMU_PROJECT64_ANY)
|
||||
*
|
||||
* Test for only PJ64 < 3.0:
|
||||
* if (gEmulator & EMU_PROJECT64_1_OR_2)
|
||||
*
|
||||
* Test for Console, Ares, or ParallelN64:
|
||||
* if (gEmulator & (EMU_CONSOLE | EMU_ARES | EMU_PARALLELN64))
|
||||
*/
|
||||
extern enum Emulator gEmulator;
|
||||
|
||||
// Included for backwards compatibility when upgrading from HackerSM64 2.0
|
||||
#define gIsConsole ((gEmulator & EMU_CONSOLE) != 0)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "emutest_vc.h"
|
||||
|
||||
f32 round_double_to_float(f64 v) {
|
||||
return v;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef EMUTEST_VC_H
|
||||
#define EMUTEST_VC_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
__attribute__((externally_visible))
|
||||
extern f32 round_double_to_float(f64 v);
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
__asm__(
|
||||
".section \".rodata\", \"a\", @progbits\n"
|
||||
".balign 16\n"
|
||||
".global fast_font\n"
|
||||
"fast_font:\n"
|
||||
".incbin \"src/game/newfont2_swapped.bin\"\n"
|
||||
|
||||
+13
-10
@@ -28,9 +28,12 @@
|
||||
#include "puppyprint.h"
|
||||
#include "puppycam2.h"
|
||||
#include "debug_box.h"
|
||||
#include "vc_check.h"
|
||||
#include "vc_ultra.h"
|
||||
#include "profiling.h"
|
||||
#include "emutest.h"
|
||||
|
||||
// Emulators that the Instant Input patch should not be applied to
|
||||
#define INSTANT_INPUT_BLACKLIST (EMU_CONSOLE | EMU_WIIVC | EMU_ARES | EMU_SIMPLE64 | EMU_CEN64)
|
||||
|
||||
// Gfx handlers
|
||||
struct SPTask *gGfxSPTask;
|
||||
@@ -43,8 +46,6 @@ struct Controller gControllers[MAXCONTROLLERS];
|
||||
OSContStatus gControllerStatuses[MAXCONTROLLERS];
|
||||
OSContPadEx gControllerPads[MAXCONTROLLERS];
|
||||
u8 gControllerBits = 0b0000;
|
||||
u8 gIsConsole = TRUE; // Needs to be initialized before audio_reset_session is called
|
||||
u8 gCacheEmulated = TRUE;
|
||||
u8 gBorderHeight;
|
||||
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
u8 gCustomDebugMode;
|
||||
@@ -402,8 +403,8 @@ void render_init(void) {
|
||||
|
||||
// Skip incrementing the initial framebuffer index on emulators so that they display immediately as the Gfx task finishes
|
||||
// VC probably emulates osViSwapBuffer accurately so instant patch breaks VC compatibility
|
||||
// Currently, Ares passes the cache emulation test and has issues with single buffering so disable it there as well.
|
||||
if (gIsConsole || gIsVC || gCacheEmulated) {
|
||||
// Currently, Ares and Simple64 have issues with single buffering so disable it there as well.
|
||||
if (gEmulator & INSTANT_INPUT_BLACKLIST) {
|
||||
sRenderingFramebuffer++;
|
||||
}
|
||||
gGlobalTimer++;
|
||||
@@ -442,7 +443,7 @@ void display_and_vsync(void) {
|
||||
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||
#endif
|
||||
// Skip swapping buffers on inaccurate emulators other than VC so that they display immediately as the Gfx task finishes
|
||||
if (gIsConsole || gIsVC || gCacheEmulated) {
|
||||
if (gEmulator & INSTANT_INPUT_BLACKLIST) {
|
||||
if (++sRenderedFramebuffer == 3) {
|
||||
sRenderedFramebuffer = 0;
|
||||
}
|
||||
@@ -646,7 +647,7 @@ void init_controllers(void) {
|
||||
#ifdef EEP
|
||||
// strangely enough, the EEPROM probe for save data is done in this function.
|
||||
// save pak detection?
|
||||
gEepromProbe = gIsVC
|
||||
gEepromProbe = (gEmulator & EMU_WIIVC)
|
||||
? osEepromProbeVC(&gSIEventMesgQueue)
|
||||
: osEepromProbe (&gSIEventMesgQueue);
|
||||
#endif
|
||||
@@ -680,9 +681,11 @@ void init_controllers(void) {
|
||||
#if (MAX_NUM_PLAYERS >= 2)
|
||||
//! Some flashcarts (eg. ED64p) don't let you start a ROM with a GameCube controller in port 1,
|
||||
// so if port 1 is an N64 controller and port 2 is a GC controller, swap them.
|
||||
if (gIsConsole) {
|
||||
if (__osControllerTypes[0] == CONT_TYPE_N64
|
||||
&& __osControllerTypes[1] == CONT_TYPE_GCN) {
|
||||
if (gEmulator & EMU_CONSOLE) {
|
||||
if (
|
||||
__osControllerTypes[0] == CONT_TYPE_N64 &&
|
||||
__osControllerTypes[1] == CONT_TYPE_GCN
|
||||
) {
|
||||
struct Controller temp = gControllers[0];
|
||||
gControllers[0] = gControllers[1];
|
||||
gControllers[1] = temp;
|
||||
|
||||
@@ -47,8 +47,6 @@ extern Gfx *gDisplayListHead;
|
||||
extern u8 *gGfxPoolEnd;
|
||||
extern struct GfxPool *gGfxPool;
|
||||
extern u8 gControllerBits;
|
||||
extern u8 gIsConsole;
|
||||
extern u8 gCacheEmulated;
|
||||
extern u8 gBorderHeight;
|
||||
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
extern u8 gCustomDebugMode;
|
||||
|
||||
@@ -36,31 +36,6 @@ static s16 sFlyingCarpetRippleTimer = 0;
|
||||
|
||||
s8 gFlyingCarpetState;
|
||||
|
||||
/**
|
||||
* Create a vertex with the given parameters and insert it into `vtx` at
|
||||
* position `n`.
|
||||
*
|
||||
* Texture coordinates are s10.5 fixed-point, which means you should left-shift the actual coordinates by 5.
|
||||
*/
|
||||
#ifndef GBI_FLOATS
|
||||
void make_vertex(Vtx *vtx, s32 n, s16 x, s16 y, s16 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a) {
|
||||
#else
|
||||
void make_vertex(Vtx *vtx, s32 n, f32 x, f32 y, f32 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a) {
|
||||
#endif
|
||||
vtx[n].v.ob[0] = x;
|
||||
vtx[n].v.ob[1] = y;
|
||||
vtx[n].v.ob[2] = z;
|
||||
|
||||
vtx[n].v.flag = 0;
|
||||
|
||||
vtx[n].v.tc[0] = tx;
|
||||
vtx[n].v.tc[1] = ty;
|
||||
|
||||
vtx[n].v.cn[0] = r;
|
||||
vtx[n].v.cn[1] = g;
|
||||
vtx[n].v.cn[2] = b;
|
||||
vtx[n].v.cn[3] = a;
|
||||
}
|
||||
|
||||
#define NUM_STARS_REQUIRED_FOR_WING_CAP_LIGHT 10
|
||||
/**
|
||||
|
||||
+44
-9
@@ -12,15 +12,50 @@ enum FlyingCarpetState {
|
||||
|
||||
extern s8 gFlyingCarpetState;
|
||||
|
||||
#ifndef GBI_FLOATS
|
||||
extern void make_vertex(
|
||||
Vtx *vtx, s32 n, s16 x, s16 y, s16 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a
|
||||
);
|
||||
#else
|
||||
extern void make_vertex(
|
||||
Vtx *vtx, s32 n, f32 x, f32 y, f32 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a
|
||||
);
|
||||
#endif
|
||||
/**
|
||||
* Create a vertex with the given parameters and insert it into `vtx` at
|
||||
* position `n`.
|
||||
*
|
||||
* Texture coordinates are s10.5 fixed-point, which means you should left-shift the actual coordinates by 5.
|
||||
*/
|
||||
ALWAYS_INLINE void make_vertex(Vtx *vtx, s32 n, s16 x, s16 y, s16 z, s16 tx, s16 ty, u8 r, u8 g, u8 b, u8 a) {
|
||||
vtx[n].v.ob[0] = x;
|
||||
vtx[n].v.ob[1] = y;
|
||||
vtx[n].v.ob[2] = z;
|
||||
|
||||
vtx[n].v.flag = 0;
|
||||
|
||||
vtx[n].v.tc[0] = tx;
|
||||
vtx[n].v.tc[1] = ty;
|
||||
|
||||
vtx[n].v.cn[0] = r;
|
||||
vtx[n].v.cn[1] = g;
|
||||
vtx[n].v.cn[2] = b;
|
||||
vtx[n].v.cn[3] = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a colourless vertex with the given parameters and insert it into `vtx` at
|
||||
* position `n`.
|
||||
*
|
||||
* Texture coordinates are s10.5 fixed-point, which means you should left-shift the actual coordinates by 5.
|
||||
*/
|
||||
ALWAYS_INLINE void make_simple_vertex(Vtx *vtx, s32 n, s16 x, s16 y, s16 z, s16 tx, s16 ty) {
|
||||
vtx[n].v.ob[0] = x;
|
||||
vtx[n].v.ob[1] = y;
|
||||
vtx[n].v.ob[2] = z;
|
||||
|
||||
vtx[n].v.flag = 0;
|
||||
|
||||
vtx[n].v.tc[0] = tx;
|
||||
vtx[n].v.tc[1] = ty;
|
||||
|
||||
vtx[n].v.cn[0] = 255;
|
||||
vtx[n].v.cn[1] = 255;
|
||||
vtx[n].v.cn[2] = 255;
|
||||
vtx[n].v.cn[3] = 255;
|
||||
}
|
||||
|
||||
extern Gfx *geo_exec_inside_castle_light(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx);
|
||||
extern Gfx *geo_exec_flying_carpet_timer_update(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx);
|
||||
extern Gfx *geo_exec_flying_carpet_create(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx);
|
||||
|
||||
+37
-15
@@ -1174,7 +1174,7 @@ void render_dialog_entries(void) {
|
||||
case DIALOG_STATE_VERTICAL:
|
||||
gDialogBoxOpenTimer = 0.0f;
|
||||
|
||||
if (gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON | START_BUTTON | D_CBUTTONS | R_CBUTTONS | D_JPAD | R_JPAD)) {
|
||||
if (gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON)) {
|
||||
if (gLastDialogPageStrPos == -1) {
|
||||
handle_special_dialog_text(gDialogID);
|
||||
gDialogBoxState = DIALOG_STATE_CLOSING;
|
||||
@@ -1468,20 +1468,14 @@ void change_dialog_camera_angle(void) {
|
||||
}
|
||||
|
||||
void shade_screen(void) {
|
||||
create_dl_translation_matrix(MENU_MTX_PUSH, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, 0);
|
||||
Gfx* dlHead = gDisplayListHead;
|
||||
|
||||
// This is a bit weird. It reuses the dialog text box (width 130, height -80),
|
||||
// so scale to at least fit the screen.
|
||||
#ifdef WIDESCREEN
|
||||
create_dl_scale_matrix(MENU_MTX_NOPUSH,
|
||||
GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT / 130.0f, 3.0f, 1.0f);
|
||||
#else
|
||||
create_dl_scale_matrix(MENU_MTX_NOPUSH, 2.6f, 3.4f, 1.0f);
|
||||
#endif
|
||||
gSPDisplayList(dlHead++, dl_shade_screen_begin);
|
||||
gDPFillRectangle(dlHead++, GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(0), gBorderHeight,
|
||||
(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(0) - 1), ((SCREEN_HEIGHT - gBorderHeight) - 1));
|
||||
gSPDisplayList(dlHead++, dl_shade_screen_end);
|
||||
|
||||
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 110);
|
||||
gSPDisplayList(gDisplayListHead++, dl_draw_text_bg_box);
|
||||
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
||||
gDisplayListHead = dlHead;
|
||||
}
|
||||
|
||||
void print_animated_red_coin(s16 x, s16 y) {
|
||||
@@ -1518,8 +1512,36 @@ void print_animated_red_coin(s16 x, s16 y) {
|
||||
void render_pause_red_coins(void) {
|
||||
s8 x;
|
||||
|
||||
for (x = 0; x < gRedCoinsCollected; x++) {
|
||||
print_animated_red_coin(GFX_DIMENSIONS_FROM_RIGHT_EDGE(30) - x * 20, 16);
|
||||
if (gRedCoinsCollected <= 9) {
|
||||
for (x = 0; x < gRedCoinsCollected; x++) {
|
||||
print_animated_red_coin(GFX_DIMENSIONS_FROM_RIGHT_EDGE(30) - x * 20, 16);
|
||||
}
|
||||
}
|
||||
else {
|
||||
print_animated_red_coin(GFX_DIMENSIONS_FROM_RIGHT_EDGE(108), 16);
|
||||
Mtx *mtx;
|
||||
|
||||
mtx = alloc_display_list(sizeof(*mtx));
|
||||
if (mtx == NULL) {
|
||||
return;
|
||||
}
|
||||
guOrtho(mtx, 0.0f, SCREEN_WIDTH, 0.0f, SCREEN_HEIGHT, -10.0f, 10.0f, 1.0f);
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
|
||||
|
||||
s8 redCoinCount = gRedCoinsCollected;
|
||||
if (redCoinCount > 99) {
|
||||
redCoinCount = 99;
|
||||
}
|
||||
|
||||
add_glyph_texture(GLYPH_MULTIPLY);
|
||||
render_textrect(GFX_DIMENSIONS_FROM_RIGHT_EDGE(100), 16, 0);
|
||||
add_glyph_texture(char_to_glyph_index((char) (48 + (redCoinCount / 10))));
|
||||
render_textrect(GFX_DIMENSIONS_FROM_RIGHT_EDGE(86), 16, 0);
|
||||
add_glyph_texture(char_to_glyph_index((char) (48 + (redCoinCount % 10))));
|
||||
render_textrect(GFX_DIMENSIONS_FROM_RIGHT_EDGE(86), 16, 1);
|
||||
|
||||
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -418,6 +418,8 @@ u32 mario_check_object_grab(struct MarioState *m) {
|
||||
if (facingDYaw >= -0x5555 && facingDYaw <= 0x5555) {
|
||||
m->faceAngle[1] = m->interactObj->oMoveAngleYaw;
|
||||
m->usedObj = m->interactObj;
|
||||
m->pos[1] = m->floorHeight;
|
||||
m->vel[1] = 0.0f;
|
||||
result = set_mario_action(m, ACT_PICKING_UP_BOWSER, 0);
|
||||
}
|
||||
} else {
|
||||
@@ -1707,11 +1709,14 @@ u32 check_read_sign(struct MarioState *m, struct Object *obj) {
|
||||
&& abs_angle_diff(mario_obj_angle_to_object(m, obj), m->faceAngle[1]) <= SIGN_RANGE
|
||||
) {
|
||||
#ifdef DIALOG_INDICATOR
|
||||
struct Object *orangeNumber;
|
||||
if (obj->behavior == segmented_to_virtual(bhvSignOnWall)) {
|
||||
spawn_object_relative(ORANGE_NUMBER_A, 0, 180, 32, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
orangeNumber = spawn_object_relative(ORANGE_NUMBER_A, 0, 180, 32, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
} else {
|
||||
spawn_object_relative(ORANGE_NUMBER_A, 0, 160, 8, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
orangeNumber = spawn_object_relative(ORANGE_NUMBER_A, 0, 160, 8, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
}
|
||||
orangeNumber->oHomeX = orangeNumber->oPosX;
|
||||
orangeNumber->oHomeZ = orangeNumber->oPosZ;
|
||||
#endif
|
||||
if (m->input & READ_MASK) {
|
||||
#else
|
||||
@@ -1742,11 +1747,14 @@ u32 check_npc_talk(struct MarioState *m, struct Object *obj) {
|
||||
&& abs_angle_diff(mario_obj_angle_to_object(m, obj), m->faceAngle[1]) <= SIGN_RANGE
|
||||
) {
|
||||
#ifdef DIALOG_INDICATOR
|
||||
struct Object *orangeNumber;
|
||||
if (obj->behavior == segmented_to_virtual(bhvYoshi)) {
|
||||
spawn_object_relative(ORANGE_NUMBER_A, 0, 256, 64, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
orangeNumber = spawn_object_relative(ORANGE_NUMBER_A, 0, 256, 64, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
} else {
|
||||
spawn_object_relative(ORANGE_NUMBER_A, 0, 160, 0, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
orangeNumber = spawn_object_relative(ORANGE_NUMBER_A, 0, 160, 0, obj, MODEL_NUMBER, bhvOrangeNumber);
|
||||
}
|
||||
orangeNumber->oHomeX = orangeNumber->oPosX;
|
||||
orangeNumber->oHomeZ = orangeNumber->oPosZ;
|
||||
#endif
|
||||
if (m->input & READ_MASK) {
|
||||
#else
|
||||
|
||||
+34
-15
@@ -178,6 +178,16 @@ u32 pressed_pause(void) {
|
||||
u32 dialogActive = get_dialog_id() >= 0;
|
||||
u32 intangible = (gMarioState->action & ACT_FLAG_INTANGIBLE) != 0;
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#ifdef BETTER_REVERB
|
||||
if (sPPDebugPage == PUPPYPRINT_PAGE_RAM || sPPDebugPage == PUPPYPRINT_PAGE_LEVEL_SELECT || sPPDebugPage == PUPPYPRINT_PAGE_BETTER_REVERB) {
|
||||
#else
|
||||
if (sPPDebugPage == PUPPYPRINT_PAGE_RAM || sPPDebugPage == PUPPYPRINT_PAGE_LEVEL_SELECT) {
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!intangible && !dialogActive && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE
|
||||
&& (gPlayer1Controller->buttonPressed & START_BUTTON)) {
|
||||
return TRUE;
|
||||
@@ -397,7 +407,7 @@ void init_mario_after_warp(void) {
|
||||
|
||||
if (gCurrDemoInput == NULL) {
|
||||
#ifdef BETTER_REVERB
|
||||
gBetterReverbPreset = gCurrentArea->betterReverbPreset;
|
||||
gBetterReverbPresetValue = gCurrentArea->betterReverbPreset;
|
||||
#endif
|
||||
set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0);
|
||||
|
||||
@@ -428,9 +438,7 @@ void init_mario_after_warp(void) {
|
||||
}
|
||||
#endif
|
||||
#ifndef DISABLE_EXIT_COURSE
|
||||
if (sWarpDest.levelNum == EXIT_COURSE_LEVEL && sWarpDest.areaIdx == EXIT_COURSE_AREA
|
||||
&& sWarpDest.nodeId == EXIT_COURSE_NODE
|
||||
) {
|
||||
if (sWarpDest.arg == WARP_FLAG_EXIT_COURSE) {
|
||||
play_sound(SOUND_MENU_MARIO_CASTLE_WARP, gGlobalSoundSource);
|
||||
}
|
||||
#endif
|
||||
@@ -511,7 +519,7 @@ void warp_credits(void) {
|
||||
|
||||
if (gCurrCreditsEntry == NULL || gCurrCreditsEntry == sCreditsSequence) {
|
||||
#ifdef BETTER_REVERB
|
||||
gBetterReverbPreset = gCurrentArea->betterReverbPreset;
|
||||
gBetterReverbPresetValue = gCurrentArea->betterReverbPreset;
|
||||
#endif
|
||||
set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0);
|
||||
}
|
||||
@@ -608,6 +616,8 @@ s16 music_unchanged_through_warp(s16 arg) {
|
||||
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 warpFlags) {
|
||||
if (destWarpNode >= WARP_NODE_CREDITS_MIN) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
} else if (warpFlags == WARP_FLAG_EXIT_COURSE) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
} else if (destLevel != gCurrLevelNum) {
|
||||
sWarpDest.type = WARP_TYPE_CHANGE_LEVEL;
|
||||
} else if (destArea != gCurrentArea->index) {
|
||||
@@ -1008,7 +1018,11 @@ s32 play_mode_normal(void) {
|
||||
check_instant_warp();
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#ifdef BETTER_REVERB
|
||||
if (sPPDebugPage != PUPPYPRINT_PAGE_RAM && sPPDebugPage != PUPPYPRINT_PAGE_LEVEL_SELECT && sPPDebugPage != PUPPYPRINT_PAGE_BETTER_REVERB) {
|
||||
#else
|
||||
if (sPPDebugPage != PUPPYPRINT_PAGE_RAM && sPPDebugPage != PUPPYPRINT_PAGE_LEVEL_SELECT) {
|
||||
#endif
|
||||
if (sTimerRunning && gHudDisplay.timer < 17999) {
|
||||
gHudDisplay.timer++;
|
||||
}
|
||||
@@ -1026,7 +1040,11 @@ s32 play_mode_normal(void) {
|
||||
#endif
|
||||
if (gCurrentArea != NULL) {
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
if (sPPDebugPage != PUPPYPRINT_PAGE_RAM && sPPDebugPage != PUPPYPRINT_PAGE_LEVEL_SELECT) {
|
||||
#ifdef BETTER_REVERB
|
||||
if (sPPDebugPage != PUPPYPRINT_PAGE_RAM && sPPDebugPage != PUPPYPRINT_PAGE_LEVEL_SELECT && sPPDebugPage != PUPPYPRINT_PAGE_BETTER_REVERB) {
|
||||
#else
|
||||
if (sPPDebugPage != PUPPYPRINT_PAGE_RAM && sPPDebugPage != PUPPYPRINT_PAGE_LEVEL_SELECT) {
|
||||
#endif
|
||||
update_camera(gCurrentArea->camera);
|
||||
}
|
||||
#else
|
||||
@@ -1069,9 +1087,16 @@ s32 play_mode_paused(void) {
|
||||
if (gDebugLevelSelect) {
|
||||
fade_into_special_warp(WARP_SPECIAL_LEVEL_SELECT, 1);
|
||||
} else {
|
||||
initiate_warp(EXIT_COURSE_LEVEL, EXIT_COURSE_AREA, EXIT_COURSE_NODE, WARP_FLAGS_NONE);
|
||||
#ifdef DEATH_ON_EXIT_COURSE
|
||||
raise_background_noise(1);
|
||||
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
||||
set_play_mode(PLAY_MODE_NORMAL);
|
||||
level_trigger_warp(gMarioState, WARP_OP_DEATH);
|
||||
#else
|
||||
initiate_warp(EXIT_COURSE_LEVEL, EXIT_COURSE_AREA, EXIT_COURSE_NODE, WARP_FLAG_EXIT_COURSE);
|
||||
fade_into_special_warp(WARP_SPECIAL_NONE, 0);
|
||||
gSavedCourseNum = COURSE_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
||||
@@ -1268,7 +1293,7 @@ s32 init_level(void) {
|
||||
|
||||
if (gCurrDemoInput == NULL) {
|
||||
#ifdef BETTER_REVERB
|
||||
gBetterReverbPreset = gCurrentArea->betterReverbPreset;
|
||||
gBetterReverbPresetValue = gCurrentArea->betterReverbPreset;
|
||||
#endif
|
||||
set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0);
|
||||
}
|
||||
@@ -1287,13 +1312,7 @@ s32 init_level(void) {
|
||||
puppylights_allocate();
|
||||
#endif
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#ifdef PUPPYPRINT_DEBUG_CYCLES
|
||||
append_puppyprint_log("Level loaded in %dc", (s32)(osGetTime() - first));
|
||||
#else
|
||||
append_puppyprint_log("Level loaded in %dus", (s32)(OS_CYCLES_TO_USEC(osGetTime() - first)));
|
||||
#endif
|
||||
#endif
|
||||
append_puppyprint_log("Level loaded in %d" PP_CYCLE_STRING ".", (s32)(PP_CYCLE_CONV(osGetTime() - first)));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,12 @@ enum SpecialWarpDestinations {
|
||||
WARP_SPECIAL_NONE = 0,
|
||||
};
|
||||
|
||||
enum WarpDoorFlags {
|
||||
enum WarpFlags {
|
||||
WARP_FLAGS_NONE = (0 << 0), // 0x00
|
||||
WARP_FLAG_DOOR_PULLED = (1 << 0), // 0x01
|
||||
WARP_FLAG_DOOR_FLIP_MARIO = (1 << 1), // 0x02
|
||||
WARP_FLAG_DOOR_IS_WARP = (1 << 2), // 0x04
|
||||
WARP_FLAG_EXIT_COURSE = (1 << 3), // 0x08
|
||||
};
|
||||
|
||||
enum MarioSpawnType {
|
||||
|
||||
@@ -242,8 +242,10 @@ void stop_and_set_height_to_floor(struct MarioState *m) {
|
||||
mario_set_forward_vel(m, 0.0f);
|
||||
m->vel[1] = 0.0f;
|
||||
|
||||
//! This is responsible for some downwarps.
|
||||
m->pos[1] = m->floorHeight;
|
||||
// HackerSM64 2.1: This check fixes the ledgegrab downwarp after being pushed off a ledge.
|
||||
if (m->pos[1] <= m->floorHeight + 160.0f) {
|
||||
m->pos[1] = m->floorHeight;
|
||||
}
|
||||
|
||||
vec3f_copy(marioObj->header.gfx.pos, m->pos);
|
||||
vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
||||
@@ -259,9 +261,10 @@ s32 stationary_ground_step(struct MarioState *m) {
|
||||
if (takeStep) {
|
||||
stepResult = perform_ground_step(m);
|
||||
} else {
|
||||
//! TODO - This is responsible for many stationary downwarps but is
|
||||
// important for stuff like catching Bowser in midair, figure out a good way to fix
|
||||
m->pos[1] = m->floorHeight;
|
||||
// HackerSM64 2.1: This check prevents the downwarps that plagued stationary actions.
|
||||
if (m->pos[1] <= m->floorHeight + 160.0f) {
|
||||
m->pos[1] = m->floorHeight;
|
||||
}
|
||||
|
||||
vec3f_copy(marioObj->header.gfx.pos, m->pos);
|
||||
vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
||||
|
||||
@@ -60,13 +60,11 @@ u32 main_pool_pop_state(void);
|
||||
void *load_segment(s32 segment, u8 *srcStart, u8 *srcEnd, u32 side, u8 *bssStart, u8 *bssEnd);
|
||||
void *load_to_fixed_pool_addr(u8 *destAddr, u8 *srcStart, u8 *srcEnd);
|
||||
void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd);
|
||||
void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd);
|
||||
void load_engine_code_segment(void);
|
||||
#else
|
||||
#define load_segment(...)
|
||||
#define load_to_fixed_pool_addr(...)
|
||||
#define load_segment_decompress(...)
|
||||
#define load_segment_decompress_heap(...)
|
||||
#define load_engine_code_segment(...)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -691,6 +691,9 @@ void spawn_orange_number(s8 behParam, s16 relX, s16 relY, s16 relZ) {
|
||||
|
||||
struct Object *orangeNumber = spawn_object_relative(behParam, relX, relY, relZ, o, MODEL_NUMBER, bhvOrangeNumber);
|
||||
orangeNumber->oPosY += 25.0f;
|
||||
orangeNumber->oOrangeNumberOffset = relX;
|
||||
orangeNumber->oHomeX = o->oPosX;
|
||||
orangeNumber->oHomeZ = o->oPosZ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -616,6 +616,22 @@ UNUSED static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all floors tied to dynamic collision, as they become invalid once the dynamic
|
||||
* surfaces are cleared.
|
||||
*
|
||||
* NOTE: Checking over the full object pool is slower than checking against the linked lists of active
|
||||
* objects until the active object pool is around half capacity, after which, this is faster.
|
||||
* Change this function to use a linked list instead if you add any additional logic here whatsoever.
|
||||
*/
|
||||
void clear_dynamic_surface_references(void) {
|
||||
for (s32 i = 0; i < OBJECT_POOL_CAPACITY; i++) {
|
||||
if (gObjectPool[i].oFloor && gObjectPool[i].oFloor->flags & SURFACE_FLAG_DYNAMIC) {
|
||||
gObjectPool[i].oFloor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all objects. This includes script execution, object collision detection,
|
||||
* and object surface management.
|
||||
|
||||
@@ -141,6 +141,7 @@ void set_object_respawn_info_bits(struct Object *obj, u8 bits);
|
||||
void unload_objects_from_area(UNUSED s32 unused, s32 areaIndex);
|
||||
void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo);
|
||||
void clear_objects(void);
|
||||
void clear_dynamic_surface_references(void);
|
||||
void update_objects(UNUSED s32 unused);
|
||||
|
||||
|
||||
|
||||
@@ -34,5 +34,8 @@ void print_text_fmt_int(s32 x, s32 y, const char *str, s32 n);
|
||||
void print_text(s32 x, s32 y, const char *str);
|
||||
void print_text_centered(s32 x, s32 y, const char *str);
|
||||
void render_text_labels(void);
|
||||
s32 char_to_glyph_index(char c);
|
||||
void add_glyph_texture(s8 glyphIndex);
|
||||
void render_textrect(s32 x, s32 y, s32 pos);
|
||||
|
||||
#endif // PRINT_H
|
||||
@@ -259,7 +259,7 @@ void profiler_print_times() {
|
||||
|
||||
// audio time is removed from the main thread profiling, so add it back here
|
||||
u32 total_cpu = microseconds[PROFILER_TIME_TOTAL] + microseconds[PROFILER_TIME_AUDIO] * 2;
|
||||
u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO];
|
||||
u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO] * 2;
|
||||
u32 max_rdp = MAX(MAX(microseconds[PROFILER_TIME_TMEM], microseconds[PROFILER_TIME_CMD]), microseconds[PROFILER_TIME_PIPE]);
|
||||
|
||||
sprintf(text_buffer,
|
||||
@@ -309,7 +309,7 @@ void profiler_print_times() {
|
||||
microseconds[PROFILER_TIME_PIPE],
|
||||
total_rsp, total_rsp / 333,
|
||||
microseconds[PROFILER_TIME_RSP_GFX],
|
||||
microseconds[PROFILER_TIME_RSP_AUDIO]
|
||||
microseconds[PROFILER_TIME_RSP_AUDIO] * 2
|
||||
);
|
||||
|
||||
Gfx* dlHead = gDisplayListHead;
|
||||
|
||||
+295
-158
@@ -1,4 +1,4 @@
|
||||
///Puppycam 2.2 by Fazana
|
||||
///Puppycam 2.3 by Fazana
|
||||
|
||||
#include <PR/ultratypes.h>
|
||||
#include <PR/gbi.h>
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "puppyprint.h"
|
||||
#include "debug_box.h"
|
||||
#include "main.h"
|
||||
#include "../../enhancements/puppycam_angles.inc.c"
|
||||
|
||||
#ifdef PUPPYCAM
|
||||
|
||||
@@ -54,27 +55,32 @@ struct MemoryPool *gPuppyMemoryPool;
|
||||
s32 gPuppyError = 0;
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
static unsigned char gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_CAMY_FR}, {NC_INVERTX_FR}, {NC_INVERTY_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR}, {OPTION_LANGUAGE_FR}};
|
||||
static unsigned char gPCOptionStringsDE[][64] = {{NC_ANALOGUE_DE}, {NC_CAMX_DE}, {NC_CAMY_DE}, {NC_INVERTX_DE}, {NC_INVERTY_DE}, {NC_CAMC_DE}, {NC_SCHEME_DE}, {NC_WIDE_DE}, {OPTION_LANGUAGE_DE}};
|
||||
static unsigned char gPCOptionStringsFR[][64] = {{NC_ANALOGUE_FR}, {NC_CAMX_FR}, {NC_INVERTX_FR}, {NC_CAMC_FR}, {NC_SCHEME_FR}, {NC_WIDE_FR}, {OPTION_LANGUAGE_FR}};
|
||||
static unsigned char gPCOptionStringsDE[][64] = {{NC_ANALOGUE_DE}, {NC_CAMX_DE}, {NC_INVERTX_DE}, {NC_CAMC_DE}, {NC_SCHEME_DE}, {NC_WIDE_DE}, {OPTION_LANGUAGE_DE}};
|
||||
static unsigned char gPCFlagStringsFR[][64] = {{OPTION_DISABLED_FR}, {OPTION_ENABLED_FR}, {OPTION_SCHEME1_FR}, {OPTION_SCHEME2_FR}, {OPTION_SCHEME3_FR}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
|
||||
static unsigned char gPCFlagStringsDE[][64] = {{OPTION_DISABLED_DE}, {OPTION_ENABLED_DE}, {OPTION_SCHEME1_DE}, {OPTION_SCHEME2_DE}, {OPTION_SCHEME3_DE}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
|
||||
static unsigned char gPCToggleStringsFR[][64] = {{NC_BUTTON_FR}, {NC_BUTTON2_FR}, {NC_OPTION_FR}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
|
||||
static unsigned char gPCToggleStringsDE[][64] = {{NC_BUTTON_DE}, {NC_BUTTON2_DE}, {NC_OPTION_DE}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
|
||||
#endif
|
||||
static unsigned char gPCOptionStringsEN[][64] = {{NC_ANALOGUE_EN}, {NC_CAMX_EN}, {NC_CAMY_EN}, {NC_INVERTX_EN}, {NC_INVERTY_EN}, {NC_CAMC_EN}, {NC_SCHEME_EN}, {NC_WIDE_EN}, {OPTION_LANGUAGE_EN}};
|
||||
static unsigned char gPCOptionStringsEN[][64] = {{NC_ANALOGUE_EN}, {NC_CAMX_EN}, {NC_INVERTX_EN}, {NC_CAMC_EN}, {NC_SCHEME_EN}, {NC_WIDE_EN}, {OPTION_LANGUAGE_EN}};
|
||||
static unsigned char gPCFlagStringsEN[][64] = {{OPTION_DISABLED_EN}, {OPTION_ENABLED_EN}, {OPTION_SCHEME1_EN}, {OPTION_SCHEME2_EN}, {OPTION_SCHEME3_EN}, {TEXT_ENGLISH}, {TEXT_FRENCH}, {TEXT_GERMAN},};
|
||||
static unsigned char gPCToggleStringsEN[][64] = {{NC_BUTTON_EN}, {NC_BUTTON2_EN}, {NC_OPTION_EN}, {NC_HIGHLIGHT_L}, {NC_HIGHLIGHT_R},};
|
||||
|
||||
static unsigned char (*gPCOptionStringsPtr)[][64] = (unsigned char (*)[][64])&gPCOptionStringsEN;
|
||||
static unsigned char (*gPCFlagStringsPtr )[][64] = (unsigned char (*)[][64])&gPCFlagStringsEN;
|
||||
static unsigned char (*gPCToggleStringsPtr)[][64] = (unsigned char (*)[][64])&gPCToggleStringsEN;
|
||||
|
||||
#define OPT 32 //Just a temp thing
|
||||
enum PuppyCamOptionNames {
|
||||
OPTION_STRING_ANALOGUE,
|
||||
OPTION_STRING_SENSITIVITY,
|
||||
OPTION_STRING_INVERT,
|
||||
OPTION_STRING_AUTOROTATE,
|
||||
OPTION_STRING_INPUTTYPE,
|
||||
OPTION_STRING_WIDESCREEN,
|
||||
OPTION_STRING_LANGUAGE
|
||||
};
|
||||
|
||||
static unsigned char (*gPCOptionStringsPtr)[OPT][64] = (unsigned char (*)[OPT][64])&gPCOptionStringsEN;
|
||||
static unsigned char (*gPCFlagStringsPtr )[OPT][64] = (unsigned char (*)[OPT][64])&gPCFlagStringsEN;
|
||||
static unsigned char (*gPCToggleStringsPtr)[OPT][64] = (unsigned char (*)[OPT][64])&gPCToggleStringsEN;
|
||||
|
||||
|
||||
struct gPCOptionStruct
|
||||
{
|
||||
struct gPCOptionStruct {
|
||||
u8 gPCOptionName; //This is the position in the newcam_options text array. It doesn't have to directly correlate with its position in the struct
|
||||
s16 *gPCOptionVar; //This is the value that the option is going to directly affect.
|
||||
u8 gPCOptionStart; //This is where the text array will start. Set it to 255 to have it be ignored.
|
||||
@@ -84,18 +90,16 @@ struct gPCOptionStruct
|
||||
|
||||
static const struct gPCOptionStruct gPCOptions[] = { //If the min and max are 0 and 1, then the value text is used, otherwise it's ignored.
|
||||
#ifdef WIDE
|
||||
{/*Option Name*/ 7, /*Option Variable*/ &gConfig.widescreen, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ OPTION_STRING_WIDESCREEN, /*Option Variable*/ &gConfig.widescreen, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
#endif
|
||||
#if MULTILANG
|
||||
{/*Option Name*/ 8, /*Option Variable*/ &gInGameLanguage, /*Option Value Text Start*/ 4, /*Option Minimum*/ 1, /*Option Maximum*/ 3},
|
||||
{/*Option Name*/ OPTION_STRING_LANGUAGE, /*Option Variable*/ &gInGameLanguage, /*Option Value Text Start*/ 4, /*Option Minimum*/ 1, /*Option Maximum*/ 3},
|
||||
#endif
|
||||
{/*Option Name*/ 0, /*Option Variable*/ &gPuppyCam.options.analogue, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ 6, /*Option Variable*/ &gPuppyCam.options.inputType, /*Option Value Text Start*/ 2, /*Option Minimum*/ 0, /*Option Maximum*/ 2},
|
||||
{/*Option Name*/ 1, /*Option Variable*/ &gPuppyCam.options.sensitivityX, /*Option Value Text Start*/ 255, /*Option Minimum*/ 10, /*Option Maximum*/ 500},
|
||||
{/*Option Name*/ 2, /*Option Variable*/ &gPuppyCam.options.sensitivityY, /*Option Value Text Start*/ 255, /*Option Minimum*/ 10, /*Option Maximum*/ 500},
|
||||
{/*Option Name*/ 3, /*Option Variable*/ &gPuppyCam.options.invertX, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ 4, /*Option Variable*/ &gPuppyCam.options.invertY, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ 5, /*Option Variable*/ &gPuppyCam.options.turnAggression, /*Option Value Text Start*/ 255, /*Option Minimum*/ 0, /*Option Maximum*/ 100},
|
||||
{/*Option Name*/ OPTION_STRING_ANALOGUE, /*Option Variable*/ &gPuppyCam.options.analogue, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ OPTION_STRING_INPUTTYPE, /*Option Variable*/ &gPuppyCam.options.inputType, /*Option Value Text Start*/ 2, /*Option Minimum*/ 0, /*Option Maximum*/ 2},
|
||||
{/*Option Name*/ OPTION_STRING_SENSITIVITY, /*Option Variable*/ &gPuppyCam.options.sensitivityX, /*Option Value Text Start*/ 255, /*Option Minimum*/ 1, /*Option Maximum*/ 10},
|
||||
{/*Option Name*/ OPTION_STRING_INVERT, /*Option Variable*/ &gPuppyCam.options.invertX, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
{/*Option Name*/ OPTION_STRING_AUTOROTATE, /*Option Variable*/ &gPuppyCam.options.turnHelper, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
};
|
||||
|
||||
u8 gPCOptionCap = sizeof(gPCOptions) / sizeof(struct gPCOptionStruct); //How many options there are in newcam_uptions.
|
||||
@@ -128,13 +132,11 @@ static void puppycam_analogue_stick(void) {
|
||||
}
|
||||
|
||||
void puppycam_default_config(void) {
|
||||
gPuppyCam.options.invertX = 1;
|
||||
gPuppyCam.options.invertY = 1;
|
||||
gPuppyCam.options.sensitivityX = 100;
|
||||
gPuppyCam.options.sensitivityY = 100;
|
||||
gPuppyCam.options.turnAggression = 50;
|
||||
gPuppyCam.options.analogue = 0;
|
||||
gPuppyCam.options.inputType = 1;
|
||||
gPuppyCam.options.invertX = FALSE;
|
||||
gPuppyCam.options.sensitivityX = 5;
|
||||
gPuppyCam.options.analogue = FALSE;
|
||||
gPuppyCam.options.inputType = INPUT_SINGLE_PRESS;
|
||||
gPuppyCam.options.turnHelper = TRUE;
|
||||
}
|
||||
|
||||
// Initial setup. Ran at the beginning of the game and never again.
|
||||
@@ -149,7 +151,7 @@ void puppycam_boot(void) {
|
||||
gPuppyCam.stickN[1] = 0;
|
||||
gPuppyMemoryPool = mem_pool_init(MAX_PUPPYCAM_VOLUMES * sizeof(struct sPuppyVolume), MEMORY_POOL_LEFT);
|
||||
gPuppyVolumeCount = 0;
|
||||
gPuppyCam.enabled = 1;
|
||||
gPuppyCam.enabled = TRUE;
|
||||
|
||||
puppycam_get_save();
|
||||
}
|
||||
@@ -199,7 +201,7 @@ void puppycam_activate_cutscene(s32 (*scene)(), s32 lockinput) {
|
||||
// If you've read camera.c this will look familiar.
|
||||
// It takes the next 4 spline points and extrapolates a curvature based positioning of the camera vector that's passed through.
|
||||
// It's a standard B spline
|
||||
static void puppycam_evaluate_spline(f32 progress, Vec3s cameraPos, Vec3f spline1, Vec3f spline2, Vec3f spline3, Vec3f spline4) {
|
||||
static void puppycam_evaluate_spline(f32 progress, Vec3f cameraPos, Vec3f spline1, Vec3f spline2, Vec3f spline3, Vec3f spline4) {
|
||||
f32 tempP[4];
|
||||
|
||||
if (progress > 1.0f) {
|
||||
@@ -478,6 +480,80 @@ void puppycam_reset_values(void) {
|
||||
gPuppyCam.splineProgress = 0;
|
||||
}
|
||||
|
||||
static void create_puppycam1_nodes(void) {
|
||||
u32 i, flagsAdd, flagsRemove;
|
||||
Vec3s pos, diff;
|
||||
struct sPuppyAngles *tempAngle;
|
||||
u32 numNodes = sizeof(newcam_fixedcam) / sizeof(struct newcam_hardpos);
|
||||
if (numNodes == 0) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < numNodes; i++) {
|
||||
if (newcam_fixedcam[i].newcam_hard_levelID != gCurrLevelNum || newcam_fixedcam[i].newcam_hard_areaID != gCurrAreaIndex)
|
||||
continue;
|
||||
if ((sPuppyVolumeStack[gPuppyVolumeCount] = mem_pool_alloc(gPuppyMemoryPool, sizeof(struct sPuppyVolume))) == NULL) {
|
||||
gPuppyError |= PUPPY_ERROR_POOL_FULL;
|
||||
append_puppyprint_log("Puppycamera volume allocation failed.");
|
||||
return;
|
||||
}
|
||||
if ((tempAngle = mem_pool_alloc(gPuppyMemoryPool, sizeof(struct sPuppyVolume))) == NULL)
|
||||
return;
|
||||
pos[0] = (newcam_fixedcam[i].newcam_hard_X1 + newcam_fixedcam[i].newcam_hard_X2) / 2;
|
||||
pos[1] = (newcam_fixedcam[i].newcam_hard_Y1 + newcam_fixedcam[i].newcam_hard_Y2) / 2;
|
||||
pos[2] = (newcam_fixedcam[i].newcam_hard_Z1 + newcam_fixedcam[i].newcam_hard_Z2) / 2;
|
||||
diff[0] = ABS(newcam_fixedcam[i].newcam_hard_X1 - newcam_fixedcam[i].newcam_hard_X2);
|
||||
diff[1] = ABS(newcam_fixedcam[i].newcam_hard_Y1 - newcam_fixedcam[i].newcam_hard_Y2);
|
||||
diff[2] = ABS(newcam_fixedcam[i].newcam_hard_Z1 - newcam_fixedcam[i].newcam_hard_Z2);
|
||||
vec3s_copy(sPuppyVolumeStack[gPuppyVolumeCount]->pos, pos);
|
||||
vec3s_copy(sPuppyVolumeStack[gPuppyVolumeCount]->radius, diff);
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->rot = 0; // Doesn't support rotation.
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->func = newcam_fixedcam[i].newcam_hard_script;
|
||||
tempAngle->yaw = PUPPY_NULL;
|
||||
tempAngle->pitch = PUPPY_NULL;
|
||||
tempAngle->zoom = PUPPY_NULL;
|
||||
tempAngle->pos[0] = newcam_fixedcam[i].newcam_hard_camX;
|
||||
tempAngle->pos[1] = newcam_fixedcam[i].newcam_hard_camY;
|
||||
tempAngle->pos[2] = newcam_fixedcam[i].newcam_hard_camZ;
|
||||
tempAngle->focus[0] = newcam_fixedcam[i].newcam_hard_lookX;
|
||||
tempAngle->focus[1] = newcam_fixedcam[i].newcam_hard_lookY;
|
||||
tempAngle->focus[2] = newcam_fixedcam[i].newcam_hard_lookZ;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->angles = tempAngle;
|
||||
switch (newcam_fixedcam[i].newcam_hard_modeset) {
|
||||
case NC_MODE_FIXED:
|
||||
flagsAdd = 0;
|
||||
flagsRemove = PUPPYCAM_BEHAVIOUR_TURN_HELPER | PUPPYCAM_BEHAVIOUR_INPUT_NORMAL | PUPPYCAM_BEHAVIOUR_INPUT_4DIR |
|
||||
PUPPYCAM_BEHAVIOUR_INPUT_8DIR | PUPPYCAM_BEHAVIOUR_INPUT_2D;
|
||||
break;
|
||||
case NC_MODE_FIXED_NOTURN:
|
||||
flagsAdd = 0;
|
||||
flagsRemove = PUPPYCAM_BEHAVIOUR_PITCH_ROTATION | PUPPYCAM_BEHAVIOUR_YAW_ROTATION |
|
||||
PUPPYCAM_BEHAVIOUR_TURN_HELPER | PUPPYCAM_BEHAVIOUR_INPUT_NORMAL | PUPPYCAM_BEHAVIOUR_INPUT_4DIR |
|
||||
PUPPYCAM_BEHAVIOUR_INPUT_8DIR | PUPPYCAM_BEHAVIOUR_INPUT_2D;
|
||||
break;
|
||||
case NC_MODE_NOROTATE:
|
||||
flagsAdd = 0;
|
||||
flagsRemove = PUPPYCAM_BEHAVIOUR_PITCH_ROTATION | PUPPYCAM_BEHAVIOUR_YAW_ROTATION;
|
||||
break;
|
||||
case NC_MODE_FIXED_NOMOVE:
|
||||
flagsAdd = 0;
|
||||
flagsRemove = PUPPYCAM_BEHAVIOUR_X_MOVEMENT | PUPPYCAM_BEHAVIOUR_Y_MOVEMENT | PUPPYCAM_BEHAVIOUR_Z_MOVEMENT;
|
||||
break;
|
||||
default:
|
||||
flagsAdd = 0;
|
||||
flagsRemove = 0;
|
||||
break;
|
||||
}
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->flagsAdd = flagsAdd;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->flagsRemove = flagsRemove;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->flagPersistance = newcam_fixedcam[i].newcam_hard_permaswap;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->shape = PUPPYVOLUME_SHAPE_BOX;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->room = -1;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->fov = 45;
|
||||
sPuppyVolumeStack[gPuppyVolumeCount]->area = newcam_fixedcam[i].newcam_hard_areaID;
|
||||
gPuppyVolumeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set up values. Runs on level load.
|
||||
void puppycam_init(void) {
|
||||
if (gMarioState->marioObj) {
|
||||
@@ -493,7 +569,6 @@ void puppycam_init(void) {
|
||||
#endif
|
||||
gPuppyCam.flags = gPuppyCam.intendedFlags;
|
||||
gPuppyCam.zoom = gPuppyCam.zoomPoints[1];
|
||||
gPuppyCam.zoomSet = 1;
|
||||
gPuppyCam.zoomTarget = gPuppyCam.zoom;
|
||||
gPuppyCam.yaw = gMarioState->faceAngle[1] + 0x8000;
|
||||
gPuppyCam.yawTarget = gPuppyCam.yaw;
|
||||
@@ -514,15 +589,16 @@ void puppycam_init(void) {
|
||||
gPuppyCam.mode3Flags = PUPPYCAM_MODE3_ZOOMED_MED;
|
||||
gPuppyCam.debugFlags = PUPPYDEBUG_LOCK_CONTROLS;
|
||||
puppycam_reset_values();
|
||||
create_puppycam1_nodes();
|
||||
}
|
||||
|
||||
void puppycam_input_pitch(void) {
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PITCH_ROTATION) {
|
||||
// Handles vertical inputs.
|
||||
if (gPlayer1Controller->buttonDown & U_CBUTTONS || gPuppyCam.stick2[1] != 0) {
|
||||
gPuppyCam.pitchAcceleration -= 50 * (gPuppyCam.options.sensitivityY / 100.f);
|
||||
gPuppyCam.pitchAcceleration += 50;
|
||||
} else if (gPlayer1Controller->buttonDown & D_CBUTTONS || gPuppyCam.stick2[1] != 0) {
|
||||
gPuppyCam.pitchAcceleration += 50 * (gPuppyCam.options.sensitivityY / 100.f);
|
||||
gPuppyCam.pitchAcceleration -= 50;
|
||||
} else {
|
||||
gPuppyCam.pitchAcceleration = 0;
|
||||
}
|
||||
@@ -530,34 +606,23 @@ void puppycam_input_pitch(void) {
|
||||
|
||||
// When Mario's moving, his pitch is clamped pretty aggressively, so this exists so you can shift your view up and down momentarily at an actually usable range, rather than the otherwise baby range.
|
||||
if (gMarioState->action & ACT_FLAG_MOVING && (gPuppyCam.pitch >= 0x3800 || gPuppyCam.pitch <= 0x2000)) {
|
||||
gPuppyCam.moveFlagAdd = 8;
|
||||
gPuppyCam.movementPitchVel = 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void puppycam_input_zoom(void) {
|
||||
// Handles R button zooming.
|
||||
if (gPlayer1Controller->buttonPressed & R_TRIG && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE) {
|
||||
gPuppyCam.zoomSet++;
|
||||
|
||||
if (gPuppyCam.zoomSet >= 3) {
|
||||
gPuppyCam.zoomSet = 0;
|
||||
}
|
||||
gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[gPuppyCam.zoomSet];
|
||||
play_sound(SOUND_MENU_CLICK_CHANGE_VIEW,gGlobalSoundSource);
|
||||
}
|
||||
}
|
||||
|
||||
void puppycam_input_centre(void) {
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) {
|
||||
return;
|
||||
}
|
||||
s32 inputDefault = L_TRIG;
|
||||
if (gPuppyCam.options.inputType == 2) {
|
||||
inputDefault = R_TRIG;
|
||||
s32 inputDefault;
|
||||
if (gPuppyCam.options.inputType != INPUT_CLASSIC) {
|
||||
inputDefault = gPlayer1Controller->buttonPressed & L_TRIG || gPlayer1Controller->buttonPressed & R_TRIG;
|
||||
} else {
|
||||
inputDefault = gPlayer1Controller->buttonPressed & R_TRIG;
|
||||
}
|
||||
// Handles L button centering.
|
||||
if (gPlayer1Controller->buttonPressed & inputDefault && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION &&
|
||||
if (inputDefault && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION &&
|
||||
!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && !(gPlayer1Controller->buttonDown & U_JPAD)) {
|
||||
gPuppyCam.yawTarget = gMarioState->faceAngle[1] + 0x8000;
|
||||
play_sound(SOUND_MENU_CLICK_CHANGE_VIEW,gGlobalSoundSource);
|
||||
@@ -567,18 +632,18 @@ void puppycam_input_centre(void) {
|
||||
// The default control scheme. Hold the button down to turn the camera, and double tap to turn quickly.
|
||||
static void puppycam_input_hold_preset1(f32 ivX) {
|
||||
if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & L_CBUTTONS && gPuppyCam.framesSinceC[0] <= 5) {
|
||||
gPuppyCam.yawTarget -= 0x4000 * ivX;
|
||||
gPuppyCam.yawTarget += 0x4000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
} else if (!gPuppyCam.options.analogue && gPlayer1Controller->buttonPressed & R_CBUTTONS && gPuppyCam.framesSinceC[1] <= 5) {
|
||||
gPuppyCam.yawTarget += 0x4000 * ivX;
|
||||
gPuppyCam.yawTarget -= 0x4000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
}
|
||||
|
||||
if ((gPlayer1Controller->buttonDown & L_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) {
|
||||
gPuppyCam.yawAcceleration -= 75 * (gPuppyCam.options.sensitivityX / 100.f);
|
||||
gPuppyCam.yawAcceleration += 75 * (gPuppyCam.options.sensitivityX / 5.0f);
|
||||
gPuppyCam.framesSinceC[0] = 0;
|
||||
} else if ((gPlayer1Controller->buttonDown & R_CBUTTONS && !gPuppyCam.options.analogue) || gPuppyCam.stick2[0] != 0) {
|
||||
gPuppyCam.yawAcceleration += 75*(gPuppyCam.options.sensitivityX / 100.f);
|
||||
gPuppyCam.yawAcceleration -= 75*(gPuppyCam.options.sensitivityX / 5.0f);
|
||||
gPuppyCam.framesSinceC[1] = 0;
|
||||
} else {
|
||||
gPuppyCam.yawAcceleration = 0;
|
||||
@@ -592,29 +657,29 @@ static void puppycam_input_hold_preset2(f32 ivX) {
|
||||
if (gPlayer1Controller->buttonPressed & R_CBUTTONS) gPuppyCam.framesSinceC[1] = 0;
|
||||
// These handle when you release the button
|
||||
if ((!(gPlayer1Controller->buttonDown & L_CBUTTONS)) && gPuppyCam.framesSinceC[0] <= 5) {
|
||||
gPuppyCam.yawTarget -= 0x3000 * ivX;
|
||||
gPuppyCam.yawTarget += 0x3000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
gPuppyCam.framesSinceC[0] = 6;
|
||||
}
|
||||
|
||||
if ((!(gPlayer1Controller->buttonDown & R_CBUTTONS)) && gPuppyCam.framesSinceC[1] <= 5) {
|
||||
gPuppyCam.yawTarget += 0x3000 * ivX;
|
||||
gPuppyCam.yawTarget -= 0x3000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
gPuppyCam.framesSinceC[1] = 6;
|
||||
}
|
||||
|
||||
// Handles continuous movement as normal, as long as the button's held.
|
||||
if (gPlayer1Controller->buttonDown & L_CBUTTONS) {
|
||||
gPuppyCam.yawAcceleration -= 75 * (gPuppyCam.options.sensitivityX / 100.f);
|
||||
gPuppyCam.yawAcceleration += 75 * (gPuppyCam.options.sensitivityX / 5.0f);
|
||||
} else if (gPlayer1Controller->buttonDown & R_CBUTTONS) {
|
||||
gPuppyCam.yawAcceleration += 75 * (gPuppyCam.options.sensitivityX / 100.f);
|
||||
gPuppyCam.yawAcceleration -= 75 * (gPuppyCam.options.sensitivityX / 5.0f);
|
||||
} else {
|
||||
gPuppyCam.yawAcceleration = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Another alternative control scheme. This one aims to mimic the parallel camera scheme down to the last bit from the original game.
|
||||
static void puppycam_input_hold_preset3(void) {
|
||||
static void puppycam_input_hold_preset3(f32 ivX) {
|
||||
f32 stickMag[2] = {gPlayer1Controller->rawStickX*0.65f, gPlayer1Controller->rawStickY*0.2f};
|
||||
// Just in case it happens to be nonzero.
|
||||
gPuppyCam.yawAcceleration = 0;
|
||||
@@ -628,31 +693,35 @@ static void puppycam_input_hold_preset3(void) {
|
||||
|
||||
// Handles continuous movement as normal, as long as the button's held.
|
||||
if (ABS(gPlayer1Controller->rawStickX) > DEADZONE) {
|
||||
gPuppyCam.yawAcceleration -= (gPuppyCam.options.sensitivityX / 100.f) * stickMag[0];
|
||||
gPuppyCam.yawAcceleration = gPlayer1Controller->rawStickX;
|
||||
} else {
|
||||
gPuppyCam.yawAcceleration = 0;
|
||||
}
|
||||
if (ABS(gPlayer1Controller->rawStickY) > DEADZONE) {
|
||||
gPuppyCam.pitchAcceleration -= (gPuppyCam.options.sensitivityY / 100.f) * stickMag[1];
|
||||
gPuppyCam.pitchAcceleration = gPlayer1Controller->rawStickY * 2.0f;
|
||||
} else {
|
||||
gPuppyCam.pitchAcceleration = approach_f32_asymptotic(gPuppyCam.pitchAcceleration, 0, DECELERATION);
|
||||
gPuppyCam.pitchAcceleration = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ((gPlayer1Controller->buttonPressed & L_TRIG) && (gPuppyCam.yawTarget % 0x2000)) {
|
||||
gPuppyCam.yawTarget += 0x2000 - gPuppyCam.yawTarget % 0x2000;
|
||||
}
|
||||
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3800, 0x200, 0x200);
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3000, 0x200, 0x200);
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_OUT) {
|
||||
gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3300, 0x200, 0x200);
|
||||
} else {
|
||||
gPuppyCam.pitchTarget = approach_s32(gPuppyCam.pitchTarget, 0x3800, 0x200, 0x200);
|
||||
}
|
||||
|
||||
if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] > DEADZONE && !gPuppyCam.stickN[0])) {
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
gPuppyCam.yawTarget -= 0x2000;
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
gPuppyCam.yawTarget += 0x2000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_TURN,gGlobalSoundSource);
|
||||
}
|
||||
if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[0] < -DEADZONE && !gPuppyCam.stickN[0])) {
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
gPuppyCam.yawTarget += 0x2000;
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
gPuppyCam.yawTarget -= 0x2000 * ivX;
|
||||
play_sound(SOUND_MENU_CAMERA_TURN,gGlobalSoundSource);
|
||||
}
|
||||
}
|
||||
@@ -663,7 +732,8 @@ static void puppycam_input_hold_preset3(void) {
|
||||
gPuppyCam.stickN[1] = 1;
|
||||
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_IN;
|
||||
gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_MED;
|
||||
gPuppyCam.zoomTarget = 200;
|
||||
gPuppyCam.pitchTarget = 0x4000;
|
||||
gPuppyCam.zoomTarget = 80;
|
||||
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ENTER_FIRST_PERSON;
|
||||
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
@@ -675,7 +745,7 @@ static void puppycam_input_hold_preset3(void) {
|
||||
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
|
||||
}
|
||||
} else if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1])) { // Otherwise handle zooming out.
|
||||
} else if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1])) { // Otherwise handle zooming out.
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_MED) {
|
||||
gPuppyCam.stickN[1] = 1;
|
||||
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_OUT;
|
||||
@@ -685,14 +755,16 @@ static void puppycam_input_hold_preset3(void) {
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource);
|
||||
}
|
||||
}
|
||||
if ((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1]) ||
|
||||
gPlayer1Controller->buttonPressed & B_BUTTON || gPlayer1Controller->buttonPressed & A_BUTTON) {
|
||||
if (((gPlayer1Controller->buttonPressed & D_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stick2[1] < -DEADZONE && !gPuppyCam.stickN[1]) ||
|
||||
gPlayer1Controller->buttonPressed & B_BUTTON || gPlayer1Controller->buttonPressed & A_BUTTON) && gPlayer1Controller->stickMag < DEADZONE) {
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) {
|
||||
gPuppyCam.stickN[1] = 1;
|
||||
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_MED;
|
||||
gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_IN;
|
||||
gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1];
|
||||
gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ENTER_FIRST_PERSON;
|
||||
gPuppyCam.pitch = 0x4000;
|
||||
gPuppyCam.pitchTarget = 0x4000;
|
||||
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource);
|
||||
}
|
||||
@@ -701,15 +773,14 @@ static void puppycam_input_hold_preset3(void) {
|
||||
|
||||
// Handles C Button inputs for modes that have held inputs, rather than presses.
|
||||
static void puppycam_input_hold(void) {
|
||||
f32 ivX = ((gPuppyCam.options.invertX * 2) - 1) * (gPuppyCam.options.sensitivityX / 100.f);
|
||||
f32 ivY = ((gPuppyCam.options.invertY * 2) - 1) * (gPuppyCam.options.sensitivityY / 100.f);
|
||||
f32 ivX = ((gPuppyCam.options.invertX * 2) - 1);
|
||||
s8 stickMag[2] = {100, 100};
|
||||
|
||||
if (gPuppyCam.intendedFlags & PUPPYCAM_BEHAVIOUR_FREE) {
|
||||
gPuppyCam.flags = PUPPYCAM_BEHAVIOUR_FREE | PUPPYCAM_BEHAVIOUR_YAW_ROTATION | PUPPYCAM_BEHAVIOUR_PITCH_ROTATION;
|
||||
}
|
||||
// Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged.
|
||||
if (gPuppyCam.options.analogue && gPuppyCam.options.inputType != 2) {
|
||||
if (gPuppyCam.options.analogue && gPuppyCam.options.inputType != INPUT_CLASSIC) {
|
||||
stickMag[0] = gPuppyCam.stick2[0] * 1.25f;
|
||||
stickMag[1] = gPuppyCam.stick2[1] * 1.25f;
|
||||
}
|
||||
@@ -718,32 +789,36 @@ static void puppycam_input_hold(void) {
|
||||
if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_YAW_ROTATION)) {
|
||||
return;
|
||||
}
|
||||
if ((!gPuppyCam.options.analogue || gPuppyCam.options.inputType == 2) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE)) {
|
||||
if ((!gPuppyCam.options.analogue || gPuppyCam.options.inputType == INPUT_CLASSIC) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE)) {
|
||||
switch (gPuppyCam.options.inputType) {
|
||||
default: puppycam_input_hold_preset1(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break;
|
||||
case 1: puppycam_input_hold_preset2(ivX); puppycam_input_pitch(); puppycam_input_zoom(); puppycam_input_centre(); break;
|
||||
case 2: puppycam_input_hold_preset3(); puppycam_input_centre(); break;
|
||||
default: puppycam_input_hold_preset1(ivX); puppycam_input_pitch(); puppycam_input_centre(); break;
|
||||
case INPUT_SINGLE_PRESS: puppycam_input_hold_preset2(ivX); puppycam_input_pitch(); puppycam_input_centre(); break;
|
||||
case INPUT_CLASSIC: puppycam_input_hold_preset3(ivX); puppycam_input_centre(); break;
|
||||
}
|
||||
} else {
|
||||
puppycam_input_hold_preset1(ivX);
|
||||
puppycam_input_pitch();
|
||||
puppycam_input_zoom();
|
||||
puppycam_input_centre();
|
||||
}
|
||||
|
||||
if (gPuppyCam.options.inputType != INPUT_CLASSIC) {
|
||||
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_MED;
|
||||
gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ZOOMED_IN;
|
||||
gPuppyCam.zoomTarget = gPuppyCam.zoomPoints[1];
|
||||
gPuppyCam.mode3Flags &= ~PUPPYCAM_MODE3_ENTER_FIRST_PERSON;
|
||||
}
|
||||
|
||||
gPuppyCam.framesSinceC[0]++;
|
||||
gPuppyCam.framesSinceC[1]++;
|
||||
|
||||
gPuppyCam.yawAcceleration = CLAMP(gPuppyCam.yawAcceleration, -100, 100);
|
||||
|
||||
gPuppyCam.yawTarget += (12 * gPuppyCam.yawAcceleration * ivX) * (stickMag[0] * 0.01f);
|
||||
gPuppyCam.pitchTarget += ((4 + gPuppyCam.moveFlagAdd) * gPuppyCam.pitchAcceleration * ivY) * (stickMag[1] * 0.01f);
|
||||
gPuppyCam.yawTarget += (12 * gPuppyCam.yawAcceleration * (ivX * (gPuppyCam.options.sensitivityX / 5.0f))) * (stickMag[0] * 0.01f);
|
||||
gPuppyCam.pitchTarget += ((3 + gPuppyCam.movementPitchVel) * gPuppyCam.pitchAcceleration) * (stickMag[1] * 0.01f);
|
||||
}
|
||||
|
||||
// Handles C Button inputs for modes that have pressed inputs, rather than held.
|
||||
static void puppycam_input_press(void) {
|
||||
f32 ivX = ((gPuppyCam.options.invertX * 2) - 1) * (gPuppyCam.options.sensitivityX / 100.f);
|
||||
f32 ivY = ((gPuppyCam.options.invertY * 2) - 1) * (gPuppyCam.options.sensitivityY / 100.f);
|
||||
s8 stickMag = 0;
|
||||
|
||||
// Analogue Camera stuff. If it fails to find an input, then it just sets stickmag to 100, which after calculations means the value goes unchanged.
|
||||
@@ -762,9 +837,9 @@ static void puppycam_input_press(void) {
|
||||
if ((gPlayer1Controller->buttonPressed & L_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] < -DEADZONE)) {
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) {
|
||||
gPuppyCam.yawTarget -= 0x2000 * ivX;
|
||||
gPuppyCam.yawTarget -= 0x2000;
|
||||
} else {
|
||||
gPuppyCam.yawTarget -= 0x4000 * ivX;
|
||||
gPuppyCam.yawTarget -= 0x4000;
|
||||
}
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN,gGlobalSoundSource);
|
||||
}
|
||||
@@ -772,16 +847,15 @@ static void puppycam_input_press(void) {
|
||||
if ((gPlayer1Controller->buttonPressed & R_CBUTTONS && !gPuppyCam.options.analogue) || (gPuppyCam.stickN[0] == 0 && gPuppyCam.stick2[0] > DEADZONE)) {
|
||||
gPuppyCam.stickN[0] = 1;
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) {
|
||||
gPuppyCam.yawTarget += 0x2000 * ivX;
|
||||
gPuppyCam.yawTarget += 0x2000;
|
||||
} else {
|
||||
gPuppyCam.yawTarget += 0x4000 * ivX;
|
||||
gPuppyCam.yawTarget += 0x4000;
|
||||
}
|
||||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN,gGlobalSoundSource);
|
||||
}
|
||||
puppycam_input_pitch();
|
||||
puppycam_input_zoom();
|
||||
puppycam_input_centre();
|
||||
gPuppyCam.pitchTarget += ((4 + gPuppyCam.moveFlagAdd) * gPuppyCam.pitchAcceleration * ivY) * (stickMag * 0.01f);
|
||||
gPuppyCam.pitchTarget += ((3 + gPuppyCam.movementPitchVel) * gPuppyCam.pitchAcceleration) * (stickMag * 0.01f);
|
||||
}
|
||||
|
||||
void puppycam_debug_view(void) {
|
||||
@@ -831,31 +905,38 @@ void puppycam_debug_view(void) {
|
||||
static void puppycam_view_panning(void) {
|
||||
s32 expectedPanX, expectedPanZ;
|
||||
s32 height = gPuppyCam.targetObj->oPosY;
|
||||
s32 panEx = (gPuppyCam.zoomTarget >= 1000) * 160; //Removes the basic panning when idling if the zoom level is at the closest.
|
||||
f32 slideSpeed = 1;
|
||||
//Removes the basic panning when idling if the zoom level is at the closest.
|
||||
s32 panEx = ((gPuppyCam.zoomTarget >= 1000) * 200) * (1.0f + MIN(gMarioState->forwardVel / 16.0f, 2.0f));
|
||||
f32 slideSpeed = 1.0f;
|
||||
|
||||
f32 panMulti = CLAMP(gPuppyCam.zoom / (f32)gPuppyCam.zoomPoints[2], 0.f, 1.f);
|
||||
if (gPuppyCam.options.inputType == 2) {
|
||||
panMulti /= 2;
|
||||
if (gPuppyCam.options.inputType == INPUT_CLASSIC) {
|
||||
panMulti /= 2.0f;
|
||||
}
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT && gMarioState->action != ACT_HOLDING_BOWSER && gMarioState->action != ACT_SLEEPING && gMarioState->action != ACT_START_SLEEPING) {
|
||||
if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) {
|
||||
slideSpeed = 10;
|
||||
slideSpeed = 10.0f;
|
||||
} else if (gMarioState->action & ACT_FLAG_MOVING) {
|
||||
slideSpeed = MIN(gMarioState->forwardVel / 12.0f, 3.0f);
|
||||
}
|
||||
expectedPanX = LENSIN(panEx + (200 * (gMarioState->forwardVel / 320.f)), gMarioState->faceAngle[1]) * panMulti;
|
||||
expectedPanZ = LENCOS(panEx + (200 * (gMarioState->forwardVel / 320.f)), gMarioState->faceAngle[1]) * panMulti;
|
||||
f32 speedMul = panEx + (400.0f * CLAMP(gMarioState->forwardVel / 320.0f, 0.25f, 1.0f));
|
||||
expectedPanX = LENCOS(LENSIN(speedMul, gMarioState->faceAngle[1] - gPuppyCam.yaw) * panMulti, ABS(gPuppyCam.yaw));
|
||||
expectedPanZ = LENSIN(LENCOS(speedMul, gMarioState->faceAngle[1]) * panMulti, ABS(gPuppyCam.yaw));
|
||||
|
||||
gPuppyCam.pan[0] = approach_f32_asymptotic(gPuppyCam.pan[0], expectedPanX, 0.02f*slideSpeed);
|
||||
gPuppyCam.pan[2] = approach_f32_asymptotic(gPuppyCam.pan[2], expectedPanZ, 0.02f*slideSpeed);
|
||||
gPuppyCam.pan[0] = approach_f32_asymptotic(gPuppyCam.pan[0], expectedPanX, 0.01f * slideSpeed);
|
||||
gPuppyCam.pan[2] = approach_f32_asymptotic(gPuppyCam.pan[2], expectedPanZ, 0.01f * slideSpeed);
|
||||
if (gMarioState->vel[1] == 0.0f) {
|
||||
f32 panFloor = CLAMP(find_floor_height((s16)(gPuppyCam.targetObj->oPosX+expectedPanX), (s16)(gPuppyCam.targetObj->oPosY + 200),
|
||||
(s16)(gPuppyCam.targetObj->oPosZ+expectedPanZ)), gPuppyCam.targetObj->oPosY - 50,gPuppyCam.targetObj->oPosY + 50);
|
||||
// If the floor is lower than 150 units below Mario, then ignore the Y value and tilt the camera instead.
|
||||
if (panFloor <= gPuppyCam.targetObj->oPosY - 150) {
|
||||
panFloor = gPuppyCam.targetObj->oPosY;
|
||||
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, -0x2000, 0x80, 0x80);
|
||||
s32 forwardPanX = LENSIN(250.0f, gPuppyCam.yaw + 0x8000);
|
||||
s32 forwardPanZ = LENCOS(250.0f, gPuppyCam.yaw + 0x8000);
|
||||
s32 ledgeHeight = find_floor_height((s16)(gPuppyCam.targetObj->oPosX+forwardPanX), (s16)(gPuppyCam.targetObj->oPosY + 200), (s16)(gPuppyCam.targetObj->oPosZ+forwardPanZ));
|
||||
if (ABS(ledgeHeight - gPuppyCam.targetObj->oPosY) > 150 && ledgeHeight != FLOOR_LOWER_LIMIT && !(gMarioState->action & ACT_FLAG_SWIMMING) && !(gMarioState->action & ACT_FLAG_AIR)) {
|
||||
ledgeHeight = gPuppyCam.targetObj->oPosY;
|
||||
gPuppyCam.edgePitch = approach_f32_asymptotic(gPuppyCam.edgePitch, -0x2000, 0.05f);
|
||||
} else {
|
||||
gPuppyCam.edgePitch = approach_s32(gPuppyCam.edgePitch, 0, 0x100, 0x100);
|
||||
gPuppyCam.edgePitch = approach_f32_asymptotic(gPuppyCam.edgePitch, 0, 0.05f);
|
||||
}
|
||||
gPuppyCam.pan[1] = approach_f32_asymptotic(gPuppyCam.pan[1], panFloor - height, 0.025f);
|
||||
} else {
|
||||
@@ -1002,10 +1083,10 @@ void puppycam_projection_behaviours(void) {
|
||||
|
||||
// This will only be executed if Mario's the target. If it's not, it'll reset the
|
||||
if (gPuppyCam.targetObj == gMarioState->marioObj) {
|
||||
if ((gPuppyCam.options.turnAggression > 0 && gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) &&
|
||||
gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != 2) || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) { // Holy hell this is getting spicy.
|
||||
if (((gPuppyCam.options.turnHelper || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_TURN_HELPER) && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_8DIR) &&
|
||||
gMarioState->vel[1] == 0.0f && !(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_4DIR) && gPuppyCam.options.inputType != INPUT_CLASSIC) || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) { // Holy hell this is getting spicy.
|
||||
// With turn aggression enabled, or if Mario's sliding, adjust the camera view behind mario.
|
||||
if (gPuppyCam.options.turnAggression > 0 || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) {
|
||||
if (gPuppyCam.options.turnHelper || gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE || gMarioState->action == ACT_SHOT_FROM_CANNON || gMarioState->action == ACT_FLYING) {
|
||||
if (gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE) {
|
||||
turnRate = 4; // If he's sliding, do it 4x as fast.
|
||||
}
|
||||
@@ -1015,7 +1096,7 @@ void puppycam_projection_behaviours(void) {
|
||||
// It also scales with forward velocity, so it's a gradual effect as he speeds up.
|
||||
if ((ABS(gPlayer1Controller->rawStickX) > 20 && !(gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE)) || (gMarioState->action == ACT_SHOT_FROM_CANNON) ||
|
||||
(gMarioState->action & ACT_FLAG_BUTT_OR_STOMACH_SLIDE && (s16)ABS(((gPuppyCam.yaw + 0x8000) % 0xFFFF - 0x8000) - ((gMarioState->faceAngle[1]) % 0xFFFF - 0x8000)) < 0x3000 ))
|
||||
gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), ((gPuppyCam.options.turnAggression * 10) * ABS(gMarioState->forwardVel / 32) * turnMag * turnRate));
|
||||
gPuppyCam.yawTarget = approach_angle(gPuppyCam.yawTarget, (gMarioState->faceAngle[1] + 0x8000), ((0x200) * ABS(gMarioState->forwardVel / 32) * turnMag * turnRate));
|
||||
}
|
||||
} else { //If none of the above is true, it'll attempt to do this instead.
|
||||
// If the camera's in these modes, snap the yaw to prevent desync.
|
||||
@@ -1035,21 +1116,24 @@ void puppycam_projection_behaviours(void) {
|
||||
gPuppyCam.targetFloorHeight = CLAMP(find_floor_height(gPuppyCam.targetObj->oPosX, gPuppyCam.targetObj->oPosY, gPuppyCam.targetObj->oPosZ), gPuppyCam.targetObj->oPosY-350, gPuppyCam.targetObj->oPosY+300);
|
||||
gPuppyCam.lastTargetFloorHeight = approach_f32_asymptotic(gPuppyCam.lastTargetFloorHeight , gPuppyCam.targetFloorHeight
|
||||
, CLAMP((absf(gMarioState->vel[1]) - 17.f) / 200.f, 0, 0.1f)
|
||||
+ CLAMP((absf(gPuppyCam.targetFloorHeight - gPuppyCam.lastTargetFloorHeight) - 30.f) / 300.f, 0, 0.1f));
|
||||
+ CLAMP((absf(gPuppyCam.targetFloorHeight - gPuppyCam.lastTargetFloorHeight)) / 300.f, 0, 0.1f));
|
||||
|
||||
if (gMarioState->action == ACT_SLEEPING || gMarioState->action == ACT_START_SLEEPING) {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomPoints[0],0.01f);
|
||||
} else if ((gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING && gMarioState->waterLevel-100 - gMarioState->pos[1] > 5) || gMarioState->action == ACT_FLYING) {
|
||||
// When moving underwater or flying, the camera will zoom in on Mayro.
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, MAX(gPuppyCam.zoomTarget/1.5f, gPuppyCam.zoomPoints[0]), 0.2f);
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, 500, 0.2f);
|
||||
} else {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom,gPuppyCam.zoomTarget, 0.2f);
|
||||
if (gPuppyCam.options.inputType != INPUT_CLASSIC) {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, 500 + CLAMP((0x4000 - gPuppyCam.pitch)/10, 0, 1250), 0.35f);
|
||||
} else {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic(gPuppyCam.zoom, gPuppyCam.zoomTarget, 0.15f);
|
||||
}
|
||||
}
|
||||
// Attempts at automatic adjustment that only apply when moving or jumping.
|
||||
if (gMarioState->action & ACT_FLAG_MOVING || gMarioState->action & ACT_FLAG_AIR || (gMarioState->action & ACT_FLAG_SWIMMING && !gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gMarioState->forwardVel != 0.0f)) {
|
||||
if (gMarioState->action & ACT_FLAG_MOVING || gMarioState->action & ACT_FLAG_AIR || gMarioState->action & ACT_FLAG_ON_POLE || (gMarioState->action & ACT_FLAG_SWIMMING && !gMarioState->waterLevel-100 - gMarioState->pos[1] > 5 && gMarioState->forwardVel != 0.0f)) {
|
||||
// Clamp the height when moving. You can still look up and down to a reasonable degree but it readjusts itself the second you let go.
|
||||
if (gPuppyCam.pitchTarget > 0x3800) gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x3800, 0.2f);
|
||||
if (gPuppyCam.pitchTarget < 0x2000) gPuppyCam.pitchTarget = approach_f32_asymptotic(gPuppyCam.pitchTarget, 0x2000, 0.2f);
|
||||
}
|
||||
|
||||
// Applies a light outward zoom to the camera when moving. Sets it back to 0 when not moving.
|
||||
@@ -1060,14 +1144,22 @@ void puppycam_projection_behaviours(void) {
|
||||
}
|
||||
|
||||
// Zooms the camera in further when underwater.
|
||||
if (gPuppyCam.pitch > 0x38C0 && ABS(gPuppyCam.swimPitch) < 100) {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic((f32)gPuppyCam.zoom, 250.0f, CLAMP((f32)((gPuppyCam.pitch - 0x38C0) / 3072.0f), 0.0f, 1.0f));
|
||||
if (gPuppyCam.pitch > 0x38C0 && ABS(gPuppyCam.swimPitch) < 100 && !(gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN)) {
|
||||
gPuppyCam.zoom = approach_f32_asymptotic((f32)gPuppyCam.zoom, 250.0f, CLAMP((f32)((gPuppyCam.pitch - 0x38C0) / 16384.0f), 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
if (!(gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING)) {
|
||||
gPuppyCam.floorY[0] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 300);
|
||||
gPuppyCam.floorY[1] = softClamp(gPuppyCam.targetObj->oPosY - gPuppyCam.lastTargetFloorHeight, -180, 350);
|
||||
gPuppyCam.swimPitch = approach_f32_asymptotic(gPuppyCam.swimPitch,0,0.2f);
|
||||
// Move the floor values upwards if moving and looking up, this makes the camera bias the view upwards.
|
||||
if (gMarioState->forwardVel > 0.0f && gPuppyCam.pitch >= 0x3A00) {
|
||||
f32 speedMul = CLAMP(gMarioState->forwardVel / 32.0f, 0.0f, 1.0f);
|
||||
gPuppyCam.floorY[0] += ((0x3A00 - gPuppyCam.pitch) / 24) * speedMul;
|
||||
gPuppyCam.floorY[1] += ((0x3A00 - gPuppyCam.pitch) / 64) * speedMul;
|
||||
// Disable collision because it shouldn't trigger intentionally at this distance anyway.
|
||||
gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_COLLISION;
|
||||
}
|
||||
} else {
|
||||
gPuppyCam.floorY[0] = 0;
|
||||
gPuppyCam.floorY[1] = 0;
|
||||
@@ -1117,7 +1209,7 @@ void puppycam_shake(UNUSED s16 x, UNUSED s16 y, UNUSED s16 z) {
|
||||
// The centrepiece behind the input side of PuppyCam. The C buttons branch off.
|
||||
static void puppycam_input_core(void) {
|
||||
puppycam_analogue_stick();
|
||||
gPuppyCam.moveFlagAdd = 0;
|
||||
gPuppyCam.movementPitchVel = 0;
|
||||
|
||||
// Decide which input for left and right C buttons to use based on behaviour type.
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_INPUT_NORMAL || gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) {
|
||||
@@ -1131,7 +1223,8 @@ static void puppycam_input_core(void) {
|
||||
static void puppycam_projection(void) {
|
||||
Vec3s targetPos, targetPos2, targetPos3;
|
||||
s16 pitchTotal;
|
||||
s32 panD = (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT) / 8192;
|
||||
f32 tempSin;
|
||||
f32 panD = (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_PANSHIFT) / 8192;
|
||||
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE) {
|
||||
puppycam_reset_values();
|
||||
@@ -1145,8 +1238,8 @@ static void puppycam_projection(void) {
|
||||
gPuppyCam.pitch = CLAMP(gPuppyCam.pitch, 0x1000, 0x7000);
|
||||
gPuppyCam.pitchTarget = CLAMP(gPuppyCam.pitchTarget, 0x1000, 0x7000);
|
||||
// These are the base rotations going to be used.
|
||||
gPuppyCam.yaw = gPuppyCam.yawTarget - approach_f32_asymptotic((s16)(gPuppyCam.yawTarget - gPuppyCam.yaw ), 0, 0.3335f);
|
||||
gPuppyCam.pitch = gPuppyCam.pitchTarget - approach_f32_asymptotic((s16)(gPuppyCam.pitchTarget - gPuppyCam.pitch), 0, 0.3335f);
|
||||
gPuppyCam.yaw = gPuppyCam.yawTarget - approach_f32_asymptotic((s16)(gPuppyCam.yawTarget - gPuppyCam.yaw ), 0, 0.5f);
|
||||
gPuppyCam.pitch = gPuppyCam.pitchTarget - approach_f32_asymptotic((s16)(gPuppyCam.pitchTarget - gPuppyCam.pitch), 0, 0.5f);
|
||||
// This adds the pitch effect when underwater, which is capped so it doesn't get out of control. If you're not swimming, swimpitch is 0, so it's normal.
|
||||
pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10)+gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800);
|
||||
|
||||
@@ -1167,14 +1260,30 @@ static void puppycam_projection(void) {
|
||||
}
|
||||
|
||||
gPuppyCam.targetDist[1] = gPuppyCam.targetDist[0] + gPuppyCam.zoom+gPuppyCam.moveZoom;
|
||||
#ifdef ENABLE_DEBUG_FREE_MOVE
|
||||
if (gMarioState->action == ACT_DEBUG_FREE_MOVE) gPuppyCam.targetDist[1] = MAX(gPuppyCam.targetDist[1] * 1.1f, 500);
|
||||
#endif
|
||||
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) gPuppyCam.focus[0] = targetPos3[0] + gPuppyCam.shake[0] + (gPuppyCam.pan[0] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) * panD;
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) gPuppyCam.focus[1] = targetPos3[1] + gPuppyCam.shake[1] + (gPuppyCam.pan[1] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) + gPuppyCam.povHeight - gPuppyCam.floorY[0] + (gPuppyCam.swimPitch / 10);
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) gPuppyCam.focus[2] = targetPos3[2] + gPuppyCam.shake[2] + (gPuppyCam.pan[2] * gPuppyCam.targetDist[1] / gPuppyCam.zoomPoints[2]) * panD;
|
||||
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) gPuppyCam.pos[0] = gPuppyCam.targetObj->oPosX + LENSIN(LENSIN(gPuppyCam.targetDist[1], pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[0];
|
||||
#ifdef ENABLE_DEBUG_FREE_MOVE
|
||||
if (gMarioState->action == ACT_DEBUG_FREE_MOVE) vec3_copy_y_off(gPuppyCam.focus, gMarioState->pos, 160.0f);
|
||||
#endif
|
||||
|
||||
tempSin = LENSIN(gPuppyCam.targetDist[1], pitchTotal);
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_X_MOVEMENT) gPuppyCam.pos[0] = gPuppyCam.targetObj->oPosX + LENSIN(tempSin, gPuppyCam.yaw) + gPuppyCam.shake[0];
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Y_MOVEMENT) gPuppyCam.pos[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight + LENCOS(gPuppyCam.targetDist[1], pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1];
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) gPuppyCam.pos[2] = gPuppyCam.targetObj->oPosZ + LENCOS(LENSIN(gPuppyCam.targetDist[1], pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[2];
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_Z_MOVEMENT) gPuppyCam.pos[2] = gPuppyCam.targetObj->oPosZ + LENCOS(tempSin, gPuppyCam.yaw) + gPuppyCam.shake[2];
|
||||
|
||||
// To improve precision in first person, apply an offset to the focus position so it's not noticably jerky.
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ENTER_FIRST_PERSON && gPuppyCam.zoom < 400 && gPuppyCam.zoomTarget < 100) {
|
||||
f32 zoomDist = LENSIN(1000.0f, pitchTotal);
|
||||
gPuppyCam.focus[0] = gPuppyCam.targetObj->oPosX + LENSIN(zoomDist, gPuppyCam.yaw + 0x8000) + gPuppyCam.shake[0];
|
||||
gPuppyCam.focus[1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight * 2) + LENCOS(1000.0f, gPuppyCam.pitch) + gPuppyCam.shake[1];
|
||||
gPuppyCam.focus[2] = gPuppyCam.targetObj->oPosZ + LENCOS(zoomDist, gPuppyCam.yaw + 0x8000) + gPuppyCam.shake[2];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1218,8 +1327,6 @@ static void puppycam_script(void) {
|
||||
if (volume.angles->zoom != PUPPY_NULL) {
|
||||
gPuppyCam.zoomTarget = volume.angles->zoom;
|
||||
gPuppyCam.zoom = gPuppyCam.zoomTarget;
|
||||
|
||||
gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1242,53 +1349,79 @@ static void puppycam_script(void) {
|
||||
|
||||
// Handles collision detection using ray casting.
|
||||
static void puppycam_collision(void) {
|
||||
struct WallCollisionData wall0, wall1;
|
||||
struct Surface *surf[2];
|
||||
Vec3f camdir[2];
|
||||
Vec3f hitpos[2];
|
||||
Vec3f target[2];
|
||||
s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch * 10) + gPuppyCam.edgePitch + gPuppyCam.terrainPitch, 800, 0x7800);
|
||||
s32 dist[2];
|
||||
|
||||
if (gPuppyCam.targetObj == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct Surface *surf[2] = {NULL, NULL};
|
||||
|
||||
Vec3f dirToCam;
|
||||
Vec3f hitpos[2];
|
||||
Vec3f target[2];
|
||||
f32 dist[2] = {0};
|
||||
// the distance from surface the camera should be. note: should NOT be greater than ~50 due to mario's hitbox
|
||||
const f32 surfOffset = 15.0f;
|
||||
// how far the raycast should extend, goes the current zoom dist plus the surfOffset (and a little bit more for safety)
|
||||
f32 colCheckDist = gPuppyCam.zoom + (surfOffset * 2.0f);
|
||||
|
||||
// The ray, starting from the top
|
||||
vec3_copy_y_off(target[0], &gPuppyCam.targetObj->oPosVec, (gPuppyCam.povHeight) - CLAMP(gPuppyCam.targetObj->oPosY - gPuppyCam.targetFloorHeight, 0, 300));
|
||||
vec3_copy_y_off(target[0], &gPuppyCam.targetObj->oPosVec, 120);
|
||||
// The ray, starting from the bottom
|
||||
vec3_copy_y_off(target[1], &gPuppyCam.targetObj->oPosVec, (gPuppyCam.povHeight * 0.4f));
|
||||
vec3_copy_y_off(target[1], &gPuppyCam.targetObj->oPosVec, 30);
|
||||
|
||||
camdir[0][0] = LENSIN(LENSIN(gPuppyCam.zoomTarget, pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[0];
|
||||
camdir[0][1] = LENCOS(gPuppyCam.zoomTarget, pitchTotal) + gPuppyCam.shake[1];
|
||||
camdir[0][2] = LENCOS(LENSIN(gPuppyCam.zoomTarget, pitchTotal), gPuppyCam.yaw) + gPuppyCam.shake[2];
|
||||
// Get the direction from mario's head to the camera
|
||||
vec3_diff(dirToCam, gPuppyCam.pos, target[0]);
|
||||
vec3f_normalize(dirToCam);
|
||||
// Get the vector from mario's head to the camera plus the extra check dist
|
||||
Vec3f vecToCam;
|
||||
vec3_prod_val(vecToCam, dirToCam, colCheckDist);
|
||||
|
||||
vec3_copy(camdir[1], camdir[0]);
|
||||
dist[0] = find_surface_on_ray(target[0], vecToCam, &surf[0], hitpos[0], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
dist[1] = find_surface_on_ray(target[1], vecToCam, &surf[1], hitpos[1], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
|
||||
find_surface_on_ray(target[0], camdir[0], &surf[0], hitpos[0], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
find_surface_on_ray(target[1], camdir[1], &surf[1], hitpos[1], RAYCAST_FIND_FLOOR | RAYCAST_FIND_CEIL | RAYCAST_FIND_WALL);
|
||||
resolve_and_return_wall_collisions(hitpos[0], 0.0f, 25.0f, &wall0);
|
||||
resolve_and_return_wall_collisions(hitpos[1], 0.0f, 25.0f, &wall1);
|
||||
dist[0] = ((target[0][0] - hitpos[0][0]) * (target[0][0] - hitpos[0][0]) + (target[0][1] - hitpos[0][1]) * (target[0][1] - hitpos[0][1]) + (target[0][2] - hitpos[0][2]) * (target[0][2] - hitpos[0][2]));
|
||||
dist[1] = ((target[1][0] - hitpos[1][0]) * (target[1][0] - hitpos[1][0]) + (target[1][1] - hitpos[1][1]) * (target[1][1] - hitpos[1][1]) + (target[1][2] - hitpos[1][2]) * (target[1][2] - hitpos[1][2]));
|
||||
// set collision distance to the current distance from mario to cam
|
||||
gPuppyCam.collisionDistance = colCheckDist;
|
||||
|
||||
gPuppyCam.collisionDistance = gPuppyCam.zoomTarget;
|
||||
if (surf[0] || surf[1]) {
|
||||
// use the further distance between the two surfaces to be less aggressive
|
||||
f32 closestDist = MAX(dist[0], dist[1]);
|
||||
// Cap it at the zoom dist so it doesn't go further than necessary
|
||||
closestDist = MIN(closestDist, gPuppyCam.zoom);
|
||||
if (closestDist - surfOffset <= gPuppyCam.zoom) {
|
||||
closestDist -= surfOffset;
|
||||
// Allow the camera to ride right up next to the wall (mario's wall radius is 50u so this is safe)
|
||||
closestDist = MAX(closestDist, 50);
|
||||
vec3_mul_val(dirToCam, closestDist);
|
||||
vec3_sum(gPuppyCam.pos, target[0], dirToCam);
|
||||
|
||||
if (surf[0] && surf[1]) {
|
||||
gPuppyCam.collisionDistance = sqrtf(MAX(dist[0], dist[1]));
|
||||
if (gPuppyCam.zoom > gPuppyCam.collisionDistance) {
|
||||
gPuppyCam.zoom = MIN(gPuppyCam.collisionDistance, gPuppyCam.zoomTarget);
|
||||
if (gPuppyCam.zoom - gPuppyCam.zoomTarget < 5) {
|
||||
if (dist[0] >= dist[1]) {
|
||||
vec3_copy(gPuppyCam.pos, hitpos[0]);
|
||||
} else {
|
||||
vec3_copy_y_off(gPuppyCam.pos, hitpos[1], (gPuppyCam.povHeight * 0.6f));
|
||||
}
|
||||
// If the camera is uncomfortably close to the wall, move it up a bit
|
||||
if (closestDist < 250 && gPuppyCam.pitch < 0x2000) {
|
||||
// lerp from 0 to 250
|
||||
gPuppyCam.pos[1] += remap(CLAMP(closestDist, 50, 255), 255, 50, 0, 250);
|
||||
}
|
||||
}
|
||||
}
|
||||
#define START_DIST 500
|
||||
#define END_DIST 250
|
||||
gPuppyCam.opacity = CLAMP((f32)(((gPuppyCam.zoom - END_DIST) / 255.0f) * (START_DIST - END_DIST)), 0, 255);
|
||||
|
||||
// Transparency based on mario dist to cam
|
||||
#define TRANS_START_DIST 200
|
||||
#define TRANS_END_DIST 100
|
||||
f32 goalOpa = 255;
|
||||
// Get the new dist between cam and mario
|
||||
vec3_diff(dirToCam, gPuppyCam.pos, target[0]);
|
||||
f32 realDist = vec3_sumsq(dirToCam);
|
||||
if (realDist < sqr(TRANS_START_DIST)) {
|
||||
realDist = sqrtf(realDist);
|
||||
// lerp from 127 to 0
|
||||
goalOpa = CLAMP((f32)(((realDist - TRANS_END_DIST) / 255.0f) * (TRANS_START_DIST - TRANS_END_DIST)), 0, 127);
|
||||
}
|
||||
// approach fast if significant diff
|
||||
f32 approachRate = absf(goalOpa - (f32)gPuppyCam.opacity) * 0.2f;
|
||||
// give a min approach speed
|
||||
approachRate = MAX(approachRate, 255/8);
|
||||
// approach the new goal opacity
|
||||
gPuppyCam.opacity = approach_f32_symmetric(gPuppyCam.opacity, goalOpa, approachRate);
|
||||
#undef TRANS_START_DIST
|
||||
#undef TRANS_END_DIST
|
||||
}
|
||||
|
||||
extern Vec3f sOldPosition;
|
||||
@@ -1356,7 +1489,11 @@ void puppycam_loop(void) {
|
||||
if (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_COLLISION) {
|
||||
puppycam_collision();
|
||||
} else {
|
||||
gPuppyCam.opacity = 255;
|
||||
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) {
|
||||
gPuppyCam.opacity = approach_f32_asymptotic(gPuppyCam.opacity, 0, 0.15f);
|
||||
} else {
|
||||
gPuppyCam.opacity = 255;
|
||||
}
|
||||
}
|
||||
} else if (gPuppyCam.cutscene) {
|
||||
gPuppyCam.opacity = 255;
|
||||
|
||||
+62
-8
@@ -47,11 +47,9 @@ struct gPuppyOptions
|
||||
{
|
||||
s16 analogue;
|
||||
s16 sensitivityX;
|
||||
s16 sensitivityY;
|
||||
s16 invertX;
|
||||
s16 invertY;
|
||||
s16 turnAggression;
|
||||
s16 inputType;
|
||||
s16 turnHelper;
|
||||
};
|
||||
|
||||
struct gPuppyStruct
|
||||
@@ -63,13 +61,12 @@ struct gPuppyStruct
|
||||
s16 pitchTarget; // Vertical Direction that pitch tries to be.
|
||||
f32 pitchAcceleration; // Vertical Direction that sets pitchTarget.
|
||||
s16 zoom; // How far the camera is currently zoomed out
|
||||
u8 zoomSet; // The current setting of which zoompoint to set the target to.
|
||||
s16 zoomTarget; // The value that zoom tries to be.
|
||||
s16 zoomPoints[3]; // An array containing distances.
|
||||
s16 targetFloorHeight; // Mario's current floor height
|
||||
s16 lastTargetFloorHeight; // Mirror's mario's floor height when his velocity is not above 0.
|
||||
Vec3s pos; // Where the camera is
|
||||
Vec3s focus; // Where the camera's looking
|
||||
Vec3f pos; // Where the camera is
|
||||
Vec3f focus; // Where the camera's looking
|
||||
Vec3s pan; // An offset of the camera's focus
|
||||
s32 intendedFlags; // The flagset the camera tries to be when it's not held hostage.
|
||||
s32 flags; // Behaviour flags that affect different properties of the camera's behaviour
|
||||
@@ -90,7 +87,7 @@ struct gPuppyStruct
|
||||
s16 edgePitch; // Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped.
|
||||
s16 moveZoom; // A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed.
|
||||
u8 mode3Flags; // A flagset for classic mode.
|
||||
u8 moveFlagAdd; // A bit that multiplies movement rate of axes when moving, to centre them faster.
|
||||
u8 movementPitchVel; // A bit that multiplies movement rate of axes when moving, to centre them faster.
|
||||
s16 targetDist[2]; // Used with secondary view targets to smooth out the between status.
|
||||
s16 intendedTerrainPitch; // The pitch that the game wants the game to tilt towards, following the terrain.
|
||||
s16 terrainPitch; // The pitch the game tilts towards, when following terrain inclines.
|
||||
@@ -122,9 +119,9 @@ struct sPuppyAngles
|
||||
//Structurally, it's exactly the same as CutsceneSplinePoint
|
||||
struct sPuppySpline
|
||||
{
|
||||
Vec3s pos; // The vector pos of the spline index itself.
|
||||
s8 index; // The index of the spline. Ends with -1
|
||||
u8 speed; // The amount of frames it takes to get through this index.
|
||||
Vec3s pos; // The vector pos of the spline index itself.
|
||||
};
|
||||
|
||||
//A bounding volume for activating puppycamera scripts and angles.
|
||||
@@ -198,4 +195,61 @@ extern s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySp
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Backwards compatability additions from Puppycam 1.
|
||||
* This adds support for the original volume format, so you can directly import them in
|
||||
* without having to make any further changes.
|
||||
* Naturally, because it's the old format, they will be severely more limited in flexibility.
|
||||
*/
|
||||
#define NC_FLAG_XTURN PUPPYCAM_BEHAVIOUR_YAW_ROTATION
|
||||
#define NC_FLAG_YTURN PUPPYCAM_BEHAVIOUR_PITCH_ROTATION
|
||||
#define NC_FLAG_ZOOM 0 // Stub
|
||||
#define NC_FLAG_8D PUPPYCAM_BEHAVIOUR_INPUT_8DIR
|
||||
#define NC_FLAG_4D PUPPYCAM_BEHAVIOUR_INPUT_4DIR
|
||||
#define NC_FLAG_2D PUPPYCAM_BEHAVIOUR_INPUT_2D
|
||||
#define NC_FLAG_FOCUSX PUPPYCAM_BEHAVIOUR_X_MOVEMENT
|
||||
#define NC_FLAG_FOCUSY PUPPYCAM_BEHAVIOUR_Y_MOVEMENT
|
||||
#define NC_FLAG_FOCUSZ PUPPYCAM_BEHAVIOUR_Z_MOVEMENT
|
||||
#define NC_FLAG_POSX PUPPYCAM_BEHAVIOUR_X_MOVEMENT
|
||||
#define NC_FLAG_POSY PUPPYCAM_BEHAVIOUR_Y_MOVEMENT
|
||||
#define NC_FLAG_POSZ PUPPYCAM_BEHAVIOUR_Z_MOVEMENT
|
||||
#define NC_FLAG_COLLISION PUPPYCAM_BEHAVIOUR_COLLISION
|
||||
#define NC_FLAG_SLIDECORRECT 0 // Stub
|
||||
|
||||
#define NC_MODE_NORMAL 1
|
||||
#define NC_MODE_SLIDE 2
|
||||
#define NC_MODE_FIXED 3
|
||||
#define NC_MODE_2D 4
|
||||
#define NC_MODE_8D 5
|
||||
#define NC_MODE_FIXED_NOMOVE 6
|
||||
#define NC_MODE_FIXED_NOTURN 7
|
||||
#define NC_MODE_NOROTATE 8
|
||||
|
||||
enum PuppyCamInput {
|
||||
INPUT_DOUBLE_TAP,
|
||||
INPUT_SINGLE_PRESS,
|
||||
INPUT_CLASSIC
|
||||
};
|
||||
|
||||
struct newcam_hardpos {
|
||||
u8 newcam_hard_levelID;
|
||||
u8 newcam_hard_areaID;
|
||||
u8 newcam_hard_permaswap;
|
||||
u16 newcam_hard_modeset;
|
||||
void *newcam_hard_script;
|
||||
s16 newcam_hard_X1;
|
||||
s16 newcam_hard_Y1;
|
||||
s16 newcam_hard_Z1;
|
||||
s16 newcam_hard_X2;
|
||||
s16 newcam_hard_Y2;
|
||||
s16 newcam_hard_Z2;
|
||||
s16 newcam_hard_camX;
|
||||
s16 newcam_hard_camY;
|
||||
s16 newcam_hard_camZ;
|
||||
s16 newcam_hard_lookX;
|
||||
s16 newcam_hard_lookY;
|
||||
s16 newcam_hard_lookZ;
|
||||
};
|
||||
extern struct newcam_hardpos newcam_fixedcam[];
|
||||
|
||||
#endif // PUPPYCAM2_H
|
||||
+499
-11
@@ -26,7 +26,9 @@ a modern game engine's developer's console.
|
||||
#include <ultra64.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "seq_ids.h"
|
||||
#include "game_init.h"
|
||||
#include "sound_init.h"
|
||||
#include "memory.h"
|
||||
#include "print.h"
|
||||
#include "string.h"
|
||||
@@ -40,7 +42,9 @@ a modern game engine's developer's console.
|
||||
#include "object_list_processor.h"
|
||||
#include "engine/surface_load.h"
|
||||
#include "audio/data.h"
|
||||
#include "audio/external.h"
|
||||
#include "audio/heap.h"
|
||||
#include "audio/load.h"
|
||||
#include "hud.h"
|
||||
#include "debug_box.h"
|
||||
#include "color_presets.h"
|
||||
@@ -447,7 +451,7 @@ void print_console_log(void) {
|
||||
finish_blank_box();
|
||||
|
||||
for (u8 i = 0; i < LOG_BUFFER_SIZE; i++) {
|
||||
if (consoleLogTable[i] == NULL) {
|
||||
if (consoleLogTable[i][0] == '\0') {
|
||||
continue;
|
||||
}
|
||||
print_small_text_light(16, (LINE_HEIGHT - (i * 12)), consoleLogTable[i], PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_DEFAULT);
|
||||
@@ -599,6 +603,378 @@ void puppyprint_level_select_menu(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BETTER_REVERB
|
||||
|
||||
#define DEBUG_REVERB_PRESET_COUNT ARRAY_COUNT(gDebugBetterReverbSettings)
|
||||
|
||||
enum BetterReverbDebugFields {
|
||||
PPREVERB_USE_LIGHTWEIGHT,
|
||||
PPREVERB_DOWNSAMPLE_RATE,
|
||||
PPREVERB_IS_MONO,
|
||||
PPREVERB_FILTER_COUNT,
|
||||
PPREVERB_WINDOW_SIZE,
|
||||
PPREVERB_GAIN,
|
||||
PPREVERB_GAIN_INDEX,
|
||||
PPREVERB_REVERB_INDEX,
|
||||
PPREVERB_DELAYS_L,
|
||||
PPREVERB_DELAYS_R,
|
||||
PPREVERB_REVERB_MULTS_L,
|
||||
PPREVERB_REVERB_MULTS_R,
|
||||
PPREVERB_AREA_ECHO,
|
||||
PPREVERB_TOTAL,
|
||||
};
|
||||
|
||||
struct BetterReverbDebugSizes {
|
||||
u8 treatAsEntryCount;
|
||||
u8 bytes;
|
||||
s32 entryMinimum;
|
||||
s32 entryMaximum;
|
||||
};
|
||||
|
||||
static struct BetterReverbDebugSizes maxReverbEntrySizes[PPREVERB_TOTAL] = {
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // useLightweightSettings
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = -1, .entryMaximum = 5}, // downsampleRate (seems to work up to 7 before things are audibly dangerous, but I suspect it's still unsafe)
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // isMono
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 3, .entryMaximum = NUM_ALLPASS}, // filterCount
|
||||
{.treatAsEntryCount = FALSE, .bytes = 2, .entryMinimum = -1, .entryMaximum = 0x7FFF}, // windowSize
|
||||
{.treatAsEntryCount = FALSE, .bytes = 2, .entryMinimum = -1, .entryMaximum = 0x7FFF}, // gain
|
||||
{.treatAsEntryCount = FALSE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 0xFF}, // gainIndex
|
||||
{.treatAsEntryCount = FALSE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 0xFF}, // reverbIndex
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // delaysL
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // delaysR
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // reverbMultsL
|
||||
{.treatAsEntryCount = TRUE, .bytes = 1, .entryMinimum = 0, .entryMaximum = 1}, // reverbMultsR
|
||||
{.treatAsEntryCount = FALSE, .bytes = 1, .entryMinimum = -0x80, .entryMaximum = 0x7F}, // area echo (not part of struct)
|
||||
};
|
||||
|
||||
#define REVERB_TOP_PRIO(x) (((x) | (0xFF << SOUNDARGS_SHIFT_PRIORITY)) & ~SOUND_NO_ECHO)
|
||||
static u32 betterReverbSfx[] = {
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAH_WAH_HOO),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAH_WAH_HOO + (1 << 16)),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAH_WAH_HOO + (2 << 16)),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_HOOHOO),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAHOO),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_UH),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_HRMM),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_WAH2),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_WHOA),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_EEUH),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_ATTACKED),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_OOOF),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_HERE_WE_GO),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAWNING),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_WAAAOOOW),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_HAHA),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_UH_LEDGE_CLIMB_FAST),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_ON_FIRE),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_DYING),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_PANTING_COLD),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_PANTING),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_MAMA_MIA),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_DROWNING),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAHOO_WAHA_YIPPEE),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAHOO_WAHA_YIPPEE + (3 << 16)),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_YAHOO_WAHA_YIPPEE + (4 << 16)),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_DOH),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_GAME_OVER),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_HELLO),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_PRESS_START_TO_PLAY),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_TWIRL_BOUNCE),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_SO_LONGA_BOWSER),
|
||||
REVERB_TOP_PRIO(SOUND_MARIO_IMA_TIRED),
|
||||
};
|
||||
#undef REVERB_TOP_PRIO
|
||||
|
||||
static s8 ppAreaEchos[DEBUG_REVERB_PRESET_COUNT] = {0};
|
||||
|
||||
static s32 ppReverbSide = 0;
|
||||
static s32 ppReverbSelectY = 0;
|
||||
|
||||
s32 better_reverb_get_or_set_field(u8 shouldSet, s32 xIndex, s32 yIndex, s32 valueToSet) {
|
||||
s32 ret = 0;
|
||||
|
||||
if (shouldSet) {
|
||||
if (valueToSet < maxReverbEntrySizes[yIndex].entryMinimum) {
|
||||
valueToSet = maxReverbEntrySizes[yIndex].entryMinimum;
|
||||
} else if (valueToSet > maxReverbEntrySizes[yIndex].entryMaximum) {
|
||||
valueToSet = maxReverbEntrySizes[yIndex].entryMaximum;
|
||||
}
|
||||
|
||||
switch(yIndex) {
|
||||
case PPREVERB_USE_LIGHTWEIGHT:
|
||||
gDebugBetterReverbSettings[xIndex].useLightweightSettings = valueToSet;
|
||||
break;
|
||||
case PPREVERB_DOWNSAMPLE_RATE:
|
||||
gDebugBetterReverbSettings[xIndex].downsampleRate = valueToSet;
|
||||
break;
|
||||
case PPREVERB_IS_MONO:
|
||||
gDebugBetterReverbSettings[xIndex].isMono = valueToSet;
|
||||
break;
|
||||
case PPREVERB_FILTER_COUNT:
|
||||
gDebugBetterReverbSettings[xIndex].filterCount = valueToSet;
|
||||
break;
|
||||
case PPREVERB_WINDOW_SIZE:
|
||||
gDebugBetterReverbSettings[xIndex].windowSize = valueToSet;
|
||||
break;
|
||||
case PPREVERB_GAIN:
|
||||
gDebugBetterReverbSettings[xIndex].gain = valueToSet;
|
||||
break;
|
||||
case PPREVERB_GAIN_INDEX:
|
||||
gDebugBetterReverbSettings[xIndex].gainIndex = valueToSet;
|
||||
break;
|
||||
case PPREVERB_REVERB_INDEX:
|
||||
gDebugBetterReverbSettings[xIndex].reverbIndex = valueToSet;
|
||||
break;
|
||||
case PPREVERB_DELAYS_L:
|
||||
gDebugBetterReverbSettings[xIndex].delaysL = sReverbDelaysArr[valueToSet];
|
||||
break;
|
||||
case PPREVERB_DELAYS_R:
|
||||
gDebugBetterReverbSettings[xIndex].delaysR = sReverbDelaysArr[valueToSet];
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_L:
|
||||
gDebugBetterReverbSettings[xIndex].reverbMultsL = sReverbMultsArr[valueToSet];
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_R:
|
||||
gDebugBetterReverbSettings[xIndex].reverbMultsR = sReverbMultsArr[valueToSet];
|
||||
break;
|
||||
case PPREVERB_AREA_ECHO:
|
||||
if (gCurrentArea != NULL && !gCurrentArea->useEchoOverride) {
|
||||
u8 level = gCurrLevelNum;
|
||||
u8 area = gCurrAreaIndex - 1;
|
||||
if (level > LEVEL_MAX) {
|
||||
level = LEVEL_MAX;
|
||||
}
|
||||
if (area > 2) {
|
||||
area = 2;
|
||||
}
|
||||
|
||||
gCurrentArea->echoOverride = sLevelAreaReverbs[level][area];
|
||||
gCurrentArea->useEchoOverride = TRUE;
|
||||
|
||||
for (u32 i = 0; i < DEBUG_REVERB_PRESET_COUNT; i++) {
|
||||
ppAreaEchos[i] = gCurrentArea->echoOverride;
|
||||
}
|
||||
}
|
||||
ppAreaEchos[xIndex] = valueToSet;
|
||||
break;
|
||||
|
||||
ret = valueToSet;
|
||||
}
|
||||
} else {
|
||||
switch(yIndex) {
|
||||
case PPREVERB_USE_LIGHTWEIGHT:
|
||||
ret = gDebugBetterReverbSettings[xIndex].useLightweightSettings;
|
||||
break;
|
||||
case PPREVERB_DOWNSAMPLE_RATE:
|
||||
ret = gDebugBetterReverbSettings[xIndex].downsampleRate;
|
||||
break;
|
||||
case PPREVERB_IS_MONO:
|
||||
ret = gDebugBetterReverbSettings[xIndex].isMono;
|
||||
break;
|
||||
case PPREVERB_FILTER_COUNT:
|
||||
ret = gDebugBetterReverbSettings[xIndex].filterCount;
|
||||
break;
|
||||
case PPREVERB_WINDOW_SIZE:
|
||||
ret = gDebugBetterReverbSettings[xIndex].windowSize;
|
||||
break;
|
||||
case PPREVERB_GAIN:
|
||||
ret = gDebugBetterReverbSettings[xIndex].gain;
|
||||
break;
|
||||
case PPREVERB_GAIN_INDEX:
|
||||
ret = gDebugBetterReverbSettings[xIndex].gainIndex;
|
||||
break;
|
||||
case PPREVERB_REVERB_INDEX:
|
||||
ret = gDebugBetterReverbSettings[xIndex].reverbIndex;
|
||||
break;
|
||||
case PPREVERB_DELAYS_L:
|
||||
ret = (u32) ((u8*) gDebugBetterReverbSettings[xIndex].delaysL - (u8*) &sReverbDelaysArr[0][0]) / sizeof(sReverbDelaysArr[0]);
|
||||
break;
|
||||
case PPREVERB_DELAYS_R:
|
||||
ret = (u32) ((u8*) gDebugBetterReverbSettings[xIndex].delaysR - (u8*) &sReverbDelaysArr[0][0]) / sizeof(sReverbDelaysArr[0]);
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_L:
|
||||
ret = (u32) ((u8*) gDebugBetterReverbSettings[xIndex].reverbMultsL - (u8*) &sReverbMultsArr[0][0]) / sizeof(sReverbMultsArr[0]);
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_R:
|
||||
ret = (u32) ((u8*) gDebugBetterReverbSettings[xIndex].reverbMultsR - (u8*) &sReverbMultsArr[0][0]) / sizeof(sReverbMultsArr[0]);
|
||||
break;
|
||||
case PPREVERB_AREA_ECHO:
|
||||
if (gCurrentArea != NULL && !gCurrentArea->useEchoOverride) {
|
||||
u8 level = gCurrLevelNum;
|
||||
u8 area = gCurrAreaIndex - 1;
|
||||
if (level > LEVEL_MAX) {
|
||||
level = LEVEL_MAX;
|
||||
}
|
||||
if (area > 2) {
|
||||
area = 2;
|
||||
}
|
||||
|
||||
gCurrentArea->echoOverride = sLevelAreaReverbs[level][area];
|
||||
gCurrentArea->useEchoOverride = TRUE;
|
||||
|
||||
for (u32 i = 0; i < DEBUG_REVERB_PRESET_COUNT; i++) {
|
||||
ppAreaEchos[i] = gCurrentArea->echoOverride;
|
||||
}
|
||||
}
|
||||
ret = ppAreaEchos[xIndex];
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret < maxReverbEntrySizes[yIndex].entryMinimum) {
|
||||
ret = maxReverbEntrySizes[yIndex].entryMinimum;
|
||||
} else if (ret > maxReverbEntrySizes[yIndex].entryMaximum) {
|
||||
ret = maxReverbEntrySizes[yIndex].entryMaximum;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void better_reverb_preset_menu(void) {
|
||||
char textBytes[16];
|
||||
s32 printValue;
|
||||
s32 x;
|
||||
s32 y;
|
||||
|
||||
prepare_blank_box();
|
||||
render_blank_box_rounded(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 127);
|
||||
finish_blank_box();
|
||||
|
||||
print_set_envcolour(63, 159, 127, 255),
|
||||
print_small_text(SCREEN_WIDTH/2, SCREEN_HEIGHT - 48, "<COL_3FFF9FFF>D-Pad Up/Down:<COL_--------> Scroll, <COL_3FFF9FFF>Start:<COL_--------> Switch Preset A/B", PRINT_TEXT_ALIGN_CENTRE, PRINT_ALL, FONT_OUTLINE);
|
||||
print_set_envcolour(63, 159, 127, 255),
|
||||
print_small_text(SCREEN_WIDTH/2, SCREEN_HEIGHT - 36, "<COL_3FFF9FFF>D-Pad L/R:<COL_--------> Fine Adjustment, <COL_3FFF9FFF>Z/R:<COL_--------> Coarse Adjustment", PRINT_TEXT_ALIGN_CENTRE, PRINT_ALL, FONT_OUTLINE);
|
||||
print_set_envcolour(63, 159, 127, 255),
|
||||
print_small_text(SCREEN_WIDTH/2, SCREEN_HEIGHT - 24, "<COL_3FFF9FFF>A:<COL_--------> Apply Selected Preset, <COL_3FFF9FFF>B:<COL_--------> Preview SFX", PRINT_TEXT_ALIGN_CENTRE, PRINT_ALL, FONT_OUTLINE);
|
||||
|
||||
x = 32;
|
||||
y = 16;
|
||||
for (s32 j = 0; j < PPREVERB_TOTAL; j++) {
|
||||
y += 12;
|
||||
if (j == ppReverbSelectY) {
|
||||
print_set_envcolour(255, 255, 159, 255);
|
||||
} else {
|
||||
print_set_envcolour(191, 159, 191, 255);
|
||||
}
|
||||
switch(j) {
|
||||
case PPREVERB_USE_LIGHTWEIGHT:
|
||||
print_small_text_light(x, y, "Lightweight:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_DOWNSAMPLE_RATE:
|
||||
print_small_text_light(x, y, "Downsample Rate:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_IS_MONO:
|
||||
print_small_text_light(x, y, "Mono:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_FILTER_COUNT:
|
||||
print_small_text_light(x, y, "Filter Count:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_WINDOW_SIZE:
|
||||
print_small_text_light(x, y, "Window Size:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_GAIN:
|
||||
print_small_text_light(x, y, "Gain:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_GAIN_INDEX:
|
||||
print_small_text_light(x, y, "Gain Index:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_REVERB_INDEX:
|
||||
print_small_text_light(x, y, "Reverb Index:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_DELAYS_L:
|
||||
print_small_text_light(x, y, "Delays L:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_DELAYS_R:
|
||||
print_small_text_light(x, y, "Delays R:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_L:
|
||||
print_small_text_light(x, y, "Reverb Mults L:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_REVERB_MULTS_R:
|
||||
print_small_text_light(x, y, "Reverb Mults R:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
case PPREVERB_AREA_ECHO:
|
||||
print_small_text_light(x, y, "Area Echo:", PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < DEBUG_REVERB_PRESET_COUNT; i++) {
|
||||
s32 windowSize = better_reverb_get_or_set_field(FALSE, i, PPREVERB_WINDOW_SIZE, 0);
|
||||
s32 downsampleRate = better_reverb_get_or_set_field(FALSE, i, PPREVERB_DOWNSAMPLE_RATE, 0);
|
||||
s32 isLightweight = better_reverb_get_or_set_field(FALSE, i, PPREVERB_USE_LIGHTWEIGHT, 0);
|
||||
x = (SCREEN_WIDTH/2) + (i * 84);
|
||||
y = 12;
|
||||
if (i == ppReverbSide) {
|
||||
print_set_envcolour(255, 255, 159, 255);
|
||||
} else {
|
||||
print_set_envcolour(191, 159, 191, 255);
|
||||
}
|
||||
sprintf(textBytes, "PRESET %c", 'A' + i);
|
||||
print_small_text_light(x, y, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
y += 4;
|
||||
for (s32 j = 0; j < PPREVERB_TOTAL; j++) {
|
||||
y += 12;
|
||||
printValue = better_reverb_get_or_set_field(FALSE, i, j, 0);
|
||||
if (i == ppReverbSide && j == ppReverbSelectY) {
|
||||
print_set_envcolour(255, 159, 0, 255);
|
||||
} else if (windowSize == 0) { // All reverb disabled
|
||||
if (j == PPREVERB_WINDOW_SIZE) {
|
||||
print_set_envcolour(255, 255, 255, 255);
|
||||
} else {
|
||||
print_set_envcolour(95, 95, 95, 255);
|
||||
}
|
||||
} else if (downsampleRate <= 0) { // Vanilla reverb
|
||||
switch(j) {
|
||||
case PPREVERB_DOWNSAMPLE_RATE:
|
||||
case PPREVERB_WINDOW_SIZE:
|
||||
case PPREVERB_GAIN:
|
||||
case PPREVERB_AREA_ECHO:
|
||||
print_set_envcolour(255, 255, 255, 255);
|
||||
break;
|
||||
default:
|
||||
print_set_envcolour(95, 95, 95, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (isLightweight) { // Lightweight reverb
|
||||
switch(j) {
|
||||
case PPREVERB_FILTER_COUNT:
|
||||
case PPREVERB_GAIN_INDEX:
|
||||
case PPREVERB_REVERB_INDEX:
|
||||
case PPREVERB_REVERB_MULTS_L:
|
||||
case PPREVERB_REVERB_MULTS_R:
|
||||
print_set_envcolour(95, 95, 95, 255);
|
||||
break;
|
||||
default:
|
||||
print_set_envcolour(255, 255, 255, 255);
|
||||
break;
|
||||
|
||||
}
|
||||
} else { // Standard reverb
|
||||
print_set_envcolour(255, 255, 255, 255);
|
||||
}
|
||||
|
||||
if (maxReverbEntrySizes[j].bytes == 2) {
|
||||
sprintf(textBytes, "0x%04X", (u16) printValue);
|
||||
} else if (!maxReverbEntrySizes[j].treatAsEntryCount) {
|
||||
sprintf(textBytes, "0x%02X", (u8) printValue);
|
||||
} else if (j == PPREVERB_USE_LIGHTWEIGHT || j == PPREVERB_IS_MONO) {
|
||||
if (printValue == 0) {
|
||||
sprintf(textBytes, "FALSE");
|
||||
} else {
|
||||
sprintf(textBytes, "TRUE");
|
||||
}
|
||||
} else {
|
||||
sprintf(textBytes, "%d", printValue);
|
||||
}
|
||||
|
||||
print_small_text_light(x, y, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u8 gLastWarpID = 0;
|
||||
|
||||
void puppyprint_render_general_vars(void) {
|
||||
@@ -650,18 +1026,21 @@ void puppyprint_render_general_vars(void) {
|
||||
|
||||
struct PuppyPrintPage ppPages[] = {
|
||||
#ifdef USE_PROFILER
|
||||
{&puppyprint_render_standard, "Profiler"},
|
||||
{&puppyprint_render_minimal, "Minimal"},
|
||||
[PUPPYPRINT_PAGE_PROFILER] = {&puppyprint_render_standard, "Profiler"},
|
||||
[PUPPYPRINT_PAGE_MINIMAL] = {&puppyprint_render_minimal, "Minimal"},
|
||||
#endif
|
||||
{&puppyprint_render_general_vars, "General"},
|
||||
{&print_audio_overview, "Audio"},
|
||||
{&print_ram_overview, "Segments"},
|
||||
{&puppyprint_render_collision, "Collision"},
|
||||
{&print_console_log, "Log"},
|
||||
{&puppyprint_level_select_menu, "Level Select"},
|
||||
{&render_coverage_map, "Coverage"},
|
||||
[PUPPYPRINT_PAGE_GENERAL] = {&puppyprint_render_general_vars, "General"},
|
||||
[PUPPYPRINT_PAGE_AUDIO] = {&print_audio_overview, "Audio"},
|
||||
[PUPPYPRINT_PAGE_RAM] = {&print_ram_overview, "Segments"},
|
||||
[PUPPYPRINT_PAGE_COLLISION] = {&puppyprint_render_collision, "Collision"},
|
||||
[PUPPYPRINT_PAGE_LOG] = {&print_console_log, "Log"},
|
||||
[PUPPYPRINT_PAGE_LEVEL_SELECT] = {&puppyprint_level_select_menu, "Level Select"},
|
||||
[PUPPYPRINT_PAGE_COVERAGE] = {&render_coverage_map, "Coverage"},
|
||||
#ifdef PUPPYCAM
|
||||
{&puppycamera_debug_view, "Unlock Camera"},
|
||||
[PUPPYPRINT_PAGE_CAMERA] = {&puppycamera_debug_view, "Unlock Camera"},
|
||||
#endif
|
||||
#ifdef BETTER_REVERB
|
||||
[PUPPYPRINT_PAGE_BETTER_REVERB] = {&better_reverb_preset_menu, "Reverb Config"},
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -810,6 +1189,115 @@ void puppyprint_profiler_process(void) {
|
||||
gPPSegScroll += 4;
|
||||
}
|
||||
}
|
||||
#ifdef BETTER_REVERB
|
||||
if (sPPDebugPage == PUPPYPRINT_PAGE_BETTER_REVERB)
|
||||
{
|
||||
s32 grabbedValue = better_reverb_get_or_set_field(FALSE, ppReverbSide, ppReverbSelectY, 0);
|
||||
|
||||
// These only need to be done once, but not really worth optimizing tbh
|
||||
maxReverbEntrySizes[PPREVERB_DELAYS_L].entryMaximum = gReverbDelaysArrCount - 1;
|
||||
maxReverbEntrySizes[PPREVERB_DELAYS_R].entryMaximum = gReverbDelaysArrCount - 1;
|
||||
maxReverbEntrySizes[PPREVERB_REVERB_MULTS_L].entryMaximum = gReverbMultsArrCount - 1;
|
||||
maxReverbEntrySizes[PPREVERB_REVERB_MULTS_R].entryMaximum = gReverbMultsArrCount - 1;
|
||||
|
||||
if (gPlayer1Controller->buttonPressed & (A_BUTTON | B_BUTTON)) {
|
||||
u8 betterReverbLastPreset = gBetterReverbPresetValue;
|
||||
|
||||
if (gCurrentArea != NULL) {
|
||||
gCurrentArea->useEchoOverride = TRUE;
|
||||
gBetterReverbPresetValue = (u8)(s8) (ppReverbSide - DEBUG_REVERB_PRESET_COUNT);
|
||||
gCurrentArea->echoOverride = ppAreaEchos[ppReverbSide];
|
||||
}
|
||||
|
||||
if (sAudioIsInitialized) {
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
|
||||
init_reverb_us(0);
|
||||
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gBetterReverbPresetValue = betterReverbLastPreset;
|
||||
|
||||
if (gPlayer1Controller->buttonPressed & B_BUTTON) {
|
||||
u32 sound = random_u16() % ARRAY_COUNT(betterReverbSfx);
|
||||
play_sound(betterReverbSfx[sound], gGlobalSoundSource);
|
||||
} else { // A_BUTTON
|
||||
sPPDebugPage = 0;
|
||||
}
|
||||
} else if (gPlayer1Controller->buttonPressed & L_JPAD) {
|
||||
if (ppReverbSelectY == PPREVERB_FILTER_COUNT) {
|
||||
grabbedValue -= 3;
|
||||
} else if ((ppReverbSelectY == PPREVERB_WINDOW_SIZE || ppReverbSelectY == PPREVERB_GAIN) && grabbedValue > 0 && grabbedValue <= 0x80) {
|
||||
grabbedValue = 0;
|
||||
} else {
|
||||
if (maxReverbEntrySizes[ppReverbSelectY].bytes == 2) {
|
||||
grabbedValue -= 0x80;
|
||||
} else {
|
||||
grabbedValue -= 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
better_reverb_get_or_set_field(TRUE, ppReverbSide, ppReverbSelectY, grabbedValue);
|
||||
} else if (gPlayer1Controller->buttonPressed & R_JPAD) {
|
||||
if (ppReverbSelectY == PPREVERB_FILTER_COUNT) {
|
||||
grabbedValue += 3;
|
||||
} else if ((ppReverbSelectY == PPREVERB_WINDOW_SIZE || ppReverbSelectY == PPREVERB_GAIN) && grabbedValue < 0) {
|
||||
grabbedValue = 0;
|
||||
} else {
|
||||
if (maxReverbEntrySizes[ppReverbSelectY].bytes == 2) {
|
||||
grabbedValue += 0x80;
|
||||
} else {
|
||||
grabbedValue += 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
better_reverb_get_or_set_field(TRUE, ppReverbSide, ppReverbSelectY, grabbedValue);
|
||||
} else if (gPlayer1Controller->buttonPressed & Z_TRIG) {
|
||||
if (ppReverbSelectY == PPREVERB_FILTER_COUNT) {
|
||||
grabbedValue -= 3;
|
||||
} else if ((ppReverbSelectY == PPREVERB_WINDOW_SIZE || ppReverbSelectY == PPREVERB_GAIN) && grabbedValue > 0 && grabbedValue <= 0x800) {
|
||||
grabbedValue = 0;
|
||||
} else {
|
||||
if (maxReverbEntrySizes[ppReverbSelectY].bytes == 2) {
|
||||
grabbedValue -= 0x800;
|
||||
} else if (!maxReverbEntrySizes[ppReverbSelectY].treatAsEntryCount) {
|
||||
grabbedValue -= 0x10;
|
||||
} else {
|
||||
grabbedValue -= 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
better_reverb_get_or_set_field(TRUE, ppReverbSide, ppReverbSelectY, grabbedValue);
|
||||
} else if (gPlayer1Controller->buttonPressed & R_TRIG) {
|
||||
if (ppReverbSelectY == PPREVERB_FILTER_COUNT) {
|
||||
grabbedValue += 3;
|
||||
} else if ((ppReverbSelectY == PPREVERB_WINDOW_SIZE || ppReverbSelectY == PPREVERB_GAIN) && grabbedValue < 0) {
|
||||
grabbedValue = 0;
|
||||
} else {
|
||||
if (maxReverbEntrySizes[ppReverbSelectY].bytes == 2) {
|
||||
grabbedValue += 0x800;
|
||||
} else if (!maxReverbEntrySizes[ppReverbSelectY].treatAsEntryCount) {
|
||||
grabbedValue += 0x10;
|
||||
} else {
|
||||
grabbedValue += 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
better_reverb_get_or_set_field(TRUE, ppReverbSide, ppReverbSelectY, grabbedValue);
|
||||
} else if (gPlayer1Controller->buttonPressed & D_JPAD) {
|
||||
ppReverbSelectY = (ppReverbSelectY + 1) % PPREVERB_TOTAL;
|
||||
} else if (gPlayer1Controller->buttonPressed & U_JPAD) {
|
||||
ppReverbSelectY = (ppReverbSelectY + PPREVERB_TOTAL - 1) % PPREVERB_TOTAL;
|
||||
} else if (gPlayer1Controller->buttonPressed & START_BUTTON) {
|
||||
ppReverbSide = (ppReverbSide + 1) % DEBUG_REVERB_PRESET_COUNT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
profiler_update(PROFILER_TIME_PUPPYPRINT2, osGetCount() - first);
|
||||
}
|
||||
|
||||
+16
-2
@@ -13,10 +13,21 @@
|
||||
#define PUPPYPRINT_ADD_COUNTER(x) x++
|
||||
#define PUPPYPRINT_GET_SNAPSHOT() u32 first = osGetCount()
|
||||
#define PUPPYPRINT_GET_SNAPSHOT_TYPE(type) u32 first = profiler_get_delta(type)
|
||||
void append_puppyprint_log(const char *str, ...);
|
||||
#else
|
||||
#define PUPPYPRINT_ADD_COUNTER(x)
|
||||
#define PUPPYPRINT_GET_SNAPSHOT()
|
||||
#define PUPPYPRINT_GET_SNAPSHOT_TYPE(type)
|
||||
#define append_puppyprint_log(...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG_CYCLES
|
||||
#define PP_CYCLE_CONV(x) (x)
|
||||
#define PP_CYCLE_STRING " cycles"
|
||||
#else
|
||||
#define PP_CYCLE_CONV(x) OS_CYCLES_TO_USEC(x)
|
||||
#define PP_CYCLE_STRING "us"
|
||||
#endif
|
||||
|
||||
struct PPTextFont {
|
||||
@@ -83,8 +94,12 @@ enum PPPages {
|
||||
PUPPYPRINT_PAGE_COLLISION,
|
||||
PUPPYPRINT_PAGE_LOG,
|
||||
PUPPYPRINT_PAGE_LEVEL_SELECT,
|
||||
PUPPYPRINT_PAGE_COVERAGE,
|
||||
#ifdef PUPPYCAM
|
||||
PUPPYPRINT_PAGE_CAMERA
|
||||
PUPPYPRINT_PAGE_CAMERA,
|
||||
#endif
|
||||
#ifdef BETTER_REVERB
|
||||
PUPPYPRINT_PAGE_BETTER_REVERB,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -130,7 +145,6 @@ extern void prepare_blank_box(void);
|
||||
extern void finish_blank_box(void);
|
||||
extern void render_blank_box(s32 x1, s32 y1, s32 x2, s32 y2, u8 r, u8 g, u8 b, u8 a);
|
||||
extern void render_blank_box_rounded(s32 x1, s32 y1, s32 x2, s32 y2, u8 r, u8 g, u8 b, u8 a);
|
||||
extern void append_puppyprint_log(const char *str, ...);
|
||||
extern char consoleLogTable[LOG_BUFFER_SIZE][255];
|
||||
extern void print_small_text_buffered(s32 x, s32 y, const char *str, u8 align, s32 amount, u8 font);
|
||||
extern void puppyprint_print_deferred(void);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "behavior_data.h"
|
||||
#include "string.h"
|
||||
#include "color_presets.h"
|
||||
#include "emutest.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "config/config_world.h"
|
||||
@@ -267,31 +268,26 @@ static struct RenderPhase sRenderPhases[] = {
|
||||
[RENDER_PHASE_ZEX_BEFORE_SILHOUETTE] = {
|
||||
.startLayer = LAYER_FIRST,
|
||||
.endLayer = LAYER_LAST_BEFORE_SILHOUETTE,
|
||||
.ucode = GRAPH_NODE_UCODE_DEFAULT,
|
||||
},
|
||||
|
||||
[RENDER_PHASE_ZEX_SILHOUETTE] = {
|
||||
.startLayer = LAYER_SILHOUETTE_FIRST,
|
||||
.endLayer = LAYER_SILHOUETTE_LAST,
|
||||
.ucode = GRAPH_NODE_UCODE_DEFAULT,
|
||||
},
|
||||
|
||||
[RENDER_PHASE_ZEX_NON_SILHOUETTE] = {
|
||||
.startLayer = LAYER_SILHOUETTE_FIRST,
|
||||
.endLayer = LAYER_SILHOUETTE_LAST,
|
||||
.ucode = GRAPH_NODE_UCODE_DEFAULT,
|
||||
},
|
||||
|
||||
[RENDER_PHASE_ZEX_OCCLUDE_SILHOUETTE] = {
|
||||
.startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST,
|
||||
.endLayer = LAYER_OCCLUDE_SILHOUETTE_LAST,
|
||||
.ucode = GRAPH_NODE_UCODE_DEFAULT,
|
||||
},
|
||||
|
||||
[RENDER_PHASE_ZEX_AFTER_SILHOUETTE] = {
|
||||
.startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST,
|
||||
.endLayer = LAYER_LAST,
|
||||
.ucode = GRAPH_NODE_UCODE_DEFAULT,
|
||||
},
|
||||
|
||||
#else
|
||||
@@ -319,7 +315,7 @@ void switch_ucode(s32 ucode) {
|
||||
break;
|
||||
case GRAPH_NODE_UCODE_REJ:
|
||||
// Use .rej Microcode, skip sub-pixel processing on console
|
||||
if (gIsConsole) {
|
||||
if (gEmulator & EMU_CONSOLE) {
|
||||
gSPLoadUcodeL(gDisplayListHead++, gspF3DLX2_Rej_fifo); // F3DLX2_Rej
|
||||
} else {
|
||||
gSPLoadUcodeL(gDisplayListHead++, gspF3DEX2_Rej_fifo); // F3DEX2_Rej
|
||||
@@ -571,6 +567,28 @@ void geo_process_perspective(struct GraphNodePerspective *node) {
|
||||
sAspectRatio = 4.0f / 3.0f; // 1.33333f
|
||||
#endif
|
||||
|
||||
// The reason this is not divided as an integer is to prevent an integer division.
|
||||
f32 vHalfFov = ( (f32) ((node->fov * 4096) + 8192) ) / 45.f;
|
||||
|
||||
// We need to account for aspect ratio changes by multiplying by the widescreen horizontal stretch
|
||||
// (normally 1.775).
|
||||
f32 hHalfFov = vHalfFov * sAspectRatio;
|
||||
|
||||
node->halfFovHorizontal = tans(hHalfFov);
|
||||
|
||||
#ifdef VERTICAL_CULLING
|
||||
node->halfFovVertical = tans(vHalfFov);
|
||||
#endif
|
||||
|
||||
#ifndef HORIZONTAL_CULLING_ON_EMULATOR
|
||||
// If an emulator is detected, use a large value for the half fov
|
||||
// horizontal value to account for viewport widescreen hacks.
|
||||
|
||||
if(!(gEmulator & EMU_CONSOLE)){
|
||||
node->halfFovHorizontal = 9999.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, node->near / WORLD_SCALE, node->far / WORLD_SCALE, 1.0f);
|
||||
gSPPerspNormalize(gDisplayListHead++, perspNorm);
|
||||
|
||||
@@ -597,7 +615,7 @@ static f32 get_dist_from_camera(Vec3f pos) {
|
||||
*/
|
||||
void geo_process_level_of_detail(struct GraphNodeLevelOfDetail *node) {
|
||||
#ifdef AUTO_LOD
|
||||
f32 distanceFromCam = gIsConsole ? get_dist_from_camera(gMatStack[gMatStackIndex][3]) : 50.0f;
|
||||
f32 distanceFromCam = (gEmulator & EMU_CONSOLE) ? get_dist_from_camera(gMatStack[gMatStackIndex][3]) : 50.0f;
|
||||
#else
|
||||
f32 distanceFromCam = get_dist_from_camera(gMatStack[gMatStackIndex][3]);
|
||||
#endif
|
||||
@@ -1020,23 +1038,24 @@ void geo_process_shadow(struct GraphNodeShadow *node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether an object is in view to determine whether it should be drawn.
|
||||
* Check whether an object is in view to determine whether if it should be drawn.
|
||||
* This is known as frustum culling.
|
||||
* It checks whether the object is far away, very close / behind the camera,
|
||||
* or horizontally out of view. It does not check whether it is vertically
|
||||
* out of view. It assumes a sphere of 300 units around the object's position
|
||||
* unless the object has a culling radius node that specifies otherwise.
|
||||
*
|
||||
* It checks whether the object is far away, very close or behind the camera and
|
||||
* vertically or horizontally out of view.
|
||||
* The radius used is specified in DEFAULT_CULLING_RADIUS unless the object
|
||||
* has a culling radius node that specifies another value.
|
||||
*
|
||||
* The matrix parameter should be the top of the matrix stack, which is the
|
||||
* object's transformation matrix times the camera 'look-at' matrix. The math
|
||||
* is counter-intuitive, but it checks column 3 (translation vector) of this
|
||||
* matrix to determine where the origin (0,0,0) in object space will be once
|
||||
* transformed to camera space (x+ = right, y+ = up, z = 'coming out the screen').
|
||||
*
|
||||
* In 3D graphics, you typically model the world as being moved in front of a
|
||||
* static camera instead of a moving camera through a static world, which in
|
||||
* this case simplifies calculations. Note that the perspective matrix is not
|
||||
* on the matrix stack, so there are still calculations with the fov to compute
|
||||
* the slope of the lines of the frustum.
|
||||
* the slope of the lines of the frustum, these are done once during geo_process_perspective.
|
||||
*
|
||||
* z-
|
||||
*
|
||||
@@ -1051,10 +1070,6 @@ void geo_process_shadow(struct GraphNodeShadow *node) {
|
||||
* Since (0,0,0) is unaffected by rotation, columns 0, 1 and 2 are ignored.
|
||||
*/
|
||||
s32 obj_is_in_view(struct GraphNodeObject *node) {
|
||||
if (node->node.flags & GRAPH_RENDER_INVISIBLE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct GraphNode *geo = node->sharedChild;
|
||||
|
||||
s16 cullingRadius;
|
||||
@@ -1062,43 +1077,38 @@ s32 obj_is_in_view(struct GraphNodeObject *node) {
|
||||
if (geo != NULL && geo->type == GRAPH_NODE_TYPE_CULLING_RADIUS) {
|
||||
cullingRadius = ((struct GraphNodeCullingRadius *) geo)->cullingRadius;
|
||||
} else {
|
||||
cullingRadius = 300;
|
||||
cullingRadius = DEFAULT_CULLING_RADIUS;
|
||||
}
|
||||
|
||||
// Don't render if the object is close to or behind the camera
|
||||
if (node->cameraToObject[2] > -100.0f + cullingRadius) {
|
||||
// Check whether the object is not too far away or too close / behind the camera.
|
||||
// This makes the HOLP not update when the camera is far away, and it
|
||||
// makes PU travel safe when the camera is locked on the main map.
|
||||
// If Mario were rendered with a depth over 65536 it would cause overflow
|
||||
// when converting the transformation matrix to a fixed point matrix.
|
||||
f32 cameraToObjectDepth = node->cameraToObject[2];
|
||||
|
||||
#define VALID_DEPTH_MIDDLE (-20100.f / 2.f)
|
||||
#define VALID_DEPTH_RANGE (19900 / 2.f)
|
||||
if (absf(cameraToObjectDepth - VALID_DEPTH_MIDDLE) >= VALID_DEPTH_RANGE + cullingRadius) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//! This makes the HOLP not update when the camera is far away, and it
|
||||
// makes PU travel safe when the camera is locked on the main map.
|
||||
// If Mario were rendered with a depth over 65536 it would cause overflow
|
||||
// when converting the transformation matrix to a fixed point matrix.
|
||||
if (node->cameraToObject[2] < -20000.0f - cullingRadius) {
|
||||
#ifdef VERTICAL_CULLING
|
||||
f32 vScreenEdge = -cameraToObjectDepth * gCurGraphNodeCamFrustum->halfFovVertical;
|
||||
|
||||
// Unlike with horizontal culling, we only check if the object is bellow the screen
|
||||
// to prevent shadows from being culled.
|
||||
if (node->cameraToObject[1] < -vScreenEdge - cullingRadius) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// half of the fov in in-game angle units instead of degrees
|
||||
s16 halfFov = (((((gCurGraphNodeCamFrustum->fov * sAspectRatio) / 2.0f) + 1.0f) * 32768.0f) / 180.0f) + 0.5f;
|
||||
#endif
|
||||
|
||||
f32 hScreenEdge = -cameraToObjectDepth * gCurGraphNodeCamFrustum->halfFovHorizontal;
|
||||
|
||||
f32 hScreenEdge = -node->cameraToObject[2] * tans(halfFov);
|
||||
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get
|
||||
// the amount of units between the center of the screen and the horizontal edge
|
||||
// given the distance from the object to the camera.
|
||||
|
||||
// This multiplication should really be performed on 4:3 as well,
|
||||
// but the issue will be more apparent on widescreen.
|
||||
// HackerSM64: This multiplication is done regardless of aspect ratio to fix object pop-in on the edges of the screen (which happens at 4:3 too)
|
||||
// hScreenEdge *= GFX_DIMENSIONS_ASPECT_RATIO;
|
||||
|
||||
// Check whether the object is horizontally in view
|
||||
if (node->cameraToObject[0] > hScreenEdge + cullingRadius) {
|
||||
if (absf(node->cameraToObject[0]) > hScreenEdge + cullingRadius) {
|
||||
return FALSE;
|
||||
}
|
||||
if (node->cameraToObject[0] < -hScreenEdge - cullingRadius) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1137,14 +1147,25 @@ void visualise_object_hitbox(struct Object *node) {
|
||||
*/
|
||||
void geo_process_object(struct Object *node) {
|
||||
if (node->header.gfx.areaIndex == gCurGraphNodeRoot->areaIndex) {
|
||||
if (node->header.gfx.throwMatrix != NULL) {
|
||||
mtxf_scale_vec3f(gMatStack[gMatStackIndex + 1], *node->header.gfx.throwMatrix, node->header.gfx.scale);
|
||||
} else if (node->header.gfx.node.flags & GRAPH_RENDER_BILLBOARD) {
|
||||
mtxf_billboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex],
|
||||
node->header.gfx.pos, node->header.gfx.scale, gCurGraphNodeCamera->roll);
|
||||
} else {
|
||||
mtxf_rotate_zxy_and_translate(gMatStack[gMatStackIndex + 1], node->header.gfx.pos, node->header.gfx.angle);
|
||||
mtxf_scale_vec3f(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex + 1], node->header.gfx.scale);
|
||||
s32 isInvisible = (node->header.gfx.node.flags & GRAPH_RENDER_INVISIBLE);
|
||||
s32 noThrowMatrix = (node->header.gfx.throwMatrix == NULL);
|
||||
|
||||
// If the throw matrix is null and the object is invisible, there is no need
|
||||
// to update billboarding, scale, rotation, etc.
|
||||
// This still updates translation since it is needed for sound.
|
||||
if (isInvisible && noThrowMatrix) {
|
||||
mtxf_translate(gMatStack[gMatStackIndex + 1], node->header.gfx.pos);
|
||||
}
|
||||
else{
|
||||
if (!noThrowMatrix) {
|
||||
mtxf_scale_vec3f(gMatStack[gMatStackIndex + 1], *node->header.gfx.throwMatrix, node->header.gfx.scale);
|
||||
} else if (node->header.gfx.node.flags & GRAPH_RENDER_BILLBOARD) {
|
||||
mtxf_billboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex],
|
||||
node->header.gfx.pos, node->header.gfx.scale, gCurGraphNodeCamera->roll);
|
||||
} else {
|
||||
mtxf_rotate_zxy_and_translate(gMatStack[gMatStackIndex + 1], node->header.gfx.pos, node->header.gfx.angle);
|
||||
mtxf_scale_vec3f(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex + 1], node->header.gfx.scale);
|
||||
}
|
||||
}
|
||||
|
||||
node->header.gfx.throwMatrix = &gMatStack[++gMatStackIndex];
|
||||
@@ -1154,7 +1175,8 @@ void geo_process_object(struct Object *node) {
|
||||
if (node->header.gfx.animInfo.curAnim != NULL) {
|
||||
geo_set_animation_globals(&node->header.gfx.animInfo, (node->header.gfx.node.flags & GRAPH_RENDER_HAS_ANIMATION) != 0);
|
||||
}
|
||||
if (obj_is_in_view(&node->header.gfx)) {
|
||||
|
||||
if (!isInvisible && obj_is_in_view(&node->header.gfx)) {
|
||||
gMatStackIndex--;
|
||||
inc_mat_stack();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "level_commands.h"
|
||||
#include "rumble_init.h"
|
||||
#include "config.h"
|
||||
#include "emutest.h"
|
||||
#ifdef SRAM
|
||||
#include "sram.h"
|
||||
#endif
|
||||
@@ -55,7 +56,6 @@ s8 gLevelToCourseNumTable[] = {
|
||||
STATIC_ASSERT(ARRAY_COUNT(gLevelToCourseNumTable) == LEVEL_COUNT - 1,
|
||||
"change this array if you are adding levels");
|
||||
#ifdef EEP
|
||||
#include "vc_check.h"
|
||||
#include "vc_ultra.h"
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ static s32 read_eeprom_data(void *buffer, s32 size) {
|
||||
block_until_rumble_pak_free();
|
||||
#endif
|
||||
triesLeft--;
|
||||
status = gIsVC
|
||||
status = (gEmulator & EMU_WIIVC)
|
||||
? osEepromLongReadVC(&gSIEventMesgQueue, offset, buffer, size)
|
||||
: osEepromLongRead (&gSIEventMesgQueue, offset, buffer, size);
|
||||
#if ENABLE_RUMBLE
|
||||
@@ -106,7 +106,7 @@ static s32 write_eeprom_data(void *buffer, s32 size) {
|
||||
block_until_rumble_pak_free();
|
||||
#endif
|
||||
triesLeft--;
|
||||
status = gIsVC
|
||||
status = (gEmulator & EMU_WIIVC)
|
||||
? osEepromLongWriteVC(&gSIEventMesgQueue, offset, buffer, size)
|
||||
: osEepromLongWrite (&gSIEventMesgQueue, offset, buffer, size);
|
||||
#if ENABLE_RUMBLE
|
||||
|
||||
+240
-188
@@ -13,150 +13,8 @@
|
||||
#include "segment2.h"
|
||||
#include "sm64.h"
|
||||
|
||||
u8 sTransitionColorFadeCount[4] = { 0 };
|
||||
u16 sTransitionTextureFadeCount[2] = { 0 };
|
||||
|
||||
s32 set_and_reset_transition_fade_timer(s8 fadeTimer, u8 transTime) {
|
||||
s32 reset = FALSE;
|
||||
|
||||
sTransitionColorFadeCount[fadeTimer]++;
|
||||
|
||||
if (sTransitionColorFadeCount[fadeTimer] == transTime) {
|
||||
sTransitionColorFadeCount[fadeTimer] = 0;
|
||||
sTransitionTextureFadeCount[fadeTimer] = 0;
|
||||
reset = TRUE;
|
||||
}
|
||||
return reset;
|
||||
}
|
||||
|
||||
u8 set_transition_color_fade_alpha(s8 fadeType, s8 fadeTimer, u8 transTime) {
|
||||
u8 time = 0;
|
||||
|
||||
switch (fadeType) {
|
||||
case COLOR_TRANS_FADE_INTO_COLOR:
|
||||
time = (f32) sTransitionColorFadeCount[fadeTimer] * 255.0 / (f32)(transTime - 1) + 0.5; // fade in
|
||||
break;
|
||||
case COLOR_TRANS_FADE_FROM_COLOR:
|
||||
time = (1.0 - sTransitionColorFadeCount[fadeTimer] / (f32)(transTime - 1)) * 255.0 + 0.5; // fade out
|
||||
break;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
Vtx *vertex_transition_color(struct WarpTransitionData *transData, u8 alpha) {
|
||||
Vtx *verts = alloc_display_list(4 * sizeof(*verts));
|
||||
u8 r = transData->red;
|
||||
u8 g = transData->green;
|
||||
u8 b = transData->blue;
|
||||
|
||||
if (verts != NULL) {
|
||||
make_vertex(verts, 0, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0, r, g, b, alpha);
|
||||
make_vertex(verts, 1, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0, r, g, b, alpha);
|
||||
make_vertex(verts, 2, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, r, g, b, alpha);
|
||||
make_vertex(verts, 3, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, r, g, b, alpha);
|
||||
}
|
||||
return verts;
|
||||
}
|
||||
|
||||
s32 dl_transition_color(s8 fadeTimer, u8 transTime, struct WarpTransitionData *transData, u8 alpha) {
|
||||
Vtx *verts = vertex_transition_color(transData, alpha);
|
||||
|
||||
if (verts != NULL) {
|
||||
gSPDisplayList(gDisplayListHead++, dl_proj_mtx_fullscreen);
|
||||
gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE);
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2);
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts), 4, 0);
|
||||
gSPDisplayList(gDisplayListHead++, dl_draw_quad_verts_0123);
|
||||
gSPDisplayList(gDisplayListHead++, dl_screen_transition_end);
|
||||
}
|
||||
return set_and_reset_transition_fade_timer(fadeTimer, transTime);
|
||||
}
|
||||
|
||||
s32 render_fade_transition_from_color(s8 fadeTimer, u8 transTime, struct WarpTransitionData *transData) {
|
||||
u8 alpha = set_transition_color_fade_alpha(COLOR_TRANS_FADE_FROM_COLOR, fadeTimer, transTime);
|
||||
|
||||
return dl_transition_color(fadeTimer, transTime, transData, alpha);
|
||||
}
|
||||
|
||||
s32 render_fade_transition_into_color(s8 fadeTimer, u8 transTime, struct WarpTransitionData *transData) {
|
||||
u8 alpha = set_transition_color_fade_alpha(COLOR_TRANS_FADE_INTO_COLOR, fadeTimer, transTime);
|
||||
|
||||
return dl_transition_color(fadeTimer, transTime, transData, alpha);
|
||||
}
|
||||
|
||||
s16 calc_tex_transition_radius(s8 fadeTimer, s8 transTime, struct WarpTransitionData *transData) {
|
||||
f32 texRadius = transData->endTexRadius - transData->startTexRadius;
|
||||
f32 radiusTime = sTransitionColorFadeCount[fadeTimer] * texRadius / (f32)(transTime - 1);
|
||||
f32 result = transData->startTexRadius + radiusTime;
|
||||
|
||||
return (s16)(result + 0.5f);
|
||||
}
|
||||
|
||||
f32 calc_tex_transition_time(s8 fadeTimer, s8 transTime, struct WarpTransitionData *transData) {
|
||||
f32 startX = transData->startTexX;
|
||||
f32 startY = transData->startTexY;
|
||||
f32 endX = transData->endTexX;
|
||||
f32 endY = transData->endTexY;
|
||||
f32 sqrtfXY = sqrtf((startX - endX) * (startX - endX) + (startY - endY) * (startY - endY));
|
||||
f32 result = (f32) sTransitionColorFadeCount[fadeTimer] * sqrtfXY / (f32)(transTime - 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
u16 convert_tex_transition_angle_to_pos(struct WarpTransitionData *transData) {
|
||||
f32 x = transData->endTexX - transData->startTexX;
|
||||
f32 y = transData->endTexY - transData->startTexY;
|
||||
|
||||
return atan2s(x, y);
|
||||
}
|
||||
|
||||
s16 center_tex_transition_x(struct WarpTransitionData *transData, f32 texTransTime, u16 texTransPos) {
|
||||
f32 x = transData->startTexX + coss(texTransPos) * texTransTime;
|
||||
|
||||
return (s16)(x + 0.5);
|
||||
}
|
||||
|
||||
s16 center_tex_transition_y(struct WarpTransitionData *transData, f32 texTransTime, u16 texTransPos) {
|
||||
f32 y = transData->startTexY + sins(texTransPos) * texTransTime;
|
||||
|
||||
return (s16)(y + 0.5);
|
||||
}
|
||||
|
||||
void make_tex_transition_vertex(Vtx *verts, s32 n, s8 fadeTimer, struct WarpTransitionData *transData, s16 centerTransX, s16 centerTransY,
|
||||
s16 texRadius1, s16 texRadius2, s16 tx, s16 ty) {
|
||||
u8 r = transData->red;
|
||||
u8 g = transData->green;
|
||||
u8 b = transData->blue;
|
||||
u16 zeroTimer = sTransitionTextureFadeCount[fadeTimer];
|
||||
f32 centerX = texRadius1 * coss(zeroTimer) - texRadius2 * sins(zeroTimer) + centerTransX;
|
||||
f32 centerY = texRadius1 * sins(zeroTimer) + texRadius2 * coss(zeroTimer) + centerTransY;
|
||||
s16 x = roundf(centerX);
|
||||
s16 y = roundf(centerY);
|
||||
|
||||
make_vertex(verts, n, x, y, -1, tx * 32, ty * 32, r, g, b, 255);
|
||||
}
|
||||
|
||||
void load_tex_transition_vertex(Vtx *verts, s8 fadeTimer, struct WarpTransitionData *transData, s16 centerTransX, s16 centerTransY,
|
||||
s16 texTransRadius, s8 transTexType) {
|
||||
switch (transTexType) {
|
||||
case TRANS_TYPE_MIRROR:
|
||||
make_tex_transition_vertex(verts, 0, fadeTimer, transData, centerTransX, centerTransY, -texTransRadius, -texTransRadius, -31, 63);
|
||||
make_tex_transition_vertex(verts, 1, fadeTimer, transData, centerTransX, centerTransY, texTransRadius, -texTransRadius, 31, 63);
|
||||
make_tex_transition_vertex(verts, 2, fadeTimer, transData, centerTransX, centerTransY, texTransRadius, texTransRadius, 31, 0);
|
||||
make_tex_transition_vertex(verts, 3, fadeTimer, transData, centerTransX, centerTransY, -texTransRadius, texTransRadius, -31, 0);
|
||||
break;
|
||||
case TRANS_TYPE_CLAMP:
|
||||
make_tex_transition_vertex(verts, 0, fadeTimer, transData, centerTransX, centerTransY, -texTransRadius, -texTransRadius, 0, 63);
|
||||
make_tex_transition_vertex(verts, 1, fadeTimer, transData, centerTransX, centerTransY, texTransRadius, -texTransRadius, 63, 63);
|
||||
make_tex_transition_vertex(verts, 2, fadeTimer, transData, centerTransX, centerTransY, texTransRadius, texTransRadius, 63, 0);
|
||||
make_tex_transition_vertex(verts, 3, fadeTimer, transData, centerTransX, centerTransY, -texTransRadius, texTransRadius, 0, 0);
|
||||
break;
|
||||
}
|
||||
make_tex_transition_vertex(verts, 4, fadeTimer, transData, centerTransX, centerTransY, -2000, -2000, 0, 0);
|
||||
make_tex_transition_vertex(verts, 5, fadeTimer, transData, centerTransX, centerTransY, 2000, -2000, 0, 0);
|
||||
make_tex_transition_vertex(verts, 6, fadeTimer, transData, centerTransX, centerTransY, 2000, 2000, 0, 0);
|
||||
make_tex_transition_vertex(verts, 7, fadeTimer, transData, centerTransX, centerTransY, -2000, 2000, 0, 0);
|
||||
}
|
||||
u8 sTransitionFadeTimer = 0;
|
||||
u16 sTransitionTextureAngle = 0;
|
||||
|
||||
void *sTextureTransitionID[] = {
|
||||
texture_transition_star_half,
|
||||
@@ -165,108 +23,302 @@ void *sTextureTransitionID[] = {
|
||||
texture_transition_bowser_half,
|
||||
};
|
||||
|
||||
s32 render_textured_transition(s8 fadeTimer, s8 transTime, struct WarpTransitionData *transData, s8 texID, s8 transTexType) {
|
||||
f32 texTransTime = calc_tex_transition_time(fadeTimer, transTime, transData);
|
||||
u16 texTransPos = convert_tex_transition_angle_to_pos(transData);
|
||||
s16 centerTransX = center_tex_transition_x(transData, texTransTime, texTransPos);
|
||||
s16 centerTransY = center_tex_transition_y(transData, texTransTime, texTransPos);
|
||||
s16 texTransRadius = calc_tex_transition_radius(fadeTimer, transTime, transData);
|
||||
Vtx *verts = alloc_display_list(8 * sizeof(*verts));
|
||||
s32 set_and_reset_transition_fade_timer(u8 transTime) {
|
||||
sTransitionFadeTimer++;
|
||||
|
||||
if (sTransitionFadeTimer >= transTime) {
|
||||
sTransitionFadeTimer = 0;
|
||||
sTransitionTextureAngle = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void make_tex_transition_vertex(Vtx *verts, s32 n, f32 centerTransX, f32 centerTransY,
|
||||
f32 vertX, f32 vertY, s16 tx, s16 ty) {
|
||||
// Rotate around the center
|
||||
s16 angle = sTransitionTextureAngle;
|
||||
f32 x = vertX * coss(angle) - vertY * sins(angle) + centerTransX;
|
||||
f32 y = vertX * sins(angle) + vertY * coss(angle) + centerTransY;
|
||||
|
||||
s16 roundedX = roundf(x);
|
||||
s16 roundedY = roundf(y);
|
||||
|
||||
make_simple_vertex(verts, n, roundedX, roundedY, -1, tx * 32, ty * 32);
|
||||
}
|
||||
|
||||
#define SOLID_COL_RADIUS 2000
|
||||
void make_tex_transition_vertices(Vtx *verts, f32 centerTransX, f32 centerTransY, f32 texTransRadius,
|
||||
s8 transTexType) {
|
||||
|
||||
s16 leftUV, rightUV, downUV, upUV;
|
||||
|
||||
if (transTexType == TRANS_TYPE_MIRROR) {
|
||||
leftUV = -31;
|
||||
rightUV = 31;
|
||||
downUV = 0;
|
||||
upUV = 63;
|
||||
}
|
||||
else {
|
||||
leftUV = 0;
|
||||
rightUV = 63;
|
||||
downUV = 0;
|
||||
upUV = 63;
|
||||
}
|
||||
|
||||
// Shape texture
|
||||
make_tex_transition_vertex(verts, 0, centerTransX, centerTransY, -texTransRadius, -texTransRadius, leftUV, upUV);
|
||||
make_tex_transition_vertex(verts, 1, centerTransX, centerTransY, texTransRadius, -texTransRadius, rightUV, upUV);
|
||||
make_tex_transition_vertex(verts, 2, centerTransX, centerTransY, texTransRadius, texTransRadius, rightUV, downUV);
|
||||
make_tex_transition_vertex(verts, 3, centerTransX, centerTransY, -texTransRadius, texTransRadius, leftUV, downUV);
|
||||
|
||||
// Solid color
|
||||
make_tex_transition_vertex(verts, 4, centerTransX, centerTransY, -SOLID_COL_RADIUS, -SOLID_COL_RADIUS, 0, 0);
|
||||
make_tex_transition_vertex(verts, 5, centerTransX, centerTransY, SOLID_COL_RADIUS, -SOLID_COL_RADIUS, 0, 0);
|
||||
make_tex_transition_vertex(verts, 6, centerTransX, centerTransY, SOLID_COL_RADIUS, SOLID_COL_RADIUS, 0, 0);
|
||||
make_tex_transition_vertex(verts, 7, centerTransX, centerTransY, -SOLID_COL_RADIUS, SOLID_COL_RADIUS, 0, 0);
|
||||
}
|
||||
|
||||
f32 calc_tex_transition_radius(s8 transTime, struct WarpTransitionData *transData) {
|
||||
f32 amount = (f32) sTransitionFadeTimer / (f32) (transTime - 1);
|
||||
|
||||
#ifdef EASE_IN_OUT_TRANSITIONS
|
||||
return smoothstep(transData->startTexRadius, transData->endTexRadius, amount);
|
||||
#else
|
||||
return lerpf(transData->startTexRadius, transData->endTexRadius, amount);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
f32 center_tex_transition_x(struct WarpTransitionData *transData, f32 posDistance, u16 texTransDir) {
|
||||
f32 x = transData->startTexX + coss(texTransDir) * posDistance;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
f32 center_tex_transition_y(struct WarpTransitionData *transData, f32 posDistance, u16 texTransDir) {
|
||||
f32 y = transData->startTexY + sins(texTransDir) * posDistance;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
f32 calc_tex_transition_pos_distance(s8 transTime, struct WarpTransitionData *transData) {
|
||||
f32 startX = transData->startTexX;
|
||||
f32 startY = transData->startTexY;
|
||||
f32 endX = transData->endTexX;
|
||||
f32 endY = transData->endTexY;
|
||||
|
||||
f32 distance = sqrtf(sqr(startX - endX) + sqr(startY - endY));
|
||||
|
||||
f32 amount = (f32) sTransitionFadeTimer / (f32)(transTime - 1);
|
||||
|
||||
return distance * amount;
|
||||
}
|
||||
|
||||
u16 calc_tex_transition_direction(struct WarpTransitionData *transData) {
|
||||
f32 x = transData->endTexX - transData->startTexX;
|
||||
f32 y = transData->endTexY - transData->startTexY;
|
||||
|
||||
return atan2s(x, y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called during render_screen_transition.
|
||||
* Handles shape transitions (such as the star, circle and Mario and bowser´s heads).
|
||||
*/
|
||||
s32 render_textured_transition(s8 transTime, struct WarpTransitionData *transData, s8 texID, s8 transTexType) {
|
||||
u16 texTransDir = calc_tex_transition_direction(transData);
|
||||
|
||||
f32 posDistance = calc_tex_transition_pos_distance(transTime, transData);
|
||||
f32 centerTransX = center_tex_transition_x(transData, posDistance, texTransDir);
|
||||
f32 centerTransY = center_tex_transition_y(transData, posDistance, texTransDir);
|
||||
|
||||
f32 texTransRadius = calc_tex_transition_radius(transTime, transData);
|
||||
Vtx *verts = alloc_display_list(8 * sizeof(Vtx));
|
||||
|
||||
|
||||
if (verts != NULL) {
|
||||
load_tex_transition_vertex(verts, fadeTimer, transData, centerTransX, centerTransY, texTransRadius, transTexType);
|
||||
make_tex_transition_vertices(verts, centerTransX, centerTransY, texTransRadius, transTexType);
|
||||
gSPDisplayList(gDisplayListHead++, dl_proj_mtx_fullscreen);
|
||||
gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE);
|
||||
|
||||
u8 r = transData->red;
|
||||
u8 g = transData->green;
|
||||
u8 b = transData->blue;
|
||||
gDPSetPrimColor(gDisplayListHead++, 0, 0, r, g, b, 255);
|
||||
|
||||
gDPSetCombineMode(gDisplayListHead++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2);
|
||||
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts), 8, 0);
|
||||
gSPDisplayList(gDisplayListHead++, dl_transition_draw_filled_region);
|
||||
gDPPipeSync(gDisplayListHead++);
|
||||
gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
|
||||
|
||||
gDPSetCombineLERP(gDisplayListHead++, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0,
|
||||
0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0);
|
||||
|
||||
#ifdef SHARP_TRANSITION_TEXTURES
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_TEX_EDGE, G_RM_AA_TEX_EDGE2);
|
||||
s32 textureType = G_IM_FMT_I;
|
||||
#else
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2);
|
||||
s32 textureType = G_IM_FMT_IA;
|
||||
#endif
|
||||
|
||||
gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP);
|
||||
|
||||
switch (transTexType) {
|
||||
case TRANS_TYPE_MIRROR:
|
||||
gDPLoadTextureBlock(gDisplayListHead++, sTextureTransitionID[texID], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0,
|
||||
G_TX_WRAP | G_TX_MIRROR, G_TX_WRAP | G_TX_MIRROR, 5, 6, G_TX_NOLOD, G_TX_NOLOD);
|
||||
break;
|
||||
case TRANS_TYPE_CLAMP:
|
||||
gDPLoadTextureBlock(gDisplayListHead++, sTextureTransitionID[texID], G_IM_FMT_IA, G_IM_SIZ_8b, 64, 64, 0,
|
||||
G_TX_CLAMP, G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD);
|
||||
break;
|
||||
case TRANS_TYPE_MIRROR:
|
||||
gDPLoadTextureBlock(gDisplayListHead++, sTextureTransitionID[texID], textureType, G_IM_SIZ_8b, 32, 64, 0,
|
||||
G_TX_WRAP | G_TX_MIRROR, G_TX_WRAP | G_TX_MIRROR, 5, 6, G_TX_NOLOD, G_TX_NOLOD);
|
||||
break;
|
||||
case TRANS_TYPE_CLAMP:
|
||||
gDPLoadTextureBlock(gDisplayListHead++, sTextureTransitionID[texID], textureType, G_IM_SIZ_8b, 64, 64, 0,
|
||||
G_TX_CLAMP, G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD);
|
||||
break;
|
||||
}
|
||||
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts), 4, 0);
|
||||
gSPDisplayList(gDisplayListHead++, dl_draw_quad_verts_0123);
|
||||
gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF);
|
||||
gSPDisplayList(gDisplayListHead++, dl_screen_transition_end);
|
||||
sTransitionTextureFadeCount[fadeTimer] += transData->texTimer;
|
||||
sTransitionTextureAngle += transData->angleSpeed;
|
||||
}
|
||||
return set_and_reset_transition_fade_timer(fadeTimer, transTime);
|
||||
return set_and_reset_transition_fade_timer(transTime);
|
||||
}
|
||||
|
||||
s32 render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct WarpTransitionData *transData) {
|
||||
Vtx *vertex_transition_color() {
|
||||
Vtx *verts = alloc_display_list(4 * sizeof(Vtx));
|
||||
|
||||
if (verts != NULL) {
|
||||
make_simple_vertex(verts, 0, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0);
|
||||
make_simple_vertex(verts, 1, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0);
|
||||
make_simple_vertex(verts, 2, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0);
|
||||
make_simple_vertex(verts, 3, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0);
|
||||
}
|
||||
return verts;
|
||||
}
|
||||
|
||||
s32 dl_transition_color(u8 transTime, struct WarpTransitionData *transData, u8 alpha) {
|
||||
Vtx *verts = vertex_transition_color();
|
||||
|
||||
if (verts != NULL) {
|
||||
u8 r = transData->red;
|
||||
u8 g = transData->green;
|
||||
u8 b = transData->blue;
|
||||
gDPSetPrimColor(gDisplayListHead++, 0, 0, r, g, b, alpha);
|
||||
|
||||
gSPDisplayList(gDisplayListHead++, dl_proj_mtx_fullscreen);
|
||||
gDPSetCombineMode(gDisplayListHead++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
|
||||
gDPSetRenderMode(gDisplayListHead++, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2);
|
||||
gSPVertex(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(verts), 4, 0);
|
||||
gSPDisplayList(gDisplayListHead++, dl_draw_quad_verts_0123);
|
||||
gSPDisplayList(gDisplayListHead++, dl_screen_transition_end);
|
||||
}
|
||||
return set_and_reset_transition_fade_timer(transTime);
|
||||
}
|
||||
|
||||
u8 set_transition_color_fade_alpha(s8 fadeType, u8 transTime) {
|
||||
u8 time = 0;
|
||||
f32 amount = (f32) sTransitionFadeTimer / (f32) (transTime - 1);
|
||||
switch (fadeType) {
|
||||
case COLOR_TRANS_FADE_INTO_COLOR:
|
||||
time = lerpf(0.f, 255.0f, amount);
|
||||
break;
|
||||
case COLOR_TRANS_FADE_FROM_COLOR:
|
||||
time = lerpf(255.0f, 0.f, amount);
|
||||
break;
|
||||
}
|
||||
return roundf(time);
|
||||
}
|
||||
|
||||
s32 render_fade_transition_from_color(u8 transTime, struct WarpTransitionData *transData) {
|
||||
u8 alpha = set_transition_color_fade_alpha(COLOR_TRANS_FADE_FROM_COLOR, transTime);
|
||||
|
||||
return dl_transition_color(transTime, transData, alpha);
|
||||
}
|
||||
|
||||
s32 render_fade_transition_into_color(u8 transTime, struct WarpTransitionData *transData) {
|
||||
u8 alpha = set_transition_color_fade_alpha(COLOR_TRANS_FADE_INTO_COLOR, transTime);
|
||||
|
||||
return dl_transition_color(transTime, transData, alpha);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called during rendering if gWarpTransition.isActive is on.
|
||||
* Handles solid colour transitions and shape transitions
|
||||
* (such as the star, circle and Mario and bowser´s heads).
|
||||
*/
|
||||
s32 render_screen_transition(s8 transType, u8 transTime, struct WarpTransitionData *transData) {
|
||||
switch (transType) {
|
||||
case WARP_TRANSITION_FADE_FROM_COLOR:
|
||||
return render_fade_transition_from_color(fadeTimer, transTime, transData);
|
||||
return render_fade_transition_from_color(transTime, transData);
|
||||
break;
|
||||
case WARP_TRANSITION_FADE_INTO_COLOR:
|
||||
return render_fade_transition_into_color(fadeTimer, transTime, transData);
|
||||
return render_fade_transition_into_color(transTime, transData);
|
||||
break;
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_STAR:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
case WARP_TRANSITION_FADE_INTO_STAR:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_STAR, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_CIRCLE:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
case WARP_TRANSITION_FADE_INTO_CIRCLE:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_CIRCLE, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_MARIO:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP);
|
||||
break;
|
||||
case WARP_TRANSITION_FADE_INTO_MARIO:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_MARIO, TRANS_TYPE_CLAMP);
|
||||
break;
|
||||
|
||||
case WARP_TRANSITION_FADE_FROM_BOWSER:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
case WARP_TRANSITION_FADE_INTO_BOWSER:
|
||||
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
|
||||
return render_textured_transition(transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Gfx *render_cannon_circle_base(void) {
|
||||
#ifdef WIDESCREEN
|
||||
Vtx *verts = alloc_display_list(8 * sizeof(*verts));
|
||||
Gfx *dlist = alloc_display_list(20 * sizeof(*dlist));
|
||||
Vtx *verts = alloc_display_list(8 * sizeof(Vtx));
|
||||
Gfx *dlist = alloc_display_list(20 * sizeof(Gfx));
|
||||
#else
|
||||
Vtx *verts = alloc_display_list(4 * sizeof(*verts));
|
||||
Gfx *dlist = alloc_display_list(16 * sizeof(*dlist));
|
||||
Vtx *verts = alloc_display_list(4 * sizeof(Vtx));
|
||||
Gfx *dlist = alloc_display_list(16 * sizeof(Gfx));
|
||||
#endif
|
||||
Gfx *g = dlist;
|
||||
|
||||
if (verts != NULL && dlist != NULL) {
|
||||
make_vertex(verts, 0, 0, 0, -1, -1152, 1824, 0, 0, 0, 255);
|
||||
make_vertex(verts, 1, SCREEN_WIDTH, 0, -1, 1152, 1824, 0, 0, 0, 255);
|
||||
make_vertex(verts, 2, SCREEN_WIDTH, SCREEN_HEIGHT, -1, 1152, 192, 0, 0, 0, 255);
|
||||
make_vertex(verts, 3, 0, SCREEN_HEIGHT, -1, -1152, 192, 0, 0, 0, 255);
|
||||
gDPSetPrimColor(gDisplayListHead++, 0, 0, 0, 0, 0, 255);
|
||||
|
||||
make_simple_vertex(verts, 0, 0, 0, -1, -1152, 1824);
|
||||
make_simple_vertex(verts, 1, SCREEN_WIDTH, 0, -1, 1152, 1824);
|
||||
make_simple_vertex(verts, 2, SCREEN_WIDTH, SCREEN_HEIGHT, -1, 1152, 192);
|
||||
make_simple_vertex(verts, 3, 0, SCREEN_HEIGHT, -1, -1152, 192);
|
||||
|
||||
#ifdef WIDESCREEN
|
||||
// Render black rectangles outside the 4:3 area.
|
||||
make_vertex(verts, 4, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255);
|
||||
make_vertex(verts, 5, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0, 0, 0, 0, 255);
|
||||
make_vertex(verts, 6, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, 0, 0, 0, 255);
|
||||
make_vertex(verts, 7, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0, 0, 0, 0, 255);
|
||||
make_simple_vertex(verts, 4, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), 0, -1, 0, 0, 0);
|
||||
make_simple_vertex(verts, 5, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), 0, -1, 0, 0, 0);
|
||||
make_simple_vertex(verts, 6, GFX_DIMENSIONS_FROM_RIGHT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0);
|
||||
make_simple_vertex(verts, 7, GFX_DIMENSIONS_FROM_LEFT_EDGE(0), SCREEN_HEIGHT, -1, 0, 0);
|
||||
#endif
|
||||
|
||||
gSPDisplayList(g++, dl_proj_mtx_fullscreen);
|
||||
gDPSetCombineMode(g++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
|
||||
gDPSetCombineMode(g++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
|
||||
gDPSetTextureFilter(g++, G_TF_BILERP);
|
||||
gDPLoadTextureBlock(g++, sTextureTransitionID[TEX_TRANS_CIRCLE], G_IM_FMT_IA, G_IM_SIZ_8b, 32, 64, 0,
|
||||
G_TX_WRAP | G_TX_MIRROR, G_TX_WRAP | G_TX_MIRROR, 5, 6, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
@@ -24,7 +24,7 @@ enum ColorTransitionFade {
|
||||
COLOR_TRANS_FADE_FROM_COLOR,
|
||||
};
|
||||
|
||||
s32 render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct WarpTransitionData *transData);
|
||||
s32 render_screen_transition(s8 transType, u8 transTime, struct WarpTransitionData *transData);
|
||||
Gfx *geo_cannon_circle_base(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx);
|
||||
|
||||
#endif // SCREEN_TRANSITION_H
|
||||
@@ -54,6 +54,8 @@ extern Gfx dl_ia_text_tex_settings[];
|
||||
extern Gfx dl_rgba16_load_tex_block[];
|
||||
extern void *main_credits_font_lut[];
|
||||
extern Texture *main_hud_camera_lut[6];
|
||||
extern Gfx dl_shade_screen_begin[];
|
||||
extern Gfx dl_shade_screen_end[];
|
||||
extern Gfx dl_draw_text_bg_box[];
|
||||
extern Gfx dl_draw_triangle[];
|
||||
extern void *seg2_dialog_table[];
|
||||
|
||||
@@ -36,7 +36,11 @@ static u16 sCurrentCapMusic = MUSIC_NONE;
|
||||
#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS
|
||||
static u8 sPlayingInfiniteStairs = FALSE;
|
||||
#endif
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
static s16 sSoundMenuModeToSoundMode[3] = { SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET };
|
||||
#else
|
||||
static s16 sSoundMenuModeToSoundMode[2] = { SOUND_MODE_STEREO, SOUND_MODE_MONO };
|
||||
#endif
|
||||
// Only the 20th array element is used.
|
||||
static u32 sMenuSoundsExtra[] = {
|
||||
SOUND_MOVING_TERRAIN_SLIDE + (0 << 16),
|
||||
|
||||
@@ -94,6 +94,7 @@ void clear_object_lists(struct ObjectNode *objLists) {
|
||||
void unload_object(struct Object *obj) {
|
||||
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
obj->prevObj = NULL;
|
||||
obj->oFloor = NULL;
|
||||
|
||||
obj->header.gfx.throwMatrix = NULL;
|
||||
stop_sounds_from_source(obj->header.gfx.cameraToObject);
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#include "vc_check.h"
|
||||
|
||||
u8 gIsVC = FALSE;
|
||||
|
||||
// literally return what was passed
|
||||
f32 round_double_to_float(f64 v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef VC_CHECK_H
|
||||
#define VC_CHECK_H
|
||||
|
||||
#include "sm64.h"
|
||||
|
||||
extern u8 gIsVC;
|
||||
|
||||
// This function must not be inlined by the compiler so I move it to a different C file
|
||||
f32 round_double_to_float(f64);
|
||||
|
||||
/*
|
||||
* This check forces RTZ bug on vc
|
||||
* If console is N64/adequate Emu round-to-nearest (RTN) rounding mode is used
|
||||
* If console is VC round-to-zero (RTZ) mode is used
|
||||
*
|
||||
* The double value 0.9999999999999999 used is 0x3FEFFFFFFFFFFFFF in binary
|
||||
* Exponent=01111111110, Mantissa=1111111111111111111111111111111111111111111111111111
|
||||
* RTZ will output not 1.0f, RTN will output exactly 1.0f
|
||||
*/
|
||||
#define IS_VC() (1.0f != round_double_to_float(0.9999999999999999))
|
||||
|
||||
#endif
|
||||
+26
-1
@@ -119,7 +119,11 @@ unsigned char textCopyFileButton[] = { TEXT_COPY_FILE_BUTTON };
|
||||
|
||||
unsigned char textEraseFileButton[] = { TEXT_ERASE_FILE_BUTTON };
|
||||
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
unsigned char textSoundModes[][8] = { { TEXT_STEREO }, { TEXT_MONO }, { TEXT_HEADSET } };
|
||||
#else
|
||||
unsigned char textSoundModes[][8] = { { TEXT_STEREO }, { TEXT_MONO } };
|
||||
#endif
|
||||
|
||||
#if MULTILANG
|
||||
unsigned char textLanguageSelect[][17] = { { TEXT_LANGUAGE_SELECT } };
|
||||
@@ -788,6 +792,7 @@ void check_erase_menu_clicked_buttons(struct Object *eraseButton) {
|
||||
* Render buttons for the sound mode menu.
|
||||
*/
|
||||
void render_sound_mode_menu_buttons(struct Object *soundModeButton) {
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
// Stereo option button
|
||||
sMainMenuButtons[MENU_BUTTON_STEREO] = spawn_object_rel_with_rot(
|
||||
soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, 533, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0);
|
||||
@@ -800,6 +805,16 @@ void render_sound_mode_menu_buttons(struct Object *soundModeButton) {
|
||||
sMainMenuButtons[MENU_BUTTON_HEADSET] = spawn_object_rel_with_rot(
|
||||
soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, -533, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0);
|
||||
sMainMenuButtons[MENU_BUTTON_HEADSET]->oMenuButtonScale = MENU_BUTTON_SCALE;
|
||||
#else
|
||||
// Stereo option button
|
||||
sMainMenuButtons[MENU_BUTTON_STEREO] = spawn_object_rel_with_rot(
|
||||
soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, 355, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0);
|
||||
sMainMenuButtons[MENU_BUTTON_STEREO]->oMenuButtonScale = MENU_BUTTON_SCALE;
|
||||
// Mono option button
|
||||
sMainMenuButtons[MENU_BUTTON_MONO] = spawn_object_rel_with_rot(
|
||||
soundModeButton, MODEL_MAIN_MENU_GENERIC_BUTTON, bhvMenuButton, -355, SOUND_BUTTON_Y, -100, 0x0, -0x8000, 0x0);
|
||||
sMainMenuButtons[MENU_BUTTON_MONO]->oMenuButtonScale = MENU_BUTTON_SCALE;
|
||||
#endif
|
||||
|
||||
#if MULTILANG
|
||||
// English option button
|
||||
@@ -841,8 +856,12 @@ void check_sound_mode_menu_clicked_buttons(struct Object *soundModeButton) {
|
||||
if (check_clicked_button(buttonX, buttonY, 22.0f) == TRUE) {
|
||||
// If sound mode button clicked, select it and define sound mode
|
||||
// The check will always be true because of the group configured above (In JP & US)
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
if (buttonID == MENU_BUTTON_STEREO || buttonID == MENU_BUTTON_MONO
|
||||
|| buttonID == MENU_BUTTON_HEADSET) {
|
||||
#else
|
||||
if (buttonID == MENU_BUTTON_STEREO || buttonID == MENU_BUTTON_MONO) {
|
||||
#endif
|
||||
if (soundModeButton->oMenuButtonActionPhase == SOUND_MODE_PHASE_MAIN) {
|
||||
play_sound(SOUND_MENU_CLICK_FILE_SELECT, gGlobalSoundSource);
|
||||
#if ENABLE_RUMBLE
|
||||
@@ -1150,7 +1169,9 @@ void bhv_menu_button_manager_loop(void) {
|
||||
// exiting the Options menu, as a result they added a return button
|
||||
case MENU_BUTTON_STEREO: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_STEREO ]); break;
|
||||
case MENU_BUTTON_MONO: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_MONO ]); break;
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
case MENU_BUTTON_HEADSET: return_to_main_menu(MENU_BUTTON_SOUND_MODE, sMainMenuButtons[MENU_BUTTON_HEADSET]); break;
|
||||
#endif
|
||||
}
|
||||
|
||||
sClickPos[0] = -10000;
|
||||
@@ -1782,7 +1803,11 @@ void print_sound_mode_menu_strings(void) {
|
||||
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
|
||||
|
||||
// Print sound mode names
|
||||
for (mode = 0, textX = 90; mode < 3; textX += 70, mode++) {
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
for (mode = 0, textX = 87; mode < ARRAY_COUNT(textSoundModes); textX += 74, mode++) {
|
||||
#else
|
||||
for (mode = 0, textX = 111; mode < ARRAY_COUNT(textSoundModes); textX += 99, mode++) {
|
||||
#endif
|
||||
if (mode == sSoundMode) {
|
||||
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, sTextBaseAlpha);
|
||||
} else {
|
||||
|
||||
@@ -81,7 +81,9 @@ enum MenuButtonTypes {
|
||||
MENU_BUTTON_OPTION_MIN,
|
||||
MENU_BUTTON_STEREO = MENU_BUTTON_OPTION_MIN,
|
||||
MENU_BUTTON_MONO,
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
MENU_BUTTON_HEADSET,
|
||||
#endif
|
||||
|
||||
#if MULTILANG
|
||||
// Language Menu
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# Makefile for s2d_engine.a
|
||||
|
||||
TARGET = libs2d_engine.a
|
||||
|
||||
default: all
|
||||
|
||||
BUILD_DIR ?= build
|
||||
DUMMY != mkdir -p $(BUILD_DIR)
|
||||
|
||||
C_FILES = $(wildcard ./*.c)
|
||||
O_FILES = $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
|
||||
INCLUDE_BASE := ../../
|
||||
I_DIRS = src include/n64/PR include/n64 include/libc include .
|
||||
FULL_I_DIRS = $(addprefix $(INCLUDE_BASE),$(I_DIRS))
|
||||
I_FLAGS = $(foreach i,$(FULL_I_DIRS),-I$(i))
|
||||
|
||||
TARGET_CFLAGS = -nostdinc -I include/libc -DTARGET_N64 -DF3DEX_GBI_2
|
||||
CFLAGS := -Wall $(TARGET_CFLAGS) $(I_FLAGS) -fno-stack-protector -march=vr4300 -mtune=vr4300 -mfix4300 -mabi=32 -mno-shared -G 0 -fno-PIC -mno-abicalls -fno-zero-initialized-in-bss -fno-toplevel-reorder -Wno-missing-braces
|
||||
|
||||
|
||||
all: $(BUILD_DIR)/$(TARGET)
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
|
||||
COPY_DIR := none
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifeq ($(COPY_DIR),none)
|
||||
$(error S2DEX Text Engine: No COPY_DIR defined!)
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/$(TARGET): $(O_FILES)
|
||||
$(AR) rcs -o $@ $(O_FILES)
|
||||
cp $@ $(COPY_DIR)
|
||||
|
||||
$(BUILD_DIR)/%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#include <ultra64.h>
|
||||
#include "mtx.h"
|
||||
@@ -62,7 +62,7 @@ void texrect(int x, int y, float scale) {
|
||||
qs510(1.0f / myScale), qs510(1.0f / myScale));
|
||||
}
|
||||
|
||||
void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
|
||||
void draw_f3d_dropshadow(char c, int x, int y, UNUSED uObjMtx *ds) {
|
||||
setup_f3d_texture(c);
|
||||
|
||||
if (s2d_red != 0
|
||||
@@ -81,7 +81,7 @@ void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
|
||||
}
|
||||
}
|
||||
|
||||
void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt) {
|
||||
void draw_f3d_glyph(char c, int x, int y, UNUSED uObjMtx *mt) {
|
||||
setup_f3d_texture(c);
|
||||
|
||||
texrect(x, y, myScale);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,136 @@
|
||||
#include <PR/ultratypes.h>
|
||||
#include <PR/gs2dex.h>
|
||||
extern uObjTxtr ifunny_tex[];
|
||||
extern uObjMtx ifunny_mtx;
|
||||
extern uObjSprite ifunny_obj;
|
||||
extern void call_ifunny_sprite_dl(int idx, int x, int y, uObjMtx *buffer, int buf_idx);
|
||||
extern u8 ifunny_tex_0[];
|
||||
extern u8 ifunny_tex_1[];
|
||||
extern u8 ifunny_tex_2[];
|
||||
extern u8 ifunny_tex_3[];
|
||||
extern u8 ifunny_tex_4[];
|
||||
extern u8 ifunny_tex_5[];
|
||||
extern u8 ifunny_tex_6[];
|
||||
extern u8 ifunny_tex_7[];
|
||||
extern u8 ifunny_tex_8[];
|
||||
extern u8 ifunny_tex_9[];
|
||||
extern u8 ifunny_tex_10[];
|
||||
extern u8 ifunny_tex_11[];
|
||||
extern u8 ifunny_tex_12[];
|
||||
extern u8 ifunny_tex_13[];
|
||||
extern u8 ifunny_tex_14[];
|
||||
extern u8 ifunny_tex_15[];
|
||||
extern u8 ifunny_tex_16[];
|
||||
extern u8 ifunny_tex_17[];
|
||||
extern u8 ifunny_tex_18[];
|
||||
extern u8 ifunny_tex_19[];
|
||||
extern u8 ifunny_tex_20[];
|
||||
extern u8 ifunny_tex_21[];
|
||||
extern u8 ifunny_tex_22[];
|
||||
extern u8 ifunny_tex_23[];
|
||||
extern u8 ifunny_tex_24[];
|
||||
extern u8 ifunny_tex_25[];
|
||||
extern u8 ifunny_tex_26[];
|
||||
extern u8 ifunny_tex_27[];
|
||||
extern u8 ifunny_tex_28[];
|
||||
extern u8 ifunny_tex_29[];
|
||||
extern u8 ifunny_tex_30[];
|
||||
extern u8 ifunny_tex_31[];
|
||||
extern u8 ifunny_tex_32[];
|
||||
extern u8 ifunny_tex_33[];
|
||||
extern u8 ifunny_tex_34[];
|
||||
extern u8 ifunny_tex_35[];
|
||||
extern u8 ifunny_tex_36[];
|
||||
extern u8 ifunny_tex_37[];
|
||||
extern u8 ifunny_tex_38[];
|
||||
extern u8 ifunny_tex_39[];
|
||||
extern u8 ifunny_tex_40[];
|
||||
extern u8 ifunny_tex_41[];
|
||||
extern u8 ifunny_tex_42[];
|
||||
extern u8 ifunny_tex_43[];
|
||||
extern u8 ifunny_tex_44[];
|
||||
extern u8 ifunny_tex_45[];
|
||||
extern u8 ifunny_tex_46[];
|
||||
extern u8 ifunny_tex_47[];
|
||||
extern u8 ifunny_tex_48[];
|
||||
extern u8 ifunny_tex_49[];
|
||||
extern u8 ifunny_tex_50[];
|
||||
extern u8 ifunny_tex_51[];
|
||||
extern u8 ifunny_tex_52[];
|
||||
extern u8 ifunny_tex_53[];
|
||||
extern u8 ifunny_tex_54[];
|
||||
extern u8 ifunny_tex_55[];
|
||||
extern u8 ifunny_tex_56[];
|
||||
extern u8 ifunny_tex_57[];
|
||||
extern u8 ifunny_tex_58[];
|
||||
extern u8 ifunny_tex_59[];
|
||||
extern u8 ifunny_tex_60[];
|
||||
extern u8 ifunny_tex_61[];
|
||||
extern u8 ifunny_tex_62[];
|
||||
extern u8 ifunny_tex_63[];
|
||||
extern u8 ifunny_tex_64[];
|
||||
extern u8 ifunny_tex_65[];
|
||||
extern u8 ifunny_tex_66[];
|
||||
extern u8 ifunny_tex_67[];
|
||||
extern u8 ifunny_tex_68[];
|
||||
extern u8 ifunny_tex_69[];
|
||||
extern u8 ifunny_tex_70[];
|
||||
extern u8 ifunny_tex_71[];
|
||||
extern u8 ifunny_tex_72[];
|
||||
extern u8 ifunny_tex_73[];
|
||||
extern u8 ifunny_tex_74[];
|
||||
extern u8 ifunny_tex_75[];
|
||||
extern u8 ifunny_tex_76[];
|
||||
extern u8 ifunny_tex_77[];
|
||||
extern u8 ifunny_tex_78[];
|
||||
extern u8 ifunny_tex_79[];
|
||||
extern u8 ifunny_tex_80[];
|
||||
extern u8 ifunny_tex_81[];
|
||||
extern u8 ifunny_tex_82[];
|
||||
extern u8 ifunny_tex_83[];
|
||||
extern u8 ifunny_tex_84[];
|
||||
extern u8 ifunny_tex_85[];
|
||||
extern u8 ifunny_tex_86[];
|
||||
extern u8 ifunny_tex_87[];
|
||||
extern u8 ifunny_tex_88[];
|
||||
extern u8 ifunny_tex_89[];
|
||||
extern u8 ifunny_tex_90[];
|
||||
extern u8 ifunny_tex_91[];
|
||||
extern u8 ifunny_tex_92[];
|
||||
extern u8 ifunny_tex_93[];
|
||||
extern u8 ifunny_tex_94[];
|
||||
extern u8 ifunny_tex_95[];
|
||||
extern u8 ifunny_tex_96[];
|
||||
extern u8 ifunny_tex_97[];
|
||||
extern u8 ifunny_tex_98[];
|
||||
extern u8 ifunny_tex_99[];
|
||||
extern u8 ifunny_tex_100[];
|
||||
extern u8 ifunny_tex_101[];
|
||||
extern u8 ifunny_tex_102[];
|
||||
extern u8 ifunny_tex_103[];
|
||||
extern u8 ifunny_tex_104[];
|
||||
extern u8 ifunny_tex_105[];
|
||||
extern u8 ifunny_tex_106[];
|
||||
extern u8 ifunny_tex_107[];
|
||||
extern u8 ifunny_tex_108[];
|
||||
extern u8 ifunny_tex_109[];
|
||||
extern u8 ifunny_tex_110[];
|
||||
extern u8 ifunny_tex_111[];
|
||||
extern u8 ifunny_tex_112[];
|
||||
extern u8 ifunny_tex_113[];
|
||||
extern u8 ifunny_tex_114[];
|
||||
extern u8 ifunny_tex_115[];
|
||||
extern u8 ifunny_tex_116[];
|
||||
extern u8 ifunny_tex_117[];
|
||||
extern u8 ifunny_tex_118[];
|
||||
extern u8 ifunny_tex_119[];
|
||||
extern u8 ifunny_tex_120[];
|
||||
extern u8 ifunny_tex_121[];
|
||||
extern u8 ifunny_tex_122[];
|
||||
extern u8 ifunny_tex_123[];
|
||||
extern u8 ifunny_tex_124[];
|
||||
extern u8 ifunny_tex_125[];
|
||||
extern u8 ifunny_tex_126[];
|
||||
extern u8 ifunny_tex_127[];
|
||||
|
||||
extern uObjSprite ifunny_obj_dropshadow;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,136 @@
|
||||
#include <PR/ultratypes.h>
|
||||
#include <PR/gs2dex.h>
|
||||
extern uObjTxtr newsm64_tex[];
|
||||
extern uObjMtx newsm64_mtx;
|
||||
extern uObjSprite newsm64_obj;
|
||||
extern void call_newsm64_sprite_dl(int idx, int x, int y, uObjMtx *buffer, int buf_idx);
|
||||
extern u8 newsm64_tex_0[];
|
||||
extern u8 newsm64_tex_1[];
|
||||
extern u8 newsm64_tex_2[];
|
||||
extern u8 newsm64_tex_3[];
|
||||
extern u8 newsm64_tex_4[];
|
||||
extern u8 newsm64_tex_5[];
|
||||
extern u8 newsm64_tex_6[];
|
||||
extern u8 newsm64_tex_7[];
|
||||
extern u8 newsm64_tex_8[];
|
||||
extern u8 newsm64_tex_9[];
|
||||
extern u8 newsm64_tex_10[];
|
||||
extern u8 newsm64_tex_11[];
|
||||
extern u8 newsm64_tex_12[];
|
||||
extern u8 newsm64_tex_13[];
|
||||
extern u8 newsm64_tex_14[];
|
||||
extern u8 newsm64_tex_15[];
|
||||
extern u8 newsm64_tex_16[];
|
||||
extern u8 newsm64_tex_17[];
|
||||
extern u8 newsm64_tex_18[];
|
||||
extern u8 newsm64_tex_19[];
|
||||
extern u8 newsm64_tex_20[];
|
||||
extern u8 newsm64_tex_21[];
|
||||
extern u8 newsm64_tex_22[];
|
||||
extern u8 newsm64_tex_23[];
|
||||
extern u8 newsm64_tex_24[];
|
||||
extern u8 newsm64_tex_25[];
|
||||
extern u8 newsm64_tex_26[];
|
||||
extern u8 newsm64_tex_27[];
|
||||
extern u8 newsm64_tex_28[];
|
||||
extern u8 newsm64_tex_29[];
|
||||
extern u8 newsm64_tex_30[];
|
||||
extern u8 newsm64_tex_31[];
|
||||
extern u8 newsm64_tex_32[];
|
||||
extern u8 newsm64_tex_33[];
|
||||
extern u8 newsm64_tex_34[];
|
||||
extern u8 newsm64_tex_35[];
|
||||
extern u8 newsm64_tex_36[];
|
||||
extern u8 newsm64_tex_37[];
|
||||
extern u8 newsm64_tex_38[];
|
||||
extern u8 newsm64_tex_39[];
|
||||
extern u8 newsm64_tex_40[];
|
||||
extern u8 newsm64_tex_41[];
|
||||
extern u8 newsm64_tex_42[];
|
||||
extern u8 newsm64_tex_43[];
|
||||
extern u8 newsm64_tex_44[];
|
||||
extern u8 newsm64_tex_45[];
|
||||
extern u8 newsm64_tex_46[];
|
||||
extern u8 newsm64_tex_47[];
|
||||
extern u8 newsm64_tex_48[];
|
||||
extern u8 newsm64_tex_49[];
|
||||
extern u8 newsm64_tex_50[];
|
||||
extern u8 newsm64_tex_51[];
|
||||
extern u8 newsm64_tex_52[];
|
||||
extern u8 newsm64_tex_53[];
|
||||
extern u8 newsm64_tex_54[];
|
||||
extern u8 newsm64_tex_55[];
|
||||
extern u8 newsm64_tex_56[];
|
||||
extern u8 newsm64_tex_57[];
|
||||
extern u8 newsm64_tex_58[];
|
||||
extern u8 newsm64_tex_59[];
|
||||
extern u8 newsm64_tex_60[];
|
||||
extern u8 newsm64_tex_61[];
|
||||
extern u8 newsm64_tex_62[];
|
||||
extern u8 newsm64_tex_63[];
|
||||
extern u8 newsm64_tex_64[];
|
||||
extern u8 newsm64_tex_65[];
|
||||
extern u8 newsm64_tex_66[];
|
||||
extern u8 newsm64_tex_67[];
|
||||
extern u8 newsm64_tex_68[];
|
||||
extern u8 newsm64_tex_69[];
|
||||
extern u8 newsm64_tex_70[];
|
||||
extern u8 newsm64_tex_71[];
|
||||
extern u8 newsm64_tex_72[];
|
||||
extern u8 newsm64_tex_73[];
|
||||
extern u8 newsm64_tex_74[];
|
||||
extern u8 newsm64_tex_75[];
|
||||
extern u8 newsm64_tex_76[];
|
||||
extern u8 newsm64_tex_77[];
|
||||
extern u8 newsm64_tex_78[];
|
||||
extern u8 newsm64_tex_79[];
|
||||
extern u8 newsm64_tex_80[];
|
||||
extern u8 newsm64_tex_81[];
|
||||
extern u8 newsm64_tex_82[];
|
||||
extern u8 newsm64_tex_83[];
|
||||
extern u8 newsm64_tex_84[];
|
||||
extern u8 newsm64_tex_85[];
|
||||
extern u8 newsm64_tex_86[];
|
||||
extern u8 newsm64_tex_87[];
|
||||
extern u8 newsm64_tex_88[];
|
||||
extern u8 newsm64_tex_89[];
|
||||
extern u8 newsm64_tex_90[];
|
||||
extern u8 newsm64_tex_91[];
|
||||
extern u8 newsm64_tex_92[];
|
||||
extern u8 newsm64_tex_93[];
|
||||
extern u8 newsm64_tex_94[];
|
||||
extern u8 newsm64_tex_95[];
|
||||
extern u8 newsm64_tex_96[];
|
||||
extern u8 newsm64_tex_97[];
|
||||
extern u8 newsm64_tex_98[];
|
||||
extern u8 newsm64_tex_99[];
|
||||
extern u8 newsm64_tex_100[];
|
||||
extern u8 newsm64_tex_101[];
|
||||
extern u8 newsm64_tex_102[];
|
||||
extern u8 newsm64_tex_103[];
|
||||
extern u8 newsm64_tex_104[];
|
||||
extern u8 newsm64_tex_105[];
|
||||
extern u8 newsm64_tex_106[];
|
||||
extern u8 newsm64_tex_107[];
|
||||
extern u8 newsm64_tex_108[];
|
||||
extern u8 newsm64_tex_109[];
|
||||
extern u8 newsm64_tex_110[];
|
||||
extern u8 newsm64_tex_111[];
|
||||
extern u8 newsm64_tex_112[];
|
||||
extern u8 newsm64_tex_113[];
|
||||
extern u8 newsm64_tex_114[];
|
||||
extern u8 newsm64_tex_115[];
|
||||
extern u8 newsm64_tex_116[];
|
||||
extern u8 newsm64_tex_117[];
|
||||
extern u8 newsm64_tex_118[];
|
||||
extern u8 newsm64_tex_119[];
|
||||
extern u8 newsm64_tex_120[];
|
||||
extern u8 newsm64_tex_121[];
|
||||
extern u8 newsm64_tex_122[];
|
||||
extern u8 newsm64_tex_123[];
|
||||
extern u8 newsm64_tex_124[];
|
||||
extern u8 newsm64_tex_125[];
|
||||
extern u8 newsm64_tex_126[];
|
||||
extern u8 newsm64_tex_127[];
|
||||
|
||||
extern uObjSprite newsm64_obj_dropshadow;
|
||||
@@ -1,18 +1,18 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "init.h"
|
||||
#include "debug.h"
|
||||
#include "s2d_error.h"
|
||||
|
||||
void s2d_init(void) {
|
||||
s2d_error_y = TEX_HEIGHT;
|
||||
if (IS_RUNNING_ON_EMULATOR)
|
||||
if (gIsEmulator)
|
||||
gSPLoadUcode(gdl_head++, s2d_text, s2d_data);
|
||||
}
|
||||
|
||||
void s2d_stop(void) {
|
||||
if (IS_RUNNING_ON_EMULATOR) {
|
||||
if (gIsEmulator) {
|
||||
gSPLoadUcode(gdl_head++, zex_text, zex_data);
|
||||
if deinit_cond {
|
||||
my_rdp_init();
|
||||
|
||||
+24
-3
@@ -1,14 +1,35 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#define s2d_text gspS2DEX2_fifoTextStart
|
||||
#define s2d_data gspS2DEX2_fifoDataStart
|
||||
#define zex_text gspF3DZEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_PosLight_fifoDataStart
|
||||
|
||||
#ifdef L3DEX2_ALONE
|
||||
#define zex_text gspL3DEX2_fifoTextStart
|
||||
#define zex_data gspL3DEX2_fifoDataStart
|
||||
#elif F3DZEX_GBI_2
|
||||
#define zex_text gspF3DZEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_PosLight_fifoDataStart
|
||||
#elif F3DZEX_NON_GBI_2
|
||||
#define zex_text gspF3DZEX2_NoN_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DZEX2_NoN_PosLight_fifoDataStart
|
||||
#elif F3DEX2PL_GBI
|
||||
#define zex_text gspF3DEX2_PosLight_fifoTextStart
|
||||
#define zex_data gspF3DEX2_PosLight_fifoDataStart
|
||||
#elif F3DEX_GBI_2
|
||||
#define zex_text gspF3DEX2_fifoTextStart
|
||||
#define zex_data gspF3DEX2_fifoDataStart
|
||||
#else
|
||||
#error S2DEX Text Engine only works with other EX2 series microcodes
|
||||
#endif
|
||||
|
||||
extern void s2d_reset_defer_index();
|
||||
|
||||
extern void s2d_init(void);
|
||||
|
||||
extern void s2d_handle_deferred();
|
||||
|
||||
extern void s2d_stop(void);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <PR/gs2dex.h>
|
||||
#include <PR/gu.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#define ftoq FTOFIX32
|
||||
#define qtof FIX32TOF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_print.h"
|
||||
|
||||
@@ -19,7 +19,7 @@ void s2d_reset_defer_index(void) {
|
||||
// TODO: these DO NOT work
|
||||
// pls debug :)
|
||||
void s2d_print_deferred(int x, int y, const char *str) {
|
||||
s2d_charBuffer[s2d_charBuffer_index] = str;
|
||||
s2d_charBuffer[s2d_charBuffer_index] = (char *) str;
|
||||
s2d_positions[s2d_charBuffer_index].x = x;
|
||||
s2d_positions[s2d_charBuffer_index].y = y;
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include "macros.h"
|
||||
#include <PR/gs2dex.h>
|
||||
#include "game/emutest.h"
|
||||
|
||||
#ifndef S2D_CONFIG_H
|
||||
#define S2D_CONFIG_H
|
||||
@@ -25,8 +28,6 @@
|
||||
*****************************/
|
||||
|
||||
// magic macros and font header inclusion
|
||||
#define GLUE(a, b) a##b
|
||||
#define GLUE2(a, b) GLUE(a, b)
|
||||
#define STR(x) #x
|
||||
#define STR2(x) STR(x)
|
||||
|
||||
@@ -88,11 +89,11 @@ extern char *proutSprintf(char *dst, const char *src, size_t count);
|
||||
#define TEX_BITDEPTH 8
|
||||
|
||||
#define seg2virt segmented_to_virtual
|
||||
#define IS_RUNNING_ON_EMULATOR (IO_READ(DPC_PIPEBUSY_REG) == 0)
|
||||
#define gIsEmulator (!(gEmulator & EMU_CONSOLE))
|
||||
|
||||
// Texture resolution (pixels on the texture per pixel on the framebuffer)
|
||||
#define TEX_RES 1
|
||||
|
||||
#define _NUM_CACHE (4096 / (TEX_WIDTH * TEX_HEIGHT * (TEX_BITDEPTH / 8)))
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include <ultra64.h>
|
||||
#include "mtx.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -12,12 +12,16 @@ extern uObjMtx final_mtx, rot_mtx;
|
||||
extern int s2d_red, s2d_green, s2d_blue, s2d_alpha;
|
||||
|
||||
extern void s2d_rdp_init(void);
|
||||
extern void f3d_rdp_init(void);
|
||||
|
||||
extern void setup_font_texture(int idx);
|
||||
|
||||
extern void mtx_pipeline(uObjMtx *m, int x, int y);
|
||||
|
||||
extern void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt);
|
||||
extern void draw_s2d_shadow(char c, int x, int y, uObjMtx *ds);
|
||||
extern void draw_s2d_dropshadow(char c, int x, int y, uObjMtx *ds);
|
||||
|
||||
extern void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt);
|
||||
extern void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "s2d_config.h"
|
||||
#include "init.h"
|
||||
#include "s2d_print.h"
|
||||
#include "mtx.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_ustlib.h"
|
||||
#include "s2d_optimized.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
#include "s2d_print.h"
|
||||
#include "s2d_error.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
#include <ultra64.h>
|
||||
#include <PR/gs2dex.h>
|
||||
#include <PR/gu.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "s2d_config.h"
|
||||
|
||||
#include "s2d_draw.h"
|
||||
#include "s2d_print.h"
|
||||
#include "s2d_ustdlib.h"
|
||||
#include "s2d_error.h"
|
||||
#include "s2d_ustdlib.h"
|
||||
#include "s2d_optimized.h"
|
||||
#include "mtx.h"
|
||||
|
||||
static int s2d_width(const char *str, int line, int len);
|
||||
static void s2d_snprint(int x, int y, int align, const char *str, int len);
|
||||
|
||||
extern void *s2d_calloc(size_t);
|
||||
|
||||
void insert_el_char(S2DList *s, S2DListNode *n) {
|
||||
if (n == NULL) return;
|
||||
|
||||
S2DListNode *pt = s->head;
|
||||
|
||||
while (pt->next != NULL) {
|
||||
if (pt->next == NULL) {
|
||||
pt->next = n;
|
||||
n->prev = pt;
|
||||
return;
|
||||
}
|
||||
|
||||
if (n->glyph >= pt->glyph
|
||||
&& n->glyph < pt->next->glyph)
|
||||
{
|
||||
S2DListNode *prev = pt;
|
||||
S2DListNode *next = pt->next;
|
||||
|
||||
n->next = next;
|
||||
prev->next = n;
|
||||
next->prev = n;
|
||||
n->prev = prev;
|
||||
s->len++;
|
||||
return;
|
||||
}
|
||||
pt = pt->next;
|
||||
}
|
||||
|
||||
pt->next = n;
|
||||
}
|
||||
|
||||
#define FTOFIX16(x) (long)((x) * (float)(1 << 2))
|
||||
void mtx_pipeline_op(uObjSubMtx *m, int x, int y, float scale) {
|
||||
m->m.BaseScaleX = FTOFIX32(scale);
|
||||
// m->m.B = 0;
|
||||
// m->m.C = 0;
|
||||
m->m.BaseScaleY = FTOFIX32(scale);
|
||||
|
||||
m->m.X = FTOFIX16((float)(x));
|
||||
m->m.Y = FTOFIX16((float)(y));
|
||||
}
|
||||
|
||||
void make_glyph(S2DList *s, int x, int y,
|
||||
int glyph,
|
||||
int r, int g, int b, int a,
|
||||
float scl,
|
||||
int d, int dx, int dy
|
||||
) {
|
||||
S2DListNode *t = (S2DListNode *) s2d_calloc(sizeof(S2DListNode));
|
||||
|
||||
t->mtx = (uObjSubMtx *) s2d_calloc(sizeof(uObjSubMtx));
|
||||
|
||||
mtx_pipeline_op(t->mtx, x, y, scl);
|
||||
|
||||
t->envR = r;
|
||||
t->envG = g;
|
||||
t->envB = b;
|
||||
t->envA = a;
|
||||
|
||||
t->glyph = glyph;
|
||||
|
||||
if (d == 1) {
|
||||
t->dropshadow = (uObjSubMtx *) s2d_calloc(sizeof(uObjSubMtx));
|
||||
// mtx_pipeline_op(t->dropshadow, x + dx, y + dy, scl);
|
||||
mtx_pipeline_op(t->dropshadow, dx, dy, scl);
|
||||
}
|
||||
|
||||
if (s->head == NULL) {
|
||||
s->head = t;
|
||||
s->len = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
insert_el_char(s, t);
|
||||
|
||||
}
|
||||
|
||||
#define CLAMP_0(x) ((x < 0) ? 0 : x)
|
||||
|
||||
void draw_all_glyphs(S2DList *s) {
|
||||
S2DListNode *tmp = s->head;
|
||||
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetCycleType(gdl_head++, G_CYC_COPY);
|
||||
gDPSetRenderMode(gdl_head++, G_RM_SPRITE, G_RM_SPRITE2);
|
||||
|
||||
while (tmp != NULL) {
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++, tmp->envR, tmp->envG, tmp->envB, tmp->envA);
|
||||
|
||||
if (tmp->prev == NULL) {
|
||||
gSPObjLoadTxtr(gdl_head++, &s2d_tex[tmp->glyph]);
|
||||
gDPLoadSync(gdl_head++);
|
||||
}
|
||||
else if (tmp->prev->glyph != tmp->glyph) {
|
||||
gSPObjLoadTxtr(gdl_head++, &s2d_tex[tmp->glyph]);
|
||||
gDPLoadSync(gdl_head++);
|
||||
}
|
||||
|
||||
if (tmp->dropshadow) {
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++,
|
||||
CLAMP_0(tmp->envR - 100),
|
||||
CLAMP_0(tmp->envG - 100),
|
||||
CLAMP_0(tmp->envB - 100),
|
||||
tmp->envA);
|
||||
gSPObjSubMatrix(gdl_head++, &tmp->dropshadow);
|
||||
gSPObjSprite(gdl_head++, &s2d_dropshadow);
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetEnvColor(gdl_head++, tmp->envR, tmp->envG, tmp->envB, tmp->envA);
|
||||
}
|
||||
|
||||
gSPObjSubMatrix(gdl_head++, tmp->mtx);
|
||||
gSPObjRectangleR(gdl_head++, &s2d_font);
|
||||
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
gDPPipeSync(gdl_head++);
|
||||
gDPSetCycleType(gdl_head++, G_CYC_1CYCLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void s2d_snprint(int x, int y, int align, const char *str, int len) {
|
||||
char *p = (char *) str;
|
||||
int tmp_len = 0;
|
||||
int orig_x = x;
|
||||
int orig_y = y;
|
||||
int line = 0;
|
||||
|
||||
if (*p == '\0') return;
|
||||
|
||||
s2d_rdp_init();
|
||||
|
||||
// resets parameters
|
||||
s2d_red = s2d_green = s2d_blue = 255;
|
||||
s2d_alpha = 255;
|
||||
drop_shadow = FALSE;
|
||||
|
||||
switch (align) {
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
|
||||
S2DList *s2d_list = (S2DList *) s2d_calloc(sizeof(S2DList));
|
||||
|
||||
do {
|
||||
char current_char = *p;
|
||||
|
||||
switch (current_char) {
|
||||
case CH_SCALE:
|
||||
CH_SKIP(p);
|
||||
myScale = (f32)s2d_atoi(p, &p) / 100.0f;
|
||||
break;
|
||||
case CH_ROT:
|
||||
CH_SKIP(p);
|
||||
myDegrees = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_TRANSLATE:
|
||||
CH_SKIP(p);
|
||||
orig_x = s2d_atoi(p, &p);
|
||||
line++;
|
||||
switch (align) {
|
||||
case ALIGN_LEFT:
|
||||
x = orig_x;
|
||||
break;
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
CH_SKIP(p);
|
||||
CH_SKIP(p);
|
||||
orig_y = s2d_atoi(p, &p);
|
||||
y = orig_y;
|
||||
break;
|
||||
case CH_COLOR:
|
||||
CH_SKIP(p);
|
||||
s2d_red = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_green = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_blue = s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
s2d_alpha = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_DROPSHADOW:
|
||||
drop_shadow ^= 1;
|
||||
break;
|
||||
case '\n':
|
||||
line++;
|
||||
switch (align) {
|
||||
case ALIGN_LEFT:
|
||||
x = orig_x;
|
||||
break;
|
||||
case ALIGN_CENTER:
|
||||
x = orig_x - s2d_width(str, line, len) / 2;
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = orig_x - s2d_width(str, line, len);
|
||||
}
|
||||
y += TEX_HEIGHT / TEX_RES;
|
||||
break;
|
||||
case '\t':
|
||||
x += TAB_WIDTH_H / TEX_RES;
|
||||
break;
|
||||
case '\v':
|
||||
x += TAB_WIDTH_V / TEX_RES;
|
||||
y += TEX_HEIGHT / TEX_RES;
|
||||
break;
|
||||
// case CH_SEPARATOR:
|
||||
// CH_SKIP(p);
|
||||
// break;
|
||||
case CH_RESET:
|
||||
s2d_red = s2d_green = s2d_blue = 255;
|
||||
s2d_alpha = 255;
|
||||
drop_shadow = FALSE;
|
||||
drop_x = 0;
|
||||
drop_y = 0;
|
||||
myScale = 1;
|
||||
myDegrees = 0;
|
||||
break;
|
||||
default:
|
||||
if (current_char != '\0' && current_char != CH_SEPARATOR) {
|
||||
char *tbl = segmented_to_virtual(s2d_kerning_table);
|
||||
|
||||
if (current_char != ' ') {
|
||||
make_glyph(s2d_list, x, y,
|
||||
current_char,
|
||||
s2d_red, s2d_green, s2d_blue, s2d_alpha,
|
||||
myScale,
|
||||
drop_shadow, drop_x, drop_y
|
||||
);
|
||||
}
|
||||
|
||||
(x += (tbl[(int) current_char] * (BASE_SCALE * myScale)));
|
||||
}
|
||||
}
|
||||
if (*p == '\0') break;
|
||||
p++;
|
||||
tmp_len++;
|
||||
} while (tmp_len < len);
|
||||
myScale = 1.0f;
|
||||
myDegrees = 0;
|
||||
drop_shadow = FALSE;
|
||||
drop_x = 0;
|
||||
drop_y = 0;
|
||||
|
||||
draw_all_glyphs(s2d_list);
|
||||
}
|
||||
|
||||
void s2d_print_optimized(int x, int y, const char *str) {
|
||||
int len;
|
||||
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
len = s2d_strlen((char *)str);
|
||||
|
||||
s2d_snprint(x, y, ALIGN_LEFT, str, len);
|
||||
}
|
||||
|
||||
static int s2d_width(const char *str, int line, int len) {
|
||||
char *p = (char *) str;
|
||||
int tmp_len = 0;
|
||||
int curLine = 0;
|
||||
int width = 0;
|
||||
int scale = 1;
|
||||
|
||||
if (*p == '\0') return width;
|
||||
|
||||
do {
|
||||
char current_char = *p;
|
||||
switch (current_char) {
|
||||
case CH_SCALE:
|
||||
CH_SKIP(p);
|
||||
scale = s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_ROT:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_TRANSLATE:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
curLine++;
|
||||
CH_SKIP(p);
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_COLOR:
|
||||
CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
CH_SKIP(p); CH_SKIP(p);
|
||||
s2d_atoi(p, &p);
|
||||
break;
|
||||
case CH_DROPSHADOW:
|
||||
case CH_RESET:
|
||||
break;
|
||||
case '\n':
|
||||
curLine++;
|
||||
break;
|
||||
case '\t':
|
||||
if (curLine == line)
|
||||
width += TAB_WIDTH_H / TEX_RES;
|
||||
break;
|
||||
case '\v':
|
||||
if (curLine == line)
|
||||
width += TAB_WIDTH_V / TEX_RES;
|
||||
break;
|
||||
default:
|
||||
if (current_char != '\0' && curLine == line)
|
||||
width += s2d_kerning_table[(int) current_char] * scale;
|
||||
}
|
||||
if (*p == '\0') break;
|
||||
p++;
|
||||
tmp_len++;
|
||||
} while (tmp_len < len && curLine <= line);
|
||||
return width;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef S2D_OPTIMIZE_H
|
||||
#define S2D_OPTIMIZE_H
|
||||
|
||||
struct s2d_optimized_linkedlist {
|
||||
struct s2d_optimized_linkedlist *next;
|
||||
struct s2d_optimized_linkedlist *prev;
|
||||
u8 envR;
|
||||
u8 envG;
|
||||
u8 envB;
|
||||
u8 envA;
|
||||
int glyph;
|
||||
uObjSubMtx *mtx;
|
||||
uObjSubMtx *dropshadow;
|
||||
};
|
||||
typedef struct s2d_optimized_linkedlist S2DListNode;
|
||||
|
||||
struct s2dlist {
|
||||
S2DListNode *head;
|
||||
int len;
|
||||
};
|
||||
typedef struct s2dlist S2DList;
|
||||
|
||||
#endif
|
||||
+20
-19
@@ -3,7 +3,7 @@
|
||||
#include <PR/gu.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "s2d_config.h"
|
||||
|
||||
#include "s2d_draw.h"
|
||||
#include "s2d_print.h"
|
||||
@@ -18,16 +18,16 @@ enum S2DPrintModes {
|
||||
};
|
||||
|
||||
static int s2d_snprint(int x, int y, int align, const char *str, uObjMtx *buf, int len, int mode) {
|
||||
char *p = str;
|
||||
char *p = (char*) str;
|
||||
int tmp_len = 0;
|
||||
int orig_x = x;
|
||||
int orig_y = y;
|
||||
int line = 0;
|
||||
char button = '\0';
|
||||
|
||||
if (*p == '\0') return;
|
||||
if (*p == '\0') return 0;
|
||||
|
||||
if (IS_RUNNING_ON_EMULATOR) {
|
||||
if (gIsEmulator) {
|
||||
s2d_rdp_init();
|
||||
} else {
|
||||
f3d_rdp_init();
|
||||
@@ -166,7 +166,7 @@ static int s2d_snprint(int x, int y, int align, const char *str, uObjMtx *buf, i
|
||||
if (current_char != '\0' && current_char != CH_SEPARATOR) {
|
||||
char *tbl = segmented_to_virtual(s2d_kerning_table);
|
||||
|
||||
if (IS_RUNNING_ON_EMULATOR) {
|
||||
if (gIsEmulator) {
|
||||
if (drop_shadow && mode == MODE_DRAW_DROPSHADOW) {
|
||||
draw_s2d_dropshadow(current_char, x + drop_x, y + drop_y, (buf++));
|
||||
} else if (mode == MODE_DRAW_NORMALTEXT) {
|
||||
@@ -196,7 +196,7 @@ static int s2d_snprint(int x, int y, int align, const char *str, uObjMtx *buf, i
|
||||
}
|
||||
|
||||
static int s2d_string_has_dropshadow(const char *str) {
|
||||
char *p = str;
|
||||
char *p = (char *) str;
|
||||
|
||||
int result = FALSE;
|
||||
|
||||
@@ -208,19 +208,19 @@ static int s2d_string_has_dropshadow(const char *str) {
|
||||
// deprecated
|
||||
void s2d_print(int x, int y, int align, const char *str, uObjMtx *buf) {
|
||||
if (s2d_check_align(align) != 0) return;
|
||||
if (s2d_check_str(str) != 0) return;
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
s2d_snprint(x, y, align, str, buf, s2d_strlen(str), MODE_DRAW_DROPSHADOW);
|
||||
s2d_snprint(x, y, align, str, buf, s2d_strlen(str), MODE_DRAW_NORMALTEXT);
|
||||
s2d_snprint(x, y, align, str, buf, s2d_strlen((char *)str), MODE_DRAW_DROPSHADOW);
|
||||
s2d_snprint(x, y, align, str, buf, s2d_strlen((char *)str), MODE_DRAW_NORMALTEXT);
|
||||
}
|
||||
|
||||
void s2d_print_alloc(int x, int y, int align, const char *str) {
|
||||
int len;
|
||||
|
||||
if (s2d_check_align(align) != 0) return;
|
||||
if (s2d_check_str(str) != 0) return;
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
len = s2d_strlen(str);
|
||||
len = s2d_strlen((char *)str);
|
||||
|
||||
if (s2d_string_has_dropshadow(str)) {
|
||||
uObjMtx *b = alloc(sizeof(uObjMtx) * len);
|
||||
@@ -236,9 +236,9 @@ void s2d_type_print(int x, int y, int align, const char *str, uObjMtx *buf, int
|
||||
int len;
|
||||
|
||||
if (s2d_check_align(align) != 0) return;
|
||||
if (s2d_check_str(str) != 0) return;
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
len = s2d_strlen(str);
|
||||
len = s2d_strlen((char *)str);
|
||||
|
||||
s2d_snprint(x, y, align, str, buf, *pos, MODE_DRAW_DROPSHADOW);
|
||||
|
||||
@@ -254,9 +254,9 @@ void s2d_type_print_alloc(int x, int y, int align, const char *str, int *pos) {
|
||||
int len;
|
||||
|
||||
if (s2d_check_align(align) != 0) return;
|
||||
if (s2d_check_str(str) != 0) return;
|
||||
if (s2d_check_str((char *)str) != 0) return;
|
||||
|
||||
len = s2d_strlen(str);
|
||||
len = s2d_strlen((char *)str);
|
||||
|
||||
uObjMtx *b = alloc(sizeof(uObjMtx) * (*pos));
|
||||
|
||||
@@ -273,14 +273,15 @@ void s2d_type_print_alloc(int x, int y, int align, const char *str, int *pos) {
|
||||
}
|
||||
}
|
||||
|
||||
// broken atm
|
||||
static int s2d_width(const char *str, int line, int len) {
|
||||
char *p = str;
|
||||
char *p = (char *) str;
|
||||
int tmp_len = 0;
|
||||
int curLine = 0;
|
||||
int width = 0;
|
||||
int scale = 1;
|
||||
|
||||
u8 *ktable = seg2virt(s2d_kerning_table);
|
||||
|
||||
if (*p == '\0') return width;
|
||||
|
||||
do {
|
||||
@@ -328,7 +329,7 @@ static int s2d_width(const char *str, int line, int len) {
|
||||
break;
|
||||
default:
|
||||
if (current_char != '\0' && curLine == line)
|
||||
width += s2d_kerning_table[(int) current_char] * scale;
|
||||
width += ktable[(int) current_char] * scale;
|
||||
}
|
||||
if (*p == '\0') break;
|
||||
p++;
|
||||
@@ -340,7 +341,7 @@ static int s2d_width(const char *str, int line, int len) {
|
||||
// void s2d_vsprint(int x, int y, int align, uObjMtx *buf, const char *str, ...) {
|
||||
// int last_chr;
|
||||
// va_list args;
|
||||
// char *dst = alloc(s2d_strlen(str) * 2);
|
||||
// char *dst = alloc(s2d_strlen((char *)str) * 2);
|
||||
// va_start(args, str);
|
||||
// last_chr = vsprintf(dst, str, str, args);
|
||||
// if (last_chr >= 0) {
|
||||
|
||||
Binary file not shown.
@@ -1,227 +0,0 @@
|
||||
// int s2d_atoi(char *s, char **s2) {
|
||||
// int ret = 0;
|
||||
// int isNegative = (*s == '-');
|
||||
// if (isNegative) {s++; (*s2)++;}
|
||||
// for (; *s != '\0' && *s != ' ' && *s >= '0' && *s <= '9'; s++) {
|
||||
// ret *= 10;
|
||||
// if (*s >= '0' && *s <= '9')
|
||||
// ret += *s - '0';
|
||||
// else break;
|
||||
// if (!(*(s+1) != '\0' && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break;
|
||||
// (*s2)++;
|
||||
// }
|
||||
// if (isNegative) ret *= -1;
|
||||
// return ret;
|
||||
// }
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define SCALE "\x80" // SCALE (some scale)
|
||||
#define ROTATE "\x81" // ROTATE (degrees) // TODO: maybe add axis?
|
||||
#define TRANSLATE "\x82" // TRANSLATE (x) (y)
|
||||
|
||||
#define CH_SCALE '\x80'
|
||||
#define CH_ROT '\x81'
|
||||
#define CH_TRANSLATE '\x82'
|
||||
|
||||
#define CH_GET_NEXT(x) (*(++x))
|
||||
#define CH_SKIP(x) ((++x))
|
||||
|
||||
int saved_degrees = 0;
|
||||
|
||||
int myScale = 1;
|
||||
int myDegrees = 0;
|
||||
|
||||
char *t = "TEST CRINGE";
|
||||
int s2d_atoi(char *s, char **s2) {
|
||||
int ret = 0;
|
||||
int isNegative = (*s == '-');
|
||||
if (isNegative) {
|
||||
s++;
|
||||
(*s2)++;
|
||||
}
|
||||
for (; *s != '\0' && *s != ' ' && *s >= '0' && *s <= '9'; s++) {
|
||||
ret *= 10;
|
||||
if (*s >= '0' && *s <= '9')
|
||||
ret += *s - '0';
|
||||
else break;
|
||||
if (!(*(s+1) != '\0' && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break;
|
||||
(*s2)++;
|
||||
}
|
||||
if (isNegative) ret *= -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern unsigned int gGlobalTimer;
|
||||
|
||||
void s2d_print(int x, int y, char *str) {
|
||||
char *p = str;
|
||||
int tx = 0, ty = 0;
|
||||
// int r = 0, g = 0, b = 0, a = 0;
|
||||
if (*p == '\0') return;
|
||||
do {
|
||||
char r = *p;
|
||||
int s, rd;
|
||||
switch (r) {
|
||||
case CH_SCALE:
|
||||
CH_SKIP(p);
|
||||
s = s2d_atoi(p, &p);
|
||||
myScale = s;
|
||||
break;
|
||||
case CH_ROT:
|
||||
CH_SKIP(p);
|
||||
rd = s2d_atoi(p, &p);
|
||||
saved_degrees = rd;
|
||||
myDegrees = rd;
|
||||
break;
|
||||
case CH_TRANSLATE:
|
||||
CH_SKIP(p);
|
||||
x = s2d_atoi(p, &p);
|
||||
CH_SKIP(p);
|
||||
CH_SKIP(p);
|
||||
y = s2d_atoi(p, &p);
|
||||
break;
|
||||
// case CH_COLOR:
|
||||
// CH_SKIP(p);
|
||||
// s2d_red = s2d_atoi(p, &p);
|
||||
// CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
// s2d_green = s2d_atoi(p, &p);
|
||||
// CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
// s2d_blue = s2d_atoi(p, &p);
|
||||
// CH_SKIP(p); CH_SKIP(p);
|
||||
|
||||
// s2d_alpha = s2d_atoi(p, &p);
|
||||
// break;
|
||||
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
// if (myDegrees == 0)
|
||||
// // draw_s2d_glyph(r, (x += (8 * myScale)) + tx, y + ty, (buf++));
|
||||
// else
|
||||
// draw_s2d_glyph(r, (x += ((8 * myScale))) + tx, y + ty, (buf++));
|
||||
}
|
||||
p++;
|
||||
// myDegrees += saved_degrees;
|
||||
} while (*p != '\0');
|
||||
myScale = 1;
|
||||
myDegrees = 0;
|
||||
saved_degrees = 0;
|
||||
tx = 0;
|
||||
ty = 0;
|
||||
}
|
||||
|
||||
int s2d_ilen(char *s) {
|
||||
int ret = 0;
|
||||
char *p = s;
|
||||
while (*p >= '0' && *p <= '9') {
|
||||
ret++;
|
||||
p++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int s2d_atoi2(char *s) {
|
||||
int ret = 0;
|
||||
int isNegative = (*s == '-');
|
||||
if (isNegative) {
|
||||
s++;
|
||||
}
|
||||
for (; *s != '\0' && *s != ' ' && *s >= '0' && *s <= '9'; s++) {
|
||||
ret *= 10;
|
||||
if (*s >= '0' && *s <= '9')
|
||||
ret += *s - '0';
|
||||
else break;
|
||||
if (!(*(s+1) != '\0' && *(s+1) != ' ' && *(s+1) >= '0' && *(s+1) <= '9')) break;
|
||||
}
|
||||
// (*s2)--;
|
||||
if (isNegative) ret *= -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void s2d_type_print(int x, int y, char *str, int *pos) {
|
||||
char *temp_str = str;
|
||||
char tmp = temp_str[*pos];
|
||||
int len = strlen(str);
|
||||
char current_transformation;
|
||||
int cur_transform_index;
|
||||
switch(tmp) {
|
||||
case CH_SCALE:
|
||||
current_transformation = CH_SCALE;
|
||||
cur_transform_index = *pos;
|
||||
// temp_str[*pos] = ' ';
|
||||
printf("SCALE %c %d\n", str[*pos + 1], s2d_ilen(str + *pos + 1));
|
||||
(*pos) += s2d_ilen(str + *pos+2) + 1;
|
||||
break;
|
||||
case CH_ROT:
|
||||
printf("ROTATE %s %d\n", str + *pos + 1, s2d_ilen(str + *pos + 1));
|
||||
(*pos) += s2d_ilen(str + *pos + 2);
|
||||
break;
|
||||
}
|
||||
// temp_str[*pos] = '\0';
|
||||
// s2d_print(x, y, temp_str);
|
||||
// // temp_str[cur_transform_index] = current_transformation;
|
||||
// temp_str[*pos] = tmp;
|
||||
|
||||
// if (gGlobalTimer % 5 == 0) {
|
||||
if (*pos < len)
|
||||
(*pos)++;
|
||||
// }
|
||||
printf("%d %c\n", *pos, str[*pos]);
|
||||
}
|
||||
|
||||
|
||||
char sss[] = SCALE "2";
|
||||
// SCALE "4"
|
||||
// "big chungus";
|
||||
|
||||
char myS[] = "small test"
|
||||
ROTATE "2"
|
||||
"big test"
|
||||
ROTATE "26"
|
||||
"italic chungus";
|
||||
|
||||
char my2[] = "small test"
|
||||
ROTATE "2"
|
||||
"big test"
|
||||
ROTATE "0000046"
|
||||
"big italic chungus"
|
||||
ROTATE "124335";
|
||||
|
||||
int pos = 0;
|
||||
int main(void) {
|
||||
// printf("%d\n", s2d_atoi(s, &s));
|
||||
// printf("%s\n", s);
|
||||
// s2d_print(0,0, t);
|
||||
char laStrBuf[0x100];
|
||||
char ff[0x100];
|
||||
sprintf(ff,
|
||||
"%s %d:"
|
||||
TRANSLATE "134 93" "%s:"
|
||||
, "Floor", 213, "Seed");
|
||||
sprintf(
|
||||
laStrBuf,
|
||||
"%s"
|
||||
TRANSLATE "138 93" "%s"
|
||||
TRANSLATE "138 110" "%s"
|
||||
TRANSLATE "138 130" "%s"
|
||||
, "The Basement", "LLRRABAB", "Continue", "End Run");
|
||||
|
||||
while (pos != strlen(laStrBuf)) {
|
||||
// s2d_type_print(0, 0, myS, &pos);
|
||||
printf("%d %s\n",s2d_ilen(laStrBuf + pos), laStrBuf + pos);
|
||||
pos++;
|
||||
}
|
||||
pos = 0;
|
||||
while (pos != strlen(ff)) {
|
||||
// s2d_type_print(0, 0, myS, &pos);
|
||||
printf("%d %s\n",s2d_ilen(ff + pos), ff + pos);
|
||||
pos++;
|
||||
}
|
||||
// laStrBuf[strlen(laStrBuf)] = "\x1";
|
||||
// laStrBuf[strlen(laStrBuf)+1] = "\x1";
|
||||
// printf("%s\n", laStrBuf);
|
||||
// printf("%d\n", s2d_ilen(sss + 1));
|
||||
}
|
||||
+126
-50
@@ -18,7 +18,6 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
#if DEBUG_MODE
|
||||
|
||||
/*********************************
|
||||
@@ -39,39 +38,41 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#define COMMAND_TOKENS 10
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
|
||||
/*********************************
|
||||
Libultra types (for libdragon)
|
||||
Libultra types (for libdragon)
|
||||
*********************************/
|
||||
|
||||
|
||||
#ifdef LIBDRAGON
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
|
||||
typedef signed char s8;
|
||||
typedef short s16;
|
||||
typedef long s32;
|
||||
typedef long long s64;
|
||||
|
||||
|
||||
typedef volatile unsigned char vu8;
|
||||
typedef volatile unsigned short vu16;
|
||||
typedef volatile unsigned long vu32;
|
||||
typedef volatile unsigned long long vu64;
|
||||
|
||||
|
||||
typedef volatile signed char vs8;
|
||||
typedef volatile short vs16;
|
||||
typedef volatile long vs32;
|
||||
typedef volatile long long vs64;
|
||||
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
#endif
|
||||
|
||||
|
||||
/*********************************
|
||||
Structs
|
||||
*********************************/
|
||||
|
||||
|
||||
// Register struct
|
||||
typedef struct
|
||||
{
|
||||
@@ -109,7 +110,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
static void debug_thread_fault(void *arg);
|
||||
#endif
|
||||
static void debug_thread_usb(void *arg);
|
||||
|
||||
|
||||
// Other
|
||||
#if OVERWRITE_OSPRINT
|
||||
static void* debug_osSyncPrintf_implementation(void *unused, const char *str, size_t len);
|
||||
@@ -117,12 +118,13 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#else
|
||||
static void debug_thread_usb(void *arg);
|
||||
#endif
|
||||
static inline void debug_handle_64drivebutton();
|
||||
|
||||
|
||||
/*********************************
|
||||
Globals
|
||||
*********************************/
|
||||
|
||||
|
||||
// Function pointers
|
||||
#ifndef LIBDRAGON
|
||||
extern int _Printf(void *(*copyfunc)(void *, const char *, size_t), void*, const char*, va_list);
|
||||
@@ -130,7 +132,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
extern void* __printfunc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Debug globals
|
||||
static char debug_initialized = 0;
|
||||
static char debug_buffer[BUFFER_SIZE];
|
||||
@@ -138,20 +140,25 @@ https://github.com/buu342/N64-UNFLoader
|
||||
// Commands hashtable related
|
||||
static debugCommand* debug_commands_hashtable[HASHTABLE_SIZE];
|
||||
static debugCommand debug_commands_elements[MAX_COMMANDS];
|
||||
static int debug_commands_count = 0;
|
||||
static int debug_commands_count = 0;
|
||||
|
||||
// Command parsing related
|
||||
static int debug_command_current = 0;
|
||||
static int debug_command_totaltokens = 0;
|
||||
static int debug_command_incoming_start[COMMAND_TOKENS];
|
||||
static int debug_command_incoming_size[COMMAND_TOKENS];
|
||||
static char* debug_command_error;
|
||||
|
||||
static int debug_command_current = 0;
|
||||
static int debug_command_totaltokens = 0;
|
||||
static int debug_command_incoming_start[COMMAND_TOKENS];
|
||||
static int debug_command_incoming_size[COMMAND_TOKENS];
|
||||
static char* debug_command_error = NULL;
|
||||
|
||||
// Assertion globals
|
||||
static int assert_line = 0;
|
||||
static int assert_line = 0;
|
||||
static const char* assert_file = NULL;
|
||||
static const char* assert_expr = NULL;
|
||||
|
||||
|
||||
// 64Drive button functions
|
||||
static void (*debug_64dbut_func)() = NULL;
|
||||
static u64 debug_64dbut_debounce = 0;
|
||||
static u64 debug_64dbut_hold = 0;
|
||||
|
||||
#ifndef LIBDRAGON
|
||||
// Fault thread globals
|
||||
#if USE_FAULTTHREAD
|
||||
@@ -166,7 +173,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
static OSMesg usbMessageBuf;
|
||||
static OSThread usbThread;
|
||||
static u64 usbThreadStack[USB_THREAD_STACK/sizeof(u64)];
|
||||
|
||||
|
||||
// List of error causes
|
||||
static regDesc causeDesc[] = {
|
||||
{CAUSE_BD, CAUSE_BD, "BD"},
|
||||
@@ -198,7 +205,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
{CAUSE_EXCMASK, EXC_VCED, "Virtual coherency exception on data reference"},
|
||||
{0, 0, ""}
|
||||
};
|
||||
|
||||
|
||||
// List of register descriptions
|
||||
static regDesc srDesc[] = {
|
||||
{SR_CU3, SR_CU3, "CU3"},
|
||||
@@ -233,7 +240,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
{SR_IE, SR_IE, "IE"},
|
||||
{0, 0, ""}
|
||||
};
|
||||
|
||||
|
||||
// List of floating point registers descriptions
|
||||
static regDesc fpcsrDesc[] = {
|
||||
{FPCSR_FS, FPCSR_FS, "FS"},
|
||||
@@ -261,7 +268,8 @@ https://github.com/buu342/N64-UNFLoader
|
||||
{0, 0, ""}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*********************************
|
||||
Debug functions
|
||||
*********************************/
|
||||
@@ -276,7 +284,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
// Initialize the USB functions
|
||||
if (!usb_initialize())
|
||||
return;
|
||||
|
||||
|
||||
// Overwrite osSyncPrintf
|
||||
#ifndef LIBDRAGON
|
||||
#if OVERWRITE_OSPRINT
|
||||
@@ -409,7 +417,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
// Ensure debug mode is initialized
|
||||
if (!debug_initialized)
|
||||
return;
|
||||
|
||||
|
||||
// Create the data header to send
|
||||
data[0] = DATATYPE_SCREENSHOT;
|
||||
data[1] = depth;
|
||||
@@ -426,7 +434,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#else
|
||||
debug_thread_usb(&msg);
|
||||
#endif
|
||||
|
||||
|
||||
// Send the framebuffer to the USB thread
|
||||
msg.msgtype = MSG_WRITE;
|
||||
msg.datatype = DATATYPE_SCREENSHOT;
|
||||
@@ -438,8 +446,8 @@ https://github.com/buu342/N64-UNFLoader
|
||||
debug_thread_usb(&msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
_debug_assert
|
||||
Halts the program (assumes expression failed)
|
||||
@@ -447,11 +455,9 @@ https://github.com/buu342/N64-UNFLoader
|
||||
@param The file where the exception ocurred
|
||||
@param The line number where the exception ocurred
|
||||
==============================*/
|
||||
|
||||
|
||||
void _debug_assert(const char* expression, const char* file, int line)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
volatile char crash;
|
||||
|
||||
// Set the assert data
|
||||
@@ -463,10 +469,25 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#ifdef LIBDRAGON
|
||||
debug_printf("Assertion failed in file '%s', line %d.\n", assert_file, assert_line);
|
||||
#endif
|
||||
|
||||
|
||||
// Intentionally cause a TLB exception on load/instruction fetch
|
||||
crash = *(volatile char *)1;
|
||||
#pragma GCC diagnostic pop
|
||||
(void)crash;
|
||||
}
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_64drivebutton
|
||||
Assigns a function to be executed when the 64drive button is pressed.
|
||||
@param The function pointer to execute
|
||||
@param Whether or not to execute the function only on pressing (ignore holding the button down)
|
||||
==============================*/
|
||||
|
||||
void debug_64drivebutton(void(*execute)(), char onpress)
|
||||
{
|
||||
debug_64dbut_func = execute;
|
||||
debug_64dbut_debounce = 0;
|
||||
debug_64dbut_hold = !onpress;
|
||||
}
|
||||
|
||||
|
||||
@@ -549,7 +570,10 @@ https://github.com/buu342/N64-UNFLoader
|
||||
// Ensure debug mode is initialized
|
||||
if (!debug_initialized)
|
||||
return;
|
||||
|
||||
|
||||
// Handle 64Drive button polling
|
||||
debug_handle_64drivebutton();
|
||||
|
||||
// Send a read message to the USB thread
|
||||
msg.msgtype = MSG_READ;
|
||||
#ifndef LIBDRAGON
|
||||
@@ -560,6 +584,56 @@ https://github.com/buu342/N64-UNFLoader
|
||||
}
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_handle_64drivebutton
|
||||
Handles the 64Drive's button logic
|
||||
==============================*/
|
||||
|
||||
static inline void debug_handle_64drivebutton()
|
||||
{
|
||||
static u32 held = 0;
|
||||
|
||||
// If we own a 64Drive
|
||||
if (usb_getcart() == CART_64DRIVE && debug_64dbut_func != NULL)
|
||||
{
|
||||
u64 curtime;
|
||||
#ifndef LIBDRAGON
|
||||
curtime = osGetTime();
|
||||
#else
|
||||
curtime = timer_ticks();
|
||||
#endif
|
||||
|
||||
// And the debounce time on the 64Drive's button has elapsed
|
||||
if (debug_64dbut_debounce < curtime)
|
||||
{
|
||||
s32 bpoll;
|
||||
#ifndef LIBDRAGON
|
||||
osPiReadIo(0xB80002F8, (u32 *)&bpoll);
|
||||
#else
|
||||
bpoll = io_read(0xB80002F8);
|
||||
#endif
|
||||
bpoll = (bpoll&0xFFFF0000)>>16;
|
||||
|
||||
// If the 64Drive's button has been pressed, then execute the assigned function and set the debounce timer
|
||||
if (bpoll == 0 && (debug_64dbut_hold || !held))
|
||||
{
|
||||
u64 nexttime;
|
||||
#ifndef LIBDRAGON
|
||||
nexttime = OS_USEC_TO_CYCLES(100000);
|
||||
#else
|
||||
nexttime = TIMER_TICKS(100000);
|
||||
#endif
|
||||
debug_64dbut_debounce = curtime + nexttime;
|
||||
debug_64dbut_func();
|
||||
held = 1;
|
||||
}
|
||||
else if (bpoll != 0 && held)
|
||||
held = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_sizecommand
|
||||
Returns the size of the data from this part of the command
|
||||
@@ -606,7 +680,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
usb_rewind(debug_command_incoming_size[curr]+debug_command_incoming_start[curr]);
|
||||
debug_command_current++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_commands_setup
|
||||
@@ -631,11 +705,11 @@ https://github.com/buu342/N64-UNFLoader
|
||||
int readsize = BUFFER_SIZE;
|
||||
if (readsize > dataleft)
|
||||
readsize = dataleft;
|
||||
|
||||
|
||||
// Read a block from USB
|
||||
memset(debug_buffer, 0, BUFFER_SIZE);
|
||||
usb_read(debug_buffer, readsize);
|
||||
|
||||
|
||||
// Parse the block
|
||||
for (i=0; i<readsize && dataleft > 0; i++)
|
||||
{
|
||||
@@ -709,12 +783,12 @@ https://github.com/buu342/N64-UNFLoader
|
||||
Handles the USB thread
|
||||
@param Arbitrary data that the thread can receive
|
||||
==============================*/
|
||||
|
||||
|
||||
static void debug_thread_usb(void *arg)
|
||||
{
|
||||
char errortype = USBERROR_NONE;
|
||||
usbMesg* threadMsg;
|
||||
|
||||
|
||||
#ifndef LIBDRAGON
|
||||
// Create the message queue for the USB message
|
||||
osCreateMesgQueue(&usbMessageQ, &usbMessageBuf, 1);
|
||||
@@ -722,7 +796,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
// Set the received thread message to the argument
|
||||
threadMsg = (usbMesg*)arg;
|
||||
#endif
|
||||
|
||||
|
||||
// Thread loop
|
||||
while (1)
|
||||
{
|
||||
@@ -815,10 +889,12 @@ https://github.com/buu342/N64-UNFLoader
|
||||
switch (threadMsg->msgtype)
|
||||
{
|
||||
case MSG_WRITE:
|
||||
if (usb_timedout())
|
||||
usb_sendheartbeat();
|
||||
usb_write(threadMsg->datatype, threadMsg->buff, threadMsg->size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// If we're in libdragon, break out of the loop as we don't need it
|
||||
#ifdef LIBDRAGON
|
||||
break;
|
||||
@@ -837,7 +913,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
@param The amount of characters to write
|
||||
@returns The end of the buffer that was written to
|
||||
==============================*/
|
||||
|
||||
|
||||
static void* debug_osSyncPrintf_implementation(void *unused, const char *str, size_t len)
|
||||
{
|
||||
void* ret;
|
||||
@@ -859,7 +935,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_FAULTTHREAD
|
||||
|
||||
/*==============================
|
||||
@@ -869,7 +945,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
@param The name of the register
|
||||
@param The registry description to use
|
||||
==============================*/
|
||||
|
||||
|
||||
static void debug_printreg(u32 value, char *name, regDesc *desc)
|
||||
{
|
||||
char first = 1;
|
||||
@@ -897,11 +973,11 @@ https://github.com/buu342/N64-UNFLoader
|
||||
{
|
||||
OSMesg msg;
|
||||
OSThread *curr;
|
||||
|
||||
|
||||
// Create the message queue for the fault message
|
||||
osCreateMesgQueue(&faultMessageQ, &faultMessageBuf, 1);
|
||||
osSetEventMesg(OS_EVENT_FAULT, &faultMessageQ, (OSMesg)MSG_FAULT);
|
||||
|
||||
|
||||
// Thread loop
|
||||
while (1)
|
||||
{
|
||||
@@ -913,7 +989,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
if (curr != NULL)
|
||||
{
|
||||
__OSThreadContext* context = &curr->context;
|
||||
|
||||
|
||||
// Print the basic info
|
||||
debug_printf("Fault in thread: %d\n\n", curr->id);
|
||||
debug_printf("pc\t\t0x%08x\n", context->pc);
|
||||
@@ -935,7 +1011,7 @@ https://github.com/buu342/N64-UNFLoader
|
||||
debug_printf("s6 0x%016llx s7 0x%016llx t8 0x%016llx\n", context->s6, context->s7, context->t8);
|
||||
debug_printf("t9 0x%016llx gp 0x%016llx sp 0x%016llx\n", context->t9, context->gp, context->sp);
|
||||
debug_printf("s8 0x%016llx ra 0x%016llx\n\n", context->s8, context->ra);
|
||||
|
||||
|
||||
// Print the floating point registers
|
||||
debug_printreg(context->fpcsr, "fpcsr", fpcsrDesc);
|
||||
debug_printf("\n");
|
||||
@@ -954,4 +1030,4 @@ https://github.com/buu342/N64-UNFLoader
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
+14
-3
@@ -79,6 +79,16 @@
|
||||
#define debug_assert(expr) (expr) ? ((void)0) : _debug_assert(#expr, __FILE__, __LINE__)
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_64drivebutton
|
||||
Assigns a function to be executed when the 64drive button is pressed.
|
||||
@param The function pointer to execute
|
||||
@param Whether or not to execute the function only on pressing (ignore holding the button down)
|
||||
==============================*/
|
||||
|
||||
extern void debug_64drivebutton(void(*execute)(), char onpress);
|
||||
|
||||
|
||||
/*==============================
|
||||
debug_pollcommands
|
||||
Check the USB for incoming commands.
|
||||
@@ -92,7 +102,7 @@
|
||||
Adds a command for the USB to read.
|
||||
@param The command name
|
||||
@param The command description
|
||||
@param The function pointer to execute
|
||||
@param The function pointer to execute
|
||||
==============================*/
|
||||
|
||||
extern void debug_addcommand(char* command, char* description, char*(*execute)());
|
||||
@@ -136,14 +146,15 @@
|
||||
|
||||
// Overwrite library functions with useless macros if debug mode is disabled
|
||||
#define debug_initialize()
|
||||
#define debug_printf(__VA_ARGS__)
|
||||
#define debug_printf
|
||||
#define debug_screenshot(a, b, c)
|
||||
#define debug_assert(a)
|
||||
#define debug_pollcommands()
|
||||
#define debug_addcommand(a, b, c)
|
||||
#define debug_parsecommand() NULL
|
||||
#define debug_parsecommand(a) NULL
|
||||
#define debug_sizecommand() 0
|
||||
#define debug_printcommands()
|
||||
#define debug_64drivebutton(a, b)
|
||||
#define usb_initialize() 0
|
||||
#define usb_getcart() 0
|
||||
#define usb_write(a, b, c)
|
||||
|
||||
+674
-796
File diff suppressed because it is too large.
Load diff
+57
-37
@@ -1,43 +1,42 @@
|
||||
#ifndef UNFL_USB_H
|
||||
#define UNFL_USB_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
/*********************************
|
||||
DataType macros
|
||||
*********************************/
|
||||
|
||||
|
||||
// UNCOMMENT THE #DEFINE IF USING LIBDRAGON
|
||||
//#define LIBDRAGON
|
||||
//#define LIBDRAGON
|
||||
|
||||
// Settings
|
||||
#define USE_OSRAW 0 // Use if you're doing USB operations without the PI Manager (libultra only)
|
||||
#define DEBUG_ADDRESS_SIZE 8*1024*1024 // Max size of USB I/O. The bigger this value, the more ROM you lose!
|
||||
|
||||
#define CHECK_EMULATOR 0 // Stops the USB library from working if it detects an emulator to prevent problems
|
||||
|
||||
// Cart definitions
|
||||
#define CART_NONE 0
|
||||
#define CART_64DRIVE 1
|
||||
#define CART_EVERDRIVE 2
|
||||
#define CART_SC64 3
|
||||
|
||||
|
||||
// Data types defintions
|
||||
#define DATATYPE_TEXT 0x01
|
||||
#define DATATYPE_RAWBINARY 0x02
|
||||
#define DATATYPE_HEADER 0x03
|
||||
#define DATATYPE_SCREENSHOT 0x04
|
||||
|
||||
extern int usb_datatype;
|
||||
extern int usb_datasize;
|
||||
extern int usb_dataleft;
|
||||
extern int usb_readblock;
|
||||
#define DATATYPE_HEARTBEAT 0x05
|
||||
|
||||
|
||||
|
||||
/*********************************
|
||||
Convenience macros
|
||||
*********************************/
|
||||
|
||||
|
||||
// Use these to conveniently read the header from usb_poll()
|
||||
#define USBHEADER_GETTYPE(header) ((header & 0xFF000000) >> 24)
|
||||
#define USBHEADER_GETSIZE(header) ((header & 0x00FFFFFF))
|
||||
|
||||
|
||||
|
||||
/*********************************
|
||||
USB Functions
|
||||
@@ -48,19 +47,19 @@
|
||||
Initializes the USB buffers and pointers
|
||||
@return 1 if the USB initialization was successful, 0 if not
|
||||
==============================*/
|
||||
|
||||
|
||||
extern char usb_initialize();
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_getcart
|
||||
Returns which flashcart is currently connected
|
||||
@return The CART macro that corresponds to the identified flashcart
|
||||
==============================*/
|
||||
|
||||
|
||||
extern char usb_getcart();
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_write
|
||||
Writes data to the USB.
|
||||
@@ -69,53 +68,74 @@
|
||||
@param A buffer with the data to send
|
||||
@param The size of the data being sent
|
||||
==============================*/
|
||||
|
||||
|
||||
extern void usb_write(int datatype, const void* data, int size);
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_poll
|
||||
Returns the header of data being received via USB
|
||||
The first byte contains the data type, the next 3 the number of bytes left to read
|
||||
@return The data header, or 0
|
||||
==============================*/
|
||||
|
||||
extern unsigned long usb_poll();
|
||||
|
||||
|
||||
|
||||
extern u32 usb_poll();
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_read
|
||||
Reads bytes from USB into the provided buffer
|
||||
@param The buffer to put the read data in
|
||||
@param The number of bytes to read
|
||||
==============================*/
|
||||
|
||||
|
||||
extern void usb_read(void* buffer, int size);
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_skip
|
||||
Skips a USB read by the specified amount of bytes
|
||||
@param The number of bytes to skip
|
||||
==============================*/
|
||||
|
||||
|
||||
extern void usb_skip(int nbytes);
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_rewind
|
||||
Rewinds a USB read by the specified amount of bytes
|
||||
@param The number of bytes to rewind
|
||||
==============================*/
|
||||
|
||||
|
||||
extern void usb_rewind(int nbytes);
|
||||
|
||||
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_purge
|
||||
Purges the incoming USB data
|
||||
==============================*/
|
||||
|
||||
|
||||
extern void usb_purge();
|
||||
|
||||
#endif
|
||||
|
||||
/*==============================
|
||||
usb_timedout
|
||||
Checks if the USB timed out recently
|
||||
@return 1 if the USB timed out, 0 if not
|
||||
==============================*/
|
||||
|
||||
extern char usb_timedout();
|
||||
|
||||
|
||||
/*==============================
|
||||
usb_sendheartbeat
|
||||
Sends a heartbeat packet to the PC
|
||||
This is done once automatically at initialization,
|
||||
but can be called manually to ensure that the
|
||||
host side tool is aware of the current USB protocol
|
||||
version.
|
||||
==============================*/
|
||||
|
||||
extern void usb_sendheartbeat();
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user