diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ce6aaf..25ac19d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(chisel8 C) # SET C STANDARD, COMPILER AND OPENGL VERSION set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_COMPILER clang) +#set(CMAKE_CXX_COMPILER clang) # MAYBE NOT NEEDED? option(ANGLE "Enable ANGLE support") if (NOT CMAKE_BUILD_TYPE) diff --git a/README.md b/README.md index 4a14f19..6f67771 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,12 @@ Currently, all opcodes are implemented and all of them except for a few work as - [X] Settings.txt to change background and pixel color values as well as the display scaling - [X] Chip-8 Audio emulation (it's just a beep...) - [X] Correct keypad input -- [ ] Settings panel to change color, display scale and debug/FPS info in the application +- [X] Settings panel to change color, display scale and debug/FPS info in the application - [ ] Loading previous ROM files for quick access via "Load ROM" -- *Scrapped*: ~~External Debug window to show RAM contents, fetched/executed opcodes etc.~~ +- [ ] Custom Font support (via external binary file or other means) + + +**Scrapped**: ~~External Debug window to show RAM contents, fetched/executed opcodes etc.~~ ``` Please report any bugs via GitHub on the issue page. Thank you! @@ -82,20 +85,16 @@ the ANGLE dylib files into the `build` dir, so it can load them. Remember to run --- ### Windows -**WARNING:** I do not own a device that runs on Windows. These instructions might not work. +**Info:** I do not own a device that runs on Windows. These instructions might not work. If there are any issues, feel free to open an issue & PR request. **Requirements:** -- Git (https://git-scm.com/) -- MinGW-w64 (https://www.mingw-w64.org/) -- CMake (https://cmake.org/download/) +1. Git (https://git-scm.com/) +2. MinGW-w64 (https://www.mingw-w64.org/) +3. CMake (https://cmake.org/download/) **Follow these steps to install MinGW-w64 for Windows:** https://code.visualstudio.com/docs/cpp/config-mingw#_installing-the-mingww64-toolchain -Change the default compiler to use in CMakeList.txt to the following: -```cmake -set(CMAKE_CXX_COMPILER gcc) -``` Once complete, continue in Powershell: ```zsh diff --git a/src/gui/main_window.c b/src/gui/main_window.c index f2d6576..c69161d 100644 --- a/src/gui/main_window.c +++ b/src/gui/main_window.c @@ -84,10 +84,12 @@ void main_window(options_config *config) { GuiSetIconScale((int32_t) (scale.font_size / 1.8) / 16); } - if (IsFileDropped()) { // Initialize Emulation + if (IsFileDropped() && menu_state != options) { // Initialize Emulation EndDrawing(); if (emu_main(config, &scale) == -2) { break; } menu_state = normal; + } else { + UnloadDroppedFiles(LoadDroppedFiles()); } SetWindowTitle(WINDOW_TITLE VERSION); @@ -100,7 +102,7 @@ void main_window(options_config *config) { if (GuiButton((Rectangle) {scale.button_x, GetScreenHeight() / 2 - GetScreenHeight() / 6 - 10, scale.button_width, scale.button_height}, - GuiIconText(ICON_CPU, "Load ROM"))) { + GuiIconText(ICON_ROM, "Load ROM"))) { menu_state = init; } @@ -110,6 +112,13 @@ void main_window(options_config *config) { menu_state = options; } + if (GuiButton((Rectangle) {GetScreenWidth() - scale.button_height * 1.5, + GetScreenHeight() - scale.button_height * 1.5, + scale.button_height, scale.button_height}, + GuiIconText(ICON_INFO, ""))) { + OpenURL("https://github.com/npxtune/chisel8"); + } + if (GuiButton((Rectangle) {scale.button_x, GetScreenHeight() - (GetScreenHeight() / 6), scale.button_width, scale.button_height}, GuiIconText(ICON_EXIT, "Quit"))) { @@ -134,7 +143,7 @@ void main_window(options_config *config) { GetScreenWidth() / 2 - (scale.font_size * 10) + (scale.font_size / 2), (GetScreenHeight() / 2) - scale.font_size * 1.5, scale.font_size, RAYWHITE); - if (GuiButton((Rectangle) {scale.button_x, GetScreenHeight() - (GetScreenHeight() / 6), + if (GuiButton((Rectangle) {scale.button_x, GetScreenHeight() - (GetScreenHeight() / 8), scale.button_width, scale.button_height}, GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { menu_state = normal; diff --git a/src/gui/options_window.c b/src/gui/options_window.c index a7e3755..c93962a 100644 --- a/src/gui/options_window.c +++ b/src/gui/options_window.c @@ -38,6 +38,11 @@ #define items 6 // How many options are configurable? +enum menu_state_counter { + main, theme, miscellaneous +}; +uint32_t menu_state = main; + void create_config(options_config *config) { FILE *file = fopen("./chisel8-settings.txt", "w"); @@ -162,42 +167,91 @@ int32_t write_settings(options_config *config) { float temp; int32_t options_window(options_config *config, ui_scale *scale) { + switch (menu_state) { - SetExitKey(KEY_NULL); + /*-------------------------------------------------------------------------------------------------------------*/ - DrawText("Settings", GetScreenWidth() / 2 - (scale->font_size * 2), (GetScreenHeight() / 12), - scale->font_size, RAYWHITE); + case main: + SetExitKey(KEY_NULL); - // AUDIO VOLUME SLIDER - GuiSliderBar((Rectangle) {(scale->window_width / 2) - 250, scale->window_height / 4, 500, 25}, - GuiIconText(ICON_AUDIO, "Volume "), - TextFormat("%d %%", (int32_t) (config->volume * 100)), &config->volume, 0, 1); + DrawText("Settings", GetScreenWidth() / 2 - (scale->font_size * 2), (GetScreenHeight() / 12), + scale->font_size, RAYWHITE); - // TODO: THIS IS VERY BROKEN!!! HIDE COLOR PICKER BEHIND BUTTON? + // AUDIO VOLUME SLIDER + GuiSliderBar((Rectangle) {(scale->window_width / 2) - 250, scale->window_height / 4, 500, 25}, + GuiIconText(ICON_AUDIO, "Volume "), + TextFormat("%d %%", (int32_t) (config->volume * 100)), &config->volume, 0, 1); - GuiColorPicker((Rectangle) {100, 175, 200, 200}, "TEXT", &config->background_color); + if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 1.7), + scale->button_width, scale->button_height}, + GuiIconText(ICON_BRUSH_PAINTER, "Change color theme"))) { + // COLOR MENU + menu_state = theme; + } - GuiColorPicker((Rectangle) {600, 175, 200, 200}, "TEXT", &config->pixel_color); + if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 2.2), + scale->button_width, scale->button_height}, + GuiIconText(ICON_GEAR_EX, "Miscellaneous"))) { + // OTHER SETTINGS + menu_state = miscellaneous; + } - GuiCheckBox((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 3), - scale->button_width/8, scale->button_width/8}, "Show Debug info", &config->show_debug); + if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 8), + scale->button_width, scale->button_height}, + GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { + SetExitKey(KEY_ESCAPE); + return 0; + } + break; - GuiCheckBox((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 2), - scale->button_width/8, scale->button_width/8}, "Show FPS", &config->show_fps); + /*-------------------------------------------------------------------------------------------------------------*/ + case theme: + DrawText("Color Theme", GetScreenWidth() / 2 - (scale->font_size * 2) - 50, (GetScreenHeight() / 12), + scale->font_size, RAYWHITE); - if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 6), - scale->button_width, scale->button_height}, - GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { - SetExitKey(KEY_ESCAPE); - return 0; - } + DrawText("Background Color:", 115, 175 - 40, 20, WHITE); + GuiColorPicker((Rectangle) {100, 175, 200, 200}, "BG Color", &config->background_color); - if (config->show_debug == true) { - SetTraceLogLevel(LOG_INFO); - } else { - SetTraceLogLevel(LOG_ERROR); - } + DrawText("Pixel Color:", 645, 175 - 40, 20, WHITE); + GuiColorPicker((Rectangle) {600, 175, 200, 200}, "FG Color", &config->pixel_color); + + if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 8), + scale->button_width, scale->button_height}, + GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { + menu_state = main; + } + break; + + /*-------------------------------------------------------------------------------------------------------------*/ + case miscellaneous: + DrawText("Miscellaneous", GetScreenWidth() / 2 - (scale->font_size * 2) - 50, (GetScreenHeight() / 12), + scale->font_size, RAYWHITE); + + GuiCheckBox((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 1.7), + scale->button_width / 8, scale->button_width / 8}, "Show Debug info", + &config->show_debug); + + GuiCheckBox((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 2.2), + scale->button_width / 8, scale->button_width / 8}, "Show FPS", &config->show_fps); + + + if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 8), + scale->button_width, scale->button_height}, + GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { + menu_state = main; + } + + if (config->show_debug == true) { + SetTraceLogLevel(LOG_INFO); + } else { + SetTraceLogLevel(LOG_ERROR); + } + break; + + /*-------------------------------------------------------------------------------------------------------------*/ + + } return 1; } \ No newline at end of file