Skip to content

Commit 8031ab4

Browse files
committed
constants tests
1 parent fca425f commit 8031ab4

File tree

9 files changed

+50
-6
lines changed

9 files changed

+50
-6
lines changed

src/modes/crash.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
; Hydrant's crash theory sheet https://docs.google.com/spreadsheets/d/1zAQIo_mnkk0c9e4-hpeDvVxrl9r_HvLSx8V4h4ttmrs/edit#gid=1013692687
2+
13
testCrash:
24
lda #$1C ; setting all cycles which always happen. for optimizing, this can be removed if all compared numbers are reduced by $6F1C.
35
sta cycleCount

src/nmi/render_util.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ vramPlayfieldRows:
6666
.word $22CC,$22EC,$230C,$232C
6767

6868
copyLowStackRowToVram:
69-
lda lowStackRow
69+
lda lowStackRowModifier
7070
asl
7171
tax
7272
lda vramPlayfieldRows+1,x

src/playstate/lock.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ playState_lockTetrimino:
8585
bcc @notAboveLowStack
8686
ldx #<lowStackNopeGraphic
8787
ldy #>lowStackNopeGraphic
88-
lda lowStackRow
88+
lda lowStackRowModifier
8989
cmp #$09
9090
bcs @drawOnUpperHalf
9191
; draw on lower half

src/playstate/util.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ updateMusicSpeed:
116116

117117
checkIfAboveLowStackLine:
118118
; carry set - block found
119-
ldx lowStackRow
119+
ldx lowStackRowModifier
120120
lda multBy10Table,x
121121
tay
122122
ldx #$0A

src/ram.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ checkerModifier: .res 1
339339
garbageModifier: .res 1
340340
droughtModifier: .res 1
341341
dasModifier: .res 1
342-
lowStackRow: .res 1
342+
lowStackRowModifier: .res 1
343343
scoringModifier: .res 1
344344
crashModifier: .res 1
345345
strictFlag: .res 1 ;used for crash detection. If 1, the game will register a crash anytime there is a possibility of one.

tests/src/constants.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::{labels, util};
2+
3+
pub fn test() {
4+
// check some hardcoded ram addresses are aligned
5+
assert_eq!(labels::get("stack"), 0x100);
6+
assert_eq!(labels::get("playfield"), 0x400);
7+
assert_eq!(labels::get("highscores"), 0x700);
8+
assert_eq!(labels::get("menuRAM"), 0x760);
9+
10+
// check the right amount of menu ram exists
11+
let qty = labels::get("MODE_QUANTITY") as usize;
12+
let cfg = labels::get("menuConfigSizeLookup") as usize;
13+
14+
let mut menu_options = 0;
15+
16+
for i in 0..qty {
17+
if util::rom_data()[cfg + i - 0x8000] != 0 {
18+
menu_options += 1;
19+
}
20+
}
21+
22+
assert_eq!(menu_options, labels::get("palFlag") + 1 - labels::get("menuVars"));
23+
}

tests/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod toprow;
1818
mod tspins;
1919
mod hz_display;
2020
mod nmi;
21+
mod constants;
2122

2223
use gumdrop::Options;
2324

@@ -48,7 +49,7 @@ struct TestOptions {
4849
fn main() {
4950
let options = TestOptions::parse_args_default_or_exit();
5051

51-
let tests: [(&str, fn()); 12] = [
52+
let tests: [(&str, fn()); 13] = [
5253
("garbage4", garbage::test_garbage4_crash),
5354
("floor", floor::test),
5455
("tspins", tspins::test),
@@ -61,6 +62,7 @@ fn main() {
6162
("palettes", palettes::test),
6263
("hz_display", hz_display::test),
6364
("nmi", nmi::test),
65+
("constants", constants::test),
6466
];
6567

6668
// run tests

tests/src/ram.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::labels;
2+
3+
pub fn test() {
4+
// check some hardcoded ram addresses are aligned
5+
assert_eq!(labels::get("stack"), 0x100);
6+
assert_eq!(labels::get("playfield"), 0x400);
7+
assert_eq!(labels::get("highscores"), 0x700);
8+
assert_eq!(labels::get("menuRAM"), 0x760);
9+
10+
println!("{:x}", labels::get("LINECAP_HOW_STRING_OFFSET"));
11+
}

tests/src/util.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ use rusticnes_core::nes::NesState;
22
use rusticnes_core::{ cartridge, opcodes, opcode_info };
33
use crate::{input, labels};
44

5+
static ROM: &'static [u8] = include_bytes!("../../tetris.nes");
6+
7+
pub fn rom_data() -> &'static [u8] {
8+
&ROM[0x10..]
9+
}
10+
511
pub fn emulator(rom: Option<&[u8]>) -> NesState {
6-
let rom = rom.unwrap_or(include_bytes!("../../tetris.nes"));
12+
let rom = rom.unwrap_or(ROM);
713
let mut emu = NesState::new(Box::new(cartridge::mapper_from_file(rom)).unwrap());
814

915
emu.power_on();

0 commit comments

Comments
 (0)