Help, I keep getting errors in my GUI OS

Sep 1, 2011 at 6:34 AM
Edited Sep 1, 2011 at 10:12 AM

I know I have posted this three times, but I am getting no answers and I can't find anything on the internet. I have also uploaded the image to a new host (photobucket), so now there shouldn't be any issues.

Ok so i code my OS using Cosmos Milestone 4 and VS2010 with no errors but when I build it i keep getting these errors. I have googled it but to no avail. I have linked an image of it here. (I uploaded it to photobucket, so now it works)

My code is also provided below. If there are any problems with it, please tell. Thanks in advance.

 

using System;
using Cosmos.Hardware;
using Cosmos.Compiler.Builder;
using Cosmos.Kernel;

namespace MyOS
{
    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 int screennum = 1;
        public static uint sx;
        public static uint sy;
        public static uint ScreenWidth = 320;
        public static uint ScreenHeight = 200;
        public static uint p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24;
        public static bool MenuOpenEx = false;
        public static uint Pressed = 0;
        public static Image MenuSave = new Image(50, 30);
        public static Boolean MenuOpen = false;
        public static void SaveScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
        {
            uint n = 0;
            if (width > height)
            {
                for (uint x4 = 0; x4 < height; x4++)
                {
                    for (uint y4 = 0; y4 < width; y4++)
                    {
                        uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
                        image.SetPixel(xpos + x4, ypos + y4, I, n);
                        n += 1;
                    }
                }
            }
            if (width < height)
            {


                for (uint y4 = 0; y4 < width; y4++)
                {
                    for (uint x4 = 0; x4 < height; x4++)
                    {
                        uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
                        image.SetPixel(xpos + x4, ypos + y4, I, n);
                        n += 1;

                    }
                }
            }



        }
        public static void RestoreScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
        {
            uint n = 0;
            if (width > height)
            {
                for (uint x4 = 0; x4 < height; x4++)
                {
                    for (uint y4 = 0; y4 < width; y4++)
                    {

                        uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
                        VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
                        n += 1;
                    }
                }
            }
            if (width < height)
            {


                for (uint y4 = 0; y4 < width; y4++)
                {
                    for (uint x4 = 0; x4 < height; x4++)
                    {
                        uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
                        VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
                        n += 1;
                    }
                }
            }


        }
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            VGAScreen.SetMode320x200x8();
            VGAScreen.SetPaletteEntry(4, 0x00, 0x3C, 0x00);//Green
            VGAScreen.SetPaletteEntry(0, 0x00, 0x00, 0x00); //Black         
            VGAScreen.SetPaletteEntry(5, 50, 50, 50);//Grey
            VGAScreen.SetPaletteEntry(6, 236, 233, 216);//window color
            VGAScreen.SetPaletteEntry(7, 255, 248, 106);//light yellow
            VGAScreen.SetPaletteEntry(8, 255, 255, 255);//white
            VGAScreen.Clear(4);//Clear the screen to green for now!
            MouseEx.Initialize();//Initialize Mouse
            //Draw All Of Our Desktop setups here
            DrawWindowsBar();
            DrawWindowsStartButton();
            SaveScreen((uint)MouseEx.X, (uint)MouseEx.Y);
            MouseEnabled();//Call the mouse loop

        }
        //Our Desktop Drawing Voids
        public static void DrawWindowsBar()
        {

            DrawRect(0, ScreenHeight - 8, ScreenWidth, 8, 5); //Make a Gray Menu Bar!
            DrawRect(0, ScreenHeight - 8, ScreenWidth, 1, 8); //Add light to the bar like windows does!
        }
        public static void DrawWindowsStartButton()
        {
            //Ok this will be a little bit harder
            DrawRect(4, ScreenHeight - 5, 25, 4, 0);//Draw our black menu button!
        }
        public static bool CheckClick(uint x, uint y, uint Length, uint Width)
        {
            for (uint bb = x; bb < x + Length; bb++)
            {
                for (uint cc = y; cc < y + Width; cc++)
                {
                    if (MouseEx.X == bb && MouseEx.Y == cc)
                    {
                        return true;   //Return true if the area is not clicked                
                    }
                }
            }
            return false;   //Return false if the area is not clicked
        }
        public static void DrawRect(uint x, uint y, uint Width, uint Height, uint color)
        {

            for (uint bb = x; bb < x + Width; bb++)
            {

                for (uint cc = y; cc < y + Height; cc++)
                {
                    VGAScreen.SetPixel320x200x8(bb, cc, color);
                }
            }
        }
        public static void MouseEnabled()
        {

            bool PointerDrawn = false;
            uint x = (uint)MouseEx.X;
            uint y = (uint)MouseEx.Y;
            uint mx;
            uint my;
            Boolean moved = false;
            while (true)
            {
                mx = (uint)MouseEx.X;
                my = (uint)MouseEx.Y;


                if (mx != x || my != y || mx == x || my == y)
                {



                    if (MouseEx.Buttons == MouseEx.MouseState.Left)
                    {
                        ProcessCMD();

                    }


                    if (mx != x & my == y) // This Checks if mouse is moving                   
                    {
                        moved = true;
                    }

                    if (mx == x & my != y)// This Checks if mouse is moving                   
                    {
                        moved = true;
                    }

                    if (mx != x & my != y)// This Checks if mouse is moving                   
                    {
                        moved = true; //Tells our code that the Mouse is not drawn.                  
                    }

                }

                if (moved == true)
                {

                    if (moved == true)// This Checks if mouse is moving                       
                    {
                        PointerDrawn = true;
                        moved = false;
                    }
                    if (PointerDrawn == true)//Is the pointer Not Drawn?                   
                    {
                        RestoreScreen();
                        x = mx;
                        y = my;
                        SaveScreen(x, y);
                        PointerDrawn = false;
                        DrawPointer(mx, my);
                    }
                    else
                    {

                        DrawPointer(mx, my);
                    }
                }
            }
        }
        public static void DrawPointer(uint x, uint y)
        {
            VGAScreen.SetPixel320x200x8(x, y, 10);
            VGAScreen.SetPixel320x200x8(x + 1, y, 10);
            VGAScreen.SetPixel320x200x8(x + 2, y, 10);
            VGAScreen.SetPixel320x200x8(x, y + 1, 10);
            VGAScreen.SetPixel320x200x8(x, y + 2, 10);
            VGAScreen.SetPixel320x200x8(x + 1, y + 1, 10);
            VGAScreen.SetPixel320x200x8(x + 2, y + 2, 10);
            VGAScreen.SetPixel320x200x8(x + 3, y + 3, 10);
        }
        public static void SaveScreen(uint x, uint y)
        {
            sx = x;
            sy = y;
            //left pixesl
            p0 = VGAScreen.GetPixel320x200x8(sx, sy);
            p1 = VGAScreen.GetPixel320x200x8(sx, sy + 1);
            p2 = VGAScreen.GetPixel320x200x8(sx, sy + 2);
            p3 = VGAScreen.GetPixel320x200x8(sx, sy + 3);
            p4 = VGAScreen.GetPixel320x200x8(sx, sy + 4);

            //Second Set of Left pixels
            p5 = VGAScreen.GetPixel320x200x8(sx + 1, sy);
            p6 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 1);
            p7 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 2);
            p8 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 3);
            p9 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 4);
            //third set of left pixels

            p10 = VGAScreen.GetPixel320x200x8(sx + 2, sy);
            p11 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 1);
            p12 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 2);
            p13 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 3);
            p14 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 4);
            //last row of pixels

            p15 = VGAScreen.GetPixel320x200x8(sx + 3, sy);
            p16 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 1);
            p17 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 2);
            p18 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 3);
            p19 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 4);

            p20 = VGAScreen.GetPixel320x200x8(sx + 4, sy);
            p21 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 1);
            p22 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 2);
            p23 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 3);
            p24 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 4);
        }
        public static void RestoreScreen()
        {

            //left pixesl
            VGAScreen.SetPixel320x200x8(sx, sy, p0);
            VGAScreen.SetPixel320x200x8(sx, sy + 1, p1);
            VGAScreen.SetPixel320x200x8(sx, sy + 2, p2);
            VGAScreen.SetPixel320x200x8(sx, sy + 3, p3);


            //Second Set of Left pixels
            VGAScreen.SetPixel320x200x8(sx + 1, sy, p5);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 1, p6);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 2, p7);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 3, p8);
            //third set of left pixels

            VGAScreen.SetPixel320x200x8(sx + 2, sy, p10);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 1, p11);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 2, p12);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 3, p13);
            //last row of pixels

            VGAScreen.SetPixel320x200x8(sx + 3, sy, p15);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 1, p16);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 2, p17);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 3, p18);

            //Extra Layer of Pixels Just incase
            VGAScreen.SetPixel320x200x8(sx + 4, sy, p20);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 1, p21);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 2, p22);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 3, p23);

        }
        public static void ProcessCMD()
        {
            if (CheckClick(4, ScreenHeight - 5, 25, 4) == true)
            {
                if (MenuOpen == false)
                {
                    DrawMenu();
                    MenuOpen = true;
                }
                else
                {
                    UnDrawMenu();
                    MenuOpen = false;
                }
            }
        }
        public static void DrawMenu()
        {
            //Save the menu before we draw it

            SaveScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);
            //This is a simple math thing ScreenHeight - 8 Lets you draw simple right on top of our menu bar so you then need to - the Menus height.
            DrawRect(0, ScreenHeight - 8 - 50, 30, 50, 1);

        }
        public static void UnDrawMenu()
        {
            //To get rid of it just restore the saved screen
            RestoreScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);

        }
    }

    class Image
    {
        private uint[] Data;
        ///
        /// The height of the image.
        ///
        private int Height;
        ///
        /// The width of the image.
        ///
        private int Width;
        public Image(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        Image()
        {
            this.Width = 1;
            this.Height = 1;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        public uint GetPixel(uint x, uint y, uint n)
        {
            return this.Data[n];
        }
        public void SetPixel(uint x, uint y, uint p, uint n)
        {

            this.Data[n] = p;
        }
    }
    class MouseEx
    {
        public static int X, Y;
        public static MouseState Buttons;

        public static void Initialize()
        {

            //enable mouse
            WaitSignal();
            CPUBus.Write8(0x64, 0xA8);

            // enable interrupt
            WaitSignal();
            CPUBus.Write8(0x64, 0x20);
            WaitData();
            byte status = (byte)(CPUBus.Read8(0x60) | 2);
            WaitSignal();
            CPUBus.Write8(0x64, 0x60);
            WaitSignal();
            CPUBus.Write8(0x60, status);

            //default
            Write(0xF6);
            Read();  //Acknowledge

            //Enable the mouse
            Write(0xF4);
            Read();  //Acknowledge

            Interrupts.AddIRQHandler(12, new Interrupts.InterruptDelegate(HandleMouse));

        }

        public static byte GetMouseID()
        {
            CPUBus.Write8(0x64, 0xF2);
            return CPUBus.Read8(0x60);
        }

        private static byte Read()
        {
            WaitData();
            return CPUBus.Read8(0x60);
        }

        private static void Write(byte b)
        {
            //Wait to be able to send a command
            WaitSignal();
            //Tell the mouse we are sending a command
            CPUBus.Write8(0x64, 0xD4);
            //Wait for the final part
            WaitSignal();
            //Finally write
            CPUBus.Write8(0x60, b);
        }
        private static void WaitData()
        {
            for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 1) == 1); i++)
                ;

        }

        private static void WaitSignal()
        {
            for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 2) != 0); i++)
                ;
        }

        public enum MouseState
        {
            None = 0,
            Left = 1,
            Right = 2,
            Middle = 4
        }
        private static byte mouse_cycle = 0;
        private static int[] mouse_byte = new int[4];

        public static void HandleMouse(ref Interrupts.InterruptContext context)
        {
            switch (mouse_cycle)
            {
                case 0:
                    mouse_byte[0] = CPUBus.Read8(0x60);

                    if ((mouse_byte[0] & 0x8) == 0x8)
                        mouse_cycle++;

                    break;
                case 1:
                    mouse_byte[1] = CPUBus.Read8(0x60);
                    mouse_cycle++;
                    break;
                case 2:
                    mouse_byte[2] = CPUBus.Read8(0x60);
                    mouse_cycle = 0;

                    if ((mouse_byte[0] & 0x10) == 0x10)
                        X -= mouse_byte[1] ^ 0xff;
                    else
                        X += mouse_byte[1];

                    if ((mouse_byte[0] & 0x20) == 0x20)
                        Y += mouse_byte[2] ^ 0xff;
                    else
                        Y -= mouse_byte[2];

                    if (X < 0)
                        X = 0;
                    else if (X > 319)
                        X = 319;

                    if (Y < 0)
                        Y = 0;
                    else if (Y > 199)
                        Y = 199;

                    Buttons = (MouseState)(mouse_byte[0] & 0x7);

                    break;
            }
        }
    }

}

am getting no answers and I can't find anything on the internet. I have also uploaded the image to a new host (photobucket), so now there shouldn't be any issues.

Ok so i code my OS using Cosmos Milestone 4 and VS2010 with no errors but when I build it i keep getting these errors. I have googled it but to no avail. I have linked an image of it here. (I uploaded it to photobucket, so now it works)

My code is also provided below. If there are any problems with it, please tell. Thanks in advance.

using System;
using Cosmos.Hardware;
using Cosmos.Compiler.Builder;
using Cosmos.Kernel;

namespace MyOS
{
    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 int screennum = 1;
        public static uint sx;
        public static uint sy;
        public static uint ScreenWidth = 320;
        public static uint ScreenHeight = 200;
        public static uint p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24;
        public static bool MenuOpenEx = false;
        public static uint Pressed = 0;
        public static Image MenuSave = new Image(50, 30);
        public static Boolean MenuOpen = false;
        public static void SaveScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
        {
            uint n = 0;
            if (width > height)
            {
                for (uint x4 = 0; x4 < height; x4++)
                {
                    for (uint y4 = 0; y4 < width; y4++)
                    {
                        uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
                        image.SetPixel(xpos + x4, ypos + y4, I, n);
                        n += 1;
                    }
                }
            }
            if (width < height)
            {


                for (uint y4 = 0; y4 < width; y4++)
                {
                    for (uint x4 = 0; x4 < height; x4++)
                    {
                        uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
                        image.SetPixel(xpos + x4, ypos + y4, I, n);
                        n += 1;

                    }
                }
            }



        }
        public static void RestoreScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
        {
            uint n = 0;
            if (width > height)
            {
                for (uint x4 = 0; x4 < height; x4++)
                {
                    for (uint y4 = 0; y4 < width; y4++)
                    {

                        uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
                        VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
                        n += 1;
                    }
                }
            }
            if (width < height)
            {


                for (uint y4 = 0; y4 < width; y4++)
                {
                    for (uint x4 = 0; x4 < height; x4++)
                    {
                        uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
                        VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
                        n += 1;
                    }
                }
            }


        }
        public static void Init()
        {
            var xBoot = new Cosmos.Sys.Boot();
            xBoot.Execute();
            VGAScreen.SetMode320x200x8();
            VGAScreen.SetPaletteEntry(4, 0x00, 0x3C, 0x00);//Green
            VGAScreen.SetPaletteEntry(0, 0x00, 0x00, 0x00); //Black         
            VGAScreen.SetPaletteEntry(5, 50, 50, 50);//Grey
            VGAScreen.SetPaletteEntry(6, 236, 233, 216);//window color
            VGAScreen.SetPaletteEntry(7, 255, 248, 106);//light yellow
            VGAScreen.SetPaletteEntry(8, 255, 255, 255);//white
            VGAScreen.Clear(4);//Clear the screen to green for now!
            MouseEx.Initialize();//Initialize Mouse
            //Draw All Of Our Desktop setups here
            DrawWindowsBar();
            DrawWindowsStartButton();
            SaveScreen((uint)MouseEx.X, (uint)MouseEx.Y);
            MouseEnabled();//Call the mouse loop

        }
        //Our Desktop Drawing Voids
        public static void DrawWindowsBar()
        {

            DrawRect(0, ScreenHeight - 8, ScreenWidth, 8, 5); //Make a Gray Menu Bar!
            DrawRect(0, ScreenHeight - 8, ScreenWidth, 1, 8); //Add light to the bar like windows does!
        }
        public static void DrawWindowsStartButton()
        {
            //Ok this will be a little bit harder
            DrawRect(4, ScreenHeight - 5, 25, 4, 0);//Draw our black menu button!
        }
        public static bool CheckClick(uint x, uint y, uint Length, uint Width)
        {
            for (uint bb = x; bb < x + Length; bb++)
            {
                for (uint cc = y; cc < y + Width; cc++)
                {
                    if (MouseEx.X == bb && MouseEx.Y == cc)
                    {
                        return true;   //Return true if the area is not clicked                
                    }
                }
            }
            return false;   //Return false if the area is not clicked
        }
        public static void DrawRect(uint x, uint y, uint Width, uint Height, uint color)
        {

            for (uint bb = x; bb < x + Width; bb++)
            {

                for (uint cc = y; cc < y + Height; cc++)
                {
                    VGAScreen.SetPixel320x200x8(bb, cc, color);
                }
            }
        }
        public static void MouseEnabled()
        {

            bool PointerDrawn = false;
            uint x = (uint)MouseEx.X;
            uint y = (uint)MouseEx.Y;
            uint mx;
            uint my;
            Boolean moved = false;
            while (true)
            {
                mx = (uint)MouseEx.X;
                my = (uint)MouseEx.Y;


                if (mx != x || my != y || mx == x || my == y)
                {



                    if (MouseEx.Buttons == MouseEx.MouseState.Left)
                    {
                        ProcessCMD();

                    }


                    if (mx != x & my == y) // This Checks if mouse is moving                   
                    {
                        moved = true;
                    }

                    if (mx == x & my != y)// This Checks if mouse is moving                   
                    {
                        moved = true;
                    }

                    if (mx != x & my != y)// This Checks if mouse is moving                   
                    {
                        moved = true; //Tells our code that the Mouse is not drawn.                  
                    }

                }

                if (moved == true)
                {

                    if (moved == true)// This Checks if mouse is moving                       
                    {
                        PointerDrawn = true;
                        moved = false;
                    }
                    if (PointerDrawn == true)//Is the pointer Not Drawn?                   
                    {
                        RestoreScreen();
                        x = mx;
                        y = my;
                        SaveScreen(x, y);
                        PointerDrawn = false;
                        DrawPointer(mx, my);
                    }
                    else
                    {

                        DrawPointer(mx, my);
                    }
                }
            }
        }
        public static void DrawPointer(uint x, uint y)
        {
            VGAScreen.SetPixel320x200x8(x, y, 10);
            VGAScreen.SetPixel320x200x8(x + 1, y, 10);
            VGAScreen.SetPixel320x200x8(x + 2, y, 10);
            VGAScreen.SetPixel320x200x8(x, y + 1, 10);
            VGAScreen.SetPixel320x200x8(x, y + 2, 10);
            VGAScreen.SetPixel320x200x8(x + 1, y + 1, 10);
            VGAScreen.SetPixel320x200x8(x + 2, y + 2, 10);
            VGAScreen.SetPixel320x200x8(x + 3, y + 3, 10);
        }
        public static void SaveScreen(uint x, uint y)
        {
            sx = x;
            sy = y;
            //left pixesl
            p0 = VGAScreen.GetPixel320x200x8(sx, sy);
            p1 = VGAScreen.GetPixel320x200x8(sx, sy + 1);
            p2 = VGAScreen.GetPixel320x200x8(sx, sy + 2);
            p3 = VGAScreen.GetPixel320x200x8(sx, sy + 3);
            p4 = VGAScreen.GetPixel320x200x8(sx, sy + 4);

            //Second Set of Left pixels
            p5 = VGAScreen.GetPixel320x200x8(sx + 1, sy);
            p6 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 1);
            p7 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 2);
            p8 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 3);
            p9 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 4);
            //third set of left pixels

            p10 = VGAScreen.GetPixel320x200x8(sx + 2, sy);
            p11 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 1);
            p12 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 2);
            p13 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 3);
            p14 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 4);
            //last row of pixels

            p15 = VGAScreen.GetPixel320x200x8(sx + 3, sy);
            p16 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 1);
            p17 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 2);
            p18 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 3);
            p19 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 4);

            p20 = VGAScreen.GetPixel320x200x8(sx + 4, sy);
            p21 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 1);
            p22 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 2);
            p23 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 3);
            p24 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 4);
        }
        public static void RestoreScreen()
        {

            //left pixesl
            VGAScreen.SetPixel320x200x8(sx, sy, p0);
            VGAScreen.SetPixel320x200x8(sx, sy + 1, p1);
            VGAScreen.SetPixel320x200x8(sx, sy + 2, p2);
            VGAScreen.SetPixel320x200x8(sx, sy + 3, p3);


            //Second Set of Left pixels
            VGAScreen.SetPixel320x200x8(sx + 1, sy, p5);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 1, p6);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 2, p7);
            VGAScreen.SetPixel320x200x8(sx + 1, sy + 3, p8);
            //third set of left pixels

            VGAScreen.SetPixel320x200x8(sx + 2, sy, p10);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 1, p11);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 2, p12);
            VGAScreen.SetPixel320x200x8(sx + 2, sy + 3, p13);
            //last row of pixels

            VGAScreen.SetPixel320x200x8(sx + 3, sy, p15);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 1, p16);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 2, p17);
            VGAScreen.SetPixel320x200x8(sx + 3, sy + 3, p18);

            //Extra Layer of Pixels Just incase
            VGAScreen.SetPixel320x200x8(sx + 4, sy, p20);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 1, p21);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 2, p22);
            VGAScreen.SetPixel320x200x8(sx + 4, sy + 3, p23);

        }
        public static void ProcessCMD()
        {
            if (CheckClick(4, ScreenHeight - 5, 25, 4) == true)
            {
                if (MenuOpen == false)
                {
                    DrawMenu();
                    MenuOpen = true;
                }
                else
                {
                    UnDrawMenu();
                    MenuOpen = false;
                }
            }
        }
        public static void DrawMenu()
        {
            //Save the menu before we draw it

            SaveScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);
            //This is a simple math thing ScreenHeight - 8 Lets you draw simple right on top of our menu bar so you then need to - the Menus height.
            DrawRect(0, ScreenHeight - 8 - 50, 30, 50, 1);

        }
        public static void UnDrawMenu()
        {
            //To get rid of it just restore the saved screen
            RestoreScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);

        }
    }

    class Image
    {
        private uint[] Data;
        ///
        /// The height of the image.
        ///
        private int Height;
        ///
        /// The width of the image.
        ///
        private int Width;
        public Image(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        Image()
        {
            this.Width = 1;
            this.Height = 1;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        public uint GetPixel(uint x, uint y, uint n)
        {
            return this.Data[n];
        }
        public void SetPixel(uint x, uint y, uint p, uint n)
        {

            this.Data[n] = p;
        }
    }
    class MouseEx
    {
        public static int X, Y;
        public static MouseState Buttons;

        public static void Initialize()
        {

            //enable mouse
            WaitSignal();
            CPUBus.Write8(0x64, 0xA8);

            // enable interrupt
            WaitSignal();
            CPUBus.Write8(0x64, 0x20);
            WaitData();
            byte status = (byte)(CPUBus.Read8(0x60) | 2);
            WaitSignal();
            CPUBus.Write8(0x64, 0x60);
            WaitSignal();
            CPUBus.Write8(0x60, status);

            //default
            Write(0xF6);
            Read();  //Acknowledge

            //Enable the mouse
            Write(0xF4);
            Read();  //Acknowledge

            Interrupts.AddIRQHandler(12, new Interrupts.InterruptDelegate(HandleMouse));

        }

        public static byte GetMouseID()
        {
            CPUBus.Write8(0x64, 0xF2);
            return CPUBus.Read8(0x60);
        }

        private static byte Read()
        {
            WaitData();
            return CPUBus.Read8(0x60);
        }

        private static void Write(byte b)
        {
            //Wait to be able to send a command
            WaitSignal();
            //Tell the mouse we are sending a command
            CPUBus.Write8(0x64, 0xD4);
            //Wait for the final part
            WaitSignal();
            //Finally write
            CPUBus.Write8(0x60, b);
        }
        private static void WaitData()
        {
            for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 1) == 1); i++)
                ;

        }

        private static void WaitSignal()
        {
            for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 2) != 0); i++)
                ;
        }

        public enum MouseState
        {
            None = 0,
            Left = 1,
            Right = 2,
            Middle = 4
        }
        private static byte mouse_cycle = 0;
        private static int[] mouse_byte = new int[4];

        public static void HandleMouse(ref Interrupts.InterruptContext context)
        {
            switch (mouse_cycle)
            {
                case 0:
                    mouse_byte[0] = CPUBus.Read8(0x60);

                    if ((mouse_byte[0] & 0x8) == 0x8)
                        mouse_cycle++;

                    break;
                case 1:
                    mouse_byte[1] = CPUBus.Read8(0x60);
                    mouse_cycle++;
                    break;
                case 2:
                    mouse_byte[2] = CPUBus.Read8(0x60);
                    mouse_cycle = 0;

                    if ((mouse_byte[0] & 0x10) == 0x10)
                        X -= mouse_byte[1] ^ 0xff;
                    else
                        X += mouse_byte[1];

                    if ((mouse_byte[0] & 0x20) == 0x20)
                        Y += mouse_byte[2] ^ 0xff;
                    else
                        Y -= mouse_byte[2];

                    if (X < 0)
                        X = 0;
                    else if (X > 319)
                        X = 319;

                    if (Y < 0)
                        Y = 0;
                    else if (Y > 199)
                        Y = 199;

                    Buttons = (MouseState)(mouse_byte[0] & 0x7);

                    break;
            }
        }
    }

}

Coordinator
Sep 1, 2011 at 7:38 AM
First, I find it very rude that you post the same question 3 times. Already the first time, you got an reply (by me, but that's not the point) asking for more information. You finally supplied us with that info.

Now to your problem: MS4 is an ancient release: it's almost 3 years old. Next, MS4 was never supported on VS2010. It seems you're mixing releases though, as I think we didn't have the ManagedMemorySPace class yet back then, but really no way to tell....



On Thu, Sep 1, 2011 at 8:34 AM, Moin <notifications@codeplex.com> wrote:

From: Moin

I know I have posted this three times, but I am getting no answers and I can't find anything on the internet. I have also uploaded the image to a new host (photobucket), so now there shouldn't be any issues.

Ok so i code my OS using Cosmos Milestone 4 and VS2010 with no errors but when I build it i keep getting these errors. I have googled it but to no avail. I have linked an image of it here. (I uploaded it to photobucket, so now it works)

My code is also provided below. If there are any problems with it, please tell. Thanks in advance.

using System;
using Cosmos.Hardware;
using Cosmos.Compiler.Builder;
using Cosmos.Kernel;

namespace MyOS
{
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 int screennum = 1;
public static uint sx;
public static uint sy;
public static uint ScreenWidth = 320;
public static uint ScreenHeight = 200;
public static uint p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24;
public static bool MenuOpenEx = false;
public static uint Pressed = 0;
public static Image MenuSave = new Image(50, 30);
public static Boolean MenuOpen = false;
public static void SaveScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
{
uint n = 0;
if (width > height)
{
for (uint x4 = 0; x4 < height; x4++)
{
for (uint y4 = 0; y4 < width; y4++)
{
uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
image.SetPixel(xpos + x4, ypos + y4, I, n);
n += 1;
}
}
}
if (width < height)
{


for (uint y4 = 0; y4 < width; y4++)
{
for (uint x4 = 0; x4 < height; x4++)
{
uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
image.SetPixel(xpos + x4, ypos + y4, I, n);
n += 1;

}
}
}



}
public static void RestoreScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
{
uint n = 0;
if (width > height)
{
for (uint x4 = 0; x4 < height; x4++)
{
for (uint y4 = 0; y4 < width; y4++)
{

uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
n += 1;
}
}
}
if (width < height)
{


for (uint y4 = 0; y4 < width; y4++)
{
for (uint x4 = 0; x4 < height; x4++)
{
uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
n += 1;
}
}
}


}
public static void Init()
{
var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
VGAScreen.SetMode320x200x8();
VGAScreen.SetPaletteEntry(4, 0x00, 0x3C, 0x00);//Green
VGAScreen.SetPaletteEntry(0, 0x00, 0x00, 0x00); //Black
VGAScreen.SetPaletteEntry(5, 50, 50, 50);//Grey
VGAScreen.SetPaletteEntry(6, 236, 233, 216);//window color
VGAScreen.SetPaletteEntry(7, 255, 248, 106);//light yellow
VGAScreen.SetPaletteEntry(8, 255, 255, 255);//white
VGAScreen.Clear(4);//Clear the screen to green for now!
MouseEx.Initialize();//Initialize Mouse
//Draw All Of Our Desktop setups here
DrawWindowsBar();
DrawWindowsStartButton();
SaveScreen((uint)MouseEx.X, (uint)MouseEx.Y);
MouseEnabled();//Call the mouse loop

}
//Our Desktop Drawing Voids
public static void DrawWindowsBar()
{

DrawRect(0, ScreenHeight - 8, ScreenWidth, 8, 5); //Make a Gray Menu Bar!
DrawRect(0, ScreenHeight - 8, ScreenWidth, 1, 8); //Add light to the bar like windows does!
}
public static void DrawWindowsStartButton()
{
//Ok this will be a little bit harder
DrawRect(4, ScreenHeight - 5, 25, 4, 0);//Draw our black menu button!
}
public static bool CheckClick(uint x, uint y, uint Length, uint Width)
{
for (uint bb = x; bb < x + Length; bb++)
{
for (uint cc = y; cc < y + Width; cc++)
{
if (MouseEx.X == bb && MouseEx.Y == cc)
{
return true; //Return true if the area is not clicked
}
}
}
return false; //Return false if the area is not clicked
}
public static void DrawRect(uint x, uint y, uint Width, uint Height, uint color)
{

for (uint bb = x; bb < x + Width; bb++)
{

for (uint cc = y; cc < y + Height; cc++)
{
VGAScreen.SetPixel320x200x8(bb, cc, color);
}
}
}
public static void MouseEnabled()
{

bool PointerDrawn = false;
uint x = (uint)MouseEx.X;
uint y = (uint)MouseEx.Y;
uint mx;
uint my;
Boolean moved = false;
while (true)
{
mx = (uint)MouseEx.X;
my = (uint)MouseEx.Y;


if (mx != x || my != y || mx == x || my == y)
{



if (MouseEx.Buttons == MouseEx.MouseState.Left)
{
ProcessCMD();

}


if (mx != x & my == y) // This Checks if mouse is moving
{
moved = true;
}

if (mx == x & my != y)// This Checks if mouse is moving
{
moved = true;
}

if (mx != x & my != y)// This Checks if mouse is moving
{
moved = true; //Tells our code that the Mouse is not drawn.
}

}

if (moved == true)
{

if (moved == true)// This Checks if mouse is moving
{
PointerDrawn = true;
moved = false;
}
if (PointerDrawn == true)//Is the pointer Not Drawn?
{
RestoreScreen();
x = mx;
y = my;
SaveScreen(x, y);
PointerDrawn = false;
DrawPointer(mx, my);
}
else
{

DrawPointer(mx, my);
}
}
}
}
public static void DrawPointer(uint x, uint y)
{
VGAScreen.SetPixel320x200x8(x, y, 10);
VGAScreen.SetPixel320x200x8(x + 1, y, 10);
VGAScreen.SetPixel320x200x8(x + 2, y, 10);
VGAScreen.SetPixel320x200x8(x, y + 1, 10);
VGAScreen.SetPixel320x200x8(x, y + 2, 10);
VGAScreen.SetPixel320x200x8(x + 1, y + 1, 10);
VGAScreen.SetPixel320x200x8(x + 2, y + 2, 10);
VGAScreen.SetPixel320x200x8(x + 3, y + 3, 10);
}
public static void SaveScreen(uint x, uint y)
{
sx = x;
sy = y;
//left pixesl
p0 = VGAScreen.GetPixel320x200x8(sx, sy);
p1 = VGAScreen.GetPixel320x200x8(sx, sy + 1);
p2 = VGAScreen.GetPixel320x200x8(sx, sy + 2);
p3 = VGAScreen.GetPixel320x200x8(sx, sy + 3);
p4 = VGAScreen.GetPixel320x200x8(sx, sy + 4);

//Second Set of Left pixels
p5 = VGAScreen.GetPixel320x200x8(sx + 1, sy);
p6 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 1);
p7 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 2);
p8 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 3);
p9 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 4);
//third set of left pixels

p10 = VGAScreen.GetPixel320x200x8(sx + 2, sy);
p11 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 1);
p12 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 2);
p13 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 3);
p14 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 4);
//last row of pixels

p15 = VGAScreen.GetPixel320x200x8(sx + 3, sy);
p16 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 1);
p17 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 2);
p18 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 3);
p19 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 4);

p20 = VGAScreen.GetPixel320x200x8(sx + 4, sy);
p21 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 1);
p22 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 2);
p23 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 3);
p24 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 4);
}
public static void RestoreScreen()
{

//left pixesl
VGAScreen.SetPixel320x200x8(sx, sy, p0);
VGAScreen.SetPixel320x200x8(sx, sy + 1, p1);
VGAScreen.SetPixel320x200x8(sx, sy + 2, p2);
VGAScreen.SetPixel320x200x8(sx, sy + 3, p3);


//Second Set of Left pixels
VGAScreen.SetPixel320x200x8(sx + 1, sy, p5);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 1, p6);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 2, p7);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 3, p8);
//third set of left pixels

VGAScreen.SetPixel320x200x8(sx + 2, sy, p10);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 1, p11);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 2, p12);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 3, p13);
//last row of pixels

VGAScreen.SetPixel320x200x8(sx + 3, sy, p15);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 1, p16);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 2, p17);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 3, p18);

//Extra Layer of Pixels Just incase
VGAScreen.SetPixel320x200x8(sx + 4, sy, p20);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 1, p21);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 2, p22);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 3, p23);

}
public static void ProcessCMD()
{
if (CheckClick(4, ScreenHeight - 5, 25, 4) == true)
{
if (MenuOpen == false)
{
DrawMenu();
MenuOpen = true;
}
else
{
UnDrawMenu();
MenuOpen = false;
}
}
}
public static void DrawMenu()
{
//Save the menu before we draw it

SaveScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);
//This is a simple math thing ScreenHeight - 8 Lets you draw simple right on top of our menu bar so you then need to - the Menus height.
DrawRect(0, ScreenHeight - 8 - 50, 30, 50, 1);

}
public static void UnDrawMenu()
{
//To get rid of it just restore the saved screen
RestoreScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);

}
}

class Image
{
private uint[] Data;
///
/// The height of the image.
///
private int Height;
///
/// The width of the image.
///
private int Width;
public Image(int width, int height)
{
this.Width = width;
this.Height = height;
this.Data = new uint[(Height + 1) * (Width + 1)];
}
Image()
{
this.Width = 1;
this.Height = 1;
this.Data = new uint[(Height + 1) * (Width + 1)];
}
public uint GetPixel(uint x, uint y, uint n)
{
return this.Data[n];
}
public void SetPixel(uint x, uint y, uint p, uint n)
{

this.Data[n] = p;
}
}
class MouseEx
{
public static int X, Y;
public static MouseState Buttons;

public static void Initialize()
{

//enable mouse
WaitSignal();
CPUBus.Write8(0x64, 0xA8);

// enable interrupt
WaitSignal();
CPUBus.Write8(0x64, 0x20);
WaitData();
byte status = (byte)(CPUBus.Read8(0x60) | 2);
WaitSignal();
CPUBus.Write8(0x64, 0x60);
WaitSignal();
CPUBus.Write8(0x60, status);

//default
Write(0xF6);
Read(); //Acknowledge

//Enable the mouse
Write(0xF4);
Read(); //Acknowledge

Interrupts.AddIRQHandler(12, new Interrupts.InterruptDelegate(HandleMouse));

}

public static byte GetMouseID()
{
CPUBus.Write8(0x64, 0xF2);
return CPUBus.Read8(0x60);
}

private static byte Read()
{
WaitData();
return CPUBus.Read8(0x60);
}

private static void Write(byte b)
{
//Wait to be able to send a command
WaitSignal();
//Tell the mouse we are sending a command
CPUBus.Write8(0x64, 0xD4);
//Wait for the final part
WaitSignal();
//Finally write
CPUBus.Write8(0x60, b);
}
private static void WaitData()
{
for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 1) == 1); i++)
;

}

private static void WaitSignal()
{
for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 2) != 0); i++)
;
}

public enum MouseState
{
None = 0,
Left = 1,
Right = 2,
Middle = 4
}
private static byte mouse_cycle = 0;
private static int[] mouse_byte = new int[4];

public static void HandleMouse(ref Interrupts.InterruptContext context)
{
switch (mouse_cycle)
{
case 0:
mouse_byte[0] = CPUBus.Read8(0x60);

if ((mouse_byte[0] & 0x8) == 0x8)
mouse_cycle++;

break;
case 1:
mouse_byte[1] = CPUBus.Read8(0x60);
mouse_cycle++;
break;
case 2:
mouse_byte[2] = CPUBus.Read8(0x60);
mouse_cycle = 0;

if ((mouse_byte[0] & 0x10) == 0x10)
X -= mouse_byte[1] ^ 0xff;
else
X += mouse_byte[1];

if ((mouse_byte[0] & 0x20) == 0x20)
Y += mouse_byte[2] ^ 0xff;
else
Y -= mouse_byte[2];

if (X < 0)
X = 0;
else if (X > 319)
X = 319;

if (Y < 0)
Y = 0;
else if (Y > 199)
Y = 199;

Buttons = (MouseState)(mouse_byte[0] & 0x7);

break;
}
}
}

}

I know I have posted this twice, but I am getting no answers and I can't find anything on the internet. I have also uploaded the image to a new host (photobucket), so now there shouldn't be any issues.

Ok so i code my OS using Cosmos Milestone 4 and VS2010 with no errors but when I build it i keep getting these errors. I have googled it but to no avail. I have linked an image of it here. (I uploaded it to photobucket, so now it works)

My code is also provided below. If there are any problems with it, please tell. Thanks in advance.

using System;
using Cosmos.Hardware;
using Cosmos.Compiler.Builder;
using Cosmos.Kernel;

namespace MyOS
{
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 int screennum = 1;
public static uint sx;
public static uint sy;
public static uint ScreenWidth = 320;
public static uint ScreenHeight = 200;
public static uint p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24;
public static bool MenuOpenEx = false;
public static uint Pressed = 0;
public static Image MenuSave = new Image(50, 30);
public static Boolean MenuOpen = false;
public static void SaveScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
{
uint n = 0;
if (width > height)
{
for (uint x4 = 0; x4 < height; x4++)
{
for (uint y4 = 0; y4 < width; y4++)
{
uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
image.SetPixel(xpos + x4, ypos + y4, I, n);
n += 1;
}
}
}
if (width < height)
{


for (uint y4 = 0; y4 < width; y4++)
{
for (uint x4 = 0; x4 < height; x4++)
{
uint I = VGAScreen.GetPixel320x200x8(xpos + x4, ypos + y4);
image.SetPixel(xpos + x4, ypos + y4, I, n);
n += 1;

}
}
}



}
public static void RestoreScreenS(uint xpos, uint ypos, int width, int height, Image image, uint set)
{
uint n = 0;
if (width > height)
{
for (uint x4 = 0; x4 < height; x4++)
{
for (uint y4 = 0; y4 < width; y4++)
{

uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
n += 1;
}
}
}
if (width < height)
{


for (uint y4 = 0; y4 < width; y4++)
{
for (uint x4 = 0; x4 < height; x4++)
{
uint I4 = image.GetPixel(xpos + x4, ypos + y4, n);
VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);
n += 1;
}
}
}


}
public static void Init()
{
var xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
VGAScreen.SetMode320x200x8();
VGAScreen.SetPaletteEntry(4, 0x00, 0x3C, 0x00);//Green
VGAScreen.SetPaletteEntry(0, 0x00, 0x00, 0x00); //Black
VGAScreen.SetPaletteEntry(5, 50, 50, 50);//Grey
VGAScreen.SetPaletteEntry(6, 236, 233, 216);//window color
VGAScreen.SetPaletteEntry(7, 255, 248, 106);//light yellow
VGAScreen.SetPaletteEntry(8, 255, 255, 255);//white
VGAScreen.Clear(4);//Clear the screen to green for now!
MouseEx.Initialize();//Initialize Mouse
//Draw All Of Our Desktop setups here
DrawWindowsBar();
DrawWindowsStartButton();
SaveScreen((uint)MouseEx.X, (uint)MouseEx.Y);
MouseEnabled();//Call the mouse loop

}
//Our Desktop Drawing Voids
public static void DrawWindowsBar()
{

DrawRect(0, ScreenHeight - 8, ScreenWidth, 8, 5); //Make a Gray Menu Bar!
DrawRect(0, ScreenHeight - 8, ScreenWidth, 1, 8); //Add light to the bar like windows does!
}
public static void DrawWindowsStartButton()
{
//Ok this will be a little bit harder
DrawRect(4, ScreenHeight - 5, 25, 4, 0);//Draw our black menu button!
}
public static bool CheckClick(uint x, uint y, uint Length, uint Width)
{
for (uint bb = x; bb < x + Length; bb++)
{
for (uint cc = y; cc < y + Width; cc++)
{
if (MouseEx.X == bb && MouseEx.Y == cc)
{
return true; //Return true if the area is not clicked
}
}
}
return false; //Return false if the area is not clicked
}
public static void DrawRect(uint x, uint y, uint Width, uint Height, uint color)
{

for (uint bb = x; bb < x + Width; bb++)
{

for (uint cc = y; cc < y + Height; cc++)
{
VGAScreen.SetPixel320x200x8(bb, cc, color);
}
}
}
public static void MouseEnabled()
{

bool PointerDrawn = false;
uint x = (uint)MouseEx.X;
uint y = (uint)MouseEx.Y;
uint mx;
uint my;
Boolean moved = false;
while (true)
{
mx = (uint)MouseEx.X;
my = (uint)MouseEx.Y;


if (mx != x || my != y || mx == x || my == y)
{



if (MouseEx.Buttons == MouseEx.MouseState.Left)
{
ProcessCMD();

}


if (mx != x & my == y) // This Checks if mouse is moving
{
moved = true;
}

if (mx == x & my != y)// This Checks if mouse is moving
{
moved = true;
}

if (mx != x & my != y)// This Checks if mouse is moving
{
moved = true; //Tells our code that the Mouse is not drawn.
}

}

if (moved == true)
{

if (moved == true)// This Checks if mouse is moving
{
PointerDrawn = true;
moved = false;
}
if (PointerDrawn == true)//Is the pointer Not Drawn?
{
RestoreScreen();
x = mx;
y = my;
SaveScreen(x, y);
PointerDrawn = false;
DrawPointer(mx, my);
}
else
{

DrawPointer(mx, my);
}
}
}
}
public static void DrawPointer(uint x, uint y)
{
VGAScreen.SetPixel320x200x8(x, y, 10);
VGAScreen.SetPixel320x200x8(x + 1, y, 10);
VGAScreen.SetPixel320x200x8(x + 2, y, 10);
VGAScreen.SetPixel320x200x8(x, y + 1, 10);
VGAScreen.SetPixel320x200x8(x, y + 2, 10);
VGAScreen.SetPixel320x200x8(x + 1, y + 1, 10);
VGAScreen.SetPixel320x200x8(x + 2, y + 2, 10);
VGAScreen.SetPixel320x200x8(x + 3, y + 3, 10);
}
public static void SaveScreen(uint x, uint y)
{
sx = x;
sy = y;
//left pixesl
p0 = VGAScreen.GetPixel320x200x8(sx, sy);
p1 = VGAScreen.GetPixel320x200x8(sx, sy + 1);
p2 = VGAScreen.GetPixel320x200x8(sx, sy + 2);
p3 = VGAScreen.GetPixel320x200x8(sx, sy + 3);
p4 = VGAScreen.GetPixel320x200x8(sx, sy + 4);

//Second Set of Left pixels
p5 = VGAScreen.GetPixel320x200x8(sx + 1, sy);
p6 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 1);
p7 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 2);
p8 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 3);
p9 = VGAScreen.GetPixel320x200x8(sx + 1, sy + 4);
//third set of left pixels

p10 = VGAScreen.GetPixel320x200x8(sx + 2, sy);
p11 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 1);
p12 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 2);
p13 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 3);
p14 = VGAScreen.GetPixel320x200x8(sx + 2, sy + 4);
//last row of pixels

p15 = VGAScreen.GetPixel320x200x8(sx + 3, sy);
p16 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 1);
p17 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 2);
p18 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 3);
p19 = VGAScreen.GetPixel320x200x8(sx + 3, sy + 4);

p20 = VGAScreen.GetPixel320x200x8(sx + 4, sy);
p21 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 1);
p22 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 2);
p23 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 3);
p24 = VGAScreen.GetPixel320x200x8(sx + 4, sy + 4);
}
public static void RestoreScreen()
{

//left pixesl
VGAScreen.SetPixel320x200x8(sx, sy, p0);
VGAScreen.SetPixel320x200x8(sx, sy + 1, p1);
VGAScreen.SetPixel320x200x8(sx, sy + 2, p2);
VGAScreen.SetPixel320x200x8(sx, sy + 3, p3);


//Second Set of Left pixels
VGAScreen.SetPixel320x200x8(sx + 1, sy, p5);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 1, p6);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 2, p7);
VGAScreen.SetPixel320x200x8(sx + 1, sy + 3, p8);
//third set of left pixels

VGAScreen.SetPixel320x200x8(sx + 2, sy, p10);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 1, p11);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 2, p12);
VGAScreen.SetPixel320x200x8(sx + 2, sy + 3, p13);
//last row of pixels

VGAScreen.SetPixel320x200x8(sx + 3, sy, p15);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 1, p16);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 2, p17);
VGAScreen.SetPixel320x200x8(sx + 3, sy + 3, p18);

//Extra Layer of Pixels Just incase
VGAScreen.SetPixel320x200x8(sx + 4, sy, p20);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 1, p21);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 2, p22);
VGAScreen.SetPixel320x200x8(sx + 4, sy + 3, p23);

}
public static void ProcessCMD()
{
if (CheckClick(4, ScreenHeight - 5, 25, 4) == true)
{
if (MenuOpen == false)
{
DrawMenu();
MenuOpen = true;
}
else
{
UnDrawMenu();
MenuOpen = false;
}
}
}
public static void DrawMenu()
{
//Save the menu before we draw it

SaveScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);
//This is a simple math thing ScreenHeight - 8 Lets you draw simple right on top of our menu bar so you then need to - the Menus height.
DrawRect(0, ScreenHeight - 8 - 50, 30, 50, 1);

}
public static void UnDrawMenu()
{
//To get rid of it just restore the saved screen
RestoreScreenS(0, ScreenHeight - 8 - 50, 50, 30, MenuSave, 0);

}
}

class Image
{
private uint[] Data;
///
/// The height of the image.
///
private int Height;
///
/// The width of the image.
///
private int Width;
public Image(int width, int height)
{
this.Width = width;
this.Height = height;
this.Data = new uint[(Height + 1) * (Width + 1)];
}
Image()
{
this.Width = 1;
this.Height = 1;
this.Data = new uint[(Height + 1) * (Width + 1)];
}
public uint GetPixel(uint x, uint y, uint n)
{
return this.Data[n];
}
public void SetPixel(uint x, uint y, uint p, uint n)
{

this.Data[n] = p;
}
}
class MouseEx
{
public static int X, Y;
public static MouseState Buttons;

public static void Initialize()
{

//enable mouse
WaitSignal();
CPUBus.Write8(0x64, 0xA8);

// enable interrupt
WaitSignal();
CPUBus.Write8(0x64, 0x20);
WaitData();
byte status = (byte)(CPUBus.Read8(0x60) | 2);
WaitSignal();
CPUBus.Write8(0x64, 0x60);
WaitSignal();
CPUBus.Write8(0x60, status);

//default
Write(0xF6);
Read(); //Acknowledge

//Enable the mouse
Write(0xF4);
Read(); //Acknowledge

Interrupts.AddIRQHandler(12, new Interrupts.InterruptDelegate(HandleMouse));

}

public static byte GetMouseID()
{
CPUBus.Write8(0x64, 0xF2);
return CPUBus.Read8(0x60);
}

private static byte Read()
{
WaitData();
return CPUBus.Read8(0x60);
}

private static void Write(byte b)
{
//Wait to be able to send a command
WaitSignal();
//Tell the mouse we are sending a command
CPUBus.Write8(0x64, 0xD4);
//Wait for the final part
WaitSignal();
//Finally write
CPUBus.Write8(0x60, b);
}
private static void WaitData()
{
for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 1) == 1); i++)
;

}

private static void WaitSignal()
{
for (int i = 0; i < 1000 & ((CPUBus.Read8(0x64) & 2) != 0); i++)
;
}

public enum MouseState
{
None = 0,
Left = 1,
Right = 2,
Middle = 4
}
private static byte mouse_cycle = 0;
private static int[] mouse_byte = new int[4];

public static void HandleMouse(ref Interrupts.InterruptContext context)
{
switch (mouse_cycle)
{
case 0:
mouse_byte[0] = CPUBus.Read8(0x60);

if ((mouse_byte[0] & 0x8) == 0x8)
mouse_cycle++;

break;
case 1:
mouse_byte[1] = CPUBus.Read8(0x60);
mouse_cycle++;
break;
case 2:
mouse_byte[2] = CPUBus.Read8(0x60);
mouse_cycle = 0;

if ((mouse_byte[0] & 0x10) == 0x10)
X -= mouse_byte[1] ^ 0xff;
else
X += mouse_byte[1];

if ((mouse_byte[0] & 0x20) == 0x20)
Y += mouse_byte[2] ^ 0xff;
else
Y -= mouse_byte[2];

if (X < 0)
X = 0;
else if (X > 319)
X = 319;

if (Y < 0)
Y = 0;
else if (Y > 199)
Y = 199;

Buttons = (MouseState)(mouse_byte[0] & 0x7);

break;
}
}
}

}

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2011 at 10:04 AM
Edited Sep 1, 2011 at 10:11 AM

I installed the latest version of COSMOS (User Kit), but now I am faced with another problem. VGAScreen is underlined in red in the code and the error is saying "The name 'VGAScreen' does not exist in the current context".
The other problem is that the word 'Interrupts' in the line "Interrupts.AddIRQHandler(12, new Interrupts.InterruptDelegate(HandleMouse));" is underlined in red and gives an error saying " The Type or namespace 'Interrupts' could not be found (are you missing a using directive or an assembly reference?)"

N.B. My Code is still the same as what I posted in my first post.

Coordinator
Sep 1, 2011 at 10:09 AM
Since MS4, we changed the way our builder works, so you have to start with a new cosmos project, and port your code over.

regarding VGAScreen: it was removed from the release (which is also a year old now)

Are you using VS express or one of the paid editions? If you're having one of the paid editions, you'd be better of getting the devkit (source package) and building cosmos yourself.

On Thu, Sep 1, 2011 at 12:04 PM, Moin <notifications@codeplex.com> wrote:

From: Moin

I installed the latest version of COSMOS (User Kit), but now I am faced with another problem. VGAScreen is underlined in red in the code and the error is saying "The name 'VGAScreen' does not exist in the current context".

N.B. My Code is still the same as what I posted before.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2011 at 10:15 AM

ok thanks, so by porting your code over you mean copy and paste it? and since VGAScreen has been removed, is there anything I can use instead? I am using VS 2010 Ultimate.

Coordinator
Sep 1, 2011 at 10:17 AM
Copy your code over, yes.

As you're using ultimate: go install the devkit.

On Thu, Sep 1, 2011 at 12:15 PM, Moin <notifications@codeplex.com> wrote:

From: Moin

ok thanks, so by porting your code over you mean copy and paste it? and since VGAScreen has been removed, is there anything I can use instead? I am using VS 2010 Ultimate.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2011 at 10:18 AM

ok I will install now and reply if I have any more problems. Thanks for all the help so far.

Sep 1, 2011 at 10:27 AM
Edited Sep 1, 2011 at 10:59 AM

ok I know this may be a stupid question but can you give me the link to downloading the devkit. Everywhere I go it redirects me to the UserKit.

Coordinator
Sep 1, 2011 at 10:51 AM
on codeplex the Sourcecontrol tab.

On Thu, Sep 1, 2011 at 12:27 PM, Moin <notifications@codeplex.com> wrote:

From: Moin

ok I know this may be a stupid question but can you give me the link to downloading the devkit. Everywhere I go it redirects me to the UserKit.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2011 at 10:58 AM

Thanks

Sep 1, 2011 at 11:55 AM

ok yeah i downloaded and installed it, but now I am lost I am using the project that was supplied "Cosmos.sln" but I am lost as this is nothing like the User Kit. Where do I start? If you have any manuals or guides that I can refer to can you tell me, thanks.

Sep 2, 2011 at 11:57 AM

Actually I have figured it out. Thanks for the other help.