Skip to content

Commit cfde17c

Browse files
committed
shtctl的指定省略
1 parent de008d0 commit cfde17c

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

10_day/sheet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize
1515
ctl->vram = vram;
1616
ctl->xsize = xsize;
1717
ctl->ysize = ysize;
18-
ctl->top = -1; /* �V�[�g�͈ꖇ���Ȃ� */
18+
ctl->top = -1; /* 没有一张SHEET */
1919
for (i = 0; i < MAX_SHEETS; i++) {
2020
ctl->sheets0[i].flags = 0; /* 标记为未使用 */
2121
}

11_day/bootpack.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ void HariMain(void)
4040
sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /* 透明色号99 */
4141
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
4242
init_mouse_cursor8(buf_mouse, 99); /* 背景色号99 */
43-
sheet_slide(shtctl, sht_back, 0, 0);
43+
sheet_slide(sht_back, 0, 0);
4444
mx = (binfo->scrnx - 16) / 2; /* 按显示在画面中央来计算坐标 */
4545
my = (binfo->scrny - 28 - 16) / 2;
46-
sheet_slide(shtctl, sht_mouse, mx, my);
47-
sheet_updown(shtctl, sht_back, 0);
48-
sheet_updown(shtctl, sht_mouse, 1);
46+
sheet_slide(sht_mouse, mx, my);
47+
sheet_updown(sht_back, 0);
48+
sheet_updown(sht_mouse, 1);
4949
sprintf(s, "(%3d, %3d)", mx, my);
5050
putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
5151
sprintf(s, "memory %dMB free : %dKB", memtotal / (1024 * 1024), memman_total(memman) / 1024);
5252
putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s);
53-
sheet_refresh(shtctl, sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */
53+
sheet_refresh(sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */
5454

5555
for (;;) {
5656
io_cli();
@@ -63,7 +63,7 @@ void HariMain(void)
6363
sprintf(s, "%02X", i);
6464
boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
6565
putfonts8_asc(buf_back, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
66-
sheet_refresh(shtctl, sht_back, 0, 16, 16, 32); /* 刷新文字 */
66+
sheet_refresh(sht_back, 0, 16, 16, 32); /* 刷新文字 */
6767
} else if (fifo8_status(&mousefifo) != 0) {
6868
i = fifo8_get(&mousefifo);
6969
io_sti();
@@ -81,7 +81,7 @@ void HariMain(void)
8181
}
8282
boxfill8(buf_back, binfo->scrnx, COL8_008484, 32, 16, 32 + 15 * 8 - 1, 31);
8383
putfonts8_asc(buf_back, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
84-
sheet_refresh(shtctl, sht_back, 32, 16, 32 + 15 * 8, 32); /* 刷新文字 */
84+
sheet_refresh(sht_back, 32, 16, 32 + 15 * 8, 32); /* 刷新文字 */
8585
/* 移动光标 */
8686
mx += mdec.x;
8787
my += mdec.y;
@@ -100,8 +100,8 @@ void HariMain(void)
100100
sprintf(s, "(%3d, %3d)", mx, my);
101101
boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 0, 79, 15); /* 消坐标 */
102102
putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s); /* 写坐标 */
103-
sheet_refresh(shtctl, sht_back, 0, 0, 80, 16); /* 刷新文字 */
104-
sheet_slide(shtctl, sht_mouse, mx, my); /* 包含sheet_refresh含sheet_refresh */
103+
sheet_refresh(sht_back, 0, 0, 80, 16); /* 刷新文字 */
104+
sheet_slide(sht_mouse, mx, my); /* 包含sheet_refresh含sheet_refresh */
105105
}
106106
}
107107
}

11_day/bootpack.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ int memman_free_4k(struct MEMMAN *man, unsigned int addr, unsigned int size);
149149
struct SHEET {
150150
unsigned char *buf;
151151
int bxsize, bysize, vx0, vy0, col_inv, height, flags;
152+
struct SHTCTL *ctl;
152153
};
153154

154155
struct SHTCTL {
@@ -161,7 +162,7 @@ struct SHTCTL {
161162
struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize, int ysize);
162163
struct SHEET *sheet_alloc(struct SHTCTL *ctl);
163164
void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, int col_inv);
164-
void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height);
165-
void sheet_refresh(struct SHTCTL *ctl, struct SHEET *sht, int bx0, int by0, int bx1, int by1);
166-
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0);
167-
void sheet_free(struct SHTCTL *ctl, struct SHEET *sht);
165+
void sheet_updown(struct SHEET *sht, int height);
166+
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1);
167+
void sheet_slide(struct SHEET *sht, int vx0, int vy0);
168+
void sheet_free(struct SHEET *sht);

11_day/sheet.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ struct SHTCTL *shtctl_init(struct MEMMAN *memman, unsigned char *vram, int xsize
1515
ctl->vram = vram;
1616
ctl->xsize = xsize;
1717
ctl->ysize = ysize;
18-
ctl->top = -1; /* �V�[�g�͈ꖇ���Ȃ� */
18+
ctl->top = -1; /* 没有一张SHEET */
1919
for (i = 0; i < MAX_SHEETS; i++) {
2020
ctl->sheets0[i].flags = 0; /* 标记为未使用 */
21+
ctl->sheets0[i].ctl = ctl; /* 记录所属*/
2122
}
2223
err:
2324
return ctl;
@@ -47,8 +48,9 @@ void sheet_setbuf(struct SHEET *sht, unsigned char *buf, int xsize, int ysize, i
4748
return;
4849
}
4950

50-
void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height)
51+
void sheet_updown(struct SHEET *sht, int height)
5152
{
53+
struct SHTCTL *ctl = sht->ctl;
5254
int h, old = sht->height; /* 存储设置前的高度信息 */
5355
if (height > ctl->top + 1) {
5456
height = ctl->top + 1;
@@ -100,10 +102,10 @@ void sheet_updown(struct SHTCTL *ctl, struct SHEET *sht, int height)
100102
return;
101103
}
102104

103-
void sheet_refresh(struct SHTCTL *ctl, struct SHEET *sht, int bx0, int by0, int bx1, int by1)
105+
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1)
104106
{
105107
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面*/
106-
sheet_refreshsub(ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1);
108+
sheet_refreshsub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1);
107109
}
108110
return;
109111
}
@@ -148,22 +150,22 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
148150
}
149151

150152

151-
void sheet_slide(struct SHTCTL *ctl, struct SHEET *sht, int vx0, int vy0)
153+
void sheet_slide(struct SHEET *sht, int vx0, int vy0)
152154
{
153155
int old_vx0 = sht->vx0, old_vy0 = sht->vy0;
154156
sht->vx0 = vx0;
155157
sht->vy0 = vy0;
156158
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面 */
157-
sheet_refreshsub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize);
158-
sheet_refreshsub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize);
159+
sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize);
160+
sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize);
159161
}
160162
return;
161163
}
162164

163-
void sheet_free(struct SHTCTL *ctl, struct SHEET *sht)
165+
void sheet_free(struct SHEET *sht)
164166
{
165167
if (sht->height >= 0) {
166-
sheet_updown(ctl, sht, -1); /* 如果处于显示状态,则先设定为隐藏 */
168+
sheet_updown(sht, -1); /* 如果处于显示状态,则先设定为隐藏 */
167169
}
168170
sht->flags = 0; /* "未使用"标志 */
169171
return;

0 commit comments

Comments
 (0)