mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-03 10:03:20 +08:00
创建命令行窗口
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act);
|
||||
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 task_b_main(struct SHEET *sht_win_b);
|
||||
void console_task(struct SHEET *sheet);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
@@ -27,9 +27,9 @@ void HariMain(void)
|
||||
0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1',
|
||||
'2', '3', '0', '.'
|
||||
};
|
||||
unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_win_b;
|
||||
struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_win_b[3];
|
||||
struct TASK *task_a, *task_b[3];
|
||||
unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_cons;
|
||||
struct SHEET *sht_back, *sht_mouse, *sht_win, *sht_cons;
|
||||
struct TASK *task_a, *task_cons;
|
||||
struct TIMER *timer;
|
||||
|
||||
init_gdtidt();
|
||||
@@ -59,29 +59,27 @@ void HariMain(void)
|
||||
sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1); /* 无透明色 */
|
||||
init_screen8(buf_back, binfo->scrnx, binfo->scrny);
|
||||
|
||||
/* sht_win_b */
|
||||
for (i = 0; i < 3; i++) {
|
||||
sht_win_b[i] = sheet_alloc(shtctl);
|
||||
buf_win_b = (unsigned char *) memman_alloc_4k(memman, 144 * 52);
|
||||
sheet_setbuf(sht_win_b[i], buf_win_b, 144, 52, -1); /* 无透明色 */
|
||||
sprintf(s, "task_b%d", i);
|
||||
make_window8(buf_win_b, 144, 52, s, 0);
|
||||
task_b[i] = task_alloc();
|
||||
task_b[i]->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 8;
|
||||
task_b[i]->tss.eip = (int) &task_b_main;
|
||||
task_b[i]->tss.es = 1 * 8;
|
||||
task_b[i]->tss.cs = 2 * 8;
|
||||
task_b[i]->tss.ss = 1 * 8;
|
||||
task_b[i]->tss.ds = 1 * 8;
|
||||
task_b[i]->tss.fs = 1 * 8;
|
||||
task_b[i]->tss.gs = 1 * 8;
|
||||
*((int *) (task_b[i]->tss.esp + 4)) = (int) sht_win_b[i];
|
||||
/* task_run(task_b[i], 2, i + 1); */
|
||||
}
|
||||
/* sht_cons */
|
||||
sht_cons = sheet_alloc(shtctl);
|
||||
buf_cons = (unsigned char *) memman_alloc_4k(memman, 256 * 165);
|
||||
sheet_setbuf(sht_cons, buf_cons, 256, 165, -1); /* 无透明色 */
|
||||
make_window8(buf_cons, 256, 165, "console", 0);
|
||||
make_textbox8(sht_cons, 8, 28, 240, 128, COL8_000000);
|
||||
task_cons = task_alloc();
|
||||
task_cons->tss.esp = memman_alloc_4k(memman, 64 * 1024) + 64 * 1024 - 8;
|
||||
task_cons->tss.eip = (int) &console_task;
|
||||
task_cons->tss.es = 1 * 8;
|
||||
task_cons->tss.cs = 2 * 8;
|
||||
task_cons->tss.ss = 1 * 8;
|
||||
task_cons->tss.ds = 1 * 8;
|
||||
task_cons->tss.fs = 1 * 8;
|
||||
task_cons->tss.gs = 1 * 8;
|
||||
*((int *) (task_cons->tss.esp + 4)) = (int) sht_cons;
|
||||
task_run(task_cons, 2, 2); /* level=2, priority=2 */
|
||||
|
||||
/* sht_win */
|
||||
sht_win = sheet_alloc(shtctl);
|
||||
buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52);
|
||||
sht_win = sheet_alloc(shtctl);
|
||||
buf_win = (unsigned char *) memman_alloc_4k(memman, 160 * 52);
|
||||
sheet_setbuf(sht_win, buf_win, 144, 52, -1); /* 无透明色 */
|
||||
make_window8(buf_win, 144, 52, "task_a", 1);
|
||||
make_textbox8(sht_win, 8, 28, 128, 16, COL8_FFFFFF);
|
||||
@@ -99,17 +97,13 @@ void HariMain(void)
|
||||
my = (binfo->scrny - 28 - 16) / 2;
|
||||
|
||||
sheet_slide(sht_back, 0, 0);
|
||||
sheet_slide(sht_win_b[0], 168, 56);
|
||||
sheet_slide(sht_win_b[1], 8, 116);
|
||||
sheet_slide(sht_win_b[2], 168, 116);
|
||||
sheet_slide(sht_win, 8, 56);
|
||||
sheet_slide(sht_cons, 32, 4);
|
||||
sheet_slide(sht_win, 64, 56);
|
||||
sheet_slide(sht_mouse, mx, my);
|
||||
sheet_updown(sht_back, 0);
|
||||
sheet_updown(sht_win_b[0], 1);
|
||||
sheet_updown(sht_win_b[1], 2);
|
||||
sheet_updown(sht_win_b[2], 3);
|
||||
sheet_updown(sht_win, 4);
|
||||
sheet_updown(sht_mouse, 5);
|
||||
sheet_updown(sht_back, 0);
|
||||
sheet_updown(sht_cons, 1);
|
||||
sheet_updown(sht_win, 2);
|
||||
sheet_updown(sht_mouse, 3);
|
||||
sprintf(s, "(%3d, %3d)", mx, my);
|
||||
putfonts8_asc_sht(sht_back, 0, 0, COL8_FFFFFF, COL8_008484, s, 10);
|
||||
sprintf(s, "memory %dMB free : %dKB",
|
||||
@@ -274,31 +268,37 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c)
|
||||
return;
|
||||
}
|
||||
|
||||
void task_b_main(struct SHEET *sht_win_b)
|
||||
void console_task(struct SHEET *sheet)
|
||||
{
|
||||
struct FIFO32 fifo;
|
||||
struct TIMER *timer_1s;
|
||||
int i, fifobuf[128], count = 0, count0 = 0;
|
||||
char s[12];
|
||||
struct TIMER *timer;
|
||||
struct TASK *task = task_now();
|
||||
|
||||
fifo32_init(&fifo, 128, fifobuf, 0);
|
||||
timer_1s = timer_alloc();
|
||||
timer_init(timer_1s, &fifo, 100);
|
||||
timer_settime(timer_1s, 100);
|
||||
int i, fifobuf[128], cursor_x = 8, cursor_c = COL8_000000;
|
||||
fifo32_init(&fifo, 128, fifobuf, task);
|
||||
timer = timer_alloc();
|
||||
timer_init(timer, &fifo, 1);
|
||||
timer_settime(timer, 50);
|
||||
|
||||
for (;;) {
|
||||
count++;
|
||||
io_cli();
|
||||
if (fifo32_status(&fifo) == 0) {
|
||||
task_sleep(task);
|
||||
io_sti();
|
||||
} else {
|
||||
i = fifo32_get(&fifo);
|
||||
io_sti();
|
||||
if (i == 100) {
|
||||
sprintf(s, "%11d", count - count0);
|
||||
putfonts8_asc_sht(sht_win_b, 24, 28, COL8_000000, COL8_C6C6C6, s, 11);
|
||||
count0 = count;
|
||||
timer_settime(timer_1s, 100);
|
||||
if (i <= 1) { /*光标用定时器*/
|
||||
if (i != 0) {
|
||||
timer_init(timer, &fifo, 0); /*下次置0 */
|
||||
cursor_c = COL8_FFFFFF;
|
||||
} else {
|
||||
timer_init(timer, &fifo, 1); /*下次置1 */
|
||||
cursor_c = COL8_000000;
|
||||
}
|
||||
timer_settime(timer, 50);
|
||||
boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
|
||||
sheet_refresh(sheet, cursor_x, 28, cursor_x + 8, 44);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user