dayoff
Posts: 2
Joined: Tue Dec 06, 2022 12:00 am

Compiling Mame w Marble Madness with 45 degree trackball offset

Hi everyone, had a question:

I'm using mame 250 in windows with an original Marble Madness control panel and have everything working great except for the fact that the original Marble Madness control panel has the trackballs mounted at a 45 degree offset so it's not just a matter of changing X and Y to get things to work. Mame is setup to 'get around this' so people with consistent panels can play, but I'm trying to stick to this mounting. Is there a section of mame that I can modify and recompile for my particular use case so that the trackball can track properly? I'm not using any other trackball games with my setup.

If it's any interest, from another project forum, I see advancemame allows the following entered into advmame.rc in linux to allow the 45 degree offset.
marble/input_map[p1_trackballx] mouse[1,x] -mouse[1,y]
marble/input_map[p1_trackbally] mouse[1,x] mouse[1,y]
marble/input_map[p2_trackballx] mouse[0,x] -mouse[0,y]
marble/input_map[p2_trackbally] mouse[0,x] mouse[0,y]
Back to the mame 250 source, I took a look at the code and am no expert in how this works, but did see the following section in atarisy1.cpp which notes this rotation. Any idea if this is where the adjustment is done, or elsewhere in the codeset?
/*************************************
*
* Trackball I/O
*
*************************************/

uint16_t atarisy1_state::trakball_r(offs_t offset)
{
int result = 0xff;

/* Marble Madness trackball type -- rotated 45 degrees! */
if (m_trackball_type == 1)
{
int player = (offset >> 1) & 1;
int which = offset & 1;

/* when reading the even ports, do a real analog port update */
if (which == 0)
{
uint8_t posx,posy;

if (player == 0)
{
posx = (int8_t)ioport("IN0")->read();
posy = (int8_t)ioport("IN1")->read();
}
else
{
posx = (int8_t)ioport("IN2")->read();
posy = (int8_t)ioport("IN3")->read();
}

m_cur[player][0] = posx + posy;
m_cur[player][1] = posx - posy;
}

result = m_cur[player][which];
}


Any information is appreciated!
Thanks,
Pete
dayoff
Posts: 2
Joined: Tue Dec 06, 2022 12:00 am

Re: Compiling Mame w Marble Madness with 45 degree trackball offset

Well, I hacked my way through it a bit... I ended up modifying this code in atarysy1.cpp:

m_cur[player][0] = posx + posy;
m_cur[player][1] = posx - posy;

I changed it to

m_cur[player][0] = posx;
m_cur[player][1] = posy;

...and recompiled MAME. Then went in and adjusted the X direction to be reversed in the analog game settings, and then changed the inputs so that P1_Trackball_X was MOUSECODE_2_YAXIS, and P1_Trackball_Y was MOUSECODE_2_XAXIS...and low and behold, my original Marble Madness trackball control panel with happ trackballs are now moving everything in the right direction.

Return to “MAME Discussion”