;; MIT License
;; 
;; Copyright (c) 2021 capAI / Aitana Devis  Ávila (@AitanaDevis) / Carlos Peñarrubia Morcillo  (@carlospm12) / Pablo Ruiz Ponce (@pabloruizp)
;; 
;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; 
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;; 
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.

.include "../man/sprites.h.s"
.include "../man/entity.h.s"
.include "cpctelera.h.s"

.area _CODE



;; AnimStates
;; UDRL
;; 0000 - run
;; 0001 - ---
;; 0010 - ---
;; 0011 - ---
;; 0100 - crouch
;; 0101 - ---
;; 0110 - ---
;; 0111 - ---
;; 1000 - jump
;; 1001 - ---
;; 1010 - ---

;;/////////////////////
;; ANIMATIONS ARRAY
;;/////////////////////
_animations_array:
    .dw _dog_running
    .dw nullptr
    .dw nullptr
    .dw nullptr
    .dw _dog_crouched
    .dw nullptr
    .dw nullptr
    .dw nullptr
    .dw _dog_jumping
    .dw nullptr
    .dw nullptr
    .dw nullptr 


;;////////////////////////////////////
;; MAN_ANIMATIONS: GetAnimHL
;;     
;;  INPUT:
;;       B = Animation state
;;  OUTPUT: 
;;      HL = pointer to animation(B)
;;////////////////////////////////////
man_animations_getAnimHL::
    ld hl, #_animations_array
    ld a, b
    add a ;;es lo mismo q desplazar 1 bit a la izq (multiplicar x2)
    add_hl_a ;; A += el acarreo (ahora en HL tenemos la dir de los punteros de _animations_array)

    ;;cargo los 2 bytes necesarios para acceder al contenido de esa pos (a la animación)
    ld a, (hl)
    inc hl
    ld h, (hl)
    ld l, a

    ret



;;/////////////////////
;;  DOG ANIMATIONS
;;/////////////////////
_dog_running::  
    .dw _walking_0 
    .dw _walking_1 
    .dw _walking_2  
    .dw _walking_3  
    .dw _walking_4
    .dw nullptr
    .dw _dog_running

_dog_crouched::
    .dw _crouched_0 
    .dw _crouched_1 
    .dw _crouched_2
    .dw _crouched_3 
    .dw _crouched_4 
    .dw nullptr  ;;para indicar el fin
    .dw _dog_crouched ;;puntero para volver al inicio

_dog_jumping::
    .dw _doggoJump
    .dw nullptr
    .dw _dog_jumping

