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
52 lines
1.7 KiB
C
52 lines
1.7 KiB
C
/* DirtyRect.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 "DirtyRect.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
__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
|
|
}
|