KEY CODES
The above codes are in` decimal ` so you will have to change the codes to `hex` to enter them in the `Monitor`.
To get your program to read the keyboard you have to load `A` with the value in address
`00C5`.A value code number is put in address `00C5` when a given key is pressed.
Each key on your keyboard has a certain code number assigned to it.The list of code numbers
are listed above ,with their own key assigned on the left of the code number.
Refering back to the previous `Screen and colour character position addresses` page and using
the program there and adding the program below  to get `key` control, enter the `Monitor`
and type

                                 .A  C015  LDA$00C5   [load `A` with the value number thats in address
                                                                        00C5]
                                 .A  C018  CMP#$3C    [compare the value in `A` with the value `3C`
                                                                        (code number for key `space`)]
                                 .A  C01A  BEQ$C01F  [branch to address C01F if the value in address
                                                                        00C5 equals `3C`]
                                 .A  C01C  JMP$C015   [jump to address C015( main loop)]
                                 .A  C01F  LDA#$51      [load `A` with the value of `51` (`ball`)]
                                 .A  C021  STA$0400     [store the value of `A` into screen address 0400]
                                 .A  C024  LDA#$04      [load `A` with the value of `04` (code number for
                                                                       colour purple)]
                                 .A  C026  STA$D800    [store the value of `A` into address D800 (colour
                                                                       address for screen address 0400)]
                                 .A  C029 JMP$C01F    [jump to address C01F to keep program
                                                                         running]


As before as in the previous page please do not enter in the `Monitor` after the commands the
`brackets [ ]` and the `information`.The information is just there for reference.
Clear the screen and type in .X and press `Return` to return to `basic`.Type SYS49152 and press `Return` to run the program.If you press key `space` you will see on the screen on the top left hand corner a `purple ball`.
Press `Stop/Restore` same time to return to `basic`.
Please note from previous program, line address `C015` the command `JMP$C00B` was changed to `LDA$00C5` for the above part of the program.
    Codes for joystick port 2
The following `codes` for joystick are read from address DC00 (port 2):-

                                  
JOYSTICK POSITION            CODE READ
                                                neutral                                7F
                                                left                                      7B
                                                right                                    77
                                                up                                       7E
                                                down                                   7D
                                                fire                                      6F
                                                up+fire                                6E
                                                down+fire                            6D
                                                left+fire                               6B
                                                right+fire                             67