More preparations. Also add a README.md
This commit is contained in:
@@ -0,0 +1,273 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "List.h"
|
||||||
|
|
||||||
|
|
||||||
|
DLL_METHOD List* DLL_CALL BU_List_Create(BBTypeElement* element) {
|
||||||
|
// Make sure the given element is valid.
|
||||||
|
if (element == NULL)
|
||||||
|
return NULL;
|
||||||
|
element = (BBTypeElement*)((uint32_t*)element - 5);
|
||||||
|
|
||||||
|
// Create our List.
|
||||||
|
List* myList = new List;
|
||||||
|
myList->originalType = element->type;
|
||||||
|
|
||||||
|
// Create a fake base Type by copying data.
|
||||||
|
myList->fakeType = new BBType;
|
||||||
|
myList->fakeType->fieldCount = myList->originalType->fieldCount;
|
||||||
|
myList->fakeType->free.type = myList->originalType->free.type;
|
||||||
|
myList->fakeType->free.refCount = myList->originalType->free.refCount;
|
||||||
|
myList->fakeType->free.fields = myList->originalType->free.fields;
|
||||||
|
myList->fakeType->free.next = (BBTypeElement*)&myList->fakeType->free;
|
||||||
|
myList->fakeType->free.prev = (BBTypeElement*)&myList->fakeType->free;
|
||||||
|
myList->fakeType->used.type = myList->originalType->used.type;
|
||||||
|
myList->fakeType->used.refCount = myList->originalType->used.refCount;
|
||||||
|
myList->fakeType->used.fields = myList->originalType->used.fields;
|
||||||
|
myList->fakeType->used.prev = (BBTypeElement*)&myList->fakeType->used;
|
||||||
|
myList->fakeType->used.next = (BBTypeElement*)&myList->fakeType->used;
|
||||||
|
|
||||||
|
// Remove element from original flow.
|
||||||
|
element->prev->next = element->next;
|
||||||
|
element->next->prev = element->prev;
|
||||||
|
element->prev = NULL;
|
||||||
|
element->next = NULL;
|
||||||
|
element->type = myList->fakeType;
|
||||||
|
|
||||||
|
// Store the element for later use;
|
||||||
|
myList->storageElement = element;
|
||||||
|
myList->storageElementFields = element->fields;
|
||||||
|
|
||||||
|
return myList;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Destroy(List* list) {
|
||||||
|
if (list == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Append remaining elements to original type.
|
||||||
|
BBTypeElement *thisEl = NULL;
|
||||||
|
for (thisEl = list->fakeType->used.next; thisEl != (BBTypeElement*)&list->fakeType->used; thisEl = list->fakeType->used.next) {
|
||||||
|
// Remove from fakeType's flow.
|
||||||
|
thisEl->prev->next = thisEl->next;
|
||||||
|
thisEl->next->prev = thisEl->prev;
|
||||||
|
|
||||||
|
// Append to originalType's flow.
|
||||||
|
thisEl->prev = list->originalType->used.prev;
|
||||||
|
thisEl->prev->next = thisEl;
|
||||||
|
thisEl->next = (BBTypeElement*)&list->originalType->used;
|
||||||
|
thisEl->next->prev = thisEl;
|
||||||
|
}
|
||||||
|
for (thisEl = list->fakeType->free.next; thisEl != (BBTypeElement*)&list->fakeType->free; thisEl = list->fakeType->free.next) {
|
||||||
|
// Remove from fakeType's flow.
|
||||||
|
thisEl->prev->next = thisEl->next;
|
||||||
|
thisEl->next->prev = thisEl->prev;
|
||||||
|
|
||||||
|
// Append to originalType's flow.
|
||||||
|
thisEl->prev = list->originalType->free.prev;
|
||||||
|
thisEl->prev->next = thisEl;
|
||||||
|
thisEl->next = (BBTypeElement*)&list->originalType->free;
|
||||||
|
thisEl->next->prev = thisEl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append storageElement to original type.
|
||||||
|
thisEl = list->storageElement;
|
||||||
|
thisEl->prev = list->originalType->used.prev;
|
||||||
|
thisEl->prev->next = thisEl;
|
||||||
|
thisEl->next = (BBTypeElement*)&list->originalType->used;
|
||||||
|
thisEl->next->prev = thisEl;
|
||||||
|
thisEl->type = list->originalType;
|
||||||
|
thisEl->fields = list->storageElementFields;
|
||||||
|
|
||||||
|
// Delete custom objects.
|
||||||
|
delete list->fakeType;
|
||||||
|
delete list;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_First(List* list) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = list->fakeType->used.next;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Last(List* list) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = list->fakeType->used.prev;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Previous(List* list) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = list->storageElement->prev->prev;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Next(List* list) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = list->storageElement->next->next;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Before(List* list, BBTypeElement* other) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
if (other == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
other = (BBTypeElement*)((uint32_t*)other - 5);
|
||||||
|
if (other->type != list->fakeType)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = other->prev;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_After(List* list, BBTypeElement* other) {
|
||||||
|
if (list == NULL)
|
||||||
|
return FALSE;
|
||||||
|
if (other == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
other = (BBTypeElement*)((uint32_t*)other - 5);
|
||||||
|
if (other->type != list->fakeType)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
BBTypeElement* element = other->next;
|
||||||
|
if (element == (BBTypeElement*)&list->fakeType->used)
|
||||||
|
return FALSE; // End of List.
|
||||||
|
|
||||||
|
// Copy data from selected element.
|
||||||
|
list->storageElement->fields = element->fields;
|
||||||
|
|
||||||
|
// Make deletion easier
|
||||||
|
list->storageElement->next = element;
|
||||||
|
list->storageElement->prev = element;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Insert(List* list, BBTypeElement* element) {
|
||||||
|
BU_List_InsertEx(list, element, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_InsertEx(List* list, BBTypeElement* element, BBTypeElement* other) {
|
||||||
|
if (list == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Make sure element is a valid pointer.
|
||||||
|
if (element == NULL)
|
||||||
|
return;
|
||||||
|
element = (BBTypeElement*)((uint32_t*)element - 5);
|
||||||
|
if (element->type != list->originalType)
|
||||||
|
return; // Can't add elements from other types, could cause serious issues.
|
||||||
|
|
||||||
|
// Make sure other is a valid pointer.
|
||||||
|
if (other == NULL) {
|
||||||
|
other = (BBTypeElement*)&list->fakeType->used;
|
||||||
|
} else {
|
||||||
|
other = (BBTypeElement*)((uint32_t*)other - 5);
|
||||||
|
|
||||||
|
// Other element must be of the same fakeType.
|
||||||
|
if (other->type != list->fakeType)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the element after(!) the other element.
|
||||||
|
element->prev = other->prev;
|
||||||
|
element->next = other;
|
||||||
|
element->prev->next = element;
|
||||||
|
element->next->prev = element;
|
||||||
|
element->type = list->fakeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Remove(List* list, BBTypeElement* element) {
|
||||||
|
if (list == NULL)
|
||||||
|
return;
|
||||||
|
if (element == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
element = (BBTypeElement*)((uint32_t*)element - 5);
|
||||||
|
if (element->type != list->fakeType)
|
||||||
|
return; // Can't remove elements from another type.
|
||||||
|
|
||||||
|
element->type = list->originalType;
|
||||||
|
element->prev = list->originalType->used.prev;
|
||||||
|
element->next = (BBTypeElement*)&list->originalType->used;
|
||||||
|
list->originalType->used.prev->next = element;
|
||||||
|
list->originalType->used.prev = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
|
||||||
|
// Reverse engineered from https://github.com/blitz-research/blitz3d/blob/master/compiler/declnode.cpp
|
||||||
|
enum BBVarType {
|
||||||
|
Global = 0,
|
||||||
|
Int = 1,
|
||||||
|
Float = 2,
|
||||||
|
String = 4,
|
||||||
|
Type = 5,
|
||||||
|
Array = 6
|
||||||
|
};
|
||||||
|
|
||||||
|
// Basic Blitz Variable
|
||||||
|
struct BBVar {
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Basic Type predefinition.
|
||||||
|
struct BBType;
|
||||||
|
|
||||||
|
// Basic Type Element
|
||||||
|
struct BBTypeElement {
|
||||||
|
uint32_t* fields;
|
||||||
|
BBTypeElement* next;
|
||||||
|
BBTypeElement* prev;
|
||||||
|
BBType* type;
|
||||||
|
unsigned int refCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Basic Type
|
||||||
|
struct BBType {
|
||||||
|
uint32_t type;
|
||||||
|
BBTypeElement used, free;
|
||||||
|
uint32_t fieldCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
// List struct.
|
||||||
|
struct List {
|
||||||
|
BBType* originalType;
|
||||||
|
BBType* fakeType;
|
||||||
|
|
||||||
|
BBTypeElement* storageElement;
|
||||||
|
uint32_t* storageElementFields;
|
||||||
|
};
|
||||||
|
|
||||||
|
DLL_METHOD List* DLL_CALL BU_List_Create(BBTypeElement* element);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Create=_BU_List_Create@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Destroy(List* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Destroy=_BU_List_Destroy@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_First(List* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_First=_BU_List_First@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Last(List* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Last=_BU_List_Last@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Previous(List* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Previous=_BU_List_Previous@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Next(List* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Next=_BU_List_Next@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_Before(List* list, BBTypeElement* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Before=_BU_List_Before@8")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_List_After(List* list, BBTypeElement* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_After=_BU_List_After@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Insert(List* list, BBTypeElement* element);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Insert=_BU_List_Insert@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_InsertEx(List* list, BBTypeElement* element, BBTypeElement* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_InsertEx=_BU_List_InsertEx@12")
|
||||||
|
DLL_METHOD void DLL_CALL BU_List_Remove(List* list, BBTypeElement* element);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_List_Remove=_BU_List_Remove@8")
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once;
|
||||||
|
#include "TypeList.h"
|
||||||
|
|
||||||
|
DLL_METHOD TypeList* DLL_CALL BU_TypeList_Create(BBTypeElement* element) {
|
||||||
|
// Make sure the given element is valid.
|
||||||
|
if (element == NULL)
|
||||||
|
return NULL;
|
||||||
|
element = (BBTypeElement*)(((uint32_t*)element) - 5);
|
||||||
|
|
||||||
|
// Create our TypeList.
|
||||||
|
TypeList* list = new TypeList();
|
||||||
|
list->type = element->type;
|
||||||
|
list->firstElement = element;
|
||||||
|
list->lastElement = element;
|
||||||
|
|
||||||
|
// Remove the given element from the flow of the type.
|
||||||
|
element->prev->next = element->next;
|
||||||
|
element->next->prev = element->prev;
|
||||||
|
element->prev = (BBTypeElement*)&list->type->used;
|
||||||
|
element->next = (BBTypeElement*)&list->type->used;
|
||||||
|
|
||||||
|
// Return the list.
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Destroy(TypeList* list) {
|
||||||
|
// Make sure we have a valid list.
|
||||||
|
if (list == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Append elements to the original type.
|
||||||
|
list->firstElement->prev = list->type->used.prev;
|
||||||
|
list->firstElement->prev->next = list->firstElement;
|
||||||
|
list->lastElement->next = (BBTypeElement*)&list->type->used;
|
||||||
|
list->lastElement->next->prev = list->lastElement;
|
||||||
|
|
||||||
|
// Free our TypeList.
|
||||||
|
delete list;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Activate(TypeList* list) {
|
||||||
|
// Store current pointers
|
||||||
|
list->storedFirstElement = list->type->used.next;
|
||||||
|
list->storedLastElement = list->type->used.prev;
|
||||||
|
|
||||||
|
// ... and replace them.
|
||||||
|
list->type->used.next = list->firstElement;
|
||||||
|
list->type->used.prev = list->lastElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Deactivate(TypeList* list) {
|
||||||
|
// Store current pointers
|
||||||
|
list->firstElement = list->type->used.next;
|
||||||
|
list->lastElement = list->type->used.prev;
|
||||||
|
|
||||||
|
// ... and replace them.
|
||||||
|
list->type->used.next = list->storedFirstElement;
|
||||||
|
list->type->used.prev = list->storedLastElement;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include "List.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
struct TypeList {
|
||||||
|
BBType *type;
|
||||||
|
|
||||||
|
BBTypeElement *storedFirstElement, *storedLastElement;
|
||||||
|
BBTypeElement *firstElement, *lastElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
DLL_METHOD TypeList* DLL_CALL BU_TypeList_Create(BBTypeElement* element);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_TypeList_Create=_BU_TypeList_Create@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Destroy(TypeList* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_TypeList_Destroy=_BU_TypeList_Destroy@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Activate(TypeList* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_TypeList_Activate=_BU_TypeList_Activate@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_TypeList_Deactivate(TypeList* list);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_TypeList_Deactivate=_BU_TypeList_Deactivate@4")
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
# BlitzUtility
|
||||||
|
BlitzUtility is aimed at extending Blitz beyond it's initial capabilities and is a sub-project of BlitzExtensions.
|
||||||
|
All functions assume that you are passing valid parameters and do no extra checking to reduce performance impact.
|
||||||
|
|
||||||
|
# Functionality
|
||||||
|
## Containers
|
||||||
|
### List
|
||||||
|
An element-based method of creating a List in Blitz, works by creating a clone of the original Type and inserting the elements into the new flow.
|
||||||
|
|
||||||
|
* List% = BU_List_Create(TypeObject*)
|
||||||
|
Creates a new list from an existing object, using it as a way of accessing the currently selected List entry.
|
||||||
|
* BU_List_Destroy(List%)
|
||||||
|
Destroys an existing List, returning it's objects into the original type.
|
||||||
|
* Sucess% = BU_List_First(List%)
|
||||||
|
Tries to selects the first object in a List, returning false if it failed.
|
||||||
|
* Sucess% = BU_List_Last(List%)
|
||||||
|
Tries to selects the last object in a List, returning false if it failed.
|
||||||
|
* Sucess% = BU_List_Previous(List%)
|
||||||
|
Tries to selects the previous object from the currently selected one, returning false if it failed.
|
||||||
|
* Sucess% = BU_List_Next(List%)
|
||||||
|
Tries to selects the next object from the currently selected one, returning false if it failed.
|
||||||
|
* Success% = BU_List_Before(List%, TypeObject*)
|
||||||
|
Tries to select the element before the given object, returning false if it failed.
|
||||||
|
* Success% = BU_List_After(List%, TypeObject*)
|
||||||
|
Tries to select the element After the given object, returning false if it failed.
|
||||||
|
* BU_List_Insert(List%, TypeObject*)
|
||||||
|
Inserts an object at the end of the given list.
|
||||||
|
* BU_List_InsertEx(List%, TypeObject*, OtherObject*)
|
||||||
|
Inserts an object after the given other object.
|
||||||
|
* BU_List_Remove(List%, TypeObject*)
|
||||||
|
Removes an object from a list, returning it to the original type.
|
||||||
|
|
||||||
|
### Type List
|
||||||
|
A type-based method of creating Lists in Blitz, works by modifying the base Type.
|
||||||
|
|
||||||
|
* List% = BU_TypeList_Create(TypeObject*)
|
||||||
|
Creates a new list from an existing object, immediately removing it from the original type and inserting it into it's own list.
|
||||||
|
* BU_TypeList_Destroy(List%)
|
||||||
|
Destroy an existing list, returning the objects into the flow of the base type.
|
||||||
|
* BU_TypeList_Activate(List%)
|
||||||
|
Activates the list, making elements inside it available for use.
|
||||||
|
* BU_TypeList_Deactivate(List%)
|
||||||
|
Deactivates the list, restoring the flow of elements to before activation.
|
||||||
|
|
||||||
|
## Types
|
||||||
|
### Long Long
|
||||||
|
64-bit integers for Blitz.
|
||||||
|
|
||||||
|
* LongLong% = BU_LongLong_Create%()
|
||||||
|
* BU_LongLong_Destroy(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_Copy%(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_TempCreate%()
|
||||||
|
* LongLong% = BU_LongLong_TempCopy%(LongLong%)
|
||||||
|
* BU_LongLong_SetTemp(LongLong%)
|
||||||
|
* BU_LongLong_UnsetTemp(LongLong%)
|
||||||
|
* BU_LongLong_TempCleanup()
|
||||||
|
* BU_LongLong_Set(LongLong%, LongLong%)
|
||||||
|
* BU_LongLong_SetV(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* BU_LongLong_Add(LongLong%, LongLong%)
|
||||||
|
* BU_LongLong_AddV(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* BU_LongLong_Sub(LongLong%, LongLong%)
|
||||||
|
* BU_LongLong_SubV(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* BU_LongLong_Mul(LongLong%, LongLong%)
|
||||||
|
* BU_LongLong_MulV(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* BU_LongLong_Div(LongLong%, LongLong%)
|
||||||
|
* BU_LongLong_DivV(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* Result% = BU_LongLong_Compare%(LongLong%, LongLong%)
|
||||||
|
* Result% = BU_LongLong_CompareV%(LongLong%, LongHigh%, LongLow%)
|
||||||
|
* String$ = BU_LongLong_ToString$(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_FromString%(String$)
|
||||||
|
* Long% = BU_LongLong_ToLong%(LongLong%, Modulus%)
|
||||||
|
* LongLong% = BU_LongLong_FromLong%(LongHigh%, LongLow%)
|
||||||
|
* Long% = BU_LongLong_ToLongHigh%(LongLong%)
|
||||||
|
* Long% = BU_LongLong_ToLongLow%(LongLong%)
|
||||||
|
* Float# = BU_LongLong_ToFloat#(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_FromFloat%(Float#)
|
||||||
|
* Double% = BU_LongLong_ToDouble%(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_FromDouble%(double%)
|
||||||
|
* String$ = BU_LongLong_Serialize$(LongLong%)
|
||||||
|
* LongLong% = BU_LongLong_Deserialize%(String$)
|
||||||
|
|
||||||
|
### Double
|
||||||
|
64-bit floating point for Blitz.
|
||||||
|
|
||||||
|
* Double% = BU_Double_Create%()
|
||||||
|
* BU_Double_Destroy(Double%)
|
||||||
|
* Double% = BU_Double_Copy%(Double%)
|
||||||
|
* Double% = BU_Double_TempCreate%()
|
||||||
|
* Double% = BU_Double_TempCopy%(Double%)
|
||||||
|
* BU_Double_SetTemp(Double%)
|
||||||
|
* BU_Double_UnsetTemp(Double%)
|
||||||
|
* BU_Double_TempCleanup()
|
||||||
|
* BU_Double_Set(Double%, Double%)
|
||||||
|
* BU_Double_SetF(Double%, Float#)
|
||||||
|
* BU_Double_Add(Double%, Double%)
|
||||||
|
* BU_Double_AddF(Double%, Float#)
|
||||||
|
* BU_Double_Sub(Double%, Double%)
|
||||||
|
* BU_Double_SubF(Double%, Float#)
|
||||||
|
* BU_Double_Mul(Double%, Double%)
|
||||||
|
* BU_Double_MulF(Double%, Float#)
|
||||||
|
* BU_Double_Div(Double%, Double%)
|
||||||
|
* BU_Double_DivF(Double%, Float#)
|
||||||
|
* Result% = BU_Double_Compare%(Double%, Double%)
|
||||||
|
Compares the two doubles and returns combinations of the following: 1 for equal, 2 for smaller, 4 for greater.
|
||||||
|
* Result% = BU_Double_CompareF%(Double%, Float#)
|
||||||
|
Compares the double as float with another float and returns combinations of the following: 1 for equal, 2 for smaller, 4 for greater.
|
||||||
|
* String$ = BU_Double_ToString$(Double%)
|
||||||
|
* Double% = BU_Double_FromString%(String$)
|
||||||
|
* Float# = BU_Double_ToFloat#(Double%)
|
||||||
|
* Double% = BU_Double_FromFloat%(Float#)
|
||||||
|
* LongLong% = BU_Double_ToLongLong%(Double%)
|
||||||
|
* Double% = BU_Double_FromLongLong%(LongLong%)
|
||||||
|
* String$ = BU_Double_Serialize$(Double%)
|
||||||
|
* String$ = BU_Double_Deserialize%(String$)
|
||||||
|
|
||||||
|
## Utility
|
||||||
|
### Display Enumerator
|
||||||
|
Retrieve information about displays from Windows.
|
||||||
|
|
||||||
|
* DisplayEnumerator% = BU_DisplayEnumerator_Create%()
|
||||||
|
* BU_DisplayEnumerator_Destroy(DisplayEnumerator%)
|
||||||
|
* BU_DisplayEnumerator_Enumerate%(DisplayEnumerator%)
|
||||||
|
* BU_DisplayEnumerator_Count%(DisplayEnumerator%)
|
||||||
|
* BU_DisplayEnumerator_Retrieve%(DisplayEnumerator%, index%, Rect*)
|
||||||
|
|
||||||
|
### Indexer V2
|
||||||
|
Fast array-based index generation. Uses a constant chunk of memory.
|
||||||
|
|
||||||
|
* Indexer% = BU_IndexerV2_Create%()
|
||||||
|
* BU_IndexerV2_Destroy(Indexer%)
|
||||||
|
* BU_IndexerV2_Mark(Indexer%, Used%)
|
||||||
|
* BU_IndexerV2_MarkFree(Indexer%)
|
||||||
|
* BU_IndexerV2_MarkUsed(Indexer%)
|
||||||
|
* Result% = BU_IndexerV2_Is%(Indexer%, Used%)
|
||||||
|
* Result% = BU_IndexerV2_IsFree%(Indexer%)
|
||||||
|
* Result% = BU_IndexerV2_IsUsed%(Indexer%)
|
||||||
|
* Index% = BU_IndexerV2_Get%(Indexer%)
|
||||||
|
* Amount% = BU_IndexerV2_Count%(Indexer%, Used%)
|
||||||
|
* Amount% = BU_IndexerV2_CountFree%(Indexer%)
|
||||||
|
* Amount% = BU_IndexerV2_CountUsed%(Indexer%)
|
||||||
|
|
||||||
|
### Indexer V2
|
||||||
|
Fast vector-based index generation, uses a dynamic amount of memory.
|
||||||
|
|
||||||
|
* Indexer% = BU_IndexerV2_Create%()
|
||||||
|
* BU_IndexerV2_Destroy(Indexer%)
|
||||||
|
* BU_IndexerV2_Mark(Indexer%, Used%)
|
||||||
|
* BU_IndexerV2_MarkFree(Indexer%)
|
||||||
|
* BU_IndexerV2_MarkUsed(Indexer%)
|
||||||
|
* Result% = BU_IndexerV2_Is%(Indexer%, Used%)
|
||||||
|
* Result% = BU_IndexerV2_IsFree%(Indexer%)
|
||||||
|
* Result% = BU_IndexerV2_IsUsed%(Indexer%)
|
||||||
|
* Index% = BU_IndexerV2_Get%(Indexer%)
|
||||||
|
* Amount% = BU_IndexerV2_Count%(Indexer%, Used%)
|
||||||
|
* Amount% = BU_IndexerV2_CountFree%(Indexer%)
|
||||||
|
* Amount% = BU_IndexerV2_CountUsed%(Indexer%)
|
||||||
|
|
||||||
|
### Mass Operation
|
||||||
|
Allows chaining operations on custom types, such as LongLong and Double. See contants
|
||||||
|
|
||||||
|
* BU_MassOp_Create%(length%)
|
||||||
|
* BU_MassOp_Destroy(massop%)
|
||||||
|
* BU_MassOp_Instruction%(massop%, index%, type%, code%, leftOperand%, rightOperand%, result%)
|
||||||
|
* BU_MassOp_Run(massop%)
|
||||||
|
|
||||||
|
### Window Message Handler
|
||||||
|
Easily handle messages sent to Blitz windows using these functions. May not work as expected initially.
|
||||||
|
|
||||||
|
* BU_WindowMessageHandler_Install(hwnd%)
|
||||||
|
* BU_WindowMessageHandler_Uninstall(hwnd%)
|
||||||
|
* Count% = BU_WindowMessageHandler_Message_Close%(hwnd%)
|
||||||
|
* Count% = BU_WindowMessageHandler_Message_Destroy%(hwnd%)
|
||||||
|
* Count% = BU_WindowMessageHandler_Message_Resize%(hwnd%, point*)
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "Vector3.h"
|
||||||
|
|
||||||
|
void Vector3::set(const float &o)
|
||||||
|
{
|
||||||
|
this->X = o;
|
||||||
|
this->Y = o;
|
||||||
|
this->Z = o;
|
||||||
|
}
|
||||||
|
void Vector3::set(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
this->X = x;
|
||||||
|
this->Y = y;
|
||||||
|
this->Z = z;
|
||||||
|
}
|
||||||
|
void Vector3::set(const Vector3 &o)
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
this->X = o.X;
|
||||||
|
this->Y = o.Y;
|
||||||
|
this->Z = o.Z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3::add(const float &o)
|
||||||
|
{
|
||||||
|
this->X += o;
|
||||||
|
this->Y += o;
|
||||||
|
this->Z += o;
|
||||||
|
}
|
||||||
|
void Vector3::add(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
this->X += x;
|
||||||
|
this->Y += y;
|
||||||
|
this->Z += z;
|
||||||
|
}
|
||||||
|
void Vector3::add(const Vector3 &o)
|
||||||
|
{
|
||||||
|
this->X += o.X;
|
||||||
|
this->Y += o.Y;
|
||||||
|
this->Z += o.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3::sub(const float &o)
|
||||||
|
{
|
||||||
|
this->X -= o;
|
||||||
|
this->Y -= o;
|
||||||
|
this->Z -= o;
|
||||||
|
}
|
||||||
|
void Vector3::sub(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
this->X -= x;
|
||||||
|
this->Y -= y;
|
||||||
|
this->Z -= z;
|
||||||
|
}
|
||||||
|
void Vector3::sub(const Vector3 &o)
|
||||||
|
{
|
||||||
|
this->X -= o.X;
|
||||||
|
this->Y -= o.Y;
|
||||||
|
this->Z -= o.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3::mul(const float &o)
|
||||||
|
{
|
||||||
|
this->X *= o;
|
||||||
|
this->Y *= o;
|
||||||
|
this->Z *= o;
|
||||||
|
}
|
||||||
|
void Vector3::mul(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
this->X *= x;
|
||||||
|
this->Y *= y;
|
||||||
|
this->Z *= z;
|
||||||
|
}
|
||||||
|
void Vector3::mul(const Vector3 &o)
|
||||||
|
{
|
||||||
|
this->X *= o.X;
|
||||||
|
this->Y *= o.Y;
|
||||||
|
this->Z *= o.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3::div(const float &o)
|
||||||
|
{
|
||||||
|
this->X /= o;
|
||||||
|
this->Y /= o;
|
||||||
|
this->Z /= o;
|
||||||
|
}
|
||||||
|
void Vector3::div(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
this->X /= x;
|
||||||
|
this->Y /= y;
|
||||||
|
this->Z /= z;
|
||||||
|
}
|
||||||
|
void Vector3::div(const Vector3 &o)
|
||||||
|
{
|
||||||
|
this->X /= o.X;
|
||||||
|
this->Y /= o.Y;
|
||||||
|
this->Z /= o.Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Vector3::length()
|
||||||
|
{
|
||||||
|
return sqrt(this->X * this->X + this->Y * this->Y + this->Z * this->Z);
|
||||||
|
}
|
||||||
|
float Vector3::distance(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
float X = (this->X - x);
|
||||||
|
float Y = (this->Y - y);
|
||||||
|
float Z = (this->Z - z);
|
||||||
|
return sqrt(X * X + Y * Y + Z * Z);
|
||||||
|
}
|
||||||
|
float Vector3::distance(const Vector3 &o)
|
||||||
|
{
|
||||||
|
float X = (this->X - o.X);
|
||||||
|
float Y = (this->Y - o.Y);
|
||||||
|
float Z = (this->Z - o.Z);
|
||||||
|
return sqrt(X * X + Y * Y + Z * Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Vector3::dot(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
return (this->X * x) + (this->Y * y) + (this->Z * z);
|
||||||
|
}
|
||||||
|
float Vector3::dot(const Vector3 &o)
|
||||||
|
{
|
||||||
|
return (this->X * o.X) + (this->Y * o.Y) + (this->Z * o.Z);
|
||||||
|
}
|
||||||
|
Vector3 Vector3::cross(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
Vector3* data = new Vector3();
|
||||||
|
data->X = (this->Y * z) - (this->Z * y);
|
||||||
|
data->Y = (this->Z * x) - (this->X * z);
|
||||||
|
data->Z = (this->X * y) - (this->Y * x);
|
||||||
|
return *data;
|
||||||
|
}
|
||||||
|
Vector3 Vector3::cross(const Vector3 &o)
|
||||||
|
{
|
||||||
|
Vector3* data = new Vector3();
|
||||||
|
data->X = (this->Y * o.Z) - (this->Z * o.Y);
|
||||||
|
data->Y = (this->Z * o.X) - (this->X * o.Z);
|
||||||
|
data->Z = (this->X * o.Y) - (this->Y * o.X);
|
||||||
|
return *data;
|
||||||
|
}
|
||||||
|
void Vector3::normalize()
|
||||||
|
{
|
||||||
|
this->div(this->length());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vector3::rotate(float &pitch, float &yaw, float &roll)
|
||||||
|
{
|
||||||
|
float** matrix = new float*[3];
|
||||||
|
matrix[0] = new float[3]; matrix[1] = new float[3]; matrix[2] = new float[3];
|
||||||
|
matrix[0][0] = cos(yaw) * cos(roll); matrix[0][1] = -sin(roll); matrix[0][2] = sin(yaw);
|
||||||
|
matrix[1][0] = sin(roll); matrix[1][1] = cos(pitch) * cos(roll); matrix[1][2] = -sin(pitch);
|
||||||
|
matrix[2][0] = -sin(yaw); matrix[2][1] = sin(pitch); matrix[2][2] = cos(pitch) * cos(yaw);
|
||||||
|
|
||||||
|
float X = (this->X * matrix[0][0]) + (this->Y * matrix[0][1]) + (this->Z * matrix[0][2]);
|
||||||
|
float Y = (this->X * matrix[1][0]) + (this->Y * matrix[1][1]) + (this->Z * matrix[1][2]);
|
||||||
|
float Z = (this->X * matrix[2][0]) + (this->Y * matrix[2][1]) + (this->Z * matrix[2][2]);
|
||||||
|
this->X = X; this->Y = Y; this->Z = Z;
|
||||||
|
}
|
||||||
|
void Vector3::rotateAround(const float &x, const float &y, const float &z, float &pitch, float &yaw, float &roll)
|
||||||
|
{
|
||||||
|
this->sub(x, y, z);
|
||||||
|
this->rotate(pitch, yaw, roll);
|
||||||
|
this->add(x, y, z);
|
||||||
|
}
|
||||||
|
void Vector3::rotateAround(Vector3 &o, float &pitch, float &yaw, float &roll)
|
||||||
|
{
|
||||||
|
this->sub(o);
|
||||||
|
this->rotate(pitch, yaw, roll);
|
||||||
|
this->add(o);
|
||||||
|
}
|
||||||
|
float Vector3::deltaPitch() {
|
||||||
|
return (float)(atan(this->X / -this->Y) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
float Vector3::deltaPitch(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
return (float)(atan((this->X - x) / (-(this->Y - y))) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
float Vector3::deltaPitch(Vector3 &o)
|
||||||
|
{
|
||||||
|
return (float)(atan((this->X - o.X) / (-(this->Y - o.Y))) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
float Vector3::deltaYaw() {
|
||||||
|
return (float)(atan(sqrt((this->X * this->X) + (this->Y * this->Y)) / this->Z) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
float Vector3::deltaYaw(const float &x, const float &y, const float &z)
|
||||||
|
{
|
||||||
|
float X = (this->X - x);
|
||||||
|
float Y = (this->Y - y);
|
||||||
|
return (float)(atan(sqrt((X * X) + (Y * Y)) / (this->Z - z)) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
float Vector3::deltaYaw(Vector3 &o)
|
||||||
|
{
|
||||||
|
float X = (this->X - o.X);
|
||||||
|
float Y = (this->Y - o.Y);
|
||||||
|
return (float)(atan(sqrt((X * X) + (Y * Y)) / (this->Z - o.Z)) * (180.0 / M_PI));
|
||||||
|
}
|
||||||
|
|
||||||
|
char* Vector3::serialize()
|
||||||
|
{
|
||||||
|
char* data = new char[13];
|
||||||
|
|
||||||
|
memcpy(data, this->Xc, 4);
|
||||||
|
memcpy(data + 4, this->Yc, 4);
|
||||||
|
memcpy(data + 8, this->Zc, 4);
|
||||||
|
data[12] = 0;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
void Vector3::deserialize(char* o)
|
||||||
|
{
|
||||||
|
memcpy(o, this->Xc, 4);
|
||||||
|
memcpy(o + 4, this->Yc, 4);
|
||||||
|
memcpy(o + 8, this->Zc, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Set(Vector3* a, float o) {
|
||||||
|
a->set(o);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_SetP(Vector3* a, float x, float y, float z) {
|
||||||
|
a->set(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_SetV(Vector3* a, Vector3* b) {
|
||||||
|
a->set(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Set=_Vector3_Set@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_SetP=_Vector3_SetP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_SetV=_Vector3_SetV@8")
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Add(Vector3* a, float o) {
|
||||||
|
a->add(o);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_AddP(Vector3* a, float x, float y, float z) {
|
||||||
|
a->add(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_AddV(Vector3* a, Vector3* b) {
|
||||||
|
a->add(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Add=_Vector3_Add@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_AddP=_Vector3_AddP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_AddV=_Vector3_AddV@8")
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Sub(Vector3* a, float o) {
|
||||||
|
a->sub(o);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_SubP(Vector3* a, float x, float y, float z) {
|
||||||
|
a->sub(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_SubV(Vector3* a, Vector3* b) {
|
||||||
|
a->sub(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Sub=_Vector3_Sub@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_SubP=_Vector3_SubP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_SubV=_Vector3_SubV@8")
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Mul(Vector3* a, float o) {
|
||||||
|
a->mul(o);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_MulP(Vector3* a, float x, float y, float z) {
|
||||||
|
a->mul(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_MulV(Vector3* a, Vector3* b) {
|
||||||
|
a->mul(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Mul=_Vector3_Mul@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_MulP=_Vector3_MulP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_MulV=_Vector3_MulV@8")
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Div(Vector3* a, float o) {
|
||||||
|
a->div(o);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_DivP(Vector3* a, float x, float y, float z) {
|
||||||
|
a->div(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_DivV(Vector3* a, Vector3* b) {
|
||||||
|
a->div(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Div=_Vector3_Div@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DivP=_Vector3_DivP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DivV=_Vector3_DivV@8")
|
||||||
|
|
||||||
|
DLL_METHOD float Vector3_Length(Vector3* a) {
|
||||||
|
return (float)a->length();
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DistanceP(Vector3* a, float x, float y, float z) {
|
||||||
|
return (float)a->distance(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DistanceV(Vector3* a, Vector3* b) {
|
||||||
|
return (float)a->distance(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Length=_Vector3_Length@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DistanceP=_Vector3_DistanceP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DistanceV=_Vector3_DistanceV@8")
|
||||||
|
|
||||||
|
DLL_METHOD float Vector3_DotP(Vector3* a, float x, float y, float z) {
|
||||||
|
return (float)a->dot(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DotV(Vector3* a, Vector3* b) {
|
||||||
|
return (float)a->dot(*b);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_CrossP(Vector3* a, float x, float y, float z, Vector3* out) {
|
||||||
|
Vector3 temp = a->cross(x, y, z);
|
||||||
|
*out = temp;
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_CrossV(Vector3* a, Vector3* b, Vector3* out) {
|
||||||
|
Vector3 temp = a->cross(*b);
|
||||||
|
*out = temp;
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_Normalize(Vector3* a) {
|
||||||
|
a->normalize();
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DotP=_Vector3_DotP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DotV=_Vector3_DotV@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_CrossP=_Vector3_CrossP@20")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_CrossV=_Vector3_CrossV@12")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Normalize=_Vector3_Normalize@4")
|
||||||
|
|
||||||
|
DLL_METHOD void Vector3_Rotate(Vector3* a, float pitch, float yaw, float roll) {
|
||||||
|
a->rotate(pitch, yaw, roll);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_RotateAroundP(Vector3* a, float x, float y, float z, float pitch, float yaw, float roll) {
|
||||||
|
a->rotateAround(x, y, z, pitch, yaw, roll);
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_RotateAroundV(Vector3* a, Vector3* b, float pitch, float yaw, float roll) {
|
||||||
|
a->rotateAround(*b, pitch, yaw, roll);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Rotate=_Vector3_Rotate@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_RotateAroundP=_Vector3_RotateAroundP@28")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_RotateAroundV=_Vector3_RotateAroundV@20")
|
||||||
|
|
||||||
|
DLL_METHOD float Vector3_DeltaPitchP(Vector3* a, float x, float y, float z) {
|
||||||
|
return (float)a->deltaPitch(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DeltaPitchV(Vector3* a, Vector3* b) {
|
||||||
|
return (float)a->deltaPitch(*b);
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DeltaYawP(Vector3* a, float x, float y, float z) {
|
||||||
|
return (float)a->deltaYaw(x, y, z);
|
||||||
|
}
|
||||||
|
DLL_METHOD float Vector3_DeltaYawV(Vector3* a, Vector3* b) {
|
||||||
|
return (float)a->deltaYaw(*b);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DeltaPitchP=_Vector3_DeltaPitchP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DeltaPitchV=_Vector3_DeltaPitchV@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DeltaYawP=_Vector3_DeltaYawP@16")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_DeltaYawV=_Vector3_DeltaYawV@8")
|
||||||
|
|
||||||
|
DLL_METHOD char* Vector3_Serialize(Vector3* a) {
|
||||||
|
return a->serialize();
|
||||||
|
}
|
||||||
|
DLL_METHOD void Vector3_Deserialize(Vector3* a, char* s) {
|
||||||
|
a->deserialize(s);
|
||||||
|
}
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Serialize=_Vector3_Serialize@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:Vector3_Deserialize=_Vector3_Deserialize@8")
|
||||||
|
*/
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#ifndef _USE_MATH_DEFINES
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
#undef _USE_MATH_DEFINES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct Vector3 {
|
||||||
|
union {
|
||||||
|
float X;
|
||||||
|
char Xc[4];
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
float Y;
|
||||||
|
char Yc[4];
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
float Z;
|
||||||
|
char Zc[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
void set(const float &o);
|
||||||
|
void set(const float &x, const float &y, const float &z);
|
||||||
|
void set(const Vector3 &o);
|
||||||
|
|
||||||
|
void add(const float &o);
|
||||||
|
void add(const float &x, const float &y, const float &z);
|
||||||
|
void add(const Vector3 &o);
|
||||||
|
|
||||||
|
void sub(const float &o);
|
||||||
|
void sub(const float &x, const float &y, const float &z);
|
||||||
|
void sub(const Vector3 &o);
|
||||||
|
|
||||||
|
void mul(const float &o);
|
||||||
|
void mul(const float &x, const float &y, const float &z);
|
||||||
|
void mul(const Vector3 &o);
|
||||||
|
|
||||||
|
void div(const float &o);
|
||||||
|
void div(const float &x, const float &y, const float &z);
|
||||||
|
void div(const Vector3 &o);
|
||||||
|
|
||||||
|
float length();
|
||||||
|
float distance(const float &x, const float &y, const float &z);
|
||||||
|
float distance(const Vector3 &o);
|
||||||
|
|
||||||
|
float dot(const float &x, const float &y, const float &z);
|
||||||
|
float dot(const Vector3 &o);
|
||||||
|
Vector3 cross(const float &x, const float &y, const float &z);
|
||||||
|
Vector3 cross(const Vector3 &o);
|
||||||
|
void normalize();
|
||||||
|
|
||||||
|
void rotate(float &pitch, float &yaw, float &roll);
|
||||||
|
void rotateAround(const float &x, const float &y, const float &z, float &pitch, float &yaw, float &roll);
|
||||||
|
void rotateAround(Vector3 &o, float &pitch, float &yaw, float &roll);
|
||||||
|
float deltaPitch();
|
||||||
|
float deltaPitch(const float &x, const float &y, const float &z);
|
||||||
|
float deltaPitch(Vector3 &o);
|
||||||
|
float deltaYaw();
|
||||||
|
float deltaYaw(const float &x, const float &y, const float &z);
|
||||||
|
float deltaYaw(Vector3 &o);
|
||||||
|
|
||||||
|
char* serialize();
|
||||||
|
void deserialize(char* o);
|
||||||
|
};*/
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
#include "Common.h"
|
||||||
|
#include <memory>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// Rev-engineered from https://github.com/blitz-research/blitz3d/blob/master/compiler/declnode.cpp
|
||||||
|
#define BBVARTYPE_GLOBAL 0
|
||||||
|
#define BBVARTYPE_INT 1
|
||||||
|
#define BBVARTYPE_FLOAT 2
|
||||||
|
#define BBVARTYPE_UNUSED 3
|
||||||
|
#define BBVARTYPE_STRING 4
|
||||||
|
#define BBVARTYPE_TYPE 5
|
||||||
|
#define BBVARTYPE_ARRAY 6
|
||||||
|
|
||||||
|
struct BBVar {
|
||||||
|
int Type = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarGlobal {
|
||||||
|
int GlobalType = -1;
|
||||||
|
int* Value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarInt : BBVar {
|
||||||
|
int Value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarFloat : BBVar {
|
||||||
|
float Value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarUnused : BBVar {
|
||||||
|
// Not a Dim, as you can see here:
|
||||||
|
// https://github.com/blitz-research/blitz3d/blob/master/compiler/stmtnode.cpp#L86
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarString : BBVar {
|
||||||
|
int Length;
|
||||||
|
char* Value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarElement;
|
||||||
|
struct BBVarType : BBVar {
|
||||||
|
BBVarElement used, free;
|
||||||
|
int fieldCount; // Field Info follows (Exactly <fieldCount> int pointers to variable struct)
|
||||||
|
int* fields[];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarElement {
|
||||||
|
int* currentPtr; // Points towards fields.
|
||||||
|
int* nextPtr, prevPtr;
|
||||||
|
BBVarType* BBStructPtr;
|
||||||
|
int refCount; // Fields usually follow here, may be at another location, see currentPtr.
|
||||||
|
//BBVar* fields[];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBVarArray : BBVar {
|
||||||
|
int Size; //???
|
||||||
|
BBVar* ArrayType;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string BBVar_Serialize(void* obj) {
|
||||||
|
std::stringstream myStream;
|
||||||
|
|
||||||
|
BBVar* var = (BBVar*)obj;
|
||||||
|
switch (var->Type) {
|
||||||
|
case BBVARTYPE_GLOBAL:
|
||||||
|
BBVarGlobal* varGlobal = (BBVarGlobal*)obj;
|
||||||
|
myStream << "[Global] " << BBVar_Serialize(varGlobal->Value) << std::endl;
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_INT:
|
||||||
|
BBVarInt* varInt = (BBVarInt*)obj;
|
||||||
|
myStream << "Int" << std::endl;
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_FLOAT:
|
||||||
|
BBVarFloat* varFloat = (BBVarFloat*)obj;
|
||||||
|
myStream << "Float" << std::endl;
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_UNUSED:
|
||||||
|
BBVarUnused* varUnused = (BBVarUnused*)obj;
|
||||||
|
myStream << "Unused" << std::endl;
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_STRING:
|
||||||
|
BBVarString* varString = (BBVarString*)obj;
|
||||||
|
myStream << "String" << std::endl;
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_TYPE:
|
||||||
|
BBVarType* varType = (BBVarType*)obj;
|
||||||
|
myStream << BBVarType_Serialize(varType);
|
||||||
|
break;
|
||||||
|
case BBVARTYPE_ARRAY:
|
||||||
|
BBVarArray* varArray = (BBVarArray*)obj;
|
||||||
|
myStream << "Array = " << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return myStream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string BBVarType_Serialize(BBVarType* obj, unsigned int indent = 0) {
|
||||||
|
std::stringstream myStream;
|
||||||
|
|
||||||
|
std::stringstream myPaddingSS;
|
||||||
|
for (unsigned int pad = 0; pad < indent; pad++) {
|
||||||
|
myPaddingSS << " ";
|
||||||
|
}
|
||||||
|
std::string myPadding = myPaddingSS.str();
|
||||||
|
|
||||||
|
myStream << myPadding << "Type {" << std::endl;
|
||||||
|
for (unsigned int fld = 0; fld < obj->fieldCount; fld++) {
|
||||||
|
myStream << myPadding << " (" << fld << ") => " << BBVar_Serialize(obj->fields[fld]) << std::endl;
|
||||||
|
}
|
||||||
|
myStream << myPadding << "}" << std::endl;
|
||||||
|
|
||||||
|
return myStream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_EXPORT(char*) SerializeObject(void* obj) {
|
||||||
|
return strdup(BBVar_Serialize(obj).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Laut Mark Sibly:
|
||||||
|
struct BBType {
|
||||||
|
int obj_size;
|
||||||
|
BBObj usedList, freeList;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BBObj {
|
||||||
|
BBObj *curr;
|
||||||
|
BBObj *next, *prev;
|
||||||
|
int* bbtype;
|
||||||
|
int ref_cnt;
|
||||||
|
};
|
||||||
+163
@@ -0,0 +1,163 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Double.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
std::list<double_t*> BU_DoubleTemporary;
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Create() {
|
||||||
|
return new double_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Destroy(double_t* pthis) {
|
||||||
|
delete pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Copy(double_t* other) {
|
||||||
|
double_t* pthis = new double_t;
|
||||||
|
*pthis = *other;
|
||||||
|
return pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_TempCreate() {
|
||||||
|
double_t* val = new double_t;
|
||||||
|
BU_DoubleTemporary.push_back(val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_TempCopy(double_t* other) {
|
||||||
|
double_t* val = new double_t(*other);
|
||||||
|
BU_DoubleTemporary.push_back(val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SetTemp(double_t* pthis) {
|
||||||
|
BU_DoubleTemporary.push_back(pthis);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_UnsetTemp(double_t* pthis) {
|
||||||
|
BU_DoubleTemporary.remove(pthis);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_TempCleanup() {
|
||||||
|
auto iterEnd = BU_DoubleTemporary.end();
|
||||||
|
for (auto iter = BU_DoubleTemporary.begin(); iter != iterEnd; ++iter) {
|
||||||
|
delete *iter;
|
||||||
|
}
|
||||||
|
BU_DoubleTemporary.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Set(double_t* pthis, double_t* other) {
|
||||||
|
*pthis = *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SetF(double_t* pthis, float_t other) {
|
||||||
|
*pthis = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Add(double_t* pthis, double_t* other) {
|
||||||
|
*pthis += *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_AddF(double_t* pthis, float_t other) {
|
||||||
|
*pthis += other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Sub(double_t* pthis, double_t* other) {
|
||||||
|
*pthis -= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SubF(double_t* pthis, float_t other) {
|
||||||
|
*pthis -= other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Mul(double_t* pthis, double_t* other) {
|
||||||
|
*pthis *= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_MulF(double_t* pthis, float_t other) {
|
||||||
|
*pthis *= other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Div(double_t* pthis, double_t* other) {
|
||||||
|
*pthis /= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_DivF(double_t* pthis, float_t other) {
|
||||||
|
*pthis /= other;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_Double_Compare(double_t* pthis, double_t* other) {
|
||||||
|
return (*pthis == *other ? 1 : 0) + (*pthis < *other ? 2 : 0) + (*pthis > *other ? 4 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_Double_CompareF(double_t* pthis, float_t other) {
|
||||||
|
return ((float_t)*pthis == other ? 1 : 0) + ((float_t)*pthis < other ? 2 : 0) + ((float_t)*pthis > other ? 4 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_Double_ToString(double_t* pthis) {
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << *pthis;
|
||||||
|
return stream.str().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromString(const char* text) {
|
||||||
|
std::stringstream stream = std::stringstream(text);
|
||||||
|
double_t* doublePtr = new double_t;
|
||||||
|
stream >> *doublePtr;
|
||||||
|
return doublePtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD float_t DLL_CALL BU_Double_ToFloat(double_t* pthis) {
|
||||||
|
return (float_t)*pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromFloat(float_t other) {
|
||||||
|
double_t* val = new double_t;
|
||||||
|
*val = (double_t)other;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_Double_ToLongLong(double_t* pthis) {
|
||||||
|
int64_t* val = new int64_t;
|
||||||
|
*val = (int64_t)*pthis;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromLongLong(int64_t* other) {
|
||||||
|
double_t* val = new double_t;
|
||||||
|
*val = (double_t)*other;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_Double_Serialize(double_t* pthis) {
|
||||||
|
union {
|
||||||
|
double_t real;
|
||||||
|
int64_t integer;
|
||||||
|
} myval;
|
||||||
|
myval.real = *pthis;
|
||||||
|
return int_to_hex<int64_t>(myval.integer).c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Deserialize(const char* text) {
|
||||||
|
union {
|
||||||
|
double_t real;
|
||||||
|
int64_t integer;
|
||||||
|
} myval;
|
||||||
|
myval.integer = hex_to_int<int64_t>(std::string(text));
|
||||||
|
return BU_Double_Copy(&myval.real);
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include "LongLong.h"
|
||||||
|
|
||||||
|
#pragma region Constructor & Destructor
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Create();
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Destroy(double_t* pthis);
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Copy(double_t* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Create=_BU_Double_Create@0")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Destroy=_BU_Double_Destroy@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Copy=_BU_Double_Copy@4")
|
||||||
|
#pragma endregion Constructor & Destructor
|
||||||
|
|
||||||
|
#pragma region Temporary Objects
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_TempCreate();
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_TempCopy(double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SetTemp(double_t* pthis);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_UnsetTemp(double_t* pthis);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_TempCleanup();
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_TempCreate=_BU_Double_TempCreate@0")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_TempCopy=_BU_Double_TempCopy@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_SetTemp=_BU_Double_SetTemp@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_UnsetTemp=_BU_Double_UnsetTemp@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_TempCleanup=_BU_Double_TempCleanup@0")
|
||||||
|
#pragma endregion Temporary Objects
|
||||||
|
|
||||||
|
#pragma region Math
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Set(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SetF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Set=_BU_Double_Set@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_SetF=_BU_Double_SetF@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Add(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_AddF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Add=_BU_Double_Add@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_AddF=_BU_Double_AddF@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Sub(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_SubF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Sub=_BU_Double_Sub@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_SubF=_BU_Double_SubF@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Mul(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_MulF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Mul=_BU_Double_Mul@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_MulF=_BU_Double_MulF@8")
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_Div(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_Double_DivF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Div=_BU_Double_Div@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_DivF=_BU_Double_DivF@8")
|
||||||
|
#pragma endregion Math
|
||||||
|
|
||||||
|
#pragma region Comparision
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_Double_Compare(double_t* pthis, double_t* other);
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_Double_CompareF(double_t* pthis, float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Compare=_BU_Double_Compare@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_CompareF=_BU_Double_CompareF@8")
|
||||||
|
#pragma endregion Comparision
|
||||||
|
|
||||||
|
#pragma region Conversion
|
||||||
|
// String conversion
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_Double_ToString(double_t* pthis);
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromString(const char* text);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_ToString=_BU_Double_ToString@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_FromString=_BU_Double_FromString@4")
|
||||||
|
// 32-Bit Floating Point
|
||||||
|
DLL_METHOD float_t DLL_CALL BU_Double_ToFloat(double_t* pthis);
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromFloat(float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_ToFloat=_BU_Double_ToFloat@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_FromFloat=_BU_Double_FromFloat@4")
|
||||||
|
// 64-Bit Integer
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_Double_ToLongLong(double_t* pthis);
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_FromLongLong(int64_t* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_ToLongLong=_BU_Double_ToLongLong@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_FromLongLong=_BU_Double_FromLongLong@4")
|
||||||
|
#pragma endregion Conversion
|
||||||
|
|
||||||
|
#pragma region Serialization
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_Double_Serialize(double_t* pthis);
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_Double_Deserialize(const char* text);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Serialize=_BU_Double_Serialize@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_Double_Deserialize=_BU_Double_Deserialize@4")
|
||||||
|
#pragma endregion Serialization
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
#pragma once
|
||||||
|
#include "FVector2.h"
|
||||||
|
|
||||||
|
double FVector2::length()
|
||||||
|
{
|
||||||
|
return std::sqrtf(std::abs((this->X*this->X) + (this->Y*this->Y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FVector2::normalize() {
|
||||||
|
double len = this->length();
|
||||||
|
double divisor = 1.0 / (len != 0 ? len : FLT_EPSILON);
|
||||||
|
}
|
||||||
|
|
||||||
|
double FVector2::distance(const FVector2 r)
|
||||||
|
{
|
||||||
|
float X = (this->X - r.X), Y = (this->Y - r.Y);
|
||||||
|
return std::sqrtf(std::abs(X*X + Y*Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* FVector2::serialize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::deserialize(const char* serialized) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2::FVector2(float V) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2::FVector2(float X, float Y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2::FVector2(FVector2& V) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator++() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator--() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator>(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator>(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FVector2::operator<(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator<(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FVector2::operator==(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator==(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FVector2::operator>=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator>=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FVector2::operator<=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator<=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FVector2::operator!=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FVector2::operator!=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator+(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator+(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator-(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator*(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator*(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator/(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator/(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator+=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator+=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator-=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator*=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator*=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator/=(const FVector2& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator/=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FVector2& FVector2::operator-(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2& FVector2::operator-=(const float& r) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#ifndef _USE_MATH_DEFINES
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
#undef _USE_MATH_DEFINES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct FVector2 {
|
||||||
|
float X, Y;
|
||||||
|
|
||||||
|
// Constructor & Destructor
|
||||||
|
FVector2(float V);
|
||||||
|
FVector2(float X, float Y);
|
||||||
|
FVector2(FVector2& V);
|
||||||
|
|
||||||
|
// Operator Overloading
|
||||||
|
FVector2& operator++();
|
||||||
|
FVector2& operator--();
|
||||||
|
bool operator>(const FVector2& r);
|
||||||
|
bool operator<(const FVector2& r);
|
||||||
|
bool operator==(const FVector2& r);
|
||||||
|
bool operator>=(const FVector2& r);
|
||||||
|
bool operator<=(const FVector2& r);
|
||||||
|
bool operator!=(const FVector2& r);
|
||||||
|
FVector2& operator=(const FVector2& r);
|
||||||
|
FVector2& operator+(const FVector2& r);
|
||||||
|
FVector2& operator-(const FVector2& r);
|
||||||
|
FVector2& operator*(const FVector2& r);
|
||||||
|
FVector2& operator/(const FVector2& r);
|
||||||
|
FVector2& operator+=(const FVector2& r);
|
||||||
|
FVector2& operator-=(const FVector2& r);
|
||||||
|
FVector2& operator*=(const FVector2& r);
|
||||||
|
FVector2& operator/=(const FVector2& r);
|
||||||
|
|
||||||
|
// Operator Overloading - float
|
||||||
|
bool operator>(const float& r);
|
||||||
|
bool operator<(const float& r);
|
||||||
|
bool operator==(const float& r);
|
||||||
|
bool operator>=(const float& r);
|
||||||
|
bool operator<=(const float& r);
|
||||||
|
bool operator!=(const float& r);
|
||||||
|
FVector2& operator=(const float& r);
|
||||||
|
FVector2& operator+(const float& r);
|
||||||
|
FVector2& operator-(const float& r);
|
||||||
|
FVector2& operator*(const float& r);
|
||||||
|
FVector2& operator/(const float& r);
|
||||||
|
FVector2& operator+=(const float& r);
|
||||||
|
FVector2& operator-=(const float& r);
|
||||||
|
FVector2& operator*=(const float& r);
|
||||||
|
FVector2& operator/=(const float& r);
|
||||||
|
|
||||||
|
// Simple Math
|
||||||
|
double length();
|
||||||
|
void normalize();
|
||||||
|
double distance(const FVector2 r);
|
||||||
|
|
||||||
|
// Advanced Math
|
||||||
|
void rotate(const double )
|
||||||
|
|
||||||
|
// Serialization
|
||||||
|
const char* serialize();
|
||||||
|
static FVector2& deserialize(const char* serialized);
|
||||||
|
};
|
||||||
|
|
||||||
|
DLL_METHOD FVector2* DLL_CALL BU_FVector2_Create();
|
||||||
|
DLL_METHOD FVector2* DLL_CALL BU_FVector2_Copy(FVector2* copyVector);
|
||||||
|
DLL_METHOD void DLL_CALL BU_FVector2_Destroy();
|
||||||
|
|
||||||
|
DLL_METHOD FVector2* DLL_CALL BU_FVector2_TempCreate();
|
||||||
|
DLL_METHOD FVector2* DLL_CALL BU_FVector2_TempCopy(FVector2* copyVector);
|
||||||
|
DLL_METHOD void DLL_CALL BU_FVector2_SetTemp(FVector2* vector);
|
||||||
|
DLL_METHOD void DLL_CALL BU_FVector2_UnsetTemp(FVector2* vector);
|
||||||
|
DLL_METHOD void DLL_CALL BU_FVector2_TempCleanup();
|
||||||
|
|
||||||
|
DLL_METHOD float DLL_CALL BU_FVector2_Length(FVector2* vector);
|
||||||
|
DLL_METHOD float DLL_CALL BU_FVector2_Normalize();
|
||||||
|
DLL_METHOD float DLL_CALL BU_FVector2_Distance(FVector2* vector);
|
||||||
|
DLL_METHOD float DLL_CALL BU_FVector2_DistanceL(float X, float Y);
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "LongLong.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
std::list<int64_t*> blitzLLTemporary;
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_Create() {
|
||||||
|
return new int64_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Destroy(int64_t* pthis) {
|
||||||
|
delete pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_Copy(int64_t* other) {
|
||||||
|
int64_t* pthis = new int64_t;
|
||||||
|
*pthis = *other;
|
||||||
|
return pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_TempCreate() {
|
||||||
|
int64_t* val = new int64_t;
|
||||||
|
blitzLLTemporary.push_back(val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_TempCopy(int64_t* other) {
|
||||||
|
int64_t* val = new int64_t(*other);
|
||||||
|
blitzLLTemporary.push_back(val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_SetTemp(int64_t* pthis) {
|
||||||
|
blitzLLTemporary.push_back(pthis);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_UnsetTemp(int64_t* pthis) {
|
||||||
|
blitzLLTemporary.remove(pthis);
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_TempCleanup() {
|
||||||
|
auto iterEnd = blitzLLTemporary.end();
|
||||||
|
for (auto iter = blitzLLTemporary.begin(); iter != iterEnd; ++iter) {
|
||||||
|
delete *iter;
|
||||||
|
}
|
||||||
|
blitzLLTemporary.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Set(int64_t* pthis, int64_t* other) {
|
||||||
|
*pthis = *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_SetV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
*pthis = ((int64_t)left << 32) + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Add(int64_t* pthis, int64_t* other) {
|
||||||
|
*pthis += *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_AddV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
*pthis += ((int64_t)left << 32) + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Sub(int64_t* pthis, int64_t* other) {
|
||||||
|
*pthis -= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_SubV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
*pthis -= ((int64_t)left << 32) + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Mul(int64_t* pthis, int64_t* other) {
|
||||||
|
*pthis *= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_MulV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
*pthis *= ((int64_t)left << 32) + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_Div(int64_t* pthis, int64_t* other) {
|
||||||
|
*pthis *= *other;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL BU_LongLong_DivV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
*pthis *= ((int64_t)left << 32) + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DLL_CALL BU_LongLong_Compare(int64_t* pthis, int64_t* other) {
|
||||||
|
return (*pthis == *other ? 1 : 0) + (*pthis < *other ? 2 : 0) + (*pthis > *other ? 4 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DLL_CALL BU_LongLong_CompareV(int64_t* pthis, uint32_t left, uint32_t right) {
|
||||||
|
int64_t other = ((int64_t)left << 32) + right;
|
||||||
|
return (*pthis == other ? 1 : 0) + (*pthis < other ? 2 : 0) + (*pthis > other ? 4 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* DLL_CALL BU_LongLong_ToString(int64_t* pthis) {
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << *pthis;
|
||||||
|
return stream.str().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_FromString(const char* text) {
|
||||||
|
std::stringstream stream = std::stringstream(text);
|
||||||
|
int64_t* val = new int64_t;
|
||||||
|
stream >> *val;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t DLL_CALL BU_LongLong_ToLong(int64_t* pthis, int32_t _modulus) {
|
||||||
|
return *pthis % _modulus;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_FromLong(int32_t left, int32_t right) {
|
||||||
|
int64_t* val = new int64_t;
|
||||||
|
*val = ((int64_t)left << 32) + right;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t DLL_CALL BU_LongLong_ToLongHigh(int64_t* pthis) {
|
||||||
|
return (int32_t)((*pthis) >> 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t DLL_CALL BU_LongLong_ToLongLow(int64_t* pthis) {
|
||||||
|
return (int32_t)((*pthis) && 0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
float_t DLL_CALL BU_LongLong_ToFloat(int64_t* pthis) {
|
||||||
|
return (float)*pthis;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_FromFloat(float_t other) {
|
||||||
|
int64_t val = (int64_t)other;
|
||||||
|
return BU_LongLong_Copy(&val);
|
||||||
|
}
|
||||||
|
|
||||||
|
double_t* DLL_CALL BU_LongLong_ToDouble(int64_t* pthis) {
|
||||||
|
double_t* val = new double_t;
|
||||||
|
*val = (double_t)*pthis;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_FromDouble(double_t* other) {
|
||||||
|
int64_t* val = new int64_t;
|
||||||
|
*val = (int64_t)*other;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* DLL_CALL BU_LongLong_Serialize(int64_t* pthis) {
|
||||||
|
return int_to_hex<int64_t>(*pthis).c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t* DLL_CALL BU_LongLong_Deserialize(const char* text) {
|
||||||
|
int64_t val = hex_to_int<int64_t>(std::string(text));
|
||||||
|
return BU_LongLong_Copy(&val);
|
||||||
|
}
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include "Double.h"
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#pragma region Constructor & Destructor
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_Create();
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Destroy(int64_t* pthis);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_Copy(int64_t* other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Create=_BU_LongLong_Create@0")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Destroy=_BU_LongLong_Destroy@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Copy=_BU_LongLong_Copy@4")
|
||||||
|
#pragma endregion Constructor & Destructor
|
||||||
|
|
||||||
|
#pragma region Temporary Objects
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_TempCreate();
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_TempCopy(int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_SetTemp(int64_t* pthis);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_UnsetTemp(int64_t* pthis);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_TempCleanup();
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCreate=_BU_LongLong_TempCreate@0")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCopy=_BU_LongLong_TempCopy@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_SetTemp=_BU_LongLong_SetTemp@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_UnsetTemp=_BU_LongLong_UnsetTemp@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCleanup=_BU_LongLong_TempCleanup@0")
|
||||||
|
#pragma endregion Temporary Objects
|
||||||
|
|
||||||
|
#pragma region Math
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Set(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_SetV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Set=_BU_LongLong_Set@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_SetV=_BU_LongLong_SetV@12")
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Add(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_AddV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Add=_BU_LongLong_Add@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_AddV=_BU_LongLong_AddV@12")
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Sub(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_SubV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Sub=_BU_LongLong_Sub@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_SubV=_BU_LongLong_SubV@12")
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Mul(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_MulV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Mul=_BU_LongLong_Mul@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_MulV=_BU_LongLong_MulV@12")
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_Div(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD void DLL_CALL BU_LongLong_DivV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Div=_BU_LongLong_Div@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_DivV=_BU_LongLong_DivV@12")
|
||||||
|
#pragma endregion Math
|
||||||
|
|
||||||
|
#pragma region Comparison
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_LongLong_Compare(int64_t* pthis, int64_t* other);
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_LongLong_CompareV(int64_t* pthis, uint32_t left, uint32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Compare=_BU_LongLong_Compare@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_CompareV=_BU_LongLong_CompareV@12")
|
||||||
|
#pragma endregion Comparison
|
||||||
|
|
||||||
|
|
||||||
|
#pragma region Conversion
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_LongLong_ToString(int64_t* pthis);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_FromString(const char* text);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToString=_BU_LongLong_ToString@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_FromString=_BU_LongLong_FromString@4")
|
||||||
|
DLL_METHOD int32_t DLL_CALL BU_LongLong_ToLong(int64_t* pthis, int32_t _modulus);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_FromLong(int32_t left, int32_t right);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLong=_BU_LongLong_ToLong@8")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_FromLong=_BU_LongLong_FromLong@8")
|
||||||
|
DLL_METHOD int32_t DLL_CALL BU_LongLong_ToLongHigh(int64_t* pthis);
|
||||||
|
DLL_METHOD int32_t DLL_CALL BU_LongLong_ToLongLow(int64_t* pthis);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLongHigh=_BU_LongLong_ToLongHigh@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLongLow=_BU_LongLong_ToLongLow@4")
|
||||||
|
DLL_METHOD float_t DLL_CALL BU_LongLong_ToFloat(int64_t* pthis);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_FromFloat(float_t other);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToFloat=_BU_LongLong_ToFloat@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_FromFloat=_BU_LongLong_FromFloat@4")
|
||||||
|
DLL_METHOD double_t* DLL_CALL BU_LongLong_ToDouble(int64_t* pthis);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_FromDouble(double_t* pthis);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_ToDouble=_BU_LongLong_ToDouble@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_FromDouble=_BU_LongLong_FromDouble@4")
|
||||||
|
#pragma endregion Conversion
|
||||||
|
|
||||||
|
#pragma region Serialization
|
||||||
|
DLL_METHOD const char* DLL_CALL BU_LongLong_Serialize(int64_t* pthis);
|
||||||
|
DLL_METHOD int64_t* DLL_CALL BU_LongLong_Deserialize(const char* text);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Serialize=_BU_LongLong_Serialize@4")
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_LongLong_Deserialize=_BU_LongLong_Deserialize@4")
|
||||||
|
#pragma endregion Serialization
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "DisplayEnumerator.h"
|
||||||
|
|
||||||
|
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
||||||
|
DisplayEnumerator* displayEnumerator = (DisplayEnumerator*)dwData;
|
||||||
|
|
||||||
|
displayEnumerator->displays.push_back(RECT(*lprcMonitor));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD DisplayEnumerator* DLL_CALL BU_DisplayEnumerator_Create() {
|
||||||
|
DisplayEnumerator* displayEnumerator = new DisplayEnumerator();
|
||||||
|
return displayEnumerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator) {
|
||||||
|
delete displayEnumerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator) {
|
||||||
|
EnumDisplayMonitors(NULL, NULL, BU_DisplayEnumerator_Callback, (LPARAM)displayEnumerator);
|
||||||
|
|
||||||
|
return displayEnumerator->displays.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator) {
|
||||||
|
return displayEnumerator->displays.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, PRECT display) {
|
||||||
|
// Retrieve the requested index.
|
||||||
|
auto iterator = displayEnumerator->displays.begin();
|
||||||
|
std::advance(iterator, index);
|
||||||
|
|
||||||
|
// Copy data.
|
||||||
|
display->left = iterator->left;
|
||||||
|
display->top = iterator->top;
|
||||||
|
display->right = iterator->right;
|
||||||
|
display->bottom = iterator->bottom;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
struct DisplayEnumerator {
|
||||||
|
std::list<RECT> displays;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Internal Callback
|
||||||
|
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
|
||||||
|
|
||||||
|
// Exported functions.
|
||||||
|
DLL_METHOD DisplayEnumerator* DLL_CALL BU_DisplayEnumerator_Create();
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Create=_BU_DisplayEnumerator_Create@0")
|
||||||
|
DLL_METHOD void DLL_CALL BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Destroy=_BU_DisplayEnumerator_Destroy@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Enumerate=_BU_DisplayEnumerator_Enumerate@4")
|
||||||
|
DLL_METHOD uint32_t DLL_CALL BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Count=_BU_DisplayEnumerator_Count@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, LPRECT display);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Retrieve=_BU_DisplayEnumerator_Retrieve@12")
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include "MassOp.h"
|
||||||
|
|
||||||
|
MassOp::MassOp(uint32_t length) : length(length) {
|
||||||
|
this->instructions = new MassOpInstruction[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
MassOp::~MassOp() {
|
||||||
|
delete this->instructions;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD MassOp* DLL_CALL BU_MassOp_Create(uint32_t length) {
|
||||||
|
MassOp* myMassOp = new MassOp(length);
|
||||||
|
return myMassOp;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Destroy(MassOp* massop) {
|
||||||
|
delete massop;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result) {
|
||||||
|
massop->instructions[index].type = type;
|
||||||
|
massop->instructions[index].code = code;
|
||||||
|
massop->instructions[index].leftOperand = leftOperand;
|
||||||
|
massop->instructions[index].rightOperand = rightOperand;
|
||||||
|
massop->instructions[index].result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Run(MassOp* massop) {
|
||||||
|
for (uint32_t index = 0; index < massop->length; index++) {
|
||||||
|
MassOpInstruction* instr = &massop->instructions[index];
|
||||||
|
switch (instr->code) {
|
||||||
|
case GoTo:
|
||||||
|
index = instr->leftOperand;
|
||||||
|
break;
|
||||||
|
case SetOpCode:
|
||||||
|
massop->instructions[instr->leftOperand].code = instr->rightOperand;
|
||||||
|
break;
|
||||||
|
case CopyLeft:
|
||||||
|
if (instr->leftOperand != instr->rightOperand) {
|
||||||
|
switch (instr->result) {
|
||||||
|
case 0:
|
||||||
|
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].leftOperand;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].leftOperand;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].leftOperand;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CopyRight:
|
||||||
|
if (instr->leftOperand != instr->rightOperand) {
|
||||||
|
switch (instr->result) {
|
||||||
|
case 0:
|
||||||
|
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].rightOperand;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].rightOperand;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].rightOperand;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CopyOut:
|
||||||
|
if (instr->leftOperand != instr->rightOperand) {
|
||||||
|
switch (instr->result) {
|
||||||
|
case 0:
|
||||||
|
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].result;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].result;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].result;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case If:
|
||||||
|
if (instr->leftOperand != instr->rightOperand) {
|
||||||
|
if (massop->instructions[instr->leftOperand].result == massop->instructions[instr->rightOperand].result) {
|
||||||
|
index += instr->result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IfValue:
|
||||||
|
if (instr->leftOperand != instr->rightOperand) {
|
||||||
|
if (massop->instructions[instr->rightOperand].result == instr->rightOperand) {
|
||||||
|
index += instr->result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
switch (instr->type) {
|
||||||
|
case Double:
|
||||||
|
switch (instr->code) {
|
||||||
|
case Create:
|
||||||
|
instr->result = (uint32_t)BU_Double_Create();
|
||||||
|
break;
|
||||||
|
case Destroy:
|
||||||
|
BU_Double_Destroy((double_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case Copy:
|
||||||
|
instr->result = (uint32_t)BU_Double_Copy((double_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case TempCreate:
|
||||||
|
instr->result = (uint32_t)BU_Double_TempCreate();
|
||||||
|
break;
|
||||||
|
case TempCopy:
|
||||||
|
instr->result = (uint32_t)BU_Double_TempCopy((double_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case TempCleanup:
|
||||||
|
BU_Double_TempCleanup();
|
||||||
|
break;
|
||||||
|
case Set:
|
||||||
|
BU_Double_Set((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Add:
|
||||||
|
BU_Double_Add((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Sub:
|
||||||
|
BU_Double_Sub((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Mul:
|
||||||
|
BU_Double_Mul((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Div:
|
||||||
|
BU_Double_Div((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Compare:
|
||||||
|
instr->result = BU_Double_Compare((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LongLong:
|
||||||
|
switch (instr->code) {
|
||||||
|
case Create:
|
||||||
|
instr->result = (uint32_t)BU_LongLong_Create();
|
||||||
|
break;
|
||||||
|
case Destroy:
|
||||||
|
BU_LongLong_Destroy((int64_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case Copy:
|
||||||
|
instr->result = (uint32_t)BU_LongLong_Copy((int64_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case TempCreate:
|
||||||
|
instr->result = (uint32_t)BU_LongLong_TempCreate();
|
||||||
|
break;
|
||||||
|
case TempCopy:
|
||||||
|
instr->result = (uint32_t)BU_LongLong_TempCopy((int64_t*)instr->leftOperand);
|
||||||
|
break;
|
||||||
|
case TempCleanup:
|
||||||
|
BU_LongLong_TempCleanup();
|
||||||
|
break;
|
||||||
|
case Set:
|
||||||
|
BU_LongLong_Set((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Add:
|
||||||
|
BU_LongLong_Add((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Sub:
|
||||||
|
BU_LongLong_Sub((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Mul:
|
||||||
|
BU_LongLong_Mul((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Div:
|
||||||
|
BU_LongLong_Div((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
case Compare:
|
||||||
|
instr->result = BU_LongLong_Compare((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// Blitz - Steam wrapper for Blitz.
|
||||||
|
// Copyright (C) 2015 Project Kube (Michael Fabian Dirks)
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dllmain.h"
|
||||||
|
#include "Type\Double.h"
|
||||||
|
#include "Type\LongLong.h"
|
||||||
|
|
||||||
|
enum MassOpType {
|
||||||
|
LongLong = 0,
|
||||||
|
Double = 1,
|
||||||
|
|
||||||
|
Vector2 = 10,
|
||||||
|
Vector3 = 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MassOpCode {
|
||||||
|
Create = 0,
|
||||||
|
Destroy = 1,
|
||||||
|
Copy = 2,
|
||||||
|
TempCreate = 5,
|
||||||
|
TempCopy = 6,
|
||||||
|
TempCleanup = 7,
|
||||||
|
|
||||||
|
Set = 10,
|
||||||
|
Add = 11,
|
||||||
|
Sub = 12,
|
||||||
|
Mul = 13,
|
||||||
|
Div = 14,
|
||||||
|
Compare = 15,
|
||||||
|
|
||||||
|
// Special OPCodes (Control MassOp)
|
||||||
|
// Goto - Go to a specific intruction
|
||||||
|
// oper_l = target massop index
|
||||||
|
GoTo = 249,
|
||||||
|
// SetOpCode - Change OpCode at position
|
||||||
|
// oper_l = target massop index
|
||||||
|
// oper_r = new OpCode
|
||||||
|
SetOpCode = 250,
|
||||||
|
// CopyLeft - Copy oper_l to new MassOp instruction.
|
||||||
|
// oper_l = source massop index
|
||||||
|
// oper_r = target massop index
|
||||||
|
// out = target position (0/oper_l, 1/oper_r, 2/out)
|
||||||
|
CopyLeft = 251,
|
||||||
|
// CopyRight - Copy oper_r to new MassOp instruction.
|
||||||
|
// oper_l = source massop index
|
||||||
|
// oper_r = target massop index
|
||||||
|
// out = target position (0/oper_l, 1/oper_r, 2/out)
|
||||||
|
CopyRight = 252,
|
||||||
|
// CopyOut - Copy out to new MassOp instruction.
|
||||||
|
// oper_l = source massop index
|
||||||
|
// oper_r = target massop index
|
||||||
|
// out = target position (0/oper_l, 1/oper_r, 2/out)
|
||||||
|
CopyOut = 253,
|
||||||
|
// If - If the result of index oper_l is equal to index oper_r, skip out instructions.
|
||||||
|
// oper_l = source massop index
|
||||||
|
// oper_r = target massop index
|
||||||
|
// out = instructions to skip
|
||||||
|
If = 254,
|
||||||
|
// IfValue - If the result of index oper_l is equal to oper_r, skip out instructions.
|
||||||
|
// oper_l = source massop index
|
||||||
|
// oper_r = value to compare with
|
||||||
|
// out = instructions to skip
|
||||||
|
IfValue = 255
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BlitzBank {
|
||||||
|
uint32_t identifier;
|
||||||
|
uint32_t address;
|
||||||
|
uint32_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MassOpInstruction {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t code;
|
||||||
|
uint32_t leftOperand, rightOperand;
|
||||||
|
uint32_t result;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MassOp {
|
||||||
|
MassOp(uint32_t length);
|
||||||
|
~MassOp();
|
||||||
|
|
||||||
|
uint32_t length;
|
||||||
|
MassOpInstruction* instructions;
|
||||||
|
};
|
||||||
|
|
||||||
|
DLL_METHOD MassOp* DLL_CALL BU_MassOp_Create(uint32_t length);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_MassOp_Create=_BU_MassOp_Create@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Destroy(MassOp* massop);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_MassOp_Destroy=_BU_MassOp_Destroy@4")
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_MassOp_Instruction=_BU_MassOp_Instruction@28")
|
||||||
|
DLL_METHOD void DLL_CALL BU_MassOp_Run(MassOp* massop);
|
||||||
|
#pragma comment(linker, "/EXPORT:BU_MassOp_Run=_BU_MassOp_Run@4")
|
||||||
Reference in New Issue
Block a user