2 实现画面外的支持(harib08b)

怎么才能让图层位于画面以外时也不出问题呢?因为只有sheet_refreshsub函数在做把图层内容写入VRAM的工作,所以我们决定把这个函数做得完美一些,让它不刷新画面以外的部分。

本次的sheet.c节选

  1. void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
  2. {
  3. int h, bx, by, vx, vy, bx0, by0, bx1, by1;
  4. unsigned char *buf, c, *vram = ctl->vram;
  5. struct SHEET *sht;
  6. /* 如果refresh的范围超出了画面则修正 */
  7. if (vx0 < 0) { vx0 = 0; }
  8. if (vy0 < 0) { vy0 = 0; }
  9. if (vx1 > ctl->xsize) { vx1 = ctl->xsize; }
  10. if (vy1 > ctl->ysize) { vy1 = ctl->ysize; }
  11. for (h = 0; h <= ctl->top; h++) {
  12. (中略)
  13. }
  14. return;
  15. }

这里不需要特别解释了吧,我们来“make run”。

2 实现画面外的支持(harib08b) - 图1

成功啦!

运行成功啦!只稍作修改就解决了问题,太厉害了。