Files
CoCoPlanes/DirtyRectList.c
T
Brian Holman 7939132267 Import coco-planes 0.1.0 upstream source snapshot
Original author: Pierre Sarrazin. Preserve upstream GPLv3-or-later and file-specific notices.
Source: http://sarrazip.com/dev/coco-planes-0.1.0.tar.gz
Archive SHA-256: 29191e6ba225965caa637ee726e1189639dc7fcdf2b68310fb93fbffd56c9c52
2026-11-09 23:39:59 -07:00

63 lines
1.6 KiB
C

/* DirtyRectList.c
Copyright (C) 2026 Pierre Sarrazin <http://sarrazip.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DirtyRectList.h"
#include <assert.h>
void
DirtyRectList_init(DirtyRectList *self)
{
self->count = 0;
self->peak = 0;
}
BOOL
DirtyRectList_add(DirtyRectList *self, byte *addr, byte numRows)
{
assert(self);
assert(addr);
assert(numRows > 0);
byte *count = &self->count;
if (*count >= DirtyRectList_MAX_DIRTY_RECTS)
return FALSE;
DirtyRect *dr = &self->rects[(*count)++]; // next DirtyRect field to fill
dr->addr = addr;
dr->numRows = numRows;
#ifndef NDEBUG
if (*count > self->peak)
self->peak = *count;
#endif
return TRUE;
}
void
DirtyRectList_clean(DirtyRectList *self)
{
const DirtyRect *dr = self->rects;
//printf("[DRLCLEAN(%p):DR=%p,C=%u]", self, dr, self->count);
for (byte i = self->count; i--; ++dr)
DirtyRect_clean(dr);
//printf("[DRLCLEAN:END]");
self->count = 0;
}