From cfde17cc0d4e89cd7870af34fb76a2a12d15b058 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Fri, 15 Apr 2016 10:55:11 +0800 Subject: [PATCH] =?UTF-8?q?shtctl=E7=9A=84=E6=8C=87=E5=AE=9A=E7=9C=81?= =?UTF-8?q?=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10_day/sheet.c | 2 +- 11_day/bootpack.c | 18 +++++++++--------- 11_day/bootpack.h | 9 +++++---- 11_day/sheet.c | 20 +++++++++++--------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/10_day/sheet.c b/10_day/sheet.c index e5bd624..717cbf5 100644 --- a/10_day/sheet.c +++ b/10_day/sheet.c @@ -15,7 +15,7 @@ struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize ctl->vram = vram; ctl->xsize = xsize; ctl->ysize = ysize; - ctl->top = -1; /* �V�[�g�͈ꖇ���Ȃ� */ + ctl->top = -1; /* 没有一张SHEET */ for (i = 0; i < MAX_SHEETS; i++) { ctl->sheets0[i].flags = 0; /* 标记为未使用 */ } diff --git a/11_day/bootpack.c b/11_day/bootpack.c index 76aa565..c7ad530 100644 --- a/11_day/bootpack.c +++ b/11_day/bootpack.c @@ -40,17 +40,17 @@ void HariMain(void) sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /* 透明色号99 */ init_screen8(buf_back, binfo->scrnx, binfo->scrny); init_mouse_cursor8(buf_mouse, 99); /* 背景色号99 */ - sheet_slide(shtctl, sht_back, 0, 0); + sheet_slide(sht_back, 0, 0); mx = (binfo->scrnx - 16) / 2; /* 按显示在画面中央来计算坐标 */ my = (binfo->scrny - 28 - 16) / 2; - sheet_slide(shtctl, sht_mouse, mx, my); - sheet_updown(shtctl, sht_back, 0); - sheet_updown(shtctl, sht_mouse, 1); + sheet_slide(sht_mouse, mx, my); + sheet_updown(sht_back, 0); + sheet_updown(sht_mouse, 1); sprintf(s, "(%3d, %3d)", mx, my); 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, sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */ + sheet_refresh(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, sht_back, 0, 16, 16, 32); /* 刷新文字 */ + sheet_refresh(sht_back, 0, 16, 16, 32); /* 刷新文字 */ } else if (fifo8_status(&mousefifo) != 0) { i = fifo8_get(&mousefifo); io_sti(); @@ -81,7 +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); /* 刷新文字 */ + sheet_refresh(sht_back, 32, 16, 32 + 15 * 8, 32); /* 刷新文字 */ /* 移动光标 */ mx += mdec.x; my += mdec.y; @@ -100,8 +100,8 @@ 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 */ + sheet_refresh(sht_back, 0, 0, 80, 16); /* 刷新文字 */ + sheet_slide(sht_mouse, mx, my); /* 包含sheet_refresh含sheet_refresh */ } } } diff --git a/11_day/bootpack.h b/11_day/bootpack.h index 7ac0cfe..041ffd6 100644 --- a/11_day/bootpack.h +++ b/11_day/bootpack.h @@ -149,6 +149,7 @@ int memman_free_4k(struct MEMMAN *man, unsigned int addr, unsigned int size); struct SHEET { unsigned char *buf; int bxsize, bysize, vx0, vy0, col_inv, height, flags; + struct SHTCTL *ctl; }; struct SHTCTL { @@ -161,7 +162,7 @@ struct SHTCTL { struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize, int ysize); 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, 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); +void sheet_updown(struct SHEET *sht, int height); +void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1); +void sheet_slide(struct SHEET *sht, int vx0, int vy0); +void sheet_free(struct SHEET *sht); diff --git a/11_day/sheet.c b/11_day/sheet.c index 2df8d99..22924d6 100644 --- a/11_day/sheet.c +++ b/11_day/sheet.c @@ -15,9 +15,10 @@ struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize ctl->vram = vram; ctl->xsize = xsize; ctl->ysize = ysize; - ctl->top = -1; /* �V�[�g�͈ꖇ���Ȃ� */ + ctl->top = -1; /* 没有一张SHEET */ for (i = 0; i < MAX_SHEETS; i++) { ctl->sheets0[i].flags = 0; /* 标记为未使用 */ + ctl->sheets0[i].ctl = ctl; /* 记录所属*/ } err: return ctl; @@ -47,8 +48,9 @@ void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, i return; } -void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height) +void sheet_updown(struct SHEET *sht, int height) { + struct SHTCTL *ctl = sht->ctl; int h, old = sht->height; /* 存储设置前的高度信息 */ if (height > ctl->top + 1) { height = ctl->top + 1; @@ -100,10 +102,10 @@ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height) return; } -void sheet_refresh(struct SHTCTL *ctl, struct SHEET *sht, int bx0, int by0, int bx1, int by1) +void sheet_refresh(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); + sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1); } return; } @@ -148,22 +150,22 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1) } -void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0) +void sheet_slide(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_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); + 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); } return; } -void sheet_free(struct SHTCTL *ctl, struct SHEET *sht) +void sheet_free(struct SHEET *sht) { if (sht->height >= 0) { - sheet_updown(ctl, sht, -1); /* 如果处于显示状态,则先设定为隐藏 */ + sheet_updown(sht, -1); /* 如果处于显示状态,则先设定为隐藏 */ } sht->flags = 0; /* "未使用"标志 */ return;