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



                              1 ;;------------------------------------------------LICENSE NOTICE------------------------------------------------------------------------------
                              2 ;;  This file is part of Amstrad CPC videogame "Redsea"
                              3 ;;  Copyright (C) 2021 Crab Party / Elena López (AneleSplats in itch.io) / Iván Tortosa (Pluvs in itch.io, @IvanTortosaBer1 on Twitter) / Antonio Gosálvez (BalgroHub in itch.io)
                              4 ;;  Copyright (C) 2015 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
                              5 ;;
                              6 ;;  This program is free software: you can redistribute it and/or modify
                              7 ;;  it under the terms of the GNU Lesser General Public License as published by
                              8 ;;  the Free Software Foundation, either version 3 of the License, or
                              9 ;;  (at your option) any later version.
                             10 ;;
                             11 ;;  This program is distributed in the hope that it will be useful,
                             12 ;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
                             13 ;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                             14 ;;  GNU Lesser General Public License for more details.
                             15 ;;
                             16 ;;  You should have received a copy of the GNU Lesser General Public License
                             17 ;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.
                             18 ;;------------------------------------------------LICENSE NOTICE-------------------------------------------------------------------------
                             19 .globl cpct_drawSprite_asm
                             20 .globl man_entity_forall_matching
                             21 .globl matching_type
                             22 .globl resetearNivel
                             23 .globl pasarNivel
                             24 .globl _img_win
                             25 .globl _main
                             26 
                             27 ;contador: .db #10   ; Cada cuanto dibuja un frame
   896E 00                   28 esperarAnim:: .db #0
   896F 00                   29 death_or_next:: .db #0
                             30 
   8970                      31 _reset:
   8970 3A 6F 89      [13]   32     ld a, (#death_or_next)
   8973 B7            [ 4]   33     or a                  ; si no 0 then
   8974 20 04         [12]   34     jr nz, _next
   8976 CD 2E 86      [17]   35     call resetearNivel
   8979 C9            [10]   36 ret
                             37 
   897A                      38 _next:
   897A 3A 6F 89      [13]   39     ld a, (#death_or_next)
   897D D6 02         [ 7]   40     sub #2                   ; if (a >= 2)
   897F DA 85 89      [10]   41     jp c, _next1           ; not
   8982 28 0A         [12]   42     jr z, _next2           ; then
   8984 C9            [10]   43 ret
                             44 
   8985                      45 _next1:
   8985 3E 00         [ 7]   46     ld a, #0
   8987 32 6F 89      [13]   47     ld (#death_or_next), a
   898A CD 1E 86      [17]   48     call pasarNivel
   898D C9            [10]   49 ret
                             50 
   898E                      51 _next2:
   898E 0E 28         [ 7]   52     ld c, #40 ;#7
   8990 06 18         [ 7]   53     ld b, #24 ;#16 
   8992 21 18 44      [10]   54     ld hl, #_img_win
   8995 5D            [ 4]   55     ld e, l
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 2.
Hexadecimal [16-Bits]



   8996 54            [ 4]   56     ld d, h
   8997 21 32 C3      [10]   57     ld hl, #0xC332
   899A EB            [ 4]   58     ex de, hl
   899B CD C2 97      [17]   59     call cpct_drawSprite_asm ;pide hl, de, c y b
                             60     
                             61     ; Cometemos el acto ilegan de poner halt, porque no nos importa ya nuestra salud mental y nos da igual que el programa se pare salu2
                             62 
   899E 3E FF         [ 7]   63     ld a, #0xFF
   89A0                      64     volver1:
   89A0 76            [ 4]   65     halt
   89A1 3D            [ 4]   66     dec a
   89A2 20 FC         [12]   67     jr nz, volver1
                             68     
   89A4 CD 59 7D      [17]   69     call _main
                             70     
                             71     
   89A7 C9            [10]   72 ret
                             73 
   89A8                      74 _deathSprite:
   89A8 3A 6E 89      [13]   75     ld a, (#esperarAnim)
   89AB 3D            [ 4]   76     dec a
   89AC 32 6E 89      [13]   77     ld (#esperarAnim), a        ; Uno menos al contador
   89AF B7            [ 4]   78     or a
   89B0 28 BE         [12]   79     jr z, _reset
   89B2 C9            [10]   80 ret
                             81 
   89B3                      82 _resetAnim:
                             83 
   89B3 23            [ 6]   84     inc hl
   89B4 23            [ 6]   85     inc hl
   89B5 4E            [ 7]   86     ld c, (hl)
   89B6 23            [ 6]   87     inc hl
   89B7 46            [ 7]   88     ld b, (hl)          ; bc = siguiente sprite a almacenar
   89B8 2B            [ 6]   89     dec hl
                             90 
   89B9 60            [ 4]   91     ld h, b
   89BA 69            [ 4]   92     ld l, c          ; bc = siguiente sprite a almacenar
                             93 
   89BB 4E            [ 7]   94     ld c, (hl)
   89BC 23            [ 6]   95     inc hl
   89BD 46            [ 7]   96     ld b, (hl)          ; bc = siguiente sprite a almacenar
   89BE 2B            [ 6]   97     dec hl
                             98 
   89BF CA 0D 8A      [10]   99 jp z, _salto1
                            100 
   89C2                     101 sys_animations_non_loopable::
                            102 
   89C2 DD 6E 0D      [19]  103     ld l, 13(ix)
   89C5 DD 66 0E      [19]  104     ld h, 14(ix)        ; Puntero actual de la animacion en hl
                            105 
   89C8 4E            [ 7]  106     ld c, (hl)
   89C9 23            [ 6]  107     inc hl
   89CA 46            [ 7]  108     ld b, (hl)          ; bc = sprite a almacenar
   89CB 2B            [ 6]  109     dec hl
                            110 
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 3.
Hexadecimal [16-Bits]



   89CC 79            [ 4]  111     ld a, c
   89CD B0            [ 4]  112     or b
   89CE 28 4D         [12]  113     jr z, _salir   ; Llega al final de la animacion o aun no hay animacion
                            114 
   89D0 DD 7E 11      [19]  115     ld a, 17(ix)
   89D3 3D            [ 4]  116     dec a
   89D4 DD 77 11      [19]  117     ld 17(ix), a        ; Uno menos al contador
   89D7 B7            [ 4]  118     or a
   89D8 20 43         [12]  119     jr nz, _salir        ; Llega a 0, dibuja
                            120 
   89DA DD 71 07      [19]  121     ld  7(ix), c    ; Guarda el sprite en la entidad
   89DD DD 70 08      [19]  122     ld  8(ix), b
                            123 
   89E0 23            [ 6]  124     inc hl
   89E1 23            [ 6]  125     inc hl
   89E2 DD 75 0D      [19]  126     ld  13(ix), l    ; Guarda el paso de la animacion en la entidad
   89E5 DD 74 0E      [19]  127     ld  14(ix), h
                            128 
   89E8 DD 36 11 03   [19]  129     ld 17(ix), #3        ; Reiniciar contador
   89EC 3A 6E 89      [13]  130     ld a, (#esperarAnim)
   89EF B7            [ 4]  131     or a                  ; si no 0 then
   89F0 20 B6         [12]  132     jr nz, _deathSprite           ; se activa al morir el personaje
                            133 
   89F2 C9            [10]  134 ret
                            135  
   89F3                     136 sys_animations_one_entity::
                            137 
   89F3 DD 7E 11      [19]  138     ld a, 17(ix)
   89F6 3D            [ 4]  139     dec a
   89F7 DD 77 11      [19]  140     ld 17(ix), a        ; Uno menos al contador
   89FA B7            [ 4]  141     or a
   89FB 20 20         [12]  142     jr nz, _salir        ; Llega a 0, dibuja
                            143 
   89FD DD 6E 0D      [19]  144     ld l, 13(ix)
   8A00 DD 66 0E      [19]  145     ld h, 14(ix)        ; Puntero actual de la animacion en hl
                            146 
   8A03 23            [ 6]  147     inc hl
   8A04 23            [ 6]  148     inc hl              ; Hacemos que apunte al siguiente frame
   8A05 4E            [ 7]  149     ld c, (hl)
   8A06 23            [ 6]  150     inc hl
   8A07 46            [ 7]  151     ld b, (hl)          ; bc = siguiente sprite a almacenar
   8A08 2B            [ 6]  152     dec hl
                            153 
   8A09 79            [ 4]  154     ld a, c
   8A0A B0            [ 4]  155     or b
   8A0B 28 A6         [12]  156     jr z, _resetAnim    ; Llega al final de la animacion
                            157     
   8A0D                     158 _salto1:
   8A0D DD 75 0D      [19]  159     ld  13(ix), l    ; Guarda el paso de la animacion en la entidad
   8A10 DD 74 0E      [19]  160     ld  14(ix), h
                            161 
   8A13 DD 71 07      [19]  162     ld  7(ix), c    ; Guarda el nuevo sprite en la entidad
   8A16 DD 70 08      [19]  163     ld  8(ix), b
                            164 
   8A19 DD 36 11 0A   [19]  165     ld 17(ix), #10        ; Reiniciar contador
ASxxxx Assembler V02.00 + NoICE + SDCC mods  (Zilog Z80 / Hitachi HD64180), page 4.
Hexadecimal [16-Bits]



                            166 
   8A1D                     167 _salir:
                            168 
   8A1D C9            [10]  169 ret
   8A1E                     170 sys_animations_update::
   8A1E DD 21 F3 89   [14]  171     ld ix, #sys_animations_one_entity
   8A22 3E 10         [ 7]  172     ld a, #16
   8A24 32 FF 7D      [13]  173     ld (#matching_type), a
   8A27 CD 8C 7E      [17]  174     call man_entity_forall_matching
                            175 
   8A2A DD 21 C2 89   [14]  176     ld ix, #sys_animations_non_loopable
   8A2E 3E 40         [ 7]  177     ld a, #0x40
   8A30 32 FF 7D      [13]  178     ld (#matching_type), a
   8A33 CD 8C 7E      [17]  179     call man_entity_forall_matching
   8A36 C9            [10]  180 ret
