Advertisement
metalx1000

X-MEN vs STREET FIGHTER - mame

Aug 24th, 2014
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. Gets and Runs Marvel vs. Capcom MAME ROMS
  3. PowerShell -ExecutionPolicy Bypass .\mvsc_mame.ps1
  4. #>
  5. function Main(){
  6.     Add-Type -AssemblyName presentationCore
  7.     $mediaPlayer = New-Object system.windows.media.mediaplayer
  8.     $music = "http://a.tumblr.com/tumblr_lxlq4i1EPI1qckwxco1.mp3"
  9.     $mediaPlayer.open($music)
  10.     $mediaPlayer.Play()
  11.    
  12.     $folder = "xmvsf"
  13.     $storageDir = "$pwd"
  14.    
  15.     function DownloadFile($url, $targetFile)
  16.    
  17.     {
  18.    
  19.        $uri = New-Object "System.Uri" "$url"
  20.    
  21.        $request = [System.Net.HttpWebRequest]::Create($uri)
  22.    
  23.        $request.set_Timeout(15000) #15 second timeout
  24.    
  25.        $response = $request.GetResponse()
  26.    
  27.        $totalLength = [System.Math]::Floor($response.get_ContentLength()/1024)
  28.    
  29.        $responseStream = $response.GetResponseStream()
  30.    
  31.        $targetStream = New-Object -TypeName System.IO.FileStream -ArgumentList $targetFile, Create
  32.    
  33.        $buffer = new-object byte[] 10KB
  34.    
  35.        $count = $responseStream.Read($buffer,0,$buffer.length)
  36.    
  37.        $downloadedBytes = $count
  38.    
  39.        while ($count -gt 0)
  40.    
  41.        {
  42.    
  43.            $targetStream.Write($buffer, 0, $count)
  44.    
  45.            $count = $responseStream.Read($buffer,0,$buffer.length)
  46.    
  47.            $downloadedBytes = $downloadedBytes + $count
  48.    
  49.            Write-Progress -activity "Downloading file '$($url.split('/') | Select -Last 1)'" -status "Downloaded ($([System.Math]::Floor($downloadedBytes/1024))K of $($totalLength)K): " -PercentComplete ((([System.Math]::Floor($downloadedBytes/1024)) / $totalLength)  * 100)
  50.    
  51.        }
  52.    
  53.        #Write-Progress -activity "Finished downloading file '$($url.split('/') | Select -Last 1)'"
  54.    
  55.        $targetStream.Flush()
  56.    
  57.        $targetStream.Close()
  58.    
  59.        $targetStream.Dispose()
  60.    
  61.        $responseStream.Dispose()
  62.    
  63.     }
  64.    
  65.     cls
  66.     Write-Output "Welcome!!!"
  67.     Start-Sleep -seconds 2
  68.    
  69.  
  70.    
  71.     if(!(Test-Path -Path $folder )){
  72.         Write-Output "Downloading Emulator for Windows..."
  73.         Start-Sleep -seconds 2
  74.    
  75.         $url = "https://dl.dropbox.com/s/v6vjm1mibedecr5/xmvsf.zip"
  76.         $file = "$storageDir\xmvsf.zip"
  77.         DownloadFile $url $file
  78.    
  79.         Write-Output "Unzipping Emulator for Windows"
  80.         Start-Sleep -seconds 2
  81.        
  82.         $shell = new-object -com shell.application
  83.         $zip = $shell.NameSpace("$file")
  84.    
  85.         foreach($item in $zip.items())
  86.         {
  87.             $shell.Namespace("$storageDir\").copyhere($item)
  88.         }
  89.         Remove-Item $file -Force -Recurse
  90.     }else{
  91.         Write-Output "Emulator Already Installed";
  92.         Start-Sleep -seconds 2
  93.     }
  94.    
  95.    
  96.  
  97.  
  98.     $file = "xmvsf.zip"
  99.     $rom = "$folder\roms\$file"
  100.    
  101.     Write-Output "Starting Game!!!"
  102.    
  103.     $mediaPlayer.Stop()
  104.  
  105.     write-output $pwd\$folder
  106.     cd $pwd\$folder
  107.     cmd /c mame $rom
  108.     cd $storageDir
  109.    
  110.     $del = Read-Host 'Do you want to remove the emulator and roms? (Y/n)'
  111.    
  112.     if(($del -eq "Y" ) -or ( $del -eq "")){
  113.         Write-Output "Removing Emulator and ROMS"
  114.         Remove-Item $folder -Force -Recurse
  115.     }
  116.    
  117.     write-output "Thank you for playing"
  118. }
  119.  
  120. Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement