Esempio n. 1
0
int amiga_floppy_set_from_list(int drive, int index) {
    write_log("insert floppy (%d) into drive (%d)\n", index, drive);
    if (drive < 0 || drive > 3) {
        // assert
        return 0;
    }
    if (index < 0 || index >= AMIGA_FLOPPY_LIST_SIZE) {
        // assert
        return 0;
    }
    write_log("perform disk_swap drive %d floppy entry %d\n", drive, index);
    strcpy(changed_prefs.floppyslots[drive].df, currprefs.dfxlist[index]);
    //strcpy(currprefs.floppyslots[drive].df, currprefs.dfxlist[entry]);
    disk_insert(drive, currprefs.floppyslots[drive].df);
    /*
    int i;
    // eject disk from other drive (if inserted)
    for (i = 0; i < 4; i++) {
        if (strcmp (currprefs.floppyslots[i].df, currprefs.dfxlist[index]) == 0)
            changed_prefs.floppyslots[i].df[0] = 0;
    }
    // insert disk
    // FIXME: IMPORTANT: CHECK length of file (prevent buffer overrun)
    strcpy(changed_prefs.floppyslots[drive].df, currprefs.dfxlist[index]);
    config_changed = 1;
    return 1;
    */
    return 1;
}
Esempio n. 2
0
File: disk.c Progetto: balr0g/cw
/****************************************************************************
 * config_disk
 ****************************************************************************/
cw_bool_t
config_disk(
	struct config			*cfg,
	cw_count_t			revision)

	{
	cw_char_t			token[GLOBAL_MAX_NAME_SIZE];
	struct disk			dsk;

	disk_init(&dsk, revision);
	config_name(cfg, "disk name expected", token, sizeof (token));
	if (! disk_set_name(&dsk, token)) config_error(cfg, "already defined disk '%s' within this scope", token);
	config_disk_directive(cfg, &dsk, disk_init_track_default(&dsk), NULL, SCOPE_ENTER | SCOPE_TRACK | SCOPE_RW);
	if (! disk_tracks_used(&dsk)) config_error(cfg, "no tracks used in disk '%s'", token);
	if (! disk_image_ok(&dsk)) config_error(cfg, "specified format and image do not have the same level in disk '%s'", token);
	if (! disk_trackmap_ok(&dsk)) config_error(cfg, "trackmap incomplete or illegal use of side_offset or flip_side in disk '%s'", token);
	if (! disk_trackmap_numbering_ok(&dsk)) config_error(cfg, "image_track numbering in trackmap not compatible with selected image format in disk '%s'", token);
	disk_insert(&dsk);
	return (CW_BOOL_OK);
	}
static void extract_media(struct uae_prefs *p, unzFile uz, xmlNode *node)
{
  xmlNode *tmp = get_node(node, "media");
  if(tmp != NULL) 
  {
    for(xmlNode *curr_node = tmp; curr_node; curr_node = curr_node->next) 
    {
      int mediatype = -1;
      if (curr_node->type == XML_ELEMENT_NODE && strcmp((const char *)curr_node->name, _T("floppy")) == 0)
        mediatype = 0;
      else if (curr_node->type == XML_ELEMENT_NODE && strcmp((const char *)curr_node->name, _T("harddrive")) == 0)
        mediatype = 1;
      if(mediatype >= 0)
      {
        xmlChar *content = xmlNodeGetContent(curr_node);
        if(content != NULL) 
        {
          int priority = 0;
          xmlChar *attr = xmlGetProp(curr_node, (const xmlChar *) _T("priority"));
          if(attr != NULL) 
          {
            priority = atoi((const char *)attr);
            xmlFree(attr);
          }
        	
        	if (unzLocateFile (uz, (char *)content, 1) == UNZ_OK)
          {
            unz_file_info file_info;
            if (unzGetCurrentFileInfo (uz, &file_info, NULL, 0, NULL, 0, NULL, 0) == UNZ_OK)
            {
              void *buffer = malloc(file_info.uncompressed_size);
              if(buffer != NULL)
              {
                if (unzOpenCurrentFile (uz) == UNZ_OK)
                {
                  int readsize = unzReadCurrentFile(uz, buffer, file_info.uncompressed_size);
                  unzCloseCurrentFile(uz);
                  if(readsize == file_info.uncompressed_size)
                  {
                    char target_file[MAX_DPATH];
                    snprintf(target_file, MAX_DPATH, "%s%s", rp9tmp_path, content);
                    FILE *f = fopen(target_file, "wb");
                    if(f != NULL)
                    {
                      fwrite(buffer, 1, readsize, f);
                      fclose(f);
                      if(mediatype == 0)
                      {
                        // Add floppy
                        if(priority < 2)
                        {
                  	      strncpy(p->floppyslots[0].df, target_file, sizeof(p->floppyslots[0].df));
                  	      disk_insert(0, p->floppyslots[0].df);
                  	    }
                  	    else if(priority == 2 && p->nr_floppies > 1)
                	      {
                  	      strncpy(p->floppyslots[1].df, target_file, sizeof(p->floppyslots[1].df));
                  	      disk_insert(1, p->floppyslots[1].df);
                	      }
                  	    else if(priority == 3 && p->nr_floppies > 2)
                	      {
                  	      strncpy(p->floppyslots[2].df, target_file, sizeof(p->floppyslots[2].df));
                  	      disk_insert(2, p->floppyslots[2].df);
                	      }
                  	    else if(priority == 4 && p->nr_floppies > 3)
                	      {
                  	      strncpy(p->floppyslots[3].df, target_file, sizeof(p->floppyslots[3].df));
                  	      disk_insert(3, p->floppyslots[3].df);
                	      }
                        AddFileToDiskList(target_file, 1);
                      }
                      else
                      {
                        // Add hardfile
                        struct uaedev_config_info *uci;
                        char dhx[8];

                        sprintf(dhx, "DH%d", add_HDF_DHnum);
                        ++add_HDF_DHnum;
                        if(hardfile_testrdb (target_file))                        
                          uci = add_filesys_config(p, -1, dhx, 0, target_file, 0, 0, 0, 0, 512, 0, 0, 0, 0);
                        else
                          uci = add_filesys_config(p, -1, dhx, 0, target_file, 0, 32, 1, 2, 512, 0, 0, 0, 0);
                        if (uci)
    	                    hardfile_do_disk_change (uci, 1);
    	                  gui_force_rtarea_hdchange();
                      }
                      lstTmpRP9Files.push_back(target_file);
                    }
                  }
                }
                free(buffer);
              }
            }
          }
          
          xmlFree(content);
        }      
      }
    }
  }
}
Esempio n. 4
0
// Handler for the XM_NOTIFY message
HRESULT CRomListScene::OnNotifyPress( HXUIOBJ hObjPressed, 
       BOOL& bHandled )
    {
		int nIndex;
		wchar_t tmpFile[MAX_PATH];

        if ( hObjPressed == m_RomList )
        {
			nIndex = m_RomList.GetCurSel(); 
			 									 
			mainloopdone = 1;
			bHandled = TRUE;
			return S_OK;
			
        }
		else if ( hObjPressed == m_DriveList )
        {
            nIndex = m_DriveList.GetCurSel();
            //m_text1.SetText(m_commonlist.GetText(nIndex));;
            // handle list item press here...

			bHandled = TRUE;
			return S_OK;

        }
		else if (hObjPressed == m_DiskEject)
		{

			switch (currDrive)
			{
			case 0:
				swprintf_s(tmpFile, L"DF0 : Empty");
				m_DeviceDrive1.SetText(tmpFile);			 
				break;
			case 1:
				swprintf_s(tmpFile, L"DF1 : Empty");
				m_DeviceDrive2.SetText(tmpFile);			 
				break;
			case 2:
				swprintf_s(tmpFile, L"DF2 : Empty");
				m_DeviceDrive3.SetText(tmpFile);			 
				break;
			case 3:
				swprintf_s(tmpFile, L"DF3 : Empty");
				m_DeviceDrive4.SetText(tmpFile);			 
				break;
			}

			disk_eject(currDrive);

			bHandled = TRUE;
			return S_OK;

		}
		else if (hObjPressed == m_InsertDiskDrive0)
		{
			nIndex = m_RomList.GetCurSel(); 			 			 
		 				  
			switch (currDrive)
			{
			case 0:
				swprintf_s(tmpFile, L"DF0 : %S", (char *)m_ListData[nIndex].c_str());
				m_DeviceDrive1.SetText(tmpFile);			 
				break;
			case 1:
				swprintf_s(tmpFile, L"DF1 : %S", (char *)m_ListData[nIndex].c_str());
				m_DeviceDrive2.SetText(tmpFile);			 
				break;
			case 2:
				swprintf_s(tmpFile, L"DF2 : %S", (char *)m_ListData[nIndex].c_str());
				m_DeviceDrive3.SetText(tmpFile);			 
				break;
			case 3:
				swprintf_s(tmpFile, L"DF3 : %S", (char *)m_ListData[nIndex].c_str());
				m_DeviceDrive4.SetText(tmpFile);			 
				break;
			}
			
			

			strcpy(szRoms,"GAME:\\ROMS\\");
			strcat(szRoms,(char *)m_ListData[nIndex].c_str());


			if (currprefs.nr_floppies-1 < currDrive ) {
				currprefs.nr_floppies = currDrive  + 1;
			}

		 
			if (currprefs.floppyslots[currDrive].dfxtype < 0) {
				currprefs.floppyslots[currDrive].dfxtype = 0;
				DISK_check_change();
			}

 

			strcpy(changed_prefs.floppyslots[currDrive].df, szRoms);
			disk_insert (currDrive, changed_prefs.floppyslots[currDrive].df);
 

			config_changed = 1;
			bHandled = TRUE;
			return S_OK;
			


		}
		else if (hObjPressed == m_SwitchDrive)
		{

			
			currDrive++;

			if (currDrive > 3)
			{
				currDrive = 0;
			}

			switch (currDrive)
			{
			case 0:
				swprintf_s(tmpFile, L"Current Drive : DF0");
				break;
			case 1:
				swprintf_s(tmpFile, L"Current Drive : DF1");
				break;
			case 2:
				swprintf_s(tmpFile, L"Current Drive : DF2");
				break;
			case 3:
				swprintf_s(tmpFile, L"Current Drive : DF3");
				break;
			}

			m_SwitchDrive.SetText(tmpFile);


			bHandled = TRUE;
			return S_OK;

			
		}
		else if (hObjPressed == m_Kick)
		{

			XuiSceneCreate( L"file://game:/media/skin.xzp#Skin\\", L"KickStart.xur", NULL, &hKickScene );
			this->NavigateForward(hKickScene);	

			bHandled = TRUE;
			return S_OK;
		}		 
		else if (hObjPressed == m_ResetAmiga)
		{		
			uae_reset(0);
			mainloopdone = 1;
			return S_OK;
		}
		else if (hObjPressed == m_Back)
		{

			this->NavigateBack(hMainScene);
			bHandled = TRUE;
			return S_OK;

		}
		
 
		 
        bHandled = TRUE;
        return S_OK;
    }
Esempio n. 5
0
// In this procedure, we use changed_prefs
int loadconfig_old(struct uae_prefs *p, const char *orgpath)
{
  char path[MAX_PATH];
  int cpu_level;
  
  strcpy(path, orgpath);
	char *ptr = strstr(path, ".uae");
	if(ptr > 0)
  {
    *(ptr + 1) = '\0';
    strcat(path, "conf");
  }
		
	FILE *f=fopen(path,"rt");
	if (!f){
		write_log ("No config file %s!\n",path);
		return 0;
	}
	else
	{
		// Set everthing to default and clear HD settings
		default_prefs(p, 0);
		SetDefaultMenuSettings(p);
	
		char filebuffer[256];
		int dummy;

		fscanf(f,"kickstart=%d\n",&kickstart);
#if defined(PANDORA) || defined(ANDROIDSDL)
		fscanf(f,"scaling=%d\n",&dummy);
#else
		fscanf(f,"scaling=%d\n",&mainMenu_enableHWscaling);
#endif
		fscanf(f,"showstatus=%d\n", &p->leds_on_screen);
		fscanf(f,"mousemultiplier=%d\n", &p->input_joymouse_multiplier);
		p->input_joymouse_multiplier *= 10;
#if defined(PANDORA) || defined(ANDROIDSDL)
		fscanf(f,"systemclock=%d\n",&dummy);    // mainMenu_throttle never changes -> removed
		fscanf(f,"syncthreshold=%d\n", &dummy); // timeslice_mode never changes -> removed
#else
		fscanf(f,"systemclock=%d\n",&mainMenu_throttle);
		fscanf(f,"syncthreshold=%d\n", &timeslice_mode);
#endif
		fscanf(f,"frameskip=%d\n", &p->gfx_framerate);
		fscanf(f,"sound=%d\n",&p->produce_sound );
		if(p->produce_sound >= 10)
	  {
	    p->sound_stereo = 1;
	    p->produce_sound -= 10;
	    if(p->produce_sound > 0)
	      p->produce_sound += 1;
	  }
	  else
	    p->sound_stereo = 0;
		fscanf(f,"soundrate=%d\n",&p->sound_freq);
		fscanf(f,"autosave=%d\n", &dummy);
		fscanf(f,"gp2xclock=%d\n", &dummy);
		int joybuffer = 0;
		fscanf(f,"joyconf=%d\n",&joybuffer);
		fscanf(f,"autofireRate=%d\n",&p->input_autofire_linecnt);
		p->input_autofire_linecnt = p->input_autofire_linecnt * 312;
		fscanf(f,"autofire=%d\n", &dummy);
		fscanf(f,"stylusOffset=%d\n",&dummy);
		fscanf(f,"tapDelay=%d\n",&p->pandora_tapDelay);
		fscanf(f,"scanlines=%d\n", &dummy);
#if defined(PANDORA) || defined(ANDROIDSDL)
		fscanf(f,"ham=%d\n",&dummy);
#else
		fscanf(f,"ham=%d\n",&mainMenu_ham);
#endif
		fscanf(f,"enableScreenshots=%d\n", &dummy);
		fscanf(f,"floppyspeed=%d\n",&p->floppy_speed);
		fscanf(f,"drives=%d\n", &p->nr_floppies);
		fscanf(f,"videomode=%d\n", &p->ntscmode);
		if(p->ntscmode)
		  p->chipset_refreshrate = 60;
		else
		  p->chipset_refreshrate = 50;
		fscanf(f,"mainMenu_cpuSpeed=%d\n",&p->pandora_cpu_speed);
		fscanf(f,"presetModeId=%d\n",&presetModeId);
		fscanf(f,"moveX=%d\n", &p->pandora_horizontal_offset);
		fscanf(f,"moveY=%d\n", &p->pandora_vertical_offset);
		fscanf(f,"displayedLines=%d\n",&p->gfx_size.height);
		fscanf(f,"screenWidth=%d\n", &p->gfx_size_fs.width);
		fscanf(f,"cutLeft=%d\n", &dummy);
		fscanf(f,"cutRight=%d\n", &dummy);
		fscanf(f,"customControls=%d\n",&p->pandora_customControls);
		fscanf(f,"custom_dpad=%d\n",&dummy);
		fscanf(f,"custom_up=%d\n",&customControlMap[SDLK_UP]);
		fscanf(f,"custom_down=%d\n",&customControlMap[SDLK_DOWN]);
		fscanf(f,"custom_left=%d\n",&customControlMap[SDLK_LEFT]);
		fscanf(f,"custom_right=%d\n",&customControlMap[SDLK_RIGHT]);
		fscanf(f,"custom_A=%d\n",&customControlMap[SDLK_HOME]);
		fscanf(f,"custom_B=%d\n",&customControlMap[SDLK_END]);
		fscanf(f,"custom_X=%d\n",&customControlMap[SDLK_PAGEDOWN]);
		fscanf(f,"custom_Y=%d\n",&customControlMap[SDLK_PAGEUP]);
		fscanf(f,"custom_L=%d\n",&customControlMap[SDLK_RSHIFT]);
		fscanf(f,"custom_R=%d\n",&customControlMap[SDLK_RCTRL]);
		fscanf(f,"cpu=%d\n", &cpu_level);
		if(cpu_level > 0) // M68000
		  // Was old format
		  cpu_level = 2; // M68020
		fscanf(f,"chipset=%d\n", &p->chipset_mask);
		p->immediate_blits = (p->chipset_mask & 0x100) == 0x100;
  	switch (p->chipset_mask & 0xff) 
  	{
  		case 1: p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; break;
  		case 2: p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA; break;
  		default: p->chipset_mask = CSMASK_ECS_AGNUS; break;
  	}
		fscanf(f,"cpu=%d\n", &p->m68k_speed);
	  if(p->m68k_speed < 0)
    {
      // New version of this option
      p->m68k_speed = -p->m68k_speed;
    }
    else
    {
      // Old version (500 5T 1200 12T 12T2)
	    if(p->m68k_speed >= 2)
      {
        // 1200: set to 68020 with 14 MHz
        cpu_level = 2; // M68020
        p->m68k_speed--;
        if(p->m68k_speed > 2)
          p->m68k_speed = 2;
      }
	  }
	  if(p->m68k_speed == 1)
	    p->m68k_speed = M68K_SPEED_14MHZ_CYCLES;
	  if(p->m68k_speed == 2)
	    p->m68k_speed = M68K_SPEED_25MHZ_CYCLES;
    p->cachesize = 0;
    p->cpu_compatible = 0;
    switch(cpu_level)
    {
      case 0:
        p->cpu_model = 68000;
        p->fpu_model = 0;
        break;
      case 1:
        p->cpu_model = 68010;
        p->fpu_model = 0;
        break;
      case 2:
        p->cpu_model = 68020;
        p->fpu_model = 0;
        break;
      case 3:
        p->cpu_model = 68020;
        p->fpu_model = 68881;
        break;
      case 4:
        p->cpu_model = 68040;
        p->fpu_model = 68881;
        break;
    }
    
	  disk_eject(0);
	  disk_eject(1);
	  disk_eject(2);
	  disk_eject(3);
		fscanf(f,"df0=%s\n",&filebuffer);
		replace(filebuffer,' ','|');
		if(DISK_validate_filename(p, filebuffer, 0, NULL, NULL, NULL))
  		strcpy(p->floppyslots[0].df, filebuffer);
  	else
  	  p->floppyslots[0].df[0] = 0;
		disk_insert(0, filebuffer);
		if(p->nr_floppies > 1)
		{
			memset(filebuffer, 0, 256);
			fscanf(f,"df1=%s\n",&filebuffer);
			replace(filebuffer,' ','|');
  		if(DISK_validate_filename(p, filebuffer, 0, NULL, NULL, NULL))
    		strcpy(p->floppyslots[1].df, filebuffer);
    	else
    	  p->floppyslots[1].df[0] = 0;
			disk_insert(1, filebuffer);
		}
		if(p->nr_floppies > 2)
		{
			memset(filebuffer, 0, 256);
			fscanf(f,"df2=%s\n",&filebuffer);
			replace(filebuffer,' ','|');
  		if(DISK_validate_filename(p, filebuffer, 0, NULL, NULL, NULL))
    		strcpy(p->floppyslots[2].df, filebuffer);
    	else
    	  p->floppyslots[2].df[0] = 0;
			disk_insert(2, filebuffer);
		}
		if(p->nr_floppies > 3)
		{
			memset(filebuffer, 0, 256);
			fscanf(f,"df3=%s\n",&filebuffer);
			replace(filebuffer,' ','|');
  		if(DISK_validate_filename(p, filebuffer, 0, NULL, NULL, NULL))
    		strcpy(p->floppyslots[3].df, filebuffer);
    	else
    	  p->floppyslots[3].df[0] = 0;
			disk_insert(3, filebuffer);
		}

		for(int i=0; i<4; ++i)
		{
		  if(i < p->nr_floppies)
		    p->floppyslots[i].dfxtype = DRV_35_DD;
		  else
		    p->floppyslots[i].dfxtype = DRV_NONE;
		}
	
		fscanf(f,"chipmemory=%d\n",&p->chipmem_size);
		if(p->chipmem_size < 10)
		  // Was saved in old format
		  p->chipmem_size = 0x80000 << p->chipmem_size;
		fscanf(f,"slowmemory=%d\n",&p->bogomem_size);
		if(p->bogomem_size > 0 && p->bogomem_size < 10)
		  // Was saved in old format
		  p->bogomem_size = 
		    (p->bogomem_size <= 2) ? 0x080000 << p->bogomem_size :
		    (p->bogomem_size == 3) ? 0x180000 : 0x1c0000;
		fscanf(f,"fastmemory=%d\n",&p->fastmem_size);
		if(p->fastmem_size > 0 && p->fastmem_size < 10)
		  // Was saved in old format
		  p->fastmem_size = 0x080000 << p->fastmem_size;
#ifdef ANDROIDSDL		
		fscanf(f,"onscreen=%d\n",&mainMenu_onScreen);
		fscanf(f,"onScreen_textinput=%d\n",&mainMenu_onScreen_textinput);
		fscanf(f,"onScreen_dpad=%d\n",&mainMenu_onScreen_dpad);
		fscanf(f,"onScreen_button1=%d\n",&mainMenu_onScreen_button1);
		fscanf(f,"onScreen_button2=%d\n",&mainMenu_onScreen_button2);
		fscanf(f,"onScreen_button3=%d\n",&mainMenu_onScreen_button3);
		fscanf(f,"onScreen_button4=%d\n",&mainMenu_onScreen_button4);
		fscanf(f,"onScreen_button5=%d\n",&mainMenu_onScreen_button5);
		fscanf(f,"onScreen_button6=%d\n",&mainMenu_onScreen_button6);
		fscanf(f,"custom_position=%d\n",&mainMenu_custom_position);
		fscanf(f,"pos_x_textinput=%d\n",&mainMenu_pos_x_textinput);
		fscanf(f,"pos_y_textinput=%d\n",&mainMenu_pos_y_textinput);
		fscanf(f,"pos_x_dpad=%d\n",&mainMenu_pos_x_dpad);
		fscanf(f,"pos_y_dpad=%d\n",&mainMenu_pos_y_dpad);
		fscanf(f,"pos_x_button1=%d\n",&mainMenu_pos_x_button1);
		fscanf(f,"pos_y_button1=%d\n",&mainMenu_pos_y_button1);
		fscanf(f,"pos_x_button2=%d\n",&mainMenu_pos_x_button2);
		fscanf(f,"pos_y_button2=%d\n",&mainMenu_pos_y_button2);
		fscanf(f,"pos_x_button3=%d\n",&mainMenu_pos_x_button3);
		fscanf(f,"pos_y_button3=%d\n",&mainMenu_pos_y_button3);
		fscanf(f,"pos_x_button4=%d\n",&mainMenu_pos_x_button4);
		fscanf(f,"pos_y_button4=%d\n",&mainMenu_pos_y_button4);
		fscanf(f,"pos_x_button5=%d\n",&mainMenu_pos_x_button5);
		fscanf(f,"pos_y_button5=%d\n",&mainMenu_pos_y_button5);
		fscanf(f,"pos_x_button6=%d\n",&mainMenu_pos_x_button6);
		fscanf(f,"pos_y_button6=%d\n",&mainMenu_pos_y_button6);
		fscanf(f,"quick_switch=%d\n",&mainMenu_quickSwitch);
		fscanf(f,"FloatingJoystick=%d\n",&mainMenu_FloatingJoystick);
#endif
	
		fclose(f);
	}

	SetPresetMode(presetModeId, p);

  CheckKickstart(p);

	return 1;
}