Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NES Emulator testing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer and Embedded Systems Engineering
Software Fundamentals
NES Emulator testing
Commits
d0b4920a
Commit
d0b4920a
authored
Sep 29, 2022
by
Vivian Roest
Browse files
Options
Downloads
Patches
Plain Diff
add docs
parent
1f55a0bc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1
-1
1 addition, 1 deletion
Cargo.lock
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
README.md
+4
-1
4 additions, 1 deletion
README.md
src/lib.rs
+27
-4
27 additions, 4 deletions
src/lib.rs
with
33 additions
and
7 deletions
Cargo.lock
+
1
−
1
View file @
d0b4920a
...
@@ -1031,7 +1031,7 @@ dependencies = [
...
@@ -1031,7 +1031,7 @@ dependencies = [
[[package]]
[[package]]
name = "tudelft-nes-test"
name = "tudelft-nes-test"
version = "1.1.
0
"
version = "1.1.
1
"
dependencies = [
dependencies = [
"bitflags",
"bitflags",
"log",
"log",
...
...
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
1
View file @
d0b4920a
[
package
]
[
package
]
name
=
"tudelft-nes-test"
name
=
"tudelft-nes-test"
version
=
"1.1.
0
"
version
=
"1.1.
1
"
edition
=
"2021"
edition
=
"2021"
authors
=
[
authors
=
[
"Victor Roest <victor@xirion.net>"
,
"Victor Roest <victor@xirion.net>"
,
...
...
...
...
This diff is collapsed.
Click to expand it.
README.md
+
4
−
1
View file @
d0b4920a
# NES Emulator testing
# NES Emulator testing
This is a helper crate to run tests ROMs on your NES
# Attribution
*
`all_instr.nes`
and
`official_only.nes`
are made by: Shay Green
<gblargg@gmail.com>
*
`nestest.nes`
is made by: Kevin Horton
This diff is collapsed.
Click to expand it.
src/lib.rs
+
27
−
4
View file @
d0b4920a
//! # `tudelft-nes-test`
//! This is a helper crate for your NES emulator to run various test ROMs
use
crate
::
all_instrs
::{
all_instrs_status_code
,
read_status_string
};
use
crate
::
all_instrs
::{
all_instrs_status_code
,
read_status_string
};
use
bitflags
::
bitflags
;
use
bitflags
::
bitflags
;
use
std
::
error
::
Error
;
use
std
::
error
::
Error
;
...
@@ -11,6 +13,7 @@ mod nestest;
...
@@ -11,6 +13,7 @@ mod nestest;
use
crate
::
nestest
::
nestest_status_code
;
use
crate
::
nestest
::
nestest_status_code
;
/// Implement this trait to run our test on our CPU via the [`run_tests`] function.
pub
trait
TestableCpu
:
Cpu
+
Sized
+
'static
{
pub
trait
TestableCpu
:
Cpu
+
Sized
+
'static
{
fn
get_cpu
(
rom
:
&
[
u8
])
->
Result
<
Self
,
Box
<
dyn
Error
>>
;
fn
get_cpu
(
rom
:
&
[
u8
])
->
Result
<
Self
,
Box
<
dyn
Error
>>
;
fn
set_program_counter
(
&
mut
self
,
value
:
u16
);
fn
set_program_counter
(
&
mut
self
,
value
:
u16
);
...
@@ -20,11 +23,27 @@ pub trait TestableCpu: Cpu + Sized + 'static {
...
@@ -20,11 +23,27 @@ pub trait TestableCpu: Cpu + Sized + 'static {
bitflags!
{
bitflags!
{
/// Select which tests you want to run
/// Select which tests you want to run
pub
struct
TestSelector
:
u32
{
pub
struct
TestSelector
:
u32
{
/// `NESTEST` is a pretty much all inclusive test suite for a NES CPU. It was designed to test almost every combination of flags, instructions,
/// and registers. Some of these tests are very difficult.
/// More information about this test ROM can be found [here](https://github.com/christopherpow/nes-test-roms/blob/master/other/nestest.txt)
const
NESTEST
=
0b00000001
;
const
NESTEST
=
0b00000001
;
/// `ALL_INSTRS` tests all instructions (including unofficial ones).
/// More function about this test can be found [here](https://github.com/christopherpow/nes-test-roms/tree/master/instr_test-v5)
const
ALL_INSTRS
=
0b00000010
;
const
ALL_INSTRS
=
0b00000010
;
/// `OFFICIAL_INSTRS` tests all official nes instructions, a finished emulator should pass this.
/// More function about this test can be found [here](https://github.com/christopherpow/nes-test-roms/tree/master/instr_test-v5)
const
OFFICIAL_INSTRS
=
0b00000100
;
const
OFFICIAL_INSTRS
=
0b00000100
;
/// `NROM_TEST` is a very simple rom that tests some basic functionality, this is a good starting test to try and pass.
/// The source for this rom can be found [here](https://gitlab.ewi.tudelft.nl/software-fundamentals/nes-nrom-test/-/blob/main/src/nrom.s)
const
NROM_TEST
=
0b00001000
;
const
NROM_TEST
=
0b00001000
;
/// This test selector runs all available tests
const
ALL
=
Self
::
NESTEST
.bits
|
Self
::
ALL_INSTRS
.bits
|
Self
::
NROM_TEST
.bits
;
const
ALL
=
Self
::
NESTEST
.bits
|
Self
::
ALL_INSTRS
.bits
|
Self
::
NROM_TEST
.bits
;
/// This test selector runs a default selection of tests: `OFFICIAL_INSTRS` and `NROM_TEST`
const
DEFAULT
=
Self
::
OFFICIAL_INSTRS
.bits
|
Self
::
NROM_TEST
.bits
;
const
DEFAULT
=
Self
::
OFFICIAL_INSTRS
.bits
|
Self
::
NROM_TEST
.bits
;
}
}
}
}
...
@@ -35,6 +54,7 @@ impl Default for TestSelector {
...
@@ -35,6 +54,7 @@ impl Default for TestSelector {
}
}
}
}
/// The main function of this crate, run this with your CPU as generic parameter and a [`TestSelector`] to run the tests
pub
fn
run_tests
<
T
:
TestableCpu
>
(
selector
:
TestSelector
)
->
Result
<
(),
String
>
{
pub
fn
run_tests
<
T
:
TestableCpu
>
(
selector
:
TestSelector
)
->
Result
<
(),
String
>
{
if
selector
.contains
(
TestSelector
::
ALL_INSTRS
)
{
if
selector
.contains
(
TestSelector
::
ALL_INSTRS
)
{
all_instrs
::
<
T
>
(
false
)
?
;
all_instrs
::
<
T
>
(
false
)
?
;
...
@@ -152,7 +172,6 @@ fn nestest<T: TestableCpu + 'static>() -> Result<(), String> {
...
@@ -152,7 +172,6 @@ fn nestest<T: TestableCpu + 'static>() -> Result<(), String> {
process_handle
(
"nestest"
,
handle
)
process_handle
(
"nestest"
,
handle
)
}
}
/// runs our own nrom test rom
/// runs our own nrom test rom
/// https://gitlab.ewi.tudelft.nl/software-fundamentals/nes-nrom-test
/// https://gitlab.ewi.tudelft.nl/software-fundamentals/nes-nrom-test
fn
nrom_test
<
T
:
TestableCpu
+
'static
>
()
->
Result
<
(),
String
>
{
fn
nrom_test
<
T
:
TestableCpu
+
'static
>
()
->
Result
<
(),
String
>
{
...
@@ -164,9 +183,13 @@ fn nrom_test<T: TestableCpu + 'static>() -> Result<(), String> {
...
@@ -164,9 +183,13 @@ fn nrom_test<T: TestableCpu + 'static>() -> Result<(), String> {
.map_err
(|
i
|
TestError
::
Custom
(
i
.to_string
()))
?
;
.map_err
(|
i
|
TestError
::
Custom
(
i
.to_string
()))
?
;
if
cpu
.memory_read
(
0x42
)
!=
0x43
{
if
cpu
.memory_read
(
0x42
)
!=
0x43
{
Err
(
TestError
::
String
(
"memory location 0x42 is wrong after executing nrom_test"
.to_owned
()))
Err
(
TestError
::
String
(
"memory location 0x42 is wrong after executing nrom_test"
.to_owned
(),
))
}
else
if
cpu
.memory_read
(
0x43
)
!=
0x6A
{
}
else
if
cpu
.memory_read
(
0x43
)
!=
0x6A
{
Err
(
TestError
::
String
(
"memory location 0x43 is wrong after executing nrom_test"
.to_owned
()))
Err
(
TestError
::
String
(
"memory location 0x43 is wrong after executing nrom_test"
.to_owned
(),
))
}
else
{
}
else
{
Ok
(())
Ok
(())
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment