int main(int argc, char* args[]) { InitColorTerminal(); SDL_RenderSetScale(render, 2.0, 2.0); // bool no_bold = false, bold = true; // int start = '!', max = '~'+17, x_offset = 0, y_offset = 0; // DrawABunchOfCharsEx(start, max, x_offset, y_offset, no_bold); // DrawABunchOfCharsEx(start, max, x_offset, y_offset + 6, bold); // SDL_RenderPresent(render); time_t t; srand((unsigned) time(&t)); int x_direction = -1, y_direction = 1; Uint32 delay = 50; RandomizedFill(); Marquee(x_direction, y_direction, delay); quit = false; ResetTerminal(); MakeBigText("AMOS!", 5, (TERMINAL_ROWS / 2) - (pbm_font->height / 2)); x_direction = 1; Marquee(x_direction, y_direction, delay); while(!quit){ CheckForQuit(WAIT); } exit(EXIT_SUCCESS); }
NTSTATUS NTAPI ConDrvDetachTerminal(IN PCONSOLE Console) { if (Console == NULL) return STATUS_INVALID_PARAMETER; /* FIXME: Lock the console before ?? */ /* Deinitialize the terminal BEFORE detaching it from the console */ Console->TermIFace.Vtbl->DeinitTerminal(&Console->TermIFace/*, Console*/); /* * Detach the terminal from the console: * reinitialize the terminal interface. */ ResetTerminal(Console); DPRINT("Terminal unregistered\n"); return STATUS_SUCCESS; }
NTSTATUS NTAPI ConDrvAttachTerminal(IN PCONSOLE Console, IN PTERMINAL Terminal) { NTSTATUS Status; if (Console == NULL || Terminal == NULL) return STATUS_INVALID_PARAMETER; /* FIXME: Lock the console before ?? */ /* * Attach the terminal to the console. Use now the TermIFace of the console, * and not the user-defined temporary Terminal pointer. */ Console->TermIFace = *Terminal; Console->TermIFace.Console = Console; /* Initialize the terminal AFTER having attached it to the console */ DPRINT("Finish initialization of terminal\n"); Status = Console->TermIFace.Vtbl->InitTerminal(&Console->TermIFace, Console); if (!NT_SUCCESS(Status)) { DPRINT1("Terminal initialization failed, Status = 0x%08lx\n", Status); /* We failed, detach the terminal from the console */ Terminal->Console = NULL; // For the caller ResetTerminal(Console); return Status; } /* Copy buffer contents to screen */ // Terminal.Draw(); DPRINT("Terminal initialization done\n"); return STATUS_SUCCESS; }
char* TANSIParser::ParseEscape(char* pszBuffer, char* pszBufferEnd) { char *pszChar; // Check if we have enough characters in buffer. if ((pszBufferEnd - pszBuffer) < 2) return pszBuffer; // I.Ioannou 04 Sep 1997 // there is no need for pszBuffer++; after each command // Decode the command. pszBuffer++; switch (*pszBuffer++) { case 'A': // Cursor up Console.MoveCursorPosition(0, -1); break; // Cursor down case 'B': Console.MoveCursorPosition(0, 1); break; // Cursor right case 'C': Console.MoveCursorPosition(1, 0); break; // LF *or* cursor left (Paul Brannan 6/27/98) case 'D': if(vt52_mode) Console.MoveCursorPosition(-1, 0); else Console.index(); break; // CR/LF (Paul Brannan 6/26/98) case 'E': Console.WriteCtrlString("\r\n", 2); break; // Special graphics char set (Paul Brannan 6/27/98) case 'F': Charmap.setmap('0'); break; // ASCII char set (Paul Brannan 6/27/98) case 'G': Charmap.setmap('B'); break; // Home cursor/tab set case 'H': if(ini.get_vt100_mode()) { int x = Console.GetCursorX(); if(x != 0) { int t = tab_stops[x - 1]; for(int j = x - 1; j >= 0 && tab_stops[j] == t; j--) tab_stops[j] = x; } } else { // I.Ioannou 04 Sep 1997 (0,0) not (1,1) ConSetCursorPos(0, 0); } break; // Reverse line feed (Paul Brannan 6/27/98) // FIX ME!!! reverse_index is wrong to be calling here // (Paul Brannan 12/2/98) case 'I': Console.reverse_index(); break; // Erase end of screen case 'J': Console.ClearEOScreen(); break; // Erase EOL case 'K': Console.ClearEOLine(); break; // Scroll Up one line //Reverse index case 'M': Console.reverse_index(); break; // Direct cursor addressing case 'Y': if ((pszBufferEnd - pszBuffer) >= 2){ // if we subtract '\x1F', then we may end up with a negative // cursor position! (Paul Brannan 6/26/98) ConSetCursorPos(pszBuffer[1] - ' ', pszBuffer[0] - ' '); pszBuffer+=2; } else { pszBuffer--; // Paul Brannan 6/26/98 } break; // Terminal ID Request case 'Z': { const char* szTerminalId = GetTerminalID(); Network.WriteString(szTerminalId, strlen(szTerminalId)); break; } // reset terminal to defaults case 'c': ResetTerminal(); break; // Enter alternate keypad mode case '=': KeyTrans.set_ext_mode(APP3_KEY); break; // Exit alternate keypad mode case '>': KeyTrans.unset_ext_mode(APP3_KEY); break; // Enter ANSI mode case '<': KeyTrans.unset_ext_mode(APP2_KEY); // exit vt52 mode break; // Graphics processor on (See note 3) case '1': break; // Line size commands case '#': //Line size commands // (Paul Brannan 6/26/98) if(pszBuffer < pszBufferEnd) { switch(*pszBuffer++) { case '3': break; // top half of a double-height line case '4': break; // bottom half of a double-height line case '6': break; // current line becomes double-width case '8': Console.ClearScreen('E'); break; } } else { pszBuffer--; } break; // Graphics processor off (See note 3) case '2': break; // Save cursor and attribs case '7': SaveCurY(Console.GetRawCursorY()); SaveCurX(Console.GetRawCursorX()); iSavedAttributes = Console.GetAttrib(); break; // Restore cursor position and attribs case '8': Console.SetRawCursorPosition(iSavedCurX, iSavedCurY); Console.SetAttrib(iSavedAttributes); break; // Set G0 map (Paul Brannan 6/25/98) case '(': if (pszBuffer < pszBufferEnd) { map_G0 = *pszBuffer; if(current_map == 0) Charmap.setmap(map_G0); pszBuffer++; } else { pszBuffer--; } break; // Set G1 map (Paul Brannan 6/25/98) case ')': if (pszBuffer < pszBufferEnd) { map_G1 = *pszBuffer; if(current_map == 1) Charmap.setmap(map_G1); pszBuffer++; } else { pszBuffer--; } break; // This doesn't do anything, as far as I can tell, but it does take // a parameter (Paul Brannan 6/27/98) case '%': if (pszBuffer < pszBufferEnd) { pszBuffer++; } else { pszBuffer--; } break; // ANSI escape sequence case '[': // Check if we have whole escape sequence in buffer. // This should not be isalpha anymore (Paul Brannan 9/1/98) pszChar = pszBuffer; while ((pszChar < pszBufferEnd) && (*pszChar <= '?')) pszChar++; if (pszChar == pszBufferEnd) pszBuffer -= 2; else pszBuffer = ParseEscapeANSI(pszBuffer, pszBufferEnd); break; #ifdef MTE_SUPPORT case '~': // Frediano Ziglio, 5/31/2000 // Meridian Terminal Emulator extension // !!! same as ANSI // !!! should put in MTE procedure pszChar = pszBuffer; while ((pszChar < pszBufferEnd) && (*pszChar <= '?')) pszChar++; if (pszChar == pszBufferEnd) pszBuffer -= 2; else pszBuffer = ParseEscapeMTE(pszBuffer, pszBufferEnd); break; #endif default: #ifdef DEBUG Console.Beep(); #endif break; } return pszBuffer; }
NTSTATUS NTAPI ConDrvInitConsole(OUT PCONSOLE* NewConsole, IN PCONSOLE_INFO ConsoleInfo) { NTSTATUS Status; // CONSOLE_INFO CapturedConsoleInfo; TEXTMODE_BUFFER_INFO ScreenBufferInfo; PCONSOLE Console; PCONSOLE_SCREEN_BUFFER NewBuffer; if (NewConsole == NULL || ConsoleInfo == NULL) return STATUS_INVALID_PARAMETER; *NewConsole = NULL; /* * Allocate a new console */ Console = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*Console)); if (NULL == Console) { DPRINT1("Not enough memory for console creation.\n"); return STATUS_NO_MEMORY; } /* * Fix the screen buffer size if needed. The rule is: * ScreenBufferSize >= ConsoleSize */ if (ConsoleInfo->ScreenBufferSize.X < ConsoleInfo->ConsoleSize.X) ConsoleInfo->ScreenBufferSize.X = ConsoleInfo->ConsoleSize.X; if (ConsoleInfo->ScreenBufferSize.Y < ConsoleInfo->ConsoleSize.Y) ConsoleInfo->ScreenBufferSize.Y = ConsoleInfo->ConsoleSize.Y; /* * Initialize the console */ Console->State = CONSOLE_INITIALIZING; Console->ReferenceCount = 0; InitializeCriticalSection(&Console->Lock); /* Initialize the terminal interface */ ResetTerminal(Console); Console->ConsoleSize = ConsoleInfo->ConsoleSize; Console->FixedSize = FALSE; // Value by default; is reseted by the terminals if needed. /* Initialize the input buffer */ Status = ConDrvInitInputBuffer(Console, 0 /* ConsoleInfo->InputBufferSize */); if (!NT_SUCCESS(Status)) { DPRINT1("ConDrvInitInputBuffer: failed, Status = 0x%08lx\n", Status); DeleteCriticalSection(&Console->Lock); ConsoleFreeHeap(Console); return Status; } /* Set-up the code page */ Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage; /* Initialize a new text-mode screen buffer with default settings */ ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize; ScreenBufferInfo.ScreenAttrib = ConsoleInfo->ScreenAttrib; ScreenBufferInfo.PopupAttrib = ConsoleInfo->PopupAttrib; ScreenBufferInfo.IsCursorVisible = TRUE; ScreenBufferInfo.CursorSize = ConsoleInfo->CursorSize; InitializeListHead(&Console->BufferList); Status = ConDrvCreateScreenBuffer(&NewBuffer, Console, NULL, CONSOLE_TEXTMODE_BUFFER, &ScreenBufferInfo); if (!NT_SUCCESS(Status)) { DPRINT1("ConDrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status); ConDrvDeinitInputBuffer(Console); DeleteCriticalSection(&Console->Lock); ConsoleFreeHeap(Console); return Status; } /* Make the new screen buffer active */ Console->ActiveBuffer = NewBuffer; Console->UnpauseEvent = NULL; DPRINT("Console initialized\n"); /* All went right, so add the console to the list */ Status = InsertConsole(Console); if (!NT_SUCCESS(Status)) { /* Fail */ ConDrvDeleteConsole(Console); return Status; } /* The initialization is finished */ DPRINT("Change state\n"); Console->State = CONSOLE_RUNNING; /* Return the newly created console to the caller and a success code too */ *NewConsole = Console; return STATUS_SUCCESS; }
void c_main(char *blockBase, u32 blockSize) { int numRead = 0; char commandline[128]; blobStatus status; int i; int retval = 0; /* We really want to be able to communicate, so initialise the * serial port at 9k6 (which works good for terminals) */ SerialInit(baud9k6); TimerInit(); /* initialise status */ status.kernelSize = 0; status.kernelType = fromFlash; status.ramdiskSize = 0; status.ramdiskType = fromFlash; status.blockSize = blockSize; status.downloadSpeed = baud115k2; /* Load kernel and ramdisk from flash to RAM */ Reload("kernel", &status); Reload("ramdisk", &status); /* Print the required GPL string */ SerialOutputString("\r" PACKAGE " version " VERSION "\r" "Copyright (C) 1999 2000 " "Jan-Derk Bakker and Erik Mouw\r" "Copyright (C) 2000 " "Johan Pouwelse.\r"); SerialOutputString(PACKAGE " comes with ABSOLUTELY NO WARRANTY; " "read the GNU GPL for details.\r"); SerialOutputString("This is free software, and you are welcome " "to redistribute it\r"); SerialOutputString("under certain conditions; " "read the GNU GPL for details.\r\r"); /* and some information */ #ifdef BLOB_DEBUG SerialOutputString("Running from "); if(RunningFromInternal()) SerialOutputString("internal flash\r"); else SerialOutputString("external flash\r"); SerialOutputString("blockBase = 0x"); SerialOutputHex((int) blockBase); SerialOutputString(", blockSize = 0x"); SerialOutputHex(blockSize); SerialOutputByte('\r'); #endif /* wait 10 seconds before starting autoboot */ SerialOutputString("Autoboot in progress, press any key to stop "); for(i = 0; i < 10; i++) { SerialOutputByte('.'); retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; } /* no key was pressed, so proceed booting the kernel */ if(retval == 0) { commandline[0] = '\0'; BootKernel(commandline); } SerialOutputString("\rAutoboot aborted\r"); SerialOutputString("Type \"help\" to get a list of commands\r"); /* the command loop. endless, of course */ for(;;) { DisplayPrompt(NULL); /* wait an hour to get a command */ numRead = GetCommand(commandline, 128, 3600); if(numRead > 0) { if(MyStrNCmp(commandline, "boot", 4) == 0) { BootKernel(commandline + 4); } else if(MyStrNCmp(commandline, "clock", 5) == 0) { SetClock(commandline + 5); } else if(MyStrNCmp(commandline, "download ", 9) == 0) { Download(commandline + 9, &status); } else if(MyStrNCmp(commandline, "flash ", 6) == 0) { Flash(commandline + 6, &status); } else if(MyStrNCmp(commandline, "help", 4) == 0) { PrintHelp(); } else if(MyStrNCmp(commandline, "reload ", 7) == 0) { Reload(commandline + 7, &status); } else if(MyStrNCmp(commandline, "reset", 5) == 0) { ResetTerminal(); } else if(MyStrNCmp(commandline, "speed ", 6) == 0) { SetDownloadSpeed(commandline + 6, &status); } else if(MyStrNCmp(commandline, "status", 6) == 0) { PrintStatus(&status); } else { SerialOutputString("*** Unknown command: "); SerialOutputString(commandline); SerialOutputByte('\r'); } } } } /* c_main */