File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ pub fn test() {
5
5
6
6
for pushdown in 2 ..15 {
7
7
[ 0 ..1000 , 24500 ..25500 , 60000 ..65536 ] . into_iter ( ) . for_each ( |range| {
8
+ // [0..65535].into_iter().for_each(|range| {
8
9
for score in range {
9
10
score:: set ( & mut emu, score) ;
10
11
@@ -22,24 +23,22 @@ pub fn test() {
22
23
}
23
24
24
25
// reference implementation - tested against the original game
25
- // may seem weird - designed to be translated to assembly
26
26
fn pushdown_impl ( pushdown : u8 , score : u16 ) -> u16 {
27
27
let ones = score % 10 ;
28
28
let hundredths = score % 100 ;
29
- let mut newscore = ones as u8 + ( pushdown - 1 ) ;
30
- if newscore & 0xF > 9 {
31
- newscore += 6 ;
32
- }
33
-
34
- let low = ( newscore & 0xF ) as u16 ;
35
- let high = ( ( newscore & 0xF0 ) / 16 * 10 ) as u16 ;
36
29
37
- let mut newscore = high + ( hundredths - ones) ;
38
- let nextscore = newscore + low;
30
+ let mut added = ones + ( pushdown as u16 - 1 ) ;
39
31
40
- if nextscore <= 100 {
41
- newscore = nextscore ;
32
+ if added & 0xF > 9 {
33
+ added += 6 ;
42
34
}
43
35
44
- newscore - hundredths
36
+ let low = added & 0xF ;
37
+ let high = ( added >> 4 ) * 10 ;
38
+
39
+ if high + low + hundredths - ones <= 100 {
40
+ high + low - ones
41
+ } else {
42
+ high - ones
43
+ }
45
44
}
You can’t perform that action at this time.
0 commit comments