Skip to content

Commit b8c7d67

Browse files
committed
video cleanup
1 parent 3461a40 commit b8c7d67

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

tests/src/main.rs

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn main() {
4848
blocks.set_input((
4949
((options.sps_seed >> 16) & 0xFF) as u8,
5050
((options.sps_seed >> 8) & 0xFF) as u8,
51-
(options.sps_seed& 0xFF) as u8,
51+
(options.sps_seed & 0xFF) as u8,
5252
));
5353

5454
for _ in 0..options.sps_qty {
@@ -57,31 +57,55 @@ fn main() {
5757
println!("");
5858
}
5959

60-
// other stuff
61-
6260
if options.rng_seeds {
6361
println!("{:?}", rng::seeds());
6462
}
6563

64+
// other stuff
65+
66+
let rng_seed = labels::get("rng_seed") as usize;
67+
let main_loop = labels::get("mainLoop");
68+
let practise_type = labels::get("practiseType") as usize;
69+
let game_mode = labels::get("gameMode") as usize;
70+
let level_number = labels::get("levelNumber") as usize;
71+
let b_modifier = labels::get("typeBModifier") as usize;
72+
let mode_typeb = labels::get("MODE_TYPEB") as u8;
73+
6674
if options.foo {
6775
let mut emu = util::emulator(None);
6876
let mut view = video::Video::new();
6977

70-
// spend a few frames bootstrapping
71-
for _ in 0..3 { emu.run_until_vblank(); }
72-
73-
emu.memory.iram_raw[labels::get("practiseType") as usize] = labels::get("MODE_TYPEB") as _;
74-
emu.memory.iram_raw[labels::get("gameMode") as usize] = 4;
75-
emu.memory.iram_raw[labels::get("levelNumber") as usize] = 18;
76-
emu.memory.iram_raw[labels::get("typeBModifier") as usize] = 5;
77-
let label = labels::get("mainLoop");
78-
rusticnes_core::opcodes::push(&mut emu, (label >> 8) as u8);
79-
rusticnes_core::opcodes::push(&mut emu, label as u8);
80-
81-
for _ in 0..10 {
82-
emu.run_until_vblank();
83-
emu.ppu.render_ntsc(256);
84-
view.update(&emu.ppu.filtered_screen);
78+
79+
rng::seeds().iter().for_each(|seed| {
80+
81+
emu.reset();
82+
83+
// spend a few frames bootstrapping
84+
for _ in 0..3 { emu.run_until_vblank(); }
85+
86+
emu.memory.iram_raw[practise_type] = mode_typeb;
87+
emu.memory.iram_raw[game_mode] = 4;
88+
emu.memory.iram_raw[level_number] = 18;
89+
emu.memory.iram_raw[b_modifier] = 5;
90+
91+
emu.memory.iram_raw[rng_seed] = (seed >> 8) as u8;
92+
emu.memory.iram_raw[rng_seed + 1] = *seed as u8;
93+
94+
rusticnes_core::opcodes::push(&mut emu, (main_loop >> 8) as u8);
95+
rusticnes_core::opcodes::push(&mut emu, main_loop as u8);
96+
97+
for _ in 0..23 {
98+
emu.run_until_vblank();
99+
}
100+
101+
emu.ppu.render_ntsc(video::WIDTH);
102+
103+
104+
// for _ in 0..5 {
105+
view.update(&emu.ppu.filtered_screen);
106+
// }
107+
});
108+
loop {
85109
}
86110
}
87111
}

tests/src/util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ pub fn run_to_return(emu: &mut NesState, print: bool) {
2626
break;
2727
}
2828
}
29+
30+
opcodes::pop(emu);
31+
opcodes::pop(emu);
2932
}
3033

3134
pub fn print_step(emu: &mut NesState) {

tests/src/video.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
use minifb::{Window, WindowOptions};
22

3-
const WIDTH: usize = 256;
4-
const HEIGHT: usize = 240;
3+
pub const WIDTH: usize = 256;
4+
pub const HEIGHT: usize = 240;
55

66
pub struct Video {
77
pub window: Window,
88
}
99

1010
impl Video {
1111
pub fn new() -> Self {
12-
let window = Window::new(
12+
let mut window = Window::new(
1313
"video",
1414
WIDTH,
1515
HEIGHT,
1616
WindowOptions::default(),
1717
)
1818
.unwrap_or_else(|e| { panic!("{}", e); });
1919

20+
window.set_position(20, 30);
21+
2022
Self {
2123
window
2224
}

0 commit comments

Comments
 (0)