ref: 088f40842f68098193c4185bf3f6a07582590dc5
parent: 222afb247d592201dc228108232e3347c762db87
author: luckytyphlosion <alan.rj.huang@gmail.com>
date: Sun Jul 26 14:19:34 EDT 2015
Bugfixes. Fix some building issues and multiply_divide.asm
--- a/data/baseStats/caterpie.asm
+++ b/data/baseStats/caterpie.asm
@@ -27,4 +27,3 @@
tmlearn 0
tmlearn 0
db 0 ; padding
-b 0 ; padding
--- a/data/baseStats/ditto.asm
+++ b/data/baseStats/ditto.asm
@@ -27,4 +27,3 @@
tmlearn 0
tmlearn 0
db 0 ; padding
-b 0 ; padding
--- a/data/baseStats/kakuna.asm
+++ b/data/baseStats/kakuna.asm
@@ -27,4 +27,3 @@
tmlearn 0
tmlearn 0
db 0 ; padding
-b 0 ; padding
--- a/data/baseStats/magikarp.asm
+++ b/data/baseStats/magikarp.asm
@@ -27,4 +27,3 @@
tmlearn 0
tmlearn 0
db 0 ; padding
-b 0 ; padding
--- a/data/baseStats/metapod.asm
+++ b/data/baseStats/metapod.asm
@@ -27,4 +27,3 @@
tmlearn 0
tmlearn 0
db 0 ; padding
-b 0 ; padding
--- a/data/baseStats/weedle.asm
+++ b/data/baseStats/weedle.asm
@@ -26,5 +26,4 @@
tmlearn 0
tmlearn 0
tmlearn 0
-db 0 ; padding
-b 0 ; padding
+db 0 ; padding
\ No newline at end of file
--- a/engine/multiply_divide.asm
+++ b/engine/multiply_divide.asm
@@ -2,17 +2,16 @@
ld a, $8
ld b, a
xor a
- ld [H_PRODUCT], a ; $ff95
- ld [H_MULTIPLYBUFFER], a ; $ff9b
- ld [H_MULTIPLYBUFFER+1], a ; $ff9c
- ld [H_MULTIPLYBUFFER+2], a ; $ff9d
- ld [H_MULTIPLYBUFFER+3], a ; $ff9e
-.multiplyLoop
- ld a, [H_MULTIPLIER] ; $ff99
+ ld [H_PRODUCT], a
+ ld [H_MULTIPLYBUFFER], a
+ ld [H_MULTIPLYBUFFER+1], a
+ ld [H_MULTIPLYBUFFER+2], a
+ ld [H_MULTIPLYBUFFER+3], a
+.loop
+ ld a, [H_MULTIPLIER]
srl a
- ld [H_MULTIPLIER], a ; $ff99
- jr nc, .smallMultiplier ; less than $80
-; code to possibly multiply the multiplicand by 2 and divide the multiplier by 2?
+ ld [H_MULTIPLIER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
+ jr nc, .smallMultiplier
ld a, [H_MULTIPLYBUFFER+3]
ld c, a
ld a, [H_MULTIPLICAND+2]
@@ -23,73 +22,74 @@
ld a, [H_MULTIPLICAND+1]
adc c
ld [H_MULTIPLYBUFFER+2], a
- ld a, [H_MULTIPLYBUFFER+1] ; $ff9c
+ ld a, [H_MULTIPLYBUFFER+1]
ld c, a
- ld a, [H_MULTIPLICAND] ; $ff96
+ ld a, [H_MULTIPLICAND] ; (aliases: H_MULTIPLICAND)
adc c
- ld [H_MULTIPLYDBUFFER+1], a ; $ff9c
+ ld [H_MULTIPLYBUFFER+1], a
ld a, [H_MULTIPLYBUFFER]
ld c, a
- ld a, [H_PRODUCT] ; $ff95
+ ld a, [H_PRODUCT] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
adc c
ld [H_MULTIPLYBUFFER], a
.smallMultiplier
dec b
jr z, .done
- ld a, [H_MULTIPLICAND]
+ ld a, [H_MULTIPLICAND+2]
sla a
ld [H_MULTIPLICAND+2], a
ld a, [H_MULTIPLICAND+1]
rl a
ld [H_MULTIPLICAND+1], a
- ld a, [H_MULTIPLICAND] ; $ff96
+ ld a, [H_MULTIPLICAND]
rl a
- ld [H_MULTIPLICAND], a ; $ff96
- ld a, [H_PRODUCT] ; $ff95
+ ld [H_MULTIPLICAND], a
+ ld a, [H_PRODUCT]
rl a
- ld [H_PRODUCT], a ; $ff95
- jr .multiplyLoop
+ ld [H_PRODUCT], a
+ jr .loop
.done
ld a, [H_MULTIPLYBUFFER+3]
ld [H_PRODUCT+3], a
ld a, [H_MULTIPLYBUFFER+2]
ld [H_PRODUCT+2], a
- ld a, [H_MULTIPLYBUFFER+1] ; $ff9c
- ld [H_PRODUCT+1], a ; $ff96
- ld [H_PRODUCT], a ; $ff95
+ ld a, [H_MULTIPLYBUFFER+1]
+ ld [H_PRODUCT+1], a
+ ld a, [H_MULTIPLYBUFFER]
+ ld [H_PRODUCT], a
ret
_Divide: ; 37da5 (d:7da5)
xor a
- ld [H_DIVIDEBUFFER], a ; ff9a
- ld [H_DIVIDEBUFFER+1], a ; ff9b
- ld [H_DIVIDEBUFFER+2], a ; ff9c
- ld [H_DIVIDEBUFFER+3], a ; ff9d
- ld [H_DIVIDEBUFFER+4], a ; ff9e
+ ld [H_DIVIDEBUFFER], a
+ ld [H_DIVIDEBUFFER+1], a
+ ld [H_DIVIDEBUFFER+2], a
+ ld [H_DIVIDEBUFFER+3], a
+ ld [H_DIVIDEBUFFER+4], a
ld a, $9
ld e, a
.asm_37db3
ld a, [H_DIVIDEBUFFER]
ld c, a
- ld a, [H_DIVIDEND+1] ; $ff96
+ ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND)
sub c
ld d, a
- ld a, [H_DIVISOR] ; $ff99
+ ld a, [H_DIVISOR] ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
ld c, a
- ld a, [H_DIVIDEND] ; $ff95
+ ld a, [H_DIVIDEND] ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
sbc c
jr c, .asm_37dce
- ld [H_DIVIDEND], a ; $ff95
+ ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
ld a, d
- ld [H_DIVIDEND+1], a ; $ff96
+ ld [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND)
ld a, [H_DIVIDEBUFFER+4]
inc a
ld [H_DIVIDEBUFFER+4], a
jr .asm_37db3
.asm_37dce
- ld a, b
+ ld a, b
cp $1
- jr z, .done
+ jr z, .asm_37e18
ld a, [H_DIVIDEBUFFER+4]
sla a
ld [H_DIVIDEBUFFER+4], a
@@ -96,9 +96,9 @@
ld a, [H_DIVIDEBUFFER+3]
rl a
ld [H_DIVIDEBUFFER+3], a
- ld a, [H_DIVIDEBUFFER+2] ; $ff9c
+ ld a, [H_DIVIDEBUFFER+2]
rl a
- ld [H_DIVIDEBUFFER+2], a ; $ff9c
+ ld [H_DIVIDEBUFFER+2], a
ld a, [H_DIVIDEBUFFER+1]
rl a
ld [H_DIVIDEBUFFER+1], a
@@ -107,13 +107,13 @@
ld a, $8
ld e, a
ld a, [H_DIVIDEBUFFER]
- ld [H_DIVISOR], a ; $ff99
+ ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
xor a
ld [H_DIVIDEBUFFER], a
- ld a, [H_DIVIDEND+1] ; $ff96
- ld [H_DIVIDEND], a ; $ff95
+ ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND)
+ ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
ld a, [H_DIVIDEND+2]
- ld [H_DIVIDEND+1], a ; $ff96
+ ld [H_DIVIDEND+1], a ; (aliases: H_MULTIPLICAND)
ld a, [H_DIVIDEND+3]
ld [H_DIVIDEND+2], a
.asm_37e04
@@ -122,22 +122,22 @@
jr nz, .asm_37e0a
dec b
.asm_37e0a
- ld a, [H_DIVIDEND+4] ; $ff99
+ ld a, [H_DIVISOR] ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
srl a
- ld [H_REMAINDER], a ; $ff99
+ ld [H_DIVISOR], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
ld a, [H_DIVIDEBUFFER]
rr a
ld [H_DIVIDEBUFFER], a
jr .asm_37db3
-.done
- ld a, [H_DIVIDEND+1] ; $ff96
- ld [H_REMAINDER], a ; $ff99
+.asm_37e18
+ ld a, [H_DIVIDEND+1] ; (aliases: H_MULTIPLICAND)
+ ld [H_REMAINDER], a ; (aliases: H_DIVISOR, H_MULTIPLIER, H_POWEROFTEN)
ld a, [H_DIVIDEBUFFER+4]
ld [H_QUOTIENT+3], a
ld a, [H_DIVIDEBUFFER+3]
ld [H_QUOTIENT+2], a
- ld a, [H_DIVIDEBUFFER+2] ; $ff9c
- ld [H_QUOTIENT+1], a ; $ff96
+ ld a, [H_DIVIDEBUFFER+2]
+ ld [H_QUOTIENT+1], a ; (aliases: H_MULTIPLICAND)
ld a, [H_DIVIDEBUFFER+1]
- ld [H_QUOTIENT], a ; $ff95
- ret
+ ld [H_DIVIDEND], a ; (aliases: H_PRODUCT, H_PASTLEADINGZEROES, H_QUOTIENT)
+ ret
\ No newline at end of file