Advertisement
FatalSleep

Untitled

Jul 9th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. #pragma once
  2. #define Export extern "C" _declspec( dllexport )
  3. #include <vector>
  4.  
  5. typedef unsigned char ubyte;
  6. typedef signed char sbyte;
  7. typedef unsigned short uint16;
  8. typedef signed short sint16;
  9. typedef unsigned int uint32;
  10. typedef signed int sint32;
  11. typedef unsigned long long uint64;
  12. typedef signed long long sint64;
  13. typedef float float32;
  14. typedef double float64;
  15. typedef bool boolflag;
  16.  
  17. ubyte* BytePrism = nullptr;
  18. uint64 ByteAddress = 0;
  19. uint32 ByteBuffWidth = 0;
  20. uint32 ByteBuffHeight = 0;
  21. uint32 ByteBuffDepth = 0;
  22. std::vector<uint64> ByteMemory;
  23. std::vector<uint32> ByteWidth;
  24. std::vector<uint32> ByteHeight;
  25. std::vector<uint32> ByteDepth;
  26.  
  27. // Creates a Prism and returns it's memory address(for reference).
  28. Export float64 PrismCreate( uint32 Width , uint32 Height , uint32 Depth ) {
  29. ubyte* Prism = new ubyte[ Width * Height * Depth ]();
  30. ByteMemory.push_back( ( uint64 ) Prism );
  31. ByteWidth.push_back( Width );
  32. ByteHeight.push_back( Height );
  33. ByteDepth.push_back( Depth );
  34. return ( float64 ) ( ( uint64 ) Prism );
  35. };
  36.  
  37. // Deletes a Prism from the specified memory address if the Prism exists.
  38. Export float64 PrismDelete( float64 Address ) {
  39. for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
  40. if ( ByteMemory.at( b ) == ( uint64 ) Address ) {
  41. ByteMemory.erase( ByteMemory.begin() + b );
  42. ByteWidth.erase( ByteWidth.begin() + b );
  43. ByteHeight.erase( ByteHeight.begin() + b );
  44. ByteDepth.erase( ByteDepth.begin() + b );
  45. ByteMemory.shrink_to_fit();
  46. ByteWidth.shrink_to_fit();
  47. ByteHeight.shrink_to_fit();
  48. ByteDepth.shrink_to_fit();
  49. delete[] ( ( ubyte* ) ( ( uint64 ) Address ) );
  50.  
  51. if ( ( uint64 ) Address == ( uint64 ) BytePrism ) {
  52. BytePrism = nullptr;
  53. ByteAddress = 0;
  54. ByteBuffWidth = 0;
  55. ByteBuffHeight = 0;
  56. ByteBuffDepth = 0;
  57. return 2.0;
  58. };
  59.  
  60. return 1.0;
  61. };
  62. };
  63.  
  64. return 0.0;
  65. };
  66.  
  67. // Sets the system target to the specified Prism if the Prism exists.
  68. Export float64 PrismTarget( float64 Address ) {
  69. for( uint32 b = 0; b < ByteMemory.size(); b ++ ) {
  70. if ( ByteMemory.at( b ) == ( uint64 ) Address ) {
  71. ByteBuffWidth = ByteWidth.at( b );
  72. ByteBuffHeight = ByteHeight.at( b );
  73. ByteBuffDepth = ByteDepth.at( b );
  74. BytePrism = ( ubyte* ) ( ( uint64 ) Address );
  75. ByteAddress = ( uint64 ) Address;
  76. return 1.0;
  77. };
  78. };
  79.  
  80. return 0.0;
  81. };
  82.  
  83. // Resets the system target to null(no target).
  84. Export float64 PrismReset( void ) {
  85. BytePrism = nullptr;
  86. ByteAddress = 0;
  87. return 0.0;
  88. };
  89.  
  90. // Returns the total number of cells of the prism.
  91. Export float64 PrismCells( void ) {
  92. return ( float64 ) ( ByteBuffWidth * ByteBuffHeight * ByteBuffDepth );
  93. };
  94.  
  95. // Returns either the Width, Height or Depth of the Prism.
  96. Export float64 PrismDimension( float64 Dimension ) {
  97.  
  98. switch( ( uint64 ) Dimension ) {
  99. case 0:
  100. //( ( float64 ) ByteBuffWidth );
  101. return ( ( float64 ) ByteBuffWidth );
  102. break;
  103. case 1:
  104. return ( ( float64 ) ByteBuffHeight );
  105. break;
  106. case 2:
  107. return ( ( float64 ) ByteBuffDepth );
  108. break;
  109. default:
  110. return -1;
  111. break;
  112. };
  113. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement