2 实现画面外的支持(harib08b)
怎么才能让图层位于画面以外时也不出问题呢?因为只有sheet_refreshsub函数在做把图层内容写入VRAM的工作,所以我们决定把这个函数做得完美一些,让它不刷新画面以外的部分。
本次的sheet.c节选
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++) {
(中略)
}
return;
}
这里不需要特别解释了吧,我们来“make run”。
成功啦!
运行成功啦!只稍作修改就解决了问题,太厉害了。