Home Page
Posted By: billb C64 Joystick - 10/02/07 11:48 AM
I'm having difficulty getting my gamepad to work with C64 games (Jumpman, specifically) in MESS ... it works on all the other emulated systems I have tried -- MSX, Vectrex, Apple II, Genesis, Coleco -- with no trouble at all.

So, I'm guessing that it is set to the wrong port on the C64, but I don't know how to change it. Something simple I am missing, probably, but I can't find it. The tab key does not bring up a menu like it does in sdlmame ... not sure if that is supposed to work or not.

I have used VICE to play Jumpman, but on the PS3 the full screen option doesn't work in VICE. I'm using sdlmess 0.115-1.fc7.drb (from Dribble) on Fedora 7 PPC and full screen / window resizing works great.
Posted By: R. Belmont Re: C64 Joystick - 10/02/07 01:37 PM
The C64 has a core joystick problem. It was temporarily fixed a while ago but that change broke the Amiga so it was reverted.
Posted By: billb Re: C64 Joystick - 10/02/07 02:18 PM
Originally Posted By R. Belmont
The C64 has a core joystick problem. It was temporarily fixed a while ago but that change broke the Amiga so it was reverted.


Thanks for letting me know. Maybe it was eaten by a grue? crazy
Posted By: Justin Re: C64 Joystick - 10/02/07 06:43 PM
The core problem should only affect joystick port 2, I dunno which one those games need to use.

The tab menu is still there, you just have to hit a special key to toggle between the C64 keyboard and the MAME UI keys. I think SDLMESS uses the Insert key for that?
Posted By: R. Belmont Re: C64 Joystick - 10/02/07 07:12 PM
On Linux/Win32 SDLMESS uses Scroll Lock like baseline, on the Mac it's Insert (which Mac keyboards call "Help", I believe).
Posted By: billb Re: C64 Joystick - 10/03/07 12:06 AM
Thanks guys ...

OK, I can bring up the MAME UI using the Scroll Lock toggle to enable the tab key.

And I see it is definitely joystick port 2 that is affected and not port 1.

I ran a BASIC program* on the C64 that loops to show values for Joystick ports 1 & 2 and when I move the dpad or hit the fire button on my gamepad it changes the value for port 1.

But if I use the 'Swap Gameport 1 and 2' option in the UI (under Dip Switches) then the values no longer change at all for ports 1 or 2.

Code:
 10 PRINTCHR$(147)
 20 PRINT"JOYSTICK PORT 1 "PEEK(56321)
 30 PRINT"JOYSTICK PORT 2 "PEEK(56320)
 40 GOTO 10


So I guess Jumpman requires a joystick in the virtual port 2. frown

* Reference:
http://personalpages.tds.net/~rcarlsen/cbm/ctrlport.txt
Posted By: billb Re: C64 Joystick - 10/04/07 05:07 PM
I see there is a patch for this here:
http://bugzilla.mess.org/show_bug.cgi?id=1150

And I'm able to apply it to the src/mess/machine/c64.c file successfully, but I'm having other unrelated problems compiling sdlmess on my Fedora 7 PPC / PS3 at the moment.

Posted By: billb Re: C64 Joystick - 10/08/07 11:38 PM
OK, I have re-compiled sdlmess 0.119 after applying the aforementioned patch and the joystick in port 2 is working now. Jumpman is on the move again. smile

In the MESS UI under Dip Switches, I have to leave Joystick 1 selected for Gameport A and None for Gameport B, and I can swap between using Gameports 1 and 2 properly.

Oddly, if I have Joystick 1 selected for Gameport A and Joystick 2 selected for Gameport B, it shows values changing for both ports at the same time when I test it with that BASIC program above using my gamepad (/dev/input/js0).
Posted By: JoJo Re: C64 Joystick - 10/09/07 11:52 AM
However, the port swap dipswitch is a ugly hack that should be removed as soon as possible: such a switch is not present on real hardware on any Commodore computer, its presence is confusing for the user and introduces bugs.
Posted By: billb Re: C64 Joystick - 10/09/07 01:51 PM
Yes, but how does one properly emulate leaning over their C64, fiddling with the joystick plugs, and spilling their Pepsi all over the keyboard? wink

Hmm... I am glad you mentioned this. I was mistaken -- I changed "Swap Gameport 1 and 2" to "No" and Gameport B to "Joystick 2" and it still works.
Posted By: Pete Rittwage Re: C64 Joystick - 10/21/07 04:40 PM
Originally Posted By R. Belmont
The C64 has a core joystick problem. It was temporarily fixed a while ago but that change broke the Amiga so it was reverted.


That was me. 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.

It is up to MAMEDevs to decide whether the chip should have the override, or the machine. I did the patch both ways. It was mentioned that the CIA emulation could be set to have a bit mask to fix this, but I wasn't up to rewriting the chip emulation. smile

Posted By: Bletch Re: C64 Joystick - 10/21/07 07:42 PM
Its not rocket science to implement tri-state logic on chips. The has been done for the 6821 PIA; there is no reason this couldn't be done for the 6526/8520 CIA chips.
Posted By: MASH Re: C64 Joystick - 07/07/14 07:11 PM
Wanted to try out some C64 games with the lastest C64 speedups (MAME 0153 r31203), but the joystick/pad (port1/2) didn't work in many games.
Where can i find this joystick patch on Page 1 of this thread?: http://bugzilla.mess.org/attachment.cgi?id=399
The link is broken.
Posted By: AWJ Re: C64 Joystick - 07/07/14 07:34 PM
It's vanishingly unlikely that you'd be able to apply a 7 year old patch to the current MESS source, even if you could find it.
Posted By: tjcbs Re: C64 Joystick - 07/08/14 05:14 AM
Same problem here.
Posted By: Stiletto Re: C64 Joystick - 07/08/14 05:17 AM
Originally Posted By tjcbs
Same problem here.


Bugzilla.mess.org died in the great MESS webserver crash of... 2011? something like that. No backups aside from extremely rare Internet Archive stuffs. Sorry, folks.
Posted By: AWJ Re: C64 Joystick - 07/08/14 07:54 AM
The patch would be completely useless in any case; both the 6526 device and the C64 driver have been completely rewritten from scratch since 2007.
Posted By: Sune Re: C64 Joystick - 07/09/14 09:22 PM
Originally Posted By Justin
The core problem should only affect joystick port 2, I dunno which one those games need to use.


The vast majority of C64 games used port 2.
Posted By: Curt Coder Re: C64 Joystick - 08/13/14 07:03 PM
Originally Posted By MASH
Wanted to try out some C64 games with the lastest C64 speedups (MAME 0153 r31203), but the joystick/pad (port1/2) didn't work in many games.


Could you elaborate which are the broken games? The ones I tried did work.
Posted By: MASH Re: C64 Joystick - 08/17/14 06:10 PM
Games that didn't work:
Buck Rogers (Port2)
Zaxxon (Port2)
Sentinel (Port2)
Forbidden Forest (Port2)


Game that work:
Encounter (Port2) works


All games work with VICE and my pad.
Posted By: Trebor Re: C64 Joystick - 05/30/15 10:28 AM
Thanks to the mention from this thread... http://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=99797#Post99797
...and to add to, as well as keep, the list of games impacted together within the same thread, the following also rely on Port 2 mapped to 'player 1' and does not work under MESS MAME grin

Bubble Bobble
Friday the 13th
G.I. Joe
Grog's Revenge
Posted By: geecab Re: C64 Joystick - 06/03/15 05:53 PM
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
Posted By: Haze Re: C64 Joystick - 06/03/15 06:04 PM
so basically just replace
Code:
data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);

with
Code:
if (m_ddra != 0xFF)
    data = (m_read_pa(0) & ~m_ddra) | (m_pra & m_ddra);
else	
    data = m_read_pa(0) & m_pra;

it does indeed mean
mame64 c64p -flop1 "Donkey Kong (1986)(Ocean Software)[cr New Stars].d64" -joy2 joy

works again and can be played...

anybody familiar enough with the real hardware to comment on the correctness? it doesn't look entirely unreasonable, but I'm not sure.
Posted By: R. Belmont Re: C64 Joystick - 06/03/15 06:18 PM
Agreed, it looks reasonable (although if it's correct it should apply to both ports). Can we get whoever caused it in the first place (Curt?) to take a look?
Posted By: geecab Re: C64 Joystick - 06/03/15 08:35 PM
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...
Code:
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:-
Code:
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..
Code:
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)...
Quote:

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 smile
Posted By: Trebor Re: C64 Joystick - 06/03/15 09:26 PM
Very cool, gentlemen. Thank you for your time and attention to the issue. It is very much appreciated.
© Forums