Page 1 of 1

How to make a *REAL* O.S. or Virtual Machine in C#

Posted: Tue Oct 05, 2010 2:59 am
by Proprogrammer
NOTICE: THIS TUTORIAL CAN BE USED ON ANY DEVICE SUCH AS A IPHONE OR ANY OTHER DEVICE HAVE FUN!

WOW! The C-Sharp area doesnt have much! Let me fill it up for you guys with great tutorials such as this one!
My strongest point is in C#!
First before you do anything download this template called Cosmos
LINK: http://cosmos.codeplex.com/releases/351 ... load/90082
now that link download the template that is only availble for C# 2008.

K now to the code after you installed it then go to C# and create new then select the template for Cosmos.
Now when Cosmos loads you will see a bunch of stuff and coding, if you are familiar with C# then you can mess around with some of the stuff, if you arent that much of a expert just leave stuff alone and follow my instructions, later in this tutorial i will show you how to make a advanced OS, i have already made a OS with only a fully functioning Command prompt with my own computer language!

Now to the code again----
Here are some simple codes that you might want to add to your OS or VOS

If you are planning on making a VOS skip all this if you want and just put Form1 and other shit but if you want to make something actually better follow the tutorial!

FIrst before you add any code take away this code on the bottom
-
Code: Select all
while (true)
                ;
that code is to just pause the OS if you need that later.
Now to some real code
to shutdown the device that the OS is on!
Code: Select all
Cosmos.Sys.Deboot.ShutDown();
to restart the device that the OS is on!
Code: Select all
Cosmos.Sys.Deboot.Reboot();
How to make a The OS read a line given to show!
Code: Select all
Console.WriteLine("Welcome! You just booted C# code. Please edit Program.cs to fit your needs");
Console.Read();
To Restart the Consoles Commands and clear the memmory of anything that happend put the following code!
Code: Select all
Console.Clear();
Here is a little code snippet thing for shutting down a computer!
Code: Select all
namespace CosmosBoot1
{
    class Program
    {
        #region Cosmos Builder logic
        // Most users wont touch this. This will call the Cosmos Build tool
        [STAThread]
        static void Main(string[] args)
        {
            BuildUI.Run();
        }
        #endregion

        // Main entry point of the kernel
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            Console.WriteLine("Welcome to EXTRA OS!");
            Console.WriteLine("If you want to shutdown your computer press any key");
            Console.Read();
            Cosmos.Sys.Deboot.ShutDown();
        }
    }
}
Now only that, just that code can shut down your device! simple yet powerfull!


Now moving onto more advanced stuff! If you want.

This code is intermediate not really advanced but carries on!
Code: Select all
using System;
using Cosmos.Compiler.Builder;

namespace CosmosBoot1
{
    class Program
    {
        #region Cosmos Builder logic
        // Most users wont touch this. This will call the Cosmos Build tool
        [STAThread]
        static void Main(string[] args)
        {
            BuildUI.Run();
        }
        #endregion

        // Main entry point of the kernel
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            Console.Title.Equals("hello OS");
            Console.WriteLine("Welcome to EXTRA OS!");
            Console.WriteLine("If you want to shutdown your computer press s");
            Console.KeyAvailable.Equals("s");
            Console.Read();
            Cosmos.Sys.Deboot.ShutDown();
        }
    }
}
that code only allow the computer to shutdown if s is pressed!
also puts a title!

Now for some advanced stuff! Lets make that boring command prompt better and funner!
LETS DRAW !

you will need to import the following!

using System;
using Cosmos.Compiler.Builder;
using Cosmos.Hardware;
using Cosmos.Sys;
using Cosmos.Kernel;
using System.Collections;
using System.Collections.Generic;
using Screen = Cosmos.Hardware.VGAScreen

that will enable you to draw animations and other stuff!

Make a new namespace called Draw

public static void FillRectangle(uint lx, uint ly, uint sx, uint sy, uint colour)
Screen.SetMode320x200x8();
{
for (uint xx = lx; xx < sx + lx; xx++)
{
for (uint yy = ly; yy < sy + ly; yy++)
{
if(xx <= 319 && xx >= 0)
screenbuffer[yy * 320 + xx] = colour; //If you are using a uint[] as a screen buffer, use this, otherwise use this:
//Screen.SetPixel320x200x8(xx, yy, colour);
}
}
}
That above is the code for coloring the command prompt,
well that is all for today!
I will keep on adding to this a little bit every few days, cause i dont like making OS's that much or explaining them, so you can try this out and do what ever!

Re: How to make a *REAL* O.S. or Virtual Machine in C#

Posted: Tue Oct 05, 2010 1:58 pm
by Agust1337
Hello Proprogrammer,
Thanks for your great post here :), you must show us how to make the gui :D
Keep it up cooll;

Re: How to make a *REAL* O.S. or Virtual Machine in C#

Posted: Wed Jan 05, 2011 4:30 pm
by DreadNought
Doesnt that app have ti me .app or something for iphone?