mirror of https://github.com/PrimeDecomp/prime.git
Implement rstl::list::push_back; CInputGenerator 98%
Former-commit-id: 3029184d1e
This commit is contained in:
parent
f22cb43557
commit
1537d151f4
|
@ -46,7 +46,7 @@ private:
|
||||||
uint xa4_;
|
uint xa4_;
|
||||||
uint xa8_;
|
uint xa8_;
|
||||||
uint xac_;
|
uint xac_;
|
||||||
rstl::list< void > xb0_;
|
rstl::list< unkptr > xb0_;
|
||||||
};
|
};
|
||||||
CHECK_SIZEOF(CResFactory, 0xc8);
|
CHECK_SIZEOF(CResFactory, 0xc8);
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ public:
|
||||||
CInputStream* LoadNewResourceSync(const SObjectTag& tag, char* extBuf);
|
CInputStream* LoadNewResourceSync(const SObjectTag& tag, char* extBuf);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rstl::list< void > x0_aramList;
|
rstl::list< unkptr > x0_aramList;
|
||||||
rstl::list< void > x18_pakLoadedList;
|
rstl::list< unkptr > x18_pakLoadedList;
|
||||||
rstl::list< void > x30_pakLoadingList;
|
rstl::list< unkptr > x30_pakLoadingList;
|
||||||
unkptr x48_curPak;
|
unkptr x48_curPak;
|
||||||
CAssetId x4c_cachedResId;
|
CAssetId x4c_cachedResId;
|
||||||
SResInfo* x50_cachedResInfo;
|
SResInfo* x50_cachedResInfo;
|
||||||
|
|
|
@ -11,14 +11,14 @@ class CDolphinController : public IController {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDolphinController();
|
CDolphinController();
|
||||||
virtual ~CDolphinController();
|
~CDolphinController() override;
|
||||||
void Poll();
|
void Poll() override;
|
||||||
uint GetDeviceCount() const;
|
uint GetDeviceCount() const override;
|
||||||
CControllerGamepadData& GetGamepadData(int controller);
|
CControllerGamepadData& GetGamepadData(int controller) override;
|
||||||
uint GetControllerType(int) const;
|
uint GetControllerType(int) const override;
|
||||||
void SetMotorState(EIOPort port, EMotorState state);
|
void SetMotorState(EIOPort port, EMotorState state) override;
|
||||||
bool Initialize();
|
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
float GetAnalogStickMaxValue(EJoyAxis axis) const;
|
float GetAnalogStickMaxValue(EJoyAxis axis) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
class CArchitectureQueue {
|
class CArchitectureQueue {
|
||||||
public:
|
public:
|
||||||
bool Push(const CArchitectureMessage& msg) {
|
bool Push(const CArchitectureMessage& msg) {
|
||||||
// x0_queue.push_back(msg);
|
x0_queue.push_back(msg);
|
||||||
return false; // TODO
|
return false; // TODO
|
||||||
}
|
}
|
||||||
void Pop(); // TODO
|
void Pop(); // TODO
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "rstl/construct.hpp"
|
||||||
#include "rstl/rmemory_allocator.hpp"
|
#include "rstl/rmemory_allocator.hpp"
|
||||||
|
|
||||||
namespace rstl {
|
namespace rstl {
|
||||||
|
@ -11,14 +12,18 @@ class list {
|
||||||
public:
|
public:
|
||||||
class iterator;
|
class iterator;
|
||||||
class const_iterator;
|
class const_iterator;
|
||||||
iterator erase(const iterator &item);
|
iterator erase(const iterator& item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class node;
|
class node;
|
||||||
node *erase(const node *item);
|
node* erase(const node* item);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
list()
|
list()
|
||||||
: x4_start(&xc_empty), x8_end(&xc_empty), xc_empty(&xc_empty, &xc_empty) {}
|
: x4_start(reinterpret_cast< node* >(&xc_empty_prev))
|
||||||
|
, x8_end(reinterpret_cast< node* >(&xc_empty_prev))
|
||||||
|
, xc_empty(reinterpret_cast< node* >(&xc_empty_prev), reinterpret_cast< node* >(&xc_empty_prev))
|
||||||
|
, x14_count(0) {}
|
||||||
~list() {
|
~list() {
|
||||||
node* cur = x4_start;
|
node* cur = x4_start;
|
||||||
while (cur != x8_end) {
|
while (cur != x8_end) {
|
||||||
|
@ -27,7 +32,7 @@ public:
|
||||||
cur = cur->get_next();
|
cur = cur->get_next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void push_back(const T&);
|
void push_back(const T& val) { do_insert_before(x8_end, val); }
|
||||||
void clear() {
|
void clear() {
|
||||||
// iterator e = end();
|
// iterator e = end();
|
||||||
iterator cur = begin();
|
iterator cur = begin();
|
||||||
|
@ -50,28 +55,40 @@ private:
|
||||||
struct node {
|
struct node {
|
||||||
node* x0_prev;
|
node* x0_prev;
|
||||||
node* x4_next;
|
node* x4_next;
|
||||||
union {
|
uchar x8_item[sizeof(T)];
|
||||||
T* x8_item;
|
|
||||||
uint x8_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
node(node* prev, node* next) : x0_prev(prev), x4_next(next), x8_count(0) {}
|
node(node* prev, node* next) : x0_prev(prev), x4_next(next) {}
|
||||||
|
|
||||||
node* get_prev() const { return x0_prev; }
|
node* get_prev() const { return x0_prev; }
|
||||||
node* get_next() const { return x4_next; }
|
node* get_next() const { return x4_next; }
|
||||||
T* get_value() { return x8_item; }
|
void set_prev(node* prev) { x0_prev = prev; }
|
||||||
const T* get_value_const() const { return x8_item; }
|
void set_next(node* next) { x4_next = next; }
|
||||||
|
T* get_value() { return reinterpret_cast< T* >(&x8_item); }
|
||||||
// todo set_next / set_prev
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
node* create_node(node* prev, node* next, const T& val) {
|
||||||
|
node* n = new node(prev, next);
|
||||||
|
construct(n->get_value(), val);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_insert_before(node* n, const T& val) {
|
||||||
|
node* nn = create_node(n->get_prev(), n, val);
|
||||||
|
if (n == x4_start) {
|
||||||
|
x4_start = nn;
|
||||||
|
}
|
||||||
|
nn->get_prev()->set_next(nn);
|
||||||
|
nn->get_next()->set_prev(nn);
|
||||||
|
++x14_count;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class const_iterator {
|
class const_iterator {
|
||||||
public:;
|
public:
|
||||||
typedef T* value_type;
|
typedef T* value_type;
|
||||||
|
|
||||||
const_iterator() : current(nullptr) {}
|
const_iterator() : current(nullptr) {}
|
||||||
const_iterator(const node *begin) : current(begin) {}
|
const_iterator(const node* begin) : current(begin) {}
|
||||||
const_iterator& operator++() {
|
const_iterator& operator++() {
|
||||||
this->current = this->current->x4_next;
|
this->current = this->current->x4_next;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -92,17 +109,18 @@ public:
|
||||||
const node* current;
|
const node* current;
|
||||||
};
|
};
|
||||||
|
|
||||||
class iterator: const_iterator {
|
class iterator : const_iterator {
|
||||||
public:
|
public:
|
||||||
typedef T* value_type;
|
typedef T* value_type;
|
||||||
|
|
||||||
iterator() : const_iterator(nullptr) {}
|
iterator() : const_iterator(nullptr) {}
|
||||||
iterator(node *begin) : const_iterator(begin) {}
|
iterator(node* begin) : const_iterator(begin) {}
|
||||||
iterator& operator++() {
|
iterator& operator++() {
|
||||||
this->current = this->current->x4_next;
|
this->current = this->current->x4_next;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
iterator operator++(int) { return const_iterator(this->current->x4_next; }
|
iterator operator++(int) { return const_iterator(this->current->x4_next;
|
||||||
|
}
|
||||||
iterator& operator--() {
|
iterator& operator--() {
|
||||||
this->current = this->current->x0_prev;
|
this->current = this->current->x0_prev;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -113,6 +131,7 @@ public:
|
||||||
T* operator->() const { return current->get_value(); }
|
T* operator->() const { return current->get_value(); }
|
||||||
bool operator==(const iterator& other) const { return current == other.current; }
|
bool operator==(const iterator& other) const { return current == other.current; }
|
||||||
bool operator!=(const iterator& other) const { return current != other.current; }
|
bool operator!=(const iterator& other) const { return current != other.current; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
node* current;
|
node* current;
|
||||||
};
|
};
|
||||||
|
@ -121,7 +140,9 @@ private:
|
||||||
Alloc x0_allocator;
|
Alloc x0_allocator;
|
||||||
node* x4_start;
|
node* x4_start;
|
||||||
node* x8_end;
|
node* x8_end;
|
||||||
node xc_empty;
|
node* xc_empty_prev;
|
||||||
|
node* x10_empty_next;
|
||||||
|
uint x14_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rstl
|
} // namespace rstl
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "MetroidPrime/Decode.hpp"
|
#include "MetroidPrime/Decode.hpp"
|
||||||
|
|
||||||
#include "Kyoto/Basics/COsContext.hpp"
|
#include "Kyoto/Basics/COsContext.hpp"
|
||||||
|
|
||||||
CInputGenerator::CInputGenerator(COsContext* ctx, float leftDiv, float rightDiv)
|
CInputGenerator::CInputGenerator(COsContext* ctx, float leftDiv, float rightDiv)
|
||||||
: x0_context(ctx)
|
: x0_context(ctx)
|
||||||
, x4_controller(IController::Create(*ctx))
|
, x4_controller(IController::Create(*ctx))
|
||||||
|
@ -13,40 +14,48 @@ CInputGenerator::CInputGenerator(COsContext* ctx, float leftDiv, float rightDiv)
|
||||||
x8_connectedControllers[i] = false;
|
x8_connectedControllers[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputGenerator::Update(float dt, CArchitectureQueue& queue) {
|
bool CInputGenerator::Update(float dt, CArchitectureQueue& queue) {
|
||||||
bool ret;
|
int availSlot = 0;
|
||||||
if (!x0_context->Update()) {
|
if (!x0_context->Update()) {
|
||||||
ret = false;
|
return false;
|
||||||
} else {
|
}
|
||||||
int availSlot = 0;
|
|
||||||
bool firstController = false;
|
bool firstController = false;
|
||||||
if (!x4_controller.null()) {
|
if (!x4_controller.null()) {
|
||||||
x4_controller->Poll();
|
int count = x4_controller->GetDeviceCount();
|
||||||
for (int i = 0; i < x4_controller->GetDeviceCount(); ++i) {
|
x4_controller->Poll();
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
const CControllerGamepadData& cont = x4_controller->GetGamepadData(i);
|
||||||
|
if (cont.DeviceIsPresent()) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
firstController = true;
|
firstController = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CControllerGamepadData cont = x4_controller->GetGamepadData(i);
|
{
|
||||||
if (cont.DeviceIsPresent()) {
|
CFinalInput input(i, dt, cont, xc_leftDiv, x10_rightDiv);
|
||||||
queue.Push(MakeMsg::CreateUserInput(kAMT_Game,
|
CArchitectureMessage msg = MakeMsg::CreateUserInput(kAMT_Game, input);
|
||||||
CFinalInput(i, dt, cont, xc_leftDiv, x10_rightDiv)));
|
queue.Push(msg);
|
||||||
++availSlot;
|
|
||||||
}
|
}
|
||||||
|
++availSlot;
|
||||||
|
}
|
||||||
|
|
||||||
if (x8_connectedControllers[i] != cont.DeviceIsPresent()) {
|
bool connected = cont.DeviceIsPresent();
|
||||||
queue.Push(MakeMsg::CreateControllerStatus(kAMT_Game, i, cont.DeviceIsPresent()));
|
if (x8_connectedControllers[i] != connected) {
|
||||||
x8_connectedControllers[i] = cont.DeviceIsPresent();
|
CArchitectureMessage msg = MakeMsg::CreateControllerStatus(kAMT_Game, i, connected);
|
||||||
}
|
queue.Push(msg);
|
||||||
|
x8_connectedControllers[i] = connected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstController) {
|
|
||||||
queue.Push(MakeMsg::CreateUserInput(kAMT_Game, CFinalInput(availSlot, dt, *x0_context)));
|
|
||||||
} else {
|
|
||||||
queue.Push(MakeMsg::CreateUserInput(kAMT_Game, CFinalInput(0, dt, *x0_context)));
|
|
||||||
}
|
|
||||||
ret = true;
|
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
if (!firstController) {
|
||||||
|
CArchitectureMessage msg = MakeMsg::CreateUserInput(kAMT_Game, CFinalInput(0, dt, *x0_context));
|
||||||
|
queue.Push(msg);
|
||||||
|
} else {
|
||||||
|
CArchitectureMessage msg =
|
||||||
|
MakeMsg::CreateUserInput(kAMT_Game, CFinalInput(availSlot, dt, *x0_context));
|
||||||
|
queue.Push(msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue