Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/gui/main_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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"))) {
Expand All @@ -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;
Expand Down
104 changes: 79 additions & 25 deletions src/gui/options_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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;
}