Advertisement
metalx1000

Street Fighter 2 - MAME ROM

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