From 67898c6505c9180b5a5a31457f11d29b41fa91ba Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Mon, 15 Aug 2022 10:08:07 -0400 Subject: fixes --- memory.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'memory.cpp') 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); -- cgit v1.2.3