Thought I'd add this here as its purely c64 joystick related.

I have hacked mos6526.c to get joystick Port2 working. It seems to work ok (I've just been playing The Last Ninja without any problems), but I've probably broken Amiga joystick emulation in the process :P

The information earlier in this thread was really helpful. Pete Rittwage posted that Port2 was broken a while ago when the C64 & Amiga's cia 6526 code was merged, so that is where I looked/hacked first. In the src/emu/machine/mos6526.c I changed this bit of code:-

Code:
READ8_MEMBER( mos6526_device::read )
{
  if (space.debugger_access())
    return 0xff;

  UINT8 data = 0;

  switch (offset & 0x0f)
  {
    case PRA:		
      data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);
      m_pa_in = data;
      break;


to look like this

Code:
READ8_MEMBER( mos6526_device::read )
{
  if (space.debugger_access())
    return 0xff;

  UINT8 data = 0;

  switch (offset & 0x0f)
  {
    case PRA:
      if(m_ddra != 0xFF)
      {		
        data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);
      }
      else
      {
        data = m_read_pa(0) & m_pra;
      }	
      m_pa_in = data;
      break;


and it worked smile

I've been testing what the joystick ports are returning by running the following:
mess.exe c64 -window -autoboot_command "10 PRINTCHR$(147)\n20 PRINT"""JP1"""PEEK(56321)\n30 PRINT"""JP2"""PEEK(56320)\n40 GOTO 10\nRUN\n"

I also found this table useful (That I found here http://personalpages.tds.net/~rcarlsen/cbm/repairs/ctrlport.txt) when checking the joystick values returned are correct:

Code:
 PIN  FUNCTION      CONTROL PORT 1         CONTROL PORT 2
       NONE          255                    127
  1    UP            254 (1)                126 (C= & F3) 
  2    DOWN          253 (LEFT ARROW)       125 (C= & S)
  3    LEFT          251 (CTRL)             123 (C= & F)
  4    RIGHT         247 (2)                119 (C= & H)
  6    FIRE          239 (SPACEBAR)         111 (C= & K)

Note. The dual entries (example: Commodore key & F3) indicate two simultanious keypresses.


Hope this helps smile

Last edited by geecab; 06/03/15 06:06 PM.