RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Food Fight - joystick troubles, solved

    Scheduled Pinned Locked Moved Help and Support
    ad stick
    125 Posts 5 Posters 10.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mahoneyt944 @grant2258
      last edited by mahoneyt944

      @grant2258 I want dip switches for both so I can decide to use the cheat or not then decide if I want delay or not.

      That way I can change the settings on the fly.

      If using analog controller
      Live center on
      Debounce off

      If using digital controller
      Live center on
      Debounce on

      If wanting to turn cheat off
      Live center off
      Debounce off

      I just don't know how to get the dip switches value to use it in my code

      1 Reply Last reply Reply Quote 0
      • G
        grant2258 Banned
        last edited by grant2258

        // debounce delay for digital
          if (options.digital_analog) {t = 8; if (delay > t) delay = 0;}
          
        
          if (options.cheat_input_ports) // using cheat ports
          {
            if (delay == t) // debounce protection
            {
              delay = 0;
        
              if (whichport == 0) // x port called
              {
                if ( center == 0 ) {} // joy at center, no change
                else
                {
                  INT16 temp = readinputport(whichport); // find new x stop direction
                
                  if (temp > 128) // left
                  {
                    if (temp > 190) currentx = 190;
                    else currentx = temp;
                  }
                
                  else if (temp < 128) // right
                  {
                    if (temp < 65) currentx = 65;
                    else currentx = temp;
                  }
                  
                  else currentx = 128; // x at center
                }
              }
              
              else if (whichport == 2) // y port called
              {
                if ( center == 0 ) {} // joy at center, no change
                else
                {
                  INT16 temp = readinputport(whichport); // find new y stop direction
                
                  if (temp > 128) // up
                  {
                    if (temp > 190) currenty = 190;
                    else currenty = temp;
                  }
                
                  else if (temp < 128) // down
                  {
                    if (temp < 65) currenty = 65;
                    else currenty = temp;
                  }
                  
                  else currenty = 128; // y at center
                }
              }
              
              
            }
            else delay++;
            
            // return x position
            if (whichport == 0)
            {
              if (center == 0)
                return currentx;
              return readinputport(whichport);
            }
        
            // return y position
            else if (whichport == 2)
            {
              if (center == 0)
                return currenty;
              return readinputport(whichport);
            }
            
          }
          else // return original input
            return readinputport(whichport);
        }
        

        you not using the digital cheatports at all your only reading readinputport(whichport); so there is no need for any setting or delays. enable cheat ports is enough

        1 Reply Last reply Reply Quote 0
        • G
          grant2258 Banned
          last edited by grant2258

          INPUT_PORTS_START( foodf )
          	PORT_START	/* IN0 */
          	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_X | IPF_PLAYER1 | IPF_REVERSE, 100, 60, 0, 255 )
          
          	PORT_START	/* IN1 */
          	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_X | IPF_PLAYER2 | IPF_REVERSE | IPF_COCKTAIL, 100, 60, 0, 255 )
          
          	PORT_START	/* IN2 */
          	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_Y | IPF_PLAYER1 | IPF_REVERSE, 100, 60, 0, 255 )
          
          	PORT_START	/* IN3 */
          	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_Y | IPF_PLAYER2 | IPF_REVERSE | IPF_COCKTAIL, 100, 60, 0, 255 )
          
          	PORT_START	/* IN4 */
          	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
          	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
          	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
          	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
          	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
          	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
          	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
          	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
          
          	PORT_START	/* SW1 */
          	PORT_DIPNAME( 0x07, 0x00, "Bonus Coins" )
          	PORT_DIPSETTING(    0x00, "None" )
          	PORT_DIPSETTING(    0x05, "1 for every 2" )
          	PORT_DIPSETTING(    0x02, "1 for every 4" )
          	PORT_DIPSETTING(    0x01, "1 for every 5" )
          	PORT_DIPSETTING(    0x06, "2 for every 4" )
          	PORT_DIPNAME( 0x08, 0x00, DEF_STR( Coin_A ))
          	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
          	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ))
          	PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_B ))
          	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
          	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ))
          	PORT_DIPSETTING(    0x10, DEF_STR( 1C_5C ))
          	PORT_DIPSETTING(    0x30, DEF_STR( 1C_6C ))
          	PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coinage ))
          	PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ))
          	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
          	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ))
          	PORT_DIPSETTING(    0x40, DEF_STR( Free_Play ))
          INPUT_PORTS_END
          

          ports stat at zero every time you see a port PORT_START thats a new port use readinputport(port number) to read that port value as you can see your code is only reading analog ports whichport is only ever set to zero and 2 or 1 and 3 in cocktail mode for player 2

          M 1 Reply Last reply Reply Quote 0
          • M
            mahoneyt944 @grant2258
            last edited by mahoneyt944

            @grant2258 ok two questions,

            If I want to check the value of a dip switch using an if statement how would I do that? It it's on or off?

            And I've been using:

            INT16 center = readinputport(6) & ~16;
            

            To identify my center how do I do that with analog? Just read each port separately or is there an easier check?

            Like this:

            INT16 center = (readinputport(0) & ~16) + (readinputport(2) & ~16);
            
            1 Reply Last reply Reply Quote 0
            • G
              grant2258 Banned
              last edited by grant2258

              you need to compare 0 and 2 with 7f

              if( readinputport(0) == 0x7f && readinputport(2)== 0x7f) center =1;
              else center =0;

              there is no use masking it with wrong bits both axis need checked that why all these checks where done on the original code digital code. Im not quite sure what your trying to achieve here now im sure it will become clear though. Obviously this wont work mainline without an auto center fix for digital to analog controls or other older ports of mame. It will also cause issues if your left right up and down where mapped to dpad and your analog mappings where on the stick. It would make sense to use the same input ports your actually reading

              M 1 Reply Last reply Reply Quote 0
              • M
                mahoneyt944 @grant2258
                last edited by

                @grant2258 thank you,

                Ok so I'm adding dip switch options to this instead of using cheat input ports. I added new dip switches to the port list like this not sure if that right or not:

                PORT_DIPNAME( 0x01, 0x01, "Live Center" )
                PORT_DIPSETTING(    0x01, "On" )
                PORT_DIPSETTING(    0x00, "Off" )
                	
                PORT_DIPNAME( 0x01, 0x01, "Use Debounce Delay" )
                PORT_DIPSETTING(    0x01, "No" )
                PORT_DIPSETTING(    0x00, "Yes" )
                

                I want to check for that dip switch in my code, how do I do that?

                If (dipswitch on) do something
                

                How do I specifically check a certain dip switch?

                1 Reply Last reply Reply Quote 0
                • G
                  grant2258 Banned
                  last edited by

                  the same way use readinputport(portnumberfordipswitch) and check the number returned

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    mahoneyt944 @grant2258
                    last edited by

                    @grant2258

                    If I type readinputport(5), how do I know it's reading the switch for centering and not for bonus coins or something else?

                    1 Reply Last reply Reply Quote 0
                    • G
                      grant2258 Banned
                      last edited by grant2258

                      by checking the returned value youll need to mask the particular bit you want to check

                      M 1 Reply Last reply Reply Quote 0
                      • M
                        mahoneyt944 @grant2258
                        last edited by

                        @grant2258 how do I mask it? You mean give it its own port?

                        1 Reply Last reply Reply Quote 0
                        • G
                          grant2258 Banned
                          last edited by grant2258

                          what are you asking if you dont know how to mask just make another port each port returns the vaules its set by it. You compare these values when you read the port.

                          you dont really need to use any options just check the enable cheap input ports option if its enabled or not thats already there. Since youve choose to read analog ports instead of digital there is no need any other options.

                          1 Reply Last reply Reply Quote 0
                          • M
                            mahoneyt944
                            last edited by mahoneyt944

                            @grant2258
                            Here this is rev 4, it's geared towards correcting analog controls with precision but supports digital correction as well. I added dip settings to have more flexibility in what "feels right" to the player and the controller type they are using. I find that my junk ps2 style controller that has analog and digital varies compared to other analog controllers I have tried. I'll elaborate after I explain the dip settings:

                            Live Center - On / Off
                            Debounce Delay - 0, 2, 4, 6, 8, 10
                            

                            Live center activates the correction, turning it off ignores the entire fix including the delay set. Debounce delay sets how many skips there are between reads. Setting the delay to "2" for example, will skip two reads on each axis before a read(stopping direction) is set . Like so:

                            Delay set at 2
                            X -----S-R-S-S-R-S-S-R-S-S-R-S-S-R
                            Y -----S-S-R-S-S-R-S-S-R-S-S-R-S-S
                            

                            So why did I add these dip settings? Well, mostly for digital correction first and foremost. However, I found that because the stopping position is read in very rapidly the entire time your joy is off of center, this sometimes means that as you are pulling your stick back to center from where you want to be pointing, the stopping position is set while almost at center and sets it off a bit from where you expected to be. This issue can be corrected by adding a slight bit of delay or increasing the analog deadzone in the retroarch options menu to maintain more precision. I also found that my cabinet which uses an 8 way restrictor on a digital control doesn't need any delay because the restrictor doesn't allow you to linger long enough in any direction to be an issue. However, my junk PS2 style controller does because of its one piece arrow buttons design. So the delay really effects each controller differently.

                            In order to use this correction on a digital controller you must use grant2258 digital centering correction fix explained in an earlier post above along with this corrected driver. This correction truly makes this game a blast to play and is the closest emulated experience I've seen.

                            The only thing left to see is if there is any more wiggle room to add more stop positions near the outer ring of the joystick. Right now they are capped to 190 and 65 which is close. It's probably unnecessary but I like to be accurate.

                            foodf.c
                            Outdated

                            /***************************************************************************
                            
                            	Atari Food Fight hardware
                            
                            	driver by Aaron Giles
                            
                            	Games supported:
                            		* Food Fight
                            
                            	Known bugs:
                            		* none at this time
                            
                            ****************************************************************************
                            
                            	Memory map
                            
                            ****************************************************************************
                            
                            	========================================================================
                            	MAIN CPU
                            	========================================================================
                            	000000-00FFFF   R     xxxxxxxx xxxxxxxx   Program ROM
                            	014000-01BFFF   R/W   xxxxxxxx xxxxxxxx   Program RAM
                            	01C000-01CFFF   R/W   xxxxxxxx xxxxxxxx   Motion object RAM (1024 entries x 2 words)
                            	                R/W   x------- --------      (0: Horizontal flip)
                            	                R/W   -x------ --------      (0: Vertical flip)
                            	                R/W   ---xxxxx --------      (0: Palette select)
                            	                R/W   -------- xxxxxxxx      (0: Tile index)
                            	                R/W   xxxxxxxx --------      (1: X position)
                            	                R/W   -------- xxxxxxxx      (1: Y position)
                            	800000-8007FF   R/W   xxxxxxxx xxxxxxxx   Playfield RAM (32x32 tiles)
                            	                R/W   x------- --------      (Tile index MSB)
                            	                R/W   --xxxxxx --------      (Palette select)
                            	                R/W   -------- xxxxxxxx      (Tile index LSBs)
                            	900000-9001FF   R/W   -------- ----xxxx   NVRAM
                            	940000-940007   R     -------- xxxxxxxx   Analog input read
                            	944000-944007     W   -------- --------   Analog input select
                            	948000          R     -------- xxxxxxxx   Digital inputs
                            	                R     -------- x-------      (Self test)
                            	                R     -------- -x------      (Player 2 throw)
                            	                R     -------- --x-----      (Player 1 throw)
                            	                R     -------- ---x----      (Aux coin)
                            	                R     -------- ----x---      (2 player start)
                            	                R     -------- -----x--      (1 player start)
                            	                R     -------- ------x-      (Right coin)
                            	                R     -------- -------x      (Left coin)
                            	948000            W   -------- xxxxxxxx   Digital outputs
                            	                  W   -------- x-------      (Right coin counter)
                            	                  W   -------- -x------      (Left coin counter)
                            	                  W   -------- --x-----      (LED 2)
                            	                  W   -------- ---x----      (LED 1)
                            	                  W   -------- ----x---      (INT2 reset)
                            	                  W   -------- -----x--      (INT1 reset)
                            	                  W   -------- ------x-      (Update)
                            	                  W   -------- -------x      (Playfield flip)
                            	94C000            W   -------- --------   Unknown
                            	950000-9501FF     W   -------- xxxxxxxx   Palette RAM (256 entries)
                            	                  W   -------- xx------      (Blue)
                            	                  W   -------- --xxx---      (Green)
                            	                  W   -------- -----xxx      (Red)
                            	954000            W   -------- --------   NVRAM recall
                            	958000            W   -------- --------   Watchdog
                            	A40000-A4001F   R/W   -------- xxxxxxxx   POKEY 2
                            	A80000-A8001F   R/W   -------- xxxxxxxx   POKEY 1
                            	AC0000-AC001F   R/W   -------- xxxxxxxx   POKEY 3
                            	========================================================================
                            	Interrupts:
                            		IRQ1 = 32V
                            		IRQ2 = VBLANK
                            	========================================================================
                            
                            
                            ***************************************************************************/
                            
                            
                            #include "driver.h"
                            #include "machine/atarigen.h"
                            #include "vidhrdw/generic.h"
                            #include "foodf.h"
                            #include "bootstrap.h"
                            
                            
                            
                            /*************************************
                             *
                             *	Statics
                             *
                             *************************************/
                            
                            static UINT8 whichport = 0;
                            
                            
                            
                            /*************************************
                             *
                             *	NVRAM
                             *
                             *************************************/
                            
                            static READ16_HANDLER( nvram_r )
                            {
                            	return ((data16_t *)generic_nvram)[offset] | 0xfff0;
                            }
                            
                            
                            
                            /*************************************
                             *
                             *	Interrupts
                             *
                             *************************************/
                            
                            static void update_interrupts(void)
                            {
                            	int newstate = 0;
                            
                            	if (atarigen_scanline_int_state)
                            		newstate |= 1;
                            	if (atarigen_video_int_state)
                            		newstate |= 2;
                            
                            	if (newstate)
                            		cpu_set_irq_line(0, newstate, ASSERT_LINE);
                            	else
                            		cpu_set_irq_line(0, 7, CLEAR_LINE);
                            }
                            
                            
                            static void scanline_update(int scanline)
                            {
                            	/* INT 1 is on 32V */
                            	if (scanline & 32)
                            		atarigen_scanline_int_gen();
                            }
                            
                            
                            static MACHINE_INIT( foodf )
                            {
                            	atarigen_interrupt_reset(update_interrupts);
                            	atarigen_scanline_timer_reset(scanline_update, 32);
                            }
                            
                            
                            
                            /*************************************
                             *
                             *	Digital outputs
                             *
                             *************************************/
                            
                            static WRITE16_HANDLER( digital_w )
                            {
                            	if (ACCESSING_LSB)
                            	{
                            		foodf_set_flip(data & 0x01);
                            
                            		if (!(data & 0x04))
                            			atarigen_scanline_int_ack_w(0,0,0);
                            		if (!(data & 0x08))
                            			atarigen_video_int_ack_w(0,0,0);
                            
                            		coin_counter_w(0, (data >> 6) & 1);
                            		coin_counter_w(1, (data >> 7) & 1);
                            	}
                            }
                            
                            
                            
                            /*************************************
                             *
                             *	Analog inputs
                             *
                             *************************************/
                            
                            static READ16_HANDLER( analog_r )
                            {
                             
                             /****************************************************
                              * Live Center - rev 4 - by mahoneyt944 & grant2258 *
                              ****************************************************/
                            
                              static INT16 currentx  = 0x80; // face left start of first round
                              static INT16 currenty  = 0x7F;
                              static INT16 delay     = 0;    // debounce counter
                              static INT16 t         = 0;    // debounce count to reach
                              INT16  center          = 0;    // reset center check
                            
                            
                              // live center dip switch set -> On
                              if (readinputport(6) == 0x10)
                              {
                                // user set debounce delay from dip setting
                                if (readinputport(7) == 0xFF) t = 0;
                                else if (readinputport(7) == 0x02) t = 2;
                                else if (readinputport(7) == 0x04) t = 4;
                                else if (readinputport(7) == 0x06) t = 6;
                                else if (readinputport(7) == 0x08) t = 8;
                                else if (readinputport(7) == 0x0A) t = 10;
                                if (delay > t) delay = 0;
                            
                                // check for center
                                if (readinputport(0) == 0x7F && readinputport(2) == 0x7F) center = 1;
                            
                                if (delay == t) // debounce protection
                                {
                                  delay = 0;
                            
                                  if (whichport == 0) // x port called
                                  {
                                    if (center) {} // joy at center, no change
                                    else
                                    {
                                      INT16 temp = readinputport(whichport); // find new x stop direction
                                    
                                      if (temp > 128) // left
                                      {
                                        if (temp > 190) currentx = 190;
                                        else currentx = temp;
                                      }
                                    
                                      else if (temp < 128) // right
                                      {
                                        if (temp < 65) currentx = 65;
                                        else currentx = temp;
                                      }
                                      
                                      else currentx = 128; // x at center
                                    }
                                  }
                                  
                                  else if (whichport == 2) // y port called
                                  {
                                    if (center) {} // joy at center, no change
                                    else
                                    {
                                      INT16 temp = readinputport(whichport); // find new y stop direction
                                    
                                      if (temp > 128) // up
                                      {
                                        if (temp > 190) currenty = 190;
                                        else currenty = temp;
                                      }
                                    
                                      else if (temp < 128) // down
                                      {
                                        if (temp < 65) currenty = 65;
                                        else currenty = temp;
                                      }
                                      
                                      else currenty = 128; // y at center
                                    }
                                  }
                                }
                                else delay++;
                                
                                // return x position
                                if (whichport == 0)
                                {
                                  if (center)
                                    return currentx;
                                  return readinputport(whichport);
                                }
                            
                                // return y position
                                else if (whichport == 2)
                                {
                                  if (center)
                                    return currenty;
                                  return readinputport(whichport);
                                }
                                
                              }
                              
                              else // return original input 
                                return readinputport(whichport);
                            }
                            
                            
                            static WRITE16_HANDLER( analog_w )
                            {
                            	whichport = offset ^ 3;
                            }
                            
                            
                            
                            /*************************************
                             *
                             *	POKEY I/O
                             *
                             *************************************/
                            
                            static READ16_HANDLER( pokey1_word_r ) { return pokey1_r(offset); }
                            static READ16_HANDLER( pokey2_word_r ) { return pokey2_r(offset); }
                            static READ16_HANDLER( pokey3_word_r ) { return pokey3_r(offset); }
                            
                            static WRITE16_HANDLER( pokey1_word_w ) { if (ACCESSING_LSB) pokey1_w(offset, data & 0xff); }
                            static WRITE16_HANDLER( pokey2_word_w ) { if (ACCESSING_LSB) pokey2_w(offset, data & 0xff); }
                            static WRITE16_HANDLER( pokey3_word_w ) { if (ACCESSING_LSB) pokey3_w(offset, data & 0xff); }
                            
                            
                            
                            /*************************************
                             *
                             *	Main CPU memory handlers
                             *
                             *************************************/
                            
                            static MEMORY_READ16_START( readmem )
                            	{ 0x000000, 0x00ffff, MRA16_ROM },
                            	{ 0x014000, 0x01cfff, MRA16_RAM },
                            	{ 0x800000, 0x8007ff, MRA16_RAM },
                            	{ 0x900000, 0x9001ff, nvram_r },
                            	{ 0x940000, 0x940007, analog_r },
                            	{ 0x948000, 0x948001, input_port_4_word_r },
                            	{ 0x94c000, 0x94c001, MRA16_NOP }, /* Used from PC 0x776E */
                            	{ 0x958000, 0x958001, watchdog_reset16_r },
                            	{ 0xa40000, 0xa4001f, pokey2_word_r },
                            	{ 0xa80000, 0xa8001f, pokey1_word_r },
                            	{ 0xac0000, 0xac001f, pokey3_word_r },
                            MEMORY_END
                            
                            
                            static MEMORY_WRITE16_START( writemem )
                            	{ 0x000000, 0x00ffff, MWA16_ROM },
                            	{ 0x014000, 0x01bfff, MWA16_RAM },
                            	{ 0x01c000, 0x01cfff, MWA16_RAM, &spriteram16, &spriteram_size },
                            	{ 0x800000, 0x8007ff, atarigen_playfield_w, &atarigen_playfield },
                            	{ 0x900000, 0x9001ff, MWA16_RAM, (data16_t **)&generic_nvram, &generic_nvram_size },
                            	{ 0x944000, 0x944007, analog_w },
                            	{ 0x948000, 0x948001, digital_w },
                            	{ 0x950000, 0x9501ff, foodf_paletteram_w, &paletteram16 },
                            	{ 0x954000, 0x954001, MWA16_NOP },
                            	{ 0x958000, 0x958001, watchdog_reset16_w },
                            	{ 0xa40000, 0xa4001f, pokey2_word_w },
                            	{ 0xa80000, 0xa8001f, pokey1_word_w },
                            	{ 0xac0000, 0xac001f, pokey3_word_w },
                            MEMORY_END
                            
                            
                            
                            /*************************************
                             *
                             *	Port definitions
                             *
                             *************************************/
                            
                            INPUT_PORTS_START( foodf )
                            	PORT_START	/* IN0 */
                            	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_X | IPF_PLAYER1 | IPF_REVERSE, 100, 60, 0, 255 )
                            
                            	PORT_START	/* IN1 */
                            	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_X | IPF_PLAYER2 | IPF_REVERSE | IPF_COCKTAIL, 100, 60, 0, 255 )
                            
                            	PORT_START	/* IN2 */
                            	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_Y | IPF_PLAYER1 | IPF_REVERSE, 100, 60, 0, 255 )
                            
                            	PORT_START	/* IN3 */
                            	PORT_ANALOG( 0xff, 0x7f, IPT_AD_STICK_Y | IPF_PLAYER2 | IPF_REVERSE | IPF_COCKTAIL, 100, 60, 0, 255 )
                            
                            	PORT_START	/* IN4 */
                            	PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
                            	PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
                            	PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
                            	PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
                            	PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
                            	PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
                            	PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
                            	PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
                            
                            	PORT_START	/* SW1 */
                            	PORT_DIPNAME( 0x07, 0x00, "Bonus Coins" )
                            	PORT_DIPSETTING(    0x00, "None" )
                            	PORT_DIPSETTING(    0x05, "1 for every 2" )
                            	PORT_DIPSETTING(    0x02, "1 for every 4" )
                            	PORT_DIPSETTING(    0x01, "1 for every 5" )
                            	PORT_DIPSETTING(    0x06, "2 for every 4" )
                            	PORT_DIPNAME( 0x08, 0x00, DEF_STR( Coin_A ))
                            	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
                            	PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ))
                            	PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_B ))
                            	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
                            	PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ))
                            	PORT_DIPSETTING(    0x10, DEF_STR( 1C_5C ))
                            	PORT_DIPSETTING(    0x30, DEF_STR( 1C_6C ))
                            	PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coinage ))
                            	PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ))
                            	PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ))
                            	PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ))
                            	PORT_DIPSETTING(    0x40, DEF_STR( Free_Play ))
                            	
                            	PORT_START	/* Port #6 - Toggle for Live Center */
                            	PORT_DIPNAME( 0x10, 0x10, "Live Center" )
                            	PORT_DIPSETTING(    0x10, "On" )
                            	PORT_DIPSETTING(    0x00, "Off" )
                            	
                            	PORT_START	/* Port #7 - Settings for Debounce Delay */
                            	PORT_DIPNAME( 0xFF, 0xFF, "Debounce Delay" )
                            	PORT_DIPSETTING(    0xFF, "0" )
                            	PORT_DIPSETTING(    0x02, "2" )
                            	PORT_DIPSETTING(    0x04, "4" )
                            	PORT_DIPSETTING(    0x06, "6" )
                            	PORT_DIPSETTING(    0x08, "8" )
                            	PORT_DIPSETTING(    0x0A, "10")
                            
                            INPUT_PORTS_END
                            
                            
                            
                            /*************************************
                             *
                             *	Graphics definitions
                             *
                             *************************************/
                            
                            static struct GfxLayout charlayout =
                            {
                            	8,8,
                            	RGN_FRAC(1,1),
                            	2,
                            	{ 0, 4 },
                            	{ 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 },
                            	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
                            	8*16
                            };
                            
                            
                            static struct GfxLayout spritelayout =
                            {
                            	16,16,
                            	RGN_FRAC(1,2),
                            	2,
                            	{ RGN_FRAC(1,2), 0 },
                            	{ 8*16+0, 8*16+1, 8*16+2, 8*16+3, 8*16+4, 8*16+5, 8*16+6, 8*16+7, 0, 1, 2, 3, 4, 5, 6, 7 },
                            	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
                            	8*32
                            };
                            
                            
                            static struct GfxDecodeInfo gfxdecodeinfo[] =
                            {
                            	{ REGION_GFX1, 0, &charlayout,   0, 64 },	/* characters 8x8 */
                            	{ REGION_GFX2, 0, &spritelayout, 0, 64 },	/* sprites & playfield */
                            	{ -1 }
                            };
                            
                            
                            
                            /*************************************
                             *
                             *	Sound definitions
                             *
                             *************************************/
                            
                            static READ_HANDLER( pot_r )
                            {
                            	return (readinputport(5) >> offset) << 7;
                            }
                            
                            static struct POKEYinterface pokey_interface =
                            {
                            	3,
                            	600000,
                            	{ 33, 33, 33 },
                            	/* The 8 pot handlers */
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	{ pot_r, 0, 0 },
                            	/* The allpot handler */
                            	{ 0, 0, 0 }
                            };
                            
                            
                            
                            /*************************************
                             *
                             *	Machine driver
                             *
                             *************************************/
                            
                            static MACHINE_DRIVER_START( foodf )
                            
                            	/* basic machine hardware */
                            	MDRV_CPU_ADD(M68000, 6000000)
                            	MDRV_CPU_MEMORY(readmem,writemem)
                            	MDRV_CPU_VBLANK_INT(atarigen_video_int_gen,1)
                            
                            	MDRV_FRAMES_PER_SECOND(60)
                            	MDRV_VBLANK_DURATION(DEFAULT_60HZ_VBLANK_DURATION)
                            
                            	MDRV_MACHINE_INIT(foodf)
                            	MDRV_NVRAM_HANDLER(generic_1fill)
                            
                            	/* video hardware */
                            	MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
                            	MDRV_SCREEN_SIZE(32*8, 32*8)
                            	MDRV_VISIBLE_AREA(0*8, 32*8-1, 0*8, 28*8-1)
                            	MDRV_GFXDECODE(gfxdecodeinfo)
                            	MDRV_PALETTE_LENGTH(256)
                            
                            	MDRV_VIDEO_START(foodf)
                            	MDRV_VIDEO_UPDATE(foodf)
                            
                            	/* sound hardware */
                            	MDRV_SOUND_ADD(POKEY, pokey_interface)
                            MACHINE_DRIVER_END
                            
                            
                            
                            /*************************************
                             *
                             *	ROM definition(s)
                             *
                             *************************************/
                            
                            ROM_START( foodf )
                            	ROM_REGION( 0x10000, REGION_CPU1, 0 )	/* 64k for 68000 code */
                            	ROM_LOAD16_BYTE( "301-8c.020",   0x000001, 0x002000, CRC(dfc3d5a8) SHA1(7abe5e9c27098bd8c93cc06f1b9e3db0744019e9) )
                            	ROM_LOAD16_BYTE( "302-9c.020",   0x000000, 0x002000, CRC(ef92dc5c) SHA1(eb41291615165f549a68ebc6d4664edef1a04ac5) )
                            	ROM_LOAD16_BYTE( "303-8d.020",   0x004001, 0x002000, CRC(64b93076) SHA1(efa4090d96aa0ffd4192a045f174ac5960810bca) )
                            	ROM_LOAD16_BYTE( "304-9d.020",   0x004000, 0x002000, CRC(ea596480) SHA1(752aa33a8e8045650dd32ec7c7026e00d7896e0f) )
                            	ROM_LOAD16_BYTE( "305-8e.020",   0x008001, 0x002000, CRC(e6cff1b1) SHA1(7c7ad2dcdff60fc092e8a825c5a6de6b506523de) )
                            	ROM_LOAD16_BYTE( "306-9e.020",   0x008000, 0x002000, CRC(95159a3e) SHA1(f180126671776f62242ec9fd4a82a581c551ffce) )
                            	ROM_LOAD16_BYTE( "307-8f.020",   0x00c001, 0x002000, CRC(17828dbb) SHA1(9d8e29a5e56a8a9c5db8561e4c20ff22f69b46ca) )
                            	ROM_LOAD16_BYTE( "308-9f.020",   0x00c000, 0x002000, CRC(608690c9) SHA1(419020c69ce6fded0d9af44ead8ec4727468d58b) )
                            
                            	ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE )
                            	ROM_LOAD( "109-6lm.020",  0x000000, 0x002000, CRC(c13c90eb) SHA1(ebd2bbbdd7e184851d1ab4b5648481d966c78cc2) )
                            
                            	ROM_REGION( 0x4000, REGION_GFX2, ROMREGION_DISPOSE )
                            	ROM_LOAD( "110-4d.020",   0x000000, 0x002000, CRC(8870e3d6) SHA1(702007d3d543f872b5bf5d00b49f6e05b46d6600) )
                            	ROM_LOAD( "111-4e.020",   0x002000, 0x002000, CRC(84372edf) SHA1(9beef3ff3b28405c45d691adfbc233921073be47) )
                            ROM_END
                            
                            
                            ROM_START( foodf2 )
                            	ROM_REGION( 0x10000, REGION_CPU1, 0 )	/* 64k for 68000 code */
                            	ROM_LOAD16_BYTE( "201-8c.020",   0x000001, 0x002000, CRC(4ee52d73) SHA1(ff4ab8169a9b260bbd1f49023a30064e2f0b6686) )
                            	ROM_LOAD16_BYTE( "202-9c.020",   0x000000, 0x002000, CRC(f8c4b977) SHA1(824d33baa413b2ee898c75157624ea007c92032f) )
                            	ROM_LOAD16_BYTE( "203-8d.020",   0x004001, 0x002000, CRC(0e9f99a3) SHA1(37bba66957ee19e7d05fcc3e4583e909809075ed) )
                            	ROM_LOAD16_BYTE( "204-9d.020",   0x004000, 0x002000, CRC(f667374c) SHA1(d7be70b56500e2071b7f8c810f7a3e2a6743c6bd) )
                            	ROM_LOAD16_BYTE( "205-8e.020",   0x008001, 0x002000, CRC(1edd05b5) SHA1(cc712a11946c103eaa808c86e15676fde8610ad9) )
                            	ROM_LOAD16_BYTE( "206-9e.020",   0x008000, 0x002000, CRC(bb8926b3) SHA1(95c6ba8ac6b56d1a67a47758b71712d55a959cd0) )
                            	ROM_LOAD16_BYTE( "207-8f.020",   0x00c001, 0x002000, CRC(c7383902) SHA1(f76e2c95fccd0cafff9346a32e0c041c291a6696) )
                            	ROM_LOAD16_BYTE( "208-9f.020",   0x00c000, 0x002000, CRC(608690c9) SHA1(419020c69ce6fded0d9af44ead8ec4727468d58b) )
                            
                            	ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE )
                            	ROM_LOAD( "109-6lm.020",  0x000000, 0x002000, CRC(c13c90eb) SHA1(ebd2bbbdd7e184851d1ab4b5648481d966c78cc2) )
                            
                            	ROM_REGION( 0x4000, REGION_GFX2, ROMREGION_DISPOSE )
                            	ROM_LOAD( "110-4d.020",   0x000000, 0x002000, CRC(8870e3d6) SHA1(702007d3d543f872b5bf5d00b49f6e05b46d6600) )
                            	ROM_LOAD( "111-4e.020",   0x002000, 0x002000, CRC(84372edf) SHA1(9beef3ff3b28405c45d691adfbc233921073be47) )
                            ROM_END
                            
                            
                            ROM_START( foodfc )
                            	ROM_REGION( 0x10000, REGION_CPU1, 0 )	/* 64k for 68000 code */
                            	ROM_LOAD16_BYTE( "113-8c.020",   0x000001, 0x002000, CRC(193a299f) SHA1(58bbf714eff22d8a47b174e4b121f14a8dcb4ef9) )
                            	ROM_LOAD16_BYTE( "114-9c.020",   0x000000, 0x002000, CRC(33ed6bbe) SHA1(5d80fb092d2964b851e6c5982572d4ffc5078c55) )
                            	ROM_LOAD16_BYTE( "115-8d.020",   0x004001, 0x002000, CRC(64b93076) SHA1(efa4090d96aa0ffd4192a045f174ac5960810bca) )
                            	ROM_LOAD16_BYTE( "116-9d.020",   0x004000, 0x002000, CRC(ea596480) SHA1(752aa33a8e8045650dd32ec7c7026e00d7896e0f) )
                            	ROM_LOAD16_BYTE( "117-8e.020",   0x008001, 0x002000, CRC(12a55db6) SHA1(508f02c72074a0e3300ec32c181e4f72cbc4245f) )
                            	ROM_LOAD16_BYTE( "118-9e.020",   0x008000, 0x002000, CRC(e6d451d4) SHA1(03bfa932ed419572c08942ad159288b38d24d90f) )
                            	ROM_LOAD16_BYTE( "119-8f.020",   0x00c001, 0x002000, CRC(455cc891) SHA1(9f7764c15dea7568326860b910686fec644c42c2) )
                            	ROM_LOAD16_BYTE( "120-9f.020",   0x00c000, 0x002000, CRC(34173910) SHA1(19e6032c22d20410386516ffc1a809ae50431c65) )
                            
                            	ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE )
                            	ROM_LOAD( "109-6lm.020",  0x000000, 0x002000, CRC(c13c90eb) SHA1(ebd2bbbdd7e184851d1ab4b5648481d966c78cc2) )
                            
                            	ROM_REGION( 0x4000, REGION_GFX2, ROMREGION_DISPOSE )
                            	ROM_LOAD( "110-4d.020",   0x000000, 0x002000, CRC(8870e3d6) SHA1(702007d3d543f872b5bf5d00b49f6e05b46d6600) )
                            	ROM_LOAD( "111-4e.020",   0x002000, 0x002000, CRC(84372edf) SHA1(9beef3ff3b28405c45d691adfbc233921073be47) )
                            ROM_END
                            
                            
                            
                            /*************************************
                             *
                             *	Game driver(s)
                             *
                             *************************************/
                            
                            GAMEC( 1982, foodf,  0,     foodf, foodf, 0, ROT0, "Atari", "Food Fight (rev 3)",    &foodf_ctrl, &foodf_bootstrap  )
                            GAMEC( 1982, foodf2, foodf, foodf, foodf, 0, ROT0, "Atari", "Food Fight (rev 2)",    &foodf_ctrl, &foodf_bootstrap  )
                            GAMEC( 1982, foodfc, foodf, foodf, foodf, 0, ROT0, "Atari", "Food Fight (cocktail)", &foodf_ctrl, &foodfc_bootstrap )
                            
                            
                            1 Reply Last reply Reply Quote 0
                            • M
                              mahoneyt944
                              last edited by mahoneyt944

                              Live Center Rev 5 for Food Fight Release

                              • synchronized input reads
                              • finer delay control
                              • cocktail support added
                              • dip switch option live center ( on/off ) -- off is default, turn on to use hack.
                              • dip switch optional debounce delay setting ( 0 - 10 ) -- 0 is default, no delay, adjust as needed.
                              • can be used with digital controls if "Center axis for digital controls" is enabled in core options.
                              • simplified code

                              What is Live Center and why is food fight wrong even in current versions of mame?
                              Well first off, mame is emulating accurately. Food fight used a highly precise analog joystick that had a larger range in it's throw from center. This allowed you to partially press the joystick to change your aiming direction, without actually moving on screen.

                              The issue in emulating this game is a result of the controllers we most commonly use. Modern analog joysticks (such as a PS3 style controller) are stubby and have a short throw from center. The original joystick was tall giving you more range to work with. Food fight took advantage of this and set an inner and outer range of movement controls. The issue here is that modern joysticks almost skip over the inner range of control due to their short throw. This prevents you from easily aiming while standing still. Typically this means you must remain moving to aim properly. I call this the "facing right" issue.

                              Live center emulates the gameplay of the original stick by tracking the position you last pressed so that when you return the joystick to center, you will face in that direction to throw things. This emulates the inner range of control you'd normally have on a highly precise analog arcade style joystick without it. This allows the game play to be more natural for all analog joysticks. A bonus of this feature is that even a digital 8 way joystick can now be used to play the game if setup properly (read post #119).

                              #785 - foodf.c patch
                              #786 - digital centering correction patch
                              #815 - digital centering bug patch

                              1 Reply Last reply Reply Quote 0
                              • RiverstormR
                                Riverstorm
                                last edited by

                                @mahoneyt944 - Is Rev 5 the completed works? Any chance you'll be doing a commit to 2003plus of these new updates for Food Fight and the (grant2258) digital control corrections? It looks like some handy work and I wouldn't mind testing it out. It's one of my staple library games! ;)

                                M 1 Reply Last reply Reply Quote 0
                                • M
                                  mahoneyt944 @Riverstorm
                                  last edited by mahoneyt944

                                  @Riverstorm I made pull requests for both fixes but I do not have access to merge anything. You'll have to compile it yourself. Rev 5 works really well so far. #785 and #786

                                  Turn grants digital center correction on (if using digital joystick). Then go into the service menu under tests and calibrate the joystick. Then exit the service menu and turn live center on in the dip menu. Adjust the delay as needed.

                                  On a sanwa jlf 8 way digital joystick with 8 way restrictor in place a delay of 2 works well for me. The delay has to be set based on user preference and controller type though so adjust until it feels right. I typically test to make sure I can stop on the diagonals without any trouble. Then test quick directional changes to see that it lands where I want. If it doesn't the delay may be set too high.

                                  On a analog joystick I have a dead zone of 15 set in the core options but this can be adjusted to preference as well. Delay can be set at 0 for analog but I find it sets stops too fast for some of my controllers because it's setting stops as your releasing the joystick, so a little delay here helps too.

                                  One thing on the Todo list is to look into the auto calibration feature. I haven't had any issues with it yet but I suspect it may interfere since it calibrates when it wants. For right now you can always turn live center off and recalibrate in the service menu if needed. But again it hasn't been an issue.

                                  1 Reply Last reply Reply Quote 0
                                  • G
                                    grant2258 Banned
                                    last edited by

                                    @mahoneyt944

                                    i must admit i havent tried it but the code looks good to look at. I have to mute the game to play it to be honest the music drives me up the wall maybe it because I played it too much. I need to finish up my port nearly done just never seem to get round too it.

                                    Ive sorted sf2 just need to do toobin and mk games for the button mapping for arcade panels.

                                    I also need to fix some 3 player button games for gamepads like double dragon and double dragon 2 and renegade they work well on panels as is but are terrible on gamepads as default mapped.

                                    Also need to do some mapping for rotary games like midres and some other none rotary games that us the z x / nm none standard mapping and im done ill just sent them to l/r.

                                    It always nice to have a backup if my mini pc fails without having to set much up.

                                    Ill add the autocenter hack in and the foodf if i ever get to finishing it ill let you know there really not that much to do if your interested.

                                    https://github.com/grant2258/Blaster-Barcade use the alpha branch

                                    M 1 Reply Last reply Reply Quote 0
                                    • M
                                      mahoneyt944 @grant2258
                                      last edited by mahoneyt944

                                      @grant2258

                                      I'm still new to github, so pardon my ignorance. But what is blaster barcade? Is this just a private copy of 2003plus with more of your own changes? Any reason for this over using the official port besides access rights?

                                      I haven't coded in years and never was it for retro games, but it's coming back to me.

                                      Does anyone currently have access rights to mame2003-plus to merge? I've made pull requests already.

                                      1 Reply Last reply Reply Quote 0
                                      • G
                                        grant2258 Banned
                                        last edited by grant2258

                                        i used to be on the 2003 plus its a long story it was me mark and acradez not sure whos doing it now. My ports basicaly back to basics using the tab menu forget the pipe dream of libretro ever being able to do what the tab menu can and bring the screens back that told you when a game wasnt working that told you what one did ect. The biggest difference is the input there is no analog/digital selection both just work. no need to slip in between them and the 1 2 3 buttons are on the bottom row. The input was put and the most impressive macro loop ive seen that mark created. It was very limited though. Basically what you will see is my port when its done is the way i wanted to do input as apposed to the way i was pushed to implement it. It is actually done just needs a few games mapped teh problem ones. Its only for my own use so barcade is as important as gamespads to work properly. The three people working on it arent there mark isint keeping wel but we heard from him a while back he can sit on a chair now so thats some good news.

                                        M 1 Reply Last reply Reply Quote 0
                                        • M
                                          mahoneyt944 @grant2258
                                          last edited by

                                          @grant2258 that makes sense. Coming into the game late, it gets confusing looking at all the ports and branches especially just learning the system layout. But I just kind of figured mame2003 and 2003plus seem to be popular cores, and the cores I personally use, so working on them might reach more people. That's really the only reason for me to implement anything.

                                          I'd like to fix journey in 2003plus to support the sepways.wav samples implemented in later versions of mame too....a later project for my father, a game he plays frequently.

                                          1 Reply Last reply Reply Quote 0
                                          • G
                                            grant2258 Banned
                                            last edited by

                                            that one shouldn't be so hard to do to be honest. Im sure your dad would appreciate that. I think arcadez gave you the info in the other thread that you needed. Since me and libretro dont see eye to eye and banned me i will help people that have little problems that can be solved if they want them mainline they can do a pull req.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.