Skip to content

NSF driver: optimize tempo calculation #414

Description

@Gumball2415

Whenever the driver calculates the next tempo tick interval through ft_restore_speed, it has to do this for unfixed-tick BPM:

player.s L1738

	lda var_Tempo_Accum
	adc var_Tempo_Dec
	sta var_Tempo_Accum
	lda var_Tempo_Accum + 1
	adc var_Tempo_Dec + 1
	sta var_Tempo_Accum + 1
	sec
	lda var_Tempo_Accum
	sbc var_Tempo_Modulus
	sta var_Tempo_Accum
	lda var_Tempo_Accum + 1
	sbc var_Tempo_Modulus + 1
	sta var_Tempo_Accum + 1

in pseudocode, this would mean Accumulator += RegionSpeedDivider; Accumulator -= Modulus;.

At this point, the modulus and the decrement would be constant after calling ft_calculate_speed. it would be optimal to cache the difference of RegionSpeedDivider and Modulus (DecrementMod = RegionSpeedDivider - Modulus;), and then add it to the Accumulator as Accumulator += DecrementMod;.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnsf-driverInvolves the 6502 asm sound engine used in ROM / assembly export

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions