summaryrefslogtreecommitdiff
path: root/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'memory.cpp')
-rw-r--r--memory.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/memory.cpp b/memory.cpp
index 8ff508f..dd581b7 100644
--- a/memory.cpp
+++ b/memory.cpp
@@ -57,12 +57,11 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek)
uint16 Width = Source->Info.Width;
uint16 Height = Source->Info.Height;
uint16 BytesPerPixel = Source->Info.BytesPerPixel;
- int32 Pitch = Width*BytesPerPixel;
memory_table *Table = &Memory->Slot[B_LoadedBitmaps];
// First check whether we'd run over the buffer at the current
- // position, and reset it if so.
+ // position, and reset the position if so.
uint64 Size = Bitmap_CalcTotalBytes(Width, Height, BytesPerPixel);
if (Table->CurrentPosition + Size > Table->Size) {
Table->CurrentPosition = 0;
@@ -71,6 +70,8 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek)
cached_bitmap *Bitmap = &Memory->Bitmap[Table->PointerIndex];
+ // If there are no pointers in front of us, we don't have to free any space
+ // and just need to increment the number of pointers.
if (Table->PointerIndex != Table->NumberOfPointers) {
// Next, if there's a pointer in front of the current position,
// check whether it's far away enough so that the size fits.
@@ -78,7 +79,7 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek)
if (Bitmap->Data) {
uint64 BytesBetween = (uint8 *)Bitmap->Data - ((uint8 *)Table->Address + Table->CurrentPosition);
if (BytesBetween > Size) {
- int16 StopAt = Table->NumberOfPointers - 1;
+ uint32 StopAt = Table->NumberOfPointers - 1;
while (StopAt > Table->PointerIndex - 1) {
Memory->Bitmap[StopAt + 1] = Memory->Bitmap[StopAt];
StopAt--;
@@ -102,7 +103,7 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek)
void *Data2 = Memory->Bitmap[Table->PointerIndex+1].Data;
uint64 BytesBetween = (uint8 *)Data2 - (uint8 *)AddressStart;
if (BytesBetween < Size) {
- int16 StopAt = Table->PointerIndex;
+ uint32 StopAt = Table->PointerIndex;
while (StopAt < Table->NumberOfPointers - 1) {
Memory->Bitmap[StopAt] = Memory->Bitmap[StopAt + 1];
StopAt++;
@@ -121,8 +122,6 @@ Memory_RollingBitmap(memory *Memory, source *Source, uint32 FrameToSeek)
}
}
} else {
- // Increment the total number of pointers if the PointerIndex is ahead
- // of the amount of pointers.
Table->NumberOfPointers++;
}
Bitmap->Data = AllocateMemory(Memory, Size, B_LoadedBitmaps);