;Entry_JoystickKeys
;------------------
;Translates Joystick movement into key presses
;
;Entry:
; R0 - Command tail
; R1 = no. of parameters
; R12 - pointer to module private word

.Entry_JoystickKeys
 STMFD   R13!, {R0-R4, R14}
 LDR     R12, [R12, #0]
 ADD     R4, R12, #RTFM_Keymapping - VARS

 MOV     R3, #0
 STR     R3, [R4, #0]			;clear mapping table
 STR     R3, [R4, #4]
 STR     R3, [R4, #8]

 TEQ     R1, #0				;any parameters?
 LDMEQFD R13!, {R0-R4, PC}		;NO
 
 MOV     R3, R1				;R3=parameter count
 MOV     R1, R0				;R1=command tail
 MOV     R0, #1 << 30			;restrict to 0-255
 ._L1
   SWI     XOS_ReadUnsigned		;read the value PRM1-460
   LDMVSFD R13!, {R0-R4, PC}		;exit on error

   STRB    R2, [R4], #1			;store key
   SUBS    R3, R3, #1			;any more parameters?
 BNE    _L1

LDMFD   R13!, {R0-R4, PC}