public static unsafe void PrintTestString() { if (!Initialised) { return; } //This does not use the Write functions as it is a test function to // test that strings and the video memory output work. FlingOops.String str = "1234567890!\"£$%^&*()qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM[];'#,./{}:@~<>?\\|`¬¦"; #if MIPS UART.Write(str); #elif x86 int strLength = str.length; char *strPtr = str.GetCharPointer(); char *vidMemPtr = vidMemBasePtr; while (strLength > 0) { vidMemPtr[0] = (char)((*strPtr & 0x00FF) | colour); strPtr++; vidMemPtr++; strLength--; } #endif }
public static unsafe void Write(FlingOops.String str) { if (!Initialised) { return; } //If string is null, just don't write anything if (str == null) { //Do not make this throw an exception. The BasicConsole // is largely a debugging tool - it should be reliable, // robust and not throw exceptions. return; } #if MIPS UART.Write(str); #elif x86 if (PrimaryOutputEnabled) { int strLength = str.length; int maxOffset = rows * cols; //This block shifts the video memory up the required number of lines. if (offset + strLength > maxOffset) { int amountToShift = (offset + strLength) - maxOffset; amountToShift = amountToShift + (80 - (amountToShift % 80)); offset -= amountToShift; char *vidMemPtr_Old = vidMemBasePtr; char *vidMemPtr_New = vidMemBasePtr + amountToShift; char *maxVidMemPtr = vidMemBasePtr + (cols * rows); while (vidMemPtr_New < maxVidMemPtr) { vidMemPtr_Old[0] = vidMemPtr_New[0]; vidMemPtr_Old++; vidMemPtr_New++; } } //This block outputs the string in the current foreground / background colours. char *vidMemPtr = vidMemBasePtr + offset; char *strPtr = str.GetCharPointer(); while (strLength > 0) { vidMemPtr[0] = (char)((*strPtr & 0x00FF) | colour); strLength--; vidMemPtr++; strPtr++; offset++; } } if (SecondaryOutput != null && SecondaryOutputEnabled) { SecondaryOutput(str); } #endif }