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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Lint](https://github.com/Diesel-Net/kiwi-8/actions/workflows/lint.yml/badge.svg)](https://github.com/Diesel-Net/kiwi-8/actions/workflows/lint.yml)
<br>

![boot](/images/screenshots/boot.png)
![boot_macos](/images/screenshots/boot_macos.png)

A cross-platform Chip-8 interpreter written
in C-style C++ using SDL2, ImGui, and OpenGL.
Expand Down Expand Up @@ -73,7 +73,7 @@ The following must be installed and added to your **PATH**:
1. Change current working directory

```cmd
cd Windows
cd windows
```

1. Configure environment for your architecture (x64 or arm64)
Expand All @@ -94,14 +94,15 @@ The following must be installed and added to your **PATH**:

>install_name_tool<br>
>clang<br>
>clang++<br>
>python3<br>
>cmake<br>
>make<br>

1. Change current working directory

```bash
cd MacOS
cd macos
```

1. Compile with GNU's `make` utility
Expand All @@ -114,6 +115,7 @@ The following must be installed and added to your **PATH**:

The following must be added to your **PATH**:

>gcc<br>
>g++<br>
>make<br>
>cmake<br>
Expand All @@ -123,7 +125,7 @@ The following must be added to your **PATH**:
You'll also need the GTK3, openGL, PulseAudio/Pipewire headers:

```bash
sudo apt install libgtk-3-dev xorg-dev libgl1-mesa-dev libasound2-dev libpulse-dev libpipewire-0.3-dev libdbus-1-dev
sudo apt install libgtk-3-dev xorg-dev libgl1-mesa-dev libasound2-dev libpulse-dev libjack-dev libpipewire-0.3-dev libdbus-1-dev
```

1. Change current working directory
Expand Down
Binary file added images/screenshots/astrodoge_macos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshots/boot_linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshots/boot_macos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
4 changes: 2 additions & 2 deletions linux/src/open_file_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ std::vector<std::string> open_file_dialog(const std::string &title, const std::s
return result;
}

int open_file_dialog(char *rom_filepath) {
int open_file_dialog(char *rom_filepath, size_t size) {
std::vector<std::string> fileTypes = {"ch8", "CH8", "chip-8", "CHIP-8", "Chip-8"};
const char* defaultDir = ""; // unify behavior: let OS choose last-used/home
std::vector<std::string> files = open_file_dialog("Chip8", defaultDir, fileTypes);
if (files.empty()) return 1;
snprintf(rom_filepath, PATH_MAX, "%s", files[0].c_str());
snprintf(rom_filepath, size, "%s", files[0].c_str());
return 0;
}
4 changes: 2 additions & 2 deletions macos/src/open_file_dialog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
return fileList;
}

int open_file_dialog(char *rom_filepath) {
int open_file_dialog(char *rom_filepath, size_t size) {
std::vector<std::string> fileTypes = {"ch8", "CH8", "chip-8", "CHIP-8", "Chip-8"};
const char* defaultDir = ""; // unify behavior: let OS choose last-used/home
std::vector<std::string> files = open_file_dialog("Chip8", defaultDir, fileTypes);
if (files.empty()) return 1;
snprintf(rom_filepath, PATH_MAX, "%s", files[0].c_str());
snprintf(rom_filepath, size, "%s", files[0].c_str());
return 0;
}
2 changes: 1 addition & 1 deletion shared/chip8.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int chip8_load_rom(const char *rom_filepath) {
} else {
/* load ROM from GUI */
char new_rom_filepath[PATH_MAX];
open_file_dialog(new_rom_filepath) ?
open_file_dialog(new_rom_filepath, sizeof(new_rom_filepath)) ?
printf("User aborted the open file dialog.\n") :
chip8_load_rom(new_rom_filepath);

Expand Down
9 changes: 8 additions & 1 deletion shared/open_file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
extern "C" {
#endif

int open_file_dialog(char *rom_filepath);
#include <stddef.h>

/* Opens a file dialog to select a ROM file.
* The selected file path is copied to `rom_filepath`.
* The `size` parameter specifies the size of the `rom_filepath` buffer.
* Returns 1 if a file was selected, 0 if cancelled, or -1 on error.
*/
int open_file_dialog(char *rom_filepath, size_t size);

#ifdef __cplusplus
}
Expand Down
8 changes: 4 additions & 4 deletions windows/src/open_file_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>

int open_file_dialog(char *rom_filepath, char *filters) {
int open_file_dialog(char *rom_filepath, char *filters, size_t size) {
/* open file dialogue */
char cwd[PATH_MAX];
GetCurrentDirectory(PATH_MAX, cwd);
Expand Down Expand Up @@ -36,10 +36,10 @@ int open_file_dialog(char *rom_filepath, char *filters) {
return 1;
}

strcpy(rom_filepath, szFile);
strncpy(rom_filepath, szFile, size);
return 0;
}

int open_file_dialog(char *rom_filepath) {
return open_file_dialog(rom_filepath, "Chip8\0*.ch8\0All\0*.*\0");
int open_file_dialog(char *rom_filepath, size_t size) {
return open_file_dialog(rom_filepath, "Chip8\0*.ch8\0All\0*.*\0", size);
}
Loading