diff options
-rw-r--r-- | audio/engine.asm | 165 | ||||
-rw-r--r-- | constants.asm | 2 | ||||
-rw-r--r-- | constants/audio_constants.asm | 84 | ||||
-rw-r--r-- | constants/battle_anim_constants.asm | 837 | ||||
-rw-r--r-- | data/predef_pointers.inc | 4 | ||||
-rw-r--r-- | engine/battle_anims/bg_effects.asm | 2376 | ||||
-rw-r--r-- | engine/gfx.asm | 52 | ||||
-rw-r--r-- | engine/palettes.asm | 113 | ||||
-rw-r--r-- | home/copy2.asm | 14 | ||||
-rw-r--r-- | home/joypad.asm | 2 | ||||
-rw-r--r-- | home/pokemon.asm | 2 | ||||
-rw-r--r-- | hram.asm | 39 | ||||
-rw-r--r-- | macros/wram.asm | 15 | ||||
-rw-r--r-- | tools/make_shim.c | 32 | ||||
-rw-r--r-- | zero_checksum.inc | 6 |
15 files changed, 3644 insertions, 99 deletions
diff --git a/audio/engine.asm b/audio/engine.asm index 3e590f6..0d1d065 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -251,8 +251,8 @@ IsAnySFXOn: ; 3a:42d0 SECTION "Function_e82f0", ROMX[$42f0], BANK[$3a] Function_e82f0: ; 3a:42f0 - call Function_e8352 - call Function_e8307 + call IncrementTempo + call PlayDanger call FadeMusic call Function_e841d ld a, [wVolume] @@ -261,7 +261,166 @@ Function_e82f0: ; 3a:42f0 ld [rNR51], a ret -SECTION "FadeMusic", ROMX[$43ce], BANK[$3a] +PlayDanger: ; 3a:4307 + 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 IsAnySFXOn + jr c, .increment + + ; Play the high tone + and a + 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 + ld a, [hli] + ld [rNR11], a + ld a, [hli] + ld [rNR12], a + ld a, [hli] + ld [rNR13], a + ld a, [hli] + ld [rNR14], a + +.increment + ld a, d + inc a + cp 30 ; Ending frame + jr c, .noreset + xor a +.noreset + ; Make sure the danger sound is kept on + or 1 << DANGER_ON_F + ld [wLowHealthAlarm], a + + ; Make sure channel 1 is on + ld a, [wSoundOutput] + or $11 + ld [wSoundOutput], a + ret + +DangerSoundHigh: ; 3a:434a + db $80 ; duty 50% + db $e2 ; volume 14, envelope decrease sweep 2 + db $50 ; frequency: $750 + db $87 ; restart sound + +DangerSoundLow: ; 3a:434e + db $80 ; duty 50% + db $e2 ; volume 14, envelope decrease sweep 2 + db $ee ; frequency: $6ee + db $86 ; restart sound + +IncrementTempo: ; 3a:4352 + call IsAnyChannelOn + ret c + + ld a, [wIncrementTempo] + ld e, a + ld a, [wIncrementTempo + 1] + ld d, a + or e + ret z + + ld hl, wChannel1Tempo + call .addtempo + ld hl, wChannel2Tempo + call .addtempo + ld hl, wChannel3Tempo + call .addtempo + ld hl, wChannel4Tempo + call .addtempo + xor a + ld [wIncrementTempo], a + ld [wIncrementTempo + 1], a + ret + +.addtempo + ; (int16)[hl] += de + push de + push hl + ld a, [hli] + ld h, [hl] + ld l, a + add hl, de + ld e, l + ld d, h + pop hl + ld [hl], e + inc hl + ld [hl], d + pop de + ret + +IsAnyChannelOn: ; 3a:438e +; Check if any music channel is on and isn't on the last frame + + ld hl, wChannel1Flags1 + bit SOUND_CHANNEL_ON, [hl] + jr z, .check_channel2 + + ld hl, wChannel1NoteDuration + ld a, [hl] + cp 1 + jr nz, .on + +.check_channel2 + ld hl, wChannel2Flags1 + bit SOUND_CHANNEL_ON, [hl] + jr z, .check_channel3 + + ld hl, wChannel2NoteDuration + ld a, [hl] + cp 1 + jr nz, .on + +.check_channel3 + ld hl, wChannel3Flags1 + bit SOUND_CHANNEL_ON, [hl] + jr z, .check_channel4 + + ld hl, wChannel3NoteDuration + ld a, [hl] + cp 1 + jr nz, .on + +.check_channel4 + ld hl, wChannel4Flags1 + bit SOUND_CHANNEL_ON, [hl] + jr z, .off + + ld hl, wChannel4NoteDuration + ld a, [hl] + cp 1 + jr nz, .on + +.off + and a + ret + +.on + scf + ret + FadeMusic: ; 3a:43ce ; Fade music if applicable ; usage: diff --git a/constants.asm b/constants.asm index d758d4b..6a93ce6 100644 --- a/constants.asm +++ b/constants.asm @@ -23,3 +23,5 @@ INCLUDE "constants/music_constants.asm" INCLUDE "constants/serial_constants.asm" INCLUDE "constants/misc_constants.asm" + +INCLUDE "constants/battle_anim_constants.asm" diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm index b9e8594..f960501 100644 --- a/constants/audio_constants.asm +++ b/constants/audio_constants.asm @@ -13,44 +13,44 @@ NUM_NOISE_CHANS EQU const_value NUM_CHANNELS EQU const_value ; channel_struct members (see macros/wram.asm) -CHANNEL_MUSIC_ID EQUS "(wChannel1MusicID - wChannel1)" -CHANNEL_MUSIC_BANK EQUS "(wChannelMusicBank - 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 "(wChannelOctave - wChannel1)" -CHANNEL_PITCH_OFFSET EQUS "(wChannelPitchOffset - 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_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)" +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)" ; Flags1 const_def @@ -88,11 +88,15 @@ CHANNEL_STRUCT_LENGTH EQUS "(wChannel2 - wChannel1)" 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 + +; wLowHealthAlarm +DANGER_PITCH_F EQU 4 +DANGER_ON_F EQU 7 ; wMusicFade MUSIC_FADE_IN_F EQU 7 diff --git a/constants/battle_anim_constants.asm b/constants/battle_anim_constants.asm new file mode 100644 index 0000000..0fbd83a --- /dev/null +++ b/constants/battle_anim_constants.asm @@ -0,0 +1,837 @@ +; battle_anim_struct members (see macros/wram.asm) + const_def + const BATTLEANIMSTRUCT_INDEX + const BATTLEANIMSTRUCT_01 + const BATTLEANIMSTRUCT_02 + const BATTLEANIMSTRUCT_FRAMESET_ID + const BATTLEANIMSTRUCT_FUNCTION + const BATTLEANIMSTRUCT_PALETTE + const BATTLEANIMSTRUCT_TILEID + const BATTLEANIMSTRUCT_XCOORD + const BATTLEANIMSTRUCT_YCOORD + const BATTLEANIMSTRUCT_XOFFSET + const BATTLEANIMSTRUCT_YOFFSET + const BATTLEANIMSTRUCT_0B + const BATTLEANIMSTRUCT_DURATION + const BATTLEANIMSTRUCT_FRAME + const BATTLEANIMSTRUCT_ANON_JT_INDEX + const BATTLEANIMSTRUCT_0F + const BATTLEANIMSTRUCT_10 + const BATTLEANIMSTRUCT_11 + const BATTLEANIMSTRUCT_12 + const BATTLEANIMSTRUCT_13 + const BATTLEANIMSTRUCT_14 + const BATTLEANIMSTRUCT_15 + const BATTLEANIMSTRUCT_16 + const BATTLEANIMSTRUCT_17 +BATTLEANIMSTRUCT_LENGTH EQU const_value + +; BattleAnimObjects indexes (see data/battle_anims/objects.asm) + const_def + const ANIM_OBJ_00 + const ANIM_OBJ_01 + const ANIM_OBJ_02 + const ANIM_OBJ_03 + const ANIM_OBJ_04 + const ANIM_OBJ_05 + const ANIM_OBJ_06 + const ANIM_OBJ_07 + const ANIM_OBJ_08 + const ANIM_OBJ_FANG + const ANIM_OBJ_0A + const ANIM_OBJ_EMBER + const ANIM_OBJ_DRAGON_RAGE + const ANIM_OBJ_FLAMETHROWER + const ANIM_OBJ_FIRE_SPIN + const ANIM_OBJ_FIRE_BLAST + const ANIM_OBJ_BURNED + const ANIM_OBJ_BLIZZARD + const ANIM_OBJ_12 + const ANIM_OBJ_ICE_BEAM + const ANIM_OBJ_RAZOR_LEAF + const ANIM_OBJ_POKE_BALL + const ANIM_OBJ_POKE_BALL_BLOCKED + const ANIM_OBJ_17 + const ANIM_OBJ_18 + const ANIM_OBJ_19 + const ANIM_OBJ_1A + const ANIM_OBJ_1B + const ANIM_OBJ_BALL_POOF + const ANIM_OBJ_BIG_ROCK + const ANIM_OBJ_SMALL_ROCK + const ANIM_OBJ_STRENGTH + const ANIM_OBJ_SEISMIC_TOSS + const ANIM_OBJ_BUBBLE + const ANIM_OBJ_SURF + const ANIM_OBJ_SING + const ANIM_OBJ_WATER_GUN + const ANIM_OBJ_HYDRO_PUMP + const ANIM_OBJ_POWDER + const ANIM_OBJ_27 + const ANIM_OBJ_28 + const ANIM_OBJ_ICE_BUILDUP + const ANIM_OBJ_FROZEN + const ANIM_OBJ_MASTER_BALL_SPARKLE + const ANIM_OBJ_RECOVER + const ANIM_OBJ_2D + const ANIM_OBJ_2E + const ANIM_OBJ_2F + const ANIM_OBJ_THUNDER_WAVE + const ANIM_OBJ_31 + const ANIM_OBJ_LIGHTNING_BOLT + const ANIM_OBJ_33 + const ANIM_OBJ_34 + const ANIM_OBJ_CLAMP + const ANIM_OBJ_BITE + const ANIM_OBJ_37 + const ANIM_OBJ_38 + const ANIM_OBJ_39 + const ANIM_OBJ_3A + const ANIM_OBJ_3B + const ANIM_OBJ_3C + const ANIM_OBJ_3D + const ANIM_OBJ_GUST + const ANIM_OBJ_3F + const ANIM_OBJ_40 + const ANIM_OBJ_41 + const ANIM_OBJ_42 + const ANIM_OBJ_SONICBOOM_JP + const ANIM_OBJ_44 + const ANIM_OBJ_ABSORB + const ANIM_OBJ_EGG + const ANIM_OBJ_47 + const ANIM_OBJ_48 + const ANIM_OBJ_49 + const ANIM_OBJ_LEECH_SEED + const ANIM_OBJ_4B + const ANIM_OBJ_WAVE + const ANIM_OBJ_CONFUSE_RAY + const ANIM_OBJ_4E + const ANIM_OBJ_4F + const ANIM_OBJ_SCREEN + const ANIM_OBJ_HARDEN + const ANIM_OBJ_CHICK + const ANIM_OBJ_AMNESIA + const ANIM_OBJ_ASLEEP + const ANIM_OBJ_SKULL + const ANIM_OBJ_56 + const ANIM_OBJ_57 + const ANIM_OBJ_58 + const ANIM_OBJ_PARALYZED + const ANIM_OBJ_STRING_SHOT + const ANIM_OBJ_HAZE + const ANIM_OBJ_MIST + const ANIM_OBJ_SMOG + const ANIM_OBJ_POISON_GAS + const ANIM_OBJ_HORN + const ANIM_OBJ_60 + const ANIM_OBJ_PETAL_DANCE + const ANIM_OBJ_SLUDGE_BOMB + const ANIM_OBJ_PAY_DAY + const ANIM_OBJ_64 + const ANIM_OBJ_MIMIC + const ANIM_OBJ_ATTRACT + const ANIM_OBJ_BONEMERANG + const ANIM_OBJ_BONE_CLUB + const ANIM_OBJ_BONE_RUSH + const ANIM_OBJ_SWIFT + const ANIM_OBJ_KINESIS + const ANIM_OBJ_FLASH + const ANIM_OBJ_SHINY + const ANIM_OBJ_SKY_ATTACK + const ANIM_OBJ_LICK + const ANIM_OBJ_WITHDRAW + const ANIM_OBJ_71 + const ANIM_OBJ_GROWTH + const ANIM_OBJ_CONVERSION2 + const ANIM_OBJ_SMOKE + const ANIM_OBJ_SMOKESCREEN + const ANIM_OBJ_SWORDS_DANCE + const ANIM_OBJ_SPEED_LINE + const ANIM_OBJ_SHARPEN + const ANIM_OBJ_DEFENSE_CURL + const ANIM_OBJ_7A + const ANIM_OBJ_7B + const ANIM_OBJ_DISABLE + const ANIM_OBJ_AGILITY + const ANIM_OBJ_HEART + const ANIM_OBJ_FLAME_WHEEL + const ANIM_OBJ_SACRED_FIRE + const ANIM_OBJ_COTTON_SPORE + const ANIM_OBJ_MILK_DRINK + const ANIM_OBJ_ANGER + const ANIM_OBJ_84 + const ANIM_OBJ_85 + const ANIM_OBJ_BATON_PASS + const ANIM_OBJ_LOCK_ON + const ANIM_OBJ_MIND_READER + const ANIM_OBJ_SAFEGUARD + const ANIM_OBJ_PROTECT + const ANIM_OBJ_THIEF + const ANIM_OBJ_OCTAZOOKA + const ANIM_OBJ_PRESENT + const ANIM_OBJ_SPIKES + const ANIM_OBJ_POWDER_SNOW + const ANIM_OBJ_DRAGONBREATH + const ANIM_OBJ_CONVERSION + const ANIM_OBJ_SPIDER_WEB + const ANIM_OBJ_93 + const ANIM_OBJ_NIGHTMARE + const ANIM_OBJ_IN_NIGHTMARE + const ANIM_OBJ_LOVELY_KISS + const ANIM_OBJ_SWEET_KISS + const ANIM_OBJ_SKETCH + const ANIM_OBJ_99 + const ANIM_OBJ_9A + const ANIM_OBJ_DESTINY_BOND + const ANIM_OBJ_MORNING_SUN + const ANIM_OBJ_GLIMMER + const ANIM_OBJ_MOONLIGHT + const ANIM_OBJ_HIDDEN_POWER + const ANIM_OBJ_A0 + const ANIM_OBJ_A1 + const ANIM_OBJ_SANDSTORM + const ANIM_OBJ_ZAP_CANNON + const ANIM_OBJ_SPITE + const ANIM_OBJ_CURSE + const ANIM_OBJ_PERISH_SONG + const ANIM_OBJ_FORESIGHT + const ANIM_OBJ_RAPID_SPIN + const ANIM_OBJ_SWAGGER + const ANIM_OBJ_AA + const ANIM_OBJ_AB + const ANIM_OBJ_MEAN_LOOK + const ANIM_OBJ_AD + const ANIM_OBJ_AE + const ANIM_OBJ_RAIN + const ANIM_OBJ_B0 + const ANIM_OBJ_PSYCH_UP + const ANIM_OBJ_ANCIENTPOWER + const ANIM_OBJ_AEROBLAST + const ANIM_OBJ_SHADOW_BALL + const ANIM_OBJ_ROCK_SMASH + const ANIM_OBJ_FLOWER + const ANIM_OBJ_COTTON + +const_value SET $b1 + const ANIM_OBJ_PLAYERFEETFOLLOW + const ANIM_OBJ_ENEMYFEETFOLLOW + const ANIM_OBJ_PLAYERHEADFOLLOW + const ANIM_OBJ_ENEMYHEADFOLLOW + +; DoBattleAnimFrame arguments (see engine/battle_anims/functions.asm) + const_def + const BATTLEANIMFUNC_00 + const BATTLEANIMFUNC_01 + const BATTLEANIMFUNC_02 + const BATTLEANIMFUNC_03 + const BATTLEANIMFUNC_04 + const BATTLEANIMFUNC_05 + const BATTLEANIMFUNC_06 + const BATTLEANIMFUNC_07 + const BATTLEANIMFUNC_08 + const BATTLEANIMFUNC_09 + const BATTLEANIMFUNC_0A + const BATTLEANIMFUNC_RAZOR_LEAF + const BATTLEANIMFUNC_0C + const BATTLEANIMFUNC_0D + const BATTLEANIMFUNC_0E + const BATTLEANIMFUNC_0F + const BATTLEANIMFUNC_10 + const BATTLEANIMFUNC_11 + const BATTLEANIMFUNC_12 + const BATTLEANIMFUNC_13 + const BATTLEANIMFUNC_14 + const BATTLEANIMFUNC_15 + const BATTLEANIMFUNC_16 + const BATTLEANIMFUNC_17 + const BATTLEANIMFUNC_18 + const BATTLEANIMFUNC_19 + const BATTLEANIMFUNC_1A + const BATTLEANIMFUNC_1B + const BATTLEANIMFUNC_1C + const BATTLEANIMFUNC_1D + const BATTLEANIMFUNC_1E + const BATTLEANIMFUNC_1F + const BATTLEANIMFUNC_LEECH_SEED + const BATTLEANIMFUNC_21 + const BATTLEANIMFUNC_22 + const BATTLEANIMFUNC_23 + const BATTLEANIMFUNC_24 + const BATTLEANIMFUNC_25 + const BATTLEANIMFUNC_26 + const BATTLEANIMFUNC_27 + const BATTLEANIMFUNC_28 + const BATTLEANIMFUNC_SPRIAL_DESCENT + const BATTLEANIMFUNC_POISON_GAS + const BATTLEANIMFUNC_HORN + const BATTLEANIMFUNC_2C + const BATTLEANIMFUNC_2D + const BATTLEANIMFUNC_2E + const BATTLEANIMFUNC_2F + const BATTLEANIMFUNC_30 + const BATTLEANIMFUNC_31 + const BATTLEANIMFUNC_32 + const BATTLEANIMFUNC_33 + const BATTLEANIMFUNC_34 + const BATTLEANIMFUNC_35 + const BATTLEANIMFUNC_36 + const BATTLEANIMFUNC_37 + const BATTLEANIMFUNC_38 + const BATTLEANIMFUNC_39 + const BATTLEANIMFUNC_3A + const BATTLEANIMFUNC_3B + const BATTLEANIMFUNC_3C + const BATTLEANIMFUNC_3D + const BATTLEANIMFUNC_3E + const BATTLEANIMFUNC_3F + const BATTLEANIMFUNC_40 + const BATTLEANIMFUNC_41 + const BATTLEANIMFUNC_42 + const BATTLEANIMFUNC_43 + const BATTLEANIMFUNC_44 + const BATTLEANIMFUNC_45 + const BATTLEANIMFUNC_46 + const BATTLEANIMFUNC_47 + const BATTLEANIMFUNC_48 + const BATTLEANIMFUNC_49 + const BATTLEANIMFUNC_4A + const BATTLEANIMFUNC_4B + const BATTLEANIMFUNC_4C + const BATTLEANIMFUNC_4D + const BATTLEANIMFUNC_4E + const BATTLEANIMFUNC_4F + +; BattleAnimFrameData indexes (see data/battle_anims/framesets.asm) + const_def + const BATTLEANIMFRAMESET_00 + const BATTLEANIMFRAMESET_01 + const BATTLEANIMFRAMESET_02 + const BATTLEANIMFRAMESET_03 + const BATTLEANIMFRAMESET_04 + const BATTLEANIMFRAMESET_05 + const BATTLEANIMFRAMESET_06 + const BATTLEANIMFRAMESET_07 + const BATTLEANIMFRAMESET_08 + const BATTLEANIMFRAMESET_09 + const BATTLEANIMFRAMESET_0A + const BATTLEANIMFRAMESET_0B + const BATTLEANIMFRAMESET_0C + const BATTLEANIMFRAMESET_0D + const BATTLEANIMFRAMESET_0E + const BATTLEANIMFRAMESET_0F + const BATTLEANIMFRAMESET_10 + const BATTLEANIMFRAMESET_11 + const BATTLEANIMFRAMESET_12 + const BATTLEANIMFRAMESET_13 + const BATTLEANIMFRAMESET_14 + const BATTLEANIMFRAMESET_15 + const BATTLEANIMFRAMESET_16 + const BATTLEANIMFRAMESET_17 + const BATTLEANIMFRAMESET_18 + const BATTLEANIMFRAMESET_19 + const BATTLEANIMFRAMESET_1A + const BATTLEANIMFRAMESET_1B + const BATTLEANIMFRAMESET_1C + const BATTLEANIMFRAMESET_1D + const BATTLEANIMFRAMESET_1E + const BATTLEANIMFRAMESET_1F + const BATTLEANIMFRAMESET_20 + const BATTLEANIMFRAMESET_21 + const BATTLEANIMFRAMESET_22 + const BATTLEANIMFRAMESET_23 + const BATTLEANIMFRAMESET_24 + const BATTLEANIMFRAMESET_25 + const BATTLEANIMFRAMESET_26 + const BATTLEANIMFRAMESET_27 + const BATTLEANIMFRAMESET_28 + const BATTLEANIMFRAMESET_29 + const BATTLEANIMFRAMESET_2A + const BATTLEANIMFRAMESET_2B + const BATTLEANIMFRAMESET_2C + const BATTLEANIMFRAMESET_2D + const BATTLEANIMFRAMESET_2E + const BATTLEANIMFRAMESET_2F + const BATTLEANIMFRAMESET_30 + const BATTLEANIMFRAMESET_31 + const BATTLEANIMFRAMESET_32 + const BATTLEANIMFRAMESET_33 + const BATTLEANIMFRAMESET_34 + const BATTLEANIMFRAMESET_35 + const BATTLEANIMFRAMESET_36 + const BATTLEANIMFRAMESET_37 + const BATTLEANIMFRAMESET_38 + const BATTLEANIMFRAMESET_39 + const BATTLEANIMFRAMESET_3A + const BATTLEANIMFRAMESET_3B + const BATTLEANIMFRAMESET_3C + const BATTLEANIMFRAMESET_3D + const BATTLEANIMFRAMESET_3E + const BATTLEANIMFRAMESET_3F + const BATTLEANIMFRAMESET_40 + const BATTLEANIMFRAMESET_41 + const BATTLEANIMFRAMESET_42 + const BATTLEANIMFRAMESET_43 + const BATTLEANIMFRAMESET_44 + const BATTLEANIMFRAMESET_45 + const BATTLEANIMFRAMESET_46 + const BATTLEANIMFRAMESET_47 + const BATTLEANIMFRAMESET_48 + const BATTLEANIMFRAMESET_49 + const BATTLEANIMFRAMESET_4A + const BATTLEANIMFRAMESET_4B + const BATTLEANIMFRAMESET_4C + const BATTLEANIMFRAMESET_4D + const BATTLEANIMFRAMESET_4E + const BATTLEANIMFRAMESET_4F + const BATTLEANIMFRAMESET_50 + const BATTLEANIMFRAMESET_51 + const BATTLEANIMFRAMESET_52 + const BATTLEANIMFRAMESET_53 + const BATTLEANIMFRAMESET_54 + const BATTLEANIMFRAMESET_55 + const BATTLEANIMFRAMESET_56 + const BATTLEANIMFRAMESET_57 + const BATTLEANIMFRAMESET_58 + const BATTLEANIMFRAMESET_59 + const BATTLEANIMFRAMESET_5A + const BATTLEANIMFRAMESET_5B + const BATTLEANIMFRAMESET_5C + const BATTLEANIMFRAMESET_5D + const BATTLEANIMFRAMESET_5E + const BATTLEANIMFRAMESET_5F + const BATTLEANIMFRAMESET_60 + const BATTLEANIMFRAMESET_61 + const BATTLEANIMFRAMESET_62 + const BATTLEANIMFRAMESET_63 + const BATTLEANIMFRAMESET_64 + const BATTLEANIMFRAMESET_65 + const BATTLEANIMFRAMESET_66 + const BATTLEANIMFRAMESET_67 + const BATTLEANIMFRAMESET_68 + const BATTLEANIMFRAMESET_69 + const BATTLEANIMFRAMESET_6A + const BATTLEANIMFRAMESET_6B + const BATTLEANIMFRAMESET_6C + const BATTLEANIMFRAMESET_6D + const BATTLEANIMFRAMESET_6E + const BATTLEANIMFRAMESET_6F + const BATTLEANIMFRAMESET_70 + const BATTLEANIMFRAMESET_71 + const BATTLEANIMFRAMESET_72 + const BATTLEANIMFRAMESET_73 + const BATTLEANIMFRAMESET_74 + const BATTLEANIMFRAMESET_75 + const BATTLEANIMFRAMESET_76 + const BATTLEANIMFRAMESET_77 + const BATTLEANIMFRAMESET_78 + const BATTLEANIMFRAMESET_79 + const BATTLEANIMFRAMESET_7A + const BATTLEANIMFRAMESET_7B + const BATTLEANIMFRAMESET_7C + const BATTLEANIMFRAMESET_7D + const BATTLEANIMFRAMESET_7E + const BATTLEANIMFRAMESET_7F + const BATTLEANIMFRAMESET_80 + const BATTLEANIMFRAMESET_81 + const BATTLEANIMFRAMESET_82 + const BATTLEANIMFRAMESET_83 + const BATTLEANIMFRAMESET_84 + const BATTLEANIMFRAMESET_85 + const BATTLEANIMFRAMESET_86 + const BATTLEANIMFRAMESET_87 + const BATTLEANIMFRAMESET_88 + const BATTLEANIMFRAMESET_89 + const BATTLEANIMFRAMESET_8A + const BATTLEANIMFRAMESET_8B + const BATTLEANIMFRAMESET_8C + const BATTLEANIMFRAMESET_8D + const BATTLEANIMFRAMESET_8E + const BATTLEANIMFRAMESET_8F + const BATTLEANIMFRAMESET_90 + const BATTLEANIMFRAMESET_91 + const BATTLEANIMFRAMESET_92 + const BATTLEANIMFRAMESET_93 + const BATTLEANIMFRAMESET_94 + const BATTLEANIMFRAMESET_95 + const BATTLEANIMFRAMESET_96 + const BATTLEANIMFRAMESET_97 + const BATTLEANIMFRAMESET_98 + const BATTLEANIMFRAMESET_99 + const BATTLEANIMFRAMESET_9A + const BATTLEANIMFRAMESET_9B + const BATTLEANIMFRAMESET_9C + const BATTLEANIMFRAMESET_9D + const BATTLEANIMFRAMESET_9E + const BATTLEANIMFRAMESET_9F + const BATTLEANIMFRAMESET_A0 + const BATTLEANIMFRAMESET_A1 + const BATTLEANIMFRAMESET_A2 + const BATTLEANIMFRAMESET_A3 + const BATTLEANIMFRAMESET_A4 + const BATTLEANIMFRAMESET_A5 + const BATTLEANIMFRAMESET_A6 + const BATTLEANIMFRAMESET_A7 + const BATTLEANIMFRAMESET_A8 + const BATTLEANIMFRAMESET_A9 + const BATTLEANIMFRAMESET_AA + const BATTLEANIMFRAMESET_AB + const BATTLEANIMFRAMESET_AC + const BATTLEANIMFRAMESET_AD + const BATTLEANIMFRAMESET_AE + const BATTLEANIMFRAMESET_AF + const BATTLEANIMFRAMESET_B0 + const BATTLEANIMFRAMESET_B1 + const BATTLEANIMFRAMESET_B2 + const BATTLEANIMFRAMESET_B3 + const BATTLEANIMFRAMESET_B4 + const BATTLEANIMFRAMESET_B5 + const BATTLEANIMFRAMESET_B6 + const BATTLEANIMFRAMESET_B7 + const BATTLEANIMFRAMESET_B8 + +; BattleAnimOAMData indexes (see data/battle_anims/oam.asm) + const_def + const BATTLEANIMOAMSET_00 + const BATTLEANIMOAMSET_01 + const BATTLEANIMOAMSET_02 + const BATTLEANIMOAMSET_03 + const BATTLEANIMOAMSET_04 + const BATTLEANIMOAMSET_05 + const BATTLEANIMOAMSET_06 + const BATTLEANIMOAMSET_07 + const BATTLEANIMOAMSET_08 + const BATTLEANIMOAMSET_09 + const BATTLEANIMOAMSET_0A + const BATTLEANIMOAMSET_0B + const BATTLEANIMOAMSET_0C + const BATTLEANIMOAMSET_0D + const BATTLEANIMOAMSET_0E + const BATTLEANIMOAMSET_0F + const BATTLEANIMOAMSET_10 + const BATTLEANIMOAMSET_11 + const BATTLEANIMOAMSET_12 + const BATTLEANIMOAMSET_13 + const BATTLEANIMOAMSET_14 + const BATTLEANIMOAMSET_15 + const BATTLEANIMOAMSET_16 + const BATTLEANIMOAMSET_17 + const BATTLEANIMOAMSET_18 + const BATTLEANIMOAMSET_19 + const BATTLEANIMOAMSET_1A + const BATTLEANIMOAMSET_1B + const BATTLEANIMOAMSET_1C + const BATTLEANIMOAMSET_1D + const BATTLEANIMOAMSET_1E + const BATTLEANIMOAMSET_1F + const BATTLEANIMOAMSET_20 + const BATTLEANIMOAMSET_21 + const BATTLEANIMOAMSET_22 + const BATTLEANIMOAMSET_23 + const BATTLEANIMOAMSET_24 + const BATTLEANIMOAMSET_25 + const BATTLEANIMOAMSET_26 + const BATTLEANIMOAMSET_27 + const BATTLEANIMOAMSET_28 + const BATTLEANIMOAMSET_29 + const BATTLEANIMOAMSET_2A + const BATTLEANIMOAMSET_2B + const BATTLEANIMOAMSET_2C + const BATTLEANIMOAMSET_2D + const BATTLEANIMOAMSET_2E + const BATTLEANIMOAMSET_2F + const BATTLEANIMOAMSET_30 + const BATTLEANIMOAMSET_31 + const BATTLEANIMOAMSET_32 + const BATTLEANIMOAMSET_33 + const BATTLEANIMOAMSET_34 + const BATTLEANIMOAMSET_35 + const BATTLEANIMOAMSET_36 + const BATTLEANIMOAMSET_37 + const BATTLEANIMOAMSET_38 + const BATTLEANIMOAMSET_39 + const BATTLEANIMOAMSET_3A + const BATTLEANIMOAMSET_3B + const BATTLEANIMOAMSET_3C + const BATTLEANIMOAMSET_3D + const BATTLEANIMOAMSET_3E + const BATTLEANIMOAMSET_3F + const BATTLEANIMOAMSET_40 + const BATTLEANIMOAMSET_41 + const BATTLEANIMOAMSET_42 + const BATTLEANIMOAMSET_43 + const BATTLEANIMOAMSET_44 + const BATTLEANIMOAMSET_45 + const BATTLEANIMOAMSET_46 + const BATTLEANIMOAMSET_47 + const BATTLEANIMOAMSET_48 + const BATTLEANIMOAMSET_49 + const BATTLEANIMOAMSET_4A + const BATTLEANIMOAMSET_4B + const BATTLEANIMOAMSET_4C + const BATTLEANIMOAMSET_4D + const BATTLEANIMOAMSET_4E + const BATTLEANIMOAMSET_4F + const BATTLEANIMOAMSET_50 + const BATTLEANIMOAMSET_51 + const BATTLEANIMOAMSET_52 + const BATTLEANIMOAMSET_53 + const BATTLEANIMOAMSET_54 + const BATTLEANIMOAMSET_55 + const BATTLEANIMOAMSET_56 + const BATTLEANIMOAMSET_57 + const BATTLEANIMOAMSET_58 + const BATTLEANIMOAMSET_59 + const BATTLEANIMOAMSET_5A + const BATTLEANIMOAMSET_5B + const BATTLEANIMOAMSET_5C + const BATTLEANIMOAMSET_5D + const BATTLEANIMOAMSET_5E + const BATTLEANIMOAMSET_5F + const BATTLEANIMOAMSET_60 + const BATTLEANIMOAMSET_61 + const BATTLEANIMOAMSET_62 + const BATTLEANIMOAMSET_63 + const BATTLEANIMOAMSET_64 + const BATTLEANIMOAMSET_65 + const BATTLEANIMOAMSET_66 + const BATTLEANIMOAMSET_67 + const BATTLEANIMOAMSET_68 + const BATTLEANIMOAMSET_69 + const BATTLEANIMOAMSET_6A + const BATTLEANIMOAMSET_6B + const BATTLEANIMOAMSET_6C + const BATTLEANIMOAMSET_6D + const BATTLEANIMOAMSET_6E + const BATTLEANIMOAMSET_6F + const BATTLEANIMOAMSET_70 + const BATTLEANIMOAMSET_71 + const BATTLEANIMOAMSET_72 + const BATTLEANIMOAMSET_73 + const BATTLEANIMOAMSET_74 + const BATTLEANIMOAMSET_75 + const BATTLEANIMOAMSET_76 + const BATTLEANIMOAMSET_77 + const BATTLEANIMOAMSET_78 + const BATTLEANIMOAMSET_79 + const BATTLEANIMOAMSET_7A + const BATTLEANIMOAMSET_7B + const BATTLEANIMOAMSET_7C + const BATTLEANIMOAMSET_7D + const BATTLEANIMOAMSET_7E + const BATTLEANIMOAMSET_7F + const BATTLEANIMOAMSET_80 + const BATTLEANIMOAMSET_81 + const BATTLEANIMOAMSET_82 + const BATTLEANIMOAMSET_83 + const BATTLEANIMOAMSET_84 + const BATTLEANIMOAMSET_85 + const BATTLEANIMOAMSET_86 + const BATTLEANIMOAMSET_87 + const BATTLEANIMOAMSET_88 + const BATTLEANIMOAMSET_89 + const BATTLEANIMOAMSET_8A + const BATTLEANIMOAMSET_8B + const BATTLEANIMOAMSET_8C + const BATTLEANIMOAMSET_8D + const BATTLEANIMOAMSET_8E + const BATTLEANIMOAMSET_8F + const BATTLEANIMOAMSET_90 + const BATTLEANIMOAMSET_91 + const BATTLEANIMOAMSET_92 + const BATTLEANIMOAMSET_93 + const BATTLEANIMOAMSET_94 + const BATTLEANIMOAMSET_95 + const BATTLEANIMOAMSET_96 + const BATTLEANIMOAMSET_97 + const BATTLEANIMOAMSET_98 + const BATTLEANIMOAMSET_99 + const BATTLEANIMOAMSET_9A + const BATTLEANIMOAMSET_9B + const BATTLEANIMOAMSET_9C + const BATTLEANIMOAMSET_9D + const BATTLEANIMOAMSET_9E + const BATTLEANIMOAMSET_9F + const BATTLEANIMOAMSET_A0 + const BATTLEANIMOAMSET_A1 + const BATTLEANIMOAMSET_A2 + const BATTLEANIMOAMSET_A3 + const BATTLEANIMOAMSET_A4 + const BATTLEANIMOAMSET_A5 + const BATTLEANIMOAMSET_A6 + const BATTLEANIMOAMSET_A7 + const BATTLEANIMOAMSET_A8 + const BATTLEANIMOAMSET_A9 + const BATTLEANIMOAMSET_AA + const BATTLEANIMOAMSET_AB + const BATTLEANIMOAMSET_AC + const BATTLEANIMOAMSET_AD + const BATTLEANIMOAMSET_AE + const BATTLEANIMOAMSET_AF + const BATTLEANIMOAMSET_B0 + const BATTLEANIMOAMSET_B1 + const BATTLEANIMOAMSET_B2 + const BATTLEANIMOAMSET_B3 + const BATTLEANIMOAMSET_B4 + const BATTLEANIMOAMSET_B5 + const BATTLEANIMOAMSET_B6 + const BATTLEANIMOAMSET_B7 + const BATTLEANIMOAMSET_B8 + const BATTLEANIMOAMSET_B9 + const BATTLEANIMOAMSET_BA + const BATTLEANIMOAMSET_BB + const BATTLEANIMOAMSET_BC + const BATTLEANIMOAMSET_BD + const BATTLEANIMOAMSET_BE + const BATTLEANIMOAMSET_BF + const BATTLEANIMOAMSET_C0 + const BATTLEANIMOAMSET_C1 + const BATTLEANIMOAMSET_C2 + const BATTLEANIMOAMSET_C3 + const BATTLEANIMOAMSET_C4 + const BATTLEANIMOAMSET_C5 + const BATTLEANIMOAMSET_C6 + const BATTLEANIMOAMSET_C7 + const BATTLEANIMOAMSET_C8 + const BATTLEANIMOAMSET_C9 + const BATTLEANIMOAMSET_CA + const BATTLEANIMOAMSET_CB + const BATTLEANIMOAMSET_CC + const BATTLEANIMOAMSET_CD + const BATTLEANIMOAMSET_CE + const BATTLEANIMOAMSET_CF + const BATTLEANIMOAMSET_D0 + const BATTLEANIMOAMSET_D1 + const BATTLEANIMOAMSET_D2 + const BATTLEANIMOAMSET_D3 + const BATTLEANIMOAMSET_D4 + const BATTLEANIMOAMSET_D5 + const BATTLEANIMOAMSET_D6 + const BATTLEANIMOAMSET_D7 + +; BattleBGEffects indexes (see engine/battle_anims/bg_effects.asm) + const_def 1 + const ANIM_BG_FLASH_INVERTED + const ANIM_BG_FLASH_WHITE + const ANIM_BG_WHITE_HUES + const ANIM_BG_BLACK_HUES + const ANIM_BG_ALTERNATE_HUES + const ANIM_BG_06 + const ANIM_BG_07 + const ANIM_BG_08 + const ANIM_BG_HIDE_MON + const ANIM_BG_SHOW_MON + const ANIM_BG_ENTER_MON + const ANIM_BG_RETURN_MON + const ANIM_BG_SURF + ;const ANIM_BG_WHIRLPOOL + const ANIM_BG_TELEPORT + const ANIM_BG_NIGHT_SHADE + const ANIM_BG_FEET_FOLLOW + const ANIM_BG_HEAD_FOLLOW + const ANIM_BG_DOUBLE_TEAM + const ANIM_BG_ACID_ARMOR + const ANIM_BG_RAPID_FLASH + const ANIM_BG_16 + const ANIM_BG_17 + const ANIM_BG_18 + const ANIM_BG_19 + const ANIM_BG_1A + const ANIM_BG_1B + const ANIM_BG_1C + const ANIM_BG_1D + const ANIM_BG_1E + const ANIM_BG_1F + const ANIM_BG_20 + const ANIM_BG_WITHDRAW + const ANIM_BG_BOUNCE_DOWN + const ANIM_BG_DIG + const ANIM_BG_TACKLE + ;const ANIM_BG_25 + const ANIM_BG_26 + const ANIM_BG_27 + const ANIM_BG_WAVE_DEFORM_USER + const ANIM_BG_PSYCHIC + const ANIM_BG_2A + const ANIM_BG_2B + const ANIM_BG_2C + const ANIM_BG_2D + const ANIM_BG_2E + const ANIM_BG_2F + ;const ANIM_BG_30 + ;const ANIM_BG_31 + ;const ANIM_BG_32 + ;const ANIM_BG_VIBRATE_MON + ;const ANIM_BG_WOBBLE_MON + ;const ANIM_BG_35 + +; AnimObjGFX indexes (see data/battle_anims/object_gfx.asm) + const_def 1 + const ANIM_GFX_HIT + const ANIM_GFX_CUT + const ANIM_GFX_FIRE + const ANIM_GFX_WATER + const ANIM_GFX_LIGHTNING + const ANIM_GFX_PLANT + const ANIM_GFX_SMOKE + const ANIM_GFX_EXPLOSION + const ANIM_GFX_ROCKS + const ANIM_GFX_ICE + const ANIM_GFX_POKE_BALL + const ANIM_GFX_POISON + const ANIM_GFX_BUBBLE + const ANIM_GFX_NOISE + const ANIM_GFX_POWDER + const ANIM_GFX_BEAM + const ANIM_GFX_SPEED + const ANIM_GFX_CHARGE + const ANIM_GFX_WIND + const ANIM_GFX_WHIP + const ANIM_GFX_EGG + const ANIM_GFX_ROPE + const ANIM_GFX_PSYCHIC + const ANIM_GFX_REFLECT + const ANIM_GFX_STATUS + const ANIM_GFX_SAND + const ANIM_GFX_WEB + const ANIM_GFX_HAZE + const ANIM_GFX_HORN + const ANIM_GFX_FLOWER + const ANIM_GFX_MISC + const ANIM_GFX_SKY_ATTACK + const ANIM_GFX_GLOBE + const ANIM_GFX_SHAPES + const ANIM_GFX_OBJECTS + const ANIM_GFX_SHINE + const ANIM_GFX_ANGELS + const ANIM_GFX_WAVE + const ANIM_GFX_AEROBLAST + +; battle_bg_effect struct members (see macros/wram.asm) + const_def + const BG_EFFECT_STRUCT_FUNCTION + const BG_EFFECT_STRUCT_JT_INDEX + const BG_EFFECT_STRUCT_BATTLE_TURN + const BG_EFFECT_STRUCT_03 + +; battle palettes + const_def + const PAL_BATTLE_BG_PLAYER ; 0 + const PAL_BATTLE_BG_ENEMY ; 1 + const PAL_BATTLE_BG_ENEMY_HP ; 2 + const PAL_BATTLE_BG_PLAYER_HP ; 3 + const PAL_BATTLE_BG_EXP ; 4 + const PAL_BATTLE_BG_5 ; 5 + const PAL_BATTLE_BG_6 ; 6 + const PAL_BATTLE_BG_TEXT ; 7 + +; animation object palettes + const_def + const PAL_BATTLE_OB_ENEMY ; 0 + const PAL_BATTLE_OB_PLAYER ; 1 + const PAL_BATTLE_OB_GRAY ; 2 + const PAL_BATTLE_OB_YELLOW ; 3 + const PAL_BATTLE_OB_RED ; 4 + const PAL_BATTLE_OB_GREEN ; 5 + const PAL_BATTLE_OB_BLUE ; 6 + const PAL_BATTLE_OB_BROWN ; 7 diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc index 0cc8d67..691a072 100644 --- a/data/predef_pointers.inc +++ b/data/predef_pointers.inc @@ -84,10 +84,10 @@ GiveItemPredef:: add_predef Function_145b8 add_predef Function_146dc add_predef Function_145de - add_predef Function_c8000 + add_predef ExecuteBGEffects add_predef Function_1457a add_predef Function_143e0 - add_predef Function_9695 + add_predef CheckSGB add_predef Function_928b add_predef Function_8786 add_predef Function_8c4be diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm new file mode 100644 index 0000000..c8e42f2 --- /dev/null +++ b/engine/battle_anims/bg_effects.asm @@ -0,0 +1,2376 @@ +include "constants.asm" + +SECTION "Battle Anims BG Effects", ROMX [$4000], BANK [$32] + + const_def + const BGSQUARE_SIX + const BGSQUARE_FOUR + const BGSQUARE_TWO + const BGSQUARE_SEVEN + const BGSQUARE_FIVE + const BGSQUARE_THREE + +; BG effects for use in battle animations. + +ExecuteBGEffects: ; c8000 (32:4000) + ld hl, wActiveBGEffects + ld e, 5 +.loop + ld a, [hl] + and a + jr z, .next + ld c, l + ld b, h + push hl + push de + call DoBattleBGEffectFunction + pop de + pop hl +.next + ld bc, 4 + add hl, bc + dec e + jr nz, .loop + ret + +QueueBGEffect: ; c801a (32:401a) + ld hl, wActiveBGEffects + ld e, 5 +.loop + ld a, [hl] + and a + jr z, .load + ld bc, 4 + add hl, bc + dec e + jr nz, .loop + scf + ret + +.load + ld c, l + ld b, h + ld hl, BG_EFFECT_STRUCT_FUNCTION + add hl, bc + ld a, [wBattleAnimTemp0] + ld [hli], a + ld a, [wBattleAnimTemp1] + ld [hli], a + ld a, [wBattleAnimTemp2] + ld [hli], a + ld a, [wBattleAnimTemp3] + ld [hl], a + ret + +EndBattleBGEffect: ; c8043 (32:4043) + ld hl, BG_EFFECT_STRUCT_FUNCTION + add hl, bc + ld [hl], 0 + ret + +DoBattleBGEffectFunction: ; c804a (32:404a) + ld hl, BG_EFFECT_STRUCT_FUNCTION + add hl, bc + ld e, [hl] + ld d, 0 + ld hl, BattleBGEffects + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +BattleBGEffects: ; c805a (32:405a) +; entries correspond to ANIM_BG_* constants + dw BattleBGEffect_End + dw BattleBGEffect_FlashInverted + dw BattleBGEffect_FlashWhite + dw BattleBGEffect_WhiteHues + dw BattleBGEffect_BlackHues + dw BattleBGEffect_AlternateHues + dw BattleBGEffect_06 + dw BattleBGEffect_07 + dw BattleBGEffect_08 + dw BattleBGEffect_HideMon + dw BattleBGEffect_ShowMon + dw BattleBGEffect_EnterMon + dw BattleBGEffect_ReturnMon + dw BattleBGEffect_Surf + ;dw BattleBGEffect_Whirlpool + dw BattleBGEffect_Teleport + dw BattleBGEffect_NightShade + dw BattleBGEffect_FeetFollow + dw BattleBGEffect_HeadFollow + dw BattleBGEffect_DoubleTeam + dw BattleBGEffect_AcidArmor + dw BattleBGEffect_RapidFlash + dw BattleBGEffect_16 + dw BattleBGEffect_17 + dw BattleBGEffect_18 + dw BattleBGEffect_19 + dw BattleBGEffect_1a + dw BattleBGEffect_1b + dw BattleBGEffect_1c + dw BattleBGEffect_1d + dw BattleBGEffect_1e + dw BattleBGEffect_1f + dw BattleBGEffect_20 + dw BattleBGEffect_Withdraw + dw BattleBGEffect_BounceDown + dw BattleBGEffect_Dig + dw BattleBGEffect_Tackle + ;dw BattleBGEffect_25 + dw BattleBGEffect_26 + dw BattleBGEffect_27 + dw BattleBGEffect_28 + dw BattleBGEffect_Psychic + dw BattleBGEffect_2a + dw BattleBGEffect_2b + dw BattleBGEffect_2c + dw BattleBGEffect_2d + dw BattleBGEffect_2e + dw BattleBGEffect_2f + ;dw BattleBGEffect_30 + ;dw BattleBGEffect_31 + ;dw BattleBGEffect_32 + ;dw BattleBGEffect_VibrateMon + ;dw BattleBGEffect_WobbleMon + + +BattleBGEffect_End: ; c80c6 (32:40c6) + call EndBattleBGEffect + ret + +BattleBGEffects_AnonJumptable: ; c80d7 (32:40d7) + ld hl, sp+$0 + ld e, [hl] + inc hl + ld d, [hl] + inc de +BatttleBGEffects_GetNamedJumptablePointer: ; c80ca (32:40ca) + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld l, [hl] + ld h, 0 + add hl, hl + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + ret + +BattleBGEffects_IncrementJumptable: ; c80e5 (32:40e5) + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + inc [hl] + ret + +BattleBGEffect_FlashInverted: ; c80eb (32:40eb) + ld de, .inverted + call BattleBGEffect_FlashContinue + ret + +.inverted + db %11100100 ; 3210 + db %00011011 ; 0123 +; c80f3 + +BattleBGEffect_FlashWhite: ; c80f3 (32:40f3) + ld de, .white + call BattleBGEffect_FlashContinue + ret + +.white + db %11100100 ; 3210 + db %00000000 ; 0000 +; c80fb + +BattleBGEffect_FlashContinue: ; c80fb (32:40fb) +; current timer, flash duration, number of flashes + ld a, $1 + ld [wBattleAnimTemp0], a + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld a, [hl] + and a + jr z, .init + dec [hl] + ret + +.init + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld [hl], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and a + jr nz, .apply_pal + call EndBattleBGEffect + ret + +.apply_pal + dec a + ld [hl], a + and 1 + ld l, a + ld h, 0 + add hl, de + ld a, [hl] + ld [wBGP], a + ret + +BattleBGEffect_WhiteHues: ; c812d (32:412d) + ld de, .Pals + call BattleBGEffect_GetNthDMGPal + jr c, .quit + ld [wBGP], a + ret + +.quit + call EndBattleBGEffect + ret + +.Pals: + db %11100100 + db %11100000 + db %11010000 + db -1 +; c8141 + +BattleBGEffect_BlackHues: ; c8141 (32:4141) + ld de, .Pals + call BattleBGEffect_GetNthDMGPal + jr c, .quit + ld [wBGP], a + ret + +.quit + call EndBattleBGEffect + ret + +.Pals: + db %11100100 + db %11110100 + db %11111000 + db -1 +; c8155 + +BattleBGEffect_AlternateHues: ; c8155 (32:4155) + ld de, .Pals + call BattleBGEffect_GetNthDMGPal + jr c, .quit + ld [wBGP], a + ld [wOBP1], a + ret + +.quit + call EndBattleBGEffect + ret + +.Pals: + db %11100100 + db %11111000 + db %11111100 + db %11111000 + db %11100100 + db %10010000 + db %01000000 + db %10010000 + db -2 +; c8171 + +BattleBGEffect_06: ; c8171 (32:4171) + call BattleBGEffects_CheckSGB + jr nz, .sgb + ld de, .PalsCGB + jr .okay + +.sgb + ld de, .PalsSGB +.okay + call BattleBGEffect_GetNthDMGPal + ld [wOBP0], a + ret + +.PalsCGB: + db %11100100 + db %10010000 + db -2 + +.PalsSGB: + db %11110000 + db %11000000 + db -2 +; c818b + +BattleBGEffect_07: ; c818b (32:418b) + call BattleBGEffects_CheckSGB + jr nz, .sgb + ld de, .PalsCGB + jr .okay + +.sgb + ld de, .PalsSGB +.okay + call BattleBGEffect_GetNthDMGPal + ld [wOBP0], a + ret + +.PalsCGB: + db %11100100 + db %11011000 + db -2 + +.PalsSGB: + db %11110000 + db %11001100 + db -2 +; c81a5 + +BattleBGEffect_08: ; c81a5 (32:41a5) + ld de, .Pals + call BattleBGEffect_GetNthDMGPal + ld [wBGP], a + ret + +.Pals: + db %00011011 + db %01100011 + db %10000111 + db -2 +; c81b3 + +BattleBGEffect_HideMon: ; c81b3 (32:41b3) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw .four + + +.zero + call BattleBGEffects_IncrementJumptable + push bc + call BGEffect_CheckBattleTurn + jr nz, .player_side + hlcoord 12, 0 + lb bc, 7, 7 + jr .got_pointer + +.player_side + hlcoord 2, 6 + lb bc, 6, 6 +.got_pointer + call ClearBox + pop bc + ld a, $1 + ldh [hBGMapMode], a + ret + +.four + xor a + ldh [hBGMapMode], a + call EndBattleBGEffect + ret + +BattleBGEffect_ShowMon: ; c81ea (32:41ea) + call BGEffect_CheckFlyDigStatus + jr z, .not_flying + call EndBattleBGEffect + ret + +.not_flying + call BGEffect_CheckBattleTurn + jr nz, .player_side + ld de, .EnemyData + jr .got_pointer + +.player_side + ld de, .PlayerData +.got_pointer + ld a, e + ld [wBattleAnimTemp1], a + ld a, d + ld [wBattleAnimTemp2], a + call BattleBGEffect_RunPicResizeScript + ret + +.PlayerData: + db 0, $31, 0 + db -1 +.EnemyData: + db 3, $00, 3 + db -1 +; c8214 + +BattleBGEffect_FeetFollow: ; c8214 (32:4214) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw .five + + +.zero + call BGEffect_CheckFlyDigStatus + jr z, .not_flying_digging + call EndBattleBGEffect + ret + +.not_flying_digging + call BattleBGEffects_IncrementJumptable + push bc + call BGEffect_CheckBattleTurn + jr nz, .player_turn + ld a, ANIM_OBJ_PLAYERFEETFOLLOW + ld [wBattleAnimTemp0], a + ld a, 16 * 8 + 4 + jr .okay + +.player_turn + ld a, ANIM_OBJ_ENEMYFEETFOLLOW + ld [wBattleAnimTemp0], a + ld a, 6 * 8 +.okay + ld [wBattleAnimTemp1], a + ld a, 8 * 8 + ld [wBattleAnimTemp2], a + xor a + ld [wBattleAnimTemp3], a + call _QueueBattleAnimation + pop bc + ret + +.one + call BattleBGEffects_IncrementJumptable + push bc + call BGEffect_CheckBattleTurn + jr nz, .player_turn_2 + hlcoord 12, 6 + lb bc, 1, 7 + jr .okay2 + +.player_turn_2 + hlcoord 2, 6 + lb bc, 1, 6 +.okay2 + call ClearBox + ld a, $1 + ldh [hBGMapMode], a + pop bc + ret + +.five + xor a + ldh [hBGMapMode], a + call EndBattleBGEffect + ret + +BattleBGEffect_HeadFollow: ; c8281 (32:4281) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw .five + + +.zero + call BGEffect_CheckFlyDigStatus + jr z, .not_flying_digging + call EndBattleBGEffect + ret + +.not_flying_digging + call BattleBGEffects_IncrementJumptable + push bc + call BGEffect_CheckBattleTurn + jr nz, .player_turn + ld a, ANIM_OBJ_PLAYERHEADFOLLOW + ld [wBattleAnimTemp0], a + ld a, 16 * 8 + 4 + jr .okay + +.player_turn + ld a, ANIM_OBJ_ENEMYHEADFOLLOW + ld [wBattleAnimTemp0], a + ld a, 6 * 8 +.okay + ld [wBattleAnimTemp1], a + ld a, 8 * 8 + ld [wBattleAnimTemp2], a + xor a + ld [wBattleAnimTemp3], a + call _QueueBattleAnimation + pop bc + ret + +.one + call BattleBGEffects_IncrementJumptable + push bc + call BGEffect_CheckBattleTurn + jr nz, .player_turn_2 + hlcoord 12, 5 + lb bc, 2, 7 + jr .okay2 + +.player_turn_2 + hlcoord 2, 6 + lb bc, 2, 6 +.okay2 + call ClearBox + ld a, $1 + ldh [hBGMapMode], a + pop bc + ret + +.five + xor a + ldh [hBGMapMode], a + call EndBattleBGEffect + ret + +_QueueBattleAnimation: ; c82ee (32:42ee) + callfar QueueBattleAnimation + ret + +BattleBGEffect_27: ; c82f5 (32:42f5) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw .four + + +.zero + call BattleBGEffects_IncrementJumptable + call BGEffect_CheckBattleTurn + ld [hl], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $8 + ret + +.one + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + and a + jr z, .user_2 + hlcoord 0, 6 + lb de, 8, 6 +.row1 + push de + push hl +.col1 + inc hl + ld a, [hld] + ld [hli], a + dec d + jr nz, .col1 + pop hl + ld de, SCREEN_WIDTH + add hl, de + pop de + dec e + jr nz, .row1 + jr .okay2 + +.user_2 + hlcoord 19, 0 + lb de, 8, 7 +.row2 + push de + push hl +.col2 + dec hl + ld a, [hli] + ld [hld], a + dec d + jr nz, .col2 + pop hl + ld de, SCREEN_WIDTH + add hl, de + pop de + dec e + jr nz, .row2 +.okay2 + ld a, $1 + ldh [hBGMapMode], a + call BattleBGEffects_IncrementJumptable + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + dec [hl] + ret + +.four + xor a + ldh [hBGMapMode], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and a + jr z, .done + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld [hl], $1 + ret + +.done + call EndBattleBGEffect + ret + +BattleBGEffect_EnterMon: ; c837b (32:437b) + call BGEffect_CheckBattleTurn + jr nz, .player_turn + ld de, .EnemyData + jr .okay + +.player_turn + ld de, .PlayerData +.okay + ld a, e + ld [wBattleAnimTemp1], a + ld a, d + ld [wBattleAnimTemp2], a + call BattleBGEffect_RunPicResizeScript + ret + +.PlayerData: + db 2, $31, 2 + db 1, $31, 1 + db 0, $31, 0 + db -1 +.EnemyData: + db 5, $00, 5 + db 4, $00, 4 + db 3, $00, 3 + db -1 +; c83a8 + +BattleBGEffect_ReturnMon: ; c83a8 (32:43a8) + call BGEffect_CheckBattleTurn + jr nz, .player_turn + ld de, .EnemyData + jr .okay + +.player_turn + ld de, .PlayerData +.okay + ld a, e + ld [wBattleAnimTemp1], a + ld a, d + ld [wBattleAnimTemp2], a + call BattleBGEffect_RunPicResizeScript + ret + +.PlayerData: + db 0, $31, 0 + db -2, $66, 0 + db 1, $31, 1 + db -2, $44, 1 + db 2, $31, 2 + db -2, $22, 2 + db -3, $00, 0 + db -1 +.EnemyData: + db 3, $00, 3 + db -2, $77, 3 + db 4, $00, 4 + db -2, $55, 4 + db 5, $00, 5 + db -2, $33, 5 + db -3, $00, 0 + db -1 +; c83ed + +BattleBGEffect_RunPicResizeScript: ; c83ed (32:43ed) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw BattleBGEffects_IncrementJumptable + dw .restart + dw .end + + +.zero + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld e, [hl] + ld d, $0 + inc [hl] + ld a, [wBattleAnimTemp1] + ld l, a + ld a, [wBattleAnimTemp2] + ld h, a + add hl, de + add hl, de + add hl, de + ld a, [hl] + cp -1 + jr z, .end + cp -2 + jr z, .clear + cp -3 + jr z, .skip + call .PlaceGraphic +.skip + call BattleBGEffects_IncrementJumptable + ld a, $1 + ldh [hBGMapMode], a + ret + +.clear + call .ClearBox + jr .zero + +.restart + xor a + ldh [hBGMapMode], a + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld [hl], $0 + ret + +.end + xor a + ldh [hBGMapMode], a + call EndBattleBGEffect + ret + +.ClearBox: +; get dims + push bc + inc hl + ld a, [hli] + ld b, a + and $f + ld c, a + ld a, b + swap a + and $f + ld b, a +; get coords + ld e, [hl] + ld d, 0 + ld hl, .Coords + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call ClearBox + pop bc + ret + +.PlaceGraphic: +; get dims + push bc + push hl + ld e, [hl] + ld d, 0 + ld hl, .BGSquares + add hl, de + add hl, de + add hl, de + ld a, [hli] + ld b, a + and $f + ld c, a + ld a, b + swap a + and $f + ld b, a +; store pointer + ld e, [hl] + inc hl + ld d, [hl] +; get byte + pop hl + inc hl + ld a, [hli] + ld [wBattleAnimTemp0], a +; get coord + push de + ld e, [hl] + ld d, 0 + ld hl, .Coords + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + pop de +; fill box +.row + push bc + push hl + ld a, [wBattleAnimTemp0] + ld b, a +.col + ld a, [de] + add b + ld [hli], a + inc de + dec c + jr nz, .col + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + pop bc + ret + +.Coords: + dwcoord 2, 6 + dwcoord 3, 8 + dwcoord 4, 10 + dwcoord 12, 0 + dwcoord 13, 2 + dwcoord 14, 4 + +.BGSquares: +bgsquare: MACRO + dn \1, \2 + dw \3 +ENDM + + bgsquare 6, 6, .SixBySix + bgsquare 4, 4, .FourByFour + bgsquare 2, 2, .TwoByTwo + bgsquare 7, 7, .SevenBySeven + bgsquare 5, 5, .FiveByFive + bgsquare 3, 3, .ThreeByThree + +.SixBySix: + db $00, $06, $0c, $12, $18, $1e + db $01, $07, $0d, $13, $19, $1f + db $02, $08, $0e, $14, $1a, $20 + db $03, $09, $0f, $15, $1b, $21 + db $04, $0a, $10, $16, $1c, $22 + db $05, $0b, $11, $17, $1d, $23 + +.FourByFour: + db $00, $0c, $12, $1e + db $02, $0e, $14, $20 + db $03, $0f, $15, $21 + db $05, $11, $17, $23 + +.TwoByTwo: + db $00, $1e + db $05, $23 + +.SevenBySeven: + db $00, $07, $0e, $15, $1c, $23, $2a + db $01, $08, $0f, $16, $1d, $24, $2b + db $02, $09, $10, $17, $1e, $25, $2c + db $03, $0a, $11, $18, $1f, $26, $2d + db $04, $0b, $12, $19, $20, $27, $2e + db $05, $0c, $13, $1a, $21, $28, $2f + db $06, $0d, $14, $1b, $22, $29, $30 + +.FiveByFive: + db $00, $07, $15, $23, $2a + db $01, $08, $16, $24, $2b + db $03, $0a, $18, $26, $2d + db $05, $0c, $1a, $28, $2f + db $06, $0d, $1b, $29, $30 + +.ThreeByThree: + db $00, $15, $2a + db $03, $18, $2d + db $06, $1b, $30 +; c8545 + +BattleBGEffect_Surf: ; c8545 (32:4545) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + + +.zero + call BattleBGEffects_IncrementJumptable + lb de, 4, 1 + call InitSurfWaves + +.one + ldh a, [hLCDCPointer] + and a + ret z + push bc + call .RotatewSurfWaveBGEffect + pop bc + ret + +.RotatewSurfWaveBGEffect: + ld hl, wLYOverrides + ld de, wLYOverrides2 + 1 +.asm_c853e: + ld bc, wLYOverrides2 + ld a, [bc] + push af + ld a, $7f +.asm_c8545: + push af + ld a, [de] +.asm_c8547: + ld [bc], a + ldh a, [hLYOverrideStart] + cp l + jr nc, .asm_c8555 + ldh a, [hLYOverrideEnd] + cp l + jr c, .asm_c8555 + ld a, [de] + jr .asm_c8556 + +.asm_c8555: + xor a +.asm_c8556: + ld [hli], a + inc de + inc bc + pop af + dec a + jr nz, .asm_c8545 + pop af + ld [bc], a + ret + +BattleBGEffect_Psychic: ; c8607 (32:4607) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + ldh [hLCDCPointer], a + xor a + ldh [hLYOverrideStart], a + ld a, $5f + ldh [hLYOverrideEnd], a + lb de, 6, 5 + call Functionc8f2e + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + inc [hl] + and $3 + ret nz + call BattleBGEffect_WavyScreenFX + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_Teleport: ; c863f (32:463f) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + lb de, 6, 5 + call Functionc8f2e + ret + +.one + call BattleBGEffect_WavyScreenFX + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_NightShade: ; c8662 (32:4662) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCY) + call BattleBGEffect_SetLCDStatCustoms + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld e, [hl] + ld d, 3 + call Functionc8f2e + ret + +.one + call BattleBGEffect_WavyScreenFX + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_DoubleTeam: ; c8689 (32:4689) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + dw .three + dw .four + dw .five + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], $0 + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + cp $10 + jr nc, .next + inc [hl] + call .UpdateLYOverrides + ret + +.three + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + cp $ff + jr z, .next + dec [hl] + call .UpdateLYOverrides + ret + +.next + call BattleBGEffects_IncrementJumptable + ret + +.two + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + ld d, $2 + call BattleBGEffects_Sine + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + add [hl] + call .UpdateLYOverrides + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + add $4 + ld [hl], a + +.four + ret + +.UpdateLYOverrides: + ld e, a + xor $ff + inc a + ld d, a + ld h, HIGH(wLYOverrides) + ldh a, [hLYOverrideStart] + ld l, a + ldh a, [hLYOverrideEnd] + sub l + srl a +.loop + ld [hl], e + inc hl + ld [hl], d + inc hl + dec a + jr nz, .loop + ld [hl], e + ret + +.five + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_AcidArmor: ; c8709 (32:4709) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCY) + call BattleBGEffect_SetLCDStatCustoms + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld e, [hl] + ld d, 3 + call Functionc8f2e + ret + +.one + ldh a, [hLYOverrideEnd] + ld l, a + ld h, HIGH(wLYOverrides) + ld e, l + ld d, h + dec de +.loop + ld a, [de] + dec de + ld [hld], a + ldh a, [hLYOverrideStart] + cp l + jr nz, .loop + ld [hl], $90 + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_Withdraw: ; c8761 (32:4761) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCY) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], $1 + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and $3f + ld d, a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + cp d + ret nc + call BGEffect_DisplaceLYOverridesBackup + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + rlca + rlca + and $3 + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + add [hl] + ld [hl], a + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_Dig: ; c87a7 (32:47a7) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + dw .three + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCY) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], $2 + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and a + jr z, .next + dec [hl] + ret + +.next + ld [hl], $10 + call BattleBGEffects_IncrementJumptable +.two + ldh a, [hLYOverrideStart] + ld l, a + ldh a, [hLYOverrideEnd] + sub l + dec a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + cp [hl] + ret c + ld a, [hl] + push af + and $7 + jr nz, .skip + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + dec [hl] +.skip + pop af + call BGEffect_DisplaceLYOverridesBackup + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + inc [hl] + inc [hl] + ret + +.three + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_Tackle: ; c8805 (32:4805) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw Tackle_BGEffect25_2d_one + dw Tackle_BGEffect25_2d_two + dw .three + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + call BGEffect_CheckBattleTurn + jr nz, .player_side + ld a, 2 + jr .okay + +.player_side + ld a, -2 +.okay + ld [hl], a + ret + +.three + call BattleAnim_ResetLCDStatCustom + ret + +Tackle_BGEffect25_2d_one: + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + cp -8 + jr z, .reached_limit + cp 8 + jr nz, .finish +.reached_limit + call BattleBGEffects_IncrementJumptable +.finish + call Functionc88a5 + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + add [hl] + ld [hl], a + ret + +Tackle_BGEffect25_2d_two: + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and a + jr nz, .asm_c8893 + call BattleBGEffects_IncrementJumptable +.asm_c8893 + call Functionc88a5 + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + xor $ff + inc a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + add [hl] + ld [hl], a + ret + +Functionc88a5: ; c88a5 (32:48a5) + push af +.asm_c87ab: + ld a, [rLY] + cp $60 + jr c, .asm_c87ab + pop af + call BGEffect_FillLYOverridesBackup + ret + +BattleBGEffect_2d: ; c88e7 (32:48e7) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw BGEffect2d_2f_zero + dw Tackle_BGEffect25_2d_one + dw Tackle_BGEffect25_2d_two + dw .three + + +.three + call BattleAnim_ResetLCDStatCustom + ret + +BGEffect2d_2f_zero: + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + call BGEffect_CheckBattleTurn + jr nz, .player_turn + ld a, -2 + jr .okay + +.player_turn + ld a, 2 +.okay + ld [hl], a + ret + +BattleBGEffect_2f: ; c8919 (32:4919) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw BGEffect2d_2f_zero + dw Tackle_BGEffect25_2d_one + dw .two + dw Tackle_BGEffect25_2d_two + dw .four + +.four + call BattleAnim_ResetLCDStatCustom +.two + ret + +BattleBGEffect_26: ; c892a (32:492a) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + ld d, $8 + call BattleBGEffects_Sine + call .Functionc8836 + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + add $4 + ld [hl], a + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +.Functionc8836: + push af +.loop + ld a, [rLY] + cp $60 + jr c, .loop + pop af + call BGEffect_FillLYOverridesBackup + ret + +BattleBGEffect_2c: ; c8964 (32:4964) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + xor a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hli], a + ld [hl], a + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + ld d, $6 + call BattleBGEffects_Sine + push af + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + ld d, $2 + call BattleBGEffects_Sine + ld e, a + pop af + add e + call .Functionc8894 + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + add $8 + ld [hl], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + add $2 + ld [hl], a + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +.Functionc8894: + push af +.asm_c8895: + ld a, [rLY] + cp $60 + jr c, .asm_c8895 + pop af + call BGEffect_FillLYOverridesBackup + ret + +BattleBGEffect_28: ; c89b5 (32:49b5) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + cp $20 + ret nc + inc [hl] + ld d, a + ld e, 4 + call Functionc8f2e + ret + +.two + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and a + jr z, .reset + dec [hl] + ld d, a + ld e, 4 + call Functionc8f2e + ret + +.reset + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_BounceDown: ; c89ee (32:49ee) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCY) + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], $1 + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $20 + ret + +.one + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + cp $38 + ret nc + push af + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + ld d, $10 + call BattleBGEffects_Cosine + add $10 + ld d, a + pop af + add d + call BGEffect_DisplaceLYOverridesBackup + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + inc [hl] + inc [hl] + ret + +.two + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_2a: ; c8a3a (32:4a3a) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + dw .three + dw .four + dw .five + +.zero + call BattleBGEffects_IncrementJumptable + ld a, $e4 + call BattleBGEffects_SetLYOverrides + ld a, $47 + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ldh a, [hLYOverrideStart] + ld l, a + ld h, HIGH(wLYOverrides) +.loop + ldh a, [hLYOverrideEnd] + cp l + jr z, .done + xor a + ld [hli], a + jr .loop + +.done + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 +.one +.four + ret + +.two + call .GetLYOverride + jr nc, .next + call .SetLYOverridesBackup + ret + +.next + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 + ldh a, [hLYOverrideStart] + inc a + ldh [hLYOverrideStart], a + call BattleBGEffects_IncrementJumptable + ret + +.three + call .GetLYOverride + jr nc, .finish + call .SetLYOverridesBackup + ldh a, [hLYOverrideEnd] + dec a + ld l, a + ld [hl], e + ret + +.finish + call BattleBGEffects_IncrementJumptable + ret + +.SetLYOverridesBackup: + ld e, a + ldh a, [hLYOverrideStart] + ld l, a + ldh a, [hLYOverrideEnd] + sub l + srl a + ld h, HIGH(wLYOverrides) +.loop2 + ld [hl], e + inc hl + inc hl + dec a + jr nz, .loop2 + ret + +.five + call BattleBGEffects_ResetVideoHRAM + ret + +.GetLYOverride: + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + inc [hl] + srl a + srl a + srl a + ld e, a + ld d, 0 + ld hl, .data + add hl, de + ld a, [hl] + cp $ff + ret + +.data + db $00, $40, $90, $e4 + db -1 +; c8acc + +BattleBGEffect_2b: ; c8acc (32:4acc) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + + +.zero + call BattleBGEffects_IncrementJumptable + call BattleBGEffects_ClearLYOverrides + ld a, LOW(rSCX) + call BattleBGEffect_SetLCDStatCustoms + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], $40 + ret + +.one + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + and a + jr z, .done + dec [hl] + srl a + srl a + srl a + and $f + ld d, a + ld e, a + call Functionc8f2e + ret + +.done + call BattleAnim_ResetLCDStatCustom + ret + +BattleBGEffect_1c: ; c8b00 (32:4b00) + call BattleBGEffects_AnonJumptable + jp hl +.anon_dw + dw .zero + dw .one + dw .two + + +.zero + call BattleBGEffects_IncrementJumptable + ld a, $e4 + call BattleBGEffects_SetLYOverrides + ld a, LOW(rBGP) + ldh [hLCDCPointer], a + xor a + ldh [hLYOverrideStart], a + ld a, $60 + ldh [hLYOverrideEnd], a + ret + +.one + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + inc [hl] + and $18 + srl a + srl a + ld e, a + ld d, $0 + push bc + call BGEffect_CheckBattleTurn + jr nz, .player + ld hl, .CGB_DMGEnemyData + add hl, de + ld a, [hli] + ld [wOBP1], a + ld d, a + ld e, [hl] + lb bc, $2f, $30 + jr .okay + +.player + ld hl, .DMG_PlayerData + add hl, de + ld d, [hl] + inc hl + ld a, [hl] + ld [wOBP1], a + ld e, a + lb bc, $37, $28 +.okay + call .DMG_LYOverrideLoads + pop bc + ret + +.two + call BattleBGEffects_ResetVideoHRAM + ld a, $e4 + ld [wBGP], a + ld [wOBP1], a + ret + +.DMG_LYOverrideLoads: + ld hl, wLYOverrides +.loop1 + ld [hl], d + inc hl + dec b + jr nz, .loop1 +.loop2 + ld [hl], e + inc hl + dec c + jr nz, .loop2 + ret + +.CGB_DMGEnemyData: + db $e4, $e4 + db $f8, $90 + db $fc, $40 + db $f8, $90 +.DMG_PlayerData: + db $e4, $e4 + db $90, $f8 + db $40, $fc + db $90, $f8 +; c8be8 + +BattleBGEffect_RapidFlash: ; c8be8 (32:4be8) + ld de, .FlashPals + call BGEffect_RapidCyclePals + ret + +.FlashPals: + db $e4, $6c, $fe +; c8bf2 + +BattleBGEffect_16: ; c8bf2 (32:4bf2) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $90, $40, $ff +; c8bfd + +BattleBGEffect_17: ; c8bfd (32:4bfd) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $f8, $fc, $ff +; c8c08 + +BattleBGEffect_18: ; c8c08 (32:4c08) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $90, $40, $90, $fe +; c8c14 + +BattleBGEffect_19: ; c8c14 (32:4c14) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $f8, $fc, $f8, $fe +; c8c20 + +BattleBGEffect_1a: ; c8c20 (32:4c20) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $f8, $fc, $f8, $e4, $90, $40, $90, $fe +; c8c30 + +BattleBGEffect_1b: ; c8c30 (32:4c30) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $fc, $e4, $00, $fe +; c8c3c + +BattleBGEffect_1d: ; c8c3c (32:4c3c) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $e4, $90, $40, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $40, $90, $e4, $ff +; c8c55 + +BattleBGEffect_1e: ; c8c55 (32:4c55) + ld de, .Pals + call BGEffect_RapidCyclePals + ret + +.Pals: + db $00, $40, $90, $e4, $ff +; c8c61 + +BattleBGEffect_2e: ; c8ce1 (32:4ce1) + call Functionc8d0b + jr c, .xor_a + bit 7, a + jr z, .okay +.xor_a + xor a +.okay + ldh [hSCY], a + xor $ff + inc a + ld [$c753], a ; wAnimObject01YOffset + ret + +BattleBGEffect_1f: ; c8cf9 (32:4cf9) + call Functionc8d0b + jr nc, .skip + xor a +.skip + ldh [hSCX], a + ret + +BattleBGEffect_20: ; c8d02 (32:4d02) + call Functionc8d0b + jr nc, .skip + xor a +.skip + ldh [hSCY], a + ret + +Functionc8d0b: ; c8d0b (32:4d0b) + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld a, [hl] + and a + jr nz, .okay + call EndBattleBGEffect + scf + ret + +.okay + dec [hl] + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + and $f + jr z, .every_16_frames + dec [hl] + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + and a + ret + +.every_16_frames + ld a, [hl] + swap a + or [hl] + ld [hl], a + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + xor $ff + inc a + ld [hl], a + and a + ret + +BattleBGEffect_GetNthDMGPal: ; c8d57 (32:4d57) + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld a, [hl] + and a + jr z, .zero + dec [hl] + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + call BattleBGEffect_GetNextDMGPal + ret + +.zero + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + ld hl, BG_EFFECT_STRUCT_JT_INDEX + add hl, bc + ld [hl], a + call BattleBGEffect_GetFirstDMGPal + ret + +BGEffect_RapidCyclePals: ; c8d77 (32:4d77) + push de + ld de, .Jumptable_DMG + call BatttleBGEffects_GetNamedJumptablePointer + pop de + jp hl + +.Jumptable_DMG: + dw .zero_dmg + dw .one_dmg + dw .two_dmg + + +.zero_dmg ; c8d8b (32:4d8b) + call BattleBGEffects_IncrementJumptable + ld a, $e4 + call BattleBGEffects_SetLYOverrides + ld a, $47 + call BattleBGEffect_SetLCDStatCustoms + ldh a, [hLYOverrideEnd] + inc a + ldh [hLYOverrideEnd], a + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + ld [hl], $0 + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld [hl], a + ret + +.one_dmg ; c8daa (32:4daa) + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ld a, [hl] + and $f + jr z, .okay_1_dmg + dec [hl] + ret + +.okay_1_dmg + ld a, [hl] + swap a + or [hl] + ld [hl], a + call BattleBGEffect_GetFirstDMGPal + jr c, .okay_2_dmg + call BGEffect_FillLYOverridesBackup + ret + +.okay_2_dmg + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + dec [hl] + ret + +.two_dmg ; c8dc9 (32:4dc9) + call BattleBGEffects_ResetVideoHRAM + ld a, %11100100 + ld [rBGP], a + call EndBattleBGEffect + ret + +BattleBGEffect_GetFirstDMGPal: ; c8eac (32:4eac) + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld a, [hl] + inc [hl] +BattleBGEffect_GetNextDMGPal: ; c8eb2 (32:4eb2) + ld l, a + ld h, $0 + add hl, de + ld a, [hl] + cp -1 + jr z, .quit + cp -2 + jr nz, .repeat + ld a, [de] + ld hl, BG_EFFECT_STRUCT_03 + add hl, bc + ld [hl], $0 +.repeat + and a + ret + +.quit + scf + ret + +BattleBGEffects_ClearLYOverrides: ; c8eca (32:4eca) + xor a +BattleBGEffects_SetLYOverrides: ; c8ecb (32:4ecb) + ld hl, wLYOverrides + ld e, $91 +.loop + ld [hli], a + dec e + jr nz, .loop + ret + +BattleBGEffect_SetLCDStatCustoms: ; c8ede (32:4ede) + ldh [hLCDCPointer], a + call BGEffect_CheckBattleTurn + jr nz, .player_turn + lb de, $00, $36 + jr .okay + +.player_turn + lb de, $2f, $5e +.okay + ld a, d + ldh [hLYOverrideStart], a + ld a, e + ldh [hLYOverrideEnd], a + ret + +BattleAnim_ResetLCDStatCustom: ; c8f0a (32:4f0a) + xor a + ldh [hLYOverrideStart], a + ldh [hLYOverrideEnd], a + call BattleBGEffects_ClearLYOverrides + xor a + ldh [hLCDCPointer], a + call EndBattleBGEffect + ret + +BattleBGEffects_ResetVideoHRAM: ; c8f19 (32:4f19) + xor a + ldh [hLCDCPointer], a + ldh [hLYOverrideStart], a + ldh [hLYOverrideEnd], a + call BattleBGEffects_ClearLYOverrides + ret + +Functionc8f2e: ; c8f2e (32:4f2e) + push bc + xor a + ld [wBattleAnimTemp0], a + ld a, e + ld [wBattleAnimTemp1], a + ld a, d + ld [wBattleAnimTemp2], a + ld a, $80 + ld [wBattleAnimTemp3], a + ld bc, wLYOverrides +.loop + ldh a, [hLYOverrideStart] + cp c + jr nc, .next + ldh a, [hLYOverrideEnd] + cp c + jr c, .next + ld a, [wBattleAnimTemp2] + ld d, a + ld a, [wBattleAnimTemp0] + call BattleBGEffects_Sine + ld [bc], a +.next + inc bc + ld a, [wBattleAnimTemp1] + ld hl, wBattleAnimTemp0 + add [hl] + ld [hl], a + ld hl, wBattleAnimTemp3 + dec [hl] + jr nz, .loop + pop bc + ret + +InitSurfWaves: ; c8f69 (32:4f69) + push bc + xor a + ld [wBattleAnimTemp0], a + ld a, e + ld [wBattleAnimTemp1], a + ld a, d + ld [wBattleAnimTemp2], a + ld a, $80 + ld [wBattleAnimTemp3], a + ld bc, wLYOverrides2 +.loop + ld a, [wBattleAnimTemp2] + ld d, a + ld a, [wBattleAnimTemp0] + call BattleBGEffects_Sine + ld [bc], a + inc bc + ld a, [wBattleAnimTemp1] + ld hl, wBattleAnimTemp0 + add [hl] + ld [hl], a + ld hl, wBattleAnimTemp3 + dec [hl] + jr nz, .loop + pop bc + ret + +BattleBGEffect_WavyScreenFX: ; c8fef (32:4fef) + push bc + ldh a, [hLYOverrideStart] + ld l, a + inc a + ld e, a + ld h, HIGH(wLYOverrides) + ld d, h + ldh a, [hLYOverrideEnd] + sub l + and a + jr z, .done + ld c, a + ld a, [hl] + push af +.loop + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .loop + pop af + ld [hl], a +.done + pop bc + ret + +BGEffect_FillLYOverridesBackup: ; c900b (32:500b) + push af + ld h, HIGH(wLYOverrides) + ldh a, [hLYOverrideStart] + ld l, a + ldh a, [hLYOverrideEnd] + sub l + ld d, a + pop af +.loop + ld [hli], a + dec d + jr nz, .loop + ret + +BGEffect_DisplaceLYOverridesBackup: ; c901b (32:501b) + ; e = a; d = [hLYOverrideEnd] - [hLYOverrideStart] - a + push af + ld e, a + ldh a, [hLYOverrideStart] + ld l, a + ldh a, [hLYOverrideEnd] + sub l + sub e + ld d, a + ld h, HIGH(wLYOverrides) + ldh a, [hLYOverrideStart] + ld l, a + ld a, $90 +.loop + ld [hli], a + dec e + jr nz, .loop + pop af + xor $ff + inc a +.loop2 + ld [hli], a + dec d + jr nz, .loop2 + ret + +BGEffect_CheckBattleTurn: ; c9038 (32:5038) + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ldh a, [hBattleTurn] + and $1 + xor [hl] + ret + +BGEffect_CheckFlyDigStatus: ; c9042 (32:5042) + ld hl, BG_EFFECT_STRUCT_BATTLE_TURN + add hl, bc + ldh a, [hBattleTurn] + and $1 + xor [hl] + jr nz, .player + ld a, [wEnemySubStatus3] ; EnemySubStatus3 + bit 6, a + ret + +.player + ld a, [wPlayerSubStatus3] ; PlayerSubStatus3 + bit 6, a + ret + +BattleBGEffects_CheckSGB: ; c9059 (32:5059) + ld a, [wcccf] + and a + ret + +BattleBGEffects_Sine: ; c905d (32:505d) + ld e, a + callfar BattleAnim_Sine_e + ld a, e + ret + +BattleBGEffects_Cosine: ; c9066 (32:5066) + ld e, a + callfar BattleAnim_Cosine_e + ld a, e + ret + +; c906f (32:506f) diff --git a/engine/gfx.asm b/engine/gfx.asm index 2c19fe6..66b3f90 100644 --- a/engine/gfx.asm +++ b/engine/gfx.asm @@ -6,22 +6,22 @@ LoadFontGraphics:: ; f8000 (3e:4000) ld de, FontGFX ld hl, $8800 lb bc, BANK(FontGFX), ((FontGFXEnd - FontGFX) / LEN_1BPP_TILE) - jp CopyVideoDataDoubleOptimized + jp Get1bpp LoadFontExtraGraphicsWithCursor:: ; f800c (3e:400c) ld de, FontExtraCDEFGHIVSLM_GFX ld hl, $9620 lb bc, BANK(FontExtraCDEFGHIVSLM_GFX), ((FontSmallKanaPunctuationGFXEnd - FontExtraCDEFGHIVSLM_GFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ld de, BlackTileAndCursor1bppGFX ld hl, $9600 lb bc, BANK(BlackTileAndCursor1bppGFX), ((BlackTileAndCursor1bppGFXEnd - BlackTileAndCursor1bppGFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp jr LoadActiveFrameGraphics LoadPokemonMenuGraphics:: ; f8026 (3e:4026) ld de, BattleHPBarGFX ld hl, $9600 lb bc, BANK(BattleHPBarGFX), ((LevelUpGFXEnd - BattleHPBarGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp jr LoadActiveFrameGraphics LoadHexadecimalFontOrHUDGraphics:: ; f8034 (3e:4034) call LoadActiveFrameGraphics @@ -31,25 +31,25 @@ LoadHexadecimalFontOrHUDGraphics:: ; f8034 (3e:4034) ld hl, $9660 ld de, FontGFX + (("0" - "ア") * $08) lb bc, BANK(FontGFX), ("9" - "0" + 1) - call CopyVideoDataDoubleOptimized + call Get1bpp ld hl, $9700 ld de, FontExtraAB_GFX lb bc, BANK(FontExtraAB_GFX), ("F" - "A" + 1) - call CopyVideoDataOptimized + call Get2bpp ret LoadHudGraphics:: ; f8057 (3e:4057) ld hl, $9660 ld de, FontGFX + (("0" - "ア") * $08) lb bc, BANK(FontGFX), ("9" - "0" + 1) - call CopyVideoDataDoubleOptimized + call Get1bpp ld hl, $9700 ld de, $7381 ld bc, $0401 - call CopyVideoDataOptimized + call Get2bpp ld hl, $9710 ld de, HUD_GFX lb bc, BANK(HUD_GFX), ((HUD_GFXEnd - HUD_GFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ret LoadActiveFrameGraphics:: ; f807c (3e:407c) ld a, [wActiveFrame] @@ -60,80 +60,80 @@ LoadActiveFrameGraphics:: ; f807c (3e:407c) ld e, l ld hl, $9790 lb bc, BANK(FrameGFX), ((FrameGFXFirstFrameEnd - FrameGFXFirstFrame) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld hl, $97f0 ld de, EmptyTile1bppGFX lb bc, BANK(EmptyTile1bppGFX), ((EmptyTile1bppGFXEnd - EmptyTile1bppGFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ret LoadPokeDexGraphics:: ; f80a0 (3e:40a0) call LoadPokemonMenuGraphics ld de, PokedexGFX ld hl, $9600 lb bc, BANK(PokedexGFX), ((PokedexLocationGFXEnd - PokedexGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ld de, PokeBallsGFX ld hl, $9720 lb bc, BANK(PokeBallsGFX), 1 ; 1 of 4 tiles - jp CopyVideoDataOptimized + jp Get2bpp LoadBattleGraphics:: ; f80bb (3e:40bb) ld de, BattleHPBarGFX ld hl, $9600 lb bc, BANK(BattleHPBarGFX), ((BattleHPBarGFXEnd - BattleHPBarGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ld hl, $9700 ld de, BattleMarkersGFX lb bc, BANK(BattleMarkersGFX), ((BattleMarkersGFXEnd - BattleMarkersGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp call LoadActiveFrameGraphics ld de, HpExpBarParts0GFX ld hl, $96c0 lb bc, BANK(HpExpBarParts0GFX), ((HpExpBarParts0GFXEnd - HpExpBarParts0GFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, HpExpBarParts1GFX ld hl, $9730 lb bc, BANK(HpExpBarParts1GFX), ((HpExpBarParts3GFXEnd - HpExpBarParts1GFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, ExpBarGFX ld hl, $9550 lb bc, BANK(ExpBarGFX), ((ExpBarGFXEnd - ExpBarGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ret LoadPokemonStatsGraphics:: ; f80fb (3e:40fb) call LoadPokemonMenuGraphics ld de, HpExpBarParts0GFX ld hl, $96c0 lb bc, BANK(HpExpBarParts0GFX), ((HpExpBarParts0GFXEnd - HpExpBarParts0GFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, HpExpBarParts1GFX ld hl, $9780 lb bc, BANK(HpExpBarParts1GFX), 1 ; 1 of 6 tiles - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, HpExpBarParts2GFX ld hl, $9760 lb bc, BANK(HpExpBarParts0GFX), ((HpExpBarParts2GFXEnd - HpExpBarParts2GFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, ExpBarGFX ld hl, $9550 lb bc, BANK(ExpBarGFX), ((ExpBarGFXEnd - ExpBarGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ld de, StatsGFX ld hl, $9310 lb bc, BANK(StatsGFX), ((StatsGFXEnd - StatsGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp ret LoadBackpackGraphics:: ; f813b (3e:413b) ld de, BlackTileAndCursor1bppGFX ld hl, $9600 lb bc, BANK(BlackTileAndCursor1bppGFX), ((BlackTileAndCursor1bppGFXEnd - BlackTileAndCursor1bppGFX) / LEN_1BPP_TILE) - call CopyVideoDataDoubleOptimized + call Get1bpp ld de, PackIconGFX ld hl, $9620 lb bc, BANK(PackIconGFX), 12 ; 12 of 15 tiles - call CopyVideoDataOptimized + call Get2bpp ld de, FontSmallKanaPunctuationGFX ld hl, $96e0 lb bc, BANK(FontSmallKanaPunctuationGFX), ((FontSmallKanaPunctuationGFXEnd - FontSmallKanaPunctuationGFX) / LEN_2BPP_TILE) - call CopyVideoDataOptimized + call Get2bpp jp LoadActiveFrameGraphics ; 0xf8162
\ No newline at end of file diff --git a/engine/palettes.asm b/engine/palettes.asm new file mode 100644 index 0000000..d1f93c0 --- /dev/null +++ b/engine/palettes.asm @@ -0,0 +1,113 @@ +INCLUDE "constants.asm" + +SECTION "Overworld fade", ROMX[$433e],BANK[$23] + +OverworldFadeIn:: ; 23:433e + ld c, 0 + call GetFadeStep + ld b, 4 + call FadeTowardsWhite + ret + +OverworldFadeOut:: ; 23:4349 + ld c, 9 + call GetFadeStep + ld b, 4 + call FadeTowardsBlack + ret + + +; TODO: merge this +SECTION "Palette fading, part 2?", ROMX[$43d1],BANK[$23] + +ApplyPalettesAtHL:: ; 23:43d1 + push hl + ld a, [hli] + ld [rBGP], a + ld a, [hli] + ld [rOBP0], a + ld a, [hli] + ld [rOBP1], a + pop hl + ret + +FadeTowardsWhite:: ; 23:43dd + call ApplyPalettesAtHL + inc hl + inc hl + inc hl + ld c, 8 + call DelayFrames + dec b + jr nz, FadeTowardsWhite + ret + +FadeTowardsBlack:: ; 23:43ec + call ApplyPalettesAtHL + dec hl + dec hl + dec hl + ld c, 8 + call DelayFrames + dec b + jr nz, FadeTowardsBlack + ret + +GetFadeStep:: ; 23:43fb + ld a, [wTimeOfDayPal] + and 3 + push bc + ld c, a + ld b, 0 + ld hl, .sequences + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + pop bc + ld b, 0 + add hl, bc + ret + +.sequences + dw .sequence0 + dw .sequence1 + dw .sequence2 + dw .sequence3 + +.sequence0 + db $ff, $ff, $ff + db $fe, $fe, $fe + db $f9, $e4, $e4 + db $e4, $d0, $d0 + db $90, $80, $80 + db $40, $40, $40 + db $00, $00, $00 + +.sequence1 + db $ff, $ff, $ff + db $fe, $fe, $fe + db $f9, $e4, $e4 + db $e9, $d0, $d0 + db $90, $80, $80 + db $40, $40, $40 + db $00, $00, $00 + +.sequence2 + db $ff, $ff, $ff + db $fe, $fe, $ff + db $f9, $e4, $ff + db $f9, $d0, $ff + db $90, $80, $90 + db $40, $40, $40 + db $00, $00, $00 + +.sequence3 + db $ff, $ff, $ff + db $fe, $fe, $fe + db $f9, $e4, $e4 + db $e8, $d0, $d0 + db $90, $80, $80 + db $40, $40, $40 + db $00, $00, $00 diff --git a/home/copy2.asm b/home/copy2.asm index 0a0ee54..5d3afe2 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -49,7 +49,7 @@ FarCopyDataDouble: ; d3e (0:d3e) call Bankswitch ret -CopyVideoData:: ; d68 (0:d68) +Request2bpp:: ; d68 (0:d68) ; Wait for the next VBlank, then copy c 2bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -89,7 +89,7 @@ CopyVideoData:: ; d68 (0:d68) ld c, a jr .loop -CopyVideoDataDouble:: ; da6 (0:da6) +Request1bpp:: ; da6 (0:da6) ; Wait for the next VBlank, then copy c 1bpp ; tiles from b:de to hl, 8 tiles at a time. ; This takes c/8 frames. @@ -129,13 +129,14 @@ CopyVideoDataDouble:: ; da6 (0:da6) ld c, a jr .loop -CopyVideoDataOptimized:: ; de4 (0:de4) +Get2bpp:: ; de4 (0:de4) ; Copy c 2bpp tiles from b:de to hl in VRAM ; using VBlank service or direct copy in ; case LCD is off ldh a, [rLCDC] bit rLCDC_ENABLE, a - jp nz, CopyVideoData ; copy video data during vblank while screen is on + jp nz, Request2bpp ; copy video data during vblank while screen is on +Copy2bpp:: ; 0deb push hl ; convert to FarCopyData call ld h, d ld l, e @@ -152,13 +153,14 @@ CopyVideoDataOptimized:: ; de4 (0:de4) pop af jp FarCopyData -CopyVideoDataDoubleOptimized: ; dff (0:dff) +Get1bpp: ; dff (0:dff) ; Copy c 1bpp tiles from b:de to hl in VRAM ; using VBlank service or direct copy in ; case LCD is off ldh a, [rLCDC] bit rLCDC_ENABLE, a - jp nz, CopyVideoDataDouble + jp nz, Request1bpp +Copy1bpp:: ; 0e06 push de ld d, h ld e, l diff --git a/home/joypad.asm b/home/joypad.asm index e0740f2..5a4e549 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -210,7 +210,7 @@ WaitAorB_BlinkCursor:: ; 8ea (0:8ea) ldh a, [hJoySum] and (A_BUTTON | B_BUTTON) ret nz - call RTC + call UpdateTime call UpdateTimeOfDayPalettes ld a, $01 ldh [hBGMapMode], a diff --git a/home/pokemon.asm b/home/pokemon.asm index 6cf1eb5..bb1bcc5 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -219,7 +219,7 @@ InterlaceMergeSpriteBuffers:: ; 3bc6 (0:3bc6) ld c, (2 * SPRITEBUFFERSIZE) / 16 ; $31, number of 16 byte chunks to be copied ldh a, [hROMBank] ld b, a - call CopyVideoDataOptimized + call Get2bpp call CloseSRAM ret @@ -1,7 +1,9 @@ SECTION "HRAM", HRAM[$FF80] hOAMDMA:: ; ff80 - ds 13 + ds 10 + + ds 3 ; TODO hRTCHours:: db ; ff8d hRTCMinutes:: db ; ff8e @@ -19,7 +21,8 @@ hROMBank:: ; ff98 hVBlank:: ; ff99 db - db ; TODO +hMapEntryMethod:: ; ff9a + db hStartmenuCloseAndSelectHookEnable:: db ; ff9b @@ -59,11 +62,27 @@ UNION hTextBoxCursorBlinkInterval:: ds 2 ; ffaf NEXTU + hSpriteWidth:: ; ffaf hSpriteInterlaceCounter:: ; ffaf db hSpriteHeight:: ; ffb0 db + +NEXTU + +hConnectionStripLength:: ; ffaf + db +hConnectedMapWidth:: ; ffb0 + db + +NEXTU + +hMapObjectIndexBuffer:: ; ffaf + db +hObjectStructIndexBuffer:: ; ffb0 + db + ENDU hSpriteOffset:: ; ffb1 @@ -82,8 +101,9 @@ hPrintNumTemp:: ds 3 ; ffba big-endian hLCDCPointer:: ; ffd0 db - - ds 3 ; TODO +hLYOverrideStart:: db ; ffd1 +hLYOverrideEnd:: db ; ffd2 + ds 1 ; TODO hSerialReceived:: ; ffd4 @@ -158,10 +178,17 @@ hRedrawRowOrColumnMode:: db ; ffe5 hRedrawRowOrColumnDest:: ds 2 ; ffe6 hMapAnims:: ; ffe8 - ; TODO: figure out size - ds 7 + db + +hTileAnimFrame:: ; ffe9 + db + + ds 5 ; TODO + hRandomAdd:: db ; ffef hRandomSub:: db ; fff0 hRTCRandom:: db ; fff1 +hBattleTurn:: db ; fff2 + ; TODO diff --git a/macros/wram.asm b/macros/wram.asm index c598245..77fe153 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -114,6 +114,19 @@ box: MACRO ENDM +map_connection_struct: MACRO +\1ConnectedMapGroup:: db +\1ConnectedMapNumber:: db +\1ConnectionStripPointer:: dw +\1ConnectionStripLocation:: dw +\1ConnectionStripLength:: db +\1ConnectedMapWidth:: db +\1ConnectionStripYOffset:: db +\1ConnectionStripXOffset:: db +\1ConnectionWindow:: dw +ENDM + + channel_struct: MACRO ; TODO: CH1 isn't at C101, please rebase all of these ; Addreses are Channel1 (c101). @@ -247,7 +260,6 @@ slot_reel: MACRO endm object_struct: MACRO -\1Struct:: \1Sprite:: ds 1 \1MapObjectIndex:: ds 1 \1SpriteTile:: ds 1 @@ -285,7 +297,6 @@ object_struct: MACRO ENDM map_object: MACRO -\1Object:: \1ObjectStructID:: ds 1 \1ObjectSprite:: ds 1 \1ObjectYCoord:: ds 1 diff --git a/tools/make_shim.c b/tools/make_shim.c index e4019cf..b5a7517 100644 --- a/tools/make_shim.c +++ b/tools/make_shim.c @@ -54,17 +54,19 @@ size_t strrcspn(const char *s1, const char *s2) { return _s1 - s1; } -#define RIP(errmsg) { \ - errno = EIO; \ - perror(errmsg); \ - if (file) fclose(file); \ - return 1; \ +#define RIP(errmsg) { \ + fprintf(stderr, "%s:%d:%s: %s\n", fname, lineno, eline, errmsg); \ + if (file) fclose(file); \ + return 1; \ } int main(int argc, char * argv[]) { int ch; char line[16*1024]; + char eline[16*1024]; char *lineptr = NULL; + char *fname; + int lineno; section_t section_list[] = { {0x4000, false, "ROM0", false}, @@ -93,40 +95,46 @@ int main(int argc, char * argv[]) { } for (int arg_idx = optind; arg_idx < argc; arg_idx++) { - FILE * file = fopen(argv[arg_idx], "r"); + eline[0] = 0; + lineno = 0; + fname = argv[arg_idx]; + FILE * file = fopen(fname, "r"); if (file == NULL) - RIP("file io"); + RIP("Unable to open file"); while ((lineptr = fgets(line, sizeof(line), file)) != NULL) { + lineno++; unsigned short bank = 0; unsigned short pointer = 0; char * symbol = NULL; char * end; char * addr_p; + strcpy(eline, line); // Unmodified copy for tracebacks + *strrchr(eline, '\n') = 0; // line = line.split(";")[0].strip() lineptr += strspn(lineptr, " \t\n"); end = strchr(lineptr, ';'); if (end) *end = 0; lineptr[strrspn(lineptr, " \t\n")] = 0; - if (!*line) + if (!*lineptr) continue; // Get the bank, address, and symbol end = lineptr + strcspn(lineptr, " \t\n"); symbol = end + strspn(end, " \t\n"); if (!*symbol) - RIP("parse"); + RIP("Declaration not in \"bank:addr Name\" format"); *end = 0; addr_p = strchr(lineptr, ':'); if (!addr_p) - RIP("parse"); + RIP("Pointer not in bank:addr format"); *addr_p++ = 0; pointer = strtoul(addr_p, &end, 16); if (pointer == 0 && end == addr_p) - RIP("parse"); + RIP("Unable to parse symbol address"); bank = strtoul(lineptr, &end, 16); if (bank == 0 && end == lineptr) - RIP("parse"); + RIP("Unable to parse bank number"); // Main loop const char * section = NULL; diff --git a/zero_checksum.inc b/zero_checksum.inc new file mode 100644 index 0000000..c35e834 --- /dev/null +++ b/zero_checksum.inc @@ -0,0 +1,6 @@ + +; This is part of a workaround to RGBFIX 0.3.7, which does not compute the global checksum correctly +; if it's not 0 in the pre-fix ROM. See https://github.com/rednex/rgbds/issues/280 + +SECTION "RGBFIX 0.3.7 workaround", ROM0[$14E] + dw 0
\ No newline at end of file |