mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 02:53:19 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f53925b6f | ||
|
|
0cc548c0c2 |
@@ -6,16 +6,15 @@
|
||||
void HariMain(void)
|
||||
{
|
||||
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
||||
char s[40], mcursor[256], keybuf[32], mousebuf[128];
|
||||
char s[40], keybuf[32], mousebuf[128];
|
||||
int mx, my, i;
|
||||
unsigned int memtotal;
|
||||
struct MOUSE_DEC mdec;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
struct SHTCTL *shtctl;
|
||||
struct SHEET *sht_back, *sht_mouse;
|
||||
unsigned char *buf_back, buf_mouse[256];
|
||||
|
||||
unsigned int memtotal;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
|
||||
init_gdtidt();
|
||||
init_pic();
|
||||
io_sti(); /* IDT/PIC的初始化已经完成,于是开放CPU的中断 */
|
||||
@@ -34,9 +33,9 @@ void HariMain(void)
|
||||
|
||||
init_palette();
|
||||
shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny);
|
||||
sht_back = sheet_alloc(shtctl);
|
||||
sht_back = sheet_alloc(shtctl);
|
||||
sht_mouse = sheet_alloc(shtctl);
|
||||
buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny);
|
||||
buf_back = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny);
|
||||
sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 没有透明色 */
|
||||
sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); /* 透明色号99 */
|
||||
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
|
||||
@@ -45,13 +44,13 @@ void HariMain(void)
|
||||
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_back, 0);
|
||||
sheet_updown(shtctl, 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);
|
||||
sheet_refresh(shtctl, sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */
|
||||
|
||||
for (;;) {
|
||||
io_cli();
|
||||
@@ -62,9 +61,9 @@ void HariMain(void)
|
||||
i = fifo8_get(&keyfifo);
|
||||
io_sti();
|
||||
sprintf(s, "%02X", i);
|
||||
boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
|
||||
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();
|
||||
@@ -82,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;
|
||||
@@ -100,9 +100,10 @@ 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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user