mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-13 14:55:04 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
216f914b48 | ||
|
|
2b669176d8 |
@@ -9,12 +9,14 @@ void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, i
|
|||||||
void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
|
void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c);
|
||||||
void console_task(struct SHEET *sheet);
|
void console_task(struct SHEET *sheet);
|
||||||
|
|
||||||
|
#define KEYCMD_LED 0xed
|
||||||
|
|
||||||
void HariMain(void)
|
void HariMain(void)
|
||||||
{
|
{
|
||||||
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
|
||||||
struct FIFO32 fifo;
|
|
||||||
char s[40];
|
char s[40];
|
||||||
int fifobuf[128];
|
struct FIFO32 fifo, keycmd;
|
||||||
|
int fifobuf[128], keycmd_buf[32];
|
||||||
int mx, my, i, cursor_x, cursor_c;
|
int mx, my, i, cursor_x, cursor_c;
|
||||||
unsigned int memtotal;
|
unsigned int memtotal;
|
||||||
struct MOUSE_DEC mdec;
|
struct MOUSE_DEC mdec;
|
||||||
@@ -44,7 +46,7 @@ void HariMain(void)
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0
|
0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0
|
||||||
};
|
};
|
||||||
int key_to = 0, key_shift = 0;
|
int key_to = 0, key_shift = 0, key_leds = (binfo->leds >> 4) & 7, keycmd_wait = -1;
|
||||||
|
|
||||||
init_gdtidt();
|
init_gdtidt();
|
||||||
init_pic();
|
init_pic();
|
||||||
@@ -55,6 +57,7 @@ void HariMain(void)
|
|||||||
enable_mouse(&fifo, 512, &mdec);
|
enable_mouse(&fifo, 512, &mdec);
|
||||||
io_out8(PIC0_IMR, 0xf8); /* 设定PIT和PIC1以及键盘为许可(11111000) */
|
io_out8(PIC0_IMR, 0xf8); /* 设定PIT和PIC1以及键盘为许可(11111000) */
|
||||||
io_out8(PIC1_IMR, 0xef); /* 开放鼠标中断(11101111) */
|
io_out8(PIC1_IMR, 0xef); /* 开放鼠标中断(11101111) */
|
||||||
|
fifo32_init(&keycmd, 32, keycmd_buf, 0);
|
||||||
|
|
||||||
memtotal = memtest(0x00400000, 0xbfffffff);
|
memtotal = memtest(0x00400000, 0xbfffffff);
|
||||||
memman_init(memman);
|
memman_init(memman);
|
||||||
@@ -124,7 +127,17 @@ void HariMain(void)
|
|||||||
memtotal / (1024 * 1024), memman_total(memman) / 1024);
|
memtotal / (1024 * 1024), memman_total(memman) / 1024);
|
||||||
putfonts8_asc_sht(sht_back, 0, 32, COL8_FFFFFF, COL8_008484, s, 40);
|
putfonts8_asc_sht(sht_back, 0, 32, COL8_FFFFFF, COL8_008484, s, 40);
|
||||||
|
|
||||||
|
/*为了避免和键盘当前状态冲突,在一开始先进行设置*/
|
||||||
|
fifo32_put(&keycmd, KEYCMD_LED);
|
||||||
|
fifo32_put(&keycmd, key_leds);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) {
|
||||||
|
/*如果存在向键盘控制器发送的数据,则发送它 */
|
||||||
|
keycmd_wait = fifo32_get(&keycmd);
|
||||||
|
wait_KBC_sendready();
|
||||||
|
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||||
|
}
|
||||||
io_cli();
|
io_cli();
|
||||||
if (fifo32_status(&fifo) == 0) {
|
if (fifo32_status(&fifo) == 0) {
|
||||||
task_sleep(task_a);
|
task_sleep(task_a);
|
||||||
@@ -144,6 +157,11 @@ void HariMain(void)
|
|||||||
} else {
|
} else {
|
||||||
s[0] = 0;
|
s[0] = 0;
|
||||||
}
|
}
|
||||||
|
if ('A' <= s[0] && s[0] <= 'Z') { /*当输入字符为英文字母时*/
|
||||||
|
if (((key_leds & 4) == 0 && key_shift == 0) ||((key_leds & 4) != 0 && key_shift != 0)) {
|
||||||
|
s[0] += 0x20; /*将大写字母转换为小写字母*/
|
||||||
|
}
|
||||||
|
}
|
||||||
if (s[0] != 0) { /*一般字符*/
|
if (s[0] != 0) { /*一般字符*/
|
||||||
if (key_to == 0) { /*发送给任务A */
|
if (key_to == 0) { /*发送给任务A */
|
||||||
if (cursor_x < 128) {
|
if (cursor_x < 128) {
|
||||||
@@ -192,6 +210,28 @@ void HariMain(void)
|
|||||||
if (i == 256 + 0xb6) { /*右Shift OFF */
|
if (i == 256 + 0xb6) { /*右Shift OFF */
|
||||||
key_shift &= ~2;
|
key_shift &= ~2;
|
||||||
}
|
}
|
||||||
|
if (i == 256 + 0x3a) { /* CapsLock */
|
||||||
|
key_leds ^= 4;
|
||||||
|
fifo32_put(&keycmd, KEYCMD_LED);
|
||||||
|
fifo32_put(&keycmd, key_leds);
|
||||||
|
}
|
||||||
|
if (i == 256 + 0x45) { /* NumLock */
|
||||||
|
key_leds ^= 2;
|
||||||
|
fifo32_put(&keycmd, KEYCMD_LED);
|
||||||
|
fifo32_put(&keycmd, key_leds);
|
||||||
|
}
|
||||||
|
if (i == 256 + 0x46) { /* ScrollLock */
|
||||||
|
key_leds ^= 1;
|
||||||
|
fifo32_put(&keycmd, KEYCMD_LED);
|
||||||
|
fifo32_put(&keycmd, key_leds);
|
||||||
|
}
|
||||||
|
if (i == 256 + 0xfa) { /*键盘成功接收到数据*/
|
||||||
|
keycmd_wait = -1;
|
||||||
|
}
|
||||||
|
if (i == 256 + 0xfe) { /*键盘没有成功接收到数据*/
|
||||||
|
wait_KBC_sendready();
|
||||||
|
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||||
|
}
|
||||||
/*重新显示光标*/
|
/*重新显示光标*/
|
||||||
boxfill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
|
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);
|
sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44);
|
||||||
|
|||||||
Reference in New Issue
Block a user