/* 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" __gcccall void asm DirtyRect_clean(const DirtyRect *dr) { #if 0 /* Original C code. */ byte *dest = dr->addr; //printf("[CDR %p %u %u]", dest, dr->rowBytes, dr->numRows); for (byte n = dr->numRows, i = 0; i < n; ++i, dest += BYTES_PER_ROW) { memset(dest, '\0', dr->rowBytes); } #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 DIRTY_RECT_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 }