;;-----------------------------LICENSE NOTICE------------------------------------
;;  This file is part of Viking Hangover
;;  Copyright (C) 2021 Ahmed Begga / Érika Moreno / Adriana Morejón (@ComputosGame)
;;
;;  This program is free software: you can redistribute it and/or modify
;;  it under the terms of the GNU Lesser General Public License as published by
;;  the Free Software Foundation, either version 3 of the License, or
;;  (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU Lesser General Public License for more details.
;;
;;  You should have received a copy of the GNU Lesser General Public License
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
;;-------------------------------------------------------------------------------

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Description:                                           ;;                                                          
;;      Draws entity as boxes and remove the las position;;
;;Required:                                              ;;
;;     IX -> Initial position of the first entity        ;;  
;; Return:                                               ;;                                                  
;;     -                                                 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sys_pre_render_update_one::
    call actualiza_prerender
    ld c, e_x(ix)
    ld b, e_y(ix)
    ld de, #0xc000
    call cpct_getScreenPtr_asm
    ld e_currentpos2(ix), l
    ld e_currentpos1(ix), h
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Description:                                           ;;                                                          
;;      Updates all the entities                         ;;
;;Required:                                              ;;
;;                                                       ;;  
;; Return:                                               ;;                                                  
;;     -                                                 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sys_pre_render_update::
    ld a, #e_cmp_render
    ld hl, #sys_pre_render_update_one
    call man_entity_forall

ret
actualiza_prerender:
    ld h, e_currentpos1(ix) 
    ld l, e_currentpos2(ix)
    ld e_prevPos1(ix), h
    ld e_prevPos2(ix), l
    ret