Consistent sine wave code formatting

This commit is contained in:
Remy Oukaour 2018-01-09 16:39:36 -05:00
parent a849c3557b
commit 11556196ba
6 changed files with 40 additions and 41 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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