diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2018-01-09 16:39:36 -0500 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2018-01-09 16:39:36 -0500 |
commit | 11556196ba546f5c45b97fffc2c263a79eb639b9 (patch) | |
tree | bff73d91ac9caba31703b4671db1f0d59524fa3f | |
parent | a849c3557b8ee3dd2b464ccdc646aebd33d7b2a7 (diff) |
Consistent sine wave code formatting
-rw-r--r-- | engine/battle/battle_transition.asm | 29 | ||||
-rwxr-xr-x | engine/battle_anims/functions.asm | 13 | ||||
-rwxr-xr-x | engine/events/celebi.asm | 19 | ||||
-rwxr-xr-x | engine/routines/sine.asm | 4 | ||||
-rwxr-xr-x | engine/sprites.asm | 14 | ||||
-rw-r--r-- | home/sine.asm | 2 |
6 files changed, 40 insertions, 41 deletions
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 85ba44072..af7bb688f 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -640,7 +640,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc) .cgb ld hl, .daypals ld a, [TimeOfDayPal] - and (1 << 2) - 1 + and $3 cp 3 jr nz, .daytime ld hl, .nightpals @@ -754,22 +754,23 @@ WipeLYOverrides: ; 8c6d8 StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) - and (1 << 6) - 1 - cp 1 << 5 - jr nc, .okay - call .DoSineWave +; a = d * sin(a * pi/32) + and %111111 + cp %100000 + jr nc, .negative + call .ApplySineWave ld a, h ret -.okay - and (1 << 5) - 1 - call .DoSineWave +.negative + and %011111 + call .ApplySineWave ld a, h - xor -1 ; cpl + xor $ff inc a ret -.DoSineWave: ; 8c70c (23:470c) +.ApplySineWave: ; 8c70c (23:470c) ld e, a ld a, d ld d, 0 @@ -780,15 +781,15 @@ StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) inc hl ld d, [hl] ld hl, 0 -.loop +.multiply srl a - jr nc, .skip + jr nc, .even add hl, de -.skip +.even sla e rl d and a - jr nz, .loop + jr nz, .multiply ret ; 8c728 (23:4728) diff --git a/engine/battle_anims/functions.asm b/engine/battle_anims/functions.asm index ea9fb70b3..4b77cd77c 100755 --- a/engine/battle_anims/functions.asm +++ b/engine/battle_anims/functions.asm @@ -4083,18 +4083,19 @@ BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c) ret BattleAnim_Cosine: ; ce732 (33:6732) - add $10 +; a = d * cos(a * pi/32) + add %010000 BattleAnim_Sine: ; ce734 (33:6734) -; a = d sin a - and $3f - cp $20 +; a = d * sin(a * pi/32) + and %111111 + cp %100000 jr nc, .negative call .ApplySineWave ld a, h ret .negative - and $1f + and %011111 call .ApplySineWave ld a, h xor $ff @@ -4111,7 +4112,7 @@ BattleAnim_Sine: ; ce734 (33:6734) ld e, [hl] inc hl ld d, [hl] - ld hl, $0 + ld hl, 0 .multiply srl a jr nc, .even diff --git a/engine/events/celebi.asm b/engine/events/celebi.asm index 1139ad3d5..22f8f00a4 100755 --- a/engine/events/celebi.asm +++ b/engine/events/celebi.asm @@ -238,27 +238,27 @@ UpdateCelebiPosition: ; 49aa2 (12:5aa2) CelebiEvent_Cosine: ; 49b3b (12:5b3b) - add $10 - and $3f - cp $20 +; a = d * cos(a * pi/32) + add %010000 + and %111111 + cp %100000 jr nc, .negative - call .SineFunction + call .ApplySineWave ld a, h ret .negative - and $1f - call .SineFunction + and %011111 + call .ApplySineWave ld a, h xor $ff inc a ret - -.SineFunction: ; 49b52 (12:5b52) +.ApplySineWave: ; 49b52 (12:5b52) ld e, a ld a, d - ld d, $0 + ld d, 0 ld hl, .sinewave add hl, de add hl, de @@ -276,7 +276,6 @@ CelebiEvent_Cosine: ; 49b3b (12:5b3b) and a jr nz, .multiply ret - ; 49b6e (12:5b6e) .sinewave ; 49b6e diff --git a/engine/routines/sine.asm b/engine/routines/sine.asm index 89a905d2e..5f56a10a8 100755 --- a/engine/routines/sine.asm +++ b/engine/routines/sine.asm @@ -7,7 +7,6 @@ _Sine:: ; 84d9 and %111111 cp %100000 jr nc, .negative - call .ApplySineWave ld a, h ret @@ -16,7 +15,7 @@ _Sine:: ; 84d9 and %011111 call .ApplySineWave ld a, h - xor -1 + xor $ff inc a ret @@ -31,7 +30,6 @@ _Sine:: ; 84d9 inc hl ld d, [hl] ld hl, 0 - ; Factor amplitude .multiply srl a diff --git a/engine/sprites.asm b/engine/sprites.asm index 740c3ef68..1ccd7b6a0 100755 --- a/engine/sprites.asm +++ b/engine/sprites.asm @@ -576,21 +576,22 @@ BrokenStdGFXPointers: ; Broken 2bpp pointers Sprites_Cosine: ; 8e72a - add $10 +; a = d * cos(a * pi/32) + add %010000 Sprites_Sine: ; 8e72c -; floor(d * sin(a * pi/32)) - and $3f - cp $20 +; a = d * sin(a * pi/32) + and %111111 + cp %100000 jr nc, .negative call .ApplySineWave ld a, h ret .negative - and $1f + and %011111 call .ApplySineWave ld a, h - xor $ff ; cpl + xor $ff inc a ret ; 8e741 @@ -610,7 +611,6 @@ Sprites_Sine: ; 8e72c srl a jr nc, .even add hl, de - .even sla e rl d diff --git a/home/sine.asm b/home/sine.asm index 810845860..eff5ed299 100644 --- a/home/sine.asm +++ b/home/sine.asm @@ -1,6 +1,6 @@ Cosine:: ; 1b0f ; Return d * cos(a) in hl - add $10 ; 90 degrees + add %010000 ; 90 degrees Sine:: ; 1b11 ; Return d * sin(a) in hl |