full port 3F and controller port details Posted by asynchronous (eie211285.levels.unisa.edu.au) on July 16, 2001 at 00:11:17: i confirmed these details over the weekend and it answers a few questions like the prospect of using genesis/megadrive peripherals on a sms. port 3F is an IO control 'register' for the controller ports, where you plug in your joypads, lightphaser, etc... into the SMS. each of the 2 ports has power, ground and 7 input lines. 5 of the lines (up, down, left, right, button-1) are fixed input lines. the other 2 (TH and button-2) are configurable as input or output by port 3F. the TH pins have the extra function where as inputs a transition causes the pixel counter of the VDP which is readable through port 7F to latch. the lower nibble, bits 0 to 3, of port 3F configures the direction of each line. a 1 sets the line as an input. a 0 sets the line as an output. the upper nibble sets the output of the lines, when they are configured as outputs. a 1 will set the line high, a 0 will set the line low. i presume that for japanese machines a 1 will set the output low and vise versa. when a line is set as an output it cannot 'see' an input and the output state is 'seen' in ports $DC and $DD (hint hint emulator coders). as outputs the lines can sink and source enough current to drive an LED. i tried and confirmed it is possible to use genesis 4 button joypads on a SMS by setting TH as an output and setting it to high and low. i tried and confirmed that it is possible to use 2 lightphasers at once by setting the TH lines to outputs to 'disable' the lightphaser from latching the pixel counter and setting the TH line as an input to enable it. you could of course enable both lightphasers at once but the lightphaser pointing to a later part of the screen refresh will latch a new value over the first lightphaser. here is a summary of port $3F: bit 0: controller 1 button 2 direction (1=input 0=output) bit 1: controller 1 TH direction (1=input 0=output) bit 2: controller 2 button 2 direction (1=input 0=output) bit 3: controller 2 TH direction (1=input 0=output) bit 4: controller 1 button 2 output level (1=high 0=low) bit 5: controller 1 TH output level (1=high 0=low*) bit 6: controller 2 button 2 output level (1=high 0=low) bit 7: controller 2 TH output level (1=high 0=low*) *presumed inverted for japanese machines. oh, the source code is available for anyone who may want it. a s out. extra information on port $3F [ Follow Ups ] [ Post Followup ] [ SMS Power - S8-Dev - Forum ] Posted by asynchronous (eie211285.levels.unisa.edu.au) on July 13, 2001 at 01:14:19: g'day tech-heads. most of us here know that port $3F is used in determining the 'nationality' of an SMS console, and that it also can be used to set the output of the TH pins on the controller sockets like the genesis. well, as it turns out, it can do more than that and it looks like the sms developers had some ideas when designing the hardware! I ran another test program i wrote on the sms and found out the following. consider this information preliminary, because i haven't completed testing. PORT $3F BIT DEFINITIONS: bit 0: joypad 1 button 2 is a input when this bit is set, and an output when it is cleared. when set as an output the state of button 2 cannot be seen. bit 1: activates joypad 1 TH pin when set, disables when reset. by disabling the TH line a transition on the TH pin will not cause the H-counter to latch, making it possible to use 2 lightphases simulataneously. bit 2: joypad 2 button 2 is a input when this bit is set, and an output when it is cleared. when set as an output the state of button 2 cannot be seen. bit 3: activates joypad 2 TH pin when set, disables when reset. by disabling the TH line a transition on the TH pin will not cause the H-counter to latch. bit 4: setting this bit makes joypad 1 button 2 high when the line is an output, and low when this bit is cleared. this is seen directly in port DC. the state of button 1 cannot be seen if this bit is high and the bit 0 in cleared making the line an output. bit 5: writing to this bit writes to the nationality bits in port $DD. combinations of the nationality bits (bits 5 and 7) and the TH enable bits (bits 1 and 3) cause combinations where the output level of TH is either high and low and whether the TH lines latche the H-counter of the VDP. bit 6: same as bit 4 but sets the output level of joypad 2 button 2 line. bit 7: same as bit 5 but effects the state and operation of joypad 2 TH line. i plan to confirm these results sometime on the weekend to hopefully have a full functional explanation of port $3F and the TH pins and the nationality. phase 2 of the testing will be to test if values written to ports $3E, $DC and $DD effect port $3F operation. this program also did not work on my SMS1 (sorrow). as with my first test program, the bios didn't even load up. i suspect something to do with either the EXM1/M07 line which i'm using as the EPROM OutputEnable or the CE settings. any takers?? a s out.