ref: 0e311ad709ec65ce65dea962666d014f825da869
dir: /engine/battle_anims/core.asm/
QueueBattleAnimation: ld hl, wActiveAnimObjects ld e, NUM_ANIM_OBJECTS .loop ld a, [hl] and a jr z, .done ld bc, BATTLEANIMSTRUCT_LENGTH add hl, bc dec e jr nz, .loop scf ret .done ld c, l ld b, h ld hl, wLastAnimObjectIndex inc [hl] call InitBattleAnimation ret DeinitBattleAnimation: ld hl, BATTLEANIMSTRUCT_INDEX add hl, bc ld [hl], $0 ret InitBattleAnimation: ld a, [wBattleObjectTempID] ld e, a ld d, 0 ld hl, BattleAnimObjects rept 6 add hl, de endr ld e, l ld d, h ld hl, BATTLEANIMSTRUCT_INDEX add hl, bc ld a, [wLastAnimObjectIndex] ld [hli], a ; Index ld a, [de] inc de ld [hli], a ; 01 ld a, [de] inc de ld [hli], a ; 02 ld a, [de] inc de ld [hli], a ; Frameset ID ld a, [de] inc de ld [hli], a ; Function ld a, [de] inc de ld [hli], a ; 05 ld a, [de] call GetBattleAnimTileOffset ld [hli], a ; Tile ID ld a, [wBattleObjectTempXCoord] ld [hli], a ; X Coord ld a, [wBattleObjectTempYCoord] ld [hli], a ; Y Coord xor a ld [hli], a ; X Offset ld [hli], a ; Y Offset ld a, [wBattleObjectTempParam] ld [hli], a ; Param xor a ld [hli], a ; 0c dec a ld [hli], a ; 0d xor a ld [hli], a ; 0e ld [hli], a ; 0f ld [hl], a ; 10 ret BattleAnimOAMUpdate: call InitBattleAnimBuffer call GetBattleAnimFrame cp dowait_command jp z, .done cp delanim_command jp z, .delete push af ld hl, wBattleAnimTempOAMFlags ld a, [wBattleAnimTempFrameOAMFlags] xor [hl] and PRIORITY | Y_FLIP | X_FLIP ld [hl], a pop af push bc call GetBattleAnimOAMPointer ld a, [wBattleAnimTempTileID] add [hl] ; tile offset ld [wBattleAnimTempTileID], a inc hl ld a, [hli] ; oam data length ld c, a ld a, [hli] ; oam data pointer ld h, [hl] ld l, a ld a, [wBattleAnimOAMPointerLo] ld e, a ld d, HIGH(wVirtualOAM) .loop ; Y Coord ld a, [wBattleAnimTempYCoord] ld b, a ld a, [wBattleAnimTempYOffset] add b ld b, a push hl ld a, [hl] ld hl, wBattleAnimTempOAMFlags bit OAM_Y_FLIP, [hl] jr z, .no_yflip add $8 xor $ff inc a .no_yflip pop hl add b ld [de], a ; X Coord inc hl inc de ld a, [wBattleAnimTempXCoord] ld b, a ld a, [wBattleAnimTempXOffset] add b ld b, a push hl ld a, [hl] ld hl, wBattleAnimTempOAMFlags bit OAM_X_FLIP, [hl] jr z, .no_xflip add $8 xor $ff inc a .no_xflip pop hl add b ld [de], a ; Tile ID inc hl inc de ld a, [wBattleAnimTempTileID] add BATTLEANIM_BASE_TILE add [hl] ld [de], a ; Attributes inc hl inc de ld a, [wBattleAnimTempOAMFlags] ld b, a ld a, [hl] xor b and PRIORITY | Y_FLIP | X_FLIP ld b, a ld a, [hl] and OBP_NUM or b ld b, a ld a, [wBattleAnimTempPalette] and PALETTE_MASK | VRAM_BANK_1 or b ld [de], a inc hl inc de ld a, e ld [wBattleAnimOAMPointerLo], a cp LOW(wVirtualOAMEnd) jr nc, .exit_set_carry dec c jr nz, .loop pop bc jr .done .delete call DeinitBattleAnimation .done and a ret .exit_set_carry pop bc scf ret InitBattleAnimBuffer: ld hl, BATTLEANIMSTRUCT_01 add hl, bc ld a, [hl] and PRIORITY ld [wBattleAnimTempOAMFlags], a xor a ld [wBattleAnimTempFrameOAMFlags], a ld hl, BATTLEANIMSTRUCT_PALETTE add hl, bc ld a, [hl] ld [wBattleAnimTempPalette], a ld hl, BATTLEANIMSTRUCT_02 add hl, bc ld a, [hl] ld [wBattleAnimTempField02], a ld hl, BATTLEANIMSTRUCT_TILEID add hl, bc ld a, [hli] ld [wBattleAnimTempTileID], a ld a, [hli] ld [wBattleAnimTempXCoord], a ld a, [hli] ld [wBattleAnimTempYCoord], a ld a, [hli] ld [wBattleAnimTempXOffset], a ld a, [hli] ld [wBattleAnimTempYOffset], a ldh a, [hBattleTurn] and a ret z ld hl, BATTLEANIMSTRUCT_01 add hl, bc ld a, [hl] ld [wBattleAnimTempOAMFlags], a bit 0, [hl] ret z ld hl, BATTLEANIMSTRUCT_XCOORD add hl, bc ld a, [hli] ld d, a ld a, (-10 * 8) + 4 sub d ld [wBattleAnimTempXCoord], a ld a, [hli] ld d, a ld a, [wBattleAnimTempField02] cp $ff jr nz, .check_kinesis_softboiled_milkdrink ld a, 5 * 8 add d jr .done .check_kinesis_softboiled_milkdrink sub d push af ld a, [wFXAnimID + 1] or a jr nz, .no_sub ld a, [wFXAnimID] cp KINESIS jr z, .kinesis cp SOFTBOILED jr z, .softboiled cp MILK_DRINK jr nz, .no_sub .kinesis .softboiled .milk_drink pop af sub 1 * 8 jr .done .no_sub pop af .done ld [wBattleAnimTempYCoord], a ld a, [hli] xor $ff inc a ld [wBattleAnimTempXOffset], a ret GetBattleAnimTileOffset: push hl push bc ld hl, wBattleAnimTileDict ld b, a ld c, 10 / 2 .loop ld a, [hli] cp b jr z, .load inc hl dec c jr nz, .loop xor a jr .done .load ld a, [hl] .done pop bc pop hl ret _ExecuteBGEffects: callfar ExecuteBGEffects ret _QueueBGEffect: callfar QueueBGEffect ret