Compare commits

..

10 Commits

Author SHA1 Message Date
c0953a9374 Implement an actual README
Some checks failed
CI / Build ubuntu-latest - Release (push) Failing after 3m12s
CI / Build macos-latest - Release (push) Has been cancelled
CI / Build windows-latest - Release (push) Has been cancelled
2025-08-29 14:14:02 -04:00
115a5c7c9f Add Linux to github workflow 2025-08-29 13:11:30 -04:00
e3af26a508 Implement support for building on Linux. Hopefully doesn't break Windows/macOS 2025-08-29 13:09:24 -04:00
a9357b924d Refactor STA Instructions 2025-07-29 11:02:06 -04:00
1ab1ec57de Refactor LDX/Y Instructions 2025-07-29 10:34:12 -04:00
45f688e8c9 More refactoring of functions 2025-07-29 10:16:18 -04:00
d40414efd8 Hopefully not break ORA instructions with refactoring 2025-07-28 13:30:12 -04:00
265cd69937 Cleanup ROL instructions 2025-07-28 12:40:13 -04:00
9ba05a45ef Cleanup ROR instructions 2025-07-28 12:33:13 -04:00
edac91baf9 More code cleanup of STZ functions 2025-07-28 12:29:02 -04:00
6 changed files with 346 additions and 790 deletions

View File

@@ -13,7 +13,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [windows-latest, macos-latest] os: [windows-latest, macos-latest, ubuntu-latest]
build_type: [Release] build_type: [Release]
steps: steps:

View File

@@ -46,10 +46,20 @@ elseif(APPLE)
find_package(SDL2 REQUIRED CONFIG) find_package(SDL2 REQUIRED CONFIG)
message(STATUS "Found SDL2 at: ${SDL2_DIR}") message(STATUS "Found SDL2 at: ${SDL2_DIR}")
elseif(UNIX) elseif(UNIX AND NOT APPLE)
find_package(SDL2 CONFIG QUIET)
if(NOT SDL2_FOUND) if(NOT SDL2_FOUND)
# Use pkg-config as fallback
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2) pkg_check_modules(SDL2 REQUIRED sdl2)
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "${SDL2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
INTERFACE_COMPILE_OPTIONS "${SDL2_CFLAGS_OTHER}"
)
endif() endif()
endif() endif()

90
README.md Normal file
View File

@@ -0,0 +1,90 @@
# BreadedSNES
**BreadedSNES** is an up-and-coming cross-platform Super Nintendo (SNES) emulator written in modern C++23. SDL2 is used for audio, video, and input support.
Note, this does not function currently. Maybe it'll boot something in the future. Now is certainly not that time.
## Build Instructions
### Prerequisites
You will need:
- CMake ≥ 3.16
- C++23-compatible compiler (GCC, Clang, or MSVC)
- SDL2 development libraries
---
### Windows
1. Clone the repository and vcpkg:
```bash
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
```
2. Install SDL2:
```bash
./vcpkg install sdl2
```
3. Build the project:
```bash
cd path/to/breadedSNES
cmake -B build -DCMAKE_TOOLCHAIN_FILE=path/to/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
```
---
### macOS
1. Install dependencies:
```bash
brew install cmake sdl2
```
2. Build the project:
```bash
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
```
---
### 🐧 Linux
1. Install dependencies:
>apt:
> ```bash
>sudo apt install cmake build-essential libsdl2-dev pkg-config
>```
> pacman:
> ```bash
> sudo pacman -S cmake sdl2 pkgconf
> ```
2. Build the project:
```bash
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
```
---
### Packaging
To create distributable packages (e.g. `.zip`, `.dmg`, `.tgz`), run:
```bash
cd build
cpack

View File

@@ -5,6 +5,7 @@
#ifndef BUS_H #ifndef BUS_H
#define BUS_H #define BUS_H
#include <algorithm> #include <algorithm>
#include <cstdint>
#include <vector> #include <vector>
// Memory Bus - handles memory mapping // Memory Bus - handles memory mapping

File diff suppressed because it is too large Load Diff

View File

@@ -67,6 +67,43 @@ class CPU {
// Helper method to check for decimal mode adjustment // Helper method to check for decimal mode adjustment
static uint16_t AdjustDecimal(uint16_t binary_result, bool is_16bit); static uint16_t AdjustDecimal(uint16_t binary_result, bool is_16bit);
// Helpers for LD* Instructions
void LDA_Mem(uint32_t address, int base_cycles, bool addDPExtraCycle, bool addPageCrossCycle, uint16_t base,
uint16_t offset);
void LD_Index(uint32_t address, bool isX, int base_cycles, bool addDPExtraCycle, bool addPageCrossCycle,
uint16_t base,
uint16_t offset);
// General ORA Logic
void ORA_Mem(uint32_t address, int base_cycles, bool addDPExtraCycle, bool addPageCrossCycle, uint16_t base_address,
uint16_t offset);
//Helper Methods for Rotate Right/Left
uint8_t ROL8(uint8_t value);
uint16_t ROL16(uint16_t value);
void ROL_AtAddress(uint32_t address, int base_cycles_8bit, int base_cycles_16bit);
uint8_t ROR8(uint8_t value);
uint16_t ROR16(uint16_t value);
void ROR_AtAddress(uint32_t address, int base_cycles_8bit, int base_cycles_16bit);
// Helper methods for SBC operations
void SBC8(uint8_t operand);
void SBC16(uint16_t operand);
uint8_t SBC8_Decimal(uint8_t a, uint8_t operand, bool carry);
uint16_t SBC16_Decimal(uint16_t a, uint16_t operand, bool carry);
void SBC_FromAddress(uint32_t address, int base_cycles_8bit, int base_cycles_16bit);
void SBC_FromAddress_PageCross(uint32_t address, uint16_t base_address, uint16_t offset, int base_cycles_8bit,
int base_cycles_16bit);
// General STZ Logic
void STZ_ToAddress(uint32_t address, int base_cycles_8bit, int base_cycles_16bit);
// ST* Helpers
void WriteWithDirectPagePenalty(uint32_t address, uint16_t value, bool isMemoryFlag, int baseCycles);
void WriteRegisterToAddress(uint32_t address, uint16_t value, bool isMemoryFlag, int baseCycles);
// Helper methods for ASL stuff // Helper methods for ASL stuff
void UpdateASLFlags8(uint8_t original_value, uint8_t result); void UpdateASLFlags8(uint8_t original_value, uint8_t result);
void UpdateASLFlags16(uint16_t original_value, uint16_t result); void UpdateASLFlags16(uint16_t original_value, uint16_t result);
@@ -80,21 +117,6 @@ class CPU {
void UpdateLSRFlags8(uint8_t original_value, uint8_t result); void UpdateLSRFlags8(uint8_t original_value, uint8_t result);
void UpdateLSRFlags16(uint16_t original_value, uint16_t result); void UpdateLSRFlags16(uint16_t original_value, uint16_t result);
//Helper Methods for Rotate Right/Left
uint8_t ROL8(uint8_t value);
uint16_t ROL16(uint16_t value);
uint8_t ROR8(uint8_t value);
uint16_t ROR16(uint16_t value);
// Helper methods for SBC operations
void SBC8(uint8_t operand);
void SBC16(uint16_t operand);
uint8_t SBC8_Decimal(uint8_t a, uint8_t operand, bool carry);
uint16_t SBC16_Decimal(uint16_t a, uint16_t operand, bool carry);
void SBC_FromAddress(uint32_t address, int base_cycles_8bit, int base_cycles_16bit);
void SBC_FromAddress_PageCross(uint32_t address, uint16_t base_address, uint16_t offset, int base_cycles_8bit,
int base_cycles_16bit);
public: public:
explicit CPU(Bus* memory_bus) : bus(memory_bus) { explicit CPU(Bus* memory_bus) : bus(memory_bus) {
Reset(); Reset();