mirror of
https://github.com/zeldaret/st
synced 2026-10-10 22:34:06 -04:00
079958c2a3
* ActorBlast OK * ActorItemBoomerang 99% * ActorItemTornado 99%
173 lines
3.2 KiB
C++
173 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "global.h"
|
|
#include "types.h"
|
|
|
|
// mapping:
|
|
// 0011 1111 1111 1111 = index
|
|
// 1100 0000 0000 0000 = type
|
|
//
|
|
// 0000 1111 1111 1111 = id
|
|
// 1111 0000 0000 0000 = unk
|
|
|
|
#define REF_TYPE_INDEX(type, index) (((type) << 14) | (index))
|
|
|
|
enum ActorRefType_ {
|
|
ActorRefType_0,
|
|
ActorRefType_1,
|
|
ActorRefType_2,
|
|
};
|
|
|
|
enum ActorRefId_ {
|
|
ActorRefId_0,
|
|
ActorRefId_1,
|
|
ActorRefId_2,
|
|
ActorRefId_4,
|
|
ActorRefId_5,
|
|
ActorRefId_6,
|
|
ActorRefId_7,
|
|
//! TODO: more ids?
|
|
};
|
|
|
|
//! TODO: remove ActorRef and MapObjRef in favor of this
|
|
struct RefStruct {
|
|
union {
|
|
// common
|
|
struct {
|
|
/* 00 */ u16 index : 14;
|
|
/* 00 */ u16 type : 2;
|
|
/* 02 */ u16 id : 12;
|
|
/* 02 */ u16 unk : 4;
|
|
/* 04 */
|
|
};
|
|
|
|
// ActorRef
|
|
struct {
|
|
/* 00 */ u16 type_index;
|
|
/* 02 */ u16 unk_id;
|
|
/* 04 */
|
|
} acRef;
|
|
|
|
// MapObjRef
|
|
struct {
|
|
union {
|
|
struct {
|
|
/* 00 */ u8 unk_00;
|
|
/* 01 */ u8 unk_01;
|
|
};
|
|
u16 unk_00_u16;
|
|
};
|
|
/* 02 */ Vec2b unk_02;
|
|
/* 04 */
|
|
} moRef;
|
|
|
|
u32 data;
|
|
};
|
|
|
|
RefStruct() {}
|
|
|
|
RefStruct(u32 value) {
|
|
this->data = value;
|
|
}
|
|
|
|
void Reset() {
|
|
this->data = 0;
|
|
}
|
|
};
|
|
|
|
struct ActorRef {
|
|
union {
|
|
struct {
|
|
/* 00 */ u16 index : 14;
|
|
/* 00 */ u16 type : 2;
|
|
/* 02 */ u16 id : 12;
|
|
/* 02 */ u16 unk : 4;
|
|
/* 04 */
|
|
};
|
|
struct {
|
|
/* 00 */ u16 type_index;
|
|
/* 02 */ u16 unk_id;
|
|
/* 04 */
|
|
};
|
|
u32 data;
|
|
};
|
|
|
|
ActorRef() {}
|
|
|
|
ActorRef(u32 value) {
|
|
this->data = value;
|
|
}
|
|
|
|
void Reset() {
|
|
this->data = 0;
|
|
}
|
|
|
|
const bool operator==(const ActorRef &other) const {
|
|
return other.data == this->data;
|
|
}
|
|
|
|
const bool operator!=(const ActorRef &other) const {
|
|
return !(*this == other);
|
|
}
|
|
|
|
void operator=(const ActorRef &other) {
|
|
this->data = other.data;
|
|
}
|
|
|
|
const u32 Get32() const {
|
|
return this->data;
|
|
}
|
|
|
|
const u16 GetTypeIndex1() {
|
|
if (this->type_index == REF_TYPE_INDEX(ActorRefType_0, 0x101)) {
|
|
return 0x00;
|
|
}
|
|
|
|
return this->unk_id;
|
|
}
|
|
|
|
const bool HasTypeIndexValue(u16 value) {
|
|
return this->type_index == value;
|
|
}
|
|
|
|
const bool UnkCheck1() {
|
|
bool ret = true;
|
|
|
|
if (this->type_index != REF_TYPE_INDEX(ActorRefType_0, 0x100) &&
|
|
this->type_index != REF_TYPE_INDEX(ActorRefType_0, 0x101)) {
|
|
ret = false;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
const bool UnkCheck2() {
|
|
bool ret = false;
|
|
|
|
if (this->UnkCheck1() && this->GetTypeIndex1() == 0x01) {
|
|
ret = true;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
const bool UnkCheck3(u16 value) {
|
|
BOOL ret = false;
|
|
|
|
if (this->HasTypeIndexValue(value) && (this->unk_id == 1 || this->unk_id == 3)) {
|
|
ret = true;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
};
|
|
|
|
// for arrays
|
|
struct ActorRefElem {
|
|
ActorRef ref;
|
|
|
|
ActorRefElem() {
|
|
this->ref.Reset();
|
|
}
|
|
};
|