Projects Jams Discord News
Resources
Unwind Fishbowls Forums
About
Manifesto Our values About
Log In

Cylinder-head-sector Addressing

nakst July 7, 2021

=== Introduction ===

Modern day secondary storage drives, like SSDs, divide up their storage space into fixed-sized sectors. On floppy disks and old hard disks, each sector was 512 bytes (these days they're 4KB each). When the operating system wants to access the drive, it needs to specify the sector it wants to access. Sectors are numbered from 0 up to X-1, where X is the total number of sectors on the drive. The number of a sector is called its logical block address, or LBA for short. The total storage capacity of a drive is calculated as X * sector_size.

However, it wasn't always this way. Sectors used to be addressed using three numbers, which for now we'll call C, H and S. In this blog post, I'm going to try to explain how this works, and why I hate it. This post will only cover CHS on IBM PCs; it might have worked differently on your favourite system of yore.

[b]=== Converting between CHS and LBA ===[/

Read more

Generating polygon outlines

nakst June 30, 2020

Generating polygon outlines

Recently I wrote a small 2D vector graphics renderer for Essence. It's currently only used for drawing binary SVG icons (previously I used the renderer in nanosvgrast.h), but I plan to use it for a custom animatable icon format, and also expose its functionality through the API directly. For the actual rasterization process, it uses a method closely adapted from stb_truetype.h, which you can read more about in Sean Barrett's article. In this blog post I'm going to discuss how my renderer generates outlines of polygons to draw lines.

The two functions that handle generating outlines are RastShapeCreateContour and RastShapeCreateDashed, which create solid and dashed lines respectively. They both take a RastPath as an argument, which is simply a

Read more

Drivers Roadmap - Help Needed!

nakst July 2, 2019

Hello all. I haven't made a blog post in quite a while since I've been very busy recently, but luckily things are back to normal and hopefully progress can resume at its original pace.

I've drafted a roadmap of all the drivers that I think a functional operating system needs, and marked which ones are already usable.

[code] Buses PCI - Usable USB - Usable Human interface devices PS2 - Usable USB mouse/keyboard - Usable Storage ATA - Usable ATAPI (CD/DVD drives) - Read only; does not yet support ejecting discs SATA - Usable NVMe - Usable USB mass storage devices - Usable Filesystems EsFS - Essence's custom filesystem ISO9660 - Usable FAT12 - Read only FAT32 - Read only NTFS - Read only ext2 - Read only Sound Intel HD Audio - Output to speakers only Graphics (these are too complex to write from scratch, will need to be ported) VGA w/ software rendering - Usable BIOS mode setting w/ software rendering - Usable UEFI mode setting w/ softwar

Read more

Text

nakst December 16, 2018

Click to zoom in.

The OS currently uses FreeType for text rendering. Although I originally used stb_truetype, it unfortunately was not able to produce text of comparable quality to other modern operating systems. This lead me to porting FreeType to the OS. In this blog post I'll explain how building and porting FreeType works, which'll hopefully help people implement it into their own programs.

Downloading FreeType

FreeType can be downloaded from their website, www.freetype.org. I haven't yet updated to version 2.9.1 (still using 2.9), but it shouldn't matter which version you download. Once you've got the source, all you need to do is extract it. The OS's build system automatically downloads and extracts the source in these three UNIX commands:

[code] curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > freetype-2.9.tar.

Read more

Automatic UI Layouts (part 2)

nakst October 6, 2018

This is a continuation of part 1.

Flow layout mode

In the previous blog post, we discussed the table layout mode, where the layout element is divided into a grid with a fixed number of columns and rows.

However, this may not be how we want to layout our UI.

Consider a file manager:

This would be difficult to layout with a table. We'd either have to make two tables (a 2x1 table containing the navigation pane and folder contents, and 1x3 table containing the toolbar, the other table and the status bar), or use multi-cell positioning.

This layout would be more naturally achieved as: [ul]

  • Toolbar (OS_CELL_H_PUSH | OS_CELL_H_EXPAND)
  • Start new row
  • Navigation pane (OS_CELL_V_PUSH | OS_CELL_V_EXPAND)
  • Folder contents (OS_CELL_H_PUSH | OS_CELL_H_EXPAND | OS_CELL_V_PUSH | OS_CELL_V_EXPAND)
  • [li]Start new

    Read more

    Automatic UI Layouts (part 1)

    nakst October 5, 2018

    Over the past week I've been thinking about UI layouts. In this blog post I'll discuss what I think the best way to do automatic UI layouts is. This system is based of this project's GUI library, but keep in mind not all of these features have been implemented; this blog post is mostly theoretical.

    Manual vs automatic

    There are 2 types of UI layouts, manual and automatic. In a manual layout, the programmer must specify where each UI element is placed themselves. This is notably used in the Windows Desktop API:

    CreateWindow("Button", "OK", WS_CHILD | WS_VISIBLE,
       16, 16, 80, 23, /*x, y, width, height*/
       window, NULL, instance, NULL
    );
    

    This is as flexible as it's possible to get, but unfortunately it has many drawbacks. For example, you have to do DPI scaling manually, you have to know the correct sizes of each standard control, you have to work out the gaps between elements, etc.

    Therefore it's probably better to have automatic UI lay

    Read more

    Rewriting and refactoring

    nakst September 30, 2018

    Over the last months I haven't added many new features. It's mostly been rewriting and improving existing code.

    Primarily, there's a new memory manager, and the GUI's been simplified. However, there are two new features I want to show off.

    Blackjack

    I added a small Blackjack game to the OS.

    SDL backend

    The GUI can now run with a very-much-work-in-progress SDL backend on Windows.

    If you want to try it out:

    1. Download the project's source
    2. Copy SDL2, Freetype, and GLEW includes and libraries to the sdl/ folder
    3. Put the DLLs at the root
    4. Run build.bat from a VS command prompt

    Your sdl/ folder should contain the following files:

    Thanks for reading! Hopefully there will be some more interesting news next month :)

    Read more

    Contributing

    nakst August 21, 2018

    I've started to write up some documentation for the OS on the project's wiki.

    If you want to help out with the project, I recommend you first read all the current documentation to get an overview of how the API and GUI work. Also see if you can complete the Getting Started tutorial.

    After that, here is a list of things you could work on:

    • Rewrite the multi-line textbox control
    • Rewrite the image viewer
    • Making a modern dark-mode visual style
    • ... And possibly more things

    If any of those sound interesting, please visit #essence on the Handmade Network Discord where I can give more information. Furthermore, if you have any feedback on the documentation, please talk to me about it there as well.

    Thanks!

    Read more

    Writing a Simple Text Editor

    nakst July 26, 2018

    I recently decided to make a version of "Notepad" for my OS, and it's mostly done now. To take a deeper look into using the OS's API, I'll walk you through how you could recreate the program. (Note: the API is still under constant revision, so any information presented in this blog could change at any time...)

    We can start by creating a manifest file. The build system should automatically find it. Let's add a definition for the program.

    text_editor/text_editor.manifest

    
    name = "Text Editor";
    shortName = "text_editor";
    systemMessageCallback = ProcessSystemMessage;
    

    This specifies the name of the program, its internal name, and the subroutine that will receive system messages. We'll take a look at this later.

    Next we include information about how to build the program.

    [code language=INI] [build] output = "Text Editor.esx"; source = "text_editor/main.cpp"; installationFolder = "/Programs/Text Editor/"; Install; [/cod

    Read more

    Plans

    nakst June 9, 2018

    Although I can't remember exactly when I started this project, it was approximately 11 months ago. Which means we're approaching the 1st year anniversary of development!

    By the first anniversary I want to get the OS running on real hardware. The things I still need to do for this are:

    • AHCI driver (the old one was buggy)
    • Proper VBE graphics mode selection
    • GPT partition table support
    • Possibly EFI booting?
    • Fixing whatever bugs we find!!

    That's a worryingly long list, especially as I'm a bit busy this week. But hopefully I'll manage to get something working :)

    For now though, here's a screenshot of some things I've been working on....

    I think it's still a little to early to ask for collaborators, but perhaps in the upcoming year it'll be possible to have more developers working on the project - if anyone's interested, of course :)


    Read more

    Hello, world!

    nakst May 9, 2018

    Let's take a look at what it takes to write a simple "Hello, world!" GUI program for my operating system.

    First, we need to write a manifest file. All we need to do is declare the properties for our main window, and how to build the program.

    hello_world/hello_world.manifest

    
    output = "Hello World.esx";
    source = "hello_world/main.cpp";
    
    
    title = "Hello, world!";
    

    [window mainWindow] title = "Hello, world!"; [/code]

    Then, we write the program itself.

    hello_world/main.cpp [code] // Include the API header. #include "../api/os.h"

    // Include the automatically-generated manifest header. #define OS_MANIFEST_DEFINITIONS #include "../bin/OS/hello_world.manifest.h"

    void ProgramEntry() { // Create a window using the mainWindow template from the manifest. OSObject window = OSCreateWindow(mainWindow);

    // Create a container grid, and make it the window's root grid.
    OSObject grid = OSCreateGrid(1, 1, OS_GRID_STYLE_CONTAINER);
    OSSetRootGrid(window, grid);
    
    Read more

    The Filesystem, Version 1

    nakst April 9, 2018

    The Filesystem, Version 1

    What is a filesystem?

    As far as your drive is concerned, there is no such thing as a "file" or "folder". Drives divide up their space into equally-sized sectors, 512 bytes each.

    (This number, 512 bytes, originates from the sector size on floppy disks. Modern drives have larger sectors behind the scenes. However, drivers send commands to the drive controllers with a precision of 512-byte blocks. As far as the filesystem driver should be considered, sectors are 512 bytes each.)

    This isn't very useful for users. They want to have hierachical folders which contain files, where each node stores metadata, such as names, modification dates, access permissions, etc.

    To achieve this, a layer needs to be inserted between programs and the drive controller drivers. Filesystem drivers must be introduced to provide this functionality.

    There are several different filesystems, such as FAT32, ext4, and NTFS.

    Read more