diff --git a/SpaceCadetPinball.sln b/SpaceCadetPinball.sln new file mode 100644 index 0000000..8586b4b --- /dev/null +++ b/SpaceCadetPinball.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.705 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpaceCadetPinball", "SpaceCadetPinball\SpaceCadetPinball.vcxproj", "{F7B78CC7-6984-4F79-9486-ABCF87DF9F06}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Debug|x64.ActiveCfg = Debug|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Debug|x64.Build.0 = Debug|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Debug|x86.ActiveCfg = Debug|Win32 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Debug|x86.Build.0 = Debug|Win32 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x64.ActiveCfg = Release|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x64.Build.0 = Release|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x86.ActiveCfg = Release|Win32 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4B620E0B-FD42-4AEC-BC4A-261C1669A1B5} + EndGlobalSection +EndGlobal diff --git a/SpaceCadetPinball/NatvisFile.natvis b/SpaceCadetPinball/NatvisFile.natvis new file mode 100644 index 0000000..cedec29 --- /dev/null +++ b/SpaceCadetPinball/NatvisFile.natvis @@ -0,0 +1,26 @@ + + + + {{ size={ListPtr->Count} }} + + ListPtr->Count + ListPtr->Size + + ListPtr->Size + ListPtr->Array + + + + + + {{ size={Count} }} + + Count + Size + + Size + Array + + + + \ No newline at end of file diff --git a/SpaceCadetPinball/SpaceCadetPinball.cpp b/SpaceCadetPinball/SpaceCadetPinball.cpp new file mode 100644 index 0000000..0a35790 --- /dev/null +++ b/SpaceCadetPinball/SpaceCadetPinball.cpp @@ -0,0 +1,29 @@ +// SpaceCadetPinball.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include "pch.h" +#include +#include "objlist_class.h" + +int main() +{ + std::cout << "Hello World!\n"; + + objlist_class d = objlist_class(2, 4); + for(int i=0;i<100;i++) + { + d.Add((void*)i); + } + d.Delete(3); +} + +// Run program: Ctrl + F5 or Debug > Start Without Debugging menu +// Debug program: F5 or Debug > Start Debugging menu + +// Tips for Getting Started: +// 1. Use the Solution Explorer window to add/manage files +// 2. Use the Team Explorer window to connect to source control +// 3. Use the Output window to see build output and other messages +// 4. Use the Error List window to view errors +// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project +// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj b/SpaceCadetPinball/SpaceCadetPinball.vcxproj new file mode 100644 index 0000000..dd130e9 --- /dev/null +++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06} + Win32Proj + SpaceCadetPinball + 10.0.17763.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + \ No newline at end of file diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters new file mode 100644 index 0000000..ddfdd7b --- /dev/null +++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/SpaceCadetPinball/objlist_class.cpp b/SpaceCadetPinball/objlist_class.cpp new file mode 100644 index 0000000..fb9e3de --- /dev/null +++ b/SpaceCadetPinball/objlist_class.cpp @@ -0,0 +1,86 @@ +#include "pch.h"" +#include "objlist_class.h" +#include +// v1 from Ida + +objlist_class::objlist_class(int SizeInt, int growSize) +{ + ListPtr = objlist_new(SizeInt); + GrowSize = growSize; +} + +objlist_class::~objlist_class() +{ + if (ListPtr) + free(ListPtr); +} + +void objlist_class::Add(void* value) +{ + if (this->ListPtr->Count == this->ListPtr->Size) + Grow(); + objlist_add_object(ListPtr, (int)value); +} + +void objlist_class::Grow() +{ + this->ListPtr = objlist_grow(this->ListPtr, this->GrowSize); +} + +int objlist_class::Delete(int value) +{ + return objlist_delete_object(ListPtr, value); +} + + +objlist_struct1* objlist_class::objlist_new(int sizeInt) +{ + objlist_struct1* result = (objlist_struct1 *)malloc(4 * sizeInt + 12); + if (!result) + return result; + result->Count = 0; + result->Size = sizeInt; + return result; +} + +int objlist_class::objlist_add_object(objlist_struct1* ptrToStruct, int value) +{ + int addIndex = ptrToStruct->Count; + if (addIndex >= ptrToStruct->Size) + return 0; + ptrToStruct->Array[addIndex] = value; + return ++ptrToStruct->Count; +} + +objlist_struct1* objlist_class::objlist_grow(objlist_struct1* ptrToStruct, int growSize) +{ + objlist_struct1* resultPtr = ptrToStruct; + if (!ptrToStruct) + return resultPtr; + int newSizeInt = growSize + ptrToStruct->Count; + if (newSizeInt <= ptrToStruct->Size) + return resultPtr; + objlist_struct1* resultPtr2 = (objlist_struct1 *)realloc(ptrToStruct, 4 * newSizeInt + 12); + if (!resultPtr2) + return resultPtr; + resultPtr = resultPtr2; + resultPtr2->Size = growSize + resultPtr2->Count; + return resultPtr; +} + +int objlist_class::objlist_delete_object(objlist_struct1* ptrToStruct, int value) +{ + int count = ptrToStruct->Count; + int index = count - 1; + if (count - 1 < 0) + return 0; + for (int* i = &ptrToStruct->Array[index]; *i != value; --i) + { + if (--index < 0) + return 0; + } + //ptrToStruct->Array[index] = *(&ptrToStruct->Count + count); + ptrToStruct->Array[index] = ptrToStruct->Array[count - 1]; + --ptrToStruct->Count; + return 1; +} diff --git a/SpaceCadetPinball/objlist_class.h b/SpaceCadetPinball/objlist_class.h new file mode 100644 index 0000000..8c364c7 --- /dev/null +++ b/SpaceCadetPinball/objlist_class.h @@ -0,0 +1,27 @@ +#pragma once + +struct __declspec(align(4)) objlist_struct1 +{ + int Size; + int Count; + int Array[]; +}; + + +class objlist_class +{ +public: + objlist_class(int SizeInt, int growSize); + ~objlist_class(); + void Add(void* value); + void Grow(); + int Delete(int value); + +private: + objlist_struct1* ListPtr; + int GrowSize; + objlist_struct1* objlist_new(int sizeInt); + int objlist_add_object(objlist_struct1 *ptrToStruct, int value); + objlist_struct1* objlist_grow(objlist_struct1 *ptrToStruct, int growSize); + int objlist_delete_object(objlist_struct1 *ptrToStruct, int value); +}; \ No newline at end of file diff --git a/SpaceCadetPinball/pch.cpp b/SpaceCadetPinball/pch.cpp new file mode 100644 index 0000000..3a3d12b --- /dev/null +++ b/SpaceCadetPinball/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: source file corresponding to pre-compiled header; necessary for compilation to succeed + +#include "pch.h" + +// In general, ignore this file, but keep it around if you are using pre-compiled headers. diff --git a/SpaceCadetPinball/pch.h b/SpaceCadetPinball/pch.h new file mode 100644 index 0000000..b04e71e --- /dev/null +++ b/SpaceCadetPinball/pch.h @@ -0,0 +1,14 @@ +// Tips for Getting Started: +// 1. Use the Solution Explorer window to add/manage files +// 2. Use the Team Explorer window to connect to source control +// 3. Use the Output window to see build output and other messages +// 4. Use the Error List window to view errors +// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project +// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + +#ifndef PCH_H +#define PCH_H + +// TODO: add headers that you want to pre-compile here + +#endif //PCH_H