• R/O
  • SSH
  • HTTPS

nos: Commit


Commit MetaInfo

Révision368 (tree)
l'heure2009-10-28 16:04:25
Auteuruchan_nos

Message de Log

ソースコードの整理

Change Summary

Modification

--- bitnos5/trunk/kernel/console.cpp (revision 367)
+++ bitnos5/trunk/kernel/console.cpp (revision 368)
@@ -15,9 +15,8 @@
1515 #include <bitnos/memory.h>
1616 #include <bitnos/timer.h>
1717 #include <bitnos/specialtask.h>
18+#include <bitnos/pit.h>
1819
19-#define REFRESH_METHOD 0
20-
2120 namespace TaskConsole
2221 {
2322
@@ -142,53 +141,86 @@
142141 void ShowCursor(Valiables* o);
143142 void EraseCursor(Valiables* o);
144143
145-void WriteBuffer(Valiables* o, int x, int y, char ch);
146-char ReadBuffer(Valiables* o, int x, int y);
144+void ConsoleMakeBorderLine(Image* img);
147145
146+/*
147+ * コンソールコマンド関数
148+ */
149+class ConsoleCommands
150+{
151+public:
152+ static void mem(Valiables* o, const char* arg);
153+ static void opencons(Valiables* o, const char* arg);
154+ static void echo(Valiables* o, const char* arg);
155+ static void beep(Valiables* o, const char* arg);
156+ static void eco(Valiables* o, const char* arg);
157+ static void cat(Valiables* o, const char* arg);
158+};
159+
160+const uint32_t TIMERDATA_CURSOR = 1;
161+const uint32_t TIMERDATA_BEEP = 2;
162+
148163 void Init(void* obj)
149164 {
165+ static int initialPosX = 110, initialPosY = 50;
166+
150167 Valiables* o = (Valiables*)obj;
151168
152169 Task* task = taskman->GetCurrentTask();
153170
154- Debug::WriteLine("Console Init");
155171
156- //o->cons.height = 10;
172+ // コンソールの大きさ設定
157173 o->cons.height = 12;
158- // o->cons.width = 29;
159174 o->cons.width = 34;
160- //o->cons.bufHeight = 40;
161- //o->cons.bufWidth = 29;
162- o->cons.bufWidth = o->cons.width;
163- o->cons.buf = new char[o->cons.bufHeight * o->cons.bufWidth];
164- o->cons.startLine = o->cons.endLine = 0;
165- o->cons.xPos = 0;
166- o->cons.printYPos = 0;
175+
176+ // コンソールの色設定
167177 o->cons.backColor = ConvRGB16(0, 0, 0);
168- o->cons.textColor = ConvRGB16(255, 255, 255);
178+ o->cons.textColor = ConvRGB16(0xD0, 0xD0, 0xD0);
179+
180+ // 各種初期化
169181 o->cmdlineBegin = 0;
170182 o->cursor = false;
183+
184+ // コンソール画面がアクティブかどうか
171185 o->active = SpecialTask::Get(SpecialTask::Active) == task;
172186
187+ // 文字列バッファの準備
173188 o->cons.sbuf.Init(o->cons.width, 20);
189+
190+ // バッファ内の書き込み位置
174191 o->cons.wPos = Point(0, 0);
192+
193+ // 画面内の表示位置
175194 o->cons.pPos = Point(0, 0);
176195
196+ // 画面のバッファ
177197 o->img = new Image(
178198 8 + fontHankaku->GetWidth() * o->cons.width,
179199 25 + 8 + fontHankaku->GetHeight() * o->cons.height);
180200 Window::Make(o->img);
181201 o->img->DrawRectangleFill(
182- o->cons.backColor, Point(0, 25), Point(o->img->width - 1, o->img->height - 1));
202+ o->cons.backColor, Point(0, 25), Point(o->img->GetWidth() - 1, o->img->GetHeight() - 1));
203+ ConsoleMakeBorderLine(o->img);
204+
183205 o->sht = shtman->Alloc();
184- o->sht->Init(o->img, Sheet::NoInvColor, Point(200, 50));
206+ o->sht->Init(o->img, Sheet::NoInvColor, Point(initialPosX, initialPosY));
185207 o->sht->SetParentTask(task);
186208 shtman->SetHeight(o->sht, 0, Sheet::Normal);
187209
188- o->tim = timman->Alloc(task, 1);
210+ // コンソールを開くごとに位置が変わるようにした。
211+ if (initialPosX < o->img->GetWidth() - 50 && initialPosY < o->img->GetHeight() - 50) {
212+ initialPosX += 20;
213+ initialPosY += 20;
214+ } else {
215+ initialPosX = 110;
216+ initialPosY = 50;
217+ }
218+
219+
220+ o->tim = timman->Alloc(task, TIMERDATA_CURSOR);
189221 o->tim->SetTime(80);
190222
191- o->timBeep = timman->Alloc(task, 2);
223+ o->timBeep = timman->Alloc(task, TIMERDATA_BEEP);
192224
193225 PutChar0(o, '>');
194226 }
@@ -208,7 +240,7 @@
208240 }
209241 }
210242 } else if (msg->from == Message::From::Timer) {
211- if (msg->arg1 == 1) {
243+ if (msg->arg1 == TIMERDATA_CURSOR) {
212244 if (o->active) {
213245 o->tim->SetTime(70);
214246 if (o->cursor) {
@@ -219,12 +251,8 @@
219251 o->cursor = true;
220252 }
221253 }
222- } else if (msg->arg1 == 2) {
223- uint8_t reg = io_in8(0x0061);
224- //reg |= 0x03;
225- //reg &= 0x0f;
226- reg &= 0x0d;
227- io_out8(0x0061, reg);
254+ } else if (msg->arg1 == TIMERDATA_BEEP) {
255+ PIT::BeepOff();
228256 }
229257 } else if (msg->from == Message::From::System) {
230258 if (msg->arg1 == Message::System::WindowActivated) {
@@ -246,119 +274,17 @@
246274 o->cons.sbuf.Scroll(1);
247275 o->cons.sbuf.Write(Point(0, o->cons.sbuf.GetHeight() - 1), '\0');
248276 o->cmdlineBegin--;
249-
250-
251277 }
252278 o->cons.wPos.X = 0;
253279 o->cons.pPos.X = 0;
254280 if (o->cons.pPos.Y < o->cons.height - 1) {
255281 o->cons.pPos.Y++;
256- } else {
257-#if REFRESH_METHOD == 1
258- Point posTo(4, 25 + 4);
259- Point posFrom(4, 25 + 4 + fontHankaku->GetHeight());
260- uint16_t* ptrTo;
261- uint16_t* ptrFrom;
262- //uint32_t* ptrTo;
263- //uint32_t* ptrFrom;
264- for (int y = 4; y < o->img->GetHeight() - 25 - fontHankaku->GetHeight(); y++) {
265- ptrTo = o->img->buf + posTo.Y * o->img->GetWidth() + 4;
266- ptrFrom = o->img->buf + posFrom.Y * o->img->GetWidth() + 4;
267- //ptrTo = (uint32_t*)(o->img->buf + posTo.Y * o->img->GetWidth() + 4);
268- //ptrFrom = (uint32_t*)(o->img->buf + posFrom.Y * o->img->GetWidth() + 4);
269-
270- //for (posFrom.X = 4, posTo.X = 4; posFrom.X < o->img->width - 4; posFrom.X++, posTo.X++) {
271- for (posFrom.X = 4; posFrom.X < o->img->width - 4; posFrom.X++) {
272- //o->img->DrawPoint(o->img->GetPoint(posFrom), posTo);
273- *ptrTo++ = *ptrFrom++;
274- }
275- posTo.Y++;
276- posFrom.Y++;
277-
278- }
279- posTo.X = 0;
280- o->img->DrawRectangleFill(
281- o->cons.backColor, posTo, Point(o->img->GetWidth() - 1, o->img->GetHeight() - 1));
282-
283- o->sht->Refresh();
284-#endif
285282 }
286283 }
287284
288285 void PutChar0(Valiables* o, char ch)
289286 {
290-#if 0
291- // バッファに格納
292287 if (0x20 <= ch && ch < 0x80) {
293- //o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = ch;
294- WriteBuffer(o, o->cons.xPos, o->cons.endLine, ch);
295- o->cons.xPos++;
296- }
297- if (ch == '\b') {
298- if (o->cons.endLine != o->cmdlineBegin) {
299- o->cons.xPos--;
300- if (o->cons.xPos < 0) {
301- o->cons.xPos = o->cons.bufWidth - 1;
302- o->cons.endLine--;
303- if (o->cons.endLine < 0) {
304- o->cons.endLine = o->cons.height - 1;
305- }
306- if (o->cons.printYPos > 0) {
307- o->cons.printYPos--;
308- }
309- }
310- } else if (o->cons.endLine == o->cmdlineBegin && o->cons.xPos > 1) {
311- o->cons.xPos--;
312- }
313- //o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = '\0';
314- WriteBuffer(o, o->cons.xPos, o->cons.endLine, '\0');
315- // 1文字だけ消去する
316- o->sht->DrawRectangleFill(
317- o->cons.backColor,
318- Point(
319- 4 + fontHankaku->GetWidth() * o->cons.xPos,
320- 25 + 4 + fontHankaku->GetHeight() * o->cons.printYPos),
321- Point(
322- 4 + fontHankaku->GetWidth() * (o->cons.xPos + 1) - 1,
323- 25 + 4 + fontHankaku->GetHeight() * (o->cons.printYPos + 1) - 1)
324- );
325- } else if (o->cons.bufWidth <= o->cons.xPos || ch == '\n') {
326- // バッファの右端まで行った、またはエンターキーが押されたから改行
327- if (o->cons.xPos < o->cons.bufWidth - 1) {
328- //o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = '\0';]
329- WriteBuffer(o, o->cons.xPos, o->cons.endLine, '\0');
330- }
331- if (o->cons.printYPos < o->cons.height - 1) {
332- o->cons.printYPos++;
333- }
334- o->cons.xPos = 0;
335- o->cons.endLine++;
336- if (o->cons.endLine == o->cons.bufHeight) {
337- o->cons.endLine = 0;
338- }
339- if (o->cons.endLine == o->cons.startLine) {
340- memset(o->cons.buf + o->cons.endLine * o->cons.bufWidth, '\0', o->cons.bufWidth);
341- o->cons.startLine++;
342- if (o->cons.startLine == o->cons.bufHeight) {
343- o->cons.startLine = 0;
344- }
345- }
346- Debug::WriteLine("start=%d,end=%d", o->cons.startLine, o->cons.endLine);
347- // 画面全体を描画しなおす
348- ConsoleRefreshScreen(o, o->cons.endLine - o->cons.height + 1);
349- } else {
350- // 改行しなかった
351- // 1文字だけ描画する
352- o->sht->DrawChar(
353- o->cons.textColor,
354- ch,
355- Point(
356- 4 + fontHankaku->GetWidth() * (o->cons.xPos - 1),
357- 25 + 4 + fontHankaku->GetHeight() * o->cons.printYPos),
358- fontHankaku);
359- }
360-#endif
361- if (0x20 <= ch && ch < 0x80) {
362288 o->cons.sbuf.Write(o->cons.wPos, ch);
363289 o->cons.wPos.X++;
364290 if (o->cons.pPos.X < o->cons.width - 1) {
@@ -394,11 +320,9 @@
394320 int pposy = o->cons.pPos.Y;
395321 NewLine(o);
396322
397-#if REFRESH_METHOD == 0
398323 if (pposy == o->cons.pPos.Y) {
399324 ConsoleRefreshScreen(o, -1);
400325 }
401-#endif
402326
403327 } else {
404328 o->sht->DrawChar(
@@ -413,105 +337,10 @@
413337
414338 void PutChar(Valiables* o, char ch)
415339 {
416-#if 0
417- // バッファに格納
418- if (0x20 <= ch && ch < 0x80) {
419- o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = ch;
420- o->cons.xPos++;
421- }
422- if (ch == '\b') {
423- if (o->cons.xPos > 0) {
424- o->cons.xPos--;
425- }
426- o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = '\0';
427- // 1文字だけ消去する
428- int end = o->cons.endLine;
429- if (end >= o->cons.height) {
430- end = o->cons.height - 1;
431- }
432- o->sht->DrawRectangleFill(
433- o->cons.backColor,
434- Point(
435- 4 + fontHankaku->GetWidth() * o->cons.xPos,
436- 25 + 4 + fontHankaku->GetHeight() * end),
437- Point(
438- 4 + fontHankaku->GetWidth() * (o->cons.xPos + 1) - 1,
439- 25 + 4 + fontHankaku->GetHeight() * (end + 1) - 1)
440- );
441- } else if (o->cons.bufWidth <= o->cons.xPos || ch == '\n') {
442- // バッファの右端まで行った、またはエンターキーが押されたから改行
443- if (o->cons.xPos < o->cons.bufWidth - 1) {
444- o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = '\0';
445- }
446- o->cons.xPos = 0;
447- o->cons.endLine++;
448- if (o->cons.endLine == o->cons.startLine) {
449- o->cons.startLine++;
450- }
451- if (ch == '\n') {
452- // コマンドラインを取得
453- int i = 0;
454- char c;
455- for (int line = o->cmdlineBegin, x = 1; line != o->cons.endLine; line++) {
456- if (line == o->cons.bufHeight) {
457- line = 0;
458- }
459- for (; x < o->cons.bufWidth && (c = o->cons.buf[o->cons.bufWidth * line + x]) != '\0'; x++) {
460- o->cmdline[i++] = c;
461- }
462- x = 0;
463- }
464- o->cmdline[i] = '\0';
465- o->cmdlineBegin = o->cons.endLine;
466- RunCommand(o);
467- o->cons.buf[o->cons.bufWidth * o->cons.endLine + o->cons.xPos] = '>';
468- o->cons.xPos++;
469- }
470- // 画面全体を描画しなおす
471- ConsoleRefreshScreen(o, o->cons.endLine - o->cons.height + 1);
472- } else {
473- // 改行しなかった
474- int end = o->cons.endLine;
475- if (end >= o->cons.height) {
476- end = o->cons.height - 1;
477- }
478- // 1文字だけ描画する
479- o->sht->DrawChar(
480- o->cons.textColor,
481- ch,
482- Point(
483- 4 + fontHankaku->GetWidth() * (o->cons.xPos - 1),
484- 25 + 4 + fontHankaku->GetHeight() * end),
485- fontHankaku);
486- }
487-#endif
488340 PutChar0(o, ch);
489-#if 0
490341 if (ch == '\n') {
491- // コマンドラインを取得
492342 int i = 0;
493343 char c;
494- for (int line = o->cmdlineBegin, x = 1; line != o->cons.endLine; line++) {
495- if (line == o->cons.bufHeight) {
496- line = 0;
497- }
498- for (; x < o->cons.bufWidth && (c = o->cons.buf[o->cons.bufWidth * line + x]) != '\0'; x++) {
499- o->cmdline[i++] = c;
500- }
501- x = 0;
502- }
503- o->cmdline[i] = '\0';
504-
505- //Debug::WriteLine(o->cmdline);
506- RunCommand(o);
507-
508- o->cmdlineBegin = o->cons.endLine;
509- PutChar0(o, '>');
510- }
511-#endif
512- if (ch == '\n') {
513- int i = 0;
514- char c;
515344 for (int line = o->cmdlineBegin, x = 1; line <= o->cons.wPos.Y; line++) {
516345 for (; (c = o->cons.sbuf.Read(Point(x, line))) != '\0'; x++) {
517346 o->cmdline[i++] = c;
@@ -544,61 +373,8 @@
544373
545374 void ConsoleRefreshScreen(Valiables* o, int begin)
546375 {
547-#if 0
548- int lines = o->cons.height;
549376 if (begin < 0) {
550377 // 自動計算モード
551- lines = o->cons.endLine - o->cons.startLine + 1;
552- if (lines <= 0) {
553- /*
554- * bufの状態が
555- * ...
556- * endLine
557- * ...
558- * startLine
559- * ...
560- * のようになっているとき
561- */
562- lines += o->cons.bufHeight;
563- }
564- if (lines <= o->cons.height) {
565- begin = o->cons.startLine;
566- } else {
567- lines = o->cons.height;
568- begin = o->cons.endLine - o->cons.height + 1;
569- if (begin < 0) {
570- begin += o->cons.bufHeight;
571- }
572- }
573- }
574- o->img->DrawRectangleFill(
575- o->cons.backColor, Point(0, 25), Point(o->img->width - 1, o->img->height - 1));
576- int line = begin;
577- Debug::WriteLine("refreshing l=%d,ls=%d", line, lines);
578- for (int y = 0; y < lines; y++) {
579- for (int x = 0; x < o->cons.width; x++) {
580- //char ch = o->cons.buf[line * o->cons.bufWidth + x];
581- char ch = ReadBuffer(o, x, line);
582- if (ch == '\0') {
583- break;
584- }
585- o->img->DrawChar(
586- o->cons.textColor,
587- ch,
588- Point(4 + x * fontHankaku->GetWidth(), 25 + 4 + y * fontHankaku->GetHeight()),
589- fontHankaku);
590- }
591- line++;
592- if (line == o->cons.bufHeight) {
593- line = 0;
594- }
595- if (line == o->cons.startLine) {
596- break;
597- }
598- }
599- o->sht->Refresh();
600-#endif
601- if (begin < 0) {
602378 begin = o->cons.wPos.Y - o->cons.height + 1;
603379 if (begin < 0) {
604380 begin = 0;
@@ -605,27 +381,11 @@
605381 }
606382 }
607383
608- /*
609- int beginOld = begin - 1;
610- if (beginOld < 0) {
611- beginOld = 0;
612- }
613- */
614-
384+ // 画面全消去
615385 o->img->DrawRectangleFill(
616386 o->cons.backColor, Point(4, 25 + 4), Point(o->img->GetWidth() - 1 - 4, o->img->GetHeight() - 1 - 4));
617387
618-/*
619- for (int lines = 0; beginOld + lines <= o->cons.sbuf.GetHeight() && lines < o->cons.height; lines++) {
620- o->img->DrawString(
621- ConvRGB16(127, 127, 127),
622- o->cons.sbuf.GetPointer(Point(0, beginOld + lines)),
623- Point(4, 25 + 4 + lines * fontHankaku->GetHeight()),
624- fontHankaku);
625- }
626- */
627-
628-
388+ // 文字列描画
629389 for (int lines = 0; begin + lines <= o->cons.sbuf.GetHeight() && lines < o->cons.height; lines++) {
630390 o->img->DrawString(
631391 o->cons.textColor,
@@ -638,7 +398,6 @@
638398
639399 void RunCommand(Valiables* o)
640400 {
641- char s[256];
642401 char* command = o->cmdline;
643402 char* args;
644403 int i = 0;
@@ -654,79 +413,17 @@
654413 }
655414 args = command + i;
656415 if (strncmp(command, "mem", 4) == 0) {
657- PutString0(o, "mem : ");
658- sprintf(s, "%10d", physicalMemorySize);
659- if ((physicalMemorySize >> 30) != 0) {
660- PutString0(o, s + 0, 1);
661- PutChar0(o, ',');
662- }
663- if ((physicalMemorySize >> 20) != 0) {
664- PutString0(o, s + 1, 3);
665- PutChar0(o, ',');
666- }
667- if ((physicalMemorySize >> 10) != 0) {
668- PutString0(o, s + 4, 3);
669- PutChar0(o, ',');
670- }
671- PutString0(o, s + 7, 3);
672- PutString0(o, " B\n");
673-
674- uint32_t freeSize = memman.GetFreeSize();
675- PutString0(o, "free : ");
676- sprintf(s, "%10d", freeSize);
677- if ((freeSize >> 30) != 0) {
678- PutString0(o, s + 0, 1);
679- PutChar0(o, ',');
680- }
681- if ((freeSize >> 20) != 0) {
682- PutString0(o, s + 1, 3);
683- PutChar0(o, ',');
684- }
685- if ((freeSize >> 10) != 0) {
686- PutString0(o, s + 4, 3);
687- PutChar0(o, ',');
688- }
689- PutString0(o, s + 7, 3);
690- PutString0(o, " B\n");
416+ ConsoleCommands::mem(o, args);
691417 } else if (strncmp(command, "opencons", 9) == 0) {
692- Task* consTask = taskman->Alloc();
693- uintptr_t stackTop;
694- uint32_t stackSize;
695- stackTop = (uintptr_t)(new uint8_t[stackSize = 1024*4]);
696- consTask->SetFuncs(stackTop, stackSize,
697- TaskConsole::Init, DummyFunc, TaskConsole::Proc);
698- consTask->InitQueue(128);
699- taskman->Run(consTask, 1, 2);
418+ ConsoleCommands::opencons(o, args);
700419 } else if (strncmp(command, "echo", 5) == 0) {
701- PutString0(o, args);
702- PutChar0(o, '\n');
420+ ConsoleCommands::echo(o, args);
703421 } else if (strncmp(command, "beep", 5) == 0) {
704- int cnt = 2712;
705- int freq = 1193180;
706- if (args[0] != '\0') {
707- cnt = ((freq << 10) / strtol(args, 0, 0) + 512) >> 10;
708- }
709- // freq = 1.19318MHz / cnt
710- io_out8(0x0043, 0xb6);
711- io_out8(0x0042, (cnt & 0x00ff));
712- io_out8(0x0042, ((cnt >> 8) & 0x00ff));
713- uint8_t reg = io_in8(0x0061);
714- reg |= 0x03;
715- reg &= 0x0f;
716- io_out8(0x0061, reg);
717- o->timBeep->SetTime(100);
422+ ConsoleCommands::beep(o, args);
718423 } else if (strncmp(command, "eco", 4) == 0) {
719- PutString0(o, " tree \n");
720- PutString0(o, " tree tree \n");
721- PutString0(o, "tree tree tree\n");
424+ ConsoleCommands::eco(o, args);
722425 } else if (strncmp(command, "cat", 4) == 0) {
723- PutString0(o, " _ ___ _.--.\n");
724- PutString0(o, " \\`.|\\..----...-'` `-._.-'_.-'`\n");
725- PutString0(o, " / ' ` , __.--'\n");
726- PutString0(o, " )/' _/ \\ `-_, /\n");
727- PutString0(o, " `-'\" `\"\\_ ,_.-;_.-\\_ ',\n");
728- PutString0(o, " _.-'_./ {_.' ; /\n");
729- PutString0(o, " {_.-``-' {_/\n");
426+ ConsoleCommands::cat(o, args);
730427 } else {
731428 if (strlen(command) > 0) {
732429 PutString0(o, "unknown command\n");
@@ -754,26 +451,125 @@
754451 pos + Point(0, fontHankaku->GetHeight() - 1));
755452 }
756453
757-void WriteBuffer(Valiables* o, int x, int y, char ch)
454+void ConsoleMakeBorderLine(Image* img)
758455 {
759- if (x < 0 || o->cons.bufWidth <= x) {
760- Debug::WriteLine("write : x is wrong.");
456+ Point pos0(1, 25);
457+ Point pos1(img->GetWidth() - 2, 25);
458+ Point pos2(1, img->GetHeight() - 2);
459+ Point pos3(img->GetWidth() - 2, img->GetHeight() - 2);
460+ img->DrawLine(
461+ ConvRGB16(0xc0, 0xc0, 0xc0),
462+ pos0, pos2);
463+ img->DrawLine(
464+ ConvRGB16(0xc0, 0xc0, 0xc0),
465+ pos1, pos3);
466+ img->DrawLine(
467+ ConvRGB16(0xc0, 0xc0, 0xc0),
468+ pos2 + Point(1, 0), pos3 + Point(-1, 0));
469+ img->DrawLine(
470+ ConvRGB16(0x80, 0x80, 0x80),
471+ pos0 + Point(1, 0), pos2 + Point(1, -2));
472+ img->DrawLine(
473+ ConvRGB16(0x80, 0x80, 0x80),
474+ pos0 + Point(2, 0), pos1 + Point(-1, 0));
475+ img->DrawLine(
476+ ConvRGB16(0xf0, 0xf0, 0xf0),
477+ pos1 + Point(-1, 1), pos3 + Point(-1, -1));
478+ img->DrawLine(
479+ ConvRGB16(0xf0, 0xf0, 0xf0),
480+ pos2 + Point(1, -1), pos3 + Point(-2, -1));
481+}
482+
483+void ConsoleCommands::mem(Valiables* o, const char* arg)
484+{
485+ char s[256];
486+ PutString0(o, "mem : ");
487+ sprintf(s, "%10d", physicalMemorySize);
488+ if ((physicalMemorySize >> 30) != 0) {
489+ PutString0(o, s + 0, 1);
490+ PutChar0(o, ',');
761491 }
762- if (y < 0 || o->cons.bufHeight <= y) {
763- Debug::WriteLine("write : y is wrong.");
492+ if ((physicalMemorySize >> 20) != 0) {
493+ PutString0(o, s + 1, 3);
494+ PutChar0(o, ',');
764495 }
765- o->cons.buf[y * o->cons.bufWidth + x] = ch;
496+ if ((physicalMemorySize >> 10) != 0) {
497+ PutString0(o, s + 4, 3);
498+ PutChar0(o, ',');
499+ }
500+ PutString0(o, s + 7, 3);
501+ PutString0(o, " B\n");
502+
503+ uint32_t freeSize = memman.GetFreeSize();
504+ PutString0(o, "free : ");
505+ sprintf(s, "%10d", freeSize);
506+ if ((freeSize >> 30) != 0) {
507+ PutString0(o, s + 0, 1);
508+ PutChar0(o, ',');
509+ }
510+ if ((freeSize >> 20) != 0) {
511+ PutString0(o, s + 1, 3);
512+ PutChar0(o, ',');
513+ }
514+ if ((freeSize >> 10) != 0) {
515+ PutString0(o, s + 4, 3);
516+ PutChar0(o, ',');
517+ }
518+ PutString0(o, s + 7, 3);
519+ PutString0(o, " B\n");
766520 }
767-char ReadBuffer(Valiables* o, int x, int y)
521+
522+void ConsoleCommands::opencons(Valiables* o, const char* arg)
768523 {
769- if (x < 0 || o->cons.bufWidth <= x) {
770- Debug::WriteLine("read : x is wrong.");
524+ Task* consTask = taskman->Alloc();
525+ uintptr_t stackTop;
526+ uint32_t stackSize;
527+ stackTop = (uintptr_t)(new uint8_t[stackSize = 1024*4]);
528+ consTask->SetFuncs(stackTop, stackSize,
529+ TaskConsole::Init, DummyFunc, TaskConsole::Proc);
530+ consTask->InitQueue(128);
531+ taskman->Run(consTask, 1, 2);
532+}
533+
534+void ConsoleCommands::echo(Valiables* o, const char* arg)
535+{
536+ PutString0(o, arg);
537+ PutChar0(o, '\n');
538+}
539+
540+void ConsoleCommands::beep(Valiables* o, const char* arg)
541+{
542+ int cnt = 2712;
543+ const int freq = 1193180;
544+ if (arg[0] != '\0') {
545+ cnt = ((freq << 10) / strtol(arg, 0, 0) + 512) >> 10;
771546 }
772- if (y < 0 || o->cons.bufHeight <= y) {
773- Debug::WriteLine("read : y is wrong.");
774- }
775- return o->cons.buf[y * o->cons.bufWidth + x];
547+
548+ // freq = 1.19318MHz / cnt
549+ PIT::BeetSetCounter(cnt);
550+ PIT::BeepOn();
551+
552+ // カウンタ2、スピーカイネーブル
553+
554+ o->timBeep->SetTime(100);
776555 }
777556
557+void ConsoleCommands::eco(Valiables* o, const char* arg)
558+{
559+ PutString0(o, " tree \n");
560+ PutString0(o, " tree tree \n");
561+ PutString0(o, "tree tree tree\n");
562+}
778563
564+void ConsoleCommands::cat(Valiables* o, const char* arg)
565+{
566+ PutString0(o, " _ ___ _.--.\n");
567+ PutString0(o, " \\`.|\\..----...-'` `-._.-'_.-'`\n");
568+ PutString0(o, " / ' ` , __.--'\n");
569+ PutString0(o, " )/' _/ \\ `-_, /\n");
570+ PutString0(o, " `-'\" `\"\\_ ,_.-;_.-\\_ ',\n");
571+ PutString0(o, " _.-'_./ {_.' ; /\n");
572+ PutString0(o, " {_.-``-' {_/\n");
779573 }
574+
575+}
--- bitnos5/trunk/include/bitnos/console.h (revision 367)
+++ bitnos5/trunk/include/bitnos/console.h (revision 368)
@@ -56,14 +56,14 @@
5656 {
5757 int width; // 横の文字数
5858 int height; // 縦の文字数
59- int bufWidth; // バッファの横の文字数
60- int bufHeight; // バッファの縦の文字数
61- char* buf; // バッファ
59+ //int bufWidth; // バッファの横の文字数
60+ //int bufHeight; // バッファの縦の文字数
61+ //char* buf; // バッファ
6262
63- int startLine; // バッファの開始行
64- int endLine; // バッファの終了行(書き込み行)
65- int xPos; // 書き込みの横位置
66- int printYPos; // 表示の縦位置
63+ //int startLine; // バッファの開始行
64+ //int endLine; // バッファの終了行(書き込み行)
65+ //int xPos; // 書き込みの横位置
66+ //int printYPos; // 表示の縦位置
6767
6868 uint16_t backColor; // 背景色
6969 uint16_t textColor; // 前景色
Afficher sur ancien navigateur de dépôt.