BSNES2Retroarch Cheat Conversion Scripta

I wrote this script, as the Xbox 360 has no option to create cht files in retroarch. This will generate 1610 cht files using the supplied XML Document.

Unfortunatly, It does not sort the cht files into folders by system, as the BSNES XML format uses the sha256 sum of the game to determine which cheats to load out of the database.

Here is the script, just copy and paste and save as a .vbs file. run file.


on error resume next
dim DocToLoad
'edit this line
DocToLoad="XML FILE PATH HERE"
'Do not edit after this line
Set objXMLDoc = CreateObject("Microsoft.XMLDOM") 
objXMLDoc.async = False 
objXMLDoc.load(DocToLoad)
dim filesys,filesys1, filetxt1, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt1 = filesys.CreateTextFile(".\error.txt", True)
	path = filesys.GetAbsolutePathName(".\error.txt")
	getname = filesys.GetFileName(path)

Set Root = objXMLDoc.documentElement 
Set NodeList = Root.getElementsByTagName("cartridge")
dim i,z
dim code_array(1000),description_array(1000)
For Each Elem In NodeList 
   set game = Elem.getElementsByTagName("name")(0)
   set cheat = elem.getElementsByTagName("cheat")
	Set filetxt = filesys.CreateTextFile(".\cheats\"&game.text&".cht", True)
	path = filesys.GetAbsolutePathName(".\cheats\"&game.text&".cht")
	getname = filesys.GetFileName(path)

   i=0
   for each elem1 in cheat
   SET Description= Elem1.getElementsByTagName("description")(0)
   SET code = Elem1.getElementsByTagName("code")(0)
   code_array(i)=code.text
   description_array(i)=Description.text
   i=i+1
   Set Description=nothing
   set code=nothing
   next
filetxt.WriteLine("###File Generated by Script Written by Gavin_Darkglider")
filetxt.WriteLine("")
filetxt.WriteLine("cheats = "&i)
filetxt.WriteLine("")

z=0
do until z = i
filetxt.WriteLine("cheat"&z&"_desc = "&chr(34) &description_array(z)&chr(34)) 
filetxt.WriteLine("cheat"&z&"_code = "&chr(34)&code_array(z)&chr(34))
filetxt.WriteLine("cheat"&z&"_enabled = false")
filetxt.WriteLine("")
If Err.Number <> 0 Then
  filetxt1.WriteLine("Error converting: "& game.text)
  Err.Clear
End If
z=z+1
loop
filetxt.Close
Next
set NodeList=nothing
 WScript.Echo "Finished"


Here is a link to the file I converted with this script. :slight_smile: https://www.dropbox.com/s/7ar1jzlbfznwwr0/cheats.xml?dl=0 should also mention you have to create a folder called cheats, and put it in the directory with the script, as the script doesnt create the folder.

Script should finish in like 30seconds, and the cht files are generated. This created more cht files then are on the retroarch github. I am surprised the person managing that never thought to do something like this.

In the future I plan on writing a database app that will store all of your cheats from any emulator, and will create cht files for retroarch. Probably will call it something like Emulator Cheat Database. I will try to make it so you can load any cht file from any emulator, and it will add the cheats to the database if they arent already there.

I am mainly writing this app for managing cht files on my xbox, so I will try to integrate an ftp client , so it can upload cht files directly to the xbox. :slight_smile: I might see if I can have it create a central database on Xbox Unity, so people can download cheats directly through aurora. That would involve team phoenix adding a Unity Store to aurora, for all the homebrew needs, so who knows. :slight_smile: I will talk to the phoenix devs about it.