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 .cgb
ld hl, .daypals ld hl, .daypals
ld a, [TimeOfDayPal] ld a, [TimeOfDayPal]
and (1 << 2) - 1 and $3
cp 3 cp 3
jr nz, .daytime jr nz, .daytime
ld hl, .nightpals ld hl, .nightpals
@ -754,22 +754,23 @@ WipeLYOverrides: ; 8c6d8
StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
and (1 << 6) - 1 ; a = d * sin(a * pi/32)
cp 1 << 5 and %111111
jr nc, .okay cp %100000
call .DoSineWave jr nc, .negative
call .ApplySineWave
ld a, h ld a, h
ret ret
.okay .negative
and (1 << 5) - 1 and %011111
call .DoSineWave call .ApplySineWave
ld a, h ld a, h
xor -1 ; cpl xor $ff
inc a inc a
ret ret
.DoSineWave: ; 8c70c (23:470c) .ApplySineWave: ; 8c70c (23:470c)
ld e, a ld e, a
ld a, d ld a, d
ld d, 0 ld d, 0
@ -780,15 +781,15 @@ StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7)
inc hl inc hl
ld d, [hl] ld d, [hl]
ld hl, 0 ld hl, 0
.loop .multiply
srl a srl a
jr nc, .skip jr nc, .even
add hl, de add hl, de
.skip .even
sla e sla e
rl d rl d
and a and a
jr nz, .loop jr nz, .multiply
ret ret
; 8c728 (23:4728) ; 8c728 (23:4728)

View File

@ -4083,18 +4083,19 @@ BattleAnim_IncAnonJumptableIndex: ; ce72c (33:672c)
ret ret
BattleAnim_Cosine: ; ce732 (33:6732) BattleAnim_Cosine: ; ce732 (33:6732)
add $10 ; a = d * cos(a * pi/32)
add %010000
BattleAnim_Sine: ; ce734 (33:6734) BattleAnim_Sine: ; ce734 (33:6734)
; a = d sin a ; a = d * sin(a * pi/32)
and $3f and %111111
cp $20 cp %100000
jr nc, .negative jr nc, .negative
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
ret ret
.negative .negative
and $1f and %011111
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
xor $ff xor $ff
@ -4111,7 +4112,7 @@ BattleAnim_Sine: ; ce734 (33:6734)
ld e, [hl] ld e, [hl]
inc hl inc hl
ld d, [hl] ld d, [hl]
ld hl, $0 ld hl, 0
.multiply .multiply
srl a srl a
jr nc, .even jr nc, .even

View File

@ -238,27 +238,27 @@ UpdateCelebiPosition: ; 49aa2 (12:5aa2)
CelebiEvent_Cosine: ; 49b3b (12:5b3b) CelebiEvent_Cosine: ; 49b3b (12:5b3b)
add $10 ; a = d * cos(a * pi/32)
and $3f add %010000
cp $20 and %111111
cp %100000
jr nc, .negative jr nc, .negative
call .SineFunction call .ApplySineWave
ld a, h ld a, h
ret ret
.negative .negative
and $1f and %011111
call .SineFunction call .ApplySineWave
ld a, h ld a, h
xor $ff xor $ff
inc a inc a
ret ret
.ApplySineWave: ; 49b52 (12:5b52)
.SineFunction: ; 49b52 (12:5b52)
ld e, a ld e, a
ld a, d ld a, d
ld d, $0 ld d, 0
ld hl, .sinewave ld hl, .sinewave
add hl, de add hl, de
add hl, de add hl, de
@ -276,7 +276,6 @@ CelebiEvent_Cosine: ; 49b3b (12:5b3b)
and a and a
jr nz, .multiply jr nz, .multiply
ret ret
; 49b6e (12:5b6e) ; 49b6e (12:5b6e)
.sinewave ; 49b6e .sinewave ; 49b6e

View File

@ -7,7 +7,6 @@ _Sine:: ; 84d9
and %111111 and %111111
cp %100000 cp %100000
jr nc, .negative jr nc, .negative
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
ret ret
@ -16,7 +15,7 @@ _Sine:: ; 84d9
and %011111 and %011111
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
xor -1 xor $ff
inc a inc a
ret ret
@ -31,7 +30,6 @@ _Sine:: ; 84d9
inc hl inc hl
ld d, [hl] ld d, [hl]
ld hl, 0 ld hl, 0
; Factor amplitude ; Factor amplitude
.multiply .multiply
srl a srl a

View File

@ -576,21 +576,22 @@ BrokenStdGFXPointers: ; Broken 2bpp pointers
Sprites_Cosine: ; 8e72a Sprites_Cosine: ; 8e72a
add $10 ; a = d * cos(a * pi/32)
add %010000
Sprites_Sine: ; 8e72c Sprites_Sine: ; 8e72c
; floor(d * sin(a * pi/32)) ; a = d * sin(a * pi/32)
and $3f and %111111
cp $20 cp %100000
jr nc, .negative jr nc, .negative
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
ret ret
.negative .negative
and $1f and %011111
call .ApplySineWave call .ApplySineWave
ld a, h ld a, h
xor $ff ; cpl xor $ff
inc a inc a
ret ret
; 8e741 ; 8e741
@ -610,7 +611,6 @@ Sprites_Sine: ; 8e72c
srl a srl a
jr nc, .even jr nc, .even
add hl, de add hl, de
.even .even
sla e sla e
rl d rl d

View File

@ -1,6 +1,6 @@
Cosine:: ; 1b0f Cosine:: ; 1b0f
; Return d * cos(a) in hl ; Return d * cos(a) in hl
add $10 ; 90 degrees add %010000 ; 90 degrees
Sine:: ; 1b11 Sine:: ; 1b11
; Return d * sin(a) in hl ; Return d * sin(a) in hl