static void InitMemoryTable(global_memory *GlobalMemory, memory *Memory, uint64 Size, memory_table_list TableName, char *Name) { memory_table *Table = &Memory->Slot[TableName]; Table->Name = Name; Table->Address = (uint64 *)((uint8 *)GlobalMemory->Address + GlobalMemory->CurrentPosition); Table->Size = Size; GlobalMemory->CurrentPosition += Size; } static void* AllocateMemory(memory *Memory, uint64 Size, memory_table_list TableName) { void *Address; memory_table *Table = &Memory->Slot[TableName]; if (Table->CurrentPosition + Size > Table->Size) { return NULL; } Address = (uint64 *)((uint8 *)Table->Address + Table->CurrentPosition); Table->CurrentPosition += Size; return Address; } // Returns 0-1 range wherever Pointer is in relation to StartingPointer to Size*Amount. static real32 Memory_NormalizedPosition(void *StartingPointer, uint32 Amount, uint32 Size, void *Pointer) { real32 Result = 0; uint64 TotalSize = Amount*Size; uint64 PointerLocationSize = (uint8 *)Pointer - (uint8 *)StartingPointer; Result = (real32)PointerLocationSize / (real32)TotalSize; return Result; }