.include "cpctelera.h.s"


enable_music:: .db 1

music_play::
    ld a, (enable_music)
    dec a
    ret nz

    call cpct_akp_musicPlay_asm
ret


init_knight_adv::

    ;;; INICIO CON LA VISUALIZACION
    call	_cpct_disableFirmware
    call    rendersys_init
    call    music_init


    menu:: 
        ;;; INICIO DEL SISTEMA MENU
        call menu_init

        loop_menu::

        ;;; INPUT + CARGA DE PANTALLA MENU
        call Menu_updt

        ;;;; EMEPEZAR JUEGO
        ld a, (salir_menu)
        dec a 
        jr z, game_start



    jr loop_menu



    game_start:: 
        
        call    init_entity_array 
        call    colision_init
        call    init_game

        loop_game::

            ;;MUSIC
            call cpct_akp_musicPlay_asm

            ;;; RENDER 
            call    rendersys_update 
            call    render_hud
            


            ;;; ENTITY UPDATE
            call     update_colisionable_SI
            call     entity_update 
            

            ;;;; UPDATE GAME
            call    sys_ai_update
            call    physics_update
            call    sys_colision_update
            call    sys_all_entityes_anim
            call    gen_elem

            ;;;; CHECK END LEVEL/GAME
            call    estado_nivel
            
            ;;;; VSYNC
            call    _cpct_waitVSYNC




    jr loop_game




ret