diff --git a/11_day/sheet.c b/11_day/sheet.c index e5bd624..2df8d99 100644 --- a/11_day/sheet.c +++ b/11_day/sheet.c @@ -113,6 +113,13 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1) int h, bx, by, vx, vy, bx0, by0, bx1, by1; unsigned char *buf, c, *vram = ctl->vram; struct SHEET *sht; + + /* 如果refresh的范围超出了画面则修正 */ + if (vx0 < 0) { vx0 = 0; } + if (vy0 < 0) { vy0 = 0; } + if (vx1 > ctl->xsize) { vx1 = ctl->xsize; } + if (vy1 > ctl->ysize) { vy1 = ctl->ysize; } + for (h = 0; h <= ctl->top; h++) { sht = ctl->sheets[h]; buf = sht->buf;