mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-04 18:43:25 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b7a4a13b0 | ||
|
|
935af85346 | ||
|
|
d2fc0dc0f5 | ||
|
|
e4a94836dd |
@@ -124,7 +124,7 @@ void HariMain(void)
|
||||
|
||||
for (;;) {
|
||||
if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) {
|
||||
/* <EFBFBD>L<EFBFBD>[<5B>{<7B>[<5B>h<EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>ɑ<EFBFBD><C991><EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<CE81><41><EFBFBD><EFBFBD> */
|
||||
/* 如果存在向键盘控制器发送的数据,则发送它 */
|
||||
keycmd_wait = fifo32_get(&keycmd);
|
||||
wait_KBC_sendready();
|
||||
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
void keywin_off(struct SHEET *key_win);
|
||||
void keywin_on(struct SHEET *key_win);
|
||||
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
@@ -15,12 +16,12 @@ void HariMain(void)
|
||||
char s[40];
|
||||
struct FIFO32 fifo, keycmd;
|
||||
int fifobuf[128], keycmd_buf[32], *cons_fifo[2];
|
||||
int mx, my, i;
|
||||
int mx, my, i, new_mx = -1, new_my = 0, new_wx = 0x7fffffff, new_wy = 0;
|
||||
unsigned int memtotal;
|
||||
struct MOUSE_DEC mdec;
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
unsigned char *buf_back, buf_mouse[256], *buf_cons[2];
|
||||
struct SHEET *sht_back, *sht_mouse, *sht_cons[2];
|
||||
struct SHEET *sht_back, *sht_mouse;
|
||||
struct TASK *task_a, *task_cons[2], *task;
|
||||
static char keytable0[0x80] = {
|
||||
0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0x08, 0,
|
||||
@@ -76,29 +77,7 @@ void HariMain(void)
|
||||
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
|
||||
|
||||
/* sht_cons */
|
||||
for (i = 0; i < 2; i++) {
|
||||
sht_cons[i] = sheet_alloc(shtctl);
|
||||
buf_cons[i] = (unsigned char *) memman_alloc_4k(memman, 256 * 165);
|
||||
sheet_setbuf(sht_cons[i], buf_cons[i], 256, 165, -1); /*没有透明色*/
|
||||
make_window8(buf_cons[i], 256, 165, "console", 0);
|
||||
make_textbox8(sht_cons[i], 8, 28, 240, 128, COL8_000000);
|
||||
task_cons[i] = task_alloc();
|
||||
task_cons[i]->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 12;
|
||||
task_cons[i]->tss.eip = (int) &console_task;
|
||||
task_cons[i]->tss.es = 1 * 8;
|
||||
task_cons[i]->tss.cs = 2 * 8;
|
||||
task_cons[i]->tss.ss = 1 * 8;
|
||||
task_cons[i]->tss.ds = 1 * 8;
|
||||
task_cons[i]->tss.fs = 1 * 8;
|
||||
task_cons[i]->tss.gs = 1 * 8;
|
||||
*((int *) (task_cons[i]->tss.esp + 4)) = (int) sht_cons[i];
|
||||
*((int *) (task_cons[i]->tss.esp + 8)) = memtotal;
|
||||
task_run(task_cons[i], 2, 2); /* level=2, priority=2 */
|
||||
sht_cons[i]->task = task_cons[i];
|
||||
sht_cons[i]->flags |= 0x20; /*有光标*/
|
||||
cons_fifo[i] = (int *) memman_alloc_4k(memman, 128 * 4);
|
||||
fifo32_init(&task_cons[i]->fifo, 128, cons_fifo[i], task_cons[i]);
|
||||
}
|
||||
key_win = open_console(shtctl, memtotal);
|
||||
|
||||
/* sht_mouse */
|
||||
sht_mouse = sheet_alloc(shtctl);
|
||||
@@ -107,15 +86,12 @@ void HariMain(void)
|
||||
mx = (binfo->scrnx - 16) / 2; /* 计算坐标使其位于画面中央 */
|
||||
my = (binfo->scrny - 28 - 16) / 2;
|
||||
|
||||
sheet_slide(sht_back, 0, 0);
|
||||
sheet_slide(sht_cons[1], 56, 6);
|
||||
sheet_slide(sht_cons[0], 8, 2);
|
||||
sheet_slide(sht_back, 0, 0);
|
||||
sheet_slide(key_win, 32, 4);
|
||||
sheet_slide(sht_mouse, mx, my);
|
||||
sheet_updown(sht_back, 0);
|
||||
sheet_updown(sht_cons[1], 1);
|
||||
sheet_updown(sht_cons[0], 2);
|
||||
sheet_updown(sht_mouse, 3);
|
||||
key_win = sht_cons[0];
|
||||
sheet_updown(sht_back, 0);
|
||||
sheet_updown(key_win, 1);
|
||||
sheet_updown(sht_mouse, 2);
|
||||
keywin_on(key_win);
|
||||
|
||||
/*为了避免和键盘当前状态冲突,在一开始先进行设置*/
|
||||
@@ -124,15 +100,26 @@ void HariMain(void)
|
||||
|
||||
for (;;) {
|
||||
if (fifo32_status(&keycmd) > 0 && keycmd_wait < 0) {
|
||||
/* <EFBFBD>L<EFBFBD>[<5B>{<7B>[<5B>h<EFBFBD>R<EFBFBD><52><EFBFBD>g<EFBFBD><67><EFBFBD>[<5B><><EFBFBD>ɑ<EFBFBD><C991><EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<CE81><41><EFBFBD><EFBFBD> */
|
||||
/* 如果存在向键盘控制器发送的数据,则发送它 */
|
||||
keycmd_wait = fifo32_get(&keycmd);
|
||||
wait_KBC_sendready();
|
||||
io_out8(PORT_KEYDAT, keycmd_wait);
|
||||
}
|
||||
io_cli();
|
||||
if (fifo32_status(&fifo) == 0) {
|
||||
task_sleep(task_a);
|
||||
io_sti();
|
||||
/* FIFO为空,当存在搁置的绘图操作时立即执行*/
|
||||
if (new_mx >= 0) {
|
||||
io_sti();
|
||||
sheet_slide(sht_mouse, new_mx, new_my);
|
||||
new_mx = -1;
|
||||
} else if (new_wx != 0x7fffffff) {
|
||||
io_sti();
|
||||
sheet_slide(sht, new_wx, new_wy);
|
||||
new_wx = 0x7fffffff;
|
||||
} else {
|
||||
task_sleep(task_a);
|
||||
io_sti();
|
||||
}
|
||||
} else {
|
||||
i = fifo32_get(&fifo);
|
||||
io_sti();
|
||||
@@ -205,6 +192,13 @@ void HariMain(void)
|
||||
io_sti();
|
||||
}
|
||||
}
|
||||
if (i == 256 + 0x3c && key_shift != 0 ) { /* Shift+F2 */
|
||||
keywin_off(key_win);
|
||||
key_win = open_console(shtctl, memtotal);
|
||||
sheet_slide(key_win, 32, 4);
|
||||
sheet_updown(key_win, shtctl->top);
|
||||
keywin_on(key_win);
|
||||
}
|
||||
if (i == 256 + 0x57) { /* F11 */
|
||||
sheet_updown(shtctl->sheets[1], shtctl->top - 1);
|
||||
}
|
||||
@@ -232,7 +226,8 @@ void HariMain(void)
|
||||
if (my > binfo->scrny - 1) {
|
||||
my = binfo->scrny - 1;
|
||||
}
|
||||
sheet_slide(sht_mouse, mx, my);/* 包含sheet_refresh含sheet_refresh */
|
||||
new_mx = mx;
|
||||
new_my = my;
|
||||
if ((mdec.btn & 0x01) != 0) { /* 按下左键 */
|
||||
if (mmx < 0) {
|
||||
/*如果处于通常模式*/
|
||||
@@ -253,6 +248,7 @@ void HariMain(void)
|
||||
mmx = mx; /*进入窗口移动模式*/
|
||||
mmy = my;
|
||||
mmx2 = sht->vx0;
|
||||
new_wy = sht->vy0;
|
||||
}
|
||||
if (sht->bxsize - 21 <= x && x < sht->bxsize - 5 && 5 <= y && y < 19) {
|
||||
/*点击“×”按钮*/
|
||||
@@ -271,14 +267,19 @@ void HariMain(void)
|
||||
}
|
||||
} else {
|
||||
/*如果处于窗口移动模式*/
|
||||
x = mx - mmx; /*计算鼠标的移动距离*/
|
||||
x = mx - mmx; /*计算鼠标指针移动量*/
|
||||
y = my - mmy;
|
||||
sheet_slide(sht, (mmx2 + x + 2) & ~3, sht->vy0 + y);
|
||||
mmy = my; /*更新到移动后的坐标*/
|
||||
new_wx = (mmx2 + x + 2) & ~3;
|
||||
new_wy = new_wy + y;
|
||||
mmy = my;
|
||||
}
|
||||
} else {
|
||||
/*没有按下左键*/
|
||||
mmx = -1; /*返回通常模式*/
|
||||
mmx = -1; /*切换到一般模式*/
|
||||
if (new_wx != 0x7fffffff) {
|
||||
sheet_slide(sht, new_wx, new_wy); /*固定图层位置*/
|
||||
new_wx = 0x7fffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,3 +304,30 @@ void keywin_on(struct SHEET *key_win)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct SHEET *open_console(struct SHTCTL *shtctl, unsigned int memtotal)
|
||||
{
|
||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||
struct SHEET *sht = sheet_alloc(shtctl);
|
||||
unsigned char *buf = (unsigned char *) memman_alloc_4k(memman, 256 * 165);
|
||||
struct TASK *task = task_alloc();
|
||||
int *cons_fifo = (int *) memman_alloc_4k(memman, 128 * 4);
|
||||
sheet_setbuf(sht, buf, 256, 165, -1); /*无透明色*/
|
||||
make_window8(buf, 256, 165, "console", 0);
|
||||
make_textbox8(sht, 8, 28, 240, 128, COL8_000000);
|
||||
task->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 12;
|
||||
task->tss.eip = (int) &console_task;
|
||||
task->tss.es = 1 * 8;
|
||||
task->tss.cs = 2 * 8;
|
||||
task->tss.ss = 1 * 8;
|
||||
task->tss.ds = 1 * 8;
|
||||
task->tss.fs = 1 * 8;
|
||||
task->tss.gs = 1 * 8;
|
||||
*((int *) (task->tss.esp + 4)) = (int) sht;
|
||||
*((int *) (task->tss.esp + 8)) = memtotal;
|
||||
task_run(task, 2, 2); /* level=2, priority=2 */
|
||||
sht->task = task;
|
||||
sht->flags |= 0x20; /*有光标*/
|
||||
fifo32_init(&task->fifo, 128, cons_fifo, task);
|
||||
return sht;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user