ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 1.
Hexadecimal [16-Bits]



                              1 ;;;
                              2 ;; ANIMATION MANAGER
                              3 ;;;
                              4 ;;-----------------------------LICENSE NOTICE------------------------------------
                              5 ;;  This file is part of Damned Games 
                              6 ;;  Copyright (C) 2021 Jorge Marín Ferrándiz, Yeray Mora Sobrino
                              7 ;;
                              8 ;;  This program is free software: you can redistribute it and/or modify
                              9 ;;  it under the terms of the GNU Lesser General Public License as published by
                             10 ;;  the Free Software Foundation, either version 3 of the License, or
                             11 ;;  (at your option) any later version.
                             12 ;;
                             13 ;;  This program is distributed in the hope that it will be useful,
                             14 ;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
                             15 ;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                             16 ;;  GNU Lesser General Public License for more details.
                             17 ;;
                             18 ;;  You should have received a copy of the GNU Lesser General Public License
                             19 ;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
                             20 ;;-------------------------------------------------------------------------------
                             21 ;; tenemos un vector de punteros con las animaciones + indicar que acaba con un nullptr + referencia inicio
                             22 
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 2.
Hexadecimal [16-Bits]



                             23 .include "render_system.h.s"
                              1 ;;-----------------------------LICENSE NOTICE------------------------------------
                              2 ;;  This file is part of Damned Games 
                              3 ;;  Copyright (C) 2021 Jorge Marín Ferrándiz, Yeray Mora Sobrino
                              4 ;;
                              5 ;;  This program is free software: you can redistribute it and/or modify
                              6 ;;  it under the terms of the GNU Lesser General Public License as published by
                              7 ;;  the Free Software Foundation, either version 3 of the License, or
                              8 ;;  (at your option) any later version.
                              9 ;;
                             10 ;;  This program is distributed in the hope that it will be useful,
                             11 ;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
                             12 ;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                             13 ;;  GNU Lesser General Public License for more details.
                             14 ;;
                             15 ;;  You should have received a copy of the GNU Lesser General Public License
                             16 ;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
                             17 ;;-------------------------------------------------------------------------------
                             18 
                             19 ;;
                             20 ;;  CABECERA DE LAS FUNCIONES DE RENDERSYS
                             21 ;;
                             22 .globl rendersys_init
                             23 .globl rendersys_update
                             24 .globl rendersys_update_first
                             25 .globl rendersys_chose_update
                             26 .globl rendersys_change_screen
                             27 .globl change_screen_to8000
                             28 .globl change_screen_toC000
                             29 .globl rendersys_UI
                             30 .globl rendersys_sumarUI
                             31 .globl rendersys_loopRestar
                             32 ;;-----------------------------
                             33 ;;SPRITES
                             34 ;;
                             35 .globl _sp_e_2_2
                             36 .globl _sp_e_2_1
                             37 .globl _sp_e_2_0
                             38 .globl _sp_e_2
                             39 .globl _sp_e_1
                             40 .globl _sp_e_0
                             41 .globl _sp_char_2
                             42 .globl _sp_char_1
                             43 .globl _sp_char_0
                             44 
                             45 .globl _barra
                             46 .globl _g_palette
                             47 
                             48 .globl _g_palette2
                             49 .globl _tronco
                             50 .globl _yesquero
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 3.
Hexadecimal [16-Bits]



                             24 .include "entity_manager.h.s"
                              1 ;;-----------------------------LICENSE NOTICE------------------------------------
                              2 ;;  This file is part of Damned Games 
                              3 ;;  Copyright (C) 2021 Jorge Marín Ferrándiz, Yeray Mora Sobrino
                              4 ;;
                              5 ;;  This program is free software: you can redistribute it and/or modify
                              6 ;;  it under the terms of the GNU Lesser General Public License as published by
                              7 ;;  the Free Software Foundation, either version 3 of the License, or
                              8 ;;  (at your option) any later version.
                              9 ;;
                             10 ;;  This program is distributed in the hope that it will be useful,
                             11 ;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
                             12 ;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                             13 ;;  GNU Lesser General Public License for more details.
                             14 ;;
                             15 ;;  You should have received a copy of the GNU Lesser General Public License
                             16 ;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
                             17 ;;-------------------------------------------------------------------------------
                             18 ;;
                             19 ;;CABECERA DE ENTITYMANAGER
                             20 ;;
                             21 .globl entityman_getEntityVector_IX
                             22 .globl entityman_getNumEntities_A
                             23 .globl entityman_getPlayerIX_enemyIY
                             24 .globl man_entity_getArray
                             25 .globl entityman_create
                             26 .globl man_entity_new
                             27 .globl man_entity_init
                             28 .globl man_entity_forall
                             29 .globl man_entity_forall_matching
                             30 .globl man_entity_forall_matching_iy
                             31 .globl entityman_get_elements
                             32 
                             33 ;;Macro creacion de entidades
                             34 .macro DefineEntityAnnonimous _cmps, _x, _y, _vx, _vy, _w, _h,_animationptr,_prevsprite, _sprite, _prevptr,_prevptr2, _lantern, _aimx, _aist, _colfunc, _type
                             35 
                             36    .db _cmps
                             37    .db _x
                             38    .db _y
                             39    .db _vx
                             40    .db _vy
                             41    .db _w
                             42    .db _h
                             43    .dw _animationptr
                             44    .dw _prevsprite
                             45    .dw _sprite
                             46    .dw _prevptr
                             47    .dw _prevptr2
                             48    .db _lantern
                             49    .db _aimx, 0x00
                             50    .db _aist
                             51    .dw _colfunc
                             52    .db _type
                             53 
                             54 .endm
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 4.
Hexadecimal [16-Bits]



                             55 
                             56 .macro DefineEntity _name, _cmps, _x, _y, _vx, _vy, _w, _h,_animationptr,_prevsprite, _sprite, _prevptr, _prevptr2, _lantern, _aimx, _aist, _colfunc, _type
                             57     _name::
                             58         DefineEntityAnnonimous _cmps, _x, _y, _vx, _vy, _w, _h,_animationptr,_prevsprite, _sprite, _prevptr, _prevptr2, _lantern, _aimx, _aist, _colfunc, _type
                             59 
                             60 .endm
                             61 
                             62 .macro DefineEntityArray _name, _N
                             63     _name::
                             64         .rept _N
                             65             DefineEntityAnnonimous 0xDE, 0xAD, 0xDE, 0xAD,0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD, 0xDE, 0xAD,0xDE, 0xAD, 0xDE, 0xAD, 0xAA
                             66         .endm
                             67 .endm
                             68 
                     0000    69 e_cmps       = 0
                     0001    70 e_x          = 1
                     0002    71 e_y          = 2
                     0003    72 e_vx         = 3
                     0004    73 e_vy         = 4
                     0005    74 e_w          = 5
                     0006    75 e_h          = 6
                     0007    76 e_animptr    = 7
                     0009    77 e_prevsprite = 9
                     000B    78 e_sprite     = 11
                     000D    79 e_prevptr    = 13
                     000F    80 e_prevptr2   = 15
                     0011    81 e_lantr      = 17
                     0012    82 e_ai_aim_x   = 18
                     0013    83 e_ai_aim_y   = 19
                     0014    84 e_ai_st      = 20
                     0015    85 e_col_func   = 21
                     0017    86 e_type       = 23
                     0018    87 sizeof_e     = 24
                             88 
                     0030    89 doublesizeof_e = 48
                             90 
                             91 ;; SISTEMAS DE IA QUE PUEDE TENER UNA ENTIDAD
                             92 
                     0000    93 e_ai_st_noAI     = 0
                     0001    94 e_ai_st_stand_by = 1
                     0002    95 e_ai_st_move_to  = 2
                     0003    96 e_ai_st_escape   = 3
                             97 
                             98 ;; TIPOS DE CMPS QUE PUEDE TENER UNA ENTIDAD
                     0000    99 e_invalid       = 0x00
                     0080   100 e_alive         = 0x80
                     0010   101 e_collider      = 0x10 
                     0008   102 e_collisionable = 0x08
                     0002   103 e_recollectable = 0x02
                     0001   104 e_animation     = 0x01
                     00C0   105 e_UI            = 0xC0
                     0020   106 e_physics       = 0x20
                            107 
                            108 ;; TIPOS DE ENTIDADES
                            109 
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 5.
Hexadecimal [16-Bits]



                     0080   110 e_player        = 0x80
                     0040   111 e_yesquero      = 0x40
                     0010   112 e_bloq          = 0x10
                     0008   113 e_enemy         = 0x08
                     0002   114 e_destructor    = 0x02
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 6.
Hexadecimal [16-Bits]



                             25 
                     0000    26 nullptr = 0x0000
                             27 
                     0001    28 cmps_animation = (e_animation)
   4B11                      29 animationsys_update::
   4B11 21 19 4B      [10]   30 ld hl, #foreach_update
   4B14 3E 01         [ 7]   31 ld a, #cmps_animation
   4B16 C3 2F 4D      [10]   32 jp man_entity_forall_matching
                             33 
                             34 
   4B19                      35 foreach_update:
   4B19 E5            [11]   36     push hl
   4B1A DD 6E 0B      [19]   37     ld l, e_sprite(ix) ;; 3
   4B1D DD 66 0C      [19]   38     ld h, e_sprite+1(ix) ;; 3
   4B20 DD 5E 09      [19]   39     ld e, e_prevsprite(ix) ;; 2
   4B23 DD 56 0A      [19]   40     ld d, e_prevsprite+1(ix) ;; 2
   4B26 DD 46 07      [19]   41     ld b, e_animptr(ix) ;; 1
   4B29 DD 4E 08      [19]   42     ld c, e_animptr+1(ix) ;; 1
                             43 
   4B2C DD 70 0B      [19]   44     ld e_sprite(ix), b ;; 3 copiamos 1
   4B2F DD 71 0C      [19]   45     ld e_sprite+1(ix), c
   4B32 DD 75 09      [19]   46     ld e_prevsprite(ix), l ;; 2 copiamos 3
   4B35 DD 74 0A      [19]   47     ld e_prevsprite+1(ix), h
   4B38 DD 73 07      [19]   48     ld e_animptr(ix), e ;; 1 copiamos 2
   4B3B DD 72 08      [19]   49     ld e_animptr+1(ix), d
   4B3E E1            [10]   50     pop hl
                             51 ;;    ld l, e_animptr+0(ix)
                             52 ;;    ld h, e_animptr+1(ix) ;; DE punter a animacion de donde esta el jugador
                             53 ;;_reset: 
                             54 ;;    ld c, (hl) ;; 
                             55 ;;    inc hl
                             56 ;;    ld b, (hl) ;;
                             57 ;;    inc hl ;; hl ---> next sprite
                             58 ;;    
                             59 ;;
                             60 ;;    ld a, c             ;; si bc nullptr, reseteamos
                             61 ;;    cp #0
                             62 ;;    jr z, _resetanimation
                             63 ;;
                             64 ;;    ;;si bc gucci, copiamos
                             65 ;;    ld e_animptr(ix),l
                             66 ;;    ld e_animptr+1(ix),h
                             67 ;;
                             68 ;;    ld l, e_sprite(ix)
                             69 ;;    ld h, e_sprite+1(ix)
                             70 ;;
                             71 ;;    ld e_prevsprite(ix), l
                             72 ;;    ld e_prevsprite+1(ix), h
                             73 ;;
                             74 ;;    ld e_sprite(ix), c
                             75 ;;    ld e_sprite+1(ix), b
                             76 ;;   
                             77 ;;
                             78 ;;    ld l, e_sprite(ix)
                             79 ;;    ld h, e_sprite+1(ix)
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 7.
Hexadecimal [16-Bits]



                             80 ;;
                             81 ;;    ld e_prevsprite(ix), l
                             82 ;;    ld e_prevsprite+1(ix), h
                             83 ;;    jr _end
                             84 ;;
                             85 ;;_resetanimation:
                             86 ;;    ld a, (hl)
                             87 ;;    inc hl
                             88 ;;    ld h,(hl)
                             89 ;;    ld l, a
                             90 ;;    jr _reset 
                             91 ;;_end:
   4B3F C9            [10]   92 ret
                             93 
