summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormid-kid <esteve.varela@gmail.com>2018-11-21 12:12:22 +0100
committermid-kid <esteve.varela@gmail.com>2018-11-21 12:12:22 +0100
commit725cee7371f1b1862225e940e5c7271dc9444a1c (patch)
treed66d7b32b08cfe474faca7b0f7a5b51b9d8515b8
parent4e3ed078f9c8c486015d5c00e8d158671d3f740d (diff)
Define first_music_cmd
This replaces the uses of $d0 in the audio engine with proper constants.
-rw-r--r--audio/engine.asm6
-rw-r--r--constants/audio_constants.asm2
-rw-r--r--macros/scripts/audio.asm5
3 files changed, 7 insertions, 6 deletions
diff --git a/audio/engine.asm b/audio/engine.asm
index 62ba0e48c..551f1e0aa 100644
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -1136,9 +1136,9 @@ ReadNoiseSample:
ParseMusic:
; parses until a note is read or the song is ended
call GetMusicByte ; store next byte in a
- cp endchannel_cmd ; is the song over?
+ cp endchannel_cmd
jr z, .endchannel
- cp $d0 ; is it a note?
+ cp first_music_cmd
jr c, .readnote
; then it's a command
.readcommand
@@ -1350,7 +1350,7 @@ ParseMusicCommand:
; reload command
ld a, [wCurMusicByte]
; get command #
- sub $d0 ; first command
+ sub first_music_cmd
ld e, a
ld d, 0
; seek command pointer
diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm
index ec8311dfe..1d092edf5 100644
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -24,11 +24,11 @@
const CHAN3 ; 2
const CHAN4 ; 3
NUM_MUSIC_CHANS EQU const_value
-NUM_NOISE_CHANS EQU const_value
const CHAN5 ; 4
const CHAN6 ; 5
const CHAN7 ; 6
const CHAN8 ; 7
+NUM_NOISE_CHANS EQU const_value - NUM_MUSIC_CHANS
NUM_CHANNELS EQU const_value
; channel_struct members (see macros/wram.asm)
diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm
index cb411fc8b..d4a3f7bb5 100644
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -21,12 +21,13 @@ ENDM
; MusicCommands indexes (see audio/engine.asm)
enum_start $d8
+first_music_cmd EQU __enum__ + -8
- enum notetype_cmd ; $d8
octave: MACRO
- db notetype_cmd - (\1)
+ db first_music_cmd + 8 - (\1)
ENDM
+ enum notetype_cmd ; $d8
notetype: MACRO
db notetype_cmd
db \1 ; note_length