mirror of https://github.com/PrimeDecomp/prime.git
Minor fixes and cleanup
Former-commit-id: 362dcbcaa40ad64c42fec541fff855d69bc4372a
This commit is contained in:
parent
5538fd2e4e
commit
48bc018adb
|
@ -163,7 +163,7 @@ static inline int __fpclassifyd(double x) {
|
||||||
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
#define isinf(x) (fpclassify(x) == FP_INFINITE)
|
||||||
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
|
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
|
||||||
|
|
||||||
static inline float sqrtf(float x) {
|
_MATH_INLINE float sqrtf(float x) {
|
||||||
const double _half = .5;
|
const double _half = .5;
|
||||||
const double _three = 3.0;
|
const double _three = 3.0;
|
||||||
volatile float y;
|
volatile float y;
|
||||||
|
@ -182,7 +182,7 @@ static inline float sqrtf(float x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double sqrt(double x) {
|
_MATH_INLINE double sqrt(double x) {
|
||||||
if (x > 0.0) {
|
if (x > 0.0) {
|
||||||
double guess = __frsqrte(x); /* returns an approximation to */
|
double guess = __frsqrte(x); /* returns an approximation to */
|
||||||
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
|
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
|
||||||
|
|
|
@ -177,7 +177,23 @@ void* SMediumAllocPuddle::FindFreeEntry(uint numBlocks) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMediumAllocPuddle::Free(const void* ptr) {}
|
void SMediumAllocPuddle::Free(const void* ptr) {
|
||||||
|
uint r28 = 0;
|
||||||
|
uint r29 = x8_bookKeeping[((uint)ptr - (uint)x0_mainData.get()) / 32];
|
||||||
|
x14_numBlocks += r29;
|
||||||
|
x18_numAllocs--;
|
||||||
|
uchar* bookKeepingStart = x8_bookKeeping;
|
||||||
|
uchar* block = &x8_bookKeeping[((uint)ptr - (uint)x0_mainData.get()) / 32];
|
||||||
|
|
||||||
|
if (xc_cachedBookKeepingAddr == block) {
|
||||||
|
r28 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block > bookKeepingStart) {
|
||||||
|
if ((block[-1] & 0x80) != 0) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ushort SMediumAllocPuddle::GetBlockOffset(const void* ptr1, const void* ptr2) {
|
ushort SMediumAllocPuddle::GetBlockOffset(const void* ptr1, const void* ptr2) {
|
||||||
unsigned char tmp = (uchar*)ptr2 - (uchar*)ptr1 > 1 ? ((uchar*)ptr1)[1] : 0;
|
unsigned char tmp = (uchar*)ptr2 - (uchar*)ptr1 > 1 ? ((uchar*)ptr1)[1] : 0;
|
||||||
|
|
|
@ -64,9 +64,9 @@ bool area_sorter::operator()(const CGameArea* a, const CGameArea* b) const {
|
||||||
class CLightPredicate {
|
class CLightPredicate {
|
||||||
public:
|
public:
|
||||||
bool operator()(const CLight& a, const CLight& b) const {
|
bool operator()(const CLight& a, const CLight& b) const {
|
||||||
if (b.GetPriority() > a.GetPriority()) {
|
if (a.GetPriority() > b.GetPriority()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (b.GetPriority() == a.GetPriority()) {
|
} else if (a.GetPriority() == b.GetPriority()) {
|
||||||
return a.GetIntensity() > b.GetIntensity();
|
return a.GetIntensity() > b.GetIntensity();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -464,8 +464,14 @@ void hwSaveSample(void* header, void* data) {
|
||||||
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize) { aramSetUploadCallback(callback, chunckSize); }
|
void hwSetSaveSampleCallback(ARAMUploadCallback callback, unsigned long chunckSize) { aramSetUploadCallback(callback, chunckSize); }
|
||||||
|
|
||||||
void hwRemoveSample(void* header, void* data) {
|
void hwRemoveSample(void* header, void* data) {
|
||||||
|
#if MUSY_VERSION <= MUSY_VERSION_CHECK(1, 5, 3)
|
||||||
|
u32 len = (((u32*)header))[1] & 0xFFFFFF;
|
||||||
|
u8 type = (((u32*)header))[1] >> 0x18;
|
||||||
|
len = convert_length(len, type);
|
||||||
|
#else
|
||||||
u8 type = (((u32*)header))[1] >> 0x18;
|
u8 type = (((u32*)header))[1] >> 0x18;
|
||||||
u32 len = convert_length((((u32*)header))[1] & 0xFFFFFF, type);
|
u32 len = convert_length((((u32*)header))[1] & 0xFFFFFF, type);
|
||||||
|
#endif
|
||||||
aramRemoveData(data, len);
|
aramRemoveData(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,14 @@ static volatile OSTick salLastTick = 0;
|
||||||
static volatile u32 salLogicActive = 0;
|
static volatile u32 salLogicActive = 0;
|
||||||
static volatile u32 salLogicIsWaiting = 0;
|
static volatile u32 salLogicIsWaiting = 0;
|
||||||
static volatile u32 salDspIsDone = 0;
|
static volatile u32 salDspIsDone = 0;
|
||||||
static void* salAIBufferBase = NULL;
|
void* salAIBufferBase = NULL;
|
||||||
static u8 salAIBufferIndex = 0;
|
static u8 salAIBufferIndex = 0;
|
||||||
SND_SOME_CALLBACK userCallback = NULL;
|
static SND_SOME_CALLBACK userCallback = NULL;
|
||||||
|
|
||||||
#define DMA_BUFFER_LEN 0x280
|
#define DMA_BUFFER_LEN 0x280
|
||||||
|
|
||||||
u32 salGetStartDelay();
|
u32 salGetStartDelay();
|
||||||
|
static void callUserCallback() {
|
||||||
void callUserCallback() {
|
|
||||||
if (salLogicActive) {
|
if (salLogicActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +45,8 @@ void salCallback() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void dspInitCallback() {
|
void dspInitCallback() {
|
||||||
salDspIsDone = TRUE;
|
salDspIsDone = TRUE;
|
||||||
salDspInitIsDone = TRUE;
|
salDspInitIsDone = TRUE;
|
||||||
|
@ -89,10 +90,13 @@ u32 salExitAi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* salAiGetDest() {
|
void* salAiGetDest() {
|
||||||
return (void*)((u32)salAIBufferBase + (u8)((salAIBufferIndex + 2) % 4) * DMA_BUFFER_LEN);
|
u8 index; // r31
|
||||||
|
index = (salAIBufferIndex + 2) % 4;
|
||||||
|
return (void*)((u8*)salAIBufferBase + index * DMA_BUFFER_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 salInitDsp() {
|
u32 salInitDsp() {
|
||||||
|
u8 _[8];
|
||||||
dsp_task.iram_mmem_addr = (u16*)dspSlave;
|
dsp_task.iram_mmem_addr = (u16*)dspSlave;
|
||||||
dsp_task.iram_length = dspSlaveLength;
|
dsp_task.iram_length = dspSlaveLength;
|
||||||
dsp_task.iram_addr = 0;
|
dsp_task.iram_addr = 0;
|
||||||
|
|
|
@ -218,6 +218,8 @@ bool dataRemoveCurve(u16 sid) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SDIR(sd) ((SDIR_DATA*)((u8*)sd + 0))
|
||||||
|
|
||||||
bool dataInsertSDir(SDIR_DATA* sdir, void* smp_data) {
|
bool dataInsertSDir(SDIR_DATA* sdir, void* smp_data) {
|
||||||
s32 i; // r31
|
s32 i; // r31
|
||||||
SDIR_DATA* s; // r25
|
SDIR_DATA* s; // r25
|
||||||
|
@ -230,25 +232,24 @@ bool dataInsertSDir(SDIR_DATA* sdir, void* smp_data) {
|
||||||
if (i == dataSmpSDirNum) {
|
if (i == dataSmpSDirNum) {
|
||||||
if (dataSmpSDirNum < 128) {
|
if (dataSmpSDirNum < 128) {
|
||||||
n = 0;
|
n = 0;
|
||||||
for (s = sdir; s->id != 0xffff; ++s) {
|
for (s = SDIR(sdir); s->id != 0xffff; ++s) {
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwDisableIrq();
|
hwDisableIrq();
|
||||||
|
|
||||||
for (j = 0; j < n; ++j) {
|
for (j = 0; j < n; ++j) {
|
||||||
for (i = 0; i < dataSmpSDirNum; ++i) {
|
for (i = 0; i < dataSmpSDirNum; ++i) {
|
||||||
for (k = 0; k < dataSmpSDirs[i].numSmp; ++k) {
|
for (k = 0; k < dataSmpSDirs[i].numSmp; ++k) {
|
||||||
if (sdir[j].id == dataSmpSDirs[i].data[k].id)
|
if (sdir[j].id == dataSmpSDirs[i].data[k].id)
|
||||||
goto done_loop;
|
goto found_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
found_id:
|
||||||
done_loop:
|
if (i != dataSmpSDirNum) {
|
||||||
if (i == dataSmpSDirNum) {
|
|
||||||
sdir[j].ref_cnt = 0;
|
|
||||||
} else {
|
|
||||||
sdir[j].ref_cnt = 0xffff;
|
sdir[j].ref_cnt = 0xffff;
|
||||||
|
} else {
|
||||||
|
sdir[j].ref_cnt = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSmpSDirs[dataSmpSDirNum].data = sdir;
|
dataSmpSDirs[dataSmpSDirNum].data = sdir;
|
||||||
|
|
Loading…
Reference in New Issue