Exemplo n.º 1
0
void console_task(struct SHEET *sheet, unsigned int memtotal)
{
	struct TIMER *timer;
	struct TASK *task = task_now();
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
	int i, fifobuf[128], *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
	struct CONSOLE cons;
	char cmdline[30];
	cons.sht = sheet;
	cons.cur_x =  8;
	cons.cur_y = 28;
	cons.cur_c = -1;
	*((int *) 0x0fec) = (int) &cons;

	fifo32_init(&task->fifo, 128, fifobuf, task);
	timer = timer_alloc();
	timer_init(timer, &task->fifo, 1);
	timer_settime(timer, 50);
	file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));

	/* プロンプト表示 */
	cons_putchar(&cons, '>', 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1) { /* カーソル用タイマ */
				if (i != 0) {
					timer_init(timer, &task->fifo, 0); /* 次は0を */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_FFFFFF;
					}
				} else {
					timer_init(timer, &task->fifo, 1); /* 次は1を */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_000000;
					}
				}
				timer_settime(timer, 50);
			}
			if (i == 2) {	/* カーソルON */
				cons.cur_c = COL8_FFFFFF;
			}
			if (i == 3) {	/* カーソルOFF */
				boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				cons.cur_c = -1;
			}
			if (256 <= i && i <= 511) { /* キーボードデータ(タスクA経由) */
				if (i == 8 + 256) {
					/* バックスペース */
					if (cons.cur_x > 16) {
						/* カーソルをスペースで消してから、カーソルを1つ戻す */
						cons_putchar(&cons, ' ', 0);
						cons.cur_x -= 8;
					}
				} else if (i == 10 + 256) {
					/* Enter */
					/* カーソルをスペースで消してから改行する */
					cons_putchar(&cons, ' ', 0);
					cmdline[cons.cur_x / 8 - 2] = 0;
					cons_newline(&cons);
					cons_runcmd(cmdline, &cons, fat, memtotal);	/* コマンド実行 */
					/* プロンプト表示 */
					cons_putchar(&cons, '>', 1);
				} else {
					/* 一般文字 */
					if (cons.cur_x < 240) {
						/* 一文字表示してから、カーソルを1つ進める */
						cmdline[cons.cur_x / 8 - 2] = i - 256;
						cons_putchar(&cons, i - 256, 1);
					}
				}
			}
			/* カーソル再表示 */
			if (cons.cur_c >= 0) {
				boxfill8(sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
			}
			sheet_refresh(sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
		}
	}
}
Exemplo n.º 2
0
void console_task(struct SHEET *sheet, unsigned int memtotal)
{
	int                 fifobuf[128];
	struct TASK         *task = task_now();
	struct TIMER        *timer;
	struct MEMMAN       *memman = (struct MEMMAN *) MEMMAN_ADDR;
	int                 *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
	struct CONSOLE      cons = {sheet, 8, 28, -1};
	int                 i;
	char                cmdline[30];
	*((int *) 0x0fec) = (int) &cons;

	fifo32_init(&task->fifo, 128, fifobuf, task);
	
	timer = timer_alloc();
	timer_init(timer, &task->fifo, 1);
	timer_settime(timer, 50);
	file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200)); // 将FAT展开到fat中

	/* 显示提示符 */
	cons_putchar(&cons, '>', 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1) {                                       /* 光标用定时器 */
				if (i != 0) {
					timer_init(timer, &task->fifo, 0);          /* 下次置0 */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_FFFFFF;
					}
				} else {
					timer_init(timer, &task->fifo, 1);          /* 下次置1 */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_000000;
					}
				}
				timer_settime(timer, 50);
			}
			// 光标ON、OFF功能用于窗口切换时
			if (i == 2) {                                       /* 光标ON */
				cons.cur_c = COL8_FFFFFF;
			}
			if (i == 3) {                                       /* 光标OFF */
				boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				cons.cur_c = -1;
			}
			if (256 <= i && i <= 511) {                         /* 键盘数据(通过任务A) */
				if (i == 8 + 256) {
					/* 退格键 */
					if (cons.cur_x > 16) {
						/* 用空白擦除光标后将光标前移一位 */
						cons_putchar(&cons, ' ', 0);
						cons.cur_x -= 8;
					}
				} else if (i == 10 + 256) {
					/* 回车键 */
					/* 将光标用空格擦除后换行 */
					cons_putchar(&cons, ' ', 0);
					cmdline[cons.cur_x / 8 - 2] = 0;
					cons_newline(&cons);
					cons_runcmd(cmdline, &cons, fat, memtotal); /* 运行命令 */
					/* 显示提示符 */
					cons_putchar(&cons, '>', 1);
				} else {
					/* 一般字符 */
					if (cons.cur_x < 240) {
						/* 显示一个字符之后将光标后移一位 */
						cmdline[cons.cur_x / 8 - 2] = i - 256;
						cons_putchar(&cons, i - 256, 1);
					}
				}
			}
			/* 重新显示光标 */
			if (cons.cur_c >= 0) {
				boxfill8(sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
			}
			sheet_refresh(sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
		}
	}
}
Exemplo n.º 3
0
void console_task(struct SHEET *sheet, int memtotal)
{
	struct TASK *task = task_now();
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
	int i, *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
	struct CONSOLE cons;
	struct FILEHANDLE fhandle[8];
	char cmdline[30];

	cons.sht = sheet;
	cons.cur_x =  8;
	cons.cur_y = 28;
	cons.cur_c = -1;
	task->cons = &cons;

	if (cons.sht != 0) {
		cons.timer = timer_alloc();
		timer_init(cons.timer, &task->fifo, 1);
		timer_settime(cons.timer, 50);
	}
	file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
	for (i = 0; i < 8; i++) {
		fhandle[i].buf = 0;	/* 未使用マーク */
	}
	task->fhandle = fhandle;
	task->fat = fat;

	/* プロンプト表示 */
	cons_putchar(&cons, '>', 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1 && cons.sht != 0) { /* カーソル用タイマ */
				if (i != 0) {
					timer_init(cons.timer, &task->fifo, 0); /* 次は0を */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_FFFFFF;
					}
				} else {
					timer_init(cons.timer, &task->fifo, 1); /* 次は1を */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_000000;
					}
				}
				timer_settime(cons.timer, 50);
			}
			if (i == 2) {	/* カーソルON */
				cons.cur_c = COL8_FFFFFF;
			}
			if (i == 3) {	/* カーソルOFF */
				if (cons.sht != 0) {
					boxfill8(cons.sht->buf, cons.sht->bxsize, COL8_000000,
						cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				}
				cons.cur_c = -1;
			}
			if (i == 4) {	/* コンソールの「×」ボタンクリック */
				cmd_exit(&cons, fat);
			}
			if (256 <= i && i <= 511) { /* キーボードデータ(タスクA経由) */
				if (i == 8 + 256) {
					/* バックスペース */
					if (cons.cur_x > 16) {
						/* カーソルをスペースで消してから、カーソルを1つ戻す */
						cons_putchar(&cons, ' ', 0);
						cons.cur_x -= 8;
					}
				} else if (i == 10 + 256) {
					/* Enter */
					/* カーソルをスペースで消してから改行する */
					cons_putchar(&cons, ' ', 0);
					cmdline[cons.cur_x / 8 - 2] = 0;
					cons_newline(&cons);
					cons_runcmd(cmdline, &cons, fat, memtotal);	/* コマンド実行 */
					if (cons.sht == 0) {
						cmd_exit(&cons, fat);
					}
					/* プロンプト表示 */
					cons_putchar(&cons, '>', 1);
				} else {
					/* 一般文字 */
					if (cons.cur_x < 240) {
						/* 一文字表示してから、カーソルを1つ進める */
						cmdline[cons.cur_x / 8 - 2] = i - 256;
						cons_putchar(&cons, i - 256, 1);
					}
				}
			}
			/* カーソル再表示 */
			if (cons.sht != 0) {
				if (cons.cur_c >= 0) {
					boxfill8(cons.sht->buf, cons.sht->bxsize, cons.cur_c, 
						cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				}
				sheet_refresh(cons.sht, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
			}
		}
	}
}
Exemplo n.º 4
0
void console_task (struct SHEET *sheet, unsigned int memtotal)
{
  struct TIMER *timer;
  struct TASK *task = task_now ();
  int i, fifobuf[128];
  char s[30], cmdline[30];
  struct MEMMAN *memman = (struct MEMMAN *)MEMMAN_ADDR;
  struct CONSOLE cons;

  cons.sht = sheet;
  cons.cur_x = 8;
  cons.cur_y = 28;
  cons.cur_c = -1;
  
  int *fat = (int *)memman_alloc_4k (memman, 4 * 2880);
  file_readfat (fat, (unsigned char *)(ADR_DISKIMG + 0x000200));
  
  fifo32_init (&task->fifo, 128, fifobuf, task);
  timer = timer_alloc ();
  timer_init (timer, &task->fifo, 1);
  timer_settime (timer, 50);

  cons_putchar (&cons, '>', 1);

  for (;;) {
    io_cli();
    if (fifo32_status (&task->fifo) == 0) {
      task_sleep(task);
      io_sti ();
    } else {
      i = fifo32_get (&task->fifo);
      io_sti ();
      if (i <= 1) {   /* timer for cursor */
        if (i != 0) {
          timer_init (timer, &task->fifo, 0);
          if (cons.cur_c >= 0) {
            cons.cur_c = COL8_FFFFFF;
          }
        } else {
          timer_init (timer, &task->fifo, 1);
          if (cons.cur_c >= 0) {
            cons.cur_c = COL8_000000;
          }
        }
        timer_settime (timer, 50);
	  }
      if (i == 2) { // Cursor ON
        cons.cur_c = COL8_FFFFFF;
      }
      if (i == 3) { // Cursor OFF
        boxfill8 (sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, 28, cons.cur_x + 7, 43);
        cons.cur_c = -1;
      }
	  if (256 <= i && i <= 511) {  /* Keyboard data from Task-A */
		if (i == 8 + 256) {
		  // Backspace
		  if (cons.cur_x > 16) {
			putfonts8_asc_sht(sheet, cons.cur_x, cons.cur_y, COL8_FFFFFF, COL8_000000, " ", 1);
			cons.cur_x -= 8;
		  }
		} else if (i == 10 + 256) {
		  // Enter
          cons_putchar (&cons, ' ', 0);
          putfonts8_asc_sht (sheet, cons.cur_x, cons.cur_y, COL8_FFFFFF, COL8_000000, " ", 1);
          cmdline[cons.cur_x / 8 - 2] = 0;
          cons_newline (&cons);
          // Execute Command
          cons_runcmd (cmdline, &cons, fat, memtotal);
          cons_putchar (&cons, '>', 1);
		} else {
		  // Normal charactor
		  if (cons.cur_x < 240) {
			s[0] = i - 256;
			s[1] = 0;
            cmdline[cons.cur_x / 8 - 2] = i - 256;
			putfonts8_asc_sht(sheet, cons.cur_x, cons.cur_y, COL8_FFFFFF, COL8_000000, s, 1);
			cons.cur_x += 8;
		  }
		}
	  }
      if (cons.cur_c >= 0) {
        boxfill8 (sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
      }
	  sheet_refresh (sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
    }
  }
}
Exemplo n.º 5
0
// sht: a sheet
void task_console(struct SHEET * sht,unsigned int memtotal)
{
//struct FIFO fifo;
struct TIMER *timer;
int i, fifobuf[128];
char s[30],cmdline[30];
struct CONSOLE cons;
cons.sht = sht;
cons.cur_x =  8;
cons.cur_y = 28;
cons.cur_c = -1;

struct MEMMAN * memman = (struct MEMMAN *) MEMMAN_ADDR;
int *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
* (int *) 0x0fec = (int) &cons;
int count=0;
struct TASK *task = task_now();
timer = timer_alloc();
timer_set(timer,50,&task->fifo,1);
fifo_init(&task->fifo,128,fifobuf,task);
cons_putchar(&cons, '$', 1);

for(;;)
{
	count++;
	io_cli();
	if(fifo_status(&task->fifo) == 0)
	{
		task_sleep(task);
		io_sti();
	}
	else
	{
	i = fifo_get(&task->fifo);
	io_sti();
	if(i <= 1)
	{	
		if(i== 1)
		{
			timer_set(timer,50,&task->fifo,0);
			if(cons.cur_c >= 0)
				cons.cur_c = COL8_FFFFFF;	
		}
		else
		{
			timer_set(timer,50,&task->fifo,1);
			if(cons.cur_c >= 0)
				cons.cur_c = COL8_000084;	
		}
		
	}
	if(i ==2 )
		cons.cur_c = COL8_FFFFFF;
	
	if(i ==3)    // cursor off
	{
		boxfill8(sht->buf,sht->bxsize, COL8_000084,cons.cur_x, cons.cur_y,cons.cur_x + 7, cons.cur_y+15);
		cons.cur_c = -1;
	}
	if (256 <= i && i <= 511)  // keyboard data
	{
				if(i == 8 + 256) 
				{  // backspace
					if (cons.cur_x >= 16) {
						cons_putchar(&cons, ' ', 0); // erase the cursor
						cons.cur_x -= 8;
					}
				} 
				else if(i == 10 + 256) {  // enter key
					cons_putchar(&cons, ' ', 0); // disable cursor
					cmdline[cons.cur_x/8 -2] = 0; // construct string
					cons_newline(&cons); // next line
					cons_runcmd(cmdline,&cons,fat,memtotal);
					cons_putchar(&cons, '$', 1);
					
				} 
						
				else // general character
				{
					
					if(cons.cur_x < 240) {
						cmdline[cons.cur_x/8 -2] = i-256;
						cons_putchar(&cons, i-256, 1);
					}
					//else
					//{
						//cons.cur_x = 16;
						//cons.cur_y +=16;
						//cmdline[cons.cur_x/8 -2] = i-256; // 16 starts char
						//cons_putchar(&cons, i-256, 1);
					//}
				}
	
	
	}
	if(cons.cur_c >= 0)
		boxfill8(sht->buf,sht->bxsize, cons.cur_c,cons.cur_x, cons.cur_y,cons.cur_x + 7, cons.cur_y+15);
	sheet_refresh(sht,cons.cur_x,cons.cur_y,cons.cur_x + 8, cons.cur_y + 16);
}
}
}
Exemplo n.º 6
0
void console_task(struct SHEET *sheet, unsigned int memtotal)
{
    struct TIMER *timer;
    struct TASK *task = task_now();
    struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
    int i, fifobuf[128], *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
    struct CONSOLE cons;
    char cmdline[30];
    cons.sht = sheet;
    cons.cur_x = 8;
    cons.cur_y = 28;
    cons.cur_c = -1;

    fifo32_init(&task->fifo, 128, fifobuf, task);
    timer = timer_alloc();
    timer_init(timer, &task->fifo, 1);
    timer_settime(timer, 50);
    file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));

    cons_putchar(&cons, '>', 1);

    for (;;) {
	io_cli();
	if (fifo32_status(&task->fifo) == 0) {
	    task_sleep(task);
	    io_sti();
	} else {
	    i = fifo32_get(&task->fifo);
	    io_sti();
	    if (i <= 1) {
		if (i != 0) {
		    timer_init(timer, &task->fifo, 0);
		    if (cons.cur_c >= 0) {
			cons.cur_c = COL8_FFFFFF;
		    }
		} else {
		    timer_init(timer, &task->fifo, 1);
		    if (cons.cur_c >= 0) {
			cons.cur_c = COL8_000000;
		    }
		}
		timer_settime(timer, 50);
	}
	if (i == 2) {
	   cons.cur_c = COL8_FFFFFF;
	}
	if (i == 3) {
	    boxfill8(sheet->buf, sheet->bxsize, COL8_000000, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
	    cons.cur_c = -1;
	}
	if (256 <= i && i <= 511) {
	   if (i == 8 + 256) {

	      if (cons.cur_x > 16) {
		
		cons_putchar(&cons, ' ', 0);
		cons.cur_x -= 8;
	      }
	   } else if (i == 10 + 256) {
	
	       cons_putchar(&cons, ' ', 0);
	       cmdline[cons.cur_x / 8 - 2] = 0;
	       cons_newline(&cons);
	       cons_runcmd(cmdline, &cons, fat, memtotal);

	       cons_putchar(&cons, '>', 1);
	   } else {
		
		if (cons.cur_x < 240) {

		   cmdline[cons.cur_x / 8 - 2] = i - 256;
		   cons_putchar(&cons, i - 256, 1);
		}
	   }
	}

	if (cons.cur_c >= 0) {
	   boxfill8(sheet->buf, sheet->bxsize, cons.cur_c, cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
	}
	sheet_refresh(sheet, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
     }
  }
}
Exemplo n.º 7
0
Arquivo: console.c Projeto: barmi/bxos
void console_task(struct SHEET *sheet, int memtotal)
{
	struct TASK *task = task_now();
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
	int i, *fat = (int *) memman_alloc_4k(memman, 4 * 2880);
	struct CONSOLE cons;
	struct FILEHANDLE fhandle[8];
	char cmdline[30];
	unsigned char *nihongo = (char *) *((int *) 0x0fe8);

	cons.sht = sheet;
	cons.cur_x =  8;
	cons.cur_y = 28;
	cons.cur_c = -1;
	task->cons = &cons;
	task->cmdline = cmdline;

	if (cons.sht != 0) {
		cons.timer = timer_alloc();
		timer_init(cons.timer, &task->fifo, 1);
		timer_settime(cons.timer, 50);
	}
	file_readfat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
	for (i = 0; i < 8; i++) {
		fhandle[i].buf = 0;	/* �̻�� ��ũ */
	}
	task->fhandle = fhandle;
	task->fat = fat;
	if (nihongo[4096] != 0xff) {	/* �Ϻ��� ��Ʈ ������ �о���� �� �־�����?  */
		task->langmode = 1;
	} else {
		task->langmode = 0;
	}
	task->langbyte1 = 0;

	/* prompt ǥ�� */
	cons_putchar(&cons, '>', 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1 && cons.sht != 0) { /* Ŀ���� Ÿ�̸� */
				if (i != 0) {
					timer_init(cons.timer, &task->fifo, 0); /* ������ 0�� */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_FFFFFF;
					}
				} else {
					timer_init(cons.timer, &task->fifo, 1); /* ������ 1�� */
					if (cons.cur_c >= 0) {
						cons.cur_c = COL8_000000;
					}
				}
				timer_settime(cons.timer, 50);
			}
			if (i == 2) {	/* Ŀ�� ON */
				cons.cur_c = COL8_FFFFFF;
			}
			if (i == 3) {	/* Ŀ�� OFF */
				if (cons.sht != 0) {
					boxfill8(cons.sht->buf, cons.sht->bxsize, COL8_000000,
						cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				}
				cons.cur_c = -1;
			}
			if (i == 4) {	/* �ܼ��� ��������ư Ŭ�� */
				cmd_exit(&cons, fat);
			}
			if (256 <= i && i <= 511) { /* Ű���� ������(�½�ũ A����) */
				if (i == 8 + 256) {
					/* �� �����̽� */
					if (cons.cur_x > 16) {
						/* �����̽��� ����� ���� Ŀ���� 1�� back */
						cons_putchar(&cons, ' ', 0);
						cons.cur_x -= 8;
					}
				} else if (i == 10 + 256) {
					/* Enter */
					/* �����̽��� ����� ���� �����Ѵ� */
					cons_putchar(&cons, ' ', 0);
					cmdline[cons.cur_x / 8 - 2] = 0;
					cons_newline(&cons);
					cons_runcmd(cmdline, &cons, fat, memtotal);	/* Ŀ�ǵ� ���� */
					if (cons.sht == 0) {
						cmd_exit(&cons, fat);
					}
					/* prompt ǥ�� */
					cons_putchar(&cons, '>', 1);
				} else {
					/* �Ϲ� ���� */
					if (cons.cur_x < 240) {
						/* �� ���� ǥ���ϰ� ����, Ŀ���� 1�� �����Ѵ� */
						cmdline[cons.cur_x / 8 - 2] = i - 256;
						cons_putchar(&cons, i - 256, 1);
					}
				}
			}
			/* Ŀ����ǥ�� */
			if (cons.sht != 0) {
				if (cons.cur_c >= 0) {
					boxfill8(cons.sht->buf, cons.sht->bxsize, cons.cur_c, 
						cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
				}
				sheet_refresh(cons.sht, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
			}
		}
	}
}