Skip to content →

adding ui elements

Despite there being a lot of better, cross-platform options, I went with using WinAPI for my UI elements. This was a decision I made, because I didn’t want to implement another library at that moment, and wanted to keep the emulator itself lightweight, so I would be able to port and use it for some later projects (projects that I will announce and talk about here, soon).

main

As I want to be able to load my ROMs, without having to change the String in the code every time, I added a simple file selection dialog, to have an “load rom” option. To load a new ROM, we need to reset our emulator of course (clearing the memory and the flags, pc, etc.), so why not adding it as a feature to the menu as well. The obligatory “exit” function of course was added as well.

config

volume

Of course we want to let the user regulate the volume in 10% increments.

debugging

WinAPI let’s you make use of the native Windows components of windows and menus. Pretty early in the development process, I wanted to have the ability to check my memory without having to use breakpoints and watchdogs in my IDE, and check if my according layers from my PPU were correct. That’s why I implemented a few debugging features.

sprite map | bg map | window map | tiledata

The graphical debugging was just setting up more windows with SDL, and printing only the individual single layer to it (or just the blank VRAM data, for the tiledata window).

The actual debugger, consists out of simple elements from WinAPI, that are filled with values of registers, flags, and important memory addresses. Additionally, I implemented a complete memory map.

q00.gb – debugger

Comments

  1. Jimmy Yang Jimmy Yang

    How did you incorporate your SDL window into the Win32 window? Does emulation happen in a different thread than the main thread?

  2. LilaQ LilaQ

    No, the emulation is running single-thread completely (which is absolutely no problem for emulating the GameBoy).
    You can pass the *SDL_Window to the Win32 API (formatting will be horrible in the comments, but something like that):

    SDL_Window* getWindow() {
    return window; // this is used in SDL init
    }

    mainWindow = getWindow();
    char title[50];
    SDL_SetWindowTitle(mainWindow, title);
    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(mainWindow, &wmInfo);
    HWND hwnd = wmInfo.info.win.window;

Leave a Reply to LilaQ Cancel reply

Your email address will not be published. Required fields are marked *