mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-03 01:53:24 +08:00
追记内容(1)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
void make_window8(unsigned char *buf, int xsize, int ysize, char *title);
|
||||
void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l);
|
||||
void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
@@ -13,7 +14,7 @@ void HariMain(void)
|
||||
char s[40];
|
||||
int fifobuf[128];
|
||||
struct TIMER *timer, *timer2, *timer3;
|
||||
int mx, my, i;
|
||||
int mx, my, i, cursor_x, cursor_c;
|
||||
unsigned int memtotal;
|
||||
struct MOUSE_DEC mdec;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
@@ -67,6 +68,9 @@ void HariMain(void)
|
||||
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
|
||||
init_mouse_cursor8(buf_mouse, 99); /* 背景色号99 */
|
||||
make_window8(buf_win, 160, 52, "window");
|
||||
make_textbox8(sht_win, 8, 28, 144, 16, COL8_FFFFFF);
|
||||
cursor_x = 8;
|
||||
cursor_c = COL8_FFFFFF;
|
||||
sheet_slide(sht_back, 0, 0);
|
||||
mx = (binfo->scrnx - 16) / 2; /* 按显示在画面中央来计算坐标 */
|
||||
my = (binfo->scrny - 28 - 16) / 2;
|
||||
@@ -84,20 +88,29 @@ void HariMain(void)
|
||||
for (;;) {
|
||||
io_cli();
|
||||
if (fifo32_status(&fifo) == 0) {
|
||||
io_sti();
|
||||
io_stihlt();
|
||||
} else {
|
||||
i = fifo32_get(&fifo);
|
||||
io_sti();
|
||||
if (256 <= i && i <= 511) { /* 键盘数据*/
|
||||
sprintf(s, "%02X", i - 256);
|
||||
putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2);
|
||||
if (i < 256 + 0x54) {
|
||||
if (keytable[i - 256] != 0) {
|
||||
if (i < 0x54 + 256) {
|
||||
if (keytable[i - 256] != 0 && cursor_x < 144) {
|
||||
s[0] = keytable[i - 256];
|
||||
s[1] = 0;
|
||||
putfonts8_asc_sht(sht_win, 40, 28, COL8_000000, COL8_C6C6C6, s, 1);
|
||||
putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, s, 1);
|
||||
cursor_x += 8;
|
||||
}
|
||||
}
|
||||
if (i == 256 + 0x0e && cursor_x > 8) { /* 退格键 */
|
||||
/* 用空格键把光标消去后,后移1次光标 */
|
||||
putfonts8_asc_sht(sht_win, cursor_x, 28, COL8_000000, COL8_FFFFFF, " ", 1);
|
||||
cursor_x -= 8;
|
||||
}
|
||||
/* 光标再显示 */
|
||||
boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
|
||||
sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44);
|
||||
} else if (512 <= i && i <= 767) { /* 鼠标数据*/
|
||||
if (mouse_decode(&mdec, i - 512) != 0) {
|
||||
/* 已经收集了3字节的数据,所以显示出来 */
|
||||
@@ -135,16 +148,17 @@ void HariMain(void)
|
||||
putfonts8_asc_sht(sht_back, 0, 64, COL8_FFFFFF, COL8_008484, "10[sec]", 7);
|
||||
} else if (i == 3) { /* 3秒定时器 */
|
||||
putfonts8_asc_sht(sht_back, 0, 80, COL8_FFFFFF, COL8_008484, "3[sec]", 6);
|
||||
} else if (i == 1) { /* 光标用定时器*/
|
||||
timer_init(timer3, &fifo, 0); /* 下面是设定0 */
|
||||
boxfill8(buf_back, binfo->scrnx, COL8_FFFFFF, 8, 96, 15, 111);
|
||||
} else if (i <= 1) { /* 光标用定时器*/
|
||||
if (i != 0) {
|
||||
timer_init(timer3, &fifo, 0); /* 下面设定0 */
|
||||
cursor_c = COL8_000000;
|
||||
} else {
|
||||
timer_init(timer3, &fifo, 1); /* 下面设定1 */
|
||||
cursor_c = COL8_FFFFFF;
|
||||
}
|
||||
timer_settime(timer3, 50);
|
||||
sheet_refresh(sht_back, 8, 96, 16, 112);
|
||||
} else if (i == 0) { /* 光标用定时器 */
|
||||
timer_init(timer3, &fifo, 1); /* 下面是设定1 */
|
||||
boxfill8(buf_back, binfo->scrnx, COL8_008484, 8, 96, 15, 111);
|
||||
timer_settime(timer3, 50);
|
||||
sheet_refresh(sht_back, 8, 96, 16, 112);
|
||||
boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
|
||||
sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,3 +220,18 @@ void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, i
|
||||
sheet_refresh(sht, x, y, x + l * 8, y + 16);
|
||||
return;
|
||||
}
|
||||
|
||||
void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c)
|
||||
{
|
||||
int x1 = x0 + sx, y1 = y0 + sy;
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 0, y1 + 1);
|
||||
boxfill8(sht->buf, sht->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 1, y1 + 1);
|
||||
boxfill8(sht->buf, sht->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user