Shop OBEX P1 Docs P2 Docs Learn Events
NES controller emulator help. — Parallax Forums

NES controller emulator help.

CoolNerd27CoolNerd27 Posts: 6
edited 2012-06-24 22:07 in BASIC Stamp
I am trying to create an program that turns the basic stamp into a NES controller emulator for the NES of course. the Nes sends a latch pulse to start the data retrieval from the controller with clock pulses following to get the 8bit button states. right now im using the pulsin command to look for the latch then the shiftout to send the data when it recieves the latch. but so far it doesn't work except as soon as i turn on the bs2 it sends the data once and thats it. like if im playing mario he will move a tiny bit when i turn the bs2 on but after that not at all unless i turn the bs2 off then back on. help

Comments

  • FranklinFranklin Posts: 4,747
    edited 2012-06-24 21:49
    It would help if you would post your code (within [code] tags) so we could check it out.
  • CoolNerd27CoolNerd27 Posts: 6
    edited 2012-06-24 22:07
    Here it is.
    ' NES remote declaration - input received from remote

    Clock PIN 4
    Lach PIN 5
    Dat PIN 6

    '
    [ Variables ]

    value VAR Byte(2)
    time VAR Byte

    '
    [ Main Routine ]
    DO
    value = %10000000 ' button states, bit1 = a, bit2 = b, ect....
    GOSUB Send_Nes_Code
    LOOP
    '
    [NES Code]

    Send_Nes_Code:
    time = 0

    PULSIN Lach, 0, time ' wait for lach
    IF time > 1 THEN ' if time > 0 then lach recieved
    SHIFTOUT Dat, Clock, 1, [value(0) \8] 'shiftout selected button states
    ELSE
    GOSUB Get_Nes_Code: 'loop if time = 0
    ENDIF

    RETURN
Sign In or Register to comment.