Previous 199869 Revisions Next

r20848 Friday 8th February, 2013 at 21:47:17 UTC by Wilbert Pol
(MESS) gba.c: Minor cleanups (nw)
[src/mess/drivers]gba.c
[src/mess/video]gba.c

trunk/src/mess/video/gba.c
r20847r20848
2222      va_start( v, s_fmt );
2323      vsprintf( buf, s_fmt, v );
2424      va_end( v );
25      logerror( "%08x: %s", machine.device("maincpu")->safe_pc(), buf );
25      logerror( "%08x: %s", machine.driver_data<gba_state>()->m_maincpu->pc(), buf );
2626   }
2727}
2828
trunk/src/mess/drivers/gba.c
r20847r20848
3535      va_start( v, s_fmt );
3636      vsprintf( buf, s_fmt, v );
3737      va_end( v );
38      logerror( "%08x: %s", machine.device("maincpu")->safe_pc(), buf );
38      logerror( "%08x: %s", machine.driver_data<gba_state>()->m_maincpu->pc(), buf );
3939   }
4040}
4141
r20847r20848
29572957
29582958DEVICE_IMAGE_LOAD_MEMBER( gba_state, gba_cart )
29592959{
2960   UINT8 *ROM = image.device().machine().root_device().memregion("cartridge")->base();
2960   UINT8 *ROM = memregion("cartridge")->base();
29612961   UINT32 cart_size;
29622962   UINT32 chip = 0;
2963   gba_state *state = image.device().machine().driver_data<gba_state>();
29642963
2965   state->m_nvsize = 0;
2966   state->m_flash_size = 0;
2967   state->m_nvptr = (UINT8 *)NULL;
2968   state->m_flash_battery_load = 0;
2964   m_nvsize = 0;
2965   m_flash_size = 0;
2966   m_nvptr = (UINT8 *)NULL;
2967   m_flash_battery_load = 0;
29692968
29702969   if (image.software_entry() == NULL)
29712970   {
r20847r20848
29942993      mame_printf_info( "GBA: Detected (ROM) %s\n", gba_chip_string( chip).cstr());
29952994
29962995      // fix the previous value when possible
2997      chip = gba_fix_wrong_chip(image.device().machine(), cart_size, chip);
2996      chip = gba_fix_wrong_chip(machine(), cart_size, chip);
29982997   }
29992998
30002999   mame_printf_info( "GBA: Emulate %s\n", gba_chip_string( chip).cstr());
30013000
30023001   if ((chip & (GBA_CHIP_EEPROM | GBA_CHIP_EEPROM_4K | GBA_CHIP_EEPROM_64K)) != 0)
30033002   {
3004      state->m_nvptr = (UINT8 *)&state->m_gba_eeprom;
3005      state->m_nvsize = (chip & GBA_CHIP_EEPROM_64K) ? 0x2000 : 0x200;
3003      m_nvptr = (UINT8 *)m_gba_eeprom;
3004      m_nvsize = (chip & GBA_CHIP_EEPROM_64K) ? 0x2000 : 0x200;
30063005
3007      state->m_eeprom_addr_bits = (chip & GBA_CHIP_EEPROM_64K) ? 14 : 6;
3006      m_eeprom_addr_bits = (chip & GBA_CHIP_EEPROM_64K) ? 14 : 6;
30083007
30093008      if (cart_size <= (16 * 1024 * 1024))
30103009      {
3011         image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xd000000, 0xdffffff, read32_delegate(FUNC(gba_state::eeprom_r),state));
3012         image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xd000000, 0xdffffff, write32_delegate(FUNC(gba_state::eeprom_w),state));
3010         m_maincpu->space(AS_PROGRAM).install_read_handler(0xd000000, 0xdffffff, read32_delegate(FUNC(gba_state::eeprom_r),this));
3011         m_maincpu->space(AS_PROGRAM).install_write_handler(0xd000000, 0xdffffff, write32_delegate(FUNC(gba_state::eeprom_w),this));
30133012      }
30143013      else
30153014      {
3016         image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xdffff00, 0xdffffff, read32_delegate(FUNC(gba_state::eeprom_r),state));
3017         image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xdffff00, 0xdffffff, write32_delegate(FUNC(gba_state::eeprom_w),state));
3015         m_maincpu->space(AS_PROGRAM).install_read_handler(0xdffff00, 0xdffffff, read32_delegate(FUNC(gba_state::eeprom_r),this));
3016         m_maincpu->space(AS_PROGRAM).install_write_handler(0xdffff00, 0xdffffff, write32_delegate(FUNC(gba_state::eeprom_w),this));
30183017      }
30193018   }
30203019
30213020   if (chip & GBA_CHIP_SRAM)
30223021   {
3023      state->m_nvptr = (UINT8 *)&state->m_gba_sram;
3024      state->m_nvsize = 0x10000;
3022      m_nvptr = (UINT8 *)&m_gba_sram;
3023      m_nvsize = 0x10000;
30253024
3026      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xe000000, 0xe00ffff, read32_delegate(FUNC(gba_state::sram_r),state));
3027      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xe000000, 0xe00ffff, write32_delegate(FUNC(gba_state::sram_w),state));
3025      m_maincpu->space(AS_PROGRAM).install_read_handler(0xe000000, 0xe00ffff, read32_delegate(FUNC(gba_state::sram_r),this));
3026      m_maincpu->space(AS_PROGRAM).install_write_handler(0xe000000, 0xe00ffff, write32_delegate(FUNC(gba_state::sram_w),this));
30283027   }
30293028
30303029   if (chip & GBA_CHIP_FLASH_1M)
30313030   {
3032      state->m_nvptr = NULL;
3033      state->m_nvsize = 0;
3034      state->m_flash_size = 0x20000;
3035      state->m_flash_mask = 0x1ffff/4;
3031      m_nvptr = NULL;
3032      m_nvsize = 0;
3033      m_flash_size = 0x20000;
3034      m_flash_mask = 0x1ffff/4;
30363035
3037      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xe000000, 0xe01ffff, read32_delegate(FUNC(gba_state::flash_r),state));
3038      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xe000000, 0xe01ffff, write32_delegate(FUNC(gba_state::flash_w),state));
3036      m_maincpu->space(AS_PROGRAM).install_read_handler(0xe000000, 0xe01ffff, read32_delegate(FUNC(gba_state::flash_r),this));
3037      m_maincpu->space(AS_PROGRAM).install_write_handler(0xe000000, 0xe01ffff, write32_delegate(FUNC(gba_state::flash_w),this));
30393038   }
30403039
30413040   if ((chip & GBA_CHIP_FLASH) || (chip & GBA_CHIP_FLASH_512))
30423041   {
3043      state->m_nvptr = NULL;
3044      state->m_nvsize = 0;
3045      state->m_flash_size = 0x10000;
3046      state->m_flash_mask = 0xffff/4;
3042      m_nvptr = NULL;
3043      m_nvsize = 0;
3044      m_flash_size = 0x10000;
3045      m_flash_mask = 0xffff/4;
30473046
3048      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0xe000000, 0xe00ffff, read32_delegate(FUNC(gba_state::flash_r),state));
3049      image.device().machine().device("maincpu")->memory().space(AS_PROGRAM).install_write_handler(0xe000000, 0xe00ffff, write32_delegate(FUNC(gba_state::flash_w),state));
3047      m_maincpu->space(AS_PROGRAM).install_read_handler(0xe000000, 0xe00ffff, read32_delegate(FUNC(gba_state::flash_r),this));
3048      m_maincpu->space(AS_PROGRAM).install_write_handler(0xe000000, 0xe00ffff, write32_delegate(FUNC(gba_state::flash_w),this));
30503049   }
30513050
30523051   if (chip & GBA_CHIP_RTC)
r20847r20848
30553054   }
30563055
30573056   // if save media was found, reload it
3058   if (state->m_nvsize > 0)
3057   if (m_nvsize > 0)
30593058   {
3060      image.battery_load(state->m_nvptr, state->m_nvsize, 0x00);
3061      state->m_nvimage = image;
3059      image.battery_load(m_nvptr, m_nvsize, 0x00);
3060      m_nvimage = image;
30623061   }
30633062   else
30643063   {
3065      state->m_nvimage = NULL;
3066      state->m_nvsize = 0;
3064      m_nvimage = NULL;
3065      m_nvsize = 0;
30673066   }
30683067
30693068   // init the flash here so it gets the contents from the battery_load above
3070   if (state->m_flash_size > 0)
3069   if (m_flash_size > 0)
30713070   {
3072      if (state->m_flash_size == 0x10000)
3073         state->m_mFlashDev = image.device().machine().device<intelfsh8_device>("pflash");
3071      if (m_flash_size == 0x10000)
3072         m_mFlashDev = machine().device<intelfsh8_device>("pflash");
30743073      else
3075         state->m_mFlashDev = image.device().machine().device<intelfsh8_device>("sflash");
3076      state->m_flash_battery_load = 1;
3077      state->m_nvimage = image;
3074         m_mFlashDev = machine().device<intelfsh8_device>("sflash");
3075      m_flash_battery_load = 1;
3076      m_nvimage = image;
30783077   }
30793078
30803079   // mirror the ROM

Previous 199869 Revisions Next


© 1997-2024 The MAME Team