Not sure if this helps, but thought I'd elaborate on my hack a little more:-
To begin with, I put a printf in the code just under the "data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra)" line like this...
data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);
printf("data=0x%X m_read_pa=0x%X m_ddra=0x%X m_pra=0x%X\n", data, m_read_pa(0), m_ddra, m_pra);
Then I ran the following:-
mess.exe c64 -window -autoboot_command "10 PRINTCHR$(147)\n20 PRINT"""JP1"""PEEK(56321)\n30 PRINT"""JP2"""P
EEK(56320)\n40 GOTO 10\nRUN\n"
and I saw this debug output from mess..
data=0x47 m_read_pa=0x44 m_ddra=0x3F m_pra=0x7
data=0x97 m_read_pa=0x84 m_ddra=0x3F m_pra=0x57
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
data=0x7F m_read_pa=0xF7 m_ddra=0xFF m_pra=0x7F <-- This is when I held the Joystick right
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
data=0x7F m_read_pa=0xFF m_ddra=0xFF m_pra=0x7F
I noticed the value being returned from m_read_pa() changed in accordance with the joystick control I was triggering, otherwise it was consistently m_read_pa=0xFF (no joystick controls triggered) - *apart* from the very first couple of reads that happen just after mess starts up (where m_read_pa is 0x44 and 0x84).
I think the m_ddra=0xFF means that PortA (Confusingly joystick Port2) has been configured for Output. So its "write only" which maybe why mess is not allowing us to read from it. I think this quote from what Pete Rittwage said is important (but I'm not totally sure I understand it)...
The 6526 and 8520 code was merged a few releases back, but the way the chip is implemented is different in the C64 vs. Amiga. On the C64, the lines can be pulled low even when the selects are set to output, which was/is an PCB design decision. On the Amiga, this can't happen since those lines are buffered by other logic.
So I guessed that I had better not be altering the 'data' return value until after m_ddra was consistently 0xFF. As m_pra is set to a consistent 0x7F I thought I'd AND that with the m_read_pa giving the correct Joystick port 2 values (126/125 etc..).
Like I said, its a pretty dirty hack but hopefully gets us a bit closer a clean fix
