Thus, I've decided to write and slot into place the joystick detection code. At the moment, the code is very general since it's not being called by any other routine or not actually doing anything itself other than detecting the joystick move.
To be honest, I've meddled with joystick code before in a previous project (Super Galax-I-Birds), so this new code is a modification of that projects code for Chiller 2 and it all starts with memory location $dc00.
; check joystick left, right and button press joy_check lda $dc00 sta joystick joy_left lda joystick and #$04 bne joy_right jmp joy_end ; jsr to another routine in future! joy_right lda joystick and #$08 bne joy_fire jmp joy_end; jsr to another routine in future!joy_fire lda joystick and #$10 bne joy_end; jst to another routine in future!joy_end jmp joy_check
Memory location $dc00 can detect various joystick inputs by 'and'ing in various values as above. In the code, if an input isn't detected, it skips and checks the next input, but if an input is detected some other code can be run, but here it just jumps down to the end at the moment.
Note, there is no detection for up or down because Chiller 2 won't be using those movements, otherwise it would be simple to add more code to the above for those movements also.
And it's that simple in assembly language to detect joysticks!
Next diary entry...
No comments:
Post a Comment