Skip to content

Commit c37f96c

Browse files
committed
score accumulation test
1 parent 39e9c28 commit c37f96c

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
* [Qualifier Mode](#qual-mode)
4444
* [PAL Mode](#pal-mode)
4545
* [Development](#development)
46-
* [Resources](#resources)
4746

4847
## Getting Started
4948

@@ -429,11 +428,4 @@ To build, you need a copy of `node` installed on your system. No other dependenc
429428

430429
Provide a `clean.nes` file of the unpatched ROM and run `node build.js`
431430

432-
This project descends from the TAUS disassembly of NES Tetris and has been heavily modified. Large parts have been replaced, lots of optimisations, removal of unused code, non-game-mechanics related bugfixes, tooling, and different approaches to the disassembly work itself has taken place.
433-
434-
435-
## Resources
436-
437-
* [https://github.com/ejona86/taus](https://github.com/ejona86/taus)
438-
* [https://github.com/CelestialAmber/TetrisNESDisasm](https://github.com/CelestialAmber/TetrisNESDisasm)
439-
* [https://github.com/pinobatch/holy-mapperel](https://github.com/pinobatch/holy-mapperel)
431+
This project descends from the [https://github.com/ejona86/taus](TAUS) and [https://github.com/CelestialAmber/TetrisNESDisasm](CelestialAmber) disassemblies of NES Tetris and has been heavily modified. Large parts have been replaced, lots of optimisations, removal of unused code, non-game-mechanics related bugfixes, tooling, and different approaches to the disassembly work itself has taken place.

tests/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct TestOptions {
5050
fn main() {
5151
let options = TestOptions::parse_args_default_or_exit();
5252

53-
let tests: [(&str, fn()); 13] = [
53+
let tests: [(&str, fn()); 14] = [
5454
("garbage4", garbage::test_garbage4_crash),
5555
("floor", floor::test),
5656
("tspins", tspins::test),

tests/src/score.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn get(emu: &mut NesState) -> u32 {
2525
emu.memory.iram_raw[binscore_addr as usize] as u32
2626
+ ((emu.memory.iram_raw[(binscore_addr + 1) as usize] as u32) << 8)
2727
+ ((emu.memory.iram_raw[(binscore_addr + 2) as usize] as u32) << 16)
28+
+ ((emu.memory.iram_raw[(binscore_addr + 3) as usize] as u32) << 24)
2829
}
2930

3031
pub fn test() {
@@ -54,6 +55,20 @@ pub fn test() {
5455
for initial_score in 999499..=1000501 {
5556
assert_eq!(score(initial_score, 4, 18), initial_score + score_impl(4, 18));
5657
}
58+
59+
// keep adding scores
60+
let mut accumulator = 0;
61+
let mut emu = util::emulator(None);
62+
63+
for _ in 0..2000 {
64+
accumulator += score_impl(4, 235);
65+
emu.registers.pc = add_points;
66+
emu.memory.iram_raw[completed_lines] = 4;
67+
emu.memory.iram_raw[level_number] = 235;
68+
util::run_to_return(&mut emu, false);
69+
assert_eq!(score::get(&mut emu), accumulator);
70+
}
71+
5772
}
5873

5974
pub fn score_impl(lines: u8, level: u8) -> u32 {

0 commit comments

Comments
 (0)