From 4f53925b6ffc8433d9d69f2eefcb9999e95d2e2d Mon Sep 17 00:00:00 2001 From: Yourtion Date: Thu, 14 Apr 2016 13:40:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=AB=98=E5=8F=A0=E5=8A=A0=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=9F=E5=BA=A6=EF=BC=881=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10_day/bootpack.c | 6 ++++-- 10_day/bootpack.h | 2 +- 10_day/sheet.c | 28 ++++++++++++++++++++-------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/10_day/bootpack.c b/10_day/bootpack.c index 7be2727..933ec49 100644 --- a/10_day/bootpack.c +++ b/10_day/bootpack.c @@ -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(); @@ -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(); @@ -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; @@ -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 */ } } diff --git a/10_day/bootpack.h b/10_day/bootpack.h index e6a6809..7ac0cfe 100644 --- a/10_day/bootpack.h +++ b/10_day/bootpack.h @@ -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); diff --git a/10_day/sheet.c b/10_day/sheet.c index dd05ca9..92de442 100644 --- a/10_day/sheet.c +++ b/10_day/sheet.c @@ -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) { /* 把中间的拉下去 */ @@ -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; @@ -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; + } } } } @@ -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; }