Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/373307D9/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
"system/movie/Movie.cpp": "Matching",
"system/movie/MovieImpl.cpp": "Matching",
"system/movie/MovieSys.cpp": "Matching",
"system/movie/Splash.cpp": "NonMatching",
"system/movie/Splash.cpp": "Matching",
"system/movie/TexMovie.cpp": "Matching",
"system/moviebink/BinkMovieImpl.cpp": "NonMatching",
"system/moviebink/BinkMovieImpl_Xbox.cpp": "MISSING",
Expand Down
2 changes: 1 addition & 1 deletion config/373307D9/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180417,7 +180417,7 @@ merged_82AF65E8 = .text:0x82AF65E8; // type:function size:0x5C scope:global
??1?$CSPGUIDPtrHash@PAVCFEClassInfo@NUISPEECH@@@NUISPEECH@@UAA@XZ = .text:0x82AF6648; // type:function size:0x5C scope:global
?DestroyValue@?$CSPGUIDPtrHash@PAVCFEClassInfo@NUISPEECH@@@NUISPEECH@@MBAXPAVCFEClassInfo@2@@Z = .text:0x82AF66A8; // type:function size:0x18 scope:global
merged_82AF66C0 = .text:0x82AF66C0; // type:function size:0x230 scope:global
merged_82AF68F0 = .text:0x82AF68F0; // type:function size:0x8 scope:global
merged_Get0x3C = .text:0x82AF68F0; // type:function size:0x8 scope:global
?Reset@CFEWaveStreamDecoder@NUISPEECH@@UAAJXZ = .text:0x82AF68F8; // type:function size:0x30 scope:global
merged_82AF6928 = .text:0x82AF6928; // type:function size:0x5C scope:global
?CreateDecoder@CFEWaveStreamCoder@NUISPEECH@@UAAPAVCFEStreamDecoder@2@XZ = .text:0x82AF6988; // type:function size:0x94 scope:global
Expand Down
6 changes: 6 additions & 0 deletions src/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#define SEH_TRY __try
#define SEH_EXCEPT __except
#define SEH_FINALLY __finally

#define ALIGN(x) __declspec(align(x))
#define INTRIN __declspec(intrin_type)
#else
#define CDECL
#define STDCALL
Expand All @@ -18,6 +21,9 @@
#define SEH_TRY try
#define SEH_EXCEPT catch
#define SEH_FINALLY ;

#define ALIGN(x) alignas(x)
#define INTRIN
#endif

// #define ROTATE_LEFT(x, i) (((x) << (i)) | ((x) >> ((sizeof((x)) * 8) - (i))))
Expand Down
59 changes: 57 additions & 2 deletions src/system/movie/Splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Splash::Suspend() {
} else {
WaitForState(kSuspended);
}
unk200.Reset();
unk_0xC8.Reset();
}
}

Expand Down Expand Up @@ -202,6 +202,60 @@ void Splash::Poll() {
}
}

void Splash::Draw() {
if (unk18.SplitMs() <= mSplashTime) {
if (!unk5c || unk50 != nullptr || unk54 != nullptr) {
if (unk54 != nullptr) {
TheTaskMgr.Poll();
unk48->Poll();
}
if (unk50 != nullptr) {
if (MainThread()) {
float allowance = unk50->GetMovie().MsPerFrame() - 1.0f;
if (unk_0xC8.Running() != 0 && unk_0xC8.SplitMs() < allowance) {
return;
}
unk_0xC8.Restart();
}
if (unk50->GetMovie().Poll() == false) {
mSplashTime = 0;
return;
}
}
for (int i = 0; i < 2; i++) {
TheRnd.BeginDrawing();
unk4c->Select();
unk48->DrawShowing();
TheRnd.EndDrawing();
if (unk50 != nullptr)
break;
if (unk54 != nullptr)
break;
}
if (unk50 == nullptr && unk54 == nullptr) {
TheNgRnd.Suspend();
}
unk5c = true;
}
int synctime = 0;
if (!MainThread()) {
synctime = mSplashTime - int(unk18.SplitMs());
if (unk50 != nullptr) {
float allowance = unk50->GetMovie().MsPerFrame() - 1.0f;
if (int(allowance) < synctime) {
synctime = allowance;
}
if (synctime < 0) {
synctime = 0;
}
} else if (unk54 != nullptr) {
synctime = 16;
}
unk90.Wait(synctime);
}
}
}

bool Splash::SetMutableState(Splash::SplashState state) {
MILO_ASSERT(state <= kResumed, 0x13b);
CritSecTracker tracker(&unk6c);
Expand Down Expand Up @@ -231,7 +285,8 @@ bool Splash::SetImmutableState(Splash::SplashState state) {

void Splash::WaitForState(Splash::SplashState state) {
MILO_ASSERT_FMT(unk64, "Can't WaitForState");
while (mState != state && (state != kResumed || mState <= kResumed)) {
while (mState != state
&& (state != kResumed || (volatile SplashState)mState <= kResumed)) {
MainThread() ? unk8c.Wait(-1) : unk90.Wait(-1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/system/movie/Splash.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Splash {
CriticalSection unk98;
std::list<PreparedScreenParams> mPreparedScreens; // 0xb8
std::list<RndDir *> unkc0;
Timer unk200;
Timer unk_0xC8;
void *mThreadStack;

protected:
Expand Down
18 changes: 17 additions & 1 deletion src/system/moviebink/BinkMovieImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,23 @@ void BinkMovieImpl::FinishOpen() {
BinkSetSoundOnOff(mBink, unk27 == 0);
BINKSUMMARY summary;
BinkGetSummary(mBink, &summary);

mAspect = float(summary.Width) / summary.Height;
int width_low_4 = summary.Width % 16;
if (summary.Height % 16 != 0 || width_low_4 != 0) {
int height_low_4 = summary.Height % 16;
int width_fixed = summary.Width;
width_fixed += width_low_4 != 0 ? 16 - width_low_4 : 0;
int height_fixed = summary.Height;
height_fixed += height_low_4 != 0 ? 16 - height_low_4 : 0;
MILO_FAIL(
"Bink movie %s must have multiples of 16 for its width and height.\nTry changing from %d x %d to %d x %d.",
mName.c_str(),
summary.Width,
summary.Height,
width_fixed,
height_fixed
);
}
SetRect();
SetPaused(true);
}
Expand Down
38 changes: 38 additions & 0 deletions src/system/synth360/GainEffect.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
#include "synth360/GainEffect.h"
#include "vectorintrinsics.h"
#include <cstddef>
#include <cstring>

float GainEffect::sGain = 1;

GainEffect::GainEffect() {
GainEffectParams p;
SetParameters(&p, sizeof(p));
}

void GainEffect::DoProcess(
const GainEffectParams &, float *samples, uint samplect, uint channelct
) {
uint data_count = samplect * channelct;
XMVECTOR *samples_simd = reinterpret_cast<XMVECTOR *>(samples);
XMVECTOR gain;
gain.v[0] = sGain;
for (int i = 0; i < 3; i++) {
gain.u[i + 1] = gain.u[i];
}
float *endpoint = samples + data_count;
if (samples >= endpoint)
return;
int i = 0;
uint pass_count =
reinterpret_cast<char *>(endpoint) - reinterpret_cast<char *>(samples) - 1;
pass_count /= sizeof(XMVECTOR) * 4;
pass_count++;
do { // why like this...?
XMVECTOR v0 = __lvx(samples_simd + i, 0x00);
XMVECTOR v1 = __lvx(samples_simd + i, 0x10);
XMVECTOR v2 = __lvx(samples_simd + i, 0x20);
XMVECTOR v3 = __lvx(samples_simd + i, 0x30);
v0 = __vmulfp(v0, gain);
v1 = __vmulfp(v1, gain);
v2 = __vmulfp(v2, gain);
v3 = __vmulfp(v3, gain);
__stvx(v0, samples_simd + i, 0x00);
__stvx(v1, samples_simd + i, 0x10);
__stvx(v2, samples_simd + i, 0x20);
__stvx(v3, samples_simd + i, 0x30);
i += 4;
} while (--pass_count);
}
24 changes: 24 additions & 0 deletions src/system/synth360/SampleInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "synth/FxSend.h"
#include "synth360/SynthSample.h"
#include "synth360/FxSend.h"
#include "xdk/win_types.h"
#include "xdk/xaudio2/xaudio2.h"

SampleInst360::SampleInst360(SynthSample360 *sample, bool loop, int loopStart, int loopEnd)
: SampleInst(sample),
Expand Down Expand Up @@ -33,6 +35,28 @@ float SampleInst360::ElapsedTime() {
return samples / rate;
}

float SampleInst360::GetProgress() {
XAUDIO2_VOICE_STATE state;
mVoice->GetVoice()->GetState(&state, 0);
SIZE_T samples = state.SamplesPlayed;
if (mVoice->GetLoopStart() >= 0) {
int sample_start = mVoice->GetSampleStart();
samples -= sample_start;
int loop_start = mVoice->GetLoopStart();
int loop_end = mVoice->GetLoopEnd();
if (loop_end == -1) {
loop_end = mVoice->GetSampleCount();
}
int loop_size = loop_end - loop_start;
int loop_count = samples / loop_size;
samples -= loop_count * loop_size;
samples += sample_start;
}
float len = mSample->LengthMs();
float rate = mSample->GetSampleRate();
return (samples * 1000.0f) / (rate * len);
}

void SampleInst360::StartImpl() { mVoice->Start(); }
void SampleInst360::StopImpl(bool b1) { mVoice->Stop(b1); }
void SampleInst360::SetVolumeImpl(float f1) { mVoice->SetVolume(f1); }
Expand Down
4 changes: 4 additions & 0 deletions src/system/synth360/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class Voice {
void Start();

IXAudio2SourceVoice *GetVoice() { return mPoolVoice.voice; }
int GetSampleStart() const { return mSampleStart; }
int GetSampleCount() const { return mNumSamples; }
int GetLoopStart() const { return mLoopStart; }
int GetLoopEnd() const { return mLoopEnd; }
void SetAttackRate(float r) { unk30 = r; }
void SetReleaseRate(float r) { unk34 = r; }
void SetUnk50(int i) { unk50 = i; }
Expand Down
7 changes: 6 additions & 1 deletion src/xdk/LIBCMT/vectorintrinsics.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include "macros.h"

// A C representation of a VMX register.
typedef struct __declspec(intrin_type) __declspec(align(16)) __vector4 { /* Size=0x10 */
typedef struct INTRIN ALIGN(16) __vector4 { /* Size=0x10 */
union {
/* 0x0000 */ float vector4_f32[4];
/* 0x0000 */ unsigned int vector4_u32[4];
Expand Down Expand Up @@ -119,6 +121,9 @@ XMVECTOR __vmaddfp(XMVECTOR mul1, XMVECTOR mul2, XMVECTOR addend);
// Vector128 Splat Word
XMVECTOR __vspltw(XMVECTOR vSrcA, unsigned int uImmed);

// Vector128 Multiply Floating-Point
XMVECTOR __vmulfp(XMVECTOR vSrcA, XMVECTOR vSrcB);

#ifdef __cplusplus
}
#endif
Loading