Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test case can not pass in /code/ch3.3/cpu.rs #9

Open
123zmz123 opened this issue Apr 19, 2021 · 5 comments
Open

test case can not pass in /code/ch3.3/cpu.rs #9

123zmz123 opened this issue Apr 19, 2021 · 5 comments

Comments

@123zmz123
Copy link

123zmz123 commented Apr 19, 2021

seems like we need comment 3 line to pass the test.

pub fn reset(&mut self){
       //self.register_a = 0;
       //self.register_x = 0;
       self.register_y = 0;
       self.stack_pointer = STACK_RESET;
       self.status = CpuFlags::from_bits_truncate(0b100100);
       //self.memory = [0; 0xFFFF];

       self.program_counter = self.mem_read_u16(0xFFFC);
    }
@123zmz123 123zmz123 changed the title bug in ch3.3/cpus.rs line 247 test case can not pass in /code/ch3.3/cpu.rs Apr 19, 2021
@bugzmanov
Copy link
Owner

Hey @123zmz123. Thank you for pointing this out! You might be right. Do you mind creating a PR ? I would be very grateful :)

@123zmz123
Copy link
Author

Hey @123zmz123. Thank you for pointing this out! You might be right. Do you mind creating a PR ? I would be very grateful :)

Cool! wait for me.

@123zmz123 123zmz123 reopened this Apr 27, 2021
@narakai
Copy link

narakai commented Aug 11, 2022

ch5.1 also have this issue. Test 'test_0xaa_tax_move_a_to_x' and 'test_inx_overflow' will not pass because load_and_run() will call reset(), which reset all variables to default value.

@enewton
Copy link

enewton commented May 6, 2024

Commit 1a4e5f5 fixed the ch3.3, but all subsequent chapters have the same problem which is still unfixed.

There were other ways this could have been fixed. Personally I would have kept using the load_and_run helper function for tests, but instead edited it to be something like:

pub fn load_and_run(&mut self, program: Vec<u8>) {
    self.load(program);
    self.program_counter = self.mem_read_u16(0xFFFC);
    self.run()
}

So not a full reset, but just re-read 0xFFFC after loading something.

In general there are quite a few unit tests failing, which was causing me confusing whilst following this great tutorial.
I'll happily have a go at putting together a pull request to fix all tests for all chapters, if you want to give your thoughts on my suggestion above.

In addition, I'm getting quite a few compiler warnings (E.g. Unused imports and naming conventions on enums). I can create a separate pull request for that.

@enewton
Copy link

enewton commented May 6, 2024

Actually, just noticed pull request #12 does exactly what I was suggesting above, but we still need to do this for all the subsequent chapters.

Do you still have time to work on this project? It would be a shame for this to gradually rot, just as Rust is about to hit the big time. I've really enjoyed following it so far; I'm about 1/2 way through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants