AEOSgui 23 Comments

12:09 am on December 12, 2009

Yay, a new version!

More goodies for you to enjoy!

http://www.ertnerd.com/source.zip

(please note that the link will never really change… unless I say so.)

Pings

  1. xanti

Comments (23) ↓ Add Comment

  1. Jack says:

    How to make a gui with cosmos? Can You tell me?

  2. Mr. Ertnerd says:

    it can get pretty advanced, but all you really need to know is how to get user input and display stuff on the screen.

    For adding a single pixel, you would add all the usual ‘using’ stuff.
    also add “using Cosmos.Hardware; using Screen = Cosmos.Hardware.VGAScreen;”
    Then somewhere before the main loop (which can be as simple as “while(true) { }”)
    add “Screen.SetPaletteEntry(int index, byte r, byte g, byte b);” //this declares what color is assigned to the index number. I don’t think there is a standard, but there may be.) Add this line for each color you want, adjusting the color values, and change the index number. You can have up to 256 (0-255) colors in COSMOS because all the color declarations are stored in a single byte.
    After that you add
    “Screen.SetMode320x200x8();
    Screen.Clear(int colorIndex);” //this sets the screen size and then colors the whole screen a single color.
    Somewhere within the main loop add
    “Screen.SetPixel320x200x8(uint x, uint y, uint color);”
    //this actually makes a certain pixel a different color!

    However, early on in my experimentation, I discovered that just coloring each pixel when you draw something, actually creates a flashing effect… which is very, not good.

    So, to fix the issue, I created a simple buffer.
    “private static uint[] screenbuffer = new uint[512000];”
    //you get 512000 from 320 * 200 * 8 //the screen size//yeah you need the 8 too
    now instead of calling SetPixel320x200x8(…); you would use
    screenbuffer[y * 320 + x] = uint color;
    and for actually drawing the buffer onto the screen, create a function that is called at the end of the main loop and sends the buffer to the screen.
    public static void reDrawScreen() {
    for (uint x = 0; x < 320; x++)
    {for (uint y = 0; y < 200; y++){
    uint num = y * 320 + x;
    Screen.SetPixel320x200x8(x, y, screenbuffer[num]);
    screenbuffer[num] = 0;} } }

    Now you just need some functions that draw different shapes. (so far I can only draw rectangles and pre-rendered images [kind of like bitmaps, only my own style])

    For mouse support, I just have another function called before the reDrawScreen().
    to get the x and y pos of the mouse, just use Cosmos.Hardware.Mouse.X and Cosmos.Hardware.Mouse.Y;
    using your basic shapes (or editing the buffer directly in the mouse function) you can draw a cursor at that position, and check for what mouse buttons are being pressed.
    "switch(Mouse.Buttons)" along with all the cases (Mouse.MouseState.Left, Mouse.MouseState.Right, Mouse.MouseState.Middle, Mouse.MouseState.None)

    Oh, and one thing else, memory is always limited, so you will have to make some way of clearing the memory..
    I edited Cosmos.Kernel.Heap by making the first few variables public [instead of private] so that I can do just that.
    if (Cosmos.Kernel.Heap.mStartAddress >= (Cosmos.Kernel.Heap.mEndOfRam / 100) * 88){
    Cosmos.Kernel.Heap.mStartAddress = starter;} //just a simple way of cleaning house…
    Please note that this is more of a temporary fix, and can cause A LOT of bugs, EVEN TOTAL CRASHING. But for the most part it gets the job done.

    If you have any questions, just ask. :)

  3. Milo says:

    Wow, I was actually looking for a GUI for Cosmos in Google but couldn’t find it. It’s great that you’ve already started the work and it’s so advanced. Cosmos is a very promising and exciting project, I hope you’ll continue your work. :)

    Downloading that 70 megs now…

    • Mr. Ertnerd says:

      yeah… I had to re-upload the entire COSMOS project because I made a few modifications to it, and people were having issues with the latest revisions and such.

      • Weirdnes222222222222 says:

        I’m editing this right now! I went back to C#. I love it, and I am trying to make a .PNG file into the background. Shouldn’t be hard, but first I need to find out where you put the background code lines in the project :S
        I’ll find it!
        PS. adding Google Chrome OS References to make a web browser, Whoot Yhea!

  4. Matt says:

    Hi! I was wondering whether it is possible to still use the Console.WriteLine and Console.ReadLine functions if you make use of the VGAScreen class? Or does it have it’s own custom functions for handling text i/o?

    • Mr. Ertnerd says:

      Yes, you can (in a way) with the VGAScreen, but in order to see what’s on the console, you will have to modify a few things in the Dev Kit.
      Instead of using Console.Read(); I use Cosmos.Hardware.Keyboard.ReadString(); (you can also use …ReadChar(); or …ReadKey();)
      The functions actually wait until they receives input, and since COSMOS so far only deals with a single thread, your whole GUI will freeze until there is input…
      So you will have to edit Cosmos.Hardware.Keyboard (basically get rid of the while loops in the ReadString(); ReadChar(); and ReadKey(); functions)
      Otherwise the Console.WriteLine(); function stays the same, however I cannot figure out how to get it onto the screen,
      so instead of using Console.WriteLine(); I would make a string that has all the console text in it and use that to make a console in your GUI.

      • Matt says:

        Thanks for the reply! I’m currently implementing a class that handles the GUI, and it works by having everything displayed on screen a subclass of a ‘core’ object (in this case, GUIObject). All of these objects are added to a rendering stack for the OS to draw – the only problem is memory, does COSMOS already have a memory manager or can I implement one myself (although I’d rather not edit the source code of COSMOS just yet – i’m not fully experienced with C#).

        Thanks,
        Matt.

        • Mr. Ertnerd says:

          I think I heard something about it (or I was mistaken) but I have yet to find it…
          For now I have implemented my own memory manager (which is very basic, and sets the current position in the memory back to the beginning (after the kernel) when the memory gets up to 88% full)
          In order to do what I did, I’ve changed the first four variables to public [instead of private] in Cosmos.Kernel.Heap
          //when setting everything up and before entering main loop
          uint starter = Cosmos.Kernel.Heap.mStartAddress * 2;

          //whenever you want to check memory
          if (Cosmos.Kernel.Heap.mStartAddress >= (Cosmos.Kernel.Heap.mEndOfRam / 100) * 88)
          {
          Cosmos.Kernel.Heap.mStartAddress = starter;
          }
          //note that mStartAddress and mEndOfRam
          //are the two variables that only need
          //to be changed in Cosmos.Kernel.Heap
          //but you can change the others if you want

          • Matt says:

            Thanks! I’ve managed to implement the memory hack, but I’m still struggling with another problem concerning the List type. I have the following code:

            public struct Pixel // Represents a pixel on screen
            {
            public uint ColourID;
            public uint X;
            public uint Y;
            }

            // In a seperate class

            public List CreatePixels()
            {
            List Contents = new List();
            Contents.Add(new Pixel {ColourID = 1, X = 0, Y = 0});
            return Contents;
            }

            Everytime I run the OS, the result of CreatePixels() contains way more than the number of add statements used… is it something to do with the way I’ve programmed it, or a fault of Cosmos?

          • Mr. Ertnerd says:

            I don’t think I’ve ever used public struct (I learn something new everyday)

            public List < *Pixel> CreatePixels()
            {
            List < *Pixel> Contents = new List < *Pixel>(); //… only without the *’s.. it’s just HTML…

            or try a different way, find a workaround if the above still won’t work…

  5. Weirdnes222222222222 says:

    HAI!!!!
    Which subfolder is the project? i open something up and it’s wrong ):

  6. [..] A little unrelated, but I rather liked this site post [..]

  7. loans says:

    I want to thank the blogger very much not only for this post but also for his all previous efforts. I found http://www.ertnerd.com to be greatly interesting. I will be coming back to http://www.ertnerd.com for more information.

  8. Steve Mabbutt says:

    This is amazing, it’s exactly what i’ve been looking for and i can’t thank you enough!

  9. Adobe says:

    Very great report, very clear, deep analyze and easy to understand.
    Thank for your share.

  10. OEMSoftware says:

    Thank you for this information. You have done a great job. So many figures, everything is so exactly. Now we can see all demografic picture of the alection.Thank you for highlighting this. Keep up your work.

  11. OEMSoft says:

    Really informative post. Thanks for sharing

  12. djnaff says:

    This is my first visit here, but I will be back soon, because I really like the way you are writing, it is so simple and honest

  13. i am in general jumping all around the web most of the day so I choose to peruse a bunch, which isnt commonly a beneficial matter as the largest part of the internet sites I visit are constructed of pointless trash copied from similar internet websites a thousand times, nevertheless I gotta give you props this webpage is in truth not bad at all and has some unique information, for that reason thanks for breaking the fad of solely copying other individual’s blogs and forums, if you ever wanna play a couple of hands of facebook poker together just hit me up – you have my email :)

Leave a Reply

You must be logged in to post a comment.