Skip to content

Commit

Permalink
提高叠加处理速度(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Apr 14, 2016
1 parent 0cc548c commit 4f53925
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 4 additions & 2 deletions 10_day/bootpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void HariMain(void)
putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
sprintf(s, "memory %dMB free : %dKB", memtotal / (1024 * 1024), memman_total(memman) / 1024);
putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s);
sheet_refresh(shtctl);
sheet_refresh(shtctl, sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */

for (;;) {
io_cli();
Expand All @@ -63,7 +63,7 @@ void HariMain(void)
sprintf(s, "%02X", i);
boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
putfonts8_asc(buf_back, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
sheet_refresh(shtctl);
sheet_refresh(shtctl, sht_back, 0, 16, 16, 32); /* 刷新文字 */
} else if (fifo8_status(&mousefifo) != 0) {
i = fifo8_get(&mousefifo);
io_sti();
Expand All @@ -81,6 +81,7 @@ void HariMain(void)
}
boxfill8(buf_back, binfo->scrnx, COL8_008484, 32, 16, 32 + 15 * 8 - 1, 31);
putfonts8_asc(buf_back, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
sheet_refresh(shtctl, sht_back, 32, 16, 32 + 15 * 8, 32); /* 刷新文字 */
/* 移动光标 */
mx += mdec.x;
my += mdec.y;
Expand All @@ -99,6 +100,7 @@ void HariMain(void)
sprintf(s, "(%3d, %3d)", mx, my);
boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 0, 79, 15); /* 消坐标 */
putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s); /* 写坐标 */
sheet_refresh(shtctl, sht_back, 0, 0, 80, 16); /* 刷新文字 */
sheet_slide(shtctl, sht_mouse, mx, my); /* 包含sheet_refresh含sheet_refresh */
}
}
Expand Down
2 changes: 1 addition & 1 deletion 10_day/bootpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize
struct SHEET *sheet_alloc(struct SHTCTL *ctl);
void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, int col_inv);
void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height);
void sheet_refresh(struct SHTCTL *ctl);
void sheet_refresh(struct SHTCTL *ctl, struct SHEET *sht, int bx0, int by0, int bx1, int by1);
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0);
void sheet_free(struct SHTCTL *ctl, struct SHEET *sht);
28 changes: 20 additions & 8 deletions 10_day/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height)
}
ctl->top--; /* 由于显示中的图层减少了一个,所以最上面的图层高度下降 */
}
sheet_refresh(ctl); /* 按新图层的信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层的信息重新绘制画面 */
} else if (old < height) { /* 比以前高 */
if (old >= 0) {
/* 把中间的拉下去 */
Expand All @@ -95,12 +95,20 @@ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height)
ctl->sheets[height] = sht;
ctl->top++; /* 由于已显示的图层增加了1个,所以最上面的图层高度增加 */
}
sheet_refresh(ctl); /* 按新图层信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层信息重新绘制画面 */
}
return;
}

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

void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
{
int h, bx, by, vx, vy;
unsigned char *buf, c, *vram = ctl->vram;
Expand All @@ -112,9 +120,11 @@ void sheet_refresh(struct SHTCTL *ctl)
vy = sht->vy0 + by;
for (bx = 0; bx < sht->bxsize; bx++) {
vx = sht->vx0 + bx;
c = buf[by * sht->bxsize + bx];
if (c != sht->col_inv) {
vram[vy * ctl->xsize + vx] = c;
if (vx0 <= vx && vx < vx1 && vy0 <= vy && vy < vy1) {
c = buf[by * sht->bxsize + bx];
if (c != sht->col_inv) {
vram[vy * ctl->xsize + vx] = c;
}
}
}
}
Expand All @@ -124,10 +134,12 @@ void sheet_refresh(struct SHTCTL *ctl)

void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0)
{
int old_vx0 = sht->vx0, old_vy0 = sht->vy0;
sht->vx0 = vx0;
sht->vy0 = vy0;
if (sht->height >= 0) { /* 如果正在显示*/
sheet_refresh(ctl); /* 按新图层的信息刷新画面 */
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面 */
sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize);
sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize);
}
return;
}
Expand Down

0 comments on commit 4f53925

Please sign in to comment.