From 0a166bc8c23f62f42e4db5059b915f139b078a9c Mon Sep 17 00:00:00 2001 From: Yourtion Date: Tue, 19 Apr 2016 12:01:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 12_day/sheet.c | 144 ++++++++++++++++++++++++------------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/12_day/sheet.c b/12_day/sheet.c index 102381d..add69cc 100644 --- a/12_day/sheet.c +++ b/12_day/sheet.c @@ -53,6 +53,78 @@ void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, i return; } +void sheet_refreshmap(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, sid, *map = ctl->map; + struct SHEET *sht; + 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 = h0; h <= ctl->top; h++) { + sht = ctl->sheets[h]; + sid = sht - ctl->sheets0; /* 将进行了减法计算的地址作为图层号码使用 */ + buf = sht->buf; + bx0 = vx0 - sht->vx0; + by0 = vy0 - sht->vy0; + bx1 = vx1 - sht->vx0; + by1 = vy1 - sht->vy0; + if (bx0 < 0) { bx0 = 0; } + if (by0 < 0) { by0 = 0; } + if (bx1 > sht->bxsize) { bx1 = sht->bxsize; } + if (by1 > sht->bysize) { by1 = sht->bysize; } + for (by = by0; by < by1; by++) { + vy = sht->vy0 + by; + for (bx = bx0; bx < bx1; bx++) { + vx = sht->vx0 + bx; + if (buf[by * sht->bxsize + bx] != sht->col_inv) { + map[vy * ctl->xsize + vx] = sid; + } + } + } + } + return; +} + +void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, int h0, int h1) +{ + int h, bx, by, vx, vy, bx0, by0, bx1, by1; + unsigned char *buf, *vram = ctl->vram, *map = ctl->map, sid; + 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 = h0; h <= h1; h++) { + sht = ctl->sheets[h]; + buf = sht->buf; + sid = sht - ctl->sheets0; + + /* 使用vx0~vy1,对bx0~by1进行倒推 */ + bx0 = vx0 - sht->vx0; + by0 = vy0 - sht->vy0; + bx1 = vx1 - sht->vx0; + by1 = vy1 - sht->vy0; + if (bx0 < 0) { bx0 = 0; } /* 处理刷新范围在图层外侧 */ + if (by0 < 0) { by0 = 0; } + if (bx1 > sht->bxsize) { bx1 = sht->bxsize; } /* 应对不同的重叠方式 */ + if (by1 > sht->bysize) { by1 = sht->bysize; } + for (by = by0; by < by1; by++) { + vy = sht->vy0 + by; + for (bx = bx0; bx < bx1; bx++) { + vx = sht->vx0 + bx; + if (map[vy * ctl->xsize + vx] == sid) { + vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx]; + } + } + } + } + return; +} + void sheet_updown(struct SHEET *sht, int height) { struct SHTCTL *ctl = sht->ctl; @@ -119,78 +191,6 @@ void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1) return; } -void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1, int h0, int h1) -{ - int h, bx, by, vx, vy, bx0, by0, bx1, by1; - unsigned char *buf, *vram = ctl->vram, *map = ctl->map, sid; - 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 = h0; h <= h1; h++) { - sht = ctl->sheets[h]; - buf = sht->buf; - sid = sht - ctl->sheets0; - - /* 使用vx0~vy1,对bx0~by1进行倒推 */ - bx0 = vx0 - sht->vx0; - by0 = vy0 - sht->vy0; - bx1 = vx1 - sht->vx0; - by1 = vy1 - sht->vy0; - if (bx0 < 0) { bx0 = 0; } /* 处理刷新范围在图层外侧 */ - if (by0 < 0) { by0 = 0; } - if (bx1 > sht->bxsize) { bx1 = sht->bxsize; } /* 应对不同的重叠方式 */ - if (by1 > sht->bysize) { by1 = sht->bysize; } - for (by = by0; by < by1; by++) { - vy = sht->vy0 + by; - for (bx = bx0; bx < bx1; bx++) { - vx = sht->vx0 + bx; - if (map[vy * ctl->xsize + vx] == sid) { - vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx]; - } - } - } - } - return; -} - -void sheet_refreshmap(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, sid, *map = ctl->map; - struct SHEET *sht; - 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 = h0; h <= ctl->top; h++) { - sht = ctl->sheets[h]; - sid = sht - ctl->sheets0; /* 将进行了减法计算的地址作为图层号码使用 */ - buf = sht->buf; - bx0 = vx0 - sht->vx0; - by0 = vy0 - sht->vy0; - bx1 = vx1 - sht->vx0; - by1 = vy1 - sht->vy0; - if (bx0 < 0) { bx0 = 0; } - if (by0 < 0) { by0 = 0; } - if (bx1 > sht->bxsize) { bx1 = sht->bxsize; } - if (by1 > sht->bysize) { by1 = sht->bysize; } - for (by = by0; by < by1; by++) { - vy = sht->vy0 + by; - for (bx = bx0; bx < bx1; bx++) { - vx = sht->vx0 + bx; - if (buf[by * sht->bxsize + bx] != sht->col_inv) { - map[vy * ctl->xsize + vx] = sid; - } - } - } - } - return; -} - void sheet_slide(struct SHEET *sht, int vx0, int vy0) { struct SHTCTL *ctl = sht->ctl;