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



                              1 ;MIT License
                              2 
                              3 ;Copyright (c) 2021 Fedora Adventures Pixeltronics
                              4 
                              5 ;Permission is hereby granted, free of charge, to any person obtaining a copy
                              6 ;of this software and associated documentation files (the "Software"), to deal
                              7 ;in the Software without restriction, including without limitation the rights
                              8 ;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                              9 ;copies of the Software, and to permit persons to whom the Software is
                             10 ;furnished to do so, subject to the following conditions:
                             11 
                             12 ;The above copyright notice and this permission notice shall be included in all
                             13 ;copies or substantial portions of the Software.
                             14 
                             15 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                             16 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                             17 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                             18 ;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                             19 ;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                             20 ;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
                             21 ;SOFTWARE.
                             22 ;;
                             23 ;;Manager de entidades
                             24 ;;
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 2.
Hexadecimal [16-Bits]



                             25 .include "entity.h.s"
                              1 ;MIT License
                              2 
                              3 ;Copyright (c) 2021 Fedora Adventures Pixeltronics
                              4 
                              5 ;Permission is hereby granted, free of charge, to any person obtaining a copy
                              6 ;of this software and associated documentation files (the "Software"), to deal
                              7 ;in the Software without restriction, including without limitation the rights
                              8 ;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                              9 ;copies of the Software, and to permit persons to whom the Software is
                             10 ;furnished to do so, subject to the following conditions:
                             11 
                             12 ;The above copyright notice and this permission notice shall be included in all
                             13 ;copies or substantial portions of the Software.
                             14 
                             15 ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                             16 ;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                             17 ;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                             18 ;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                             19 ;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                             20 ;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
                             21 ;SOFTWARE.
                             22 ;;archivo de cabecera para hacer include de las funciones
                             23 ;;
                             24 .globl _fedora_sprites_00
                             25 .globl _fedora_sprites_01
                             26 
                     0011    27 entity_size = 17
                     001E    28 max_entities = 30
                             29 ;;Constantes para definir en que byte está cada dato
                             30 ;; Nuestros datos de cada entidad son:
                             31 ;; Com
                     0000    32 e_cmps = 0
                     0001    33 e_cmps_physics = 1
                     0002    34 e_h = 2
                     0003    35 e_w = 3
                     0004    36 e_vx = 4
                     0005    37 e_vy = 5
                     0006    38 e_altura_salto = 6
                     0007    39 e_maxy = 7
                             40 ;e_color = 10
                     0008    41 e_ptr_sprite = 8 ;; esto usa 2 bytes
                     000A    42 e_prev_ptr = 10  ;; puntero 2 bytes
                     000C    43 e_movimiento1 = 12
                     000D    44 e_movimiento2 = 13
                     000E    45 e_movimiento3 = 14
                     000F    46 e_x = 15
                     0010    47 e_y = 16
                             48 
                     0080    49 e_cmps_alive = 0x80
                     0040    50 e_cmps_render = 0x40
                     0020    51 e_cmps_player = 0x20
                     0010    52 e_cmps_door = 0x10
                     0008    53 e_cmps_treasure = 0x08
                     0004    54 e_cmps_platform = 0x04
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 3.
Hexadecimal [16-Bits]



                             55 
                     0080    56 e_cmps_phy_left = 0x80
                     0040    57 e_cmps_phy_right = 0x40
                     0020    58 e_cmps_phy_jumping = 0x20
                     0010    59 e_cmps_phy_falling = 0x10
                             60 
                             61 
                             62 
                             63 ;;FUNCIONES PUBLICAS
                             64 .globl getEntityInArray
                             65 .globl getNumEntities
                             66 .globl create_entity
                             67 .globl man_entity_put_player_in_ix
                             68 .globl man_entity_put_platforms_in_iy
                             69 .globl man_entity_put_treasure_in_iy
                             70 .globl man_entity_put_door_in_iy
                             71 .globl man_entity_reset
                             72 .globl man_entity_init
                             73 .globl man_map_init
                             74 .globl create_entity_1
                             75 .globl create_entity_2
                             76 ;;CONSTANTES
                             77 .globl entity_size
                             78 .globl max_entities
                             79 .globl e_cmps
                             80 .globl e_cmps_physics
                             81 .globl e_h
                             82 .globl e_w
                             83 .globl e_x
                             84 .globl e_y
                             85 .globl e_vx
                             86 .globl e_vy
                             87 .globl e_altura_salto
                             88 .globl e_maxy
                             89 ;.globl e_color
                             90 .globl e_ptr_sprite
                             91 .globl e_cmps_alive
                             92 .globl e_cmps_render
                             93 .globl e_cmps_phy_left
                             94 .globl e_cmps_phy_right
                             95 .globl e_cmps_phy_jumping
                             96 .globl e_cmps_phy_falling
                             97 .globl e_movimiento1
                             98 .globl e_movimiento2
                             99 .globl e_movimiento3
                            100 
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 4.
Hexadecimal [16-Bits]



                             26    
   5FB5 00                   27 _num_entities:: .db 0
   5FB6                      28 _entity_array:: .ds max_entities * entity_size
   61B4 B6 5F                29 _last_elem_ptr:: .dw _entity_array
                             30 
   61B6                      31 getEntityInArray::
   61B6 DD 21 B6 5F   [14]   32     ld ix, #_entity_array
   61BA C9            [10]   33     ret
                             34 
   61BB                      35 getNumEntities::
   61BB 3A B5 5F      [13]   36     ld a, (_num_entities)
   61BE C9            [10]   37     ret
                             38 
                             39 
   61BF                      40 create_entity_1::
   61BF ED 5B B4 61   [20]   41     ld de, (_last_elem_ptr)
   61C3 01 0F 00      [10]   42     ld bc, #entity_size-2
   61C6 ED B0         [21]   43     ldir
                             44 
   61C8 3A B5 5F      [13]   45     ld a, (_num_entities)
   61CB 3C            [ 4]   46     inc a 
   61CC 32 B5 5F      [13]   47     ld (_num_entities), a 
                             48     
   61CF 2A B4 61      [16]   49     ld hl, (_last_elem_ptr)
   61D2 01 11 00      [10]   50     ld bc, #entity_size
   61D5 09            [11]   51     add hl, bc
   61D6 22 B4 61      [16]   52     ld (_last_elem_ptr), hl
   61D9 C9            [10]   53 ret 
                             54 
   61DA                      55 create_entity_2::
   61DA ED 5B B4 61   [20]   56     ld de, (_last_elem_ptr)
   61DE 1B            [ 6]   57     dec de
   61DF 1B            [ 6]   58     dec de
   61E0 01 02 00      [10]   59     ld bc, #0002
   61E3 ED B0         [21]   60     ldir
   61E5 C9            [10]   61 ret 
                             62 
   61E6                      63 create_entity::
   61E6 ED 5B B4 61   [20]   64     ld de, (_last_elem_ptr)
   61EA 01 11 00      [10]   65     ld bc, #entity_size
   61ED ED B0         [21]   66     ldir
                             67 
   61EF 3A B5 5F      [13]   68     ld a, (_num_entities)
   61F2 3C            [ 4]   69     inc a 
   61F3 32 B5 5F      [13]   70     ld (_num_entities), a 
                             71     
   61F6 2A B4 61      [16]   72     ld hl, (_last_elem_ptr)
   61F9 01 11 00      [10]   73     ld bc, #entity_size
   61FC 09            [11]   74     add hl, bc
   61FD 22 B4 61      [16]   75     ld (_last_elem_ptr), hl
                             76 
   6200 C9            [10]   77     ret
                             78 
   6201                      79 man_entity_put_player_in_ix::
   6201 DD 21 B6 5F   [14]   80     ld ix, #_entity_array
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 5.
Hexadecimal [16-Bits]



   6205 01 11 00      [10]   81     ld bc, #entity_size
   6208 DD 09         [15]   82     add ix, bc
   620A DD 09         [15]   83     add ix, bc
   620C C9            [10]   84     ret
                             85 
   620D                      86 man_entity_put_platforms_in_iy::
   620D 01 11 00      [10]   87     ld bc, #entity_size
   6210 FD 21 B6 5F   [14]   88     ld iy, #_entity_array
   6214 3E 03         [ 7]   89     ld a, #3
                             90 
   6216                      91     search_platforms:
   6216 FD 09         [15]   92         add iy, bc
   6218 3D            [ 4]   93         dec a
   6219 C8            [11]   94         ret z
                             95 
   621A 18 FA         [12]   96         jr search_platforms
   621C C9            [10]   97 ret
                             98 
   621D                      99 man_entity_put_treasure_in_iy::
                            100 ;    ld bc, #entity_size
   621D FD 21 B6 5F   [14]  101     ld iy, #_entity_array
                            102 ;    ld a, #1
                            103 
                            104 ;    search_treasure:
                            105 ;        add iy, bc
                            106 ;        dec a
                            107 ;        ret z
                            108 
                            109 ;        jr search_treasure
   6221 C9            [10]  110 ret 
                            111 
   6222                     112 man_entity_put_door_in_iy::
   6222 01 11 00      [10]  113     ld bc, #entity_size
   6225 FD 21 B6 5F   [14]  114     ld iy, #_entity_array
   6229 3E 01         [ 7]  115     ld a, #1
                            116 
   622B                     117     search_door:
   622B FD 09         [15]  118         add iy, bc
   622D 3D            [ 4]  119         dec a
   622E C8            [11]  120         ret z
                            121 
   622F 18 FA         [12]  122         jr search_door
   6231 C9            [10]  123 ret 
                            124 
   6232                     125 man_entity_reset::
   6232 AF            [ 4]  126     xor a
   6233 32 B5 5F      [13]  127     ld (_num_entities), a
   6236 21 B6 5F      [10]  128     ld hl, #_entity_array
   6239 22 B4 61      [16]  129     ld (_last_elem_ptr), hl
   623C C9            [10]  130 ret
                            131 
   623D                     132 man_entity_init:
   623D                     133 man_map_init:
                            134 
   623D C9            [10]  135 ret
