Cosmos/Demos/Guess/GuessOS.cs
fanoI db5b713090 CGS is finally ready to be used! Let's merge it...
- To solve the slowness of the MemoryBlock Fill() method when the block has a big size I've created a new class for this MemoryOperations that for now contains only the method Fill() with a part implemented in ASM and with some overloads to semplify its usage from managed code. In future in this class will be added other methods to operate fast on memory for example Cmp() and Copy().
- Adding (not passing) test of the Color struct to the BoxingTest kernel
- Removed BoxingTest kernel inside BCL test: it was a duplicate of the BoxingTest kernel
- Restored correct TestKernelSets
- In the CGS Test kernel the last rectangle is now LimeGreen instead of another type of red (more clear that is working correctly)
- Added to X# the generation of the instruction Shuftps
- Added to X# the generation of the instruction MoveUPS
- Modified Guess Demo to wait for a key press to terminate (it closed suddenly in case the number was guessed)
- The VBE IOMemoryBlock has again size of 1920x1200 (the max usable)
- Added CGS Demo
- Code clean up
2017-03-05 20:32:55 +01:00

67 lines
2 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Cosmos.Debug.Kernel;
using Sys = Cosmos.System;
/*
* Beware Demo Kernels are not recompiled when its dependencies changes!
* To force recompilation right click on on the Cosmos icon of the demo solution and do "Build".
*/
namespace GuessKernel
{
public class GuessOS : Sys.Kernel
{
protected int mCount = 0;
protected int mMagicNo = 22;
public GuessOS()
{
// Didnt check if tickcount is working yet.. can change this later
//var xRandom = new Random(234243534);
//mMagicNo = xRandom.Next(1, 100);
}
protected override void BeforeRun()
{
//Cosmos.Core.HMI.Init();
Console.Clear();
Console.WriteLine("Guess Demo");
Console.WriteLine("Please guess a number from 1 to 100.");
}
protected override void Run()
{
mCount++;
mDebugger.Send("");
mDebugger.SendMessage("Kernel", "New iteration");
Console.WriteLine();
Console.WriteLine("Guess #" + mCount);
Console.Write("Please enter a guess: ");
string xInputStr = Console.ReadLine();
Console.Write("Input length: ");
Console.WriteLine(xInputStr.Length.ToString());
int xGuess = int.Parse(xInputStr);
Console.WriteLine("Your guess was " + xGuess);
if (xGuess < mMagicNo)
{
Console.WriteLine("Too low.");
}
else if (xGuess > mMagicNo)
{
Console.WriteLine("Too high.");
}
else
{
Console.WriteLine("You guessed it!");
Console.WriteLine("Press any key to end Guess Demo. Thanks for playing!");
Console.ReadKey();
Stop();
}
}
}
}