Compare commits

...

3 Commits

Author SHA1 Message Date
Yourtion
2c7fd6f752 消除闪烁(1) 2016-04-15 11:20:53 +08:00
Yourtion
39e9bc34ea 高速计数器 2016-04-15 11:11:56 +08:00
Yourtion
2898207560 小实验 2016-04-15 11:06:26 +08:00
2 changed files with 20 additions and 15 deletions

View File

@@ -8,7 +8,7 @@ void HariMain(void)
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
char s[40], keybuf[32], mousebuf[128];
int mx, my, i;
unsigned int memtotal;
unsigned int memtotal, count = 0;
struct MOUSE_DEC mdec;
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
struct SHTCTL *shtctl;
@@ -37,15 +37,13 @@ void HariMain(void)
sht_mouse = sheet_alloc(shtctl);
sht_win = sheet_alloc(shtctl);
buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny);
buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 68);
buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52);
sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 没有透明色 */
sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /* 透明色号99 */
sheet_setbuf(sht_win, buf_win, 160, 68, -1); /* 没有透明色 */
sheet_setbuf(sht_win, buf_win, 160, 52, -1); /* 没有透明色 */
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
init_mouse_cursor8(buf_mouse, 99); /* 背景色号99 */
make_window8(buf_win, 160, 68, "window");
putfonts8_asc(buf_win, 160, 24, 28, COL8_000000, "Welcome to");
putfonts8_asc(buf_win, 160, 24, 44, COL8_000000, " Haribote-OS!");
make_window8(buf_win, 160, 52, "counter");
sheet_slide(sht_back, 0, 0);
mx = (binfo->scrnx - 16) / 2; /* 按显示在画面中央来计算坐标 */
my = (binfo->scrny - 28 - 16) / 2;
@@ -61,9 +59,15 @@ void HariMain(void)
sheet_refresh(sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */
for (;;) {
count++; /* 从这里开始 */
sprintf(s, "%010d", count);
boxfill8(buf_win, 160, COL8_C6C6C6, 40, 28, 119, 43);
putfonts8_asc(buf_win, 160, 40, 28, COL8_000000, s);
sheet_refresh(sht_win, 40, 28, 120, 44); /* 到这里结束 */
io_cli();
if (fifo8_status(&keyfifo) + fifo8_status(&mousefifo) == 0) {
io_stihlt();
io_sti(); /* 不做HLT */
} else {
if (fifo8_status(&keyfifo) != 0) {
i = fifo8_get(&keyfifo);

View File

@@ -69,6 +69,7 @@ void sheet_updown(struct SHEET *sht, int height)
ctl->sheets[h]->height = h;
}
ctl->sheets[height] = sht;
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1);
} else { /* 隐藏 */
if (ctl->top > old) {
/* 把上面的降下来 */
@@ -78,8 +79,8 @@ void sheet_updown(struct SHEET *sht, int height)
}
}
ctl->top--; /* 由于显示中的图层减少了一个,所以最上面的图层高度下降 */
}
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层的信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0);
}
} else if (old < height) { /* 比以前高 */
if (old >= 0) {
/* 把中间的拉下去 */
@@ -97,7 +98,7 @@ void sheet_updown(struct SHEET *sht, int height)
ctl->sheets[height] = sht;
ctl->top++; /* 由于已显示的图层增加了1个所以最上面的图层高度增加 */
}
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize); /* 按新图层信息重新绘制画面 */
sheet_refreshsub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height); /* 按新图层信息重新绘制画面 */
}
return;
}
@@ -105,12 +106,12 @@ void sheet_updown(struct SHEET *sht, int height)
void sheet_refresh(struct SHEET *sht, int bx0, int by0, int bx1, int by1)
{
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面*/
sheet_refreshsub(sht->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, sht->height);
}
return;
}
void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
void sheet_refreshsub(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, c, *vram = ctl->vram;
@@ -122,7 +123,7 @@ void sheet_refreshsub(struct SHTCTL *ctl, int vx0, int vy0, int vx1, int vy1)
if (vx1 > ctl->xsize) { vx1 = ctl->xsize; }
if (vy1 > ctl->ysize) { vy1 = ctl->ysize; }
for (h = 0; h <= ctl->top; h++) {
for (h = h0; h <= ctl->top; h++) {
sht = ctl->sheets[h];
buf = sht->buf;
/* 使用vx0vy1对bx0by1进行倒推 */
@@ -156,8 +157,8 @@ void sheet_slide(struct SHEET *sht, int vx0, int vy0)
sht->vx0 = vx0;
sht->vy0 = vy0;
if (sht->height >= 0) { /* 如果正在显示,则按新图层的信息刷新画面 */
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);
sheet_refreshsub(sht->ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0);
sheet_refreshsub(sht->ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height);
}
return;
}