It is currently Wed Oct 18, 2017 6:58 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: controllers
PostPosted: Fri Sep 16, 2005 9:56 am 
Offline
User avatar

Joined: Wed Sep 07, 2005 9:55 am
Posts: 299
Location: Phoenix, AZ
when should the controller status be updated? when $4016 is strobed or a specific scanline or is it some other time?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 10:13 am 
Offline

Joined: Thu Sep 15, 2005 9:23 am
Posts: 1194
Location: Behind you with a knife!
You should check to see whether a button is pressed at the start of a VBlank. When the joypad is strobed then return the bits via 4016.

example;

- Check for input (via directinput)
- start VBlank
- joypad strobe here (then begin to return bits)

Hope this helps.

_________________
http://www.jamesturner.de/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 10:56 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Bit 0 of the value written to $4016 sets the strobe, which is connected to a shift register in both joypads. When the strobe is 1, reading from $4016 or $4017 always returns the status of the respective A button in bit 0. When the strobe is changed from 1 to 0, the current state of the buttons is latched into the shift registers of both joypads. Then, with the strobe left at 0, reading from $4016 and $4017 reads the low bit in the corresponding shift register and then clocks it right one bit.

An emulator could latch the current host keyboard/joystick state into a shift register when the strobe changed from 1 to 0. The following code demonstrates the behavior (for clarity is reads joypad #2):

Code:
lda  #1     ; strobe = 1
sta  $4016
lda  $4017  ; bit 0 has A button status at this exact moment
lda  $4017  ; bit 0 has A button status at this exact moment
            ; etc.

lda  #0     ; change strobe to 0 and latch current buttons
sta  $4016

lda  $4017  ; bit 0 has A button status when it was latched
lda  $4017  ; bit 0 has B button status when it was latched
            ; etc.

lda  #0     ; strobe already 0, thus no effect on shift register
sta  $4016

lda  $4017  ; bit 0 has does *not* have A button status


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group