diff --git a/README.md b/README.md index d607b6e..a3b3f99 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Currently, all opcodes are implemented and all of them except for a few work as - [X] Supports all opcodes for the original [Chip-8](https://emu.gulrak.net/reference/opcodes/) system - [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 (currently wonky...) +- [X] Correct keypad input - [ ] 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.~~ @@ -82,7 +82,32 @@ the ANGLE dylib files into the `build` dir, so it can load them. Remember to run --- ### Windows -No idea, good luck. If you figured it out, let me know per PR. Probably something similair to the steps above. +**WARNING:** 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:** +- MinGW-w64 (https://www.mingw-w64.org/) +- 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 +git clone https://github.com/npxtune/chisel8.git +cd chisel8 +git submodule update --init --recursive # To fetch raylib & raygui +mkdir build && cd ./build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j 6 # '6' -> How many cores you want to use +``` + +There should now be an executable called `chisel8.exe` in your build folder. +Run it and the application should open. --- #### Copyright & Licensing diff --git a/include/core/emu_definition.h b/include/core/emu_definition.h index d2d3276..74b68ba 100644 --- a/include/core/emu_definition.h +++ b/include/core/emu_definition.h @@ -61,8 +61,7 @@ typedef struct Chip8 { uint8_t delay, sound; // Delay and sound timers uint8_t ram[RAM_SIZE], reg[REGISTER_SIZE + 1]; uint16_t stack[STACK_SIZE]; - uint16_t pc, I; - uint16_t opcode; + uint16_t pc, I, opcode; int16_t key, i_stack; diff --git a/src/core/emu_file.c b/src/core/emu_file.c index 20f6ac2..bcd0a13 100644 --- a/src/core/emu_file.c +++ b/src/core/emu_file.c @@ -33,10 +33,10 @@ int32_t gui_load_file(emu *chip8) { if (file != NULL) { SetWindowTitle(GetFileName(*dropped_file.paths)); - TraceLog(LOG_INFO, "EMU_FILE -> Loading ROM into ram"); + TraceLog(LOG_INFO, "EMU_FILE -> Loading ROM into RAM"); if ((fread(chip8->ram + 0x200, 1, RAM_SIZE, file)) > 0) { - TraceLog(LOG_INFO, "EMU_FILE -> ROM was loaded into ram"); + TraceLog(LOG_INFO, "EMU_FILE -> ROM was loaded into RAM"); fclose(file); UnloadDroppedFiles(dropped_file); return 0; diff --git a/src/core/emu_main.c b/src/core/emu_main.c index 9579b8e..6f67e58 100644 --- a/src/core/emu_main.c +++ b/src/core/emu_main.c @@ -34,7 +34,6 @@ void emu_stop(emu *chip8, AudioStream beep) { UnloadTexture(chip8->display); ClearBackground(BLACK); TraceLog(LOG_INFO, "EMU_MAIN -> Stopped emulation"); - SetWindowState(FLAG_WINDOW_RESIZABLE); SetExitKey(KEY_ESCAPE); } diff --git a/src/gui/main_window.c b/src/gui/main_window.c index 93f38a6..f2d6576 100644 --- a/src/gui/main_window.c +++ b/src/gui/main_window.c @@ -128,6 +128,7 @@ void main_window(options_config *config) { /*-------------------------------------------------------------------------------------------------------------*/ case (init): + SetExitKey(KEY_NULL); DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.2f)); DrawText("Please drag a ROM file into the window", GetScreenWidth() / 2 - (scale.font_size * 10) + (scale.font_size / 2), @@ -135,8 +136,9 @@ void main_window(options_config *config) { if (GuiButton((Rectangle) {scale.button_x, GetScreenHeight() - (GetScreenHeight() / 6), scale.button_width, scale.button_height}, - GuiIconText(ICON_REREDO_FILL, "Return"))) { + GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { menu_state = normal; + SetExitKey(KEY_ESCAPE); break; } if (IsFileDropped()) { // Initialize Emulation diff --git a/src/gui/options_window.c b/src/gui/options_window.c index 9e8e11c..7860689 100644 --- a/src/gui/options_window.c +++ b/src/gui/options_window.c @@ -163,6 +163,8 @@ float temp; int32_t options_window(options_config *config, ui_scale *scale) { + SetExitKey(KEY_NULL); + DrawText("Settings", GetScreenWidth() / 2 - (scale->font_size * 2), (GetScreenHeight() / 12), scale->font_size, RAYWHITE); @@ -179,7 +181,8 @@ int32_t options_window(options_config *config, ui_scale *scale) { if (GuiButton((Rectangle) {scale->button_x, GetScreenHeight() - (GetScreenHeight() / 6), scale->button_width, scale->button_height}, - GuiIconText(ICON_REREDO_FILL, "Return"))) { + GuiIconText(ICON_REREDO_FILL, "Return")) || IsKeyPressed(KEY_ESCAPE)) { + SetExitKey(KEY_ESCAPE); return 0; } return 1;