# HG changeset patch # User Laurens Holst # Date 1538435333 -7200 # Tue Oct 02 01:08:53 2018 +0200 # Node ID a5f825852c52286ddb83b88becf429f75e52a17c # Parent 5caf0d49041baf345e954f99614666b5657a9ddf PSGTone/Noise/Envelope: Reduce the number of shifts done in Math_Pow2. diff --git a/src/modules/PSGEnvelope.asm b/src/modules/PSGEnvelope.asm --- a/src/modules/PSGEnvelope.asm +++ b/src/modules/PSGEnvelope.asm @@ -47,7 +47,10 @@ PSGEnvelope_GetPeriod: ld hl,0AAABH ; de = hl * (1 / 1.5) muluw hl,bc - ld hl,-10773 ; (69 / 12 - log2(440) - log2(256) + log2(3579545) - 16) * 2048 + ld hl,5611 ; (69 / 12 - log2(440) - log2(256) + log2(3579545) - 8) * 2048 and a sbc hl,de - jp Math_Pow2 + call Math_Pow2 + ld l,h + ld h,e + ret diff --git a/src/modules/PSGNoise.asm b/src/modules/PSGNoise.asm --- a/src/modules/PSGNoise.asm +++ b/src/modules/PSGNoise.asm @@ -33,10 +33,12 @@ PSGNoise_GetPeriod: ld hl,0AAABH ; de = hl * (1 / 1.5) muluw hl,bc - ld hl,-14869 ; (69 / 12 - 6 - log2(440) - log2(16) + log2(3579545) - 16) * 2048 + ld hl,1515 ; (69 / 12 - 6 - log2(440) - log2(16) + log2(3579545) - 8) * 2048 and a sbc hl,de call Math_Pow2 + ld l,h + ld h,e ld a,l and ~1FH or h diff --git a/src/modules/PSGTone.asm b/src/modules/PSGTone.asm --- a/src/modules/PSGTone.asm +++ b/src/modules/PSGTone.asm @@ -49,10 +49,12 @@ PSGTone_GetPeriod: ld hl,0AAABH ; de = hl * (1 / 1.5) muluw hl,bc - ld hl,-2580 ; (69 / 12 - log2(440) - log2(16) + log2(3579545) - 16) * 2048 + ld hl,13803 ; (69 / 12 - log2(440) - log2(16) + log2(3579545) - 8) * 2048 and a sbc hl,de call Math_Pow2 + ld l,h + ld h,e ld a,h and ~0FH ret z