-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from YushiOMOTE/actions
Actions
- Loading branch information
Showing
18 changed files
with
539 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Rust | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Prepare | ||
run: sudo apt install libasound2-dev libxcursor-dev | ||
- name: Build (stable) | ||
run: cargo build --verbose | ||
- name: Build examples (stable) | ||
run: cargo build --verbose --examples | ||
- name: Test (stable) | ||
run: cargo test --verbose | ||
- name: Install nightly | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
- name: Build (nightly) | ||
run: | | ||
cd core | ||
cargo build --verbose --features readme | ||
- name: Build examples (nightly) | ||
run: | | ||
cd core | ||
cargo build --verbose --examples --features readme | ||
- name: Test (nightly) | ||
run: | | ||
cd core | ||
cargo test --verbose --features readme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# rGB | ||
# rgy | ||
|
||
Try emulating Game Boy in Rust | ||
No-std cross-platform Rust GameBoy emulator library. Rust GameboY (RGY, or Real GaY). | ||
|
||
[![Latest version](https://img.shields.io/crates/v/rgy.svg)](https://crates.io/crates/rgy) | ||
[![Documentation](https://docs.rs/rgy/badge.svg)](https://docs.rs/rgy) | ||
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
[![Actions Status](https://github.com/YushiOMOTE/rgy/workflows/Rust/badge.svg)](https://github.com/YushiOMOTE/rgy/actions) | ||
|
||
![demo](https://raw.github.com/wiki/YushiOMOTE/gbr/media/demo.gif) | ||
![screens](https://raw.github.com/wiki/YushiOMOTE/gbr/media/demo_screens.jpg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use rgy::{Config, Key, Stream, VRAM_HEIGHT, VRAM_WIDTH}; | ||
|
||
struct Hardware { | ||
display: Vec<Vec<u32>>, | ||
} | ||
|
||
impl Hardware { | ||
fn new() -> Self { | ||
// Create a frame buffer with the size VRAM_WIDTH * VRAM_HEIGHT. | ||
let display = vec![vec![0u32; VRAM_HEIGHT]; VRAM_WIDTH]; | ||
|
||
Self { display } | ||
} | ||
} | ||
|
||
impl rgy::Hardware for Hardware { | ||
fn vram_update(&mut self, line: usize, buffer: &[u32]) { | ||
// `line` corresponds to the y coordinate. | ||
let y = line; | ||
|
||
for (x, col) in buffer.iter().enumerate() { | ||
self.display[x][y] = *col; | ||
} | ||
} | ||
|
||
fn joypad_pressed(&mut self, key: Key) -> bool { | ||
// Read a keyboard device and check if the `key` is pressed or not. | ||
println!("Check if {:?} is pressed", key); | ||
false | ||
} | ||
|
||
fn sound_play(&mut self, _stream: Box<dyn Stream>) { | ||
// Play the wave provided `Stream`. | ||
} | ||
|
||
fn clock(&mut self) -> u64 { | ||
// Return the epoch in microseconds. | ||
let epoch = std::time::SystemTime::now() | ||
.duration_since(std::time::UNIX_EPOCH) | ||
.expect("Couldn't get epoch"); | ||
epoch.as_micros() as u64 | ||
} | ||
|
||
fn send_byte(&mut self, _b: u8) { | ||
// Send a byte to a serial port. | ||
} | ||
|
||
fn recv_byte(&mut self) -> Option<u8> { | ||
// Try to read a byte from a serial port. | ||
None | ||
} | ||
|
||
fn sched(&mut self) -> bool { | ||
// `true` to continue, `false` to stop the emulator. | ||
println!("It's running!"); | ||
true | ||
} | ||
|
||
fn load_ram(&mut self, size: usize) -> Vec<u8> { | ||
// Return save data. | ||
vec![0; size] | ||
} | ||
|
||
fn save_ram(&mut self, _ram: &[u8]) { | ||
// Store save data. | ||
} | ||
} | ||
|
||
fn main() { | ||
// Create the default config. | ||
let cfg = Config::new(); | ||
|
||
// Create the hardware instance. | ||
let hw = Hardware::new(); | ||
|
||
// The content of a ROM file, which can be downloaded from the Internet. | ||
let rom = vec![0u8; 1024]; | ||
|
||
// Run the emulator. | ||
rgy::run(cfg, &rom, hw); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.