Skip to content

Commit

Permalink
消除闪烁(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Apr 15, 2016
1 parent 39e9bc3 commit 2c7fd6f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions 11_day/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void sheet_updown(struct SHEET *sht, int height)
ctl->sheets[h]->height = h;
}
ctl->sheets[height] = sht;
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1);
} else { /* 隐藏 */
if (ctl->top > old) {
/* 把上面的降下来 */
Expand All @@ -78,8 +79,8 @@ void sheet_updown(struct SHEET *sht, int height)
}
}
ctl->top--; /* 由于显示中的图层减少了一个,所以最上面的图层高度下降 */
}
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层的信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0);
}
} else if (old < height) { /* 比以前高 */
if (old >= 0) {
/* 把中间的拉下去 */
Expand All @@ -97,20 +98,20 @@ void sheet_updown(struct SHEET *sht, int height)
ctl->sheets[height] = sht;
ctl->top++; /* 由于已显示的图层增加了1个,所以最上面的图层高度增加 */
}
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); /* 按新图层信息重新绘制画面 */
}
return;
}

void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1)
{
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面*/
sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1);
sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height);
}
return;
}

void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, int h0)
{
int h, bx, by, vx, vy, bx0, by0, bx1, by1;
unsigned char *buf, c, *vram = ctl->vram;
Expand All @@ -122,7 +123,7 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
if (vx1 > ctl->xsize) { vx1 = ctl->xsize; }
if (vy1 > ctl->ysize) { vy1 = ctl->ysize; }

for (h = 0; h <= ctl->top; h++) {
for (h = h0; h <= ctl->top; h++) {
sht = ctl->sheets[h];
buf = sht->buf;
/* 使用vx0~vy1,对bx0~by1进行倒推 */
Expand Down Expand Up @@ -156,8 +157,8 @@ void sheet_slide(struct SHEET *sht, int vx0, int vy0)
sht->vx0 = vx0;
sht->vy0 = vy0;
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面 */
sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize);
sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize);
sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0);
sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height);
}
return;
}
Expand Down

0 comments on commit 2c7fd6f

Please sign in to comment.