;;------------------------------------------------LICENSE NOTICE------------------------------------------------------------------------------
;;  This file is part of Amstrad CPC videogame "Redsea"
;;  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)
;;  Copyright (C) 2015 ronaldo / Fremos / Cheesetea / ByteRealms (@FranGallegoBR)
;;
;;  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/>.
;;------------------------------------------------LICENSE NOTICE-------------------------------------------------------------------------
.include "cpctelera.h.s"

.globl cpct_scanKeyboard_asm
.globl cpct_isKeyPressed_asm
.globl cpct_drawSprite_asm
.globl main_game
;.globl _spr_mainC
.globl _img_menu2_0
.globl _img_menu2_1
.globl _img_menu2_2
.globl _img_menu2_3

start:
    call main_game
ret

man_menu_init::

    ld c, #40 ;#7
    ld b, #100 ;#16 
    ld hl, #_img_menu2_0
    ld e, l
    ld d, h
    ld hl, #0xC000
    ex de, hl
    call cpct_drawSprite_asm ;pide hl, de, c y b

    ld c, #40 ;#7
    ld b, #100 ;#16 
    ld hl, #_img_menu2_1
    ld e, l
    ld d, h
    ld hl, #0xC028
    ex de, hl
    call cpct_drawSprite_asm ;pide hl, de, c y b

    ld c, #40 ;#7
    ld b, #100 ;#16 
    ld hl, #_img_menu2_2
    ld e, l
    ld d, h
    ld hl, #0xE3C0
    ex de, hl
    call cpct_drawSprite_asm ;pide hl, de, c y b

        ld c, #40 ;#7
    ld b, #100 ;#16 
    ld hl, #_img_menu2_3
    ld e, l
    ld d, h
    ld hl, #0xE3E8
    ex de, hl
    call cpct_drawSprite_asm ;pide hl, de, c y b

; TXT_OUTPUT=0xBB5A

; string:
;     .asciz "PRESS_SPACE_TO_START"

;     ld bc, #string
; bucle:                      ; Bucle para escribir cada palabra
;     ld a, (bc)
;     or a
;     ret z
;     call TXT_OUTPUT
;     inc bc
;     ld a, (bc)
;     or a
;     jr nz, bucle            ; No hay mas letras se sale
    
; ret

man_menu_update::

loopk:
    call cpct_scanKeyboard_asm

    ;Key-Action Check-Call loop
    ld hl, #Key_Space
    ;Check if key is pressed
    call cpct_isKeyPressed_asm
    jr z, loopk
    jr start
    ;; key is pressed execute action

ret