mohanson / gameboy Goto Github PK
View Code? Open in Web Editor NEWFull featured Cross-platform GameBoy emulator by Rust. Forever boys!.
License: MIT License
Full featured Cross-platform GameBoy emulator by Rust. Forever boys!.
License: MIT License
According to the GBCPUman: C - Set if no borrow.
In my opinion, the code should be:
self.reg.set_flag(Flag::C, a >= n);
when the value of register A is greater then the number n, a-n
is not borrowed. But in the project, the code is:
self.reg.set_flag(C, u16::from(a) < u16::from(n));
Which I couldn't understand.
Line 998 in 87865c1
n
should not be incremented by 1. Otherwise, by example, if n = 1
you will get a divisor value of 32 instead of the 16 expected.
You can also use this operation instead:
n => u32::from(n) << 4
cargo run --release -- "./res/boxes.gb"
Compiling coreaudio-sys v0.2.2
error: failed to run custom build command for `coreaudio-sys v0.2.2`
Caused by:
process didn't exit successfully: `/Users/my/Projects/gameboy/target/release/build/coreaudio-sys-8d0fefacc2d2969d/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=framework=AudioUnit
cargo:rustc-link-lib=framework=CoreAudio
--- stderr
error: header '/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h' does not exist.
thread 'main' panicked at 'unable to generate bindings: ()', /Users/my/.cargo/registry/src/github.com-1ecc6299db9ec823/coreaudio-sys-0.2.2/build.rs:144:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
As I've been playing with this emulator I've noticed that the clock rate seems to jump around. Sometimes the game will slow the a crawl, and other times it runs so fast that it becomes hard to control. I think this may be because my machine isn't that powerful, and it may be missing frame timing (it was taking ~30ms a cpu cycle rather than the target 16 when I threw some prints in there).
I think the following diff might fix things:
diff --git a/src/cpu.rs b/src/cpu.rs
index bb07a5e..80f3556 100644
--- a/src/cpu.rs
+++ b/src/cpu.rs
@@ -1693,7 +1693,7 @@ impl Cpu {
pub struct Rtc {
pub cpu: Cpu,
step_cycles: u32,
- step_zero: time::SystemTime,
+ step_zero: time::Instant,
step_flip: bool,
}
@@ -1703,7 +1703,7 @@ impl Rtc {
Self {
cpu,
step_cycles: 0,
- step_zero: time::SystemTime::now(),
+ step_zero: time::Instant::now(),
step_flip: false,
}
}
@@ -1713,14 +1713,20 @@ impl Rtc {
if self.step_cycles > STEP_CYCLES {
self.step_flip = true;
self.step_cycles -= STEP_CYCLES;
- let d = time::SystemTime::now().duration_since(self.step_zero).unwrap();
+ let now = time::Instant::now();
+ let d = now.duration_since(self.step_zero);
let s = u64::from(STEP_TIME.saturating_sub(d.as_millis() as u32));
rog::debugln!("CPU: sleep {} millis", s);
thread::sleep(time::Duration::from_millis(s));
- self.step_zero = self
- .step_zero
+ self.step_zero = self.step_zero
.checked_add(time::Duration::from_millis(u64::from(STEP_TIME)))
.unwrap();
+
+ // If now is after the just updated target frame time, reset to
+ // avoid drift.
+ if now.checked_duration_since(self.step_zero).is_some() {
+ self.step_zero = now;
+ }
}
let cycles = self.cpu.next();
self.step_cycles += cycles;
I don't think switching from SystemTime to monotonic time is actually that important, but I think it is probably the right thing to do here since we are just using this stuff for frame timing and it doesn't really have to relate to the real wallclock time.
But the bug can take a while to manifest, so I can't really confirm yet. I'm going to run an emulator with this patch for a while and update this thread.
Cargo.lock is a generated file by cargo, but build fail if your generated Cargo.lock is present.
Suggestion: delete Cargo.lock and add it to .gitignore
Something went wrong with rom Pockmon - Crystal, when speak to npcs
Hello, the speed switch code should get the value in the address that the PC register pointed instead of the value of in register.
Line 21 in ff9c35b
Reference: https://gbdev.gg8.se/wiki/articles/CGB_Registers#FF4D_-_KEY1_-_CGB_Mode_Only_-_Prepare_Speed_Switch
The actual speed switch is performed by executing a STOP command after Bit 0 has been set. After that Bit 0 will be cleared automatically, and the gameboy will operate at the 'other' speed.
Firstly, we congratulate you for getting so much star by sharing this repository with humanity.
But it is very disappointing for non-Chinese speakers when one couldn't understand what a trending repository is about.
When we see such a repo on trending, our minds are blurring like Gollum's.
There is a way you can help to solve this disappointment which I believe is experienced by many people who want to know more about your valuable work and appreciate it.
“Sharing knowledge is the most fundamental act of friendship. Because it is a way you can give something without loosing something.”
— Richard Stallman
Thank you!
This issue created by
us/english-please
script. Please report on any error. Thank you!
I'm learning GB dev, and some simple sprite swapping code is not rendering out as expected using this emulator (release built on an M1 Mac from bc90e61), but is with others.
For example with gameboy vs rboy:
I've attached the rom, and the code as it's simple. I am building it with @gbdk-2020.
#include <gb/gb.h>
const unsigned char face[] =
{
0x7E,0x7E,0x81,0x81,0xA5,0xA5,0x81,0x81,
0xA5,0xA5,0x99,0x99,0x81,0x81,0x7E,0x7E,
0x7E,0x7E,0x81,0x81,0xA5,0xA5,0x81,0x81,
0x81,0x81,0xBD,0xBD,0x81,0x81,0x7E,0x7E
};
void main(void) {
UINT8 current_sprite = 0;
set_sprite_data(0, 2, face);
set_sprite_tile(0, 0);
move_sprite(0, 88, 78);
SHOW_SPRITES;
while(1) {
if (current_sprite == 0) {
current_sprite = 1;
} else {
current_sprite = 0;
}
delay(1000);
set_sprite_tile(0, current_sprite);
}
}
Anyway, thanks for the effort on this project! 🙇🏻
I was looking for a release but found none. Is it alpha, beta or stable?
I'm currently running bspwm
, and everything is set to tiling.
I believe the issue is that gameboy
is trying to launch with specific geometry size, but since it can't due to tiling, it segfaults.
If I'm right, I can fix this by setting bspwm
to float that window.
The problem though, is that I can't obtain the wm_class
since the window instantly closes.
So could you tell me what the wm_class
is?
While I review your code in src/memory.rs
, one thing makes me confused.
There are two functions named as get_halfword
and set_halfword
.
Literally, they are used to get half of a WORD length data from a specific memory address,
or setting half of a WORD length data.
In fact, they are designed as 16-bit version getter and setter for memory.
ARM64 and x86 family of CPU defined a WORD as 16 bits(2 bytes).
Back to time of Intel 8080 and Zilog 80, a WORD stands for 8 bits.
I have not found any LR35902 specifications, indicating that a WORD is 32 bits.
So I wonder if a correctly expressed version of those function names should be get_word
(for widely used x86 and ARM standard) or get_dword
(for 8080 and Z80 standard), the same for setter.
Thanks for your hard work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.