/* DirtyRect.c
Copyright (C) 2026 Pierre Sarrazin
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 .
*/
#include "DirtyRect.h"
#include
__gcccall void asm
DirtyRect_clean(const DirtyRect *dr)
{
#if 0 /* Original C code. */
byte *dest = dr->addr;
//printf("[DRCLEAN %p %u]", dest, dr->numRows);
assert(dr->numRows > 0 && dr->numRows <= 192);
for (byte n = dr->numRows, i = 0; i < n; ++i, dest += DirtyRect_BYTES_PER_ROW)
{
memset(dest, '\0', DirtyRect_WIDTH);
}
#else
asm
{
; 'dr' received in X as per __gcccall.
ldb 2,x ; B = dr->numRows: height in pixels of rectangle
ldx ,x ; X = dr->addr: 1st screen byte of top row of dirty rect
clra ; byte to clear with
@nextRow
sta ,x ; a dirty rect is already 3 bytes wide (cf DirtyRect_WIDTH)
sta 1,x
sta 2,x
@cond
leax DirtyRect_BYTES_PER_ROW,x ; point to next screen row
decb ; rows left?
bne @nextRow ; if yes
}
#endif
}