void cin(char* buf, unsigned int bufLen) { unsigned int readChars = 0; char temp[bufLen]; if(!EnsureKeyboard()) return; // We have no keyboard do { char k = KeyboardGetChar(); if(k == 0) continue; if(k == '\n') break; temp[readChars] = k; readChars++; }while(readChars < bufLen); // Just keep reading (Return cancels this early) if(readChars < bufLen - 1) temp[readChars + 1] = '\0'; else temp[bufLen - 1] = '\0'; // Copy the read stuff into the buffer strcpy(temp, buf); }
void terminal_readline() { uint32_t x = 0; uint32_t y = 0; while (1) { KeyboardUpdate(); char c = KeyboardGetChar(); if (c == 0) continue; terminal_screen[y*terminal_width + x] = c; if (c == '\n') { y++; y = y % 75; x = 0; } else { x++; x = x % 240; } terminal_display(); } }
void OS_Main(void) { uint32 tmpAddr; WND* topWnd; int8 buf[10]; TASK *task;// *taskB, *taskC; WND_CONSOLE* console; char* wStr[64]; OS_Init(); fill_box(bgSheet, BLACK, 0, 0, 160, 16); sprintf(printBuf, "MemVol:%dMB", mem_getTotalSize() / (1024 * 1024)); puts_str(bgSheet, printBuf, WHITE, 0, 0); multiTask_init(); // console_puts(&wnd, "%s\n", "学挖掘机^_^,还到山东蓝翔!wwy"); strcpy(wStr, "a学挖掘机到底!にほんご哪家强?"); puts_str(bgSheet, wStr, WHITE, 32, 32); strcpy(wStr, "学挖掘机^_^,还到山东蓝翔!"); puts_str(bgSheet, wStr, GREEN, 32, 48); // put_ascii(bgSheet, 0xD0D6, WHITE, 32, 32); // put_ascii(bgSheet, 'w', BLACK, 32, 48); sheet_draw_all(); while(1){ if(KeyboardGetChar(buf, 1)) { fill_box(bgSheet, BLACK, 0, 232, 100, 248); puts_str(bgSheet, buf, WHITE, 0, 232); sheet_add_redraw_region(0, 232, 100, 248); topWnd = wnd_get_top(); if(topWnd != NULL) { PutIntoLoopArray(topWnd->keyboardBuffer, buf[0]); } } MouseKeyboardDeamon(); sheet_draw_deamon(); if(keyboardCtl.AltOn == TRUE && keyboardCtl.F4_On == TRUE) { console = (WND_CONSOLE*)*((int*)0xFEC); if(console->task->tss.ss0 != 0) { console_puts(console, "\nBreak(key) :\n"); io_cli(); console->task->tss.eax = (int) &(console->task->tss.esp0); console->task->tss.eip = (int) asm_end_app; io_sti(); keyboardCtl.AltOn = FALSE; keyboardCtl.F4_On = FALSE; } } else if(keyboardCtl.WinOn == TRUE && keyboardCtl.F1_On == TRUE) { //Console Task mem_alloc(64 * 1024, &tmpAddr); tmpAddr += 64 * 1024 - 12; *((int*)(tmpAddr + 4)) = (int)bgSheet; task_alloc("Task Console", (int32)&task_console_main, tmpAddr, 0x00000202, 1, &task); *((int*)(tmpAddr + 8)) = (int)task; task->tss.cs = 2 * 8; //目前必须为 2 × 8 task_run(task); keyboardCtl.WinOn = FALSE; keyboardCtl.F1_On = FALSE; } } // 不能有 return }