Editing
Use the SNES/NES controller in Assembly
(section)
From F256 Foenix
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== ; This is test code that goes through all the ports and mux the NES and SNES... === NES_CTRL = $D880 NES_STAT = $D880 NES_EN = $01 NES_MODE = $04 NES_TRIG = $80 NES_DONE = $40 NES_JOY0 = $D884 NES_JOY1 = $D886 NES_JOY2 = $D888 NES_JOY3 = $D88A SNES_JOY0_LO = $D884 SNES_JOY0_HI = $D885 SNES_JOY1_LO = $D886 SNES_JOY1_HI = $D887 SNES_JOY2_LO = $D888 SNES_JOY2_HI = $D889 SNES_JOY3_LO = $D88A SNES_JOY3_HI = $D88B Test_4N4S: jsr SetIOPage0 '''; Test NES First''' '''; Enable and Begin a Sample''' NES_Start_Again: lda #NES_EN sta NES_CTRL lda NES_CTRL ora #NES_TRIG sta NES_CTRL and #~NES_TRIG sta NES_CTRL NESWait2beDone lda NES_STAT and #NES_DONE cmp #NES_DONE bne NESWait2beDone '''; When here, the Joystick Sampling is done''' lda NES_JOY0 eor #$FF ldx #$00 jsr Byte2Hex lda NES_JOY1 eor #$FF ldx #$03 jsr Byte2Hex lda NES_JOY2 eor #$FF ldx #$06 jsr Byte2Hex lda NES_JOY3 eor #$FF ldx #$09 jsr Byte2Hex lda NES_JOY3 eor #$FF and #$C0 cmp #$C0 beq NESDoneWithTest '''; Let's do the SNES''' lda #NES_EN | NES_MODE sta NES_CTRL lda NES_CTRL ora #NES_TRIG sta NES_CTRL and #~NES_TRIG sta NES_CTRL SNESWait2beDone lda NES_STAT and #NES_DONE cmp #NES_DONE bne SNESWait2beDone '''; When here, the Joystick Sampling is done''' lda SNES_JOY0_HI and #$0F eor #$0F ldx #$50 jsr Byte2Hex lda SNES_JOY0_LO eor #$FF ldx #$52 jsr Byte2Hex lda SNES_JOY1_HI and #$0F eor #$0F ldx #$55 jsr Byte2Hex lda SNES_JOY1_LO eor #$FF ldx #$57 jsr Byte2Hex lda SNES_JOY2_HI and #$0F eor #$0F ldx #$5A jsr Byte2Hex lda SNES_JOY2_LO eor #$FF ldx #$5C jsr Byte2Hex lda SNES_JOY3_HI and #$0F eor #$0F ldx #$5F jsr Byte2Hex lda SNES_JOY3_LO eor #$FF ldx #$61 jsr Byte2Hex jmp NES_Start_Again NESDoneWithTest: lda #$00 sta NES_CTRL rts Byte2Hex: sta $50 stx $51 jsr SetIOPage2 '''; Hi Part''' lda $50 and #$F0 lsr a lsr a lsr a lsr a tax lda HEX, x ; ldx $51 sta $c320,x '''; Low Part''' lda $50 and #$0F tax lda HEX, x ldx $51 sta $c321,x jsr SetIOPage0 rts
Summary:
Please note that all contributions to F256 Foenix are considered to be released under the Creative Commons Zero (Public Domain) (see
F256 Foenix:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
Edit source
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information