RAM addresses

Score tally algorithm

When you score points, the points don't immediately go into the player's score (which is an array of 6 decimal digits starting at 0x0370). Instead they go into a "score increment" array (6 decimal digits starting at 0x037c). The points are moved from the score increment to the player's score a little each frame. 10 points are transferred per frame while the tens digits of the score increment is nonzero; otherwise 100 points are transferred. You cannot advance to the next level until all points have been transferred out of the score increment.
See also 6347S#ImprovementsOverThePreviousTas "Why time the score tally?…"
The score tally algorithm starts at 0x8dcb in the ROM. In pseudocode, it works like this:
const DELTA_10  = [0, 0, 0, 0, 1, 0];
const DELTA_100 = [0, 0, 0, 1, 0, 0];

if (score_increment == [0, 0, 0, 0, 0, 0]) {    // 0x037c
    // Early exit if the increment is zero.
    return;
}

if (score_increment[4] != 0) { // Tens digit
    delta = DELTA_10;   // 0x8e59
} else {
    delta = DELTA_100;  // 0x8e5f
}

// Subtract delta from score_increment, store result in score_increment.
decimal_subtract(score_increment, delta, score_increment);

if (current_player == 0) {  // 0x0019
    player_score = p1_score;    // 0x0370
} else {
    player_score = p2_score;    // 0x0376
}
// Add delta to player_score, store result in player_score.
decimal_add(player_score, delta, player_score);

GameResources/NES/Arkanoid last edited by adelikat on 9/2/2023 2:48 PM
Page History Latest diff List referrers View Source