2023-11-13 18:23:10 +00:00
|
|
|
#include "ob.h"
|
|
|
|
#include "mem.h"
|
2024-05-06 16:47:06 +00:00
|
|
|
#include "spool.h"
|
2023-11-13 18:23:10 +00:00
|
|
|
#include <cstring>
|
2024-02-25 14:55:59 +00:00
|
|
|
#include "validate.h"
|
2024-05-07 16:43:26 +00:00
|
|
|
#include "ps2redbook.h"
|
2024-05-08 21:24:34 +00:00
|
|
|
#include "ps2m3d.h"
|
|
|
|
#include "m3dutils.h"
|
2023-11-13 18:23:10 +00:00
|
|
|
|
|
|
|
|
2024-05-06 16:30:21 +00:00
|
|
|
// @Ok
|
|
|
|
// Random move from global to eax and test eax, eax that doesn't change shit
|
2023-11-13 18:23:10 +00:00
|
|
|
void* CItem::operator new(unsigned int size) {
|
|
|
|
|
|
|
|
void *result = DCMem_New(size, 0, 1, 0, 1);
|
|
|
|
|
|
|
|
unsigned int adjusted_size = ((size + 3) & 0xFFFFFFFC) >> 2;
|
|
|
|
if ( adjusted_size )
|
|
|
|
memset(result, 0, 4 * adjusted_size);
|
|
|
|
|
|
|
|
return result;
|
2024-02-25 14:55:59 +00:00
|
|
|
}
|
|
|
|
|
2024-05-21 18:09:54 +00:00
|
|
|
// @Ok
|
2024-05-21 16:47:51 +00:00
|
|
|
void CItem::operator delete(void *ptr)
|
|
|
|
{
|
|
|
|
Mem_Delete(ptr);
|
|
|
|
}
|
|
|
|
|
2024-02-25 14:55:59 +00:00
|
|
|
|
2024-05-06 16:30:21 +00:00
|
|
|
/// @NotOk
|
|
|
|
// missing 3C assignement need to understand what it is
|
2024-05-07 17:48:31 +00:00
|
|
|
__inline CItem::CItem()
|
2024-05-06 16:30:21 +00:00
|
|
|
{
|
|
|
|
this->mPos.vx = 0;
|
|
|
|
this->mPos.vy = 0;
|
|
|
|
this->mPos.vz = 0;
|
|
|
|
|
|
|
|
|
|
|
|
this->mAngles.vx = 0;
|
|
|
|
this->mAngles.vy = 0;
|
|
|
|
this->mAngles.vz = 0;
|
|
|
|
|
|
|
|
//this->field_2C = 0;
|
|
|
|
|
|
|
|
this->field_28 = 0x1000;
|
|
|
|
this->field_2A = 0x1000;
|
|
|
|
this->field_2C = 0x1000;
|
|
|
|
|
|
|
|
///this->field_3C = ???;
|
|
|
|
}
|
2024-02-25 14:55:59 +00:00
|
|
|
|
2024-05-21 16:47:51 +00:00
|
|
|
// @Ok
|
|
|
|
// First part is for delete[]
|
|
|
|
// second is for delete, nothing to do
|
|
|
|
CItem::~CItem()
|
|
|
|
{
|
|
|
|
}
|
2024-02-25 14:55:59 +00:00
|
|
|
|
2024-05-21 17:16:43 +00:00
|
|
|
// @Ok
|
|
|
|
void CBody::AI(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Ok
|
|
|
|
int CBody::Hit(SHitInfo*)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @TODO
|
|
|
|
void CBody::UnknownVirtualFuction(void)
|
|
|
|
{
|
|
|
|
}
|
2024-05-07 15:49:34 +00:00
|
|
|
|
2024-05-06 16:47:06 +00:00
|
|
|
// @NotOk
|
|
|
|
// indices not matching, rest is okay
|
|
|
|
void CItem::InitItem(const char * a1)
|
2024-02-25 14:55:59 +00:00
|
|
|
{
|
|
|
|
|
2024-05-06 16:47:06 +00:00
|
|
|
int Region = Spool_FindRegion(a1);
|
|
|
|
this->mRegion = Region;
|
2024-02-25 14:55:59 +00:00
|
|
|
this->mModel = 0;
|
2024-05-06 16:47:06 +00:00
|
|
|
|
|
|
|
int index = (Region & 0xFF) * 0x11;
|
|
|
|
|
|
|
|
if (Regions[index])
|
|
|
|
{
|
|
|
|
int *tmp = *CItemRelatedList[index];
|
|
|
|
tmp[2] = 0x64000;
|
|
|
|
tmp[3] = 0xFF9C0064;
|
|
|
|
tmp[4] = 0xFF9C0064;
|
|
|
|
tmp[5] = 0xFF9C0064;
|
|
|
|
}
|
2024-02-25 14:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-03 16:47:50 +00:00
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
// @Ok
|
|
|
|
// has weird xor eax, eax at the top
|
2024-03-03 16:47:50 +00:00
|
|
|
int __inline CBody::IsDead(void) const{
|
2024-03-03 18:26:01 +00:00
|
|
|
return (this->mCBodyFlags >> 6) & 1;
|
2024-03-03 16:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
|
|
|
|
// @Ok
|
2024-03-03 16:47:50 +00:00
|
|
|
void CBody::Die(void){
|
|
|
|
int isDead = this->IsDead();
|
|
|
|
if(!isDead)
|
|
|
|
{
|
2024-03-03 18:26:01 +00:00
|
|
|
this->mCBodyFlags |= 0x40;
|
2024-03-03 16:47:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
// @Ok
|
2024-03-03 18:26:01 +00:00
|
|
|
void CBody::ShadowOn(void){
|
|
|
|
this->mCBodyFlags |= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
// @NotOk
|
|
|
|
// dessutrctor
|
2024-03-03 18:26:01 +00:00
|
|
|
void __inline CBody::KillShadow(void){
|
|
|
|
|
|
|
|
this->mCBodyFlags &= ~8u;
|
|
|
|
if ( this->bodyQuadBit )
|
|
|
|
{
|
|
|
|
//result = (**somethingWithVtableDestructor)(somethingWithVtableDestructor, 1);
|
|
|
|
this->bodyQuadBit = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
// @NotOk
|
|
|
|
// Inlined KillShadow and weird part where we store data but it's just xor eax, eax
|
2024-03-03 18:26:01 +00:00
|
|
|
void CBody::UpdateShadow(void){
|
|
|
|
|
|
|
|
__int16 flags = this->mCBodyFlags;
|
|
|
|
|
|
|
|
if(flags & 8){
|
|
|
|
|
|
|
|
if(!this->bodyQuadBit){
|
2024-03-03 19:00:31 +00:00
|
|
|
|
|
|
|
CQuadBit *quad = new CQuadBit();
|
|
|
|
this->bodyQuadBit = quad;
|
|
|
|
|
|
|
|
quad->SetTexture(0, 0);
|
|
|
|
this->bodyQuadBit->SetSubtractiveTransparency();
|
|
|
|
this->bodyQuadBit->mFrigDeltaZ = 32;
|
|
|
|
this->bodyQuadBit->mProtected = 1;
|
2024-03-03 18:26:01 +00:00
|
|
|
}
|
|
|
|
|
2024-03-03 19:00:31 +00:00
|
|
|
SVector vec;
|
|
|
|
vec.vx = 0;
|
|
|
|
vec.vy = -4096;
|
|
|
|
vec.vz = 0;
|
|
|
|
|
|
|
|
unsigned __int16 lastParam = this->field_D0;
|
|
|
|
this->bodyQuadBit->OrientUsing(&this->bodyVector, &vec, lastParam, lastParam);
|
|
|
|
|
|
|
|
|
|
|
|
__int8 trans = ((this->field_D4 - this->field_D2) << 7) / this->field_D4;
|
|
|
|
|
|
|
|
if(trans < 0){
|
|
|
|
trans = 0;
|
|
|
|
}
|
2024-03-03 18:26:01 +00:00
|
|
|
|
2024-03-03 19:00:31 +00:00
|
|
|
this->bodyQuadBit->SetTransparency(trans);
|
2024-03-03 18:26:01 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this->KillShadow();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-03-06 17:00:25 +00:00
|
|
|
|
2024-05-07 15:49:34 +00:00
|
|
|
// @Ok
|
2024-05-07 17:11:14 +00:00
|
|
|
void __inline CBody::AttachTo(CBody** a1)
|
2024-05-07 15:49:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
CBody *v2 = *a1;
|
|
|
|
this->field_34 = 0;
|
|
|
|
this->field_20 = v2;
|
|
|
|
|
|
|
|
*a1 = this;
|
|
|
|
|
|
|
|
CItem *v3 = this->field_20;
|
|
|
|
if (v3)
|
|
|
|
v3->field_34 = this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-05-07 17:11:14 +00:00
|
|
|
// @NotOk
|
|
|
|
// remove constants
|
|
|
|
void __inline CBody::DeleteFrom(CBody **a2)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(this->mCBodyFlags & 1 && a2 != reinterpret_cast<CBody**>(0x60DAB4))
|
|
|
|
{
|
|
|
|
this->UnSuspend();
|
|
|
|
}
|
|
|
|
|
|
|
|
CItem *v6 = this->field_20;
|
|
|
|
if (v6)
|
|
|
|
v6->field_34 = this->field_34;
|
|
|
|
|
|
|
|
CItem *r = this->field_34;
|
|
|
|
if (r)
|
|
|
|
r->field_20 = this->field_20;
|
|
|
|
|
|
|
|
if (*a2 == this)
|
|
|
|
*a2 = reinterpret_cast<CBody*>(this->field_20);
|
|
|
|
}
|
|
|
|
|
|
|
|
// @NotOk
|
|
|
|
// looks good, but I think the constants are fucking it up
|
|
|
|
void __inline CBody::UnSuspend(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (this->mCBodyFlags & 1)
|
|
|
|
{
|
|
|
|
this->DeleteFrom(reinterpret_cast<CBody**>(0x60DAB4));
|
|
|
|
this->AttachTo(this->field_40);
|
|
|
|
this->mCBodyFlags &= 0xFFFE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 17:22:28 +00:00
|
|
|
// @NotOk
|
|
|
|
// removed constants
|
|
|
|
void CBody::Suspend(CBody **a2)
|
|
|
|
{
|
|
|
|
print_if_false((this->mCBodyFlags & 1) == 0, "Suspended flag illegally set");
|
|
|
|
print_if_false(a2 != 0, "woops");
|
|
|
|
|
2024-05-21 17:20:58 +00:00
|
|
|
this->UnknownVirtualFuction();
|
2024-05-07 17:22:28 +00:00
|
|
|
|
|
|
|
this->field_40 = a2;
|
|
|
|
this->DeleteFrom(a2);
|
|
|
|
|
|
|
|
this->AttachTo(reinterpret_cast<CBody**>(0x60DAB4));
|
|
|
|
this->mCBodyFlags |= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-07 17:11:14 +00:00
|
|
|
|
2024-05-21 17:20:58 +00:00
|
|
|
// @Ok
|
2024-05-07 16:04:53 +00:00
|
|
|
void CBody::InterleaveAI(void)
|
|
|
|
{
|
|
|
|
if (this->mFlags & 2)
|
|
|
|
{
|
|
|
|
this->EveryFrame();
|
|
|
|
CSuper *super = reinterpret_cast<CSuper*>(this);
|
|
|
|
super->UpdateFrame();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->EveryFrame();
|
|
|
|
}
|
|
|
|
|
2024-05-21 17:20:58 +00:00
|
|
|
this->AI();
|
2024-05-07 16:04:53 +00:00
|
|
|
}
|
|
|
|
|
2024-05-07 16:13:22 +00:00
|
|
|
// @Ok
|
|
|
|
// almost close, lea on original mov on mine
|
|
|
|
int* CBody::SquirtPos(int *params)
|
|
|
|
{
|
|
|
|
print_if_false(((int)params & 3) == 0, "Bad alignment");
|
|
|
|
|
2024-05-07 16:25:30 +00:00
|
|
|
this->mPos.vx = *params++ << 12;
|
2024-05-07 16:13:22 +00:00
|
|
|
|
2024-05-07 16:25:30 +00:00
|
|
|
this->mPos.vy = *params++ << 12;
|
2024-05-07 16:13:22 +00:00
|
|
|
|
2024-05-07 16:25:30 +00:00
|
|
|
this->mPos.vz = *params++ << 12;
|
|
|
|
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Ok
|
|
|
|
__int16* CBody::SquirtAngles(__int16* params)
|
|
|
|
{
|
|
|
|
this->mAngles.vx = *params++;
|
|
|
|
this->mAngles.vy = *params++;
|
|
|
|
this->mAngles.vz = *params++;
|
|
|
|
|
2024-05-07 16:13:22 +00:00
|
|
|
return params;
|
|
|
|
}
|
2024-05-07 15:49:34 +00:00
|
|
|
|
2024-05-07 16:34:21 +00:00
|
|
|
static int * const dword_6B4CA0 = (int*)0x6B4CA0;
|
|
|
|
|
|
|
|
// @NotOk
|
|
|
|
// replace dword_
|
|
|
|
void CBody::AttachXA(int a2, int a3)
|
|
|
|
{
|
|
|
|
this->field_98 = *dword_6B4CA0;
|
|
|
|
this->field_9C = a2;
|
|
|
|
this->field_A0 = a3;
|
|
|
|
}
|
|
|
|
|
2024-05-07 16:43:26 +00:00
|
|
|
static int * const dword_681D1C = (int*)0x681D1C;
|
|
|
|
static int * const dword_6612C0 = (int*)0x6612C0;
|
|
|
|
|
|
|
|
// @NotOk
|
|
|
|
// Replace dword_
|
|
|
|
void CBody::StopMyXA(void)
|
|
|
|
{
|
|
|
|
if ( (unsigned int)(*dword_6B4CA0 - this->field_98) < 0x12C
|
|
|
|
&& *dword_681D1C == this->field_9C
|
|
|
|
&& *dword_6612C0 == this->field_A0)
|
|
|
|
{
|
|
|
|
Redbook_XAStop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 17:48:31 +00:00
|
|
|
// @NotOk
|
|
|
|
// field reassignement + missing vtable
|
|
|
|
// need to understand whether the default constructor is called by default and then overriden
|
|
|
|
CBody::CBody()
|
|
|
|
{
|
|
|
|
this->field_48 = 0;
|
|
|
|
this->field_4C = 0;
|
|
|
|
this->field_50 = 0;
|
|
|
|
this->field_54 = 0;
|
|
|
|
this->field_58 = 0;
|
|
|
|
this->field_5C = 0;
|
|
|
|
|
|
|
|
this->mAccellorVel.vx = 0;
|
|
|
|
this->mAccellorVel.vy = 0;
|
|
|
|
this->mAccellorVel.vz = 0;
|
|
|
|
|
|
|
|
|
|
|
|
this->gVec.vx = 0;
|
|
|
|
this->gVec.vy = 0;
|
|
|
|
this->gVec.vz = 0;
|
|
|
|
|
|
|
|
this->field_78 = 0;
|
|
|
|
this->field_79 = 0;
|
|
|
|
this->field_7A = 0;
|
|
|
|
|
|
|
|
|
|
|
|
this->csVector1.vx = 0;
|
|
|
|
this->csVector1.vy = 0;
|
|
|
|
this->csVector1.vz = 0;
|
|
|
|
|
|
|
|
this->field_8E.vx = 0;
|
|
|
|
this->field_8E.vy = 0;
|
|
|
|
this->field_8E.vz = 0;
|
|
|
|
|
|
|
|
this->field_94 = 0;
|
|
|
|
this->field_95 = 0;
|
|
|
|
this->field_96 = 0;
|
|
|
|
|
|
|
|
this->field_A8 = 0;
|
|
|
|
this->field_AA = 0;
|
|
|
|
this->field_AC = 0;
|
|
|
|
this->bodyVector.vx = 0;
|
|
|
|
this->bodyVector.vy = 0;
|
|
|
|
this->bodyVector.vz = 0;
|
|
|
|
|
|
|
|
this->field_C4 = 0;
|
|
|
|
this->field_C6 = 0;
|
|
|
|
this->field_C8 = 0;
|
|
|
|
this->field_E8 = 0;
|
|
|
|
this->field_EC = 0;
|
|
|
|
|
|
|
|
this->cbodyend = 0;
|
|
|
|
|
|
|
|
this->field_78 = 1;
|
|
|
|
this->field_79 = 1;
|
|
|
|
this->field_7A = 1;
|
|
|
|
|
|
|
|
this->field_94 = 1;
|
|
|
|
this->field_95 = 1;
|
|
|
|
this->field_96 = 1;
|
|
|
|
this->mCBodyFlags |= 0x16;
|
|
|
|
|
|
|
|
this->field_D8 = 10;
|
|
|
|
this->field_A4 = 0;
|
|
|
|
this->field_DE = -1;
|
|
|
|
this->field_D0 = 32;
|
|
|
|
this->field_D4 = 200;
|
|
|
|
}
|
|
|
|
|
2024-05-08 21:27:51 +00:00
|
|
|
// @NotOk
|
|
|
|
// code is matching but make sure vtable is also
|
|
|
|
CSuper::CSuper()
|
|
|
|
{
|
|
|
|
this->mFlags |= 2u;
|
|
|
|
this->gAnim = 1;
|
|
|
|
this->field_142 = 1;
|
|
|
|
//this->cbody.citem.vtable = (int)&off_53BBE8;
|
|
|
|
this->csuperend = 0x10000;
|
|
|
|
this->field_13E = 100;
|
|
|
|
this->field_13F = 94;
|
2024-03-06 17:00:25 +00:00
|
|
|
}
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @Ok
|
2024-03-06 17:06:10 +00:00
|
|
|
void CSuper::OutlineOff(void){
|
|
|
|
this->outlineRelated &= 0xFFFFFFFB;
|
|
|
|
}
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @NotOk
|
|
|
|
// Missing most stuff, only used by CVenom and CDummy
|
2024-03-06 19:11:38 +00:00
|
|
|
void CSuper::OutlineOn(void){
|
|
|
|
this->outlineRelated |= 4;
|
|
|
|
if (!this->SNbrFaces){
|
|
|
|
}
|
|
|
|
|
|
|
|
this->outlineR = -1;
|
|
|
|
this->outlineG = -1;
|
|
|
|
this->outlineB = -1;
|
|
|
|
this->alsoOutlineRelated = 0x50000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @Ok
|
2024-03-06 17:16:40 +00:00
|
|
|
void CSuper::SetOutlineSemiTransparent(){
|
|
|
|
this->alsoOutlineRelated |= 0x20000000;
|
|
|
|
}
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
|
|
|
|
// @Ok
|
2024-03-06 17:16:40 +00:00
|
|
|
void CSuper::SetOutlineRGB(unsigned char a2, unsigned char a3, unsigned char a4){
|
|
|
|
this->outlineR = a2;
|
|
|
|
this->outlineG = a3;
|
|
|
|
this->outlineB = a4;
|
|
|
|
}
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @Ok
|
|
|
|
// Slightly different register allocation, edx and eax are swapped
|
2024-03-06 18:29:43 +00:00
|
|
|
void CSuper::UpdateFrame(void){
|
|
|
|
char v1; // bl
|
|
|
|
int v2; // esi
|
|
|
|
int v3; // edx
|
|
|
|
int v4; // eax
|
|
|
|
int v5; // edx
|
|
|
|
int v6; // eax
|
|
|
|
unsigned __int16 v7; // dx
|
|
|
|
|
|
|
|
|
|
|
|
if ( !this->field_80 )
|
|
|
|
this->field_80 = 2;
|
|
|
|
v1 = this->field_141;
|
|
|
|
v2 = this->field_80 * this->csuperend / 2;
|
|
|
|
v3 = (unsigned __int16)this->field_146 | (this->field_128 << 16);
|
|
|
|
if ( this->field_141 == 1 )
|
|
|
|
v3 += v2;
|
|
|
|
if ( v1 == -1 )
|
|
|
|
v3 -= v2;
|
|
|
|
v4 = v3;
|
|
|
|
this->field_146 = v3;
|
|
|
|
v5 = (unsigned __int8)this->field_140;
|
|
|
|
v6 = v4 >> 16;
|
|
|
|
this->field_128 = v6;
|
|
|
|
|
|
|
|
if (v5) {
|
|
|
|
if ( --v5 == 0)
|
|
|
|
{
|
2024-03-06 19:02:22 +00:00
|
|
|
v7 = this->gAnim;
|
2024-03-06 18:29:43 +00:00
|
|
|
if ( (__int16)v6 >= (int)v7 )
|
|
|
|
{
|
|
|
|
this->field_128 = v6 - v7;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( (__int16)(v6) < 0 )
|
|
|
|
this->field_128 = v6 + v7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( (this->field_141 == 1 && (__int16)v6 >= this->field_144)
|
|
|
|
||
|
|
|
|
(v1 == -1 && (__int16)v6 <= this->field_144)
|
|
|
|
){
|
|
|
|
this->field_128 = this->field_144;
|
|
|
|
this->field_142 = 1;
|
|
|
|
}
|
2024-03-06 19:02:22 +00:00
|
|
|
}
|
2024-03-06 18:29:43 +00:00
|
|
|
|
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @NotOk
|
2024-03-06 19:02:22 +00:00
|
|
|
// Revisit
|
|
|
|
void CSuper::CycleAnim(int a2, char a3){
|
|
|
|
if (this->field_12A != a2 )
|
2024-03-06 18:29:43 +00:00
|
|
|
{
|
2024-03-06 19:02:22 +00:00
|
|
|
this->field_128 = 0;
|
|
|
|
this->field_146 = 0;
|
|
|
|
this->field_12A = a2;
|
|
|
|
int mRegion = (unsigned __int8)this->mRegion;
|
|
|
|
|
|
|
|
print_if_false(
|
|
|
|
(unsigned int)(unsigned __int16)a2 < *(unsigned int *)Animations[17 * mRegion],
|
|
|
|
"Bad anim sent to CycleAnim");
|
|
|
|
this->gAnim = *(__int16 *)(Animations[17 * (unsigned __int8)this->mRegion]
|
|
|
|
+ 8 * (unsigned __int16)this->field_12A
|
|
|
|
+ 8);
|
|
|
|
|
|
|
|
|
|
|
|
this->field_141 = a3;
|
|
|
|
}
|
|
|
|
this->field_140 = 1;
|
|
|
|
this->field_142 = 0;
|
2024-03-06 18:29:43 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 17:57:26 +00:00
|
|
|
|
2024-05-08 21:24:34 +00:00
|
|
|
// @Ok
|
2024-03-07 17:57:26 +00:00
|
|
|
void CSuper::ApplyPose(__int16 *a2){
|
|
|
|
|
2024-05-08 21:24:34 +00:00
|
|
|
if (!this->field_188)
|
|
|
|
{
|
|
|
|
M3dUtils_ReadLinksPacket(this, reinterpret_cast<void*>(a2));
|
2024-03-07 17:57:26 +00:00
|
|
|
this->actualcsuperend = a2;
|
|
|
|
}
|
|
|
|
|
2024-05-08 21:24:34 +00:00
|
|
|
M3dUtils_InBetween(this);
|
|
|
|
|
|
|
|
if ((this->mFlags & 4) != 0)
|
|
|
|
{
|
|
|
|
M3d_BuildTransform(this);
|
|
|
|
M3dUtils_BuildPose(this);
|
2024-03-07 17:57:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-09 11:21:56 +00:00
|
|
|
|
2024-05-08 21:08:53 +00:00
|
|
|
// @NotOk
|
|
|
|
// slightly different register allocation
|
|
|
|
// relies on global Animations
|
|
|
|
void CSuper::RunAnim(__int16 a2, int a3, int a4)
|
|
|
|
{
|
|
|
|
int mRegion; // ecx
|
|
|
|
unsigned __int16 v6; // dx
|
|
|
|
int v7; // eax
|
|
|
|
int v8; // ecx
|
|
|
|
char v9; // dl
|
|
|
|
|
|
|
|
mRegion = this->mRegion;
|
|
|
|
this->field_12A = a2;
|
|
|
|
|
|
|
|
print_if_false((unsigned int)a2 < *(unsigned int *)Animations[17 * mRegion], "Bad anim sent to RunAnim");
|
|
|
|
v6 = *(unsigned __int16 *)(Animations[17 * (unsigned char)this->mRegion] + 8 * (unsigned __int16)this->field_12A + 8);
|
|
|
|
v7 = a3;
|
|
|
|
this->gAnim = v6;
|
|
|
|
if ( a3 == -1 )
|
|
|
|
v7 = v6 - 1;
|
|
|
|
v8 = a4;
|
|
|
|
if ( a4 == -1 )
|
|
|
|
v8 = v6 - 1;
|
|
|
|
if ( v7 < 0 || v7 >= v6 )
|
|
|
|
v7 = 0;
|
|
|
|
if ( v8 < 0 || v8 >= v6 )
|
|
|
|
v8 = 0;
|
|
|
|
this->field_140 = 0;
|
|
|
|
|
|
|
|
if ( v8 > v7 )
|
|
|
|
v9 = 1;
|
|
|
|
else
|
|
|
|
v9 = (v8 >= v7) - 1;
|
|
|
|
|
|
|
|
this->field_144 = v8;
|
|
|
|
this->field_141 = v9;
|
|
|
|
this->field_128 = v7;
|
|
|
|
this->field_146 = 0;
|
|
|
|
this->field_142 = (unsigned __int16)v7 == (unsigned __int16)v8;
|
2024-03-09 11:21:56 +00:00
|
|
|
}
|
|
|
|
|
2024-05-07 16:04:53 +00:00
|
|
|
// @NotOk
|
|
|
|
// timerRelated needs to be fixed and call to print_if_false looks wrong
|
2024-05-01 17:50:43 +00:00
|
|
|
void CBody::EveryFrame(void)
|
|
|
|
{
|
|
|
|
int v3; // edx
|
|
|
|
int v4; // ecx
|
|
|
|
__int16 v6; // ax
|
|
|
|
__int16 v7; // cx
|
|
|
|
char v8; // dl
|
|
|
|
bool v9; // [esp-8h] [ebp-Ch]
|
|
|
|
|
|
|
|
if ( (this->mCBodyFlags & 4) != 0 )
|
|
|
|
{
|
|
|
|
this->field_80 = 2;
|
|
|
|
this->mCBodyFlags &= 0xFFFB;
|
|
|
|
this->field_7C = *gTimerRelated;
|
|
|
|
this->field_84 = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v3 = this->field_7C;
|
|
|
|
v9 = *gTimerRelated - v3 >= 0;
|
|
|
|
this->field_80 = *gTimerRelated - v3;
|
|
|
|
print_if_false(v9, "Timing error");
|
|
|
|
v4 = this->field_80;
|
|
|
|
this->field_7C = *gTimerRelated;
|
|
|
|
if ( v4 > 6 )
|
|
|
|
this->field_80 = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->field_84 += this->field_80;
|
|
|
|
if ( (this->mFlags & 2) != 0 )
|
|
|
|
{
|
2024-05-02 16:57:01 +00:00
|
|
|
CSuper *super = reinterpret_cast<CSuper*>(this);
|
|
|
|
v6 = super->field_128;
|
|
|
|
v7 = super->field_12A;
|
|
|
|
v8 = super->field_141;
|
|
|
|
super->field_152 = v6;
|
|
|
|
super->field_150 = v6;
|
|
|
|
super->field_154 = v7;
|
|
|
|
super->field_143 = v8;
|
2024-05-01 17:50:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-25 14:55:59 +00:00
|
|
|
void validate_CItem(void){
|
|
|
|
|
2024-05-06 16:30:21 +00:00
|
|
|
VALIDATE_SIZE(CItem, 0x40);
|
|
|
|
|
2024-02-25 14:55:59 +00:00
|
|
|
VALIDATE(CItem, mFlags, 0x4);
|
|
|
|
VALIDATE(CItem, mPos, 0x8);
|
|
|
|
VALIDATE(CItem, mAngles, 0x14);
|
|
|
|
VALIDATE(CItem, mModel, 0x1A);
|
|
|
|
VALIDATE(CItem, mRegion, 0x1F);
|
|
|
|
|
2024-05-07 15:49:34 +00:00
|
|
|
VALIDATE(CItem, field_20, 0x20);
|
|
|
|
|
2024-05-06 16:30:21 +00:00
|
|
|
|
2024-05-14 18:19:05 +00:00
|
|
|
VALIDATE(CItem, field_24, 0x24);
|
2024-05-06 16:30:21 +00:00
|
|
|
VALIDATE(CItem, field_28, 0x28);
|
|
|
|
VALIDATE(CItem, field_2A, 0x2A);
|
|
|
|
VALIDATE(CItem, field_2C, 0x2C);
|
2024-05-07 15:49:34 +00:00
|
|
|
|
2024-05-14 18:19:05 +00:00
|
|
|
VALIDATE(CItem, field_30, 0x30);
|
2024-05-07 15:49:34 +00:00
|
|
|
VALIDATE(CItem, field_34, 0x34);
|
2024-05-16 15:14:36 +00:00
|
|
|
VALIDATE(CItem, field_38, 0x38);
|
2024-05-06 16:30:21 +00:00
|
|
|
VALIDATE(CItem, field_3C, 0x3C);
|
|
|
|
|
2024-03-03 16:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void validate_CBody(void){
|
2024-05-01 18:16:21 +00:00
|
|
|
|
2024-05-02 16:57:01 +00:00
|
|
|
VALIDATE_SIZE(CBody, 0xF4);
|
2024-05-01 18:16:21 +00:00
|
|
|
|
2024-05-07 17:11:14 +00:00
|
|
|
VALIDATE(CBody, field_40, 0x40);
|
|
|
|
|
2024-03-08 19:05:38 +00:00
|
|
|
VALIDATE(CBody, field_44, 0x44);
|
2024-03-03 18:26:01 +00:00
|
|
|
VALIDATE(CBody, mCBodyFlags, 0x46);
|
2024-03-09 11:21:56 +00:00
|
|
|
VALIDATE(CBody, mAccellorVel, 0x60);
|
2024-03-12 11:31:40 +00:00
|
|
|
|
2024-05-07 17:48:31 +00:00
|
|
|
VALIDATE(CBody, field_48, 0x48);
|
|
|
|
VALIDATE(CBody, field_4C, 0x4C);
|
|
|
|
VALIDATE(CBody, field_50, 0x50);
|
|
|
|
VALIDATE(CBody, field_54, 0x54);
|
|
|
|
VALIDATE(CBody, field_58, 0x58);
|
|
|
|
VALIDATE(CBody, field_5C, 0x5C);
|
|
|
|
|
|
|
|
VALIDATE(CBody, mAccellorVel, 0x60);
|
2024-05-01 17:50:43 +00:00
|
|
|
VALIDATE(CBody, gVec, 0x6C);
|
|
|
|
|
|
|
|
VALIDATE(CBody, field_78, 0x78);
|
|
|
|
VALIDATE(CBody, field_79, 0x79);
|
|
|
|
VALIDATE(CBody, field_7A, 0x7A);
|
|
|
|
|
|
|
|
|
|
|
|
VALIDATE(CBody, field_7C, 0x7C);
|
|
|
|
|
2024-03-06 18:29:43 +00:00
|
|
|
VALIDATE(CBody, field_80, 0x80);
|
2024-05-01 17:50:43 +00:00
|
|
|
VALIDATE(CBody, field_84, 0x84);
|
|
|
|
|
2024-03-12 11:31:40 +00:00
|
|
|
VALIDATE(CBody, csVector1, 0x88);
|
|
|
|
|
2024-03-08 17:43:31 +00:00
|
|
|
VALIDATE(CBody, field_8E, 0x8E);
|
2024-05-07 16:34:21 +00:00
|
|
|
|
2024-05-07 17:48:31 +00:00
|
|
|
VALIDATE(CBody, field_94, 0x94);
|
|
|
|
VALIDATE(CBody, field_95, 0x95);
|
|
|
|
VALIDATE(CBody, field_96, 0x96);
|
|
|
|
|
2024-05-07 16:34:21 +00:00
|
|
|
VALIDATE(CBody, field_98, 0x98);
|
|
|
|
VALIDATE(CBody, field_9C, 0x9C);
|
|
|
|
VALIDATE(CBody, field_A0, 0xA0);
|
|
|
|
|
2024-05-07 17:48:31 +00:00
|
|
|
VALIDATE(CBody, field_A4, 0xA4);
|
|
|
|
VALIDATE(CBody, field_A8, 0xA8);
|
|
|
|
VALIDATE(CBody, field_AA, 0xAA);
|
|
|
|
VALIDATE(CBody, field_AC, 0xAC);
|
2024-05-07 16:34:21 +00:00
|
|
|
|
2024-03-07 18:38:43 +00:00
|
|
|
VALIDATE(CBody, bodyVector, 0xB8);
|
2024-05-07 17:48:31 +00:00
|
|
|
|
|
|
|
VALIDATE(CBody, field_C4, 0xC4);
|
|
|
|
VALIDATE(CBody, field_C6, 0xC6);
|
|
|
|
VALIDATE(CBody, field_C8, 0xC8);
|
|
|
|
|
|
|
|
|
2024-03-03 18:26:01 +00:00
|
|
|
VALIDATE(CBody, bodyQuadBit, 0xCC);
|
2024-03-03 19:00:31 +00:00
|
|
|
VALIDATE(CBody, field_D0, 0xD0);
|
|
|
|
VALIDATE(CBody, field_D2, 0xD2);
|
|
|
|
VALIDATE(CBody, field_D4, 0xD4);
|
2024-05-07 17:48:31 +00:00
|
|
|
|
|
|
|
VALIDATE(CBody, field_D8, 0xD8);
|
|
|
|
|
2024-03-08 17:57:06 +00:00
|
|
|
VALIDATE(CBody, field_DC, 0xDC);
|
2024-05-07 17:48:31 +00:00
|
|
|
|
|
|
|
VALIDATE(CBody, field_DE, 0xDE);
|
|
|
|
|
2024-03-07 18:38:43 +00:00
|
|
|
VALIDATE(CBody, field_E2, 0xE2);
|
2024-05-01 17:50:43 +00:00
|
|
|
|
2024-05-07 17:48:31 +00:00
|
|
|
VALIDATE(CBody, field_E8, 0xE8);
|
|
|
|
VALIDATE(CBody, field_EC, 0xEC);
|
|
|
|
VALIDATE(CBody, cbodyend, 0xF0);
|
|
|
|
|
2024-03-06 17:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void validate_CSuper(void){
|
|
|
|
|
|
|
|
/*
|
|
|
|
unsigned char field_13E;
|
|
|
|
unsigned char field_13F;
|
|
|
|
unsigned char field_142;
|
|
|
|
__int16 field_148;
|
|
|
|
*/
|
2024-03-06 17:16:40 +00:00
|
|
|
|
2024-05-17 17:15:00 +00:00
|
|
|
VALIDATE(CSuper, field_F4, 0xF4);
|
2024-05-02 16:57:01 +00:00
|
|
|
VALIDATE(CSuper, field_F8, 0xF8);
|
|
|
|
VALIDATE(CSuper, field_FC, 0xFC);
|
|
|
|
VALIDATE(CSuper, field_100, 0x100);
|
|
|
|
VALIDATE(CSuper, field_104, 0x104);
|
|
|
|
VALIDATE(CSuper, field_108, 0x108);
|
|
|
|
|
|
|
|
VALIDATE(CSuper, field_10C, 0x10C);
|
2024-05-22 16:55:46 +00:00
|
|
|
VALIDATE(CSuper, field_114, 0x114);
|
2024-05-02 16:57:01 +00:00
|
|
|
VALIDATE(CSuper, SNbrFaces, 0x11C);
|
|
|
|
VALIDATE(CSuper, alsoOutlineRelated, 0x120);
|
|
|
|
VALIDATE(CSuper, outlineR, 0x124);
|
|
|
|
VALIDATE(CSuper, outlineG, 0x125);
|
|
|
|
VALIDATE(CSuper, outlineB, 0x126);
|
|
|
|
|
|
|
|
VALIDATE(CSuper, field_128, 0x128);
|
|
|
|
VALIDATE(CSuper, field_12A, 0x12A);
|
|
|
|
VALIDATE(CSuper, field_141, 0x141);
|
|
|
|
VALIDATE(CSuper, field_143, 0x143);
|
|
|
|
VALIDATE(CSuper, field_150, 0x150);
|
|
|
|
VALIDATE(CSuper, field_152, 0x152);
|
|
|
|
VALIDATE(CSuper, field_154, 0x154);
|
2024-03-06 17:16:40 +00:00
|
|
|
|
|
|
|
|
2024-03-06 18:29:43 +00:00
|
|
|
VALIDATE(CSuper, field_128, 0x128);
|
|
|
|
|
2024-03-06 19:02:22 +00:00
|
|
|
VALIDATE(CSuper, field_12A, 0x12A);
|
2024-03-06 17:16:40 +00:00
|
|
|
VALIDATE(CSuper, outlineRelated, 0x12C);
|
|
|
|
|
2024-03-06 17:00:25 +00:00
|
|
|
VALIDATE(CSuper, field_13E, 0x13E);
|
|
|
|
VALIDATE(CSuper, field_13F, 0x13F);
|
2024-03-06 18:29:43 +00:00
|
|
|
|
|
|
|
VALIDATE(CSuper, field_140, 0x140);
|
|
|
|
VALIDATE(CSuper, field_141, 0x141);
|
2024-03-06 17:00:25 +00:00
|
|
|
VALIDATE(CSuper, field_142, 0x142);
|
2024-03-06 18:29:43 +00:00
|
|
|
|
|
|
|
VALIDATE(CSuper, field_144, 0x144);
|
|
|
|
VALIDATE(CSuper, field_146, 0x146);
|
|
|
|
|
2024-03-06 19:02:22 +00:00
|
|
|
VALIDATE(CSuper, gAnim, 0x148);
|
2024-03-06 18:29:43 +00:00
|
|
|
VALIDATE(CSuper, csuperend, 0x14C);
|
2024-03-07 17:57:26 +00:00
|
|
|
|
2024-03-09 11:43:36 +00:00
|
|
|
VALIDATE(CSuper, field_164, 0x164);
|
2024-03-07 17:57:26 +00:00
|
|
|
|
|
|
|
VALIDATE(CSuper, field_188, 0x188);
|
|
|
|
VALIDATE(CSuper, actualcsuperend, 0x190);
|
2024-03-07 18:18:34 +00:00
|
|
|
}
|