Hi,
This code was cut and pasted from "Rwin's" "Jumpy" program which just displayed a little character that jumped up and down and could be moved left and right with the keypad.
I was only interested in the key reading section. I left out the sub routines. That's where I'll be adding code which responds to the keypresses.
My next step is to add in the subroutines such as; if the left key is pressed write to one of the sound channels, if the right key pressed then write to another sound channel, etc.
;;---CODE START---;; I copied parts of this from -'Rwin's "Jumpy" rom dated 04/11/2002
.inesprg 1
.ineschr 0
.bank 1
.org $FFFA
.dw 0 ; no VBlank routine
.dw keypress
.dw 0
.bank 0
.org $8000
keypress:
jsr resetjoy ; goto to the routine which resets the joypad #1 status
lda $4016 ; checks if "a" button is pressed
bne abutton ; goto jump routine if "a" is pressed
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ; checks if left is pressed
bne lft ; if left is pressed goto the routine for moving the sprite to the left
lda $4016 ; checks if right is pressed
bne rt ; if right is pressed goto the routine for moving the sprite to the right
jmp keypress ; Jump to the begin of the main loop
resetjoy:
lda #$01 ; Writing #$01 to $4016 (=joypad1) followed by writing #$00
sta $4016 ; to $4016 resets status of joypad 1
lda #$00
sta $4016
rts
lft: ; this is where some other code will respond to left arrow keypress
jmp keypress
rt: ; right arrow keypress response
jmp keypress
abutton: ; a button sub routine
jmp keypress
Where we have;
lda $4016
lda $4016
(continued 6 times, 8 times total in the "keypress" section)
One "lda $4016" for each of the 8 buttons of the keypad?
Is this storing a zero in the accumulator each time?
Is it clearing the bit for each button?
I'm not a programmer, I apologize for any really confused questions I might ask (they'll probably be a lot of them.)
Thanks in advance,
T
[/code]
This code was cut and pasted from "Rwin's" "Jumpy" program which just displayed a little character that jumped up and down and could be moved left and right with the keypad.
I was only interested in the key reading section. I left out the sub routines. That's where I'll be adding code which responds to the keypresses.
My next step is to add in the subroutines such as; if the left key is pressed write to one of the sound channels, if the right key pressed then write to another sound channel, etc.
Code:
;;---CODE START---;; I copied parts of this from -'Rwin's "Jumpy" rom dated 04/11/2002
.inesprg 1
.ineschr 0
.bank 1
.org $FFFA
.dw 0 ; no VBlank routine
.dw keypress
.dw 0
.bank 0
.org $8000
keypress:
jsr resetjoy ; goto to the routine which resets the joypad #1 status
lda $4016 ; checks if "a" button is pressed
bne abutton ; goto jump routine if "a" is pressed
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ;
lda $4016 ; checks if left is pressed
bne lft ; if left is pressed goto the routine for moving the sprite to the left
lda $4016 ; checks if right is pressed
bne rt ; if right is pressed goto the routine for moving the sprite to the right
jmp keypress ; Jump to the begin of the main loop
resetjoy:
lda #$01 ; Writing #$01 to $4016 (=joypad1) followed by writing #$00
sta $4016 ; to $4016 resets status of joypad 1
lda #$00
sta $4016
rts
lft: ; this is where some other code will respond to left arrow keypress
jmp keypress
rt: ; right arrow keypress response
jmp keypress
abutton: ; a button sub routine
jmp keypress
Where we have;
lda $4016
lda $4016
(continued 6 times, 8 times total in the "keypress" section)
One "lda $4016" for each of the 8 buttons of the keypad?
Is this storing a zero in the accumulator each time?
Is it clearing the bit for each button?
I'm not a programmer, I apologize for any really confused questions I might ask (they'll probably be a lot of them.)
Thanks in advance,
T
[/code]