.include "cpctelera.h.s"
.include "man/entity.h.s"
.include "cmp/entity.h.s"
.include "cpct_functions.h.s"



sys_input_init::
	ret

sys_input_update:
    ld hl,#sys_input_update_one
    ld  a,#e_cmp_Physics
    ;;call man_entity_forall_matching
ret

sys_input_update_one::

	
	ld 	a,e_cmp_type(ix)
	or a
	ret z

	ld e_vx(ix), #0
	ld e_vy(ix), #0

	call cpct_scanKeyboard_f_asm

	ld hl, #Key_A
	call cpct_isKeyPressed_asm
	jr z, O_NotPressed
O_Pressed:
		ld e_vx(ix), #-1
O_NotPressed:

		ld hl, #Key_D
		call cpct_isKeyPressed_asm
		jr z, P_NotPressed
P_Pressed:
		ld e_vx(ix), #1
P_NotPressed:

		ld hl, #Key_W
		call cpct_isKeyPressed_asm
		jr z, Q_NotPressed
Q_Pressed:
		ld e_vy(ix), #-2
Q_NotPressed:

		ld hl, #Key_S
		call cpct_isKeyPressed_asm
		jr z, A_NotPressed
A_Pressed:
		ld e_vy(ix), #2
A_NotPressed:

	ret