Use structure constants for channel_struct

This commit is contained in:
mid-kid 2018-06-04 11:35:27 +02:00
parent 5e9c785b3f
commit e8f847b537
5 changed files with 247 additions and 209 deletions

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,46 @@ NUM_NOISE_CHANS EQU const_value
const CHAN8 ; 7
NUM_CHANNELS EQU const_value
; channel_struct members (see macros/wram.asm)
CHANNEL_MUSIC_ID EQUS "(wChannel1MusicID - wChannel1)"
CHANNEL_MUSIC_BANK EQUS "(wChannel1MusicBank - wChannel1)"
CHANNEL_FLAGS1 EQUS "(wChannel1Flags1 - wChannel1)"
CHANNEL_FLAGS2 EQUS "(wChannel1Flags2 - wChannel1)"
CHANNEL_FLAGS3 EQUS "(wChannel1Flags3 - wChannel1)"
CHANNEL_MUSIC_ADDRESS EQUS "(wChannel1MusicAddress - wChannel1)"
CHANNEL_LAST_MUSIC_ADDRESS EQUS "(wChannel1LastMusicAddress - wChannel1)"
CHANNEL_NOTE_FLAGS EQUS "(wChannel1NoteFlags - wChannel1)"
CHANNEL_CONDITION EQUS "(wChannel1Condition - wChannel1)"
CHANNEL_DUTY_CYCLE EQUS "(wChannel1DutyCycle - wChannel1)"
CHANNEL_INTENSITY EQUS "(wChannel1Intensity - wChannel1)"
CHANNEL_FREQUENCY EQUS "(wChannel1Frequency - wChannel1)"
CHANNEL_PITCH EQUS "(wChannel1Pitch - wChannel1)"
CHANNEL_OCTAVE EQUS "(wChannel1Octave - wChannel1)"
CHANNEL_PITCH_OFFSET EQUS "(wChannel1PitchOffset - wChannel1)"
CHANNEL_NOTE_DURATION EQUS "(wChannel1NoteDuration - wChannel1)"
CHANNEL_FIELD16 EQUS "(wChannel1Field16 - wChannel1)"
CHANNEL_LOOP_COUNT EQUS "(wChannel1LoopCount - wChannel1)"
CHANNEL_TEMPO EQUS "(wChannel1Tempo - wChannel1)"
CHANNEL_TRACKS EQUS "(wChannel1Tracks - wChannel1)"
CHANNEL_SFX_DUTY_LOOP EQUS "(wChannel1SFXDutyLoop - wChannel1)"
CHANNEL_VIBRATO_DELAY_COUNT EQUS "(wChannel1VibratoDelayCount - wChannel1)"
CHANNEL_VIBRATO_DELAY EQUS "(wChannel1VibratoDelay - wChannel1)"
CHANNEL_VIBRATO_EXTENT EQUS "(wChannel1VibratoExtent - wChannel1)"
CHANNEL_VIBRATO_RATE EQUS "(wChannel1VibratoRate - wChannel1)"
CHANNEL_PITCH_WHEEL_TARGET EQUS "(wChannel1PitchWheelTarget - wChannel1)"
CHANNEL_PITCH_WHEEL_AMOUNT EQUS "(wChannel1PitchWheelAmount - wChannel1)"
CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION EQUS "(wChannel1PitchWheelAmountFraction - wChannel1)"
CHANNEL_FIELD25 EQUS "(wChannel1Field25 - wChannel1)"
CHANNEL_CRY_PITCH EQUS "(wChannel1CryPitch - wChannel1)"
CHANNEL_FIELD29 EQUS "(wChannel1Field29 - wChannel1)"
CHANNEL_FIELD2A EQUS "(wChannel1Field2a - wChannel1)"
CHANNEL_FIELD2C EQUS "(wChannel1Field2c - wChannel1)"
CHANNEL_NOTE_LENGTH EQUS "(wChannel1NoteLength - wChannel1)"
CHANNEL_FIELD2E EQUS "(wChannel1Field2e - wChannel1)"
CHANNEL_FIELD2F EQUS "(wChannel1Field2f - wChannel1)"
CHANNEL_FIELD30 EQUS "(wChannel1Field30 - wChannel1)"
CHANNEL_STRUCT_LENGTH EQUS "(wChannel2 - wChannel1)"
NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
; Flags1

View File

@ -269,7 +269,7 @@ ItemAttributes: ; 67c1
item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; STARDUST
item_attribute 2000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; STAR PIECE
; STAR_PIECE
item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
; BASEMENT_KEY
item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE

View File

@ -249,16 +249,16 @@ WaitSFX:: ; 3c55
push hl
.wait
ld hl, wChannel5Flags
ld hl, wChannel5Flags1
bit 0, [hl]
jr nz, .wait
ld hl, wChannel6Flags
ld hl, wChannel6Flags1
bit 0, [hl]
jr nz, .wait
ld hl, wChannel7Flags
ld hl, wChannel7Flags1
bit 0, [hl]
jr nz, .wait
ld hl, wChannel8Flags
ld hl, wChannel8Flags1
bit 0, [hl]
jr nz, .wait
@ -271,16 +271,16 @@ IsSFXPlaying:: ; 3c74
; The inverse of CheckSFX.
push hl
ld hl, wChannel5Flags
ld hl, wChannel5Flags1
bit 0, [hl]
jr nz, .playing
ld hl, wChannel6Flags
ld hl, wChannel6Flags1
bit 0, [hl]
jr nz, .playing
ld hl, wChannel7Flags
ld hl, wChannel7Flags1
bit 0, [hl]
jr nz, .playing
ld hl, wChannel8Flags
ld hl, wChannel8Flags1
bit 0, [hl]
jr nz, .playing
@ -540,16 +540,16 @@ Unreferenced_Function3d9f:: ; 3d9f
CheckSFX:: ; 3dde
; Return carry if any SFX channels are active.
ld a, [wChannel5Flags]
ld a, [wChannel5Flags1]
bit 0, a
jr nz, .playing
ld a, [wChannel6Flags]
ld a, [wChannel6Flags1]
bit 0, a
jr nz, .playing
ld a, [wChannel7Flags]
ld a, [wChannel7Flags1]
bit 0, a
jr nz, .playing
ld a, [wChannel8Flags]
ld a, [wChannel8Flags1]
bit 0, a
jr nz, .playing
and a
@ -561,7 +561,7 @@ CheckSFX:: ; 3dde
TerminateExpBarSound:: ; 3dfe
xor a
ld [wChannel5Flags], a
ld [wChannel5Flags1], a
ld [wSoundInput], a
ld [rNR10], a
ld [rNR11], a
@ -575,10 +575,10 @@ TerminateExpBarSound:: ; 3dfe
ChannelsOff:: ; 3e10
; Quickly turn off music channels
xor a
ld [wChannel1Flags], a
ld [wChannel2Flags], a
ld [wChannel3Flags], a
ld [wChannel4Flags], a
ld [wChannel1Flags1], a
ld [wChannel2Flags1], a
ld [wChannel3Flags1], a
ld [wChannel4Flags1], a
ld [wSoundInput], a
ret
; 3e21
@ -586,10 +586,10 @@ ChannelsOff:: ; 3e10
SFXChannelsOff:: ; 3e21
; Quickly turn off sound effect channels
xor a
ld [wChannel5Flags], a
ld [wChannel6Flags], a
ld [wChannel7Flags], a
ld [wChannel8Flags], a
ld [wChannel5Flags1], a
ld [wChannel6Flags1], a
ld [wChannel7Flags1], a
ld [wChannel8Flags1], a
ld [wSoundInput], a
ret
; 3e32

View File

@ -131,7 +131,7 @@ channel_struct: MACRO
; Addreses are wChannel1 (c101).
\1MusicID:: dw
\1MusicBank:: db
\1Flags:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest
\1Flags1:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest
\1Flags2:: db ; 0:vibrato on/off 2:duty 4:cry pitch
\1Flags3:: db ; 0:vibrato up/down
\1MusicAddress:: dw
@ -141,9 +141,7 @@ channel_struct: MACRO
\1Condition:: db ; conditional jumps
\1DutyCycle:: db ; bits 6-7 (0:12.5% 1:25% 2:50% 3:75%)
\1Intensity:: db ; hi:pressure lo:velocity
\1Frequency:: ; 11 bits
\1FrequencyLo:: db
\1FrequencyHi:: db
\1Frequency:: dw ; 11 bits
\1Pitch:: db ; 0:rest 1-c:note
\1Octave:: db ; 7-0 (0 is highest)
\1PitchOffset:: db ; raises existing octaves (to repeat phrases)