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.3k 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.
    • G
      grant2258 Banned
      last edited by

      im lost now the digital code on runs when you set the cheat options it in the if condition.

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

        @grant2258 I'm just saying this fix benefits when using analog sticks too but at the cost of cutting the analogs precision to 8 way. That's all. Analog always centers facing to the right and it sucks to play it that way. I know this input cheat is not intended for analog but using it with the analog stick allows you to center facing more properly.

        So it got me thinking if we use the off section of our cheat input option to correct analog to stop facing in the direction last pressed too it would complete the driver. It's just a lot more directions to account for on analog.

        Cheat Input Off would fix analog and on would fix digital.

        I'll never use analog because my cab has digital but it would be cool to see fixed for the benefit of the games emulation.

        To correct analog in this hypothetical cheat input off code it would be something like:

        if (centered) { return stop_direction;}
        Else return readinputport(whichport);
        

        The stop_direction would be set based on the last position your stick was in before centering. Similarly to what you did to fix digital . Just more directions to account for.

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

          you would need to look at that but thats not in the original games specs. The rolling just the eyes is important in analog controls in this game the gimbal lets you walk up to piles of food and throw it all directions without moving because it had such a big throw it would be easy to pull off. I think it would be a sane move to return 7f in digital if your going to switch between the two.

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

            @grant2258 agreed.

            So is Digital uses 0 to 255, 128 being center and analog uses 00 to FF, 7F being center? Correct?

            I'll look into it at a later date. No hurry right now though.

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

              nope analog uses 0 - 255 as well the fist 0xff hex is (255 decimal) ff is the mask the second 0x7f is default center value. the min and max are at the end

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

                @grant2258
                @Cornervizion

                Here's a true control fix for food fight that I'm calling "Live center - rev 3".

                Turning on cheat input ports activates the code for analog joysticks without debounce delay. If you're using a digital joystick, you must also turn on grant2258's centering fix which will use the same fix that analog uses but with debounce delay.

                Still some things I'd like to edit but I've had enough for today, probably a rev 4 coming soon though when I find more time. I plan to tighten up any dead zones for analog so every possible value is accounted for to be completely accuracy, its fairly close now though. I'd like to eventually implement this into an official driver for the game so it just finally "fixed" once and for all once it's perfect. Credit to grant2258 for his work done in the earlier code versions above that made this possible.

                For now though here's the WIP foodf.c driver with fixes implemented:
                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 3 - by mahoneyt944 & grant2258 *
                  ****************************************************/
                
                  static INT16  currentx  = 0x80; // face left start of first round
                  static INT16  currenty  = 0x7F;
                  static INT16  delay     = 0;
                  INT16 center = readinputport(6) & ~16; // check for joy center
                  INT16 t = 0; // no debounce delay for analog
                
                
                  // 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);
                }
                
                
                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	/* fake port for digital joystick control */
                	PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_CHEAT )
                	PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_CHEAT )
                	PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_CHEAT )
                	PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_CHEAT )
                
                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
                • G
                  grant2258 Banned
                  last edited by

                  honestly this was just for digital control hacks you would be better off adding a dipswitch option. with

                  controls hack -> digital hack
                  controls hack -> analog hack
                  controls hack -> off
                  
                  M 1 Reply Last reply Reply Quote 0
                  • M
                    mahoneyt944 @grant2258
                    last edited by mahoneyt944

                    @grant2258 yeah that would be a good idea. Under dip switch we'll have an option.

                    Live Center - On/Off
                    Use Debounce Delay - No/Yes
                    

                    Live centering turns the hack on and off, default being on. Use Debounce Delay adds a delay or not, default being no.

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

                      @grant2258
                      So I don't know how to properly add/ use dip switch options. I added this:

                      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" )
                      

                      Then I need to update my code to something like this but with the right argument:

                      if ("Live Center dip -> On") // live center dip switch set -> On
                      {
                        // check debounce dip switch
                        If ("Use Debounce Delay dip -> No") t = 0;) // debounce dip set -> No
                          else { t = 8; if (delay > t) delay = 0; } // debounce dip set -> Yes
                      
                      // rest of code
                      

                      What argument do I need to get the dip values for each switch?

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

                        really dont understand what your doing here at all you dont need debounce for analog ports. I thought you wanted this to work in barcade which is digital you removed that. You would be better removing the cheat port as its not needed since your reading the analog ports again. I really doesnt matter what way you do it if you want it to go upstream you need to enable the original functionality as well.

                        M 1 Reply Last reply Reply Quote 0
                        • 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
                                            • 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.