2 '''* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * Mupen64plus - code_convert.c *
4 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
5 * Copyright (C) 2010 Rhett Osborne *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
21 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
25 python code_convert.py > ../data/mupencheat.txt < ../data/mupen64plus.cht
41 l.append(" cn %s"%(self.n))
42 if(self.d != ""): l.append(" cd %s"%(self.d))
64 print line.replace("\x00", "")
70 lines = stdin.read().split("\n")
73 if len(line) < 2: continue
74 elif(line[:2] == "//" and line != "//----" and line != "//---" ):
76 elif len(line) < 4: continue
77 elif(line[0] == '[' and line[-1] == ']' and len(line) > 23):
79 l.append("\ncrc %s" % line[1:-1])
80 elif(line[:5] == "Name="):
81 l.append("gn %s" % (line[5:]))
82 elif(line[:5] == "Cheat"):
83 t = line[5:].split('=')[0]
84 if (len(t)>1 and t[-2] == '_'):
87 cs[n].d = line.split("=")[1]
89 for option in line.split("=")[1].split("$")[1:]:
92 if(option[-1]==','): end =-1
95 cs[n].c[cs[n].v] += "%s%s:\"%s\""%(cs[n].hb,option[:2],option[3:end].replace("\"", "\\\""))
97 cs[n].c[cs[n].v] += "%s:\"%s\""%(option[:4],option[5:end].replace("\"", "\\\""))
99 cs[n].c[cs[n].v] = cs[n].c[cs[n].v][:-1]
103 cs[n].c = cn[2][1:].split(',')
106 for cheat in cs[n].c:
107 if(cheat[-1] == '?'):
108 if(cheat[-2:] == '??' and cheat[-4:-2] != '??'):
109 cs[n].hb = cheat[-4:-2]
112 cs[n].c[i] = cheat[:9] + "???? ";
117 elif(line != "//----" and line != "//---" ):
118 l.append("//%s" %line)