summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/cries.asm70
-rw-r--r--audio/engine.asm430
-rw-r--r--audio/sfx.asm202
-rw-r--r--audio/sfx_crystal.asm4
-rw-r--r--constants/audio_constants.asm46
-rw-r--r--constants/map_constants.asm4
-rw-r--r--constants/map_object_constants.asm67
-rw-r--r--constants/scgb_constants.asm44
-rw-r--r--data/battle_anims/object_gfx.asm2
-rw-r--r--data/events/collision_stdscripts.asm2
-rw-r--r--data/items/attributes.asm2
-rw-r--r--data/items/catch_rate_items.asm2
-rw-r--r--data/predef_pointers.asm2
-rw-r--r--data/sprites/facings.asm100
-rw-r--r--data/sprites/map_objects.asm228
-rw-r--r--data/types/type_matchups.asm4
-rw-r--r--data/wild/treemon_maps.asm2
-rw-r--r--docs/bugs_and_glitches.md12
-rw-r--r--docs/design_flaws.md52
-rw-r--r--engine/battle/ai/scoring.asm6
-rw-r--r--engine/battle/effect_commands.asm4
-rw-r--r--engine/events/pokecenter_pc.asm102
-rw-r--r--engine/events/specials.asm6
-rw-r--r--engine/gfx/cgb_layouts.asm8
-rw-r--r--engine/gfx/color.asm25
-rw-r--r--engine/gfx/load_pics.asm50
-rw-r--r--engine/gfx/pic_animation.asm6
-rw-r--r--engine/gfx/sgb_layouts.asm12
-rw-r--r--engine/items/pack.asm6
-rw-r--r--engine/overworld/map_object_action.asm14
-rw-r--r--engine/overworld/map_objects.asm57
-rw-r--r--engine/overworld/movement.asm14
-rw-r--r--engine/overworld/npc_movement.asm49
-rw-r--r--engine/overworld/player_movement.asm4
-rw-r--r--engine/overworld/scripting.asm2
-rw-r--r--engine/pokemon/bills_pc_top.asm4
-rw-r--r--engine/pokemon/move_mon.asm10
-rw-r--r--gfx/beta_poker/beta_poker.pal (renamed from gfx/unknown/b789.pal)0
-rw-r--r--gfx/pack/pack_menu.pngbin360 -> 356 bytes
-rw-r--r--gfx/pics.asm19
-rw-r--r--gfx/sgb/pal_packets.asm18
-rw-r--r--gfx/sgb/predef.pal38
-rw-r--r--gfx/tilesets/roofs.pal54
-rw-r--r--home.asm21
-rw-r--r--home/audio.asm42
-rw-r--r--home/copy2.asm8
-rw-r--r--home/hp_pals.asm19
-rw-r--r--home/map_objects.asm20
-rw-r--r--macros/code.asm8
-rw-r--r--macros/wram.asm6
-rw-r--r--maps/GoldenrodGameCorner.asm20
-rw-r--r--maps/Route35GoldenrodGate.asm6
-rw-r--r--mobile/mobile_40.asm2
-rw-r--r--pokecrystal.link5
-rw-r--r--wram.asm2
55 files changed, 1021 insertions, 921 deletions
diff --git a/audio/cries.asm b/audio/cries.asm
index 7848d185e..ca6c569b3 100644
--- a/audio/cries.asm
+++ b/audio/cries.asm
@@ -226,9 +226,9 @@ Cry_Magcargo_Ch6: ; f2ed3
Cry_Magcargo_Ch8: ; f2ef2
noise __, 3, $e8, $3b
-Cry_Magcargo_branch_f2ef5: ; f2ef5
+.loop
noise __, 2, $f1, $4e
- loopchannel 5, Cry_Magcargo_branch_f2ef5
+ loopchannel 5, .loop
noise __, 3, $d8, $3f
noise C_, 5, $c2, $5f
endchannel
@@ -378,9 +378,8 @@ Cry_Togetic_branch_f3022: ; f3022
Cry_Togetic_Ch5: ; f3035
tone $0002
Cry_Togetic_Ch6: ; f3038
-Cry_Togetic_branch_f3038: ; f3038
callchannel Cry_Togetic_branch_f3022
- loopchannel 2, Cry_Togetic_branch_f3038
+ loopchannel 2, Cry_Togetic_Ch6
sound __, 15, $0, 0
sound __, 9, $f2, $07c2
endchannel
@@ -464,12 +463,12 @@ Cry_Hoothoot_Ch5: ; f30d6
Cry_Hoothoot_Ch6: ; f30f9
sound_duty 2, 0, 2, 0
-Cry_Hoothoot_branch_f30fb: ; f30fb
+.loop1
sound __, 3, $a1, $0600
- loopchannel 3, Cry_Hoothoot_branch_f30fb
-Cry_Hoothoot_branch_f3103: ; f3103
+ loopchannel 3, .loop1
+.loop2
sound __, 3, $a1, $0630
- loopchannel 4, Cry_Hoothoot_branch_f3103
+ loopchannel 4, .loop2
sound __, 5, $a2, $0634
sound __, 5, $91, $0638
endchannel
@@ -525,14 +524,14 @@ Cry_Cyndaquil_Ch5: ; f3156
Cry_Cyndaquil_Ch6: ; f3159
dutycycle $2
sound __, 9, $2f, $0107
-Cry_Cyndaquil_branch_f315f: ; f315f
+.loop1
sound __, 1, $e1, $0483
sound __, 1, $51, $044e
- loopchannel 4, Cry_Cyndaquil_branch_f315f
-Cry_Cyndaquil_branch_f316b: ; f316b
+ loopchannel 4, .loop1
+.loop2
sound __, 1, $e1, $03da
sound __, 2, $51, $0312
- loopchannel 4, Cry_Cyndaquil_branch_f316b
+ loopchannel 4, .loop2
endchannel
; f3178
@@ -683,29 +682,24 @@ Cry_Donphan_Ch8: ; f3274
Cry_Typhlosion_Ch5: ; f3284
Cry_Teddiursa_Ch5: ; f3284
sound_duty 2, 0, 1, 0
-Cry_Typhlosion_branch_f3286: ; f3286
-Cry_Teddiursa_branch_f3286: ; f3286
+.loop1
sound __, 4, $c1, $0791
- loopchannel 3, Cry_Typhlosion_branch_f3286
-Cry_Typhlosion_branch_f328e: ; f328e
-Cry_Teddiursa_branch_f328e: ; f328e
+ loopchannel 3, .loop1
+.loop2
sound __, 4, $d1, $04b1
- loopchannel 6, Cry_Typhlosion_branch_f328e
-Cry_Typhlosion_branch_f3296: ; f3296
-Cry_Teddiursa_branch_f3296: ; f3296
+ loopchannel 6, .loop2
+.loop3
sound __, 2, $d1, $0491
sound __, 2, $b1, $0451
- loopchannel 6, Cry_Typhlosion_branch_f3296
-Cry_Typhlosion_branch_f32a2: ; f32a2
-Cry_Teddiursa_branch_f32a2: ; f32a2
+ loopchannel 6, .loop3
+.loop4
sound __, 2, $a3, $0471
sound __, 2, $81, $0441
- loopchannel 6, Cry_Typhlosion_branch_f32a2
-Cry_Typhlosion_branch_f32ae: ; f32ae
-Cry_Teddiursa_branch_f32ae: ; f32ae
+ loopchannel 6, .loop4
+.loop5
sound __, 2, $41, $0421
sound __, 2, $21, $0401
- loopchannel 4, Cry_Typhlosion_branch_f32ae
+ loopchannel 4, .loop5
endchannel
; f32bb
@@ -803,10 +797,10 @@ Cry_Mantine_Ch8: ; f334c
Cry_Ampharos_Ch5: ; f3353
sound_duty 2, 3, 1, 3
-Cry_Ampharos_branch_f3355: ; f3355
+.loop
sound __, 2, $c1, $0520
sound __, 2, $a1, $0420
- loopchannel 4, Cry_Ampharos_branch_f3355
+ loopchannel 4, .loop
dutycycle $0
sound __, 5, $78, $0760
sound __, 5, $78, $0730
@@ -911,23 +905,22 @@ Cry_Aipom_Ch5: ; f3422
Cry_Aipom_Ch6: ; f3441
sound_duty 3, 1, 2, 0
-Cry_Aipom_branch_f3443: ; f3443
+.loop1
sound __, 2, $f1, $07b4
- loopchannel 8, Cry_Aipom_branch_f3443
-Cry_Aipom_branch_f344b: ; f344b
+ loopchannel 8, .loop1
+.loop2
sound __, 2, $c1, $0790
- loopchannel 3, Cry_Aipom_branch_f344b
-Cry_Aipom_branch_f3453: ; f3453
+ loopchannel 3, .loop2
+.loop3
sound __, 2, $b1, $078d
- loopchannel 2, Cry_Aipom_branch_f3453
+ loopchannel 2, .loop3
sound C_, 1, $92, $0795
endchannel
; f3460
Cry_Aipom_Ch8: ; f3460
-Cry_Aipom_branch_f3460: ; f3460
noise __, 1, $f1, $28
- loopchannel 4, Cry_Aipom_branch_f3460
+ loopchannel 4, Cry_Aipom_Ch8
noise __, 1, $91, $49
noise __, 2, $a8, $4a
noise __, 1, $e1, $4b
@@ -1656,7 +1649,6 @@ Cry_Slowpoke_Ch8: ; f3a19
; f3a1a
Cry_Drowzee_Ch5: ; f3a1a
-Cry_Drowzee_branch_f3a1a: ; f3a1a
sound_duty 0, 2, 0, 2
sound __, 6, $f2, $0650
sound __, 10, $d1, $0660
@@ -1664,7 +1656,7 @@ Cry_Drowzee_branch_f3a1a: ; f3a1a
sound __, 10, $c1, $0622
sound __, 6, $f2, $0610
sound __, 7, $d1, $0620
- loopchannel 2, Cry_Drowzee_branch_f3a1a
+ loopchannel 2, Cry_Drowzee_Ch5
endchannel
; f3a39
diff --git a/audio/engine.asm b/audio/engine.asm
index 50f2f5843..d0f64088b 100644
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -100,12 +100,12 @@ _UpdateSound:: ; e805c
ld bc, wChannel1
.loop
; is the channel active?
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_CHANNEL_ON, [hl]
jp z, .nextchannel
; check time left in the current note
- ld hl, wChannel1NoteDuration - wChannel1
+ ld hl, CHANNEL_NOTE_DURATION
add hl, bc
ld a, [hl]
cp $2 ; 1 or 0?
@@ -115,14 +115,14 @@ _UpdateSound:: ; e805c
.noteover
; reset vibrato delay
- ld hl, wChannel1VibratoDelay - wChannel1
+ ld hl, CHANNEL_VIBRATO_DELAY
add hl, bc
ld a, [hl]
- ld hl, wChannel1VibratoDelayCount - wChannel1
+ ld hl, CHANNEL_VIBRATO_DELAY_COUNT
add hl, bc
ld [hl], a
; turn vibrato off for now
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
res SOUND_PITCH_WHEEL, [hl]
; get next note
@@ -130,7 +130,7 @@ _UpdateSound:: ; e805c
.continue_sound_update
call ApplyPitchWheel
; duty cycle
- ld hl, wChannel1DutyCycle - wChannel1
+ ld hl, CHANNEL_DUTY_CYCLE
add hl, bc
ld a, [hli]
ld [wCurTrackDuty], a
@@ -151,58 +151,58 @@ _UpdateSound:: ; e805c
jr z, .next
; are we in a sfx channel right now?
ld a, [wCurChannel]
- cp CHAN5
+ cp NUM_MUSIC_CHANS
jr nc, .next
; are any sfx channels active?
; if so, mute
- ld hl, wChannel5Flags
+ ld hl, wChannel5Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .restnote
- ld hl, wChannel6Flags
+ ld hl, wChannel6Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .restnote
- ld hl, wChannel7Flags
+ ld hl, wChannel7Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .restnote
- ld hl, wChannel8Flags
+ ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl]
jr z, .next
.restnote
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_REST, [hl] ; Rest
.next
; are we in a sfx channel right now?
ld a, [wCurChannel]
- cp CHAN5
+ cp NUM_MUSIC_CHANS
jr nc, .sfx_channel
- ld hl, wChannel5Flags - wChannel1
+ ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
add hl, bc
bit SOUND_CHANNEL_ON, [hl]
jr nz, .sound_channel_on
.sfx_channel
call UpdateChannels
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
ld a, [wSoundOutput]
or [hl]
ld [wSoundOutput], a
.sound_channel_on
; clear note flags
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
xor a
ld [hl], a
.nextchannel
; next channel
- ld hl, wChannel2 - wChannel1
+ ld hl, CHANNEL_STRUCT_LENGTH
add hl, bc
ld c, l
ld b, h
ld a, [wCurChannel]
inc a
ld [wCurChannel], a
- cp $8 ; are we done?
+ cp NUM_CHANNELS ; are we done?
jp nz, .loop ; do it all again
call PlayDanger
@@ -248,7 +248,7 @@ UpdateChannels: ; e8125
bit DANGER_ON_F, a
ret nz
.Channel5:
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
bit NOTE_UNKN_3, [hl]
jr z, .asm_e8159
@@ -317,7 +317,7 @@ UpdateChannels: ; e8125
.Channel2:
.Channel6:
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
bit NOTE_REST, [hl] ; rest
jr nz, .ch2rest
@@ -377,7 +377,7 @@ UpdateChannels: ; e8125
.Channel3:
.Channel7:
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
bit NOTE_REST, [hl] ; rest
jr nz, .ch3rest
@@ -478,7 +478,7 @@ endr
.Channel4:
.Channel8:
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
bit NOTE_REST, [hl] ; rest
jr nz, .ch4rest
@@ -514,16 +514,16 @@ endr
_CheckSFX: ; e82e7
; return carry if any sfx channels are active
- ld hl, wChannel5Flags
+ ld hl, wChannel5Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .sfxon
- ld hl, wChannel6Flags
+ ld hl, wChannel6Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .sfxon
- ld hl, wChannel7Flags
+ ld hl, wChannel7Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .sfxon
- ld hl, wChannel8Flags
+ ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl]
jr nz, .sfxon
and a
@@ -539,47 +539,57 @@ PlayDanger: ; e8307
ld a, [wLowHealthAlarm]
bit DANGER_ON_F, a
ret z
+
+ ; Don't do anything if SFX is being played
and $ff ^ (1 << DANGER_ON_F)
ld d, a
call _CheckSFX
- jr c, .asm_e8335
+ jr c, .increment
+
+ ; Play the high tone
and a
- jr z, .asm_e8323
- cp 16 ; halfway
- jr z, .asm_e831e
- jr .asm_e8335
-
-.asm_e831e
- ld hl, Tablee8354
- jr .updatehw
-
-.asm_e8323
- ld hl, Tablee8350
-.updatehw
+ jr z, .begin
+
+ ; Play the low tone
+ cp 16
+ jr z, .halfway
+
+ jr .increment
+
+.halfway
+ ld hl, DangerSoundLow
+ jr .applychannel
+
+.begin
+ ld hl, DangerSoundHigh
+
+.applychannel
xor a
- ld [rNR10], a ; sweep off
+ ld [rNR10], a
ld a, [hli]
- ld [rNR11], a ; sound length / duty cycle
+ ld [rNR11], a
ld a, [hli]
- ld [rNR12], a ; ch1 volume envelope
+ ld [rNR12], a
ld a, [hli]
- ld [rNR13], a ; ch1 frequency lo
+ ld [rNR13], a
ld a, [hli]
- ld [rNR14], a ; ch1 frequency hi
-.asm_e8335
+ ld [rNR14], a
+
+.increment
ld a, d
inc a
- cp 30
- jr c, .asm_e833c
+ cp 30 ; Ending frame
+ jr c, .noreset
xor a
-.asm_e833c
+.noreset
+ ; Make sure the danger sound is kept on
or 1 << DANGER_ON_F
ld [wLowHealthAlarm], a
- ; is hw ch1 on?
+
+ ; Enable channel 1 if it's off
ld a, [wSoundOutput]
and $11
ret nz
- ; if not, turn it on
ld a, [wSoundOutput]
or $11
ld [wSoundOutput], a
@@ -587,14 +597,14 @@ PlayDanger: ; e8307
; e8350
-Tablee8350: ; e8350
+DangerSoundHigh: ; e8350
db $80 ; duty 50%
db $e2 ; volume 14, envelope decrease sweep 2
db $50 ; frequency: $750
db $87 ; restart sound
; e8354
-Tablee8354: ; e8354
+DangerSoundLow: ; e8354
db $80 ; duty 50%
db $e2 ; volume 14, envelope decrease sweep 2
db $ee ; frequency: $6ee
@@ -693,7 +703,7 @@ FadeMusic: ; e8358
.fadein
; are we done?
- cp $7
+ cp MAX_VOLUME & $f
jr nc, .maxvolume
; inc volume
inc a
@@ -717,12 +727,12 @@ FadeMusic: ; e8358
LoadNote: ; e83d1
; wait for pitch wheel to finish
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
bit SOUND_PITCH_WHEEL, [hl]
ret z
; get note duration
- ld hl, wChannel1NoteDuration - wChannel1
+ ld hl, CHANNEL_NOTE_DURATION
add hl, bc
ld a, [hl]
ld hl, wCurNoteDuration
@@ -732,13 +742,13 @@ LoadNote: ; e83d1
.ok
ld [hl], a
; get frequency
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; get direction of pitch wheel
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld a, e
sub [hl]
@@ -746,21 +756,21 @@ LoadNote: ; e83d1
ld a, d
sbc 0
ld d, a
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
sub [hl]
jr nc, .greater_than
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
set SOUND_PITCH_WHEEL_DIR, [hl]
; get frequency
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; ????
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld a, [hl]
sub e
@@ -769,7 +779,7 @@ LoadNote: ; e83d1
sbc 0
ld d, a
; ????
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
ld a, [hl]
sub d
@@ -777,17 +787,17 @@ LoadNote: ; e83d1
jr .resume
.greater_than
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
res SOUND_PITCH_WHEEL_DIR, [hl]
; get frequency
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; get distance from pitch wheel target
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld a, e
sub [hl]
@@ -795,7 +805,7 @@ LoadNote: ; e83d1
ld a, d
sbc 0
ld d, a
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
sub [hl]
ld d, a
@@ -823,13 +833,13 @@ LoadNote: ; e83d1
add [hl]
ld d, b ; quotient
pop bc
- ld hl, wChannel1PitchWheelAmount - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT
add hl, bc
ld [hl], d ; quotient
- ld hl, wChannel1PitchWheelAmountFraction - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION
add hl, bc
ld [hl], a ; remainder
- ld hl, wChannel1Field25 - wChannel1
+ ld hl, CHANNEL_FIELD25
add hl, bc
xor a
ld [hl], a
@@ -839,11 +849,11 @@ LoadNote: ; e83d1
HandleTrackVibrato: ; e8466
; handle duty, cry pitch, and vibrato
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
bit SOUND_DUTY, [hl] ; duty
jr z, .next
- ld hl, wChannel1SFXDutyLoop - wChannel1
+ ld hl, CHANNEL_SFX_DUTY_LOOP
add hl, bc
ld a, [hl]
rlca
@@ -851,15 +861,15 @@ HandleTrackVibrato: ; e8466
ld [hl], a
and $c0
ld [wCurTrackDuty], a
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_DUTY_OVERRIDE, [hl]
.next
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
bit SOUND_CRY_PITCH, [hl]
jr z, .vibrato
- ld hl, wChannel1CryPitch - wChannel1
+ ld hl, CHANNEL_CRY_PITCH
add hl, bc
ld e, [hl]
inc hl
@@ -877,19 +887,19 @@ HandleTrackVibrato: ; e8466
ld [hl], d
.vibrato
; is vibrato on?
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
bit SOUND_VIBRATO, [hl] ; vibrato
jr z, .quit
; is vibrato active for this note yet?
; is the delay over?
- ld hl, wChannel1VibratoDelayCount - wChannel1
+ ld hl, CHANNEL_VIBRATO_DELAY_COUNT
add hl, bc
ld a, [hl]
and a
jr nz, .subexit
; is the extent nonzero?
- ld hl, wChannel1VibratoExtent - wChannel1
+ ld hl, CHANNEL_VIBRATO_EXTENT
add hl, bc
ld a, [hl]
and a
@@ -897,7 +907,7 @@ HandleTrackVibrato: ; e8466
; save it for later
ld d, a
; is it time to toggle vibrato up/down?
- ld hl, wChannel1VibratoRate - wChannel1
+ ld hl, CHANNEL_VIBRATO_RATE
add hl, bc
ld a, [hl]
and $f ; count
@@ -916,7 +926,7 @@ HandleTrackVibrato: ; e8466
ld a, [wCurTrackFrequency]
ld e, a
; toggle vibrato up/down
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
bit SOUND_VIBRATO_DIR, [hl] ; vibrato up/down
jr z, .down
@@ -948,7 +958,7 @@ HandleTrackVibrato: ; e8466
.no_carry
ld [wCurTrackFrequency], a
;
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_VIBRATO_OVERRIDE, [hl]
.quit
@@ -958,23 +968,23 @@ HandleTrackVibrato: ; e8466
ApplyPitchWheel: ; e84f9
; quit if pitch wheel inactive
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
bit SOUND_PITCH_WHEEL, [hl]
ret z
; de = Frequency
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; check whether pitch wheel is going up or down
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
bit SOUND_PITCH_WHEEL_DIR, [hl]
jr z, .decreasing
; frequency += [Channel*PitchWheelAmount]
- ld hl, wChannel1PitchWheelAmount - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT
add hl, bc
ld l, [hl]
ld h, 0
@@ -983,10 +993,10 @@ ApplyPitchWheel: ; e84f9
ld e, l
; [Channel*Field25] += [Channel*PitchWheelAmountFraction]
; if rollover: Frequency += 1
- ld hl, wChannel1PitchWheelAmountFraction - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION
add hl, bc
ld a, [hl]
- ld hl, wChannel1Field25 - wChannel1
+ ld hl, CHANNEL_FIELD25
add hl, bc
add [hl]
ld [hl], a
@@ -999,13 +1009,13 @@ ApplyPitchWheel: ; e84f9
; Compare the dw at [Channel*PitchWheelTarget] to de.
; If frequency is greater, we're finished.
; Otherwise, load the frequency and set two flags.
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
ld a, [hl]
cp d
jp c, .finished_pitch_wheel
jr nz, .continue_pitch_wheel
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld a, [hl]
cp e
@@ -1015,7 +1025,7 @@ ApplyPitchWheel: ; e84f9
.decreasing
; frequency -= [Channel*PitchWheelAmount]
ld a, e
- ld hl, wChannel1PitchWheelAmount - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT
add hl, bc
ld e, [hl]
sub e
@@ -1025,7 +1035,7 @@ ApplyPitchWheel: ; e84f9
ld d, a
; [Channel*Field25] *= 2
; if rollover: Frequency -= 1
- ld hl, wChannel1PitchWheelAmountFraction - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION
add hl, bc
ld a, [hl]
add a
@@ -1039,33 +1049,33 @@ ApplyPitchWheel: ; e84f9
; Compare the dw at [Channel*PitchWheelTarget] to de.
; If frequency is lower, we're finished.
; Otherwise, load the frequency and set two flags.
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
ld a, d
cp [hl]
jr c, .finished_pitch_wheel
jr nz, .continue_pitch_wheel
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld a, e
cp [hl]
jr nc, .continue_pitch_wheel
.finished_pitch_wheel
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
res SOUND_PITCH_WHEEL, [hl]
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
res SOUND_PITCH_WHEEL_DIR, [hl]
ret
.continue_pitch_wheel
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld [hl], e
inc hl
ld [hl], d
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_FREQ_OVERRIDE, [hl]
set NOTE_DUTY_OVERRIDE, [hl]
@@ -1075,7 +1085,7 @@ ApplyPitchWheel: ; e84f9
HandleNoise: ; e858c
; is noise sampling on?
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_NOISE, [hl] ; noise sampling
ret z
@@ -1084,7 +1094,7 @@ HandleNoise: ; e858c
bit NOISE_CHAN_F, a
jr nz, .next
; is ch8 on? (noise)
- ld hl, wChannel8Flags
+ ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl] ; on?
jr z, .next
; is ch8 playing noise?
@@ -1143,7 +1153,7 @@ ReadNoiseSample: ; e85af
inc hl
ld [hl], d
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_NOISE_SAMPLING, [hl]
ret
@@ -1168,7 +1178,7 @@ ParseMusic: ; e85e1
.readnote
; wCurMusicByte contains current note
; special notes
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_SFX, [hl]
jp nz, ParseSFXOrRest
@@ -1187,38 +1197,38 @@ ParseMusic: ; e85e1
and $f
jr z, .rest ; pitch 0-> rest
; update pitch
- ld hl, wChannel1Pitch - wChannel1
+ ld hl, CHANNEL_PITCH
add hl, bc
ld [hl], a
; store pitch in e
ld e, a
; store octave in d
- ld hl, wChannel1Octave - wChannel1
+ ld hl, CHANNEL_OCTAVE
add hl, bc
ld d, [hl]
; update frequency
call GetFrequency
- ld hl, wChannel1Frequency - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld [hl], e
inc hl
ld [hl], d
; ????
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_NOISE_SAMPLING, [hl]
jp LoadNote
.rest
; note = rest
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_REST, [hl] ; Rest
ret
.endchannel
; $ff is reached in music data
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_SUBROUTINE, [hl] ; in a subroutine?
jr nz, .readcommand ; execute
@@ -1226,12 +1236,12 @@ ParseMusic: ; e85e1
cp CHAN5
jr nc, .chan_5to8
; ????
- ld hl, wChannel5Flags - wChannel1
+ ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
add hl, bc
bit SOUND_CHANNEL_ON, [hl]
jr nz, .ok
.chan_5to8
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_REST, [hl]
call nz, RestoreVolume
@@ -1245,15 +1255,15 @@ ParseMusic: ; e85e1
.ok
; stop playing
; turn channel off
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
res SOUND_CHANNEL_ON, [hl]
; note = rest
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_REST, [hl]
; clear music id & bank
- ld hl, wChannel1MusicID - wChannel1
+ ld hl, CHANNEL_MUSIC_ID
add hl, bc
xor a
ld [hli], a ; id hi
@@ -1286,7 +1296,7 @@ RestoreVolume: ; e8679
ParseSFXOrRest: ; e8698
; turn noise sampling on
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_NOISE_SAMPLING, [hl] ; noise sample
; update note duration
@@ -1294,12 +1304,12 @@ ParseSFXOrRest: ; e8698
call SetNoteDuration ; top nybble doesnt matter?
; update intensity from next param
call GetMusicByte
- ld hl, wChannel1Intensity - wChannel1
+ ld hl, CHANNEL_INTENSITY
add hl, bc
ld [hl], a
; update lo frequency from next param
call GetMusicByte
- ld hl, wChannel1FrequencyLo - wChannel1
+ ld hl, CHANNEL_FREQUENCY
add hl, bc
ld [hl], a
; are we on the last channel? (noise sampling)
@@ -1309,7 +1319,7 @@ ParseSFXOrRest: ; e8698
ret z
; update hi frequency from next param
call GetMusicByte
- ld hl, wChannel1FrequencyHi - wChannel1
+ ld hl, CHANNEL_FREQUENCY + 1
add hl, bc
ld [hl], a
ret
@@ -1332,7 +1342,7 @@ GetNoiseSample: ; e86c5
ld a, [wCurChannel]
bit NOISE_CHAN_F, a
jr nz, .sfx
- ld hl, wChannel8Flags
+ ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl] ; is ch8 on? (noise)
ret nz
ld a, [wMusicNoiseSampleSet]
@@ -1462,16 +1472,16 @@ Music_EndChannel: ; e8781
; end music stream
; return to caller of the subroutine
; reset subroutine flag
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
res SOUND_SUBROUTINE, [hl]
; copy LastMusicAddress to MusicAddress
- ld hl, wChannel1LastMusicAddress - wChannel1
+ ld hl, CHANNEL_LAST_MUSIC_ADDRESS
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
@@ -1490,25 +1500,25 @@ Music_CallChannel: ; e8796
ld d, a
push de
; copy MusicAddress to LastMusicAddress
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
- ld hl, wChannel1LastMusicAddress - wChannel1
+ ld hl, CHANNEL_LAST_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
ld [hl], d
; load pointer into MusicAddress
pop de
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
ld [hl], d
; set subroutine flag
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_SUBROUTINE, [hl]
ret
@@ -1523,7 +1533,7 @@ Music_JumpChannel: ; e87bc
ld e, a
call GetMusicByte
ld d, a
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
@@ -1542,7 +1552,7 @@ Music_LoopChannel: ; e87cc
; get loop count
call GetMusicByte
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_LOOPING, [hl] ; has the loop been initiated?
jr nz, .checkloop
@@ -1551,11 +1561,11 @@ Music_LoopChannel: ; e87cc
; initiate loop
dec a
set SOUND_LOOPING, [hl] ; set loop flag
- ld hl, wChannel1LoopCount - wChannel1
+ ld hl, CHANNEL_LOOP_COUNT
add hl, bc
ld [hl], a ; store loop counter
.checkloop
- ld hl, wChannel1LoopCount - wChannel1
+ ld hl, CHANNEL_LOOP_COUNT
add hl, bc
ld a, [hl]
and a ; are we done?
@@ -1568,7 +1578,7 @@ Music_LoopChannel: ; e87cc
call GetMusicByte
ld d, a
; load new pointer into MusicAddress
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
@@ -1577,11 +1587,11 @@ Music_LoopChannel: ; e87cc
.endloop
; reset loop flag
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
res SOUND_LOOPING, [hl]
; skip to next command
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld e, [hl]
inc hl
@@ -1603,7 +1613,7 @@ Music_SetCondition: ; e880e
; set condition
call GetMusicByte
- ld hl, wChannel1Condition - wChannel1
+ ld hl, CHANNEL_CONDITION
add hl, bc
ld [hl], a
ret
@@ -1621,13 +1631,13 @@ Music_JumpIf: ; e8817
; a = condition
call GetMusicByte
; if existing condition matches, jump to new address
- ld hl, wChannel1Condition - wChannel1
+ ld hl, CHANNEL_CONDITION
add hl, bc
cp [hl]
jr z, .jump
; skip to next command
; get address
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld e, [hl]
inc hl
@@ -1649,7 +1659,7 @@ Music_JumpIf: ; e8817
call GetMusicByte
ld d, a
; update pointer in MusicAddress
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
@@ -1680,7 +1690,7 @@ MusicEE; e883e
jr nz, .jump
; skip to next command
; get address
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld e, [hl]
inc hl
@@ -1703,7 +1713,7 @@ MusicEE; e883e
call GetMusicByte
ld d, a
; update address
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld [hl], e
inc hl
@@ -1726,10 +1736,10 @@ MusicE2: ; e8873
; seems to have been dummied out
; params: 1
call GetMusicByte
- ld hl, wChannel1Field2c - wChannel1
+ ld hl, CHANNEL_FIELD2C
add hl, bc
ld [hl], a
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_UNKN_0B, [hl]
ret
@@ -1746,28 +1756,28 @@ Music_Vibrato: ; e8882
; z: rate (# frames per cycle)
; set vibrato flag?
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_VIBRATO, [hl]
; start at lower frequency (extent is positive)
- ld hl, wChannel1Flags3 - wChannel1
+ ld hl, CHANNEL_FLAGS3
add hl, bc
res SOUND_VIBRATO_DIR, [hl]
; get delay
call GetMusicByte
; update delay
- ld hl, wChannel1VibratoDelay - wChannel1
+ ld hl, CHANNEL_VIBRATO_DELAY
add hl, bc
ld [hl], a
; update delay count
- ld hl, wChannel1VibratoDelayCount - wChannel1
+ ld hl, CHANNEL_VIBRATO_DELAY_COUNT
add hl, bc
ld [hl], a
; update extent
; this is split into halves only to get added back together at the last second
; get extent/rate
call GetMusicByte
- ld hl, wChannel1VibratoExtent - wChannel1
+ ld hl, CHANNEL_VIBRATO_EXTENT
add hl, bc
ld d, a
; get top nybble
@@ -1775,12 +1785,12 @@ Music_Vibrato: ; e8882
swap a
srl a ; halve
ld e, a
- adc a, 0; round up
+ adc 0 ; round up
swap a
or e
ld [hl], a
; update rate
- ld hl, wChannel1VibratoRate - wChannel1
+ ld hl, CHANNEL_VIBRATO_RATE
add hl, bc
; get bottom nybble
ld a, d
@@ -1813,13 +1823,13 @@ Music_SlidePitchTo: ; e88bd
and $f
ld d, a
call GetFrequency
- ld hl, wChannel1PitchWheelTarget - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET
add hl, bc
ld [hl], e
- ld hl, wChannel1PitchWheelTarget + 1 - wChannel1
+ ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1
add hl, bc
ld [hl], d
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_PITCH_WHEEL, [hl]
ret
@@ -1829,10 +1839,10 @@ Music_SlidePitchTo: ; e88bd
Music_Tone: ; e88e4
; tone
; params: 1 (dw)
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_CRY_PITCH, [hl]
- ld hl, wChannel1CryPitch + 1 - wChannel1
+ ld hl, CHANNEL_CRY_PITCH + 1
add hl, bc
call GetMusicByte
ld [hld], a
@@ -1845,11 +1855,11 @@ Music_Tone: ; e88e4
MusicE7: ; e88f7
; unused
; params: 1
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_UNKN_0E, [hl]
call GetMusicByte
- ld hl, wChannel1Field29 - wChannel1
+ ld hl, CHANNEL_FIELD29
add hl, bc
ld [hl], a
ret
@@ -1859,19 +1869,19 @@ MusicE7: ; e88f7
Music_SoundDuty: ; e8906
; sequence of 4 duty cycles to be looped
; params: 1 (4 2-bit duty cycle arguments)
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_DUTY, [hl] ; duty cycle
; sound duty sequence
call GetMusicByte
rrca
rrca
- ld hl, wChannel1SFXDutyLoop - wChannel1
+ ld hl, CHANNEL_SFX_DUTY_LOOP
add hl, bc
ld [hl], a
; update duty cycle
and $c0 ; only uses top 2 bits
- ld hl, wChannel1DutyCycle - wChannel1
+ ld hl, CHANNEL_DUTY_CYCLE
add hl, bc
ld [hl], a
ret
@@ -1881,11 +1891,11 @@ Music_SoundDuty: ; e8906
MusicE8: ; e891e
; unused
; params: 1
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_UNKN_0D, [hl]
call GetMusicByte
- ld hl, wChannel1Field2a - wChannel1
+ ld hl, CHANNEL_FIELD2A
add hl, bc
ld [hl], a
ret
@@ -1895,7 +1905,7 @@ MusicE8: ; e891e
Music_ToggleSFX: ; e892d
; toggle something
; params: none
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_SFX, [hl]
jr z, .on
@@ -1915,7 +1925,7 @@ Music_ToggleNoise: ; e893b
; noise on: 1
; noise off: 0
; check if noise sampling is on
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_NOISE, [hl]
jr z, .on
@@ -1938,7 +1948,7 @@ Music_SFXToggleNoise: ; e894f
; on: 1
; off: 0
; check if noise sampling is on
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
bit SOUND_NOISE, [hl]
jr z, .on
@@ -1962,7 +1972,7 @@ Music_NoteType: ; e8963
; params: 2
; note length
call GetMusicByte
- ld hl, wChannel1NoteLength - wChannel1
+ ld hl, CHANNEL_NOTE_LENGTH
add hl, bc
ld [hl], a
ld a, [wCurChannel]
@@ -1980,7 +1990,7 @@ Music_SoundStatus: ; e8977
; params: 1
call GetMusicByte
ld [wSoundInput], a
- ld hl, wChannel1NoteFlags - wChannel1
+ ld hl, CHANNEL_NOTE_FLAGS
add hl, bc
set NOTE_UNKN_3, [hl]
ret
@@ -1994,7 +2004,7 @@ Music_DutyCycle: ; e8984
rrca
rrca
and $c0
- ld hl, wChannel1DutyCycle - wChannel1
+ ld hl, CHANNEL_DUTY_CYCLE
add hl, bc
ld [hl], a
ret
@@ -2007,7 +2017,7 @@ Music_Intensity: ; e8991
; hi: pressure
; lo: velocity
call GetMusicByte
- ld hl, wChannel1Intensity - wChannel1
+ ld hl, CHANNEL_INTENSITY
add hl, bc
ld [hl], a
ret
@@ -2036,7 +2046,7 @@ Music_Octave3: ; e89a6
Music_Octave2: ; e89a6
Music_Octave1: ; e89a6
; set octave based on lo nybble of the command
- ld hl, wChannel1Octave - wChannel1
+ ld hl, CHANNEL_OCTAVE
add hl, bc
ld a, [wCurMusicByte]
and 7
@@ -2050,7 +2060,7 @@ Music_ForceOctave: ; e89b1
; this forces all notes up by the starting octave
; params: 1
call GetMusicByte
- ld hl, wChannel1PitchOffset - wChannel1
+ ld hl, CHANNEL_PITCH_OFFSET
add hl, bc
ld [hl], a
ret
@@ -2075,7 +2085,7 @@ Music_Panning: ; e89c5
; params: 1
call SetLRTracks
call GetMusicByte
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
and [hl]
ld [hl], a
@@ -2116,7 +2126,7 @@ Music_TempoRelative: ; e89e1
.negative
ld d, -1
.ok
- ld hl, wChannel1Tempo - wChannel1
+ ld hl, CHANNEL_TEMPO
add hl, bc
ld a, [hli]
ld h, [hl]
@@ -2156,14 +2166,14 @@ Music_RestartChannel: ; e8a08
; zzyy: pointer to new music data
; update music id
- ld hl, wChannel1MusicID - wChannel1
+ ld hl, CHANNEL_MUSIC_ID
add hl, bc
ld a, [hli]
ld [wMusicID], a
ld a, [hl]
ld [wMusicID + 1], a
; update music bank
- ld hl, wChannel1MusicBank - wChannel1
+ ld hl, CHANNEL_MUSIC_BANK
add hl, bc
ld a, [hl]
ld [wMusicBank], a
@@ -2205,20 +2215,20 @@ GetMusicByte: ; e8a3e
push hl
push de
; load address into de
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld a, [hli]
ld e, a
ld d, [hl]
; load bank into a
- ld hl, wChannel1MusicBank - wChannel1
+ ld hl, CHANNEL_MUSIC_BANK
add hl, bc
ld a, [hl]
; get byte
call _LoadMusicByte ; load data into wCurMusicByte
inc de ; advance to next byte for next time this is called
; update channeldata address
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
ld a, e
ld [hli], a
@@ -2242,7 +2252,7 @@ GetFrequency: ; e8a5d
; get octave
; get starting octave
- ld hl, wChannel1PitchOffset - wChannel1
+ ld hl, CHANNEL_PITCH_OFFSET
add hl, bc
ld a, [hl]
swap a ; hi nybble
@@ -2251,7 +2261,7 @@ GetFrequency: ; e8a5d
add d
push af ; we'll use this later
; get starting octave
- ld hl, wChannel1PitchOffset - wChannel1
+ ld hl, CHANNEL_PITCH_OFFSET
add hl, bc
ld a, [hl]
and $f ; lo nybble
@@ -2293,7 +2303,7 @@ SetNoteDuration: ; e8a8d
ld e, a
ld d, 0
; store NoteLength in a
- ld hl, wChannel1NoteLength - wChannel1
+ ld hl, CHANNEL_NOTE_LENGTH
add hl, bc
ld a, [hl]
; multiply NoteLength by delay units
@@ -2301,13 +2311,13 @@ SetNoteDuration: ; e8a8d
call .Multiply
ld a, l ; low
; store Tempo in de
- ld hl, wChannel1Tempo - wChannel1
+ ld hl, CHANNEL_TEMPO
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
; add ???? to the next result
- ld hl, wChannel1Field16 - wChannel1
+ ld hl, CHANNEL_FIELD16
add hl, bc
ld l, [hl]
; multiply Tempo by last result (NoteLength * LOW(delay))
@@ -2316,11 +2326,11 @@ SetNoteDuration: ; e8a8d
ld e, l
ld d, h
; store result in ????
- ld hl, wChannel1Field16 - wChannel1
+ ld hl, CHANNEL_FIELD16
add hl, bc
ld [hl], e
; store result in NoteDuration
- ld hl, wChannel1NoteDuration - wChannel1
+ ld hl, CHANNEL_NOTE_DURATION
add hl, bc
ld [hl], d
ret
@@ -2385,14 +2395,14 @@ Tempo: ; e8b03
; input:
; de: note length
; update Tempo
- ld hl, wChannel1Tempo - wChannel1
+ ld hl, CHANNEL_TEMPO
add hl, bc
ld [hl], e
inc hl
ld [hl], d
; clear ????
xor a
- ld hl, wChannel1Field16 - wChannel1
+ ld hl, CHANNEL_FIELD16
add hl, bc
ld [hl], a
ret
@@ -2401,7 +2411,7 @@ Tempo: ; e8b03
StartChannel: ; e8b11
call SetLRTracks
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_CHANNEL_ON, [hl] ; turn channel on
ret
@@ -2422,7 +2432,7 @@ SetLRTracks: ; e8b1b
add hl, de ; de = channel 0-3
ld a, [hl]
; load lr tracks into Tracks
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
ld [hl], a
pop de
@@ -2513,15 +2523,15 @@ _PlayCry:: ; e8b79
push af
call LoadChannel
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_REST, [hl]
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_CRY_PITCH, [hl]
- ld hl, wChannel1CryPitch - wChannel1
+ ld hl, CHANNEL_CRY_PITCH
add hl, bc
ld a, [wCryPitch]
ld [hli], a
@@ -2535,7 +2545,7 @@ _PlayCry:: ; e8b79
jr nc, .start
; Tempo is effectively length
- ld hl, wChannel1Tempo - wChannel1
+ ld hl, CHANNEL_TEMPO
add hl, bc
ld a, [wCryLength]
ld [hli], a
@@ -2555,12 +2565,12 @@ _PlayCry:: ; e8b79
jr z, .next
; [Tracks] &= [wCryTracks]
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
ld a, [hl]
ld hl, wCryTracks
and [hl]
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
ld [hl], a
@@ -2590,7 +2600,7 @@ _PlayCry:: ; e8b79
_PlaySFX:: ; e8c04
; clear channels if they aren't already
call MusicOff
- ld hl, wChannel5Flags
+ ld hl, wChannel5Flags1
bit SOUND_CHANNEL_ON, [hl] ; ch5 on?
jr z, .ch6
res SOUND_CHANNEL_ON, [hl] ; turn it off
@@ -2606,7 +2616,7 @@ _PlaySFX:: ; e8c04
ld [wSoundInput], a ; global sound off
ld [rNR10], a ; sweep = 0
.ch6
- ld hl, wChannel6Flags
+ ld hl, wChannel6Flags1
bit SOUND_CHANNEL_ON, [hl]
jr z, .ch7
res SOUND_CHANNEL_ON, [hl] ; turn it off
@@ -2619,7 +2629,7 @@ _PlaySFX:: ; e8c04
ld a, $80
ld [rNR24], a ; restart sound (freq hi = 0)
.ch7
- ld hl, wChannel7Flags
+ ld hl, wChannel7Flags1
bit SOUND_CHANNEL_ON, [hl]
jr z, .ch8
res SOUND_CHANNEL_ON, [hl] ; turn it off
@@ -2633,7 +2643,7 @@ _PlaySFX:: ; e8c04
ld a, $80
ld [rNR34], a ; restart sound (freq hi = 0)
.ch8
- ld hl, wChannel8Flags
+ ld hl, wChannel8Flags1
bit SOUND_CHANNEL_ON, [hl]
jr z, .chscleared
res SOUND_CHANNEL_ON, [hl] ; turn it off
@@ -2674,7 +2684,7 @@ _PlaySFX:: ; e8c04
.startchannels
push af
call LoadChannel ; bc = current channel
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_SFX, [hl]
call StartChannel
@@ -2729,7 +2739,7 @@ PlayStereoSFX:: ; e8ca6
push af
call LoadChannel
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_SFX, [hl]
@@ -2745,11 +2755,11 @@ PlayStereoSFX:: ; e8ca6
ld hl, wStereoPanningMask
and [hl]
- ld hl, wChannel1Tracks - wChannel1
+ ld hl, CHANNEL_TRACKS
add hl, bc
ld [hl], a
- ld hl, wChannel1Field30 - wChannel1
+ ld hl, CHANNEL_FIELD30
add hl, bc
ld [hl], a
@@ -2760,15 +2770,15 @@ PlayStereoSFX:: ; e8ca6
; ch3-4
ld a, [wSFXDuration]
- ld hl, wChannel1Field2e - wChannel1
+ ld hl, CHANNEL_FIELD2E
add hl, bc
ld [hl], a
- ld hl, wChannel1Field2f - wChannel1
+ ld hl, CHANNEL_FIELD2F
add hl, bc
ld [hl], a
- ld hl, wChannel1Flags2 - wChannel1
+ ld hl, CHANNEL_FLAGS2
add hl, bc
set SOUND_UNKN_0F, [hl]
@@ -2776,7 +2786,7 @@ PlayStereoSFX:: ; e8ca6
pop de
; turn channel on
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
set SOUND_CHANNEL_ON, [hl] ; on
@@ -2808,12 +2818,12 @@ LoadChannel: ; e8d1b
ld c, [hl]
inc hl
ld b, [hl] ; bc = channel pointer
- ld hl, wChannel1Flags - wChannel1
+ ld hl, CHANNEL_FLAGS1
add hl, bc
res SOUND_CHANNEL_ON, [hl] ; channel off
call ChannelInit
; load music pointer
- ld hl, wChannel1MusicAddress - wChannel1
+ ld hl, CHANNEL_MUSIC_ADDRESS
add hl, bc
call LoadMusicByte
ld [hli], a
@@ -2822,14 +2832,14 @@ LoadChannel: ; e8d1b
ld [hl], a
inc de
; load music id
- ld hl, wChannel1MusicID - wChannel1
+ ld hl, CHANNEL_MUSIC_ID
add hl, bc
ld a, [wMusicID]
ld [hli], a
ld a, [wMusicID + 1]
ld [hl], a
; load music bank
- ld hl, wChannel1MusicBank - wChannel1
+ ld hl, CHANNEL_MUSIC_BANK
add hl, bc
ld a, [wMusicBank]
ld [hl], a
@@ -2845,23 +2855,23 @@ ChannelInit: ; e8d5b
push de
xor a
; get channel struct location and length
- ld hl, wChannel1MusicID - wChannel1 ; start
+ ld hl, CHANNEL_MUSIC_ID ; start
add hl, bc
- ld e, wChannel2 - wChannel1 ; channel struct length
+ ld e, CHANNEL_STRUCT_LENGTH ; channel struct length
; clear channel
.loop
ld [hli], a
dec e
jr nz, .loop
; set tempo to default ($100)
- ld hl, wChannel1Tempo - wChannel1
+ ld hl, CHANNEL_TEMPO
add hl, bc
xor a
ld [hli], a
inc a
ld [hl], a
; set note length to default ($1) (fast)
- ld hl, wChannel1NoteLength - wChannel1
+ ld hl, CHANNEL_NOTE_LENGTH
add hl, bc
ld [hl], a
pop de
diff --git a/audio/sfx.asm b/audio/sfx.asm
index 864e56558..2f80fa912 100644
--- a/audio/sfx.asm
+++ b/audio/sfx.asm
@@ -1545,9 +1545,9 @@ Sfx_2ndPlace_Ch8: ; f0fd2
togglesfx
sfxtogglenoise $3
notetype $8
-Sfx_2ndPlace_branch_f0fd7: ; f0fd7
+.loop
note C#, 1
- loopchannel 6, Sfx_2ndPlace_branch_f0fd7
+ loopchannel 6, .loop
note B_, 12
note B_, 12
note B_, 12
@@ -2085,7 +2085,7 @@ Sfx_GetBadge_Ch8: ; f121b
togglesfx
sfxtogglenoise $4
notetype $6
-Sfx_GetBadge_branch_f1220: ; f1220
+.loop
note B_, 12
note D_, 1
note D_, 1
@@ -2100,7 +2100,7 @@ Sfx_GetBadge_branch_f1220: ; f1220
note C#, 1
note C#, 1
note C#, 1
- loopchannel 2, Sfx_GetBadge_branch_f1220
+ loopchannel 2, .loop
note B_, 16
note __, 6
endchannel
@@ -2238,7 +2238,7 @@ Sfx_Protect_Ch5: ; f12ba
togglesfx
notetype $1, $f1
dutycycle $0
-Sfx_Protect_branch_f12c0: ; f12c0
+.loop
octave 5
note F_, 5
note A_, 5
@@ -2251,7 +2251,7 @@ Sfx_Protect_branch_f12c0: ; f12c0
octave 6
note C#, 5
note E_, 5
- loopchannel 3, Sfx_Protect_branch_f12c0
+ loopchannel 3, .loop
intensity $c1
octave 5
note F_, 5
@@ -2272,10 +2272,9 @@ Sfx_Protect_branch_f12c0: ; f12c0
; f12e5
Sfx_Protect_Ch8: ; f12e5
-Sfx_Protect_branch_f12e5: ; f12e5
noise __, 10, $9e, $0
noise __, 10, $be, $11
- loopchannel 6, Sfx_Protect_branch_f12e5
+ loopchannel 6, Sfx_Protect_Ch8
noise __, 10, $a7, $0
noise C_, 1, $75, $11
endchannel
@@ -2288,12 +2287,12 @@ Sfx_Sketch: ; f12f6
Sfx_Sketch_Ch5: ; f12f9
dutycycle $1
soundinput $a5
-Sfx_Sketch_branch_f12fd: ; f12fd
+.loop
sound __, 3, $f1, $06e0
sound __, 14, $af, $05b0
sound __, 5, $0, 0
sound __, 10, $f4, $0718
- loopchannel 3, Sfx_Sketch_branch_f12fd
+ loopchannel 3, .loop
soundinput $8
endchannel
; f1314
@@ -2303,12 +2302,11 @@ Sfx_RainDance: ; f1314
; f1317
Sfx_RainDance_Ch8: ; f1317
-Sfx_RainDance_branch_f1317: ; f1317
noise __, 12, $7d, $50
noise __, 7, $7d, $4f
noise __, 12, $7f, $47
noise __, 16, $6e, $22
- loopchannel 3, Sfx_RainDance_branch_f1317
+ loopchannel 3, Sfx_RainDance_Ch8
noise __, 7, $6d, $50
noise __, 6, $5d, $4f
noise __, 6, $4f, $47
@@ -2342,10 +2340,9 @@ Sfx_Spark: ; f1352
; f1355
Sfx_Spark_Ch8: ; f1355
-Sfx_Spark_branch_f1355: ; f1355
noise __, 5, $f8, $5d
noise __, 5, $d8, $6f
- loopchannel 2, Sfx_Spark_branch_f1355
+ loopchannel 2, Sfx_Spark_Ch8
endchannel
; f1360
@@ -2393,12 +2390,11 @@ Sfx_Thief: ; f139c
; f139f
Sfx_Thief_Ch8: ; f139f
-Sfx_Thief_branch_f139f: ; f139f
noise __, 1, $0, $0
noise __, 5, $e1, $12
noise __, 1, $0, $0
noise __, 3, $b1, $22
- loopchannel 2, Sfx_Thief_branch_f139f
+ loopchannel 2, Sfx_Thief_Ch8
endchannel
; f13b0
@@ -2488,7 +2484,7 @@ Sfx_Nightmare: ; f141d
Sfx_Nightmare_Ch5: ; f1420
dutycycle $0
soundinput $34
-Sfx_Nightmare_branch_f1424: ; f1424
+.loop
sound __, 4, $ba, $0631
sound __, 3, $0, 0
sound __, 4, $f8, $0621
@@ -2499,7 +2495,7 @@ Sfx_Nightmare_branch_f1424: ; f1424
sound __, 3, $0, 0
sound __, 4, $e8, $05f1
sound __, 3, $0, 0
- loopchannel 2, Sfx_Nightmare_branch_f1424
+ loopchannel 2, .loop
soundinput $8
endchannel
; f1453
@@ -2524,10 +2520,10 @@ Sfx_SweetKiss: ; f1469
Sfx_SweetKiss_Ch5: ; f146c
dutycycle $2
-Sfx_SweetKiss_branch_f146e: ; f146e
+.loop
sound __, 3, $c1, $07c8
sound __, 3, $d1, $07da
- loopchannel 2, Sfx_SweetKiss_branch_f146e
+ loopchannel 2, .loop
sound C_, 11, $f1, $07e2
endchannel
; f147f
@@ -2757,10 +2753,9 @@ Sfx_ZapCannon: ; f15de
; f15e1
Sfx_ZapCannon_Ch8: ; f15e1
-Sfx_ZapCannon_branch_f15e1: ; f15e1
noise __, 3, $e1, $49
noise __, 1, $0, $0
- loopchannel 8, Sfx_ZapCannon_branch_f15e1
+ loopchannel 8, Sfx_ZapCannon_Ch8
noise __, 9, $e1, $49
endchannel
; f15ef
@@ -2773,10 +2768,10 @@ Sfx_MeanLook_Ch5: ; f15f2
soundinput $77
dutycycle $3
sound __, 3, $f8, $0720
-Sfx_MeanLook_branch_f15fa: ; f15fa
+.loop
sound __, 2, $88, $0660
sound __, 3, $f8, $0790
- loopchannel 5, Sfx_MeanLook_branch_f15fa
+ loopchannel 5, .loop
sound __, 13, $f8, $0700
sound __, 13, $c8, $0720
sound __, 13, $a8, $0700
@@ -2806,13 +2801,13 @@ Sfx_Return: ; f1637
Sfx_Return_Ch5: ; f163a
dutycycle $0
-Sfx_Return_branch_f163c: ; f163c
+.loop
soundinput $bf
sound __, 9, $f1, $0759
soundinput $57
sound __, 9, $f1, $0759
sound C_, 1, $0, 0
- loopchannel 2, Sfx_Return_branch_f163c
+ loopchannel 2, .loop
soundinput $8
endchannel
; f1653
@@ -2843,14 +2838,14 @@ Sfx_MilkDrink: ; f167f
Sfx_MilkDrink_Ch5: ; f1682
dutycycle $2
-Sfx_MilkDrink_branch_f1684: ; f1684
+.loop
soundinput $a4
sound __, 3, $ea, $04e0
sound __, 14, $f7, $0290
soundinput $9e
sound __, 5, $c9, $05e1
sound __, 3, $0, 0
- loopchannel 6, Sfx_MilkDrink_branch_f1684
+ loopchannel 6, .loop
soundinput $8
endchannel
; f169f
@@ -2862,10 +2857,10 @@ Sfx_Present: ; f169f
Sfx_Present_Ch5: ; f16a2
dutycycle $2
soundinput $d6
-Sfx_Present_branch_f16a6: ; f16a6
+.loop
sound __, 3, $f1, $0740
sound __, 2, $0, 0
- loopchannel 3, Sfx_Present_branch_f16a6
+ loopchannel 3, .loop
sound C_, 1, $f1, $0780
soundinput $8
endchannel
@@ -2877,11 +2872,11 @@ Sfx_MorningSun: ; f16b9
Sfx_MorningSun_Ch5: ; f16bc
dutycycle $3
-Sfx_MorningSun_branch_f16be: ; f16be
+.loop
sound __, 3, $f1, $07e4
sound __, 3, $f1, $07e0
sound __, 6, $f2, $07e7
- loopchannel 3, Sfx_MorningSun_branch_f16be
+ loopchannel 3, .loop
sound __, 2, $0, 0
sound __, 9, $c2, $07e7
sound __, 2, $0, 0
@@ -2895,10 +2890,10 @@ Sfx_Moonlight: ; f16df
Sfx_Moonlight_Ch5: ; f16e2
dutycycle $2
-Sfx_Moonlight_branch_f16e4: ; f16e4
+.loop
sound __, 2, $f8, $07d0
sound __, 5, $f1, $07e0
- loopchannel 2, Sfx_Moonlight_branch_f16e4
+ loopchannel 2, .loop
sound C_, 1, $f1, $07e0
sound C_, 1, $d1, $07e0
sound C_, 1, $81, $07e0
@@ -2914,10 +2909,10 @@ Sfx_Encore_Ch5: ; f1703
dutycycle $2
soundinput $ce
sound C_, 1, $0, 0
-Sfx_Encore_branch_f170b: ; f170b
+.loop
sound __, 3, $f8, $0774
sound C#, 5, $0, 0
- loopchannel 2, Sfx_Encore_branch_f170b
+ loopchannel 2, .loop
soundinput $8
endchannel
; f171a
@@ -3085,12 +3080,12 @@ Sfx_GsIntroCharizardFireball: ; f17d9
Sfx_GsIntroCharizardFireball_Ch8: ; f17dc
noise __, 9, $cf, $4d
noise __, 9, $f1, $37
-Sfx_GsIntroCharizardFireball_branch_f17e2: ; f17e2
+.loop
noise __, 2, $f8, $4f
noise __, 1, $c8, $26
noise __, 2, $d8, $5f
noise __, 1, $a8, $37
- loopchannel 12, Sfx_GsIntroCharizardFireball_branch_f17e2
+ loopchannel 12, .loop
noise __, 4, $f8, $6f
noise __, 5, $d8, $5f
noise __, 13, $d8, $5c
@@ -3348,13 +3343,13 @@ Sfx_DexFanfare140169_Ch8: ; f193f
sfxtogglenoise $4
notetype $c
note C_, 4
-Sfx_DexFanfare140169_branch_f1945: ; f1945
+.loop
note D_, 4
note C#, 1
note C#, 1
note C#, 1
note C#, 1
- loopchannel 3, Sfx_DexFanfare140169_branch_f1945
+ loopchannel 3, .loop
note D_, 8
endchannel
; f1950
@@ -3762,7 +3757,7 @@ Sfx_DexFanfare230Plus_Ch8: ; f1b0c
note D_, 2
note D_, 2
note D_, 2
-Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14
+.loop1
note D_, 6
note D_, 2
note D_, 2
@@ -3774,7 +3769,7 @@ Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14
note C#, 1
note C#, 1
note C#, 1
- loopchannel 2, Sfx_DexFanfare230Plus_branch_f1b14
+ loopchannel 2, .loop1
note D_, 6
note D_, 2
note D_, 2
@@ -3783,9 +3778,9 @@ Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14
note D_, 4
note D_, 4
note D_, 4
-Sfx_DexFanfare230Plus_branch_f1b2b: ; f1b2b
+.loop2
note C#, 1
- loopchannel 18, Sfx_DexFanfare230Plus_branch_f1b2b
+ loopchannel 18, .loop2
note D_, 6
endchannel
; f1b32
@@ -3878,11 +3873,11 @@ Sfx_SweetScent2_Ch5: ; f1bb9
Sfx_SweetScent2_Ch8: ; f1bcc
noise __, 3, $e8, $22
noise C_, 2, $aa, $0
-Sfx_SweetScent2_branch_f1bd2: ; f1bd2
+.loop
noise __, 5, $d9, $10
noise __, 9, $91, $0
noise __, 3, $61, $7
- loopchannel 5, Sfx_SweetScent2_branch_f1bd2
+ loopchannel 5, .loop
noise __, 5, $99, $0
noise __, 11, $61, $0
noise __, 7, $59, $0
@@ -3990,13 +3985,13 @@ Sfx_2Boops: ; f1cb4
Sfx_2Boops_Ch5: ; f1cb7
dutycycle $2
-Sfx_2Boops_branch_f1cb9: ; f1cb9
+.loop
soundinput $79
sound __, 2, $99, $0563
sound __, 5, $f2, $04b5
soundinput $43
sound C_, 1, $f8, $05cd
- loopchannel 2, Sfx_2Boops_branch_f1cb9
+ loopchannel 2, .loop
soundinput $8
endchannel
; f1cd0
@@ -4150,11 +4145,10 @@ Sfx_Potion_Ch5: ; f1d9d
; f1dac
Sfx_Poison_Ch5: ; f1dac
-Sfx_Poison_branch_f1dac: ; f1dac
dutycycle $0
soundinput $14
sound __, 5, $f2, $0600
- loopchannel 4, Sfx_Poison_branch_f1dac
+ loopchannel 4, Sfx_Poison_Ch5
sound __, 16, $f3, $0600
soundinput $8
endchannel
@@ -4572,11 +4566,10 @@ Sfx_Cut_Ch8: ; f20c3
; f20d0
Sfx_WingAttack_Ch8: ; f20d0
-Sfx_WingAttack_branch_f20d0: ; f20d0
noise __, 9, $4f, $23
noise __, 5, $c4, $22
noise __, 7, $f2, $23
- loopchannel 4, Sfx_WingAttack_branch_f20d0
+ loopchannel 4, Sfx_WingAttack_Ch8
endchannel
; f20de
@@ -4754,9 +4747,9 @@ Sfx_Thunder_Ch8: ; f21d3
Sfx_Supersonic_Ch5: ; f21e9
dutycycle $2
sound __, 16, $3f, $07c0
-Sfx_Supersonic_branch_f21ef: ; f21ef
+.loop
sound __, 16, $df, $07c0
- loopchannel 4, Sfx_Supersonic_branch_f21ef
+ loopchannel 4, .loop
sound __, 16, $d1, $07c0
endchannel
; f21fc
@@ -4764,63 +4757,57 @@ Sfx_Supersonic_branch_f21ef: ; f21ef
Sfx_Supersonic_Ch6: ; f21fc
sound_duty 3, 0, 3, 2
sound __, 16, $2f, $07c8
-Sfx_Supersonic_branch_f2202: ; f2202
+.loop
sound __, 16, $cf, $07c7
- loopchannel 4, Sfx_Supersonic_branch_f2202
+ loopchannel 4, .loop
sound __, 16, $c1, $07c8
endchannel
; f220f
Sfx_Supersonic_Ch8: ; f220f
-Sfx_Supersonic_branch_f220f: ; f220f
noise __, 4, $97, $12
noise __, 4, $a1, $11
- loopchannel 10, Sfx_Supersonic_branch_f220f
+ loopchannel 10, Sfx_Supersonic_Ch8
endchannel
; f221a
Sfx_Leer_Ch5: ; f221a
-Sfx_Leer_branch_f221a: ; f221a
dutycycle $0
sound __, 1, $f1, $07c0
sound __, 1, $f1, $0700
- loopchannel 12, Sfx_Leer_branch_f221a
+ loopchannel 12, Sfx_Leer_Ch5
endchannel
; f2229
Sfx_Leer_Ch6: ; f2229
-Sfx_Leer_branch_f2229: ; f2229
sound_duty 3, 0, 3, 2
sound __, 1, $e1, $07c1
sound __, 1, $e1, $0701
- loopchannel 12, Sfx_Leer_branch_f2229
+ loopchannel 12, Sfx_Leer_Ch6
endchannel
; f2238
Sfx_Leer_Ch8: ; f2238
-Sfx_Leer_branch_f2238: ; f2238
noise __, 2, $d1, $49
noise __, 2, $d1, $29
- loopchannel 6, Sfx_Leer_branch_f2238
+ loopchannel 6, Sfx_Leer_Ch8
endchannel
; f2243
Sfx_Ember_Ch5: ; f2243
-Sfx_Ember_branch_f2243: ; f2243
sound_duty 1, 2, 0, 3
sound __, 12, $f3, $0120
sound __, 10, $d3, $0150
- loopchannel 5, Sfx_Ember_branch_f2243
+ loopchannel 5, Sfx_Ember_Ch5
sound __, 9, $e3, $0130
sound __, 16, $c2, $0110
endchannel
; f225a
Sfx_Ember_Ch8: ; f225a
-Sfx_Ember_branch_f225a: ; f225a
noise __, 11, $f3, $35
noise __, 15, $f6, $45
- loopchannel 4, Sfx_Ember_branch_f225a
+ loopchannel 4, Sfx_Ember_Ch8
noise __, 13, $f4, $bc
noise __, 13, $f5, $9c
noise __, 16, $f4, $ac
@@ -4828,178 +4815,161 @@ Sfx_Ember_branch_f225a: ; f225a
; f226e
Sfx_Bubblebeam_Ch5: ; f226e
-Sfx_Bubblebeam_branch_f226e: ; f226e
sound_duty 1, 2, 3, 0
sound __, 5, $f4, $0600
sound __, 4, $c4, $0500
sound __, 6, $b5, $0600
sound __, 14, $e2, $06c0
- loopchannel 3, Sfx_Bubblebeam_branch_f226e
+ loopchannel 3, Sfx_Bubblebeam_Ch5
sound __, 9, $d1, $0600
endchannel
; f2289
Sfx_Bubblebeam_Ch6: ; f2289
-Sfx_Bubblebeam_branch_f2289: ; f2289
sound_duty 1, 3, 0, 2
sound __, 6, $e4, $05e0
sound __, 5, $b4, $04e0
sound __, 7, $a5, $05e8
sound __, 15, $d1, $06a0
- loopchannel 3, Sfx_Bubblebeam_branch_f2289
+ loopchannel 3, Sfx_Bubblebeam_Ch6
endchannel
; f22a0
Sfx_Bubblebeam_Ch8: ; f22a0
-Sfx_Bubblebeam_branch_f22a0: ; f22a0
noise __, 6, $c3, $33
noise __, 4, $92, $43
noise __, 11, $b5, $33
noise __, 16, $c3, $32
- loopchannel 2, Sfx_Bubblebeam_branch_f22a0
+ loopchannel 2, Sfx_Bubblebeam_Ch8
endchannel
; f22b1
Sfx_HydroPump_Ch5: ; f22b1
-Sfx_HydroPump_branch_f22b1: ; f22b1
sound_duty 2, 0, 1, 3
sound __, 4, $81, $0300
sound __, 4, $c1, $0400
sound __, 4, $f1, $0500
sound __, 4, $b1, $0400
sound __, 4, $71, $0300
- loopchannel 5, Sfx_HydroPump_branch_f22b1
+ loopchannel 5, Sfx_HydroPump_Ch5
sound __, 9, $81, $0400
endchannel
; f22d0
Sfx_HydroPump_Ch8: ; f22d0
-Sfx_HydroPump_branch_f22d0: ; f22d0
noise __, 4, $62, $22
noise __, 4, $a2, $32
noise __, 4, $d2, $33
noise __, 4, $92, $23
noise __, 4, $52, $12
- loopchannel 5, Sfx_HydroPump_branch_f22d0
+ loopchannel 5, Sfx_HydroPump_Ch8
noise __, 9, $81, $12
endchannel
; f22e7
Sfx_Surf_Ch5: ; f22e7
-Sfx_Surf_branch_f22e7: ; f22e7
sound_duty 1, 2, 3, 0
sound __, 16, $f4, $0500
sound __, 16, $c4, $0400
sound __, 16, $e2, $05c0
- loopchannel 3, Sfx_Surf_branch_f22e7
+ loopchannel 3, Sfx_Surf_Ch5
endchannel
; f22fa
Sfx_Surf_Ch6: ; f22fa
-Sfx_Surf_branch_f22fa: ; f22fa
sound_duty 1, 3, 0, 2
sound __, 8, $e4, $0430
sound __, 16, $b4, $0330
sound __, 16, $a2, $0438
- loopchannel 4, Sfx_Surf_branch_f22fa
+ loopchannel 4, Sfx_Surf_Ch6
endchannel
; f230d
Sfx_Surf_Ch8: ; f230d
-Sfx_Surf_branch_f230d: ; f230d
noise __, 10, $f4, $44
noise __, 10, $f2, $43
noise __, 16, $f4, $42
noise __, 16, $f4, $41
- loopchannel 3, Sfx_Surf_branch_f230d
+ loopchannel 3, Sfx_Surf_Ch8
endchannel
; f231e
Sfx_Psybeam_Ch5: ; f231e
-Sfx_Psybeam_branch_f231e: ; f231e
sound_duty 1, 0, 2, 2
sound __, 11, $f1, $0640
sound __, 11, $f3, $0680
sound __, 11, $f2, $0620
- loopchannel 4, Sfx_Psybeam_branch_f231e
+ loopchannel 4, Sfx_Psybeam_Ch5
sound __, 11, $f1, $0640
endchannel
; f2335
Sfx_Psybeam_Ch6: ; f2335
-Sfx_Psybeam_branch_f2335: ; f2335
sound_duty 3, 0, 3, 2
sound __, 11, $f3, $0571
sound __, 8, $e3, $0531
sound __, 11, $f1, $0551
- loopchannel 4, Sfx_Psybeam_branch_f2335
+ loopchannel 4, Sfx_Psybeam_Ch6
sound __, 11, $f1, $0571
endchannel
; f234c
Sfx_Psybeam_Ch8: ; f234c
-Sfx_Psybeam_branch_f234c: ; f234c
noise __, 3, $d1, $4a
noise __, 3, $d2, $2a
- loopchannel 21, Sfx_Psybeam_branch_f234c
+ loopchannel 21, Sfx_Psybeam_Ch8
endchannel
; f2357
Sfx_Charge_Ch5: ; f2357
-Sfx_Charge_branch_f2357: ; f2357
dutycycle $0
sound __, 3, $f1, $0200
sound __, 4, $f1, $0700
sound __, 5, $f1, $0500
sound __, 6, $f1, $07f0
- loopchannel 8, Sfx_Charge_branch_f2357
+ loopchannel 8, Sfx_Charge_Ch5
endchannel
; f236e
Sfx_Charge_Ch6: ; f236e
-Sfx_Charge_branch_f236e: ; f236e
sound_duty 3, 0, 3, 2
sound __, 3, $e1, $0302
sound __, 4, $e1, $07f2
sound __, 5, $e1, $0602
sound __, 6, $e1, $0702
- loopchannel 8, Sfx_Charge_branch_f236e
+ loopchannel 8, Sfx_Charge_Ch6
endchannel
; f2385
Sfx_Charge_Ch8: ; f2385
-Sfx_Charge_branch_f2385: ; f2385
noise __, 3, $d3, $10
noise __, 4, $d3, $11
noise __, 3, $d2, $10
noise __, 6, $d2, $12
- loopchannel 9, Sfx_Charge_branch_f2385
+ loopchannel 9, Sfx_Charge_Ch8
endchannel
; f2396
Sfx_Thundershock_Ch5: ; f2396
-Sfx_Thundershock_branch_f2396: ; f2396
sound_duty 3, 2, 2, 0
sound __, 4, $f1, $07f0
sound __, 5, $f2, $0200
- loopchannel 8, Sfx_Thundershock_branch_f2396
+ loopchannel 8, Sfx_Thundershock_Ch5
endchannel
; f23a5
Sfx_Thundershock_Ch6: ; f23a5
-Sfx_Thundershock_branch_f23a5: ; f23a5
sound_duty 3, 0, 3, 2
sound __, 5, $e2, $0202
sound __, 5, $e1, $07e2
- loopchannel 9, Sfx_Thundershock_branch_f23a5
+ loopchannel 9, Sfx_Thundershock_Ch6
endchannel
; f23b4
Sfx_Thundershock_Ch8: ; f23b4
-Sfx_Thundershock_branch_f23b4: ; f23b4
noise __, 5, $ff, $43
noise __, 5, $f2, $44
- loopchannel 9, Sfx_Thundershock_branch_f23b4
+ loopchannel 9, Sfx_Thundershock_Ch8
endchannel
; f23bf
@@ -5159,10 +5129,10 @@ Sfx_HyperBeam_Ch5: ; f24ca
sound __, 3, $f1, $07c0
sound __, 3, $f1, $0700
sound __, 3, $f1, $07d0
-Sfx_HyperBeam_branch_f24f8: ; f24f8
+.loop
sound __, 3, $f1, $0700
sound __, 3, $f1, $07e0
- loopchannel 12, Sfx_HyperBeam_branch_f24f8
+ loopchannel 12, .loop
sound __, 16, $f1, $0700
endchannel
; f2509
@@ -5180,19 +5150,18 @@ Sfx_HyperBeam_Ch6: ; f2509
sound __, 3, $f1, $07c1
sound __, 3, $f1, $0701
sound __, 3, $f1, $07d1
-Sfx_HyperBeam_branch_f2537: ; f2537
+.loop
sound __, 3, $f1, $0701
sound __, 3, $f1, $07e1
- loopchannel 12, Sfx_HyperBeam_branch_f2537
+ loopchannel 12, .loop
sound __, 16, $f1, $0701
endchannel
; f2548
Sfx_HyperBeam_Ch8: ; f2548
-Sfx_HyperBeam_branch_f2548: ; f2548
noise __, 2, $d1, $49
noise __, 2, $d1, $29
- loopchannel 26, Sfx_HyperBeam_branch_f2548
+ loopchannel 26, Sfx_HyperBeam_Ch8
endchannel
; f2553
@@ -5302,10 +5271,9 @@ Sfx_Metronome_Ch5: ; f25ec
; f2617
Sfx_Unknown5F_Ch5: ; f2617
-Sfx_Unknown5F_branch_f2617: ; f2617
sound __, 3, $f7, $0601
sound __, 3, $f7, $0701
- loopchannel 8, Sfx_Unknown5F_branch_f2617
+ loopchannel 8, Sfx_Unknown5F_Ch5
endchannel
; f2624
@@ -5313,7 +5281,7 @@ Sfx_Unknown5F_Ch6: ; f2624
sound __, 2, $f7, $ffff
sound __, 3, $f7, $0602
sound __, 3, $f7, $0702
- loopchannel 8, Sfx_Unknown5F_branch_f2617
+ loopchannel 8, Sfx_Unknown5F_Ch5
endchannel
; f2635
@@ -5484,35 +5452,31 @@ Sfx_HangUp_Ch5: ; f26f1
sound __, 5, $b8, $077b
sound __, 3, $21, $077b
sound C_, 1, $0, 0
-Sfx_HangUp_branch_f26ff: ; f26ff
Sfx_NoSignal_Ch5: ; f26ff
-Sfx_NoSignal_branch_f26ff: ; f26ff
dutycycle $2
sound C_, 5, $e8, $070b
sound C_, 13, $0, 0
- loopchannel 3, Sfx_HangUp_branch_f26ff
+ loopchannel 3, Sfx_NoSignal_Ch5
endchannel
; f270e
Sfx_Sandstorm_Ch8: ; f270e
-Sfx_Sandstorm_branch_f270e: ; f270e
Sfx_Unknown5F_Ch8: ; f270e
-Sfx_Unknown5F_branch_f270e: ; f270e
noise __, 2, $f8, $41
noise __, 3, $9c, $24
noise __, 1, $0, $0
noise __, 4, $59, $16
noise __, 3, $0, $0
- loopchannel 3, Sfx_Sandstorm_branch_f270e
+ loopchannel 3, Sfx_Sandstorm_Ch8
endchannel
; f2722
Sfx_Elevator_Ch5: ; f2722
dutycycle $2
soundinput $5a
-Sfx_Elevator_branch_f2726: ; f2726
+.loop
sound __, 3, $f1, $0300
- loopchannel 48, Sfx_Elevator_branch_f2726
+ loopchannel 48, .loop
soundinput $8
dutycycle $2
sound __, 16, $f3, $0730
diff --git a/audio/sfx_crystal.asm b/audio/sfx_crystal.asm
index 178d4b560..eb5cae561 100644
--- a/audio/sfx_crystal.asm
+++ b/audio/sfx_crystal.asm
@@ -196,7 +196,7 @@ Sfx_Tingle_Ch5: ; 179964
dutycycle $1
pitchoffset 0, B_
notetype $1, $b1
-Sfx_Tingle_branch_17996c: ; 17996c
+.loop
octave 5
note C_, 3
octave 6
@@ -204,7 +204,7 @@ Sfx_Tingle_branch_17996c: ; 17996c
octave 5
note C_, 3
note __, 2
- loopchannel 2, Sfx_Tingle_branch_17996c
+ loopchannel 2, .loop
note C_, 2
intensity $a1
note G_, 13
diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm
index 85c5cc577..ec8311dfe 100644
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -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
@@ -69,11 +109,11 @@ NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
const NOTE_VIBRATO_OVERRIDE ; 6
; wVolume
-VOLUME_SO1_F EQU 3
-VOLUME_SO2_F EQU 7
+VOLUME_SO1_F EQU 3
+VOLUME_SO2_F EQU 7
VOLUME_SO1_LEVEL EQU %00000111
VOLUME_SO2_LEVEL EQU %01110000
-MAX_VOLUME EQU $77
+MAX_VOLUME EQU $77
; wSoundInput
SOUND_INPUT_CH1_F EQU 0
diff --git a/constants/map_constants.asm b/constants/map_constants.asm
index 3efc8e30b..7c07c9e9e 100644
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -5,8 +5,8 @@ ENDM
map_const: MACRO
;\1: map id
-;\2: height: in blocks
-;\3: width: in blocks
+;\2: width: in blocks
+;\3: height: in blocks
GROUP_\1 EQU const_value
enum MAP_\1
\1_WIDTH EQU \2
diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm
index 73685d4ec..ee0b21356 100644
--- a/constants/map_object_constants.asm
+++ b/constants/map_object_constants.asm
@@ -44,16 +44,54 @@ OW_LEFT EQU LEFT << 2
OW_RIGHT EQU RIGHT << 2
; object_struct OBJECT_FLAGS1 bit flags
-INVISIBLE EQU 0
-FIXED_FACING EQU 2
-SLIDING EQU 3
-EMOTE_OBJECT EQU 7
+ const_def
+ const INVISIBLE_F ; 0
+ const WONT_DELETE_F ; 1
+ const FIXED_FACING_F ; 2
+ const SLIDING_F ; 3
+ const NOCLIP_TILES_F ; 4
+ const MOVE_ANYWHERE_F ; 5
+ const NOCLIP_OBJS_F ; 6
+ const EMOTE_OBJECT_F ; 7
+
+INVISIBLE EQU 1 << INVISIBLE_F
+WONT_DELETE EQU 1 << WONT_DELETE_F
+FIXED_FACING EQU 1 << FIXED_FACING_F
+SLIDING EQU 1 << SLIDING_F
+NOCLIP_TILES EQU 1 << NOCLIP_TILES_F
+MOVE_ANYWHERE EQU 1 << MOVE_ANYWHERE_F
+NOCLIP_OBJS EQU 1 << NOCLIP_OBJS_F
+EMOTE_OBJECT EQU 1 << EMOTE_OBJECT_F
; object_struct OBJECT_FLAGS2 bit flags
-LOW_PRIORITY EQU 0
-HIGH_PRIORITY EQU 1
-OVERHEAD EQU 3
+ const_def
+ const LOW_PRIORITY_F ; 0
+ const HIGH_PRIORITY_F ; 1
+ const OBJ_FLAGS2_2 ; 2
+ const OVERHEAD_F ; 3
+ const USE_OBP1_F ; 4
+
+LOW_PRIORITY EQU 1 << LOW_PRIORITY_F
+HIGH_PRIORITY EQU 1 << HIGH_PRIORITY_F
+OVERHEAD EQU 1 << OVERHEAD_F
+USE_OBP1 EQU 1 << USE_OBP1_F
+
+; object_struct OBJECT_PALETTE bit flags
+ const_def 5
+ const SWIMMING_F ; 5
+ const STRENGTH_BOULDER_F ; 6
+ const BIG_OBJECT_F ; 7
+SWIMMING EQU 1 << SWIMMING_F
+STRENGTH_BOULDER EQU 1 << STRENGTH_BOULDER_F
+BIG_OBJECT EQU 1 << BIG_OBJECT_F
+
+; facing attribute bit flags
+RELATIVE_ATTRIBUTES_F EQU 1
+ABSOLUTE_TILE_ID_F EQU 2
+
+RELATIVE_ATTRIBUTES EQU 1 << RELATIVE_ATTRIBUTES_F
+ABSOLUTE_TILE_ID EQU 1 << ABSOLUTE_TILE_ID_F
; map_object struct members (see macros/wram.asm)
const_def
@@ -75,8 +113,18 @@ OVERHEAD EQU 3
const MAPOBJECT_F ; unused
OBJECT_LENGTH EQU const_value
-MAPOBJECT_SCREEN_HEIGHT EQU 11
-MAPOBJECT_SCREEN_WIDTH EQU 12
+; SpriteMovementData struct members (see data/sprites/map_objects.asm)
+ const_def
+ const SPRITEMOVEATTR_MOVEMENT ; 0
+ const SPRITEMOVEATTR_FACING ; 1
+ const SPRITEMOVEATTR_ACTION ; 2
+ const SPRITEMOVEATTR_FLAGS1 ; 3
+ const SPRITEMOVEATTR_FLAGS2 ; 4
+ const SPRITEMOVEATTR_PALFLAGS ; 5
+NUM_SPRITEMOVEDATA_FIELDS EQU const_value
+
+MAPOBJECT_SCREEN_WIDTH EQU (SCREEN_WIDTH / 2) + 2
+MAPOBJECT_SCREEN_HEIGHT EQU (SCREEN_HEIGHT / 2) + 2
; SpriteMovementData indexes (see data/sprites/map_objects.asm)
@@ -119,7 +167,6 @@ MAPOBJECT_SCREEN_WIDTH EQU 12
const SPRITEMOVEDATA_GRASS ; 23
const SPRITEMOVEDATA_SWIM_WANDER ; 24
NUM_SPRITEMOVEDATA EQU const_value
-SPRITEMOVEDATA_FIELDS EQU 6
; MapObjectMovementPattern.Pointers indexes (see engine/overworld/map_objects.asm)
const_def
diff --git a/constants/scgb_constants.asm b/constants/scgb_constants.asm
index e7d987113..807b5003c 100644
--- a/constants/scgb_constants.asm
+++ b/constants/scgb_constants.asm
@@ -15,9 +15,9 @@
const SCGB_GS_TITLE_SCREEN
const SCGB_0D
const SCGB_MOVE_LIST
- const SCGB_0F
+ const SCGB_BETA_PIKACHU_MINIGAME
const SCGB_POKEDEX_SEARCH_OPTION
- const SCGB_11
+ const SCGB_BETA_POKER
const SCGB_POKEPIC
const SCGB_13
const SCGB_PACKPALS
@@ -75,40 +75,40 @@ SCGB_RAM EQU -1
const PREDEFPAL_RB_PINKMON
const PREDEFPAL_RB_YELLOWMON
const PREDEFPAL_CGB_BADGE ; RB_GREYMON
- const PREDEFPAL_MEWMON_NITE
- const PREDEFPAL_BLUEMON_NITE
- const PREDEFPAL_REDMON_NITE
- const PREDEFPAL_CYANMON_NITE
- const PREDEFPAL_PURPLEMON_NITE
- const PREDEFPAL_BROWNMON_NITE
- const PREDEFPAL_GREENMON_NITE
- const PREDEFPAL_PINKMON_NITE
- const PREDEFPAL_YELLOWMON_NITE
- const PREDEFPAL_PARTY_ICON ; GREYMON_NITE
+ const PREDEFPAL_BETA_SHINY_MEWMON
+ const PREDEFPAL_BETA_SHINY_BLUEMON
+ const PREDEFPAL_BETA_SHINY_REDMON
+ const PREDEFPAL_BETA_SHINY_CYANMON
+ const PREDEFPAL_BETA_SHINY_PURPLEMON
+ const PREDEFPAL_BETA_SHINY_BROWNMON
+ const PREDEFPAL_BETA_SHINY_GREENMON
+ const PREDEFPAL_BETA_SHINY_PINKMON
+ const PREDEFPAL_BETA_SHINY_YELLOWMON
+ const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GREYMON
const PREDEFPAL_HP_GREEN
const PREDEFPAL_HP_YELLOW
const PREDEFPAL_HP_RED
const PREDEFPAL_POKEGEAR
- const PREDEFPAL_33
- const PREDEFPAL_34
+ const PREDEFPAL_BETA_LOGO_1
+ const PREDEFPAL_BETA_LOGO_2
const PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO
const PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS
- const PREDEFPAL_37
+ const PREDEFPAL_BETA_INTRO_LAPRAS
const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG
const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB
const PREDEFPAL_GS_INTRO_STARTERS_TRANSITION
- const PREDEFPAL_3B
+ const PREDEFPAL_BETA_INTRO_VENUSAUR
const PREDEFPAL_PACK ; GS_INTRO_CHARIZARD
const PREDEFPAL_SLOT_MACHINE_0
const PREDEFPAL_SLOT_MACHINE_1
const PREDEFPAL_SLOT_MACHINE_2
const PREDEFPAL_SLOT_MACHINE_3
- const PREDEFPAL_SCGB_11_0
- const PREDEFPAL_SCGB_11_1
- const PREDEFPAL_SCGB_11_2
- const PREDEFPAL_SCGB_11_3
- const PREDEFPAL_45
- const PREDEFPAL_46
+ const PREDEFPAL_BETA_POKER_0
+ const PREDEFPAL_BETA_POKER_1
+ const PREDEFPAL_BETA_POKER_2
+ const PREDEFPAL_BETA_POKER_3
+ const PREDEFPAL_BETA_RADIO
+ const PREDEFPAL_BETA_POKEGEAR
const PREDEFPAL_47
const PREDEFPAL_GS_TITLE_SCREEN_0
const PREDEFPAL_GS_TITLE_SCREEN_1
diff --git a/data/battle_anims/object_gfx.asm b/data/battle_anims/object_gfx.asm
index 133298d13..441692b03 100644
--- a/data/battle_anims/object_gfx.asm
+++ b/data/battle_anims/object_gfx.asm
@@ -1,6 +1,6 @@
anim_obj_gfx: MACRO
; # tiles, label
- db \1
+ db \1
dba \2
ENDM
diff --git a/data/events/collision_stdscripts.asm b/data/events/collision_stdscripts.asm
index 8156d039d..dff26dd85 100644
--- a/data/events/collision_stdscripts.asm
+++ b/data/events/collision_stdscripts.asm
@@ -10,4 +10,4 @@ TileCollisionStdScripts:
dbw COLL_TV, tv
dbw COLL_WINDOW, window
dbw COLL_INCENSE_BURNER, incenseburner
- db -1 ; end
+ db -1 ; end
diff --git a/data/items/attributes.asm b/data/items/attributes.asm
index 9f669e979..e0198e3ad 100644
--- a/data/items/attributes.asm
+++ b/data/items/attributes.asm
@@ -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
diff --git a/data/items/catch_rate_items.asm b/data/items/catch_rate_items.asm
index fbab7d434..d7ef4cf2b 100644
--- a/data/items/catch_rate_items.asm
+++ b/data/items/catch_rate_items.asm
@@ -15,5 +15,5 @@ TimeCapsule_CatchRateItems: ; 28785
db ITEM_DC, BERRY
db ITEM_FA, BERRY
db -1, BERRY
- db 0 ; end
+ db 0 ; end
; 2879e
diff --git a/data/predef_pointers.asm b/data/predef_pointers.asm
index 3a14a19ee..87906597a 100644
--- a/data/predef_pointers.asm
+++ b/data/predef_pointers.asm
@@ -58,7 +58,7 @@ PredefPointers:: ; 856b
add_predef InitSGBBorder ; $30
add_predef LoadSGBLayout
add_predef Pokedex_GetArea
- add_predef Unused_CheckContestMon
+ add_predef Unused_CheckShininess
add_predef DoBattleTransition
add_predef DummyPredef35
add_predef DummyPredef36
diff --git a/data/sprites/facings.asm b/data/sprites/facings.asm
index 166455707..c321ca462 100644
--- a/data/sprites/facings.asm
+++ b/data/sprites/facings.asm
@@ -50,24 +50,24 @@ FacingWeirdTree2: ; standing down
db 4 ; #
db 0, 0, 0, $00
db 0, 8, 0, $01
- db 8, 0, 2, $02
- db 8, 8, 2, $03
+ db 8, 0, RELATIVE_ATTRIBUTES, $02
+ db 8, 8, RELATIVE_ATTRIBUTES, $03
; 409c
FacingStepDown1: ; walking down 1
db 4 ; #
db 0, 0, 0, $80
db 0, 8, 0, $81
- db 8, 0, 2, $82
- db 8, 8, 2, $83
+ db 8, 0, RELATIVE_ATTRIBUTES, $82
+ db 8, 8, RELATIVE_ATTRIBUTES, $83
; 40ad
FacingStepDown3: ; walking down 2
db 4 ; #
db 0, 8, X_FLIP, $80
db 0, 0, X_FLIP, $81
- db 8, 8, 2 | X_FLIP, $82
- db 8, 0, 2 | X_FLIP, $83
+ db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $82
+ db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $83
; 40be
FacingStepUp0:
@@ -75,24 +75,24 @@ FacingStepUp2: ; standing up
db 4 ; #
db 0, 0, 0, $04
db 0, 8, 0, $05
- db 8, 0, 2, $06
- db 8, 8, 2, $07
+ db 8, 0, RELATIVE_ATTRIBUTES, $06
+ db 8, 8, RELATIVE_ATTRIBUTES, $07
; 40cf
FacingStepUp1: ; walking up 1
db 4 ; #
db 0, 0, 0, $84
db 0, 8, 0, $85
- db 8, 0, 2, $86
- db 8, 8, 2, $87
+ db 8, 0, RELATIVE_ATTRIBUTES, $86
+ db 8, 8, RELATIVE_ATTRIBUTES, $87
; 40e0
FacingStepUp3: ; walking up 2
db 4 ; #
db 0, 8, X_FLIP, $84
db 0, 0, X_FLIP, $85
- db 8, 8, 2 | X_FLIP, $86
- db 8, 0, 2 | X_FLIP, $87
+ db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $86
+ db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $87
; 40f1
FacingStepLeft0:
@@ -100,8 +100,8 @@ FacingStepLeft2: ; standing left
db 4 ; #
db 0, 0, 0, $08
db 0, 8, 0, $09
- db 8, 0, 2, $0a
- db 8, 8, 2, $0b
+ db 8, 0, RELATIVE_ATTRIBUTES, $0a
+ db 8, 8, RELATIVE_ATTRIBUTES, $0b
; 4102
FacingStepRight0:
@@ -109,8 +109,8 @@ FacingStepRight2: ; standing right
db 4 ; #
db 0, 8, X_FLIP, $08
db 0, 0, X_FLIP, $09
- db 8, 8, 2 | X_FLIP, $0a
- db 8, 0, 2 | X_FLIP, $0b
+ db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $0a
+ db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $0b
; 4113
FacingStepLeft1:
@@ -118,8 +118,8 @@ FacingStepLeft3: ; walking left
db 4 ; #
db 0, 0, 0, $88
db 0, 8, 0, $89
- db 8, 0, 2, $8a
- db 8, 8, 2, $8b
+ db 8, 0, RELATIVE_ATTRIBUTES, $8a
+ db 8, 8, RELATIVE_ATTRIBUTES, $8b
; 4124
FacingStepRight1:
@@ -127,58 +127,58 @@ FacingStepRight3: ; walking right
db 4 ; #
db 0, 8, X_FLIP, $88
db 0, 0, X_FLIP, $89
- db 8, 8, 2 | X_FLIP, $8a
- db 8, 0, 2 | X_FLIP, $8b
+ db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $8a
+ db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $8b
; 4135
FacingFishDown: ; fishing down
db 5 ; #
db 0, 0, 0, $00
db 0, 8, 0, $01
- db 8, 0, 2, $02
- db 8, 8, 2, $03
- db 16, 0, 4, $fc
+ db 8, 0, RELATIVE_ATTRIBUTES, $02
+ db 8, 8, RELATIVE_ATTRIBUTES, $03
+ db 16, 0, ABSOLUTE_TILE_ID, $fc
; 414a
FacingFishUp: ; fishing up
db 5 ; #
db 0, 0, 0, $04
db 0, 8, 0, $05
- db 8, 0, 2, $06
- db 8, 8, 2, $07
- db -8, 0, 4, $fc
+ db 8, 0, RELATIVE_ATTRIBUTES, $06
+ db 8, 8, RELATIVE_ATTRIBUTES, $07
+ db -8, 0, ABSOLUTE_TILE_ID, $fc
; 415f
FacingFishLeft: ; fishing left
db 5 ; #
db 0, 0, 0, $08
db 0, 8, 0, $09
- db 8, 0, 2, $0a
- db 8, 8, 2, $0b
- db 5, -8, 4 | X_FLIP, $fd
+ db 8, 0, RELATIVE_ATTRIBUTES, $0a
+ db 8, 8, RELATIVE_ATTRIBUTES, $0b
+ db 5, -8, ABSOLUTE_TILE_ID | X_FLIP, $fd
; 4174
FacingFishRight: ; fishing right
db 5 ; #
db 0, 8, X_FLIP, $08
db 0, 0, X_FLIP, $09
- db 8, 8, 2 | X_FLIP, $0a
- db 8, 0, 2 | X_FLIP, $0b
- db 5, 16, 4, $fd
+ db 8, 8, RELATIVE_ATTRIBUTES | X_FLIP, $0a
+ db 8, 0, RELATIVE_ATTRIBUTES | X_FLIP, $0b
+ db 5, 16, ABSOLUTE_TILE_ID, $fd
; 4189
FacingEmote: ; emote
db 4 ; #
- db 0, 0, 4, $f8
- db 0, 8, 4, $f9
- db 8, 0, 4, $fa
- db 8, 8, 4, $fb
+ db 0, 0, ABSOLUTE_TILE_ID, $f8
+ db 0, 8, ABSOLUTE_TILE_ID, $f9
+ db 8, 0, ABSOLUTE_TILE_ID, $fa
+ db 8, 8, ABSOLUTE_TILE_ID, $fb
; 419a
FacingShadow: ; shadow
db 2 ; #
- db 0, 0, 4, $fc
- db 0, 8, 4 | X_FLIP, $fc
+ db 0, 0, ABSOLUTE_TILE_ID, $fc
+ db 0, 8, ABSOLUTE_TILE_ID | X_FLIP, $fc
; 41a3
FacingBigDollSymmetric: ; big snorlax or lapras doll
@@ -237,28 +237,28 @@ FacingBigDollAsymmetric: ; big doll other than snorlax or lapras
FacingBoulderDust1: ; boulder dust 1
db 4 ; #
- db 0, 0, 4, $fe
- db 0, 8, 4, $fe
- db 8, 0, 4, $fe
- db 8, 8, 4, $fe
+ db 0, 0, ABSOLUTE_TILE_ID, $fe
+ db 0, 8, ABSOLUTE_TILE_ID, $fe
+ db 8, 0, ABSOLUTE_TILE_ID, $fe
+ db 8, 8, ABSOLUTE_TILE_ID, $fe
; 4250
FacingBoulderDust2: ; boulder dust 2
db 4 ; #
- db 0, 0, 4, $ff
- db 0, 8, 4, $ff
- db 8, 0, 4, $ff
- db 8, 8, 4, $ff
+ db 0, 0, ABSOLUTE_TILE_ID, $ff
+ db 0, 8, ABSOLUTE_TILE_ID, $ff
+ db 8, 0, ABSOLUTE_TILE_ID, $ff
+ db 8, 8, ABSOLUTE_TILE_ID, $ff
; 4261
FacingGrass1: ; 4261
db 2 ; #
- db 8, 0, 4, $fe
- db 8, 8, 4 | X_FLIP, $fe
+ db 8, 0, ABSOLUTE_TILE_ID, $fe
+ db 8, 8, ABSOLUTE_TILE_ID | X_FLIP, $fe
; 426a
FacingGrass2: ; 426a
db 2 ; #
- db 9, -1, 4, $fe
- db 9, 9, 4 | X_FLIP, $fe
+ db 9, -1, ABSOLUTE_TILE_ID, $fe
+ db 9, 9, ABSOLUTE_TILE_ID | X_FLIP, $fe
; 4273
diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm
index 8821f8a1b..cf577869a 100644
--- a/data/sprites/map_objects.asm
+++ b/data/sprites/map_objects.asm
@@ -5,304 +5,304 @@ SpriteMovementData:: ; 4273
db SPRITEMOVEFN_00 ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STILL
db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00001100 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db FIXED_FACING | SLIDING ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_WANDER
db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SPINRANDOM_SLOW
db SPRITEMOVEFN_SLOW_RANDOM_SPIN ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_WALK_UP_DOWN
db SPRITEMOVEFN_RANDOM_WALK_Y ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_WALK_LEFT_RIGHT
db SPRITEMOVEFN_RANDOM_WALK_X ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_DOWN
db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_UP
db SPRITEMOVEFN_STANDING ; movement function
db UP ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_LEFT
db SPRITEMOVEFN_STANDING ; movement function
db LEFT ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STANDING_RIGHT
db SPRITEMOVEFN_STANDING ; movement function
db RIGHT ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SPINRANDOM_FAST
db SPRITEMOVEFN_FAST_RANDOM_SPIN ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_PLAYER
db SPRITEMOVEFN_OBEY_DPAD ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_0C
db SPRITEMOVEFN_08 ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_0D
db SPRITEMOVEFN_09 ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_0E
db SPRITEMOVEFN_0A ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_0F
db SPRITEMOVEFN_0B ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_10
db SPRITEMOVEFN_0C ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_11
db SPRITEMOVEFN_0D ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_12
db SPRITEMOVEFN_0E ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_FOLLOWING
db SPRITEMOVEFN_FOLLOW ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SCRIPTED
db SPRITEMOVEFN_SCRIPTED ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_BIGDOLLSYM
db SPRITEMOVEFN_BIG_SNORLAX ; movement function
db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL_SYM ; action
- db %00101110 ; flags1
- db %00000001 ; flags2
- db %11000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db LOW_PRIORITY ; flags2
+ db STRENGTH_BOULDER | BIG_OBJECT ; palette flags
; SPRITEMOVEDATA_POKEMON
db SPRITEMOVEFN_BOUNCE ; movement function
db DOWN ; facing
db OBJECT_ACTION_BOUNCE ; action
- db %00101110 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SUDOWOODO
db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00001100 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db FIXED_FACING | SLIDING ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SMASHABLE_ROCK
db SPRITEMOVEFN_STANDING ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00101110 ; flags1
- db %00010000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db USE_OBP1 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_STRENGTH_BOULDER
db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00101110 ; flags1
- db %00000000 ; flags2
- db %01000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db 0 ; flags2
+ db STRENGTH_BOULDER ; palette flags
; SPRITEMOVEDATA_FOLLOWNOTEXACT
db SPRITEMOVEFN_FOLLOWNOTEXACT ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SHADOW
db SPRITEMOVEFN_SHADOW ; movement function
db DOWN ; facing
db OBJECT_ACTION_00 ; action
- db %10001110 ; flags1
- db %00000001 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+ db LOW_PRIORITY ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_EMOTE
db SPRITEMOVEFN_EMOTE ; movement function
db DOWN ; facing
db OBJECT_ACTION_EMOTE ; action
- db %10001110 ; flags1
- db %00000010 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+ db HIGH_PRIORITY ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SCREENSHAKE
db SPRITEMOVEFN_SCREENSHAKE ; movement function
db DOWN ; facing
db OBJECT_ACTION_00 ; action
- db %10000010 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | EMOTE_OBJECT ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SPINCOUNTERCLOCKWISE
db SPRITEMOVEFN_SPIN_COUNTERCLOCKWISE ; movement function
db LEFT ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SPINCLOCKWISE
db SPRITEMOVEFN_SPIN_CLOCKWISE ; movement function
db RIGHT ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_BIGDOLLASYM
db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL_ASYM ; action
- db %00101110 ; flags1
- db %00000001 ; flags2
- db %11000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db LOW_PRIORITY ; flags2
+ db STRENGTH_BOULDER | BIG_OBJECT ; palette flags
; SPRITEMOVEDATA_BIGDOLL
db SPRITEMOVEFN_STRENGTH ; movement function
db DOWN ; facing
db OBJECT_ACTION_BIG_DOLL ; action
- db %00101110 ; flags1
- db %00000001 ; flags2
- db %11000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | MOVE_ANYWHERE ; flags1
+ db LOW_PRIORITY ; flags2
+ db STRENGTH_BOULDER | BIG_OBJECT ; palette flags
; SPRITEMOVEDATA_BOULDERDUST
db SPRITEMOVEFN_BOULDERDUST ; movement function
db DOWN ; facing
db OBJECT_ACTION_BOULDER_DUST ; action
- db %10001110 ; flags1
- db %00000001 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+ db LOW_PRIORITY ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_GRASS
db SPRITEMOVEFN_GRASS ; movement function
db DOWN ; facing
db OBJECT_ACTION_GRASS_SHAKE ; action
- db %10001110 ; flags1
- db %00000010 ; flags2
- db %00000000 ; palette flags
+ db WONT_DELETE | FIXED_FACING | SLIDING | EMOTE_OBJECT ; flags1
+ db HIGH_PRIORITY ; flags2
+ db 0 ; palette flags
; SPRITEMOVEDATA_SWIM_WANDER
db SPRITEMOVEFN_RANDOM_WALK_XY ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00100000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db SWIMMING ; palette flags
; 25
db SPRITEMOVEFN_00 ; movement function
db DOWN ; facing
db OBJECT_ACTION_STAND ; action
- db %00000000 ; flags1
- db %00000000 ; flags2
- db %00000000 ; palette flags
+ db 0 ; flags1
+ db 0 ; flags2
+ db 0 ; palette flags
; 4357
diff --git a/data/types/type_matchups.asm b/data/types/type_matchups.asm
index 90e38ae2c..3cd0f609b 100644
--- a/data/types/type_matchups.asm
+++ b/data/types/type_matchups.asm
@@ -109,11 +109,11 @@ TypeMatchups: ; 34bb1
db STEEL, ROCK, SUPER_EFFECTIVE
db STEEL, STEEL, NOT_VERY_EFFECTIVE
- db -2 ; end
+ db -2 ; end (with Foresight)
; Foresight removes Ghost's immunities.
db NORMAL, GHOST, NO_EFFECT
db FIGHTING, GHOST, NO_EFFECT
- db -1 ; end (with Foresight)
+ db -1 ; end
; 34cfd
diff --git a/data/wild/treemon_maps.asm b/data/wild/treemon_maps.asm
index 59eba43cc..8bc742a3e 100644
--- a/data/wild/treemon_maps.asm
+++ b/data/wild/treemon_maps.asm
@@ -1,6 +1,6 @@
treemon_map: MACRO
map_id \1
- db \2 ; treemon set
+ db \2 ; treemon set
ENDM
TreeMonMaps: ; b825e
diff --git a/docs/bugs_and_glitches.md b/docs/bugs_and_glitches.md
index f7675ae78..2b5a6a152 100644
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -44,7 +44,7 @@ These are known bugs and glitches in the original Pokémon Crystal game: code th
- [Two tiles in the `port` tileset are drawn incorrectly](#two-tiles-in-the-port-tileset-are-drawn-incorrectly)
- [`LoadMetatiles` wraps around past 128 blocks](#loadmetatiles-wraps-around-past-128-blocks)
- [Surfing directly across a map connection does not load the new map](#surfing-directly-across-a-map-connection-does-not-load-the-new-map)
-- [`Function6ec1` does not correctly limit object movement](#function6ec1-does-not-correctly-limit-object-movement)
+- [Swimming NPCs aren't limited by their movement radius](#swimming-npcs-arent-limited-by-their-movement-radius)
- [`CheckOwnMon` only checks the first five letters of OT names](#checkownmon-only-checks-the-first-five-letters-of-ot-names)
- [Catching a Transformed Pokémon always catches a Ditto](#catching-a-transformed-pokémon-always-catches-a-ditto)
- [Using a Park Ball in normal battles has a corrupt animation](#using-a-park-ball-in-normal-battles-has-a-corrupt-animation)
@@ -1185,20 +1185,20 @@ In [home/map.asm](/home/map.asm):
*To do:* Identify specific code causing this bug and fix it.
-## `Function6ec1` does not correctly limit object movement
+## Swimming NPCs aren't limited by their movement radius
This bug is why the Lapras in [maps/UnionCaveB2F.asm](/maps/UnionCaveB2F.asm), which uses `SPRITEMOVEDATA_SWIM_WANDER`, is not restricted by its `1, 1` movement radius.
-In [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm):
+This is a bug with `CanObjectMoveInDirection` in [engine/overworld/npc_movement.asm](/engine/overworld/npc_movement.asm):
```asm
ld hl, OBJECT_FLAGS1
add hl, bc
- bit 4, [hl] ; lost, uncomment next line to fix
-; jr nz, .resume
+ bit NOCLIP_TILES_F, [hl] ; lost, uncomment next line to fix
+ ; jr nz, .noclip_tiles
```
-**Fix:** Uncomment `jr nz, .resume`.
+**Fix:** Uncomment `jr nz, .noclip_tiles`.
## `CheckOwnMon` only checks the first five letters of OT names
diff --git a/docs/design_flaws.md b/docs/design_flaws.md
index e4a81123b..6b015a56a 100644
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -36,7 +36,7 @@ GLOBAL PICS_FIX
push hl
push bc
- sub BANK(Pics_1) - PICS_FIX
+ sub BANK("Pics 1") - PICS_FIX
ld c, a
ld b, 0
ld hl, .PicsBanks
@@ -47,33 +47,33 @@ GLOBAL PICS_FIX
ret
.PicsBanks: ; 511d4
- db BANK(Pics_1) + 0
- db BANK(Pics_1) + 1
- db BANK(Pics_1) + 2
- db BANK(Pics_1) + 3
- db BANK(Pics_1) + 4
- db BANK(Pics_1) + 5
- db BANK(Pics_1) + 6
- db BANK(Pics_1) + 7
- db BANK(Pics_1) + 8
- db BANK(Pics_1) + 9
- db BANK(Pics_1) + 10
- db BANK(Pics_1) + 11
- db BANK(Pics_1) + 12
- db BANK(Pics_1) + 13
- db BANK(Pics_1) + 14
- db BANK(Pics_1) + 15
- db BANK(Pics_1) + 16
- db BANK(Pics_1) + 17
- db BANK(Pics_1) + 18
- db BANK(Pics_1) + 19
- db BANK(Pics_1) + 20
- db BANK(Pics_1) + 21
- db BANK(Pics_1) + 22
- db BANK(Pics_1) + 23
+ db BANK("Pics 1") ; BANK("Pics 1") + 0
+ db BANK("Pics 2") ; BANK("Pics 1") + 1
+ db BANK("Pics 3") ; BANK("Pics 1") + 2
+ db BANK("Pics 4") ; BANK("Pics 1") + 3
+ db BANK("Pics 5") ; BANK("Pics 1") + 4
+ db BANK("Pics 6") ; BANK("Pics 1") + 5
+ db BANK("Pics 7") ; BANK("Pics 1") + 6
+ db BANK("Pics 8") ; BANK("Pics 1") + 7
+ db BANK("Pics 9") ; BANK("Pics 1") + 8
+ db BANK("Pics 10") ; BANK("Pics 1") + 9
+ db BANK("Pics 11") ; BANK("Pics 1") + 10
+ db BANK("Pics 12") ; BANK("Pics 1") + 11
+ db BANK("Pics 13") ; BANK("Pics 1") + 12
+ db BANK("Pics 14") ; BANK("Pics 1") + 13
+ db BANK("Pics 15") ; BANK("Pics 1") + 14
+ db BANK("Pics 16") ; BANK("Pics 1") + 15
+ db BANK("Pics 17") ; BANK("Pics 1") + 16
+ db BANK("Pics 18") ; BANK("Pics 1") + 17
+ db BANK("Pics 19") ; BANK("Pics 1") + 18
+ db BANK("Pics 20") ; BANK("Pics 1") + 19
+ db BANK("Pics 21") ; BANK("Pics 1") + 20
+ db BANK("Pics 22") ; BANK("Pics 1") + 21
+ db BANK("Pics 23") ; BANK("Pics 1") + 22
+ db BANK("Pics 24") ; BANK("Pics 1") + 23
```
-**Fix:** Use `dba` instead of `dba_pic`, and don't call `FixPicBank` to modify `a`.
+**Fix:** Use `dba` instead of `dba_pic`, delete `FixPicBank`, and remove all four calls to `FixPicBank`.
## `PokemonPicPointers` and `UnownPicPointers` are assumed to start at the same address
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 7af2db8ad..567737c1f 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -1055,7 +1055,7 @@ AI_Smart_TrapTarget: ; 38a71
jr nz, .asm_38a91
ld a, [wPlayerSubStatus1]
- and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
+ and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38a91
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
@@ -1569,7 +1569,7 @@ AI_Smart_DefrostOpponent: ; 38ccb
; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused.
ld a, [wEnemyMonStatus]
- and $20
+ and 1 << FRZ
ret z
dec [hl]
dec [hl]
@@ -1847,7 +1847,7 @@ AI_Smart_MeanLook: ; 38dfb
; 80% chance to greatly encourage this move if the player is either
; in love, identified, stuck in Rollout, or has a Nightmare.
ld a, [wPlayerSubStatus1]
- and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
+ and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38e26
; Otherwise, discourage this move unless the player only has not very effective moves against the enemy.
diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm
index fad5b27a0..2723bba6b 100644
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -64,7 +64,7 @@ DoMove: ; 3402c
inc hl
ld [de], a
inc de
- cp -1
+ cp endmove_command
jr nz, .GetMoveEffect
; Start at the first command.
@@ -364,7 +364,7 @@ CantMove: ; 341f0
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr
ld a, [hl]
- and $ff ^ (1<<SUBSTATUS_BIDE + 1<<SUBSTATUS_RAMPAGE + 1<<SUBSTATUS_CHARGED)
+ and $ff ^ (1 << SUBSTATUS_BIDE | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_CHARGED)
ld [hl], a
call ResetFuryCutterCount
diff --git a/engine/events/pokecenter_pc.asm b/engine/events/pokecenter_pc.asm
index 42284aeab..6e33d376c 100644
--- a/engine/events/pokecenter_pc.asm
+++ b/engine/events/pokecenter_pc.asm
@@ -39,12 +39,19 @@ PokemonCenterPC: ; 1559a
dw PlaceNthMenuStrings
dw .JumpTable
+PCPC_PLAYERS_PC EQU 0
+PCPC_BILLS_PC EQU 1
+PCPC_OAKS_PC EQU 2
+PCPC_HALL_OF_FAME EQU 3
+PCPC_TURN_OFF EQU 4
+
.JumpTable:
- dw PlayersPC, .String_PlayersPC
- dw BillsPC, .String_BillsPC
- dw OaksPC, .String_OaksPC
+; entries correspond to PCPC_* constants
+ dw PlayersPC, .String_PlayersPC
+ dw BillsPC, .String_BillsPC
+ dw OaksPC, .String_OaksPC
dw HallOfFamePC, .String_HallOfFame
- dw TurnOffPC, .String_TurnOff
+ dw TurnOffPC, .String_TurnOff
.String_PlayersPC: db "<PLAYER>'s PC@"
.String_BillsPC: db "BILL's PC@"
@@ -53,33 +60,42 @@ PokemonCenterPC: ; 1559a
.String_TurnOff: db "TURN OFF@"
.WhichPC:
- ; before pokedex
- db 3 ; items
- db 1, 0, 4 ; bill's, player's, turn off
- db -1
+ ; before Pokédex
+ db 3
+ db PCPC_BILLS_PC
+ db PCPC_PLAYERS_PC
+ db PCPC_TURN_OFF
+ db -1 ; end
; before Hall Of Fame
- db 4 ; items
- db 1, 0, 2, 4 ; bill's, player's, oak's, turn off
- db -1
+ db 4
+ db PCPC_BILLS_PC
+ db PCPC_PLAYERS_PC
+ db PCPC_OAKS_PC
+ db PCPC_TURN_OFF
+ db -1 ; end
; postgame
- db 5 ; items
- db 1, 0, 2, 3, 4 ; bill's, player's, oak's, hall of fame, turn off
- db -1
+ db 5
+ db PCPC_BILLS_PC
+ db PCPC_PLAYERS_PC
+ db PCPC_OAKS_PC
+ db PCPC_HALL_OF_FAME
+ db PCPC_TURN_OFF
+ db -1 ; end
.ChooseWhichPCListToUse:
call CheckReceivedDex
jr nz, .got_dex
- ld a, $0
+ ld a, 0 ; before Pokédex
ret
.got_dex
ld a, [wHallOfFameCount]
and a
- ld a, $1
+ ld a, 1 ; before Hall Of Fame
ret z
- ld a, $2
+ ld a, 2 ; postgame
ret
; 15650
@@ -244,7 +260,16 @@ PlayersPCMenuData: ; 0x15736
dw PlaceNthMenuStrings
dw .PlayersPCMenuPointers
+PLAYERSPC_WITHDRAW_ITEM EQU 0
+PLAYERSPC_DEPOSIT_ITEM EQU 1
+PLAYERSPC_TOSS_ITEM EQU 2
+PLAYERSPC_MAIL_BOX EQU 3
+PLAYERSPC_DECORATION EQU 4
+PLAYERSPC_TURN_OFF EQU 5
+PLAYERSPC_LOG_OFF EQU 6
+
.PlayersPCMenuPointers: ; 0x15746
+; entries correspond to PLAYERSPC_* constants
dw PlayerWithdrawItemMenu, .WithdrawItem
dw PlayerDepositItemMenu, .DepositItem
dw PlayerTossItemMenu, .TossItem
@@ -261,32 +286,24 @@ PlayersPCMenuData: ; 0x15736
.TurnOff: db "TURN OFF@"
.LogOff: db "LOG OFF@"
-WITHDRAW_ITEM EQU 0
-DEPOSIT_ITEM EQU 1
-TOSS_ITEM EQU 2
-MAIL_BOX EQU 3
-DECORATION EQU 4
-TURN_OFF EQU 5
-LOG_OFF EQU 6
-
.PlayersPCMenuList1:
db 5
- db WITHDRAW_ITEM
- db DEPOSIT_ITEM
- db TOSS_ITEM
- db MAIL_BOX
- db TURN_OFF
- db -1
+ db PLAYERSPC_WITHDRAW_ITEM
+ db PLAYERSPC_DEPOSIT_ITEM
+ db PLAYERSPC_TOSS_ITEM
+ db PLAYERSPC_MAIL_BOX
+ db PLAYERSPC_TURN_OFF
+ db -1 ; end
.PlayersPCMenuList2:
db 6
- db WITHDRAW_ITEM
- db DEPOSIT_ITEM
- db TOSS_ITEM
- db MAIL_BOX
- db DECORATION
- db LOG_OFF
- db -1
+ db PLAYERSPC_WITHDRAW_ITEM
+ db PLAYERSPC_DEPOSIT_ITEM
+ db PLAYERSPC_TOSS_ITEM
+ db PLAYERSPC_MAIL_BOX
+ db PLAYERSPC_DECORATION
+ db PLAYERSPC_LOG_OFF
+ db -1 ; end
PC_DisplayTextWaitMenu: ; 157bb
ld a, [wOptions]
@@ -461,13 +478,14 @@ PlayerDepositItemMenu: ; 0x1588b
ret
.dw
- dw .tossable
+; entries correspond to ITEMMENU_* constants
+ dw .tossable ; ITEMMENU_NOUSE
dw .no_toss
dw .no_toss
dw .no_toss
- dw .tossable
- dw .tossable
- dw .tossable
+ dw .tossable ; ITEMMENU_CURRENT
+ dw .tossable ; ITEMMENU_PARTY
+ dw .tossable ; ITEMMENU_CLOSE
.no_toss
ret
diff --git a/engine/events/specials.asm b/engine/events/specials.asm
index acfc3c450..533f59520 100644
--- a/engine/events/specials.asm
+++ b/engine/events/specials.asm
@@ -95,13 +95,13 @@ NameRival: ; 0xc29d
farcall _NamingScreen
; default to "SILVER"
ld hl, wRivalName
- ld de, DefaultRivalName
+ ld de, .default
call InitName
ret
-; 0xc2b2
-DefaultRivalName: ; 0xc2b2
+.default
db "SILVER@"
+; 0xc2b9
NameRater: ; c2b9
farcall _NameRater
diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm
index b36dceeb6..6ab676cda 100644
--- a/engine/gfx/cgb_layouts.asm
+++ b/engine/gfx/cgb_layouts.asm
@@ -48,7 +48,7 @@ LoadSGBLayoutCGB: ; 8d59
dw _CGB_GSTitleScreen
dw _CGB0d
dw _CGB_MoveList
- dw _CGB0f
+ dw _CGB_BetaPikachuMinigame
dw _CGB_PokedexSearchOption
dw _CGB11
dw _CGB_Pokepic
@@ -532,7 +532,7 @@ _CGB_GSIntro: ; 9122
; 9195
_CGB11: ; 9195
- ld hl, Palettes_SCGB_11
+ ld hl, BetaPokerPals
ld de, wBGPals1
ld bc, 5 palettes
ld a, BANK(wBGPals1)
@@ -790,8 +790,8 @@ _CGB_MoveList: ; 9373
ret
; 93a6
-_CGB0f: ; 93a6
- ld hl, PalPacket_SCGB_0F + 1
+_CGB_BetaPikachuMinigame: ; 93a6
+ ld hl, PalPacket_BetaPikachuMinigame + 1
call CopyFourPalettes
call WipeAttrMap
call ApplyAttrMap
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index 6cf896ff4..d9b9b1dbc 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -43,37 +43,36 @@ CheckShininess:
and a
ret
-Unused_CheckContestMon:
-; Check a mon's DVs at hl in the bug catching contest.
-; Return carry if its DVs are good enough to place in the contest.
+Unused_CheckShininess:
+; Return carry if the DVs at hl are all 10 or higher.
; Attack
ld a, [hl]
cp 10 << 4
- jr c, .Bad
+ jr c, .NotShiny
; Defense
ld a, [hli]
and $f
cp 10
- jr c, .Bad
+ jr c, .NotShiny
; Speed
ld a, [hl]
cp 10 << 4
- jr c, .Bad
+ jr c, .NotShiny
; Special
ld a, [hl]
and $f
cp 10
- jr c, .Bad
+ jr c, .NotShiny
-.Good:
+.Shiny:
scf
ret
-.Bad:
+.NotShiny:
and a
ret
@@ -182,12 +181,12 @@ Unreferenced_Function8b4d:
ld a, [hSGB]
and a
ret z
- ld hl, PalPacket_Function8b4d
+ ld hl, PalPacket_BetaIntroVenusaur
jp PushSGBPals_
.cgb
ld de, wOBPals1
- ld a, PREDEFPAL_3B
+ ld a, PREDEFPAL_BETA_INTRO_VENUSAUR
call GetPredefPal
jp LoadHLPaletteIntoDE
@@ -1349,8 +1348,8 @@ INCLUDE "gfx/pokegear/pokegear.pal"
FemalePokegearPals:
INCLUDE "gfx/pokegear/pokegear_f.pal"
-Palettes_SCGB_11:
-INCLUDE "gfx/unknown/b789.pal"
+BetaPokerPals:
+INCLUDE "gfx/beta_poker/beta_poker.pal"
SlotMachinePals:
INCLUDE "gfx/slots/slots.pal"
diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm
index b533ee56b..9c909a5cd 100644
--- a/engine/gfx/load_pics.asm
+++ b/engine/gfx/load_pics.asm
@@ -252,7 +252,7 @@ GLOBAL PICS_FIX
push hl
push bc
- sub BANK(Pics_1) - PICS_FIX
+ sub BANK("Pics 1") - PICS_FIX
ld c, a
ld b, 0
ld hl, .PicsBanks
@@ -263,30 +263,30 @@ GLOBAL PICS_FIX
ret
.PicsBanks: ; 511d4
- db BANK(Pics_1) + 0
- db BANK(Pics_1) + 1
- db BANK(Pics_1) + 2
- db BANK(Pics_1) + 3
- db BANK(Pics_1) + 4
- db BANK(Pics_1) + 5
- db BANK(Pics_1) + 6
- db BANK(Pics_1) + 7
- db BANK(Pics_1) + 8
- db BANK(Pics_1) + 9
- db BANK(Pics_1) + 10
- db BANK(Pics_1) + 11
- db BANK(Pics_1) + 12
- db BANK(Pics_1) + 13
- db BANK(Pics_1) + 14
- db BANK(Pics_1) + 15
- db BANK(Pics_1) + 16
- db BANK(Pics_1) + 17
- db BANK(Pics_1) + 18
- db BANK(Pics_1) + 19
- db BANK(Pics_1) + 20
- db BANK(Pics_1) + 21
- db BANK(Pics_1) + 22
- db BANK(Pics_1) + 23
+ db BANK("Pics 1") ; BANK("Pics 1") + 0
+ db BANK("Pics 2") ; BANK("Pics 1") + 1
+ db BANK("Pics 3") ; BANK("Pics 1") + 2
+ db BANK("Pics 4") ; BANK("Pics 1") + 3
+ db BANK("Pics 5") ; BANK("Pics 1") + 4
+ db BANK("Pics 6") ; BANK("Pics 1") + 5
+ db BANK("Pics 7") ; BANK("Pics 1") + 6
+ db BANK("Pics 8") ; BANK("Pics 1") + 7
+ db BANK("Pics 9") ; BANK("Pics 1") + 8
+ db BANK("Pics 10") ; BANK("Pics 1") + 9
+ db BANK("Pics 11") ; BANK("Pics 1") + 10
+ db BANK("Pics 12") ; BANK("Pics 1") + 11
+ db BANK("Pics 13") ; BANK("Pics 1") + 12
+ db BANK("Pics 14") ; BANK("Pics 1") + 13
+ db BANK("Pics 15") ; BANK("Pics 1") + 14
+ db BANK("Pics 16") ; BANK("Pics 1") + 15
+ db BANK("Pics 17") ; BANK("Pics 1") + 16
+ db BANK("Pics 18") ; BANK("Pics 1") + 17
+ db BANK("Pics 19") ; BANK("Pics 1") + 18
+ db BANK("Pics 20") ; BANK("Pics 1") + 19
+ db BANK("Pics 21") ; BANK("Pics 1") + 20
+ db BANK("Pics 22") ; BANK("Pics 1") + 21
+ db BANK("Pics 23") ; BANK("Pics 1") + 22
+ db BANK("Pics 24") ; BANK("Pics 1") + 23
Function511ec: ; 511ec
ld a, c
diff --git a/engine/gfx/pic_animation.asm b/engine/gfx/pic_animation.asm
index 54999a6bb..925296388 100644
--- a/engine/gfx/pic_animation.asm
+++ b/engine/gfx/pic_animation.asm
@@ -399,11 +399,11 @@ PokeAnim_DoAnimScript: ; d0250
.RunAnim: ; d0261
call PokeAnim_GetPointer
ld a, [wPokeAnimCommand]
- cp -1
+ cp endanim_command
jr z, PokeAnim_End
- cp -2
+ cp setrepeat_command
jr z, .SetRepeat
- cp -3
+ cp dorepeat_command
jr z, .DoRepeat
call PokeAnim_GetFrame
ld a, [wPokeAnimParameter]
diff --git a/engine/gfx/sgb_layouts.asm b/engine/gfx/sgb_layouts.asm
index 24bdc952e..d53be908f 100644
--- a/engine/gfx/sgb_layouts.asm
+++ b/engine/gfx/sgb_layouts.asm
@@ -38,9 +38,9 @@ LoadSGBLayout: ; 864c
dw .SGB_GSTitleScreen
dw .SGB0d
dw .SGB_MoveList
- dw .SGB0f
+ dw .SGB_BetaPikachuMinigame
dw .SGB_PokedexSearchOption
- dw .SGB11
+ dw .SGB_BetaPoker
dw .SGB12
dw .SGB13
dw .SGB_PackPals
@@ -346,18 +346,18 @@ endr
ret
; 8897
-.SGB0f: ; 8897
- ld hl, PalPacket_SCGB_0F
+.SGB_BetaPikachuMinigame: ; 8897
+ ld hl, PalPacket_BetaPikachuMinigame
ld de, BlkPacket_9a86
ret
; 889e
-.SGB11: ; 889e
+.SGB_BetaPoker: ; 889e
ld hl, BlkPacket_9a86
ld de, wPlayerLightScreenCount ; ???
ld bc, PALPACKET_LENGTH
call CopyBytes
- ld hl, PalPacket_SCGB_11
+ ld hl, PalPacket_BetaPoker
ld de, BlkPacket_9a86
ret
; 88b1
diff --git a/engine/items/pack.asm b/engine/items/pack.asm
index ea3a051ac..9f0e82f66 100644
--- a/engine/items/pack.asm
+++ b/engine/items/pack.asm
@@ -571,11 +571,11 @@ RegisterItem: ; 103c2
ld a, [wCurrPocket]
rrca
rrca
- and $c0
+ and REGISTERED_POCKET
ld b, a
ld a, [wCurItemQuantity]
inc a
- and $3f
+ and REGISTERED_NUMBER
or b
ld [wWhichRegisteredItem], a
ld a, [wCurItem]
@@ -1283,7 +1283,7 @@ DrawPackGFX: ; 1089d
ld a, [wCurrPocket]
maskbits NUM_POCKETS
ld e, a
- ld d, $0
+ ld d, 0
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
jr z, .male_dude
diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm
index c82cd80a2..8c897d25a 100644
--- a/engine/overworld/map_object_action.asm
+++ b/engine/overworld/map_object_action.asm
@@ -47,7 +47,7 @@ SetFacingStandAction: ; 44b5
SetFacingStepAction: ; 44c1
ld hl, OBJECT_FLAGS1
add hl, bc
- bit SLIDING, [hl]
+ bit SLIDING_F, [hl]
jp nz, SetFacingCurrent
ld hl, OBJECT_STEP_FRAME
@@ -59,7 +59,7 @@ SetFacingStepAction: ; 44c1
rrca
rrca
- and %00000011
+ maskbits NUM_DIRECTIONS
ld d, a
call GetSpriteDirection
@@ -74,7 +74,7 @@ SetFacingStepAction: ; 44c1
SetFacingSkyfall: ; 44e4
ld hl, OBJECT_FLAGS1
add hl, bc
- bit SLIDING, [hl]
+ bit SLIDING_F, [hl]
jp nz, SetFacingCurrent
ld hl, OBJECT_STEP_FRAME
@@ -86,7 +86,7 @@ SetFacingSkyfall: ; 44e4
rrca
rrca
- and %00000011
+ maskbits NUM_DIRECTIONS
ld d, a
call GetSpriteDirection
@@ -101,7 +101,7 @@ SetFacingSkyfall: ; 44e4
SetFacingBumpAction: ; 4508
ld hl, OBJECT_FLAGS1
add hl, bc
- bit SLIDING, [hl]
+ bit SLIDING_F, [hl]
jp nz, SetFacingCurrent
ld hl, OBJECT_STEP_FRAME
@@ -112,7 +112,7 @@ SetFacingBumpAction: ; 4508
rrca
rrca
rrca
- and %00000011
+ maskbits NUM_DIRECTIONS
ld d, a
call GetSpriteDirection
@@ -245,7 +245,7 @@ SetFacingWeirdTree: ; 45ab
ld a, [hl]
inc a
ld [hl], a
- and %00001100
+ maskbits NUM_DIRECTIONS, 2
rrca
rrca
add FACING_WEIRD_TREE_0
diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm
index 1573a27b5..7ed1d5f5f 100644
--- a/engine/overworld/map_objects.asm
+++ b/engine/overworld/map_objects.asm
@@ -93,7 +93,7 @@ Function437b: ; 437b
.ok2
ld hl, OBJECT_FLAGS1
add hl, bc
- bit 1, [hl]
+ bit WONT_DELETE_F, [hl]
jr nz, .yes2
call DeleteMapObject
scf
@@ -146,7 +146,7 @@ Function437b: ; 437b
.HandleObjectAction:
ld hl, OBJECT_FLAGS1
add hl, bc
- bit INVISIBLE, [hl]
+ bit INVISIBLE_F, [hl]
jr nz, SetFacingStanding
ld hl, OBJECT_FLAGS2
add hl, bc
@@ -161,7 +161,7 @@ Function437b: ; 437b
Function4440: ; 4440
ld hl, OBJECT_FLAGS1
add hl, bc
- bit INVISIBLE, [hl]
+ bit INVISIBLE_F, [hl]
jr nz, SetFacingStanding
asm_4448:
ld de, ObjectActionPairPointers + 2 ; use second column
@@ -233,7 +233,7 @@ Function462a: ; 462a
UpdateTallGrassFlags: ; 463f
ld hl, OBJECT_FLAGS2
add hl, bc
- bit OVERHEAD, [hl]
+ bit OVERHEAD_F, [hl]
jr z, .ok
ld hl, OBJECT_NEXT_TILE
add hl, bc
@@ -260,13 +260,13 @@ SetTallGrassFlags: ; 4661
.set
ld hl, OBJECT_FLAGS2
add hl, bc
- set OVERHEAD, [hl]
+ set OVERHEAD_F, [hl]
ret
.reset
ld hl, OBJECT_FLAGS2
add hl, bc
- res OVERHEAD, [hl]
+ res OVERHEAD_F, [hl]
ret
; 4679
@@ -298,7 +298,7 @@ InitStep: ; 4690
ld [hl], a
ld hl, OBJECT_FLAGS1
add hl, bc
- bit FIXED_FACING, [hl]
+ bit FIXED_FACING_F, [hl]
jr nz, GetNextTile
add a
add a
@@ -696,7 +696,7 @@ MapObjectMovementPattern: ; 47dd
and %00000011
or 0
call InitStep
- call Function6ec1
+ call CanObjectMoveInDirection
jr c, .ok2
ld de, SFX_STRENGTH
call PlaySFX
@@ -1049,7 +1049,7 @@ MapObjectMovementPattern: ; 47dd
.RandomWalkContinue:
call InitStep
- call Function6ec1 ; check whether the object can move in that direction
+ call CanObjectMoveInDirection ; check whether the object can move in that direction
jr c, .NewDuration
call UpdateTallGrassFlags
ld hl, OBJECT_ACTION
@@ -2116,13 +2116,13 @@ SpawnEmote: ; 5547
ShakeGrass: ; 5556
push bc
- ld de, .data_5562
+ ld de, .GrassObject
call CopyTempObjectData
call InitTempObject
pop bc
ret
-.data_5562
+.GrassObject
db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS
; 5565
@@ -2140,6 +2140,7 @@ ShakeScreen: ; 5565
.ScreenShakeObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SCREENSHAKE
; 5579
+
DespawnEmote: ; 5579
push bc
ld a, [hMapObjectIndexBuffer]
@@ -2155,7 +2156,7 @@ DespawnEmote: ; 5579
push af
ld hl, OBJECT_FLAGS1
add hl, de
- bit EMOTE_OBJECT, [hl]
+ bit EMOTE_OBJECT_F, [hl]
jr z, .next
ld hl, OBJECT_SPRITE
add hl, de
@@ -2444,7 +2445,7 @@ Function56cd: ; 56cd
ld [hUsedSpriteTile], a
ld hl, OBJECT_PALETTE
add hl, bc
- bit 7, [hl]
+ bit BIG_OBJECT_F, [hl]
jr z, .ok7
ld a, d
add 2
@@ -2574,7 +2575,7 @@ ContinueSpawnFacing: ; 57db
_SetPlayerPalette: ; 57e2
ld a, d
- and %10000000
+ and 1 << 7
ret z
ld bc, 0 ; debug?
ld hl, OBJECT_FACING
@@ -2584,13 +2585,13 @@ _SetPlayerPalette: ; 57e2
ld [hl], a
ld a, d
swap a
- and %00000111
+ and PALETTE_MASK
ld d, a
ld bc, wPlayerStruct
ld hl, OBJECT_PALETTE
add hl, bc
ld a, [hl]
- and %11111000
+ and $ff ^ PALETTE_MASK
or d
ld [hl], a
ret
@@ -2918,10 +2919,10 @@ InitSprites: ; 5991
ld e, PRIORITY_LOW
ld hl, OBJECT_FLAGS2
add hl, bc
- bit LOW_PRIORITY, [hl]
+ bit LOW_PRIORITY_F, [hl]
jr nz, .add
ld e, PRIORITY_NORM
- bit HIGH_PRIORITY, [hl]
+ bit HIGH_PRIORITY_F, [hl]
jr z, .add
ld e, PRIORITY_HIGH
jr .add
@@ -2973,35 +2974,35 @@ InitSprites: ; 5991
ld hl, OBJECT_SPRITE_TILE
add hl, bc
ld a, [hl]
- and %01111111
+ and $ff ^ (1 << 7)
ld [hFFC1], a
xor a
bit 7, [hl]
jr nz, .skip1
- or %00001000
+ or VRAM_BANK_1
.skip1
ld hl, OBJECT_FLAGS2
add hl, bc
ld e, [hl]
bit 7, e
jr z, .skip2
- or %10000000
+ or PRIORITY
.skip2
- bit 4, e
+ bit USE_OBP1_F, e
jr z, .skip3
- or %00010000
+ or OBP_NUM
.skip3
ld hl, OBJECT_PALETTE
add hl, bc
ld d, a
ld a, [hl]
- and %00000111
+ and PALETTE_MASK
or d
ld d, a
xor a
- bit 3, e
+ bit OVERHEAD_F, e
jr z, .skip4
- or %10000000
+ or PRIORITY
.skip4
ld [hFFC2], a
ld hl, OBJECT_SPRITE_X
@@ -3063,7 +3064,7 @@ InitSprites: ; 5991
ld e, [hl]
inc hl
ld a, [hFFC1]
- bit 2, e
+ bit ABSOLUTE_TILE_ID_F, e
jr z, .nope1
xor a
.nope1
@@ -3072,7 +3073,7 @@ InitSprites: ; 5991
ld [bc], a ; tile id
inc c
ld a, e
- bit 1, a
+ bit RELATIVE_ATTRIBUTES_F, a
jr z, .nope2
ld a, [hFFC2]
or e
diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm
index 3dbb0b83a..fcb8d55fb 100644
--- a/engine/overworld/movement.asm
+++ b/engine/overworld/movement.asm
@@ -377,42 +377,42 @@ Movement_tree_shake: ; 5279
Movement_remove_sliding: ; 5293
ld hl, OBJECT_FLAGS1
add hl, bc
- res SLIDING, [hl]
+ res SLIDING_F, [hl]
jp ContinueReadingMovement
; 529c
Movement_set_sliding: ; 529c
ld hl, OBJECT_FLAGS1
add hl, bc
- set SLIDING, [hl]
+ set SLIDING_F, [hl]
jp ContinueReadingMovement
; 52a5
Movement_remove_fixed_facing: ; 52a5
ld hl, OBJECT_FLAGS1
add hl, bc
- res FIXED_FACING, [hl]
+ res FIXED_FACING_F, [hl]
jp ContinueReadingMovement
; 52ae
Movement_fix_facing: ; 52ae
ld hl, OBJECT_FLAGS1
add hl, bc
- set FIXED_FACING, [hl]
+ set FIXED_FACING_F, [hl]
jp ContinueReadingMovement
; 52b7
Movement_show_object: ; 52b7
ld hl, OBJECT_FLAGS1
add hl, bc
- res INVISIBLE, [hl]
+ res INVISIBLE_F, [hl]
jp ContinueReadingMovement
; 52c0
Movement_hide_object: ; 52c0
ld hl, OBJECT_FLAGS1
add hl, bc
- set INVISIBLE, [hl]
+ set INVISIBLE_F, [hl]
jp ContinueReadingMovement
; 52c9
@@ -838,7 +838,7 @@ JumpStep: ; 548a
ld hl, OBJECT_FLAGS2
add hl, bc
- res OVERHEAD, [hl]
+ res OVERHEAD_F, [hl]
ld hl, OBJECT_ACTION
add hl, bc
diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm
index 5670935e8..40ced1a5f 100644
--- a/engine/overworld/npc_movement.asm
+++ b/engine/overworld/npc_movement.asm
@@ -1,37 +1,38 @@
-Function6ec1: ; 6ec1
+CanObjectMoveInDirection: ; 6ec1
ld hl, OBJECT_PALETTE
add hl, bc
- bit 5, [hl]
- jr z, .not_bit_5
+ bit SWIMMING_F, [hl]
+ jr z, .not_swimming
ld hl, OBJECT_FLAGS1
add hl, bc
- bit 4, [hl] ; lost, uncomment next line to fix
-; jr nz, .resume
+ bit NOCLIP_TILES_F, [hl] ; lost, uncomment next line to fix
+ ; jr nz, .noclip_tiles
push hl
push bc
- call Function6f2c
+ call WillObjectBumpIntoLand
pop bc
pop hl
ret c
- jr .resume
+ jr .continue
-.not_bit_5
+.not_swimming
ld hl, OBJECT_FLAGS1
add hl, bc
- bit 4, [hl]
- jr nz, .resume
+ bit NOCLIP_TILES_F, [hl]
+ jr nz, .noclip_tiles
push hl
push bc
- call Function6f07
+ call WillObjectBumpIntoWater
pop bc
pop hl
ret c
-.resume
- bit 6, [hl]
- jr nz, .bit_6
+.noclip_tiles
+.continue
+ bit NOCLIP_OBJS_F, [hl]
+ jr nz, .noclip_objs
push hl
push bc
@@ -40,9 +41,9 @@ Function6ec1: ; 6ec1
pop hl
ret c
-.bit_6
- bit 5, [hl]
- jr nz, .bit_5
+.noclip_objs
+ bit MOVE_ANYWHERE_F, [hl]
+ jr nz, .move_anywhere
push hl
call HasObjectReachedMovementLimit
pop hl
@@ -53,13 +54,13 @@ Function6ec1: ; 6ec1
pop hl
ret c
-.bit_5
+.move_anywhere
and a
ret
; 6f07
-Function6f07: ; 6f07
+WillObjectBumpIntoWater: ; 6f07
call Function6f5f
ret c
ld hl, OBJECT_NEXT_MAP_X
@@ -78,12 +79,12 @@ Function6f07: ; 6f07
ld d, a
call GetTileCollision
and a ; LANDTILE
- jr z, Function6f3e
+ jr z, WillObjectBumpIntoTile
scf
ret
; 6f2c
-Function6f2c: ; 6f2c
+WillObjectBumpIntoLand: ; 6f2c
call Function6f5f
ret c
ld hl, OBJECT_NEXT_TILE
@@ -91,12 +92,12 @@ Function6f2c: ; 6f2c
ld a, [hl]
call GetTileCollision
cp WATERTILE
- jr z, Function6f3e
+ jr z, WillObjectBumpIntoTile
scf
ret
; 6f3e
-Function6f3e: ; 6f3e
+WillObjectBumpIntoTile: ; 6f3e
ld hl, OBJECT_NEXT_TILE
add hl, bc
ld a, [hl]
@@ -331,7 +332,7 @@ IsNPCAtCoord: ; 7041
ld hl, OBJECT_PALETTE
add hl, bc
- bit 7, [hl]
+ bit BIG_OBJECT_F, [hl]
jr z, .got
call Function7171
diff --git a/engine/overworld/player_movement.asm b/engine/overworld/player_movement.asm
index ef9afc7ad..f8bbe4952 100644
--- a/engine/overworld/player_movement.asm
+++ b/engine/overworld/player_movement.asm
@@ -684,7 +684,7 @@ DoPlayerMovement:: ; 80000
ld hl, OBJECT_PALETTE
add hl, bc
- bit 6, [hl]
+ bit STRENGTH_BOULDER_F, [hl]
jr z, .not_boulder
ld hl, OBJECT_FLAGS2
@@ -696,7 +696,7 @@ DoPlayerMovement:: ; 80000
ld hl, OBJECT_RANGE
add hl, bc
ld a, [hl]
- and $fc
+ and %11111100
or d
ld [hl], a
diff --git a/engine/overworld/scripting.asm b/engine/overworld/scripting.asm
index a18be2e6c..a2315a541 100644
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -1071,7 +1071,7 @@ ApplyObjectFacing:
jr c, .not_visible ; STILL_SPRITE
ld hl, OBJECT_FLAGS1
add hl, bc
- bit FIXED_FACING, [hl]
+ bit FIXED_FACING_F, [hl]
jr nz, .not_visible
pop de
ld a, e
diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm
index 1e808c02c..e25381e29 100644
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -96,9 +96,9 @@ _BillsPC: ; e3fd
dw BillsPC_SeeYa
.items ; e4c4
- db 5
+ db 5 ; # items
db 0 ; WITHDRAW
- db 1; DEPOSIT
+ db 1 ; DEPOSIT
db 2 ; CHANGE BOX
db 3 ; MOVE PKMN
db 4 ; SEE YA!
diff --git a/engine/pokemon/move_mon.asm b/engine/pokemon/move_mon.asm
index 630479797..2074e537f 100644
--- a/engine/pokemon/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
@@ -1497,29 +1497,29 @@ CalcMonStatC: ; e17b
jr z, .Special
cp STAT_SDEF
jr z, .Special
-; DV_HP = (DV_ATK & 1) << 3 + (DV_DEF & 1) << 2 + (DV_SPD & 1) << 1 + (DV_SPC & 1)
+; DV_HP = (DV_ATK & 1) << 3 | (DV_DEF & 1) << 2 | (DV_SPD & 1) << 1 | (DV_SPC & 1)
push bc
ld a, [hl]
swap a
- and $1
+ and 1
add a
add a
add a
ld b, a
ld a, [hli]
- and $1
+ and 1
add a
add a
add b
ld b, a
ld a, [hl]
swap a
- and $1
+ and 1
add a
add b
ld b, a
ld a, [hl]
- and $1
+ and 1
add b
pop bc
jr .GotDV
diff --git a/gfx/unknown/b789.pal b/gfx/beta_poker/beta_poker.pal
index cce760662..cce760662 100644
--- a/gfx/unknown/b789.pal
+++ b/gfx/beta_poker/beta_poker.pal
diff --git a/gfx/pack/pack_menu.png b/gfx/pack/pack_menu.png
index 52e2bcdd5..aa693cc40 100644
--- a/gfx/pack/pack_menu.png
+++ b/gfx/pack/pack_menu.png
Binary files differ
diff --git a/gfx/pics.asm b/gfx/pics.asm
index 198569a76..043e41489 100644
--- a/gfx/pics.asm
+++ b/gfx/pics.asm
@@ -20,7 +20,6 @@ INCLUDE "data/trainers/pic_pointers.asm"
SECTION "Pics 1", ROMX
-Pics_1::
HoOhFrontpic: INCBIN "gfx/pokemon/ho_oh/front.animated.2bpp.lz"
MachampFrontpic: INCBIN "gfx/pokemon/machamp/front.animated.2bpp.lz"
@@ -794,3 +793,21 @@ INCBIN "gfx/pokemon/unown_y/back.2bpp.lz"
INCBIN "gfx/pokemon/unown_p/back.2bpp.lz"
INCBIN "gfx/pokemon/unown_i/back.2bpp.lz"
INCBIN "gfx/pokemon/unown_r/back.2bpp.lz"
+
+
+; Sections "Pics 20" to "Pics 24" are not used for any graphics,
+; but entries for their banks exist in FixPicBank (see engine/gfx/load_pics.asm).
+
+SECTION "Pics 20", ROMX
+
+
+SECTION "Pics 21", ROMX
+
+
+SECTION "Pics 22", ROMX
+
+
+SECTION "Pics 23", ROMX
+
+
+SECTION "Pics 24", ROMX
diff --git a/gfx/sgb/pal_packets.asm b/gfx/sgb/pal_packets.asm
index fa3b386da..0a392fb22 100644
--- a/gfx/sgb/pal_packets.asm
+++ b/gfx/sgb/pal_packets.asm
@@ -21,10 +21,10 @@ PalPacket_GSTitleScreen:
sgb_pal_set GS_TITLE_SCREEN_0, GS_TITLE_SCREEN_1, GS_TITLE_SCREEN_2, GS_TITLE_SCREEN_3
PalPacket_SCGB_13:
- sgb_pal_set GREENMON_NITE, CGB_BADGE, RB_BROWNMON, 00
+ sgb_pal_set BETA_SHINY_GREENMON, CGB_BADGE, RB_BROWNMON, 00
-PalPacket_SCGB_11:
- sgb_pal_set SCGB_11_0, SCGB_11_1, SCGB_11_2, SCGB_11_3
+PalPacket_BetaPoker:
+ sgb_pal_set BETA_POKER_0, BETA_POKER_1, BETA_POKER_2, BETA_POKER_3
PalPacket_UnownPuzzle:
sgb_pal_set UNOWN_PUZZLE, UNOWN_PUZZLE, UNOWN_PUZZLE, UNOWN_PUZZLE
@@ -35,8 +35,8 @@ PalPacket_9bd6:
PalPacket_GSIntroShellderLapras:
sgb_pal_set GS_INTRO_SHELLDER_LAPRAS, 00, 00, 00
-UnreferencedPalPacket_9bf6:
- sgb_pal_set 37, 00, 00, 00
+UnreferencedPalPacket_BetaIntroLapras:
+ sgb_pal_set BETA_INTRO_LAPRAS, 00, 00, 00
PalPacket_GSIntroJigglypuffPikachu:
sgb_pal_set GS_INTRO_JIGGLYPUFF_PIKACHU_BG, GS_INTRO_JIGGLYPUFF_PIKACHU_OB, 00, 00
@@ -44,13 +44,13 @@ PalPacket_GSIntroJigglypuffPikachu:
PalPacket_GSIntroStartersTransition:
sgb_pal_set GS_INTRO_STARTERS_TRANSITION, 00, 00, 00
-PalPacket_Function8b4d:
- sgb_pal_set 3B, 00, 00, 00
+PalPacket_BetaIntroVenusaur:
+ sgb_pal_set BETA_INTRO_VENUSAUR, 00, 00, 00
PalPacket_Pack:
sgb_pal_set PACK, 00, 00, 00
-PalPacket_SCGB_0F:
+PalPacket_BetaPikachuMinigame:
sgb_pal_set GS_INTRO_JIGGLYPUFF_PIKACHU_OB, 00, 00, 00
PalPacket_PartyMenu:
@@ -69,7 +69,7 @@ PalPacket_SlotMachine:
sgb_pal_set SLOT_MACHINE_0, SLOT_MACHINE_1, SLOT_MACHINE_2, SLOT_MACHINE_3
PalPacket_SCGB_06:
- sgb_pal_set 33, 34, DIPLOMA, RB_PURPLEMON
+ sgb_pal_set BETA_LOGO_1, BETA_LOGO_2, DIPLOMA, RB_PURPLEMON
PalPacket_Diploma:
sgb_pal_set DIPLOMA, 00, 00, 00
diff --git a/gfx/sgb/predef.pal b/gfx/sgb/predef.pal
index 67d19baec..9c86e2459 100644
--- a/gfx/sgb/predef.pal
+++ b/gfx/sgb/predef.pal
@@ -35,40 +35,40 @@
RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_RB_PINKMON
RGB 31,31,31, 31,28,14, 26,20,00, 00,00,00 ; PREDEFPAL_RB_YELLOWMON
RGB 31,31,31, 26,21,22, 15,15,18, 00,00,00 ; PREDEFPAL_CGB_BADGE
- RGB 31,31,31, 23,19,13, 14,12,17, 00,00,00 ; PREDEFPAL_MEWMON_NITE
- RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_BLUEMON_NITE
- RGB 31,31,31, 22,15,16, 17,02,05, 00,00,00 ; PREDEFPAL_REDMON_NITE
- RGB 31,31,31, 15,20,20, 05,16,16, 00,00,00 ; PREDEFPAL_CYANMON_NITE
- RGB 31,31,31, 23,15,19, 14,04,12, 00,00,00 ; PREDEFPAL_PURPLEMON_NITE
- RGB 31,31,31, 20,17,18, 18,13,11, 00,00,00 ; PREDEFPAL_BROWNMON_NITE
- RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_GREENMON_NITE
- RGB 31,31,31, 21,25,29, 30,22,24, 00,00,00 ; PREDEFPAL_PINKMON_NITE
- RGB 31,31,31, 26,23,16, 29,14,09, 00,00,00 ; PREDEFPAL_YELLOWMON_NITE
+ RGB 31,31,31, 23,19,13, 14,12,17, 00,00,00 ; PREDEFPAL_SHINY_MEWMON
+ RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_SHINY_BLUEMON
+ RGB 31,31,31, 22,15,16, 17,02,05, 00,00,00 ; PREDEFPAL_SHINY_REDMON
+ RGB 31,31,31, 15,20,20, 05,16,16, 00,00,00 ; PREDEFPAL_SHINY_CYANMON
+ RGB 31,31,31, 23,15,19, 14,04,12, 00,00,00 ; PREDEFPAL_SHINY_PURPLEMON
+ RGB 31,31,31, 20,17,18, 18,13,11, 00,00,00 ; PREDEFPAL_SHINY_BROWNMON
+ RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_SHINY_GREENMON
+ RGB 31,31,31, 21,25,29, 30,22,24, 00,00,00 ; PREDEFPAL_SHINY_PINKMON
+ RGB 31,31,31, 26,23,16, 29,14,09, 00,00,00 ; PREDEFPAL_SHINY_YELLOWMON
RGB 31,31,31, 18,18,18, 10,10,10, 00,00,00 ; PREDEFPAL_PARTY_ICON
RGB 31,31,31, 30,26,15, 00,23,00, 00,00,00 ; PREDEFPAL_HP_GREEN
RGB 31,31,31, 30,26,15, 31,23,00, 00,00,00 ; PREDEFPAL_HP_YELLOW
RGB 31,31,31, 30,26,15, 31,00,00, 00,00,00 ; PREDEFPAL_HP_RED
RGB 31,31,31, 29,26,19, 27,20,14, 00,00,00 ; PREDEFPAL_POKEGEAR
- RGB 31,31,31, 24,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_33
- RGB 31,31,31, 31,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_34
+ RGB 31,31,31, 24,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_BETA_LOGO_1
+ RGB 31,31,31, 31,20,10, 21,00,04, 00,00,00 ; PREDEFPAL_BETA_LOGO_2
RGB 31,31,31, 30,26,16, 16,12,09, 00,00,00 ; PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO
RGB 31,31,31, 15,28,26, 12,22,26, 03,16,14 ; PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS
- RGB 31,31,31, 15,28,26, 23,24,24, 00,00,00 ; PREDEFPAL_37
+ RGB 31,31,31, 15,28,26, 23,24,24, 00,00,00 ; PREDEFPAL_BETA_INTRO_LAPRAS
RGB 31,31,24, 07,27,19, 26,20,10, 19,12,08 ; PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG
RGB 31,31,31, 31,28,14, 31,13,31, 00,00,00 ; PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB
RGB 31,31,31, 16,18,21, 10,12,18, 00,00,00 ; PREDEFPAL_GS_INTRO_STARTERS_TRANSITION
- RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_3B
+ RGB 31,31,31, 23,21,16, 12,12,10, 00,00,00 ; PREDEFPAL_BETA_INTRO_VENUSAUR
RGB 31,31,31, 31,14,00, 07,11,15, 00,00,00 ; PREDEFPAL_PACK
RGB 31,31,31, 26,21,22, 26,10,06, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_0
RGB 31,31,31, 30,27,04, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_1
RGB 31,31,31, 31,13,25, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_2
RGB 31,31,31, 16,19,29, 24,20,11, 00,00,00 ; PREDEFPAL_SLOT_MACHINE_3
- RGB 31,31,31, 30,22,24, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_0
- RGB 31,31,31, 21,25,29, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_1
- RGB 31,31,31, 20,26,16, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_2
- RGB 31,31,31, 31,28,14, 18,18,18, 16,10,07 ; PREDEFPAL_SCGB_11_3
- RGB 31,31,31, 18,18,18, 26,10,06, 00,00,00 ; PREDEFPAL_45
- RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_46
+ RGB 31,31,31, 30,22,24, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_0
+ RGB 31,31,31, 21,25,29, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_1
+ RGB 31,31,31, 20,26,16, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_2
+ RGB 31,31,31, 31,28,14, 18,18,18, 16,10,07 ; PREDEFPAL_BETA_POKER_3
+ RGB 31,31,31, 18,18,18, 26,10,06, 00,00,00 ; PREDEFPAL_BETA_RADIO
+ RGB 31,31,31, 30,22,24, 28,15,21, 00,00,00 ; PREDEFPAL_BETA_POKEGEAR
RGB 31,31,31, 26,20,00, 16,19,29, 00,00,00 ; PREDEFPAL_47
RGB 31,31,31, 16,02,30, 15,20,31, 00,00,00 ; PREDEFPAL_GS_TITLE_SCREEN_0
RGB 31,31,31, 16,13,04, 15,20,31, 00,00,00 ; PREDEFPAL_GS_TITLE_SCREEN_1
diff --git a/gfx/tilesets/roofs.pal b/gfx/tilesets/roofs.pal
index 6daf87cb6..652b152c1 100644
--- a/gfx/tilesets/roofs.pal
+++ b/gfx/tilesets/roofs.pal
@@ -1,107 +1,107 @@
; group 0 (unused)
RGB 21,21,21, 11,11,11 ; morn/day
- RGB 21,21,21, 11,11,11; nite
+ RGB 21,21,21, 11,11,11 ; nite
; group 1 (Olivine)
RGB 14,17,31, 07,11,15 ; morn/day
- RGB 09,09,17, 05,07,13; nite
+ RGB 09,09,17, 05,07,13 ; nite
; group 2 (Mahogany)
RGB 12,19,00, 06,10,00 ; morn/day
- RGB 06,09,07, 04,05,06; nite
+ RGB 06,09,07, 04,05,06 ; nite
; group 3 (dungeons)
RGB 21,21,21, 11,11,11 ; morn/day
- RGB 21,21,21, 17,08,07; nite
+ RGB 21,21,21, 17,08,07 ; nite
; group 4 (Ecruteak)
RGB 31,19,00, 27,10,05 ; morn/day
- RGB 15,07,02, 11,04,02; nite
+ RGB 15,07,02, 11,04,02 ; nite
; group 5 (Blackthorn)
RGB 11,10,16, 05,06,07 ; morn/day
- RGB 03,04,08, 00,00,00; nite
+ RGB 03,04,08, 00,00,00 ; nite
; group 6 (Cinnabar)
RGB 31,10,00, 18,06,00 ; morn/day
- RGB 18,05,09, 17,08,07; nite
+ RGB 18,05,09, 17,08,07 ; nite
; group 7 (Cerulean)
RGB 17,27,31, 05,15,31 ; morn/day
- RGB 07,08,22, 07,07,16; nite
+ RGB 07,08,22, 07,07,16 ; nite
; group 8 (Azalea)
RGB 22,20,10, 17,14,03 ; morn/day
- RGB 11,11,05, 10,09,07; nite
+ RGB 11,11,05, 10,09,07 ; nite
; group 9 (Lake of Rage)
RGB 31,08,04, 09,09,08 ; morn/day
- RGB 18,05,09, 09,09,08; nite
+ RGB 18,05,09, 09,09,08 ; nite
; group 10 (Violet)
RGB 24,14,31, 13,07,21 ; morn/day
- RGB 12,03,18, 09,03,15; nite
+ RGB 12,03,18, 09,03,15 ; nite
; group 11 (Goldenrod)
RGB 25,25,00, 20,17,08 ; morn/day
- RGB 12,12,00, 10,09,05; nite
+ RGB 12,12,00, 10,09,05 ; nite
; group 12 (Vermilion)
RGB 27,23,01, 23,11,00 ; morn/day
- RGB 15,11,01, 11,10,01; nite
+ RGB 15,11,01, 11,10,01 ; nite
; group 13 (Pallet)
RGB 27,28,31, 17,19,22 ; morn/day
- RGB 14,14,18, 10,09,13; nite
+ RGB 14,14,18, 10,09,13 ; nite
; group 14 (Pewter)
RGB 19,19,16, 10,12,15 ; morn/day
- RGB 09,09,11, 04,05,07; nite
+ RGB 09,09,11, 04,05,07 ; nite
; group 15 (Mount Moon Square)
RGB 14,17,31, 07,11,15 ; morn/day
- RGB 09,13,19, 07,07,16; nite
+ RGB 09,13,19, 07,07,16 ; nite
; group 16 (Indigo)
RGB 21,21,21, 13,13,13 ; morn/day
- RGB 11,11,19, 07,07,12; nite
+ RGB 11,11,19, 07,07,12 ; nite
; group 17 (Fuchsia)
RGB 31,18,29, 17,13,20 ; morn/day
- RGB 14,06,12, 11,03,10; nite
+ RGB 14,06,12, 11,03,10 ; nite
; group 18 (Lavender)
RGB 23,15,31, 16,05,31 ; morn/day
- RGB 12,07,17, 08,06,10; nite
+ RGB 12,07,17, 08,06,10 ; nite
; group 19 (Silver Cave)
RGB 21,21,25, 16,16,16 ; morn/day
- RGB 13,13,13, 07,07,07; nite
+ RGB 13,13,13, 07,07,07 ; nite
; group 20 (Cable Club)
RGB 21,21,21, 11,11,11 ; morn/day
- RGB 21,21,21, 11,11,11; nite
+ RGB 21,21,21, 11,11,11 ; nite
; group 21 (Celadon)
RGB 19,31,15, 31,22,02 ; morn/day
- RGB 12,13,09, 09,12,03; nite
+ RGB 12,13,09, 09,12,03 ; nite
; group 22 (Cianwood)
RGB 15,10,31, 07,05,15 ; morn/day
- RGB 06,05,17, 02,02,08; nite
+ RGB 06,05,17, 02,02,08 ; nite
; group 23 (Viridian)
RGB 21,31,07, 13,25,04 ; morn/day
- RGB 09,14,08, 06,10,04; nite
+ RGB 09,14,08, 06,10,04 ; nite
; group 24 (New Bark)
RGB 20,31,14, 11,23,05 ; morn/day
- RGB 09,13,08, 06,09,04; nite
+ RGB 09,13,08, 06,09,04 ; nite
; group 25 (Saffron)
RGB 31,26,00, 31,15,00 ; morn/day
- RGB 13,13,01, 08,08,01; nite
+ RGB 13,13,01, 08,08,01 ; nite
; group 26 (Cherrygrove)
RGB 31,14,28, 31,05,21 ; morn/day
- RGB 14,07,17, 13,00,08; nite
+ RGB 14,07,17, 13,00,08 ; nite
diff --git a/home.asm b/home.asm
index 1963e2f6a..9aaa50098 100644
--- a/home.asm
+++ b/home.asm
@@ -227,26 +227,7 @@ CompareLong:: ; 31e4
; 31f3
INCLUDE "home/tilemap.asm"
-
-SetHPPal:: ; 334e
-; Set palette for hp bar pixel length e at hl.
- call GetHPPal
- ld [hl], d
- ret
-; 3353
-
-GetHPPal:: ; 3353
-; Get palette for hp bar pixel length e in d.
- ld d, HP_GREEN
- ld a, e
- cp (50 * 48 / 100)
- ret nc
- inc d ; HP_YELLOW
- cp (21 * 48 / 100)
- ret nc
- inc d ; HP_RED
- ret
-; 335f
+INCLUDE "home/hp_pals.asm"
CountSetBits:: ; 0x335f
; Count the number of set bits in b bytes starting from hl.
diff --git a/home/audio.asm b/home/audio.asm
index 4b9c3a71c..05dbafa0a 100644
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -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
diff --git a/home/copy2.asm b/home/copy2.asm
index 23e1eca7f..63f3cfafb 100644
--- a/home/copy2.asm
+++ b/home/copy2.asm
@@ -1,7 +1,7 @@
CopyBytes:: ; 0x3026
; copy bc bytes from hl to de
- inc b ; we bail the moment b hits 0, so include the last run
- inc c ; same thing; include last byte
+ inc b ; we bail the moment b hits 0, so include the last run
+ inc c ; same thing; include last byte
jr .HandleLoop
.CopyByte:
ld a, [hli]
@@ -39,8 +39,8 @@ SwapBytes:: ; 0x3034
ByteFill:: ; 0x3041
; fill bc bytes with the value of a, starting at hl
- inc b ; we bail the moment b hits 0, so include the last run
- inc c ; same thing; include last byte
+ inc b ; we bail the moment b hits 0, so include the last run
+ inc c ; same thing; include last byte
jr .HandleLoop
.PutByte:
ld [hli], a
diff --git a/home/hp_pals.asm b/home/hp_pals.asm
new file mode 100644
index 000000000..221b93da0
--- /dev/null
+++ b/home/hp_pals.asm
@@ -0,0 +1,19 @@
+SetHPPal:: ; 334e
+; Set palette for hp bar pixel length e at hl.
+ call GetHPPal
+ ld [hl], d
+ ret
+; 3353
+
+GetHPPal:: ; 3353
+; Get palette for hp bar pixel length e in d.
+ ld d, HP_GREEN
+ ld a, e
+ cp (HP_BAR_LENGTH_PX * 50 / 100) ; 24
+ ret nc
+ inc d ; HP_YELLOW
+ cp (HP_BAR_LENGTH_PX * 21 / 100) ; 10
+ ret nc
+ inc d ; HP_RED
+ ret
+; 335f
diff --git a/home/map_objects.asm b/home/map_objects.asm
index c99e27088..5acea7822 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -482,10 +482,10 @@ GetSpriteMovementFunction:: ; 1a2f
xor a
.ok
- ld hl, SpriteMovementData
+ ld hl, SpriteMovementData + SPRITEMOVEATTR_MOVEMENT
ld e, a
ld d, 0
-rept SPRITEMOVEDATA_FIELDS
+rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de
endr
ld a, [hl]
@@ -497,15 +497,15 @@ GetInitialFacing:: ; 1a47
push de
ld e, a
ld d, 0
- ld hl, SpriteMovementData + 1 ; init facing
-rept SPRITEMOVEDATA_FIELDS
+ ld hl, SpriteMovementData + SPRITEMOVEATTR_FACING
+rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de
endr
ld a, BANK(SpriteMovementData)
call GetFarByte
add a
add a
- and $c
+ maskbits NUM_DIRECTIONS, 2
pop de
pop bc
ret
@@ -537,8 +537,8 @@ CopySpriteMovementData:: ; 1a61
push de
ld e, a
ld d, 0
- ld hl, SpriteMovementData + 1 ; init facing
-rept SPRITEMOVEDATA_FIELDS
+ ld hl, SpriteMovementData + SPRITEMOVEATTR_FACING
+rept NUM_SPRITEMOVEDATA_FIELDS
add hl, de
endr
ld b, h
@@ -549,7 +549,7 @@ endr
inc bc
rlca
rlca
- and %00001100
+ maskbits NUM_DIRECTIONS, 2
ld hl, OBJECT_FACING
add hl, de
ld [hl], a
@@ -654,7 +654,7 @@ SetSpriteDirection:: ; 1af8
and %11110011
ld e, a
pop af
- and %00001100
+ maskbits NUM_DIRECTIONS, 2
or e
ld [hl], a
ret
@@ -664,6 +664,6 @@ GetSpriteDirection:: ; 1b07
ld hl, OBJECT_FACING
add hl, bc
ld a, [hl]
- and %00001100
+ maskbits NUM_DIRECTIONS, 2
ret
; 1b0f
diff --git a/macros/code.asm b/macros/code.asm
index 1fb651f30..09b15255e 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -36,8 +36,10 @@ jumptable: MACRO
ENDM
maskbits: MACRO
-; masks just enough bits to cover the argument
+; masks just enough bits to cover the first argument
+; the second argument is an optional shift amount
; e.g. "maskbits 26" becomes "and %00011111" (since 26 - 1 = %00011001)
+; and "maskbits 3, 2" becomes "and %00001100" (since "maskbits 3" becomes %00000011)
; example usage in rejection sampling:
; .loop
; call Random
@@ -50,7 +52,11 @@ if x + 1 < (\1)
x = x << 1 | 1
endc
endr
+if _NARG == 2
+ and x << (\2)
+else
and x
+endc
ENDM
calc_sine_wave: MACRO
diff --git a/macros/wram.asm b/macros/wram.asm
index 469cc1022..6096d2bba 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -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)
diff --git a/maps/GoldenrodGameCorner.asm b/maps/GoldenrodGameCorner.asm
index dee306ba7..2e49a874b 100644
--- a/maps/GoldenrodGameCorner.asm
+++ b/maps/GoldenrodGameCorner.asm
@@ -46,10 +46,10 @@ GoldenrodGameCornerPokefanM3Script:
turnobject GOLDENRODGAMECORNER_POKEFAN_M3, RIGHT
end
-GoldenrodGmeCornerCoinVendorScript:
+GoldenrodGameCornerCoinVendorScript:
jumpstd gamecornercoinvendor
-GoldenrodGmeCornerTMVendorScript:
+GoldenrodGameCornerTMVendorScript:
faceplayer
opentext
writetext GoldenrodGameCornerPrizeVendorIntroText
@@ -57,7 +57,7 @@ GoldenrodGmeCornerTMVendorScript:
checkitem COIN_CASE
iffalse GoldenrodGameCornerPrizeVendor_NoCoinCaseScript
writetext GoldenrodGameCornerPrizeVendorWhichPrizeText
-GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36
+GoldenrodGameCornerTMVendor_LoopScript: ; 056c36
special DisplayCoinCaseBalance
loadmenu GoldenrodGameCornerTMVendorMenuHeader
verticalmenu
@@ -76,7 +76,7 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36
giveitem TM_THUNDER
iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump GoldenrodGmeCornerTMVendor_FinishScript
+ jump GoldenrodGameCornerTMVendor_FinishScript
.Blizzard:
checkcoins 5500
@@ -87,7 +87,7 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36
giveitem TM_BLIZZARD
iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump GoldenrodGmeCornerTMVendor_FinishScript
+ jump GoldenrodGameCornerTMVendor_FinishScript
.FireBlast:
checkcoins 5500
@@ -98,19 +98,19 @@ GoldenrodGmeCornerTMVendor_LoopScript: ; 056c36
giveitem TM_FIRE_BLAST
iffalse GoldenrodGameCornerPrizeMonVendor_NoRoomForPrizeScript
takecoins 5500
- jump GoldenrodGmeCornerTMVendor_FinishScript
+ jump GoldenrodGameCornerTMVendor_FinishScript
GoldenrodGameCornerPrizeVendor_ConfirmPurchaseScript:
writetext GoldenrodGameCornerPrizeVendorConfirmPrizeText
yesorno
end
-GoldenrodGmeCornerTMVendor_FinishScript:
+GoldenrodGameCornerTMVendor_FinishScript:
waitsfx
playsound SFX_TRANSACTION
writetext GoldenrodGameCornerPrizeVendorHereYouGoText
waitbutton
- jump GoldenrodGmeCornerTMVendor_LoopScript
+ jump GoldenrodGameCornerTMVendor_LoopScript
GoldenrodGameCornerPrizeVendor_NotEnoughCoinsScript:
writetext GoldenrodGameCornerPrizeVendorNeedMoreCoinsText
@@ -477,8 +477,8 @@ GoldenrodGameCorner_MapEvents:
bg_event 12, 1, BGEVENT_LEFT, GoldenrodGameCornerLeftTheirDrinkScript
db 12 ; object events
- object_event 3, 2, SPRITE_CLERK, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGmeCornerCoinVendorScript, -1
- object_event 16, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGmeCornerTMVendorScript, -1
+ object_event 3, 2, SPRITE_CLERK, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerCoinVendorScript, -1
+ object_event 16, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerTMVendorScript, -1
object_event 18, 2, SPRITE_RECEPTIONIST, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPrizeMonVendorScript, -1
object_event 8, 7, SPRITE_PHARMACIST, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, DAY, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1
object_event 8, 7, SPRITE_PHARMACIST, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, NITE, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, GoldenrodGameCornerPharmacistScript, -1
diff --git a/maps/Route35GoldenrodGate.asm b/maps/Route35GoldenrodGate.asm
index 52089c4db..71a1e510b 100644
--- a/maps/Route35GoldenrodGate.asm
+++ b/maps/Route35GoldenrodGate.asm
@@ -63,15 +63,17 @@ RandyScript:
end
GiftSpearowMail:
- db FLOWER_MAIL
+ db FLOWER_MAIL
db "DARK CAVE leads"
next "to another road@"
+
GiftSpearowName:
db "KENYA@"
+
GiftSpearowOTName:
db "RANDY@"
- db 0
+ db 0 ; filler
Route35GoldenrodGatePokefanFScript:
faceplayer
diff --git a/mobile/mobile_40.asm b/mobile/mobile_40.asm
index c64e348de..f82f3d2d3 100644
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -83,7 +83,7 @@ EnableMobile: ; 100082
call DoubleSpeed
xor a
ld [rIF], a
- ld a, 1 << VBLANK + 1 << LCD_STAT + 1 << TIMER + 1 << SERIAL
+ ld a, 1 << VBLANK | 1 << LCD_STAT | 1 << TIMER | 1 << SERIAL
ld [rIE], a
xor a
ld [hMapAnims], a
diff --git a/pokecrystal.link b/pokecrystal.link
index fc8fbb38a..157b39197 100644
--- a/pokecrystal.link
+++ b/pokecrystal.link
@@ -234,17 +234,22 @@ ROMX $5a
"Pics 19"
ROMX $5b
"bank5B"
+ "Pics 20"
ROMX $5c
"Mobile 5C"
+ "Pics 21"
ROMX $5d
"Crystal Phone Text 2"
+ "Pics 22"
ROMX $5e
"UpdateBattleHUDs"
"Songs 5"
"Crystal Sound Effects"
"Mobile 5E"
+ "Pics 23"
ROMX $5f
"Mobile 5F"
+ "Pics 24"
ROMX $60
"Map Scripts 13"
"Pokedex Entries 001-064"
diff --git a/wram.asm b/wram.asm
index 6ddcf2f42..9158a4047 100644
--- a/wram.asm
+++ b/wram.asm
@@ -2421,7 +2421,7 @@ wMapObjectsEnd::
wObjectMasks:: ds NUM_OBJECTS ; d81e
-wVariableSprites:: ds 16; d82e
+wVariableSprites:: ds $100 - SPRITE_VARS ; d82e
wEnteredMapFromContinue:: db ; d83e
ds 2