This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Support of using controllers of Famicom expansion port

Support of using controllers of Famicom expansion port
by on (#129285)
Most NES/Famicom games support simply plugging in a famicom controller in the expansion port or using a four score or similar in order to play the games.

One specific game I'd like to add expansion port support for is DPAD Hero 2. I've contacted the developer about it, and hopefully he can fix it. I saw the game's source was freely available aswell in .asm. Now I'm not a master, but I checked the makefile and there's a bunch of unix specific stuff in that which probably won't work so well for windows gnuwin32 make. I'll try to get that info from the developer.

But I'm turning to you guys, do you know anything about expansion port controllers? What sort of code would you need to add in order to support controlling the game via expansion port rather than normal game-system-attached-controllers of famicom?

I know of atleast 2 normal NES/Famicom games which actually require you to use the game-system-attached-controllers. Zelda 2 (I tried both PAL version on Famicom and the famicom disk game) and Gyro (only tried famicom game) are the two games I've identified so far which don't allow input from the expansion port..
Re: Support of using controllers of Famicom expansion port
by on (#129293)
You have to modify the controller read routines to read both bits 1 and 0. It'll make the read routines 3 bytes larger and take 16 cycles longer per controller.

It's probably doing something like this piece of code, which fills the carry with a single bit read from the controller. On the NES and AV Famicom, it reads the plugged-in controller, but on the original Famicom, it reads the hardwired controller.
Code:
  lda $4016,x
  lsr a  ; move bit 0 to carry
  ; omitted: then shift it into another variable


This piece of code sets the carry if the button is pressed on either device. Bit 0 comes from the controller, and bit 1 comes from the DA15 expansion port.
Code:
  lda $4016,x
  and #$03  ; ignore all bits except those from the controller
  cmp #$01  ; set carry if not all bits are zero
  ; omitted: then shift it into another variable


Famicom games for four players treat the bits separately:
Code:
  lda $4016,x
  lsr a
  rol cur_keys,x  ; hardwired controllers used by player 1 or 2
  lsr a
  rol cur_keys+2,x  ; expansion controllers used by player 3 or 4
Re: Support of using controllers of Famicom expansion port
by on (#129342)
Thank you for your response tepples. I'll have a look at the current controller code and see if I can update it with what you've suggested.
First I need response from the developer on how to get his makefile working on windows environment.
Re: Support of using controllers of Famicom expansion port
by on (#129571)
This is something that bothered me too with my famicom since I'm normally using NES controllers hooked up to the expansion port.
I've actually done a few patches to games to fix this where it was possible, including one for D-Pad Hero 2.

I've uploaded two of them that I found for now, but I also made patches for Zelda 2 and Battletoads (1p only) that I can upload as well later.

These are tested with a PowerPAK only but they should work in all cases I guess.

You can find the patches here:
http://yavin.viskos.org/fc/