summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2StopInfoArray.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-28 22:22:32 +0100
commitc0c336500955a23e344651e5412c9d9d441ef4ee (patch)
tree790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2StopInfoArray.cpp
parent37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff)
downloadt2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz
t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2StopInfoArray.cpp95
1 files changed, 80 insertions, 15 deletions
diff --git a/src/T2DLL/T2StopInfoArray.cpp b/src/T2DLL/T2StopInfoArray.cpp
index 689e167..a509cbb 100644
--- a/src/T2DLL/T2StopInfoArray.cpp
+++ b/src/T2DLL/T2StopInfoArray.cpp
@@ -1,52 +1,117 @@
+#include "T2Archive.h"
#include "T2StopInfoArray.h"
-T2StopInfoArray::T2StopInfoArray() {
+T2StopInfoArray::T2StopInfoArray()
+ : LArray(1)
+{
}
/*virtual*/ T2StopInfoArray::~T2StopInfoArray() {
}
-void T2StopInfoArray::Init(int) {
+void T2StopInfoArray::Init(int count) {
+ Expand(EEquipPos_2, count);
}
void T2StopInfoArray::AllClear() {
+ RemoveItemsAt(mItemCount, 1);
}
-void T2StopInfoArray::Expand(EEquipPos, int) {
+void T2StopInfoArray::Expand(EEquipPos pos, int count) {
+ int where;
+ if (pos == EEquipPos_2)
+ where = mItemCount + 1;
+ else if (pos == EEquipPos_3)
+ where = 1;
+ else
+ return;
+
+ if (count > 0) {
+ int actualCount = count * 2;
+ unsigned char zero = 0;
+ for (int i = 0; i < actualCount; i++)
+ InsertItemsAt(1, where, &zero);
+ } else {
+ int actualCount = -count * 2;
+ for (int i = 0; i < actualCount; i++)
+ RemoveItemsAt(1, where);
+ }
}
-int T2StopInfoArray::IsStopPos(int, ERequestUpDown) {
+BOOL T2StopInfoArray::IsStopPos(int i, ERequestUpDown upDown) {
+ return GetStopAt(i, upDown) > 0;
}
-int T2StopInfoArray::IsOnStopPos(int, ERequestUpDown) {
+BOOL T2StopInfoArray::IsOnStopPos(int i, ERequestUpDown upDown) {
+ return (GetStopAt(i, upDown) & 2) > 0;
}
-int T2StopInfoArray::IsOffStopPos(int, ERequestUpDown) {
+BOOL T2StopInfoArray::IsOffStopPos(int i, ERequestUpDown upDown) {
+ return (GetStopAt(i, upDown) & 1) > 0;
}
-void T2StopInfoArray::SetOnStop(int, ERequestUpDown) {
+void T2StopInfoArray::SetOnStop(int i, ERequestUpDown upDown) {
+ char v = GetStopAt(i, upDown) | 2;
+ SetStopAt(i, upDown, v);
}
-void T2StopInfoArray::SetOffStop(int, ERequestUpDown) {
+void T2StopInfoArray::SetOffStop(int i, ERequestUpDown upDown) {
+ char v = GetStopAt(i, upDown) | 1;
+ SetStopAt(i, upDown, v);
}
-void T2StopInfoArray::ClearOnStop(int, ERequestUpDown) {
+void T2StopInfoArray::ClearOnStop(int i, ERequestUpDown upDown) {
+ char v = GetStopAt(i, upDown) & 1;
+ SetStopAt(i, upDown, v);
}
-void T2StopInfoArray::ClearOffStop(int, ERequestUpDown) {
+void T2StopInfoArray::ClearOffStop(int i, ERequestUpDown upDown) {
+ char v = GetStopAt(i, upDown) & 2;
+ SetStopAt(i, upDown, v);
}
-char T2StopInfoArray::GetStopAt(int, ERequestUpDown) {
+char T2StopInfoArray::GetStopAt(int i, ERequestUpDown upDown) {
+ char v;
+ FetchItemAt(GetIndex(i, upDown), &v);
+ return v;
}
-void T2StopInfoArray::SetStopAt(int, ERequestUpDown, char) {
+void T2StopInfoArray::SetStopAt(int i, ERequestUpDown upDown, char v) {
+ AssignItemsAt(1, GetIndex(i, upDown), &v);
}
-int T2StopInfoArray::GetIndex(int, ERequestUpDown) const {
+int T2StopInfoArray::GetIndex(int i, ERequestUpDown upDown) const {
+ int index = 1;
+ index += i * 2;
+ if (upDown == ERequestUpDown_1)
+ index++;
+ return index;
}
-/*static*/ T2StopInfoArray* T2StopInfoArray::ReadStopInfoArray(T2Archive&) {
+/*static*/ T2StopInfoArray* T2StopInfoArray::ReadStopInfoArray(T2Archive& archive) {
+ T2StopInfoArray *array = NULL;
+
+ DWORD code;
+ archive >> code;
+
+ if (code == 'SIfA')
+ array = new T2StopInfoArray;
+
+ if (array)
+ array->ReadAsChar(archive);
+
+ return array;
}
-/*static*/ void T2StopInfoArray::WriteStopInfoArray(T2StopInfoArray*, T2Archive&) {
+/*static*/ void T2StopInfoArray::WriteStopInfoArray(T2StopInfoArray* array, T2Archive& archive) {
+ DWORD code;
+
+ if (!array) {
+ code = 'xSIA';
+ archive << code;
+ } else {
+ code = 'SIfA';
+ archive << code;
+ array->WriteAsChar(archive);
+ }
}