diff options
-rw-r--r-- | home.asm | 5 | ||||
-rw-r--r-- | home/random.asm | 2 |
2 files changed, 4 insertions, 3 deletions
@@ -785,9 +785,10 @@ INCLUDE "home/random.asm" INCLUDE "home/joypad.asm" INCLUDE "home/palettes.asm" -HorrendousMultiplyAbyL: ; 0xdd4 +MultiplyAbyL_AncientEgyptian: ; 0xdd4 ; Return a * l to hl -; Stupid waste of space +; This is a constant-time multiplication algorithm that uses binary decomposition to achieve the result. +; See https://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication push bc ld c, l ld b, $0 diff --git a/home/random.asm b/home/random.asm index ce34f69..c532ec5 100644 --- a/home/random.asm +++ b/home/random.asm @@ -119,7 +119,7 @@ RandomRange: ; 0xa21 add hl, bc ld l, [hl] call GenRandom - call HorrendousMultiplyAbyL + call MultiplyAbyL_AncientEgyptian inc h srl h ld a, h |