NES controller emulator help.
CoolNerd27
Posts: 6
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
' 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