Git Product home page Git Product logo

gameboy's People

Contributors

carnageiron avatar eric-lac avatar hanaasagi avatar heropoo avatar mohanson avatar nwtnni avatar rhian-cs avatar urmyfaith avatar yazgoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gameboy's Issues

SUB A, r8/d8 command to set flag C

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.

在M1芯片的macOS下编译报错

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

intermitant clock changes

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.

Please add Cargo.lock to .gitignore

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

incorrect speed switch implementation in CGB mode

Hello, the speed switch code should get the value in the address that the PC register pointed instead of the value of in register.

if self.mmu.borrow().get(self.cpu.cpu.reg.pc) == 0x10 {

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.

English Please

What is the problem with Chinese README's

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.

Gollum Image

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.

What we want:

  • Please add English translation of your README so you are sharing your work and knowledge with more people.

How this will help you:

  • More feedback to fix and improve your project.
  • New ideas about your project.
  • Greater fame.
  • SungerBob Image

“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!

Slightly odd rendering on a Mac

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:
problem

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! 🙇🏻

Time to release?

I was looking for a release but found none. Is it alpha, beta or stable?

Segfault on start, I believe I know the problem

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?

Ambiguous function names in src/memory.rs

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.