.include "cpctelera.h.s"
.include "animations.h.s"
.include "entity.h.s"
.include "assets/assets.h.s"

;;; MANAGER DE ANIMACIONES

;;
;; ESTADOS
;;
;; 0000 -- muerte
;; 0001 -- down
;; 0010 -- up
;; 0011 -- left
;; 0100 -- right
;; 0101 -- s. down
;; 0110 -- s. down 
;; 0111 -- s. left 
;; 1000 -- s. right 
;; 1001 -- ataque down
;; 1010 -- ataque up
;; 1011 -- ataque left
;; 1100 -- ataque right
;; 1101 -- invencible

;; ===============================
;; PASA AL SIGUIENTE FRAME DE UNA ANIMACION
;; Input: B --> Estado de animacion
;;        IX --> Entidad actual
;; Output: HL->puntero animacion
;; Destroy: AF
;; ===============================
animations_getAnimHL:
    ld l, e_tablaAnimL(ix)
    ld h, e_tablaAnimH(ix)
    ld a, b     ;; pongo en a el estado b
    add a       ;;a+a (ax2) porque el array va de 2 en 2 (dw)
    add_hl_a    ;;sumo hl con a con acarreo (es una macro)
    
    ;;estoy en el puntero de animacion que quiero
    ;;cargo el puntero que quiero en hl para devolverlo
    ld a, (hl)
    inc hl
    ld h, (hl)
    ld l, a
ret 

;;
;; ANIMACIONES DE CADA ENTIDAD
;;

animations_player1_array:
    .dw player1_muere
    .dw player1_walk_down
    .dw player1_walk_up
    .dw player1_walk_left
    .dw player1_walk_right
    .dw player1_wait_down
    .dw player1_wait_up
    .dw player1_wait_left
    .dw player1_wait_right
    .dw player1_ataque_down
    .dw player1_ataque_up
    .dw player1_ataque_left
    .dw player1_ataque_right
    .dw player1_invencible
    
animations_player2_array:
    .dw player2_muere
    .dw player2_walk_down
    .dw player2_walk_up
    .dw player2_walk_left
    .dw player2_walk_right
    .dw player2_wait_down
    .dw player2_wait_up
    .dw player2_wait_left
    .dw player2_wait_right
    .dw player2_ataque_down
    .dw player2_ataque_up
    .dw player2_ataque_left
    .dw player2_ataque_right
    .dw player2_invencible
    
animations_fantasma_array:
    .dw fantasma_muere
    .dw fantasma_wait_down
    .dw fantasma_wait_up
    .dw fantasma_wait_left
    .dw fantasma_wait_right
    .dw fantasma_wait_down
    .dw fantasma_wait_up
    .dw fantasma_wait_left
    .dw fantasma_wait_right

animations_boss_array:
    .dw boss_muere
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw boss_walk
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw boss_invencible

animations_zombie_array:
    .dw zombie_muere
    .dw zombie_walk_down
    .dw zombie_walk_up
    .dw zombie_walk_left
    .dw zombie_walk_right

animations_shot_array:
    .dw shot_muere

animations_pato_array:
    .dw pato_muere
    .dw pato_walk_down
    .dw pato_walk_up
    .dw pato_walk_left
    .dw pato_walk_right

animations_topo_array:
    .dw topo_muere
    .dw topo_wait_down
    .dw topo_wait_down
    .dw topo_wait_down
    .dw topo_wait_down
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw topo_walk_down
    

animations_cangrejo_array:
    .dw cangrejo_muere
    .dw cangrejo_walk_down
    .dw cangrejo_walk_up
    .dw cangrejo_walk_left
    .dw cangrejo_walk_right
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw cangrejo_wait_down


animations_canion2_array:
    .dw canion2_muere
    .dw canion2_walk_down
    .dw canion2_walk_up
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw 0x0000
    .dw canion2_ataque_down
    .dw canion2_ataque_up


animations_arcoiris_array:
    .dw arcoiris_muere
    .dw arcoiris_objeto
    

animations_vida_array:
    .dw vida_muere
    .dw vida_objeto
    

;;
;; ANIMACIONES
;;

;;
;; BOSS
;;
boss_muere:
    .dw _spr_boss_2
    .dw 0x0000
    .dw boss_muere

boss_walk:
    .dw _spr_boss_0
    .dw 0x0000
    .dw boss_walk

boss_invencible:
    .dw _spr_boss_1
    .dw _spr_boss_0
    .dw _spr_boss_1
    .dw _spr_boss_0
    .dw 0x0000
    .dw boss_invencible
;;
;; PLAYER 1
;;

player1_wait_down:
    .dw _spr_player1_00
    .dw _spr_player1_01
    .dw 0x0000
    .dw player1_wait_down

player1_wait_up:
    .dw _spr_player1_06
    .dw _spr_player1_07
    .dw 0x0000
    .dw player1_wait_up

player1_wait_left:
    .dw _spr_player1_13
    .dw _spr_player1_14
    .dw 0x0000
    .dw player1_wait_left

player1_wait_right:
    .dw _spr_player1_19
    .dw _spr_player1_20
    .dw 0x0000
    .dw player1_wait_right

player1_walk_down:
    .dw _spr_player1_00
    .dw _spr_player1_02
    .dw _spr_player1_00
    .dw _spr_player1_03
    .dw 0x0000
    .dw player1_walk_down

player1_walk_up:
    .dw _spr_player1_06
    .dw _spr_player1_08
    .dw _spr_player1_06
    .dw _spr_player1_09
    .dw 0x0000
    .dw player1_walk_up

player1_walk_left:
    .dw _spr_player1_13
    .dw _spr_player1_15
    .dw _spr_player1_13
    .dw _spr_player1_16
    .dw 0x0000
    .dw player1_walk_left

player1_walk_right:
    .dw _spr_player1_19
    .dw _spr_player1_21
    .dw _spr_player1_19
    .dw _spr_player1_22
    .dw 0x0000
    .dw player1_walk_right

player1_ataque_down:
    .dw _spr_player1_04
    .dw 0x0000
    .dw player1_ataque_down

player1_ataque_up:
    .dw _spr_player1_10
    .dw 0x0000
    .dw player1_ataque_up

player1_ataque_left:
    .dw _spr_player1_17
    .dw 0x0000
    .dw player1_ataque_left

player1_ataque_right:
    .dw _spr_player1_23
    .dw 0x0000
    .dw player1_ataque_right

player1_muere:
    .dw _spr_player1_05
    .dw _spr_player1_11
    .dw _spr_player1_18
    .dw _spr_player1_18
    .dw _spr_player1_18
    .dw _spr_player1_24
    .dw _spr_player1_24
    .dw _spr_player1_24
    .dw 0x0000
    .dw player1_muere

player1_invencible:
    .dw _spr_player1_00
    .dw _spr_player1_12
    .dw _spr_player1_00
    .dw _spr_player1_12
    .dw 0x0000
    .dw player1_invencible

;;
;; PLAYER 2
;;

player2_wait_down:
    .dw _spr_player2_00
    .dw _spr_player2_01
    .dw 0x0000
    .dw player2_wait_down

player2_wait_up:
    .dw _spr_player2_06
    .dw _spr_player2_07
    .dw 0x0000
    .dw player2_wait_up

player2_wait_left:
    .dw _spr_player2_13
    .dw _spr_player2_14
    .dw 0x0000
    .dw player2_wait_left

player2_wait_right:
    .dw _spr_player2_19
    .dw _spr_player2_20
    .dw 0x0000
    .dw player2_wait_right

player2_walk_down:
    .dw _spr_player2_00
    .dw _spr_player2_02
    .dw _spr_player2_00
    .dw _spr_player2_03
    .dw 0x0000
    .dw player2_walk_down

player2_walk_up:
    .dw _spr_player2_06
    .dw _spr_player2_08
    .dw _spr_player2_06
    .dw _spr_player2_09
    .dw 0x0000
    .dw player2_walk_up

player2_walk_left:
    .dw _spr_player2_13
    .dw _spr_player2_15
    .dw _spr_player2_13
    .dw _spr_player2_16
    .dw 0x0000
    .dw player2_walk_left

player2_walk_right:
    .dw _spr_player2_19
    .dw _spr_player2_21
    .dw _spr_player2_19
    .dw _spr_player2_22
    .dw 0x0000
    .dw player2_walk_right

player2_ataque_down:
    .dw _spr_player2_04
    .dw 0x0000
    .dw player2_ataque_down

player2_ataque_up:
    .dw _spr_player2_10
    .dw 0x0000
    .dw player2_ataque_up

player2_ataque_left:
    .dw _spr_player2_17
    .dw 0x0000
    .dw player2_ataque_left

player2_ataque_right:
    .dw _spr_player2_23
    .dw 0x0000
    .dw player2_ataque_right

player2_muere:
    .dw _spr_player2_05
    .dw _spr_player2_11
    .dw _spr_player2_18
    .dw _spr_player2_18
    .dw _spr_player2_18
    .dw _spr_player2_24
    .dw _spr_player2_24
    .dw _spr_player2_24
    .dw 0x0000
    .dw player2_muere

player2_invencible:
    .dw _spr_player2_00
    .dw _spr_player2_12
    .dw _spr_player2_00
    .dw _spr_player2_12
    .dw 0x0000
    .dw player2_invencible


;;
;; ZOMBIE
;;
zombie_walk_down:
    .dw _spr_zombie_00
    .dw _spr_zombie_01
    .dw _spr_zombie_00
    .dw _spr_zombie_02
    .dw 0x0000
    .dw zombie_walk_down

zombie_walk_up:
    .dw _spr_zombie_03
    .dw _spr_zombie_04
    .dw _spr_zombie_03
    .dw _spr_zombie_05
    .dw 0x0000
    .dw zombie_walk_up

zombie_walk_left:
    .dw _spr_zombie_07
    .dw _spr_zombie_08
    .dw _spr_zombie_07
    .dw _spr_zombie_09
    .dw 0x0000
    .dw zombie_walk_left

zombie_walk_right:
    .dw _spr_zombie_10
    .dw _spr_zombie_11
    .dw _spr_zombie_10
    .dw _spr_zombie_12
    .dw 0x0000
    .dw zombie_walk_right

zombie_muere:
    .dw _spr_zombie_06
    .dw 0x0000
    .dw zombie_muere




;; SHOT

shot_muere:
    .dw _spr_shotArcoiris_5
    .dw 0x0000
    .dw shot_muere

;; PATO
pato_walk_down:
    .dw _spr_pato_00
    .dw _spr_pato_01
    .dw _spr_pato_00
    .dw _spr_pato_02
    .dw 0x0000
    .dw pato_walk_down

pato_walk_up:
    .dw _spr_pato_03
    .dw _spr_pato_04
    .dw _spr_pato_03
    .dw _spr_pato_05
    .dw 0x0000
    .dw pato_walk_up

pato_walk_left:
    .dw _spr_pato_06
    .dw _spr_pato_07
    .dw 0x0000
    .dw pato_walk_left

pato_walk_right:
    .dw _spr_pato_09
    .dw _spr_pato_10
    .dw 0x0000
    .dw pato_walk_right

pato_muere:
    .dw _spr_pato_08
    .dw 0x0000
    .dw pato_muere


;; TOPO
topo_walk_down:
    .dw _spr_topo_0
    .dw 0x0000
    .dw topo_walk_down

topo_wait_down:
    .dw _spr_topo_1
    .dw _spr_topo_2
    .dw _spr_topo_3
    .dw _spr_topo_2
    .dw _spr_topo_4
    .dw _spr_topo_2
    .dw _spr_topo_1
    .dw 0x0000
    .dw topo_wait_down

topo_muere:
    .dw _spr_topo_5
    .dw 0x0000
    .dw topo_muere


;; CANION 2

canion2_walk_up:
    .dw _spr_canion2_2
    .dw 0x0000
    .dw canion2_walk_up

canion2_walk_down:
    .dw _spr_canion2_0
    .dw 0x0000
    .dw canion2_walk_down

canion2_muere:
    .dw _spr_canion2_4
    .dw 0x0000
    .dw canion2_muere

canion2_ataque_down:
    .dw _spr_canion2_1
    .dw _spr_canion2_0
    .dw 0x0000
    .dw canion2_ataque_down

canion2_ataque_up:
    .dw _spr_canion2_3
    .dw _spr_canion2_2
    .dw 0x0000
    .dw canion2_ataque_up
;; CANGREJO

cangrejo_walk_down:
    .dw _spr_cangrejo_00
    .dw _spr_cangrejo_01
    .dw 0x0000
    .dw cangrejo_walk_down

cangrejo_walk_up:
    .dw _spr_cangrejo_03
    .dw _spr_cangrejo_04
    .dw 0x0000
    .dw cangrejo_walk_up

cangrejo_walk_left:
    .dw _spr_cangrejo_06
    .dw _spr_cangrejo_07
    .dw 0x0000
    .dw cangrejo_walk_left

cangrejo_walk_right:
    .dw _spr_cangrejo_09
    .dw _spr_cangrejo_10
    .dw 0x0000
    .dw cangrejo_walk_right

cangrejo_wait_down:
    .dw _spr_cangrejo_02
    .dw _spr_cangrejo_05
    .dw 0x0000
    .dw cangrejo_wait_down

cangrejo_muere:
    .dw _spr_cangrejo_08
    .dw 0x0000
    .dw cangrejo_muere


;; FANTASMA

fantasma_wait_down:
    .dw _spr_fantasma_00
    .dw _spr_fantasma_01
    .dw _spr_fantasma_02
    .dw 0x0000
    .dw fantasma_wait_down

fantasma_wait_up:
    .dw _spr_fantasma_03
    .dw _spr_fantasma_04
    .dw _spr_fantasma_05
    .dw 0x0000
    .dw fantasma_wait_up

fantasma_wait_left:
    .dw _spr_fantasma_07
    .dw _spr_fantasma_08
    .dw _spr_fantasma_09
    .dw 0x0000
    .dw fantasma_wait_left

fantasma_wait_right:
    .dw _spr_fantasma_10
    .dw _spr_fantasma_11
    .dw _spr_fantasma_12
    .dw 0x0000
    .dw fantasma_wait_right

fantasma_muere:
    .dw _spr_fantasma_06
    .dw 0x0000
    .dw fantasma_muere


;; OBJETOS


vida_objeto:
    .dw _spr_vida_0
    .dw _spr_vida_1
    .dw _spr_vida_2
    .dw _spr_vida_3
    .dw 0x0000
    .dw vida_objeto

vida_muere:
    .dw _spr_vida_4
    .dw 0x0000
    .dw vida_muere

arcoiris_objeto:
    .dw _spr_arcoiris_0
    .dw _spr_arcoiris_1
    .dw _spr_arcoiris_2
    .dw _spr_arcoiris_3
    .dw 0x0000
    .dw arcoiris_objeto

arcoiris_muere:
    .dw _spr_arcoiris_4
    .dw 0x0000
    .dw arcoiris_muere