shithub: pokecrystal

Download patch

ref: d84ebd212434dd754729543b257cd17fed9e54d4
parent: a32b6ccbb5b9ad15befa3b9893659f2ceabd1ba0
author: PikalaxALT <[email protected]>
date: Fri Jul 29 06:40:54 EDT 2016

pitchoffset macro to replace forceoctave

--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -231,7 +231,6 @@
 	ld l, a
 	jp [hl]
 
-
 .ChannelFnPtrs:
 	dw .Channel1
 	dw .Channel2
@@ -643,7 +642,6 @@
 	dec a
 	jr .updatevolume
 
-
 .novolume
 	; make sure volume is off
 	xor a
@@ -1211,8 +1209,6 @@
 	set NOTE_UNKN_4, [hl]
 	jp LoadNote
 
-
-
 .rest
 ; note = rest
 	ld hl, Channel1NoteFlags - Channel1
@@ -1220,7 +1216,6 @@
 	set NOTE_REST, [hl] ; Rest
 	ret
 
-;
 .endchannel
 ; $ff is reached in music data
 	ld hl, Channel1Flags - Channel1
@@ -1808,10 +1803,12 @@
 	ld [wCurNoteDuration], a
 
 	call GetMusicByte
+	; pitch in e
 	ld d, a
 	and $f
 	ld e, a
 
+	; octave in d
 	ld a, d
 	swap a
 	and $f
@@ -2054,7 +2051,7 @@
 ; this forces all notes up by the starting octave
 ; params: 1
 	call GetMusicByte
-	ld hl, Channel1StartingOctave - Channel1
+	ld hl, Channel1PitchOffset - Channel1
 	add hl, bc
 	ld [hl], a
 	ret
@@ -2246,7 +2243,7 @@
 
 ; get octave
 	; get starting octave
-	ld hl, Channel1StartingOctave - Channel1
+	ld hl, Channel1PitchOffset - Channel1
 	add hl, bc
 	ld a, [hl]
 	swap a ; hi nybble
@@ -2255,7 +2252,7 @@
 	add d
 	push af ; we'll use this later
 	; get starting octave
-	ld hl, Channel1StartingOctave - Channel1
+	ld hl, Channel1PitchOffset - Channel1
 	add hl, bc
 	ld a, [hl]
 	and $f ; lo nybble
@@ -2573,7 +2570,6 @@
 	dec a
 	jr nz, .loop
 
-
 ; Cries play at max volume, so we save the current volume for later.
 	ld a, [LastVolume]
 	and a
@@ -2693,7 +2689,6 @@
 
 ; e8ca6
 
-
 PlayStereoSFX:: ; e8ca6
 ; play sfx de
 
@@ -2797,7 +2792,6 @@
 
 ; e8d1b
 
-
 LoadChannel: ; e8d1b
 ; prep channel for use
 ; input:
@@ -2889,31 +2883,31 @@
 ; e8d80
 
 FrequencyTable: ; e8d80
-	dw 0 ; filler
-	dw $f82c
-	dw $f89d
-	dw $f907
-	dw $f96b
-	dw $f9ca
-	dw $fa23
-	dw $fa77
-	dw $fac7
-	dw $fb12
-	dw $fb58
-	dw $fb9b
-	dw $fbda
-	dw $fc16
-	dw $fc4e
-	dw $fc83
-	dw $fcb5
-	dw $fce5
-	dw $fd11
-	dw $fd3b
-	dw $fd63
-	dw $fd89
-	dw $fdac
-	dw $fdcd
-	dw $fded
+	dw 0     ; __
+	dw $f82c ; C_
+	dw $f89d ; C#
+	dw $f907 ; D_
+	dw $f96b ; D#
+	dw $f9ca ; E_
+	dw $fa23 ; F_
+	dw $fa77 ; F#
+	dw $fac7 ; G_
+	dw $fb12 ; G#
+	dw $fb58 ; A_
+	dw $fb9b ; A#
+	dw $fbda ; B_
+	dw $fc16 ; C_
+	dw $fc4e ; C#
+	dw $fc83 ; D_
+	dw $fcb5 ; D#
+	dw $fce5 ; E_
+	dw $fd11 ; F_
+	dw $fd3b ; F#
+	dw $fd63 ; G_
+	dw $fd89 ; G#
+	dw $fdac ; A_
+	dw $fdcd ; A#
+	dw $fded ; B_
 ; e8db2
 
 WaveSamples: ; e8db2
--- a/audio/music/clair.asm
+++ b/audio/music/clair.asm
@@ -207,9 +207,9 @@
 	octave 3
 	note A#, 16
 	note __, 4
-	forceoctave $c
+	pitchoffset 0, CC
 	callchannel Music_Clair_branch_1fba6
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 5
 	note F#, 2
 	note __, 4
@@ -254,7 +254,7 @@
 
 Music_Clair_Ch3: ; 1fbb9
 	notetype $c, $14
-	forceoctave $c
+	pitchoffset 0, CC
 	octave 3
 	note C#, 2
 	note __, 4
--- a/audio/music/credits.asm
+++ b/audio/music/credits.asm
@@ -142,12 +142,12 @@
 	note E_, 7
 	octave 3
 	note __, 1
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_Credits_branch_1f483
 	callchannel Music_Credits_branch_1f4ed
 	callchannel Music_Credits_branch_1f4f8
 	callchannel Music_Credits_branch_1f559
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 3
 	note A_, 12
 	notetype $8, $a7
@@ -664,11 +664,11 @@
 	note A_, 4
 	note G_, 4
 	notetype $6, $c7
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_Credits_branch_1f6cb
 	callchannel Music_Credits_branch_1f73f
 	callchannel Music_Credits_branch_1f748
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 5
 	note C#, 1
 	note D_, 11
@@ -1139,15 +1139,15 @@
 	note F_, 1
 	note F#, 7
 	note G_, 8
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_Credits_branch_1f8aa
 	callchannel Music_Credits_branch_1f8db
-	forceoctave $12
+	pitchoffset 1, D_
 	callchannel Music_Credits_branch_1f8e7
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_Credits_branch_1f934
 	callchannel Music_Credits_branch_1f94b
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 6
 	note C#, 2
 	octave 5
--- a/audio/music/evolution.asm
+++ b/audio/music/evolution.asm
@@ -13,13 +13,13 @@
 	dutycycle $2
 	notetype $c, $92
 	octave 3
-	slidepitchto 0, 4, A_
+	slidepitchto 1, 4, A_
 	note C_, 1
-	slidepitchto 0, 4, A_
+	slidepitchto 1, 4, A_
 	note G_, 1
-	slidepitchto 0, 4, A_
+	slidepitchto 1, 4, A_
 	note C_, 1
-	slidepitchto 0, 4, A_
+	slidepitchto 1, 4, A_
 	note G_, 1
 	note __, 4
 	dutycycle $3
--- a/audio/music/healpokemon.asm
+++ b/audio/music/healpokemon.asm
@@ -11,16 +11,16 @@
 	tone $0001
 	notetype $c, $81
 	note __, 2
-	slidepitchto 0, 4, __
+	slidepitchto 1, 4, __
 	note B_, 2
-	slidepitchto 0, 5, E_
+	slidepitchto 1, 5, E_
 	note B_, 2
-	slidepitchto 0, 4, E_
+	slidepitchto 1, 4, E_
 	note E_, 2
 	note __, 4
-	slidepitchto 0, 3, __
+	slidepitchto 1, 3, __
 	note E_, 4
-	slidepitchto 0, 4, __
+	slidepitchto 1, 4, __
 	note B_, 4
 	endchannel
 ; f06c4
--- a/audio/music/kantotrainerbattle.asm
+++ b/audio/music/kantotrainerbattle.asm
@@ -9,7 +9,7 @@
 Music_KantoTrainerBattle_Ch1: ; eca04
 	tempo 114
 	volume $77
-	forceoctave $1b
+	pitchoffset 1, B_
 	notetype $c, $b3
 	vibrato $12, $24
 	dutycycle $1
@@ -467,7 +467,7 @@
 ; ecbea
 
 Music_KantoTrainerBattle_Ch2: ; ecbea
-	forceoctave $1b
+	pitchoffset 1, B_
 	vibrato $6, $36
 	dutycycle $1
 	notetype $c, $d1
@@ -920,7 +920,7 @@
 ; ecdd2
 
 Music_KantoTrainerBattle_Ch3: ; ecdd2
-	forceoctave $1b
+	pitchoffset 1, B_
 	vibrato $12, $23
 	notetype $c, $15
 	octave 2
--- a/audio/music/kantowildbattle.asm
+++ b/audio/music/kantowildbattle.asm
@@ -327,17 +327,17 @@
 	notetype $6, $b7
 	callchannel Music_KantoWildBattle_branch_ed307
 	callchannel Music_KantoWildBattle_branch_ed307
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_KantoWildBattle_branch_ed307
 	callchannel Music_KantoWildBattle_branch_ed307
-	forceoctave $0
+	pitchoffset 0, C_
 rept 4
 	callchannel Music_KantoWildBattle_branch_ed307
 endr
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_KantoWildBattle_branch_ed307
 	callchannel Music_KantoWildBattle_branch_ed307
-	forceoctave $0
+	pitchoffset 0, C_
 	callchannel Music_KantoWildBattle_branch_ed307
 	callchannel Music_KantoWildBattle_branch_ed307
 	note __, 16
@@ -384,9 +384,9 @@
 	note G#, 1
 	notetype $6, $b7
 	callchannel Music_KantoWildBattle_branch_ed31b
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_KantoWildBattle_branch_ed31b
-	forceoctave $0
+	pitchoffset 0, C_
 	callchannel Music_KantoWildBattle_branch_ed340
 	octave 2
 	note C_, 2
@@ -450,9 +450,9 @@
 	callchannel Music_KantoWildBattle_branch_ed354
 	callchannel Music_KantoWildBattle_branch_ed340
 	callchannel Music_KantoWildBattle_branch_ed354
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_KantoWildBattle_branch_ed340
-	forceoctave $0
+	pitchoffset 0, C_
 	note C#, 2
 	note __, 2
 	octave 3
--- a/audio/music/lookofficer.asm
+++ b/audio/music/lookofficer.asm
@@ -73,9 +73,9 @@
 	note E_, 2
 	note G#, 2
 	loopchannel 2, Music_LookOfficer_branch_ed882
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_LookOfficer_branch_ed89e
-	forceoctave $0
+	pitchoffset 0, C_
 	callchannel Music_LookOfficer_branch_ed89e
 	loopchannel 0, Music_LookOfficer_branch_ed882
 ; ed89e
--- a/audio/music/lookrocket.asm
+++ b/audio/music/lookrocket.asm
@@ -8,7 +8,7 @@
 Music_LookRocket_Ch1: ; f74ae
 	tempo 123
 	volume $77
-	forceoctave $2
+	pitchoffset 0, D_
 	stereopanning $f
 	dutycycle $3
 	vibrato $5, $64
@@ -94,7 +94,7 @@
 ; f7514
 
 Music_LookRocket_Ch2: ; f7514
-	forceoctave $2
+	pitchoffset 0, D_
 	vibrato $4, $64
 	dutycycle $3
 	notetype $c, $b7
@@ -216,7 +216,7 @@
 ; f7597
 
 Music_LookRocket_Ch3: ; f7597
-	forceoctave $2
+	pitchoffset 0, D_
 	vibrato $4, $22
 	notetype $c, $14
 	stereopanning $f0
--- a/audio/music/postcredits.asm
+++ b/audio/music/postcredits.asm
@@ -8,7 +8,7 @@
 Music_PostCredits_Ch1: ; cfda5
 	tempo 271
 	volume $77
-	forceoctave $3
+	pitchoffset 0, D#
 	dutycycle $2
 	notetype $c, $93
 	note __, 8
@@ -133,7 +133,7 @@
 ; cfe48
 
 Music_PostCredits_Ch2: ; cfe48
-	forceoctave $3
+	pitchoffset 0, D#
 	dutycycle $2
 	notetype $c, $a3
 	octave 5
--- a/audio/music/profoak.asm
+++ b/audio/music/profoak.asm
@@ -34,10 +34,10 @@
 	callchannel Music_ProfOak_branch_f4e58
 	callchannel Music_ProfOak_branch_f4e6c
 	callchannel Music_ProfOak_branch_f4e6c
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_ProfOak_branch_f4e58
 	callchannel Music_ProfOak_branch_f4e58
-	forceoctave $0
+	pitchoffset 0, C_
 	callchannel Music_ProfOak_branch_f4e6c
 	callchannel Music_ProfOak_branch_f4e6c
 	loopchannel 0, Music_ProfOak_branch_f4e22
@@ -241,10 +241,10 @@
 	callchannel Music_ProfOak_branch_f4f5a
 	callchannel Music_ProfOak_branch_f4f69
 	callchannel Music_ProfOak_branch_f4f69
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Music_ProfOak_branch_f4f5a
 	callchannel Music_ProfOak_branch_f4f5a
-	forceoctave $0
+	pitchoffset 0, C_
 	callchannel Music_ProfOak_branch_f4f69
 	callchannel Music_ProfOak_branch_f4f69
 	loopchannel 0, Music_ProfOak_branch_f4f1d
--- a/audio/music/ssaqua.asm
+++ b/audio/music/ssaqua.asm
@@ -276,9 +276,9 @@
 	octave 4
 	note C#, 1
 	note E_, 1
-	forceoctave $c
+	pitchoffset 0, CC
 	callchannel Music_SSAqua_branch_eafe0
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 3
 	note B_, 1
 	note __, 1
--- a/audio/music/surf.asm
+++ b/audio/music/surf.asm
@@ -425,7 +425,7 @@
 	note B_, 16
 	octave 4
 	note C#, 8
-	forceoctave $c
+	pitchoffset 0, CC
 	dutycycle $3
 	callchannel Music_Surf_branch_f53d6
 	intensity $b8
@@ -436,7 +436,7 @@
 	intensity $b8
 	dutycycle $1
 	callchannel Music_Surf_branch_f5404
-	forceoctave $0
+	pitchoffset 0, C_
 	notetype $c, $b8
 	octave 4
 	note B_, 12
--- a/audio/music/wildpokemonvictory.asm
+++ b/audio/music/wildpokemonvictory.asm
@@ -29,7 +29,7 @@
 	intensity $78
 	octave 3
 	note G_, 4
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_WildPokemonVictory_branch_f455c
 	note F#, 2
 	note F#, 2
@@ -36,7 +36,7 @@
 	note F#, 4
 	callchannel Music_WildPokemonVictory_branch_f455c
 	note G#, 4
-	forceoctave $0
+	pitchoffset 0, C_
 	intensity $78
 	octave 3
 	note F#, 4
@@ -97,7 +97,7 @@
 	note E_, 1
 	note G_, 1
 	note A#, 1
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_WildPokemonVictory_branch_f45b5
 	octave 4
 	note B_, 2
@@ -106,7 +106,7 @@
 	callchannel Music_WildPokemonVictory_branch_f45b5
 	octave 4
 	note B_, 4
-	forceoctave $0
+	pitchoffset 0, C_
 	intensity $81
 	octave 3
 	note B_, 1
@@ -156,7 +156,7 @@
 	note E_, 2
 	note __, 2
 	note C_, 4
-	forceoctave $1
+	pitchoffset 0, C#
 	callchannel Music_WildPokemonVictory_branch_f45f4
 	note D#, 2
 	note C#, 2
@@ -166,7 +166,7 @@
 	callchannel Music_WildPokemonVictory_branch_f45f4
 	note E_, 2
 	note __, 2
-	forceoctave $0
+	pitchoffset 0, C_
 	octave 2
 	note B_, 4
 	loopchannel 0, Music_WildPokemonVictory_branch_f45cf
--- a/audio/sfx.asm
+++ b/audio/sfx.asm
@@ -1957,9 +1957,9 @@
 	note F_, 3
 	callchannel Sfx_GetBadge_branch_f11aa
 	note A#, 3
-	forceoctave $2
+	pitchoffset 0, D_
 	callchannel Sfx_GetBadge_branch_f11aa
-	forceoctave $0
+	pitchoffset 0, C_
 	intensity $a7
 	note A_, 16
 	note __, 6
--- a/audio/sfx_crystal.asm
+++ b/audio/sfx_crystal.asm
@@ -169,7 +169,7 @@
 	dutycycle $2
 	notetype $2, $b1
 	soundinput $ff
-	forceoctave $1a
+	pitchoffset 1, A#
 	octave 5
 	note C_, 2
 	note E_, 2
@@ -194,7 +194,7 @@
 Sfx_Tingle_Ch5: ; 179964
 	togglesfx
 	dutycycle $1
-	forceoctave $b
+	pitchoffset 0, B_
 	notetype $1, $b1
 Sfx_Tingle_branch_17996c: ; 17996c
 	octave 5
@@ -234,7 +234,7 @@
 	togglesfx
 	dutycycle $2
 	notetype $2, $e8
-	forceoctave $2
+	pitchoffset 0, D_
 	octave 4
 	note C_, 2
 	intensity $48
@@ -279,7 +279,7 @@
 Sfx_Twinkle_Ch5: ; 1799ce
 	togglesfx
 	dutycycle $0
-	forceoctave $2
+	pitchoffset 0, D_
 	notetype $2, $e1
 	octave 3
 	note G_, 2
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -15,6 +15,7 @@
 	const A_
 	const A#
 	const B_
+	const CC ; used for pitchoffset
 
 ; channel
 	const_def
--- a/engine/events_3.asm
+++ b/engine/events_3.asm
@@ -65,7 +65,7 @@
 	ld a, [wPreviousLandmark]
 	cp c
 	ret z
-	cp $0
+	cp SPECIAL_MAP
 	ret
 ; b8070
 
--- a/macros/sound.asm
+++ b/macros/sound.asm
@@ -37,10 +37,10 @@
 	endc
 	endm
 
-	enum forceoctave_cmd
-forceoctave: macro
-	db forceoctave_cmd
-	db \1 ; octave
+	enum pitchoffset_cmd
+pitchoffset: macro
+	db pitchoffset_cmd
+	dn \1, \2 - 1 ; octave, key
 	endm
 
 	enum tempo_cmd
@@ -81,7 +81,7 @@
 	enum slidepitchto_cmd
 slidepitchto: macro
 	db slidepitchto_cmd
-	db \1 ; unknown
+	db \1 - 1 ; duration
 	dn \2, \3 ; octave, pitch
 	endm
 
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -134,7 +134,7 @@
 \1FrequencyHi::       db
 \1Pitch::             db ; 0:rest 1-c:note
 \1Octave::            db ; 7-0 (0 is highest)
-\1StartingOctave::    db ; raises existing octaves (to repeat phrases)
+\1PitchOffset::    db ; raises existing octaves (to repeat phrases)
 \1NoteDuration::      db ; frames remaining for the current note
 \1Field0x16::         ds 1 ; c117
                       ds 1 ; c118
--- a/maps/BattleTower1F.asm
+++ b/maps/BattleTower1F.asm
@@ -168,7 +168,6 @@
 	closetext
 	end
 
-
 UnreferencedScript_0x9e4be:
 	writetext Text_SaveBeforeEnteringBattleRoom
 	yesorno
--- a/text/trainer_class_names.asm
+++ b/text/trainer_class_names.asm
@@ -64,4 +64,4 @@
 	db "LEADER@"
 	db "OFFICER@"
 	db "ROCKET@"
-	db "MYSTICALMAN@"
\ No newline at end of file
+	db "MYSTICALMAN@"