├── .gitattributes
├── .gitignore
├── CLPS2C-Changelog.txt
├── CLPS2C-Compiler.sln
├── CLPS2C-Compiler
├── 256x256.ico
├── CLPS2C-Compiler.csproj
├── Program.cs
├── Properties
│ └── launchSettings.json
└── Util.cs
├── CLPS2C-Documentation.txt
├── Example
├── CLPS2C-ExampleCode.txt
└── IncludeExample
│ └── Sly2
│ └── NTSC
│ ├── All.txt
│ ├── Engine.txt
│ ├── Entity.txt
│ ├── Gui.txt
│ ├── Player.txt
│ └── README.md
├── LICENSE.txt
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # .dll files
7 | CLPS2C-Compiler/keystone.dll
8 | CLPS2C-Compiler/Keystone.Net.dll
9 |
10 | # User-specific files
11 | *.rsuser
12 | *.suo
13 | *.user
14 | *.userosscache
15 | *.sln.docstates
16 |
17 | # User-specific files (MonoDevelop/Xamarin Studio)
18 | *.userprefs
19 |
20 | # Mono auto generated files
21 | mono_crash.*
22 |
23 | # Build results
24 | [Dd]ebug/
25 | [Dd]ebugPublic/
26 | [Rr]elease/
27 | [Rr]eleases/
28 | x64/
29 | x86/
30 | [Ww][Ii][Nn]32/
31 | [Aa][Rr][Mm]/
32 | [Aa][Rr][Mm]64/
33 | bld/
34 | [Bb]in/
35 | [Oo]bj/
36 | [Oo]ut/
37 | [Ll]og/
38 | [Ll]ogs/
39 |
40 | # Visual Studio 2015/2017 cache/options directory
41 | .vs/
42 | # Uncomment if you have tasks that create the project's static files in wwwroot
43 | #wwwroot/
44 |
45 | # Visual Studio 2017 auto generated files
46 | Generated\ Files/
47 |
48 | # MSTest test Results
49 | [Tt]est[Rr]esult*/
50 | [Bb]uild[Ll]og.*
51 |
52 | # NUnit
53 | *.VisualState.xml
54 | TestResult.xml
55 | nunit-*.xml
56 |
57 | # Build Results of an ATL Project
58 | [Dd]ebugPS/
59 | [Rr]eleasePS/
60 | dlldata.c
61 |
62 | # Benchmark Results
63 | BenchmarkDotNet.Artifacts/
64 |
65 | # .NET Core
66 | project.lock.json
67 | project.fragment.lock.json
68 | artifacts/
69 |
70 | # ASP.NET Scaffolding
71 | ScaffoldingReadMe.txt
72 |
73 | # StyleCop
74 | StyleCopReport.xml
75 |
76 | # Files built by Visual Studio
77 | *_i.c
78 | *_p.c
79 | *_h.h
80 | *.ilk
81 | *.meta
82 | *.obj
83 | *.iobj
84 | *.pch
85 | *.pdb
86 | *.ipdb
87 | *.pgc
88 | *.pgd
89 | *.rsp
90 | *.sbr
91 | *.tlb
92 | *.tli
93 | *.tlh
94 | *.tmp
95 | *.tmp_proj
96 | *_wpftmp.csproj
97 | *.log
98 | *.vspscc
99 | *.vssscc
100 | .builds
101 | *.pidb
102 | *.svclog
103 | *.scc
104 |
105 | # Chutzpah Test files
106 | _Chutzpah*
107 |
108 | # Visual C++ cache files
109 | ipch/
110 | *.aps
111 | *.ncb
112 | *.opendb
113 | *.opensdf
114 | *.sdf
115 | *.cachefile
116 | *.VC.db
117 | *.VC.VC.opendb
118 |
119 | # Visual Studio profiler
120 | *.psess
121 | *.vsp
122 | *.vspx
123 | *.sap
124 |
125 | # Visual Studio Trace Files
126 | *.e2e
127 |
128 | # TFS 2012 Local Workspace
129 | $tf/
130 |
131 | # Guidance Automation Toolkit
132 | *.gpState
133 |
134 | # ReSharper is a .NET coding add-in
135 | _ReSharper*/
136 | *.[Rr]e[Ss]harper
137 | *.DotSettings.user
138 |
139 | # TeamCity is a build add-in
140 | _TeamCity*
141 |
142 | # DotCover is a Code Coverage Tool
143 | *.dotCover
144 |
145 | # AxoCover is a Code Coverage Tool
146 | .axoCover/*
147 | !.axoCover/settings.json
148 |
149 | # Coverlet is a free, cross platform Code Coverage Tool
150 | coverage*.json
151 | coverage*.xml
152 | coverage*.info
153 |
154 | # Visual Studio code coverage results
155 | *.coverage
156 | *.coveragexml
157 |
158 | # NCrunch
159 | _NCrunch_*
160 | .*crunch*.local.xml
161 | nCrunchTemp_*
162 |
163 | # MightyMoose
164 | *.mm.*
165 | AutoTest.Net/
166 |
167 | # Web workbench (sass)
168 | .sass-cache/
169 |
170 | # Installshield output folder
171 | [Ee]xpress/
172 |
173 | # DocProject is a documentation generator add-in
174 | DocProject/buildhelp/
175 | DocProject/Help/*.HxT
176 | DocProject/Help/*.HxC
177 | DocProject/Help/*.hhc
178 | DocProject/Help/*.hhk
179 | DocProject/Help/*.hhp
180 | DocProject/Help/Html2
181 | DocProject/Help/html
182 |
183 | # Click-Once directory
184 | publish/
185 |
186 | # Publish Web Output
187 | *.[Pp]ublish.xml
188 | *.azurePubxml
189 | # Note: Comment the next line if you want to checkin your web deploy settings,
190 | # but database connection strings (with potential passwords) will be unencrypted
191 | *.pubxml
192 | *.publishproj
193 |
194 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
195 | # checkin your Azure Web App publish settings, but sensitive information contained
196 | # in these scripts will be unencrypted
197 | PublishScripts/
198 |
199 | # NuGet Packages
200 | *.nupkg
201 | # NuGet Symbol Packages
202 | *.snupkg
203 | # The packages folder can be ignored because of Package Restore
204 | **/[Pp]ackages/*
205 | # except build/, which is used as an MSBuild target.
206 | !**/[Pp]ackages/build/
207 | # Uncomment if necessary however generally it will be regenerated when needed
208 | #!**/[Pp]ackages/repositories.config
209 | # NuGet v3's project.json files produces more ignorable files
210 | *.nuget.props
211 | *.nuget.targets
212 |
213 | # Microsoft Azure Build Output
214 | csx/
215 | *.build.csdef
216 |
217 | # Microsoft Azure Emulator
218 | ecf/
219 | rcf/
220 |
221 | # Windows Store app package directories and files
222 | AppPackages/
223 | BundleArtifacts/
224 | Package.StoreAssociation.xml
225 | _pkginfo.txt
226 | *.appx
227 | *.appxbundle
228 | *.appxupload
229 |
230 | # Visual Studio cache files
231 | # files ending in .cache can be ignored
232 | *.[Cc]ache
233 | # but keep track of directories ending in .cache
234 | !?*.[Cc]ache/
235 |
236 | # Others
237 | ClientBin/
238 | ~$*
239 | *~
240 | *.dbmdl
241 | *.dbproj.schemaview
242 | *.jfm
243 | *.pfx
244 | *.publishsettings
245 | orleans.codegen.cs
246 |
247 | # Including strong name files can present a security risk
248 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
249 | #*.snk
250 |
251 | # Since there are multiple workflows, uncomment next line to ignore bower_components
252 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
253 | #bower_components/
254 |
255 | # RIA/Silverlight projects
256 | Generated_Code/
257 |
258 | # Backup & report files from converting an old project file
259 | # to a newer Visual Studio version. Backup files are not needed,
260 | # because we have git ;-)
261 | _UpgradeReport_Files/
262 | Backup*/
263 | UpgradeLog*.XML
264 | UpgradeLog*.htm
265 | ServiceFabricBackup/
266 | *.rptproj.bak
267 |
268 | # SQL Server files
269 | *.mdf
270 | *.ldf
271 | *.ndf
272 |
273 | # Business Intelligence projects
274 | *.rdl.data
275 | *.bim.layout
276 | *.bim_*.settings
277 | *.rptproj.rsuser
278 | *- [Bb]ackup.rdl
279 | *- [Bb]ackup ([0-9]).rdl
280 | *- [Bb]ackup ([0-9][0-9]).rdl
281 |
282 | # Microsoft Fakes
283 | FakesAssemblies/
284 |
285 | # GhostDoc plugin setting file
286 | *.GhostDoc.xml
287 |
288 | # Node.js Tools for Visual Studio
289 | .ntvs_analysis.dat
290 | node_modules/
291 |
292 | # Visual Studio 6 build log
293 | *.plg
294 |
295 | # Visual Studio 6 workspace options file
296 | *.opt
297 |
298 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
299 | *.vbw
300 |
301 | # Visual Studio LightSwitch build output
302 | **/*.HTMLClient/GeneratedArtifacts
303 | **/*.DesktopClient/GeneratedArtifacts
304 | **/*.DesktopClient/ModelManifest.xml
305 | **/*.Server/GeneratedArtifacts
306 | **/*.Server/ModelManifest.xml
307 | _Pvt_Extensions
308 |
309 | # Paket dependency manager
310 | .paket/paket.exe
311 | paket-files/
312 |
313 | # FAKE - F# Make
314 | .fake/
315 |
316 | # CodeRush personal settings
317 | .cr/personal
318 |
319 | # Python Tools for Visual Studio (PTVS)
320 | __pycache__/
321 | *.pyc
322 |
323 | # Cake - Uncomment if you are using it
324 | # tools/**
325 | # !tools/packages.config
326 |
327 | # Tabs Studio
328 | *.tss
329 |
330 | # Telerik's JustMock configuration file
331 | *.jmconfig
332 |
333 | # BizTalk build output
334 | *.btp.cs
335 | *.btm.cs
336 | *.odx.cs
337 | *.xsd.cs
338 |
339 | # OpenCover UI analysis results
340 | OpenCover/
341 |
342 | # Azure Stream Analytics local run output
343 | ASALocalRun/
344 |
345 | # MSBuild Binary and Structured Log
346 | *.binlog
347 |
348 | # NVidia Nsight GPU debugger configuration file
349 | *.nvuser
350 |
351 | # MFractors (Xamarin productivity tool) working folder
352 | .mfractor/
353 |
354 | # Local History for Visual Studio
355 | .localhistory/
356 |
357 | # BeatPulse healthcheck temp database
358 | healthchecksdb
359 |
360 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
361 | MigrationBackup/
362 |
363 | # Ionide (cross platform F# VS Code tools) working folder
364 | .ionide/
365 |
366 | # Fody - auto-generated XML schema
367 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/CLPS2C-Changelog.txt:
--------------------------------------------------------------------------------
1 | Version 1.0.3 (07/11/2024)
2 | - Assembly:
3 | - Added support for variables to be valid arguments for "J" and "JAL" opcodes.
4 | - Added support for the addition operator "+" for "J" and "JAL" instructions argument.
5 | - Fixed bugs:
6 | - Keystone engine is now disposed when the application terminates.
7 | - Changed documentation:
8 | - Added a CLPS2C example code that uses assembly with its output.
9 | - Specified that not all (ADDRESS) and (VALUE) arguments can be replaced with variables.
10 | - Added an alternative method to load a float in a register.
11 | - Added an example that uses the "J" and "JAL" instructions with a variable in an assembly scope.
12 | - Changed README:
13 | - Removed mention of CodeBreaker.
14 |
15 | Version 1.0.2 (28/09/2024)
16 | - Updated keystone.
17 | - Fixed bugs:
18 | - Assembly: Fixed a crash when white space was present before the 2nd argument for load and store instructions that have an immediate value greater than 0x7FFF (example: "lw $t1, 0x2DE2F0").
19 | - Changed documentation:
20 | - Removed the "when not using a declared variable" sentence for the "Include (VALUE)" command.
21 | - Changed README:
22 | - Added an advertisement for vscode-clps2c.
23 |
24 | Version 1.0.1 (17/05/2024)
25 | - Fixed bugs:
26 | - Added case-insensitivity for the "If" command (used to throw a WRONG_SYNTAX error when the command's type was "if", "iF" and "IF").
27 |
28 | Version 1.0.0 (02/03/2024)
29 | - Initial version
--------------------------------------------------------------------------------
/CLPS2C-Compiler.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.34009.444
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CLPS2C-Compiler", "CLPS2C-Compiler\CLPS2C-Compiler.csproj", "{D980F7D6-C5FF-4A15-A9E8-AF578E9BAB0E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D980F7D6-C5FF-4A15-A9E8-AF578E9BAB0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D980F7D6-C5FF-4A15-A9E8-AF578E9BAB0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D980F7D6-C5FF-4A15-A9E8-AF578E9BAB0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D980F7D6-C5FF-4A15-A9E8-AF578E9BAB0E}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B4321EC8-0EF8-4F9D-8E1A-4E78483DDB1B}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CLPS2C-Compiler/256x256.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NiV-L-A/CLPS2C-Compiler/49e6a4e5edc3e3312e3463b52a2a9e1603df1f94/CLPS2C-Compiler/256x256.ico
--------------------------------------------------------------------------------
/CLPS2C-Compiler/CLPS2C-Compiler.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | CLPS2C_Compiler
7 | enable
8 | enable
9 | x86
10 | 256x256.ico
11 | 1.0.3
12 |
13 |
14 |
15 | none
16 |
17 |
18 |
19 | none
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Keystone.Net.dll
33 | True
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/CLPS2C-Compiler/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "CLPS2C-Compiler": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CLPS2C-Compiler/Util.cs:
--------------------------------------------------------------------------------
1 | using System.Globalization;
2 | using System.Text.RegularExpressions;
3 | using System.Diagnostics;
4 | using Keystone;
5 |
6 | namespace CLPS2C_Compiler
7 | {
8 | public class Util
9 | {
10 | // string PatternString = @"(""(?:[^""\\]|\\.)*""*)";
11 | // string PatternString2 = @"(""(\\.|[^""])*""*)";
12 | // string PatternString3 = @"(""(?:\\.|[^""])*""?)";
13 |
14 | [DebuggerDisplay("({ID}) | {FullLine} = {Output}")]
15 | public class Command_t
16 | {
17 | [DebuggerDisplay("{System.IO.Path.GetFileName(FilePath)}:{LineIdx} - {FullLine}")]
18 | public class Traceback_t
19 | {
20 | public string? FilePath;
21 | public string? FullLine;
22 | public int LineIdx;
23 | }
24 |
25 | public string FullLine;
26 | public int ID;
27 | public int Weight; // How many lines the command produced. Will get set when parsing the command. Some commands might have a weight of 0
28 | public string Type;
29 | public List Data;
30 | public string? Output;
31 | public List Traceback;
32 | public int WordCount { get => Data.Count + 1; }
33 |
34 | public Command_t(string line)
35 | {
36 | Weight = 0;
37 | FullLine = line;
38 | Traceback = new();
39 |
40 | // (\(.*\))|("(?:\\.|[^"])*"?)|(\+\s*(("(?:\\.|[^"])*"?)|([^+"]+?))?(?=\+|$| |,))|(,("?)([^,"]+?)\8(?=,|$| |\+))|([^ \t\n\r\f\v(+,]+)
41 | // Order of precedence:
42 | // (\(.*\)) - In parenthesis, this is one element: (test "test" test, test)
43 | // ("(?:\\.|[^"])*"?) - In double quotes, taking into account escaped ". this is one element: "test \"test\" test"
44 | // (\+\s*(("(?:\\.|[^"])*"?)|([^+"]+?))?(?=\+|$| |,)) - + symbol, any white space, string (see above) or word. With the ? before the last group so that it matches '+'
45 | // In the following: +1+2+3+4+ 5+"6+ 7"+ 8
46 | // The elements are +1,+2,+3,+4,+ 5,+"6+ 7",+ 8
47 | // (,("?)([^,"]+?)\8(?=,|$| |\+)) - Separated by comma
48 | // ([^ \t\n\r\f\v(+,]+) - Any other word. This is \S, and '(', '+', ','
49 | MatchCollection Matches = Regex.Matches(line, @"(\(.*\))|(""(?:\\.|[^""])*""?)|(\+\s*((""(?:\\.|[^""])*""?)|([^+""]+?))?(?=\+|$| |,))|(,(""?)([^,""]+?)\8(?=,|$| |\+))|([^ \t\n\r\f\v(+,]+)");
50 | Type = Matches[0].Value.ToUpper();
51 | Data = Matches.Skip(1).Take(Matches.Count - 1).Select(item => item.Value).ToList(); // Data has every word except first
52 | }
53 |
54 | public void AppendToTraceback(string file, string fullLine, int lineIdx)
55 | {
56 | Traceback.Add(new Traceback_t
57 | {
58 | FilePath = file,
59 | FullLine = fullLine,
60 | LineIdx = lineIdx
61 | });
62 | }
63 |
64 | public void AppendToTraceback(List traceback)
65 | {
66 | Traceback.AddRange(traceback);
67 | }
68 |
69 | public Command_t DeepClone()
70 | {
71 | Command_t Clone = new(FullLine)
72 | {
73 | Weight = Weight,
74 | Type = Type,
75 | Data = Data.Select(item => item).ToList(), // Deep clone the list
76 | Output = Output,
77 | Traceback = Traceback.Select(item => item).ToList()
78 | };
79 | return Clone;
80 | }
81 | }
82 |
83 | [DebuggerDisplay("({ID}) | {Name} = {string.Join(\", \", Values)}")]
84 | public class LocalVar_t
85 | {
86 | public string Name;
87 | public List Values;
88 | public int ID;
89 |
90 | public LocalVar_t(string name, List values)
91 | {
92 | Name = name;
93 | Values = values;
94 | }
95 | }
96 |
97 | [DebuggerDisplay("{ThisCommand.FullLine}")]
98 | public class Function_t
99 | {
100 | public string? Name; // WriteXYZ
101 | public List? Args; // base, valueX, valueY, valueZ
102 | public Command_t? ThisCommand;
103 | public List? Commands; // WritePointerFloat base,0x30 valueX | WritePointerFloat base,0x34 valueY | WritePointerFloat base,0x38 valueZ
104 |
105 | public Function_t(Command_t currentCommand)
106 | {
107 | Match Match = Regex.Match(currentCommand.FullLine, @"Function (\w+)\(([^)]*)\)");
108 |
109 | // Wrong syntax
110 | if (!Match.Success)
111 | {
112 | return;
113 | }
114 |
115 | ThisCommand = currentCommand;
116 | Name = Match.Groups[1].Value;
117 | Args = new();
118 | Commands = new();
119 | if (Match.Groups[2].Value != "")
120 | {
121 | Args.AddRange(Match.Groups[2].Value.Split(',').Select(elementName => elementName.Trim()));
122 | }
123 | }
124 | }
125 |
126 | public class ErrorInfo_t
127 | {
128 | public Command_t? Command;
129 | public ERROR ErrorValue;
130 | public KeystoneError KeystoneErrorValue;
131 | }
132 |
133 | public static List TextCleanUp(List lines)
134 | {
135 | lines = lines.Select(x => x.Replace("\t", "")).ToList(); // remove \t
136 | lines = RemoveComments(lines);
137 | lines = lines.Select(x => x.Trim()).ToList(); // remove white spaces at the beginning and end (including \r\n)
138 | return lines;
139 | }
140 |
141 | public static List RemoveComments(List lines)
142 | {
143 | string Code = string.Join(Program._newLine, lines);
144 | Code = RemoveMultiLineComments(Code);
145 | Code = RemoveSingleLineComments(Code);
146 | lines = Code.Split(new[] { Program._newLine }, StringSplitOptions.None).ToList();
147 | return lines;
148 | }
149 |
150 | public static string RemoveMultiLineComments(string code)
151 | {
152 | // Preserve the original line indices (by keeping the line breaks).
153 | // ("(?:\\.|[^"])*"?)|(\/\*.*?(?:\*\/|$))
154 | // ("(?:\\.|[^"])*"?) - Match strings (so we can ignore them)
155 | // (\/\*.*?(?:\*\/|$)) - Match /* anything */ - */ can be absent
156 | // With the ? quantifier at the end of the first group so that it matches: "test""what" and "test
157 | Regex MultiLineCommentRegex = new(@"(""(?:\\.|[^""])*""?)|(\/\*.*?(?:\*\/|$))", RegexOptions.Singleline);
158 | code = MultiLineCommentRegex.Replace(code, match =>
159 | {
160 | if (match.Groups[1].Success)
161 | {
162 | // It's a string, return the matched string as it is
163 | return match.Value;
164 | }
165 | else
166 | {
167 | // It's a comment, count new lines
168 | int newLinesCount = match.Value.Split(Program._newLine).Length - 1;
169 | return string.Concat(Enumerable.Repeat(Program._newLine, newLinesCount));
170 | }
171 | });
172 |
173 | return code;
174 | }
175 |
176 | public static string RemoveSingleLineComments(string code)
177 | {
178 | // https://www.reddit.com/r/regex/comments/g86xrg/comment/folxneo
179 | // With the ? quantifier at the end so that it matches the string "//test" with no new line after
180 | // With the ? quantifier at the end of the first group so that it matches: "test""what" and "test
181 | // ("(?:\\.|[^"])*"?)|(\/\/.*(?:\r\n|\n)?)
182 | Regex SingleLineCommentRegex = new(@"(""(?:\\.|[^""])*""?)|(\/\/.*(?:\r\n|\n)?)");
183 | code = SingleLineCommentRegex.Replace(code, match =>
184 | {
185 | if (match.Groups[1].Success)
186 | {
187 | // It's a string, return the matched string as it is
188 | return match.Value;
189 | }
190 | else
191 | {
192 | // It's a comment
193 | if (match.Value.EndsWith(Program._newLine))
194 | {
195 | return Program._newLine;
196 | }
197 | return ""; // If the comment doesn't end with a new line (for example, when the comment is at the last line)
198 | }
199 | });
200 |
201 | return code;
202 | }
203 |
204 | public static string PrintError(ErrorInfo_t errorInfo)
205 | {
206 | string Tmp = "ERROR: ";
207 | if (errorInfo.ErrorValue == ERROR.OK)
208 | {
209 | // Keystone error
210 | if (errorInfo.KeystoneErrorValue != KeystoneError.KS_ERR_OK)
211 | {
212 | Tmp += $"{Engine.ErrorToString(errorInfo.KeystoneErrorValue)} at line {errorInfo.Command!.Traceback.First().LineIdx + 1} in file {errorInfo.Command.Traceback.First().FilePath}{Program._newLine}";
213 |
214 | if (errorInfo.KeystoneErrorValue == KeystoneError.KS_ERR_ASM_SYMBOL_MISSING)
215 | {
216 | // b notDefinedLabel
217 | // Tmp += $"The following symbol was referenced but it does not exist in the current context: {errorInfo.Command.FullLine}{Program._newLine}";
218 | // Tmp += $"Line that produced the error:{Program._newLine}ASM_END";
219 | Tmp += $"The Keystone engine could not find a symbol. This usually occurs because there's a branch/jump instruction to a label which has not been defined.";
220 | }
221 | else if (errorInfo.KeystoneErrorValue == KeystoneError.KS_ERR_ASM_MNEMONICFAIL)
222 | {
223 | // lqw t1,0x002DE2F0 (no opcode); %li $t0,1 (% character)
224 | Tmp += $"The Keystone engine could not recognize an opcode. Note that not all opcodes supported by the PS2's MIPS R5900 CPU are supported in Keystone.";
225 | }
226 | else if (errorInfo.KeystoneErrorValue == KeystoneError.KS_ERR_ASM_INVALIDOPERAND)
227 | {
228 | // lw t1,0x002DE2F0 (no $)
229 | Tmp += $"The Keystone engine could not correctly parse the assembly instruction.{Program._newLine}This usually occurs because the dollar sign (\"$\") symbol is missing before referencing a register (\"t1\" instead of \"$t1\"), or because of an invalid number (for example, in the line \"lw $t1,0xq\", \"0xq\" is not a valid hexadecimal number).";
230 | }
231 | Tmp += $"{Program._newLine}{Program._newLine}";
232 | }
233 | }
234 | else
235 | {
236 | // CLPS2C error
237 | Tmp += $"{Enum.GetName(typeof(ERROR), errorInfo.ErrorValue)} at line {errorInfo.Command!.Traceback.First().LineIdx + 1} in file {errorInfo.Command.Traceback.First().FilePath}{Program._newLine}";
238 | Tmp += $"{ErrorMessages[errorInfo.ErrorValue]}{Program._newLine}{Program._newLine}";
239 | }
240 |
241 | Tmp += $"Line that produced the error:{Program._newLine}{errorInfo.Command!.FullLine}";
242 | Tmp += $"{Program._newLine}{Program._newLine}Traceback:";
243 | errorInfo.Command.Traceback.Reverse();
244 | foreach (Command_t.Traceback_t item in errorInfo.Command.Traceback)
245 | {
246 | Tmp += $"{Program._newLine}at {item.FilePath}:{item.LineIdx + 1} - {item.FullLine}";
247 | }
248 | return Tmp;
249 | }
250 |
251 | public static void ConsolePrintError(string text)
252 | {
253 | Console.ForegroundColor = ConsoleColor.Red;
254 | Console.Write($"ERROR: ");
255 | Console.ForegroundColor = ConsoleColor.Gray;
256 | Console.Write(text);
257 | }
258 |
259 | public static int CountCharInRange(string str, char ch, int startIdx, int endIdx)
260 | {
261 | // Returns the count of how many chars 'ch' there're between 2 index positions in a string
262 | if (startIdx == -1 || endIdx == -1)
263 | {
264 | return -1;
265 | }
266 | string Substring = str.Substring(startIdx, endIdx - startIdx);
267 | return Substring.Count(c => c == ch);
268 | }
269 |
270 | public static string GetSubstringInQuotes(string line, bool includeQuotes)
271 | {
272 | // "\"park\"" -> "park"
273 | // "\"00 11 22 33\"" -> "00 11 22 33"
274 | var First = line.IndexOf('\"');
275 | var Second = line.LastIndexOf('\"');
276 | if (includeQuotes)
277 | {
278 | return line.Substring(First, Second - First + 1); // With '\"'
279 | }
280 | return line.Substring(First + 1, Second - First - 1); // Without '\"'
281 | }
282 |
283 | public static List GetDelimitatedPlusString(string input)
284 | {
285 | List Elements = new();
286 | MatchCollection Matches = Regex.Matches(input, @"(\+\s*((""(?:\\.|[^""])*""?)|([^+""]+?))(?=\+|$| |,))|([^ \t\n\r\f\v(+,]+)");
287 | for (int i = 0; i < Matches.Count; i++)
288 | {
289 | Elements.Add(Matches[i].Value);
290 | }
291 |
292 | return Elements;
293 | }
294 |
295 | public static int GetNthOccuranceInList(List list, string value, int n)
296 | {
297 | int tmp = 0;
298 | for (int i = 0; i < list.Count; i++)
299 | {
300 | if (list[i] == value)
301 | {
302 | if (tmp == n)
303 | {
304 | // found
305 | return i;
306 | }
307 | tmp++;
308 | }
309 | }
310 | return -1;
311 | }
312 |
313 | public static bool StartsAndEndsWithQuotes(string value)
314 | {
315 | if (value.StartsWith("\"") && value.EndsWith("\"") && value.Length != 1)
316 | {
317 | return true;
318 | }
319 | return false;
320 | }
321 |
322 | public static string GetAddressValuePairsFromAOB(byte[] array, string startAddress)
323 | {
324 | int W32Count = array.Length / 4; // How many W32
325 | int WXCount = array.Length % 4; // How many writes remain (W8 + W16)
326 | string Output = "";
327 | uint Address = Convert.ToUInt32(startAddress, 16);
328 |
329 | for (int i = 0; i < W32Count; i++)
330 | {
331 | string address = $"2{((int)(Address + i * 4)).ToString("X8").Substring(1)}";
332 | string value = array[(i + 1) * 4 - 1].ToString("X2") +
333 | array[(i + 1) * 4 - 2].ToString("X2") +
334 | array[(i + 1) * 4 - 3].ToString("X2") +
335 | array[(i + 1) * 4 - 4].ToString("X2");
336 | Output += $"{Program._newLine}{address} {value}";
337 | }
338 |
339 | switch (WXCount)
340 | {
341 | case 0:
342 | break;
343 | case 1:
344 | // W8
345 | Output += $"{Program._newLine}0{((int)(Address + W32Count * 4)).ToString("X8").Substring(1)} ";
346 | Output += $"000000{array[array.Length - 1].ToString("X2")}";
347 | break;
348 | case 2:
349 | // W16
350 | Output += $"{Program._newLine}1{((int)(Address + W32Count * 4)).ToString("X8").Substring(1)} ";
351 | Output += $"0000{array[array.Length - 1].ToString("X2") + array[array.Length - 2].ToString("X2")}";
352 | break;
353 | case 3:
354 | // W16 + W8
355 | Output += $"{Program._newLine}1{((int)(Address + W32Count * 4)).ToString("X8").Substring(1)} ";
356 | Output += $"0000{array[array.Length - 2].ToString("X2")}{array[array.Length - 3].ToString("X2")}";
357 | Output += $"{Program._newLine}0{((int)(Address + W32Count * 4 + 2)).ToString("X8").Substring(1)} ";
358 | Output += $"000000{array[array.Length - 1].ToString("X2")}";
359 | break;
360 | }
361 | return Output;
362 | }
363 |
364 | public static bool IsAOBValid(string value)
365 | {
366 | return Regex.IsMatch(value, @"^([0-9A-Fa-f]{2} )*[0-9A-Fa-f]{2}$");
367 | }
368 |
369 | public static bool IsAddressValid(string address)
370 | {
371 | Match match = Regex.Match(address, @"^-?(0x)?[0-9A-Fa-f]{1,8}$");
372 | if (!match.Success)
373 | {
374 | return false;
375 | }
376 | return true;
377 | }
378 |
379 | public static bool IsIntValueValid(string value)
380 | {
381 | Match Match = Regex.Match(value, @"^-?(0x){1}[0-9A-Fa-f]{1,8}$|^-?(?!0x)\d+$");
382 | if (!Match.Success)
383 | return false;
384 | return true;
385 | }
386 |
387 | public static bool IsFloatValueValid(string value)
388 | {
389 | if (!Regex.IsMatch(value, @"^-?(0x){1}[0-9A-Fa-f]{1,8}$|^-?(?!0x)\d+(\.\d+)?$"))
390 | {
391 | value = value.ToUpper();
392 | return value == "INFINITY" || value == "-INFINITY" || value == "NAN";
393 | }
394 | return true;
395 | }
396 |
397 | public static int ConvertAddress(string input)
398 | {
399 | if (!input.StartsWith("-"))
400 | {
401 | //0x123A, 123A, 123
402 | return Convert.ToInt32(input, 16);
403 | }
404 |
405 | if (input.StartsWith("-0x"))
406 | {
407 | input = input.Substring(2);
408 | }
409 |
410 | input = input.Substring(1);
411 | return Convert.ToInt32(input, 16) * -1;
412 | }
413 |
414 | public static int ConvertIntValue(string input)
415 | {
416 | if (input.StartsWith("0x"))
417 | {
418 | //0x123A
419 | return Convert.ToInt32(input, 16);
420 | }
421 |
422 | if (input.StartsWith("-0x"))
423 | {
424 | //-0x123A
425 | return Convert.ToInt32(input.Substring(3), 16) * -1;
426 | }
427 |
428 | // 123, -123
429 | return Convert.ToInt32(input, 10);
430 | }
431 |
432 | public static uint ConvertUIntValue(string input)
433 | {
434 | if (input.StartsWith("0x"))
435 | {
436 | //0x123A
437 | return Convert.ToUInt32(input, 16);
438 | }
439 |
440 | if (input.StartsWith("-0x"))
441 | {
442 | //-0x123A
443 | return (uint)(Convert.ToUInt32(input.Substring(3), 16) * -1);
444 | }
445 |
446 | // 123, -123
447 | return Convert.ToUInt32(input, 10);
448 | }
449 |
450 | public static int ConvertFloatValue(string input)
451 | {
452 | if (input.StartsWith("0x"))
453 | {
454 | //0x123A
455 | return Convert.ToInt32(input, 16);
456 | }
457 |
458 | if (input.StartsWith("-0x"))
459 | {
460 | //-0x123A
461 | return (Convert.ToInt32(input.Substring(3), 16) * -1);
462 | }
463 |
464 | // 123, -123
465 | input = Convert.ToDouble(input, CultureInfo.InvariantCulture.NumberFormat).ToString();
466 | return BitConverter.ToInt32(BitConverter.GetBytes(Convert.ToSingle(input)), 0);
467 | }
468 |
469 | public static bool IsVarDeclared(string target, List listSets)
470 | {
471 | // Checks in listSets if there's a match with a local var
472 | return listSets.Any(y => y.Name == target);
473 | }
474 |
475 | public static List GetSetValuesFromTarget(string target, int id, List listSets)
476 | {
477 | // Based on a string "target", find the closest "Set" (considering the id) in which the (NAME) parameter has the target value
478 | List PossibleSets = listSets.Where(item => item.Name == target).ToList();
479 | var SetID = FindClosestLowerElement(PossibleSets, id);
480 | if (SetID == -1)
481 | {
482 | return new List();
483 | }
484 |
485 | List Output = PossibleSets.FirstOrDefault(item => item.ID == SetID)!.Values.ToList();
486 | for (int i = 0; i < Output.Count; i++)
487 | {
488 | string Element = Output[i];
489 | if (Element.StartsWith('+'))
490 | {
491 | Element = Element.Substring(1).TrimStart();
492 | }
493 |
494 | if (IsVarDeclared(Element, listSets))
495 | {
496 | List RecursiveValues = GetSetValuesFromTarget(Element, SetID, listSets);
497 | if (RecursiveValues.Count != 0)
498 | {
499 | if (Output[i].StartsWith('+'))
500 | {
501 | RecursiveValues[0] = "+" + RecursiveValues[0];
502 | }
503 | Output.RemoveAt(i);
504 | Output.InsertRange(i, RecursiveValues);
505 | i = i + RecursiveValues.Count - 1;
506 | }
507 | }
508 | }
509 | return Output;
510 | }
511 |
512 | static int FindClosestLowerElement(List listSets, int targetValue)
513 | {
514 | int closestLowerElement = -1;
515 | var q = listSets.Select(item => item.ID).ToList();
516 |
517 | foreach (int number in q)
518 | {
519 | int difference = targetValue - number;
520 | if (difference < 0)
521 | {
522 | // not found based on the id
523 | break;
524 | }
525 | closestLowerElement = number;
526 | }
527 | return closestLowerElement;
528 | }
529 |
530 | public static List GetListCommands(List lines, string filePath)
531 | {
532 | List ListCommands = new();
533 | foreach (var line in lines.OfType().Select((CurrentLine, CurrentLineIdx) => new { CurrentLine, CurrentLineIdx }))
534 | {
535 | if (line.CurrentLine == "")
536 | {
537 | continue;
538 | }
539 |
540 | ListCommands.Add(new(line.CurrentLine));
541 | ListCommands.Last().AppendToTraceback(filePath, line.CurrentLine, line.CurrentLineIdx);
542 | }
543 | return ListCommands;
544 | }
545 |
546 | public static string ConvertRawToPnach(string source)
547 | {
548 | return Regex.Replace(source, @"([0-9A-F]{8}) ([0-9A-F]{8})", "patch=1,EE,$1,extended,$2");
549 | }
550 |
551 | public static bool IsFilePathValid(string path)
552 | {
553 | // q -> invalid
554 | // "C:\Users\admin\Desktop\CLPS2C\CLPS2C-Test" -> invalid
555 | // "C:\Users\admin\Desktop\CLPS2C\CLPS2C-Test\CLPS2C-Test.clps2c" -> valid
556 | if (Directory.Exists(path) || !File.Exists(path))
557 | {
558 | return false;
559 | }
560 | return true;
561 | }
562 |
563 | public static bool IsAbsolutePath(string path)
564 | {
565 | if (Path.IsPathRooted(path) && !Path.GetPathRoot(path)!.Equals(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
566 | {
567 | return true;
568 | }
569 | return false;
570 | }
571 |
572 | public static string ReplaceTRegisters(string value)
573 | {
574 | // TO-DO: It would be better to handle this inside keystone itself
575 | // With keystone set to MIPS64 mode, the first 7 temporary registers do not produce the same result as Mips32:
576 | // https://github.com/keystone-engine/keystone/issues/421
577 |
578 | return value.Replace("t0", "8").Replace("t1", "9")
579 | .Replace("t2", "10").Replace("t3", "11")
580 | .Replace("t4", "12").Replace("t5", "13")
581 | .Replace("t6", "14").Replace("t7", "15");
582 | }
583 |
584 | public enum ERROR : int
585 | {
586 | OK,
587 | UNKNOWN_COMMAND,
588 | WRONG_SYNTAX,
589 | ADDRESS_INVALID,
590 | VALUE_INVALID,
591 | MISS_ENDIF,
592 | MISS_ASM_START,
593 | MISS_ASM_END,
594 | MISS_FUNCTION,
595 | MISS_ENDFUNCTION,
596 | FUNCTION_COMMAND_INSIDE_FUNCTION_DEFINITION,
597 | FUNCTION_ALREADY_DEFINED,
598 | INCLUDE_COMMAND_INSIDE_FUNCTION_DEFINITION,
599 | INCLUDE_STACK_OVERFLOW,
600 | CALL_STACK_OVERFLOW,
601 | ARGUMENT_COUNT_MISMATCH
602 | }
603 |
604 | public static Dictionary ErrorMessages = new()
605 | {
606 | { ERROR.UNKNOWN_COMMAND, "An unknown command has been detected. Check the list of commands supported in the documentation -> \"List of commands\" section" },
607 | { ERROR.WRONG_SYNTAX, "There is something wrong with the command's syntax. Check the list of commands and their syntaxes in the documentation -> \"List of commands\" section." },
608 | { ERROR.ADDRESS_INVALID, "The (ADDRESS) argument was invalid. Check the conditions for a valid (ADDRESS) in the documentation -> \"Description and Settings\" section." },
609 | { ERROR.VALUE_INVALID, "The (VALUE) argument was invalid. Check the conditions for a valid (VALUE) in the documentation -> \"Description and Settings\" section." },
610 | { ERROR.MISS_ENDIF, "An \"If\" scope was opened but not closed. An \"If\" command must always have an \"EndIf\" command." },
611 | { ERROR.MISS_ASM_START, "An \"ASM_END\" command was detected but no matching \"ASM_START\" command is present. An \"ASM_END\" command must always have an \"ASM_START\" command." },
612 | { ERROR.MISS_ASM_END, "An \"ASM_START\" scope was opened but not closed. An \"ASM_START\" command must always have an \"ASM_END\" command." },
613 | { ERROR.MISS_FUNCTION, "An \"EndFunction\" command was detected but no matching \"Function\" command is present. An \"EndFunction\" command must always have a \"Function\" command." },
614 | { ERROR.MISS_ENDFUNCTION, "A \"Function\" scope was opened but not closed. A \"Function\" command must always have an \"EndFunction\" command." },
615 | { ERROR.FUNCTION_COMMAND_INSIDE_FUNCTION_DEFINITION, "A \"Function\" command was detected inside a \"Function\" definition. A \"Function\" scope must not have a \"Function\" command inside." },
616 | { ERROR.FUNCTION_ALREADY_DEFINED, "A \"Function\" command with the same (NAME) has already been defined. A function must not be defined more than once." },
617 | { ERROR.INCLUDE_COMMAND_INSIDE_FUNCTION_DEFINITION, "An \"Include\" command was detected inside a \"Function\" definition. A \"Function\" scope must not have an \"Include\" command inside." },
618 | { ERROR.INCLUDE_STACK_OVERFLOW, "An \"Include\" command was trying to include an already included file. This would create infinite recursion and result in a StackOverflowException.\nA file must not include itself, or include another file which includes one of the previous files." },
619 | { ERROR.CALL_STACK_OVERFLOW, "A \"Call\" command was trying to call the function in which it is defined. This would create infinite recursion and result in a StackOverflowException.\nRecursive functions are not allowed." },
620 | { ERROR.ARGUMENT_COUNT_MISMATCH, "The count of the arguments in the \"Function\" definition and the count of the arguments passed to the function with the \"Call\" command are not equal.\nThe count of the arguments in the \"Function\" command and the ones in the \"Call\" command must be equal." }
621 | };
622 | }
623 | }
624 |
--------------------------------------------------------------------------------
/CLPS2C-Documentation.txt:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////
2 |
3 |
4 | CLPS2C (Custom Language for PlayStation 2 Cheats) - Compiler
5 | Version: 1.0.3
6 | GitHub: https://github.com/NiV-L-A/CLPS2C-Compiler
7 |
8 |
9 | ///////////////////////////////////////////////////////////////////////
10 |
11 |
12 | Table Of Contents:
13 | (1) Description and Settings
14 | (2) List of commands
15 | (3) Example code (CLPS2C)
16 | (4) Example code (CLPS2C - Assembly)
17 | (5) Credits
18 |
19 |
20 | ///////////////////////////////////////////////////////////////////////
21 |
22 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
23 | (1) Description and Settings
24 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
25 |
26 | CLPS2C is a domain-specific language, built specifically for writing PS2 cheat codes.
27 | The main goal of the project is to have better managment and readability when cheats become too big/complex.
28 | The app supports, among other things:
29 | - Write all code types supported by ps2rd and Cheat Device
30 | - Output RAW or pnach-formatted cheat lines
31 | - Write MIPS Assembly
32 | - Automatic calculation for how many lines to execute in "If" commands
33 | - Support for logical AND in "If" commands
34 | - Set local variables to be referenced by name
35 | - Define functions with arguments and call them
36 | - Include CLPS2C files in other CLPS2C files
37 |
38 | Usage: CLPS2C-Compiler.exe
39 | -i, --input The file to be parsed. Example: -i "C:\Users\admin\Desktop\CLPS2C\Test1.txt"
40 | -o, --output The file in which the output will be written to. Example: -o "C:\Users\admin\Desktop\pcsx2\cheats\SCUS-97316_07652DD9testmod.pnach"
41 | If not passed, the output file path will be defaulted to the input's folder, with the same file name as the input file, and appending "-Output" to it.
42 | (e.g. "C:\Users\admin\Desktop\CLPS2C\Test1-Output.txt")
43 | -p, --pnach The app, by default, produces RAW lines. Enabling this option will convert them to Pnach-formatted lines.
44 | -d, --dtype The app, by default, converts "If" commands to E-type codes. Enabling this option will convert them to D-type codes.
45 | --help Display an help screen.
46 | --version Display version information.
47 |
48 | - All (ADDRESS) must be a valid hexadecimal number:
49 | - consisting of up to 8 digits,
50 | - with or without the prefix "0x",
51 | - with or without the negative "-" sign (hyphen symbol, not the dash symbol "—").
52 | - All (VALUE) are always considered decimal,
53 | adding the prefix "0x" will make them hexadecimal
54 | adding the prefix "-" (hyphen symbol, not the dash symbol "—") will make them negative
55 | and placing the (VALUE) between quotes (") will make them a string.
56 | - Some (ADDRESS) and (VALUE) arguments can be replaced with variables
57 | previously declared by using the "Set" command.
58 | - Support for the addition operator "+".
59 | The + operator is used for performing addition between two operands.
60 | - It can be a numeric addition:
61 | Set myVar 1 + 2 // myVar now contains 3
62 | Set myVar 1 + 2 + 3 // myVar now contains 6
63 | - A string concatenation:
64 | Set myVar "test" + "whatever" // myVar now contains "testwhatever"
65 | Set myVar "test" + "whatever" + " holding on" // myVar now contains "testwhatever holding on"
66 | - Or both:
67 | Set myVar 1
68 | Set myString "test" + myVar // myString now contains "test1"
69 | Set myString "test" + myVar + " environment" // myString now contains "test1 environment"
70 | - There can be any number of spaces/tabs before and/or after a command.
71 | - Support for single-line ("//") and multi-line ("/*" "*/") comments.
72 | - Support for escape characters in strings:
73 | \0 Null terminator. Byte representation: 0x00
74 | \n New line. Byte representation: 0x0A
75 | \t Tab. Byte representation: 0x09
76 | \" Double quote. Byte representation: 0x22
77 |
78 | - Syntax that is case-sensetive:
79 | - Variable names ("Set myVar 1" is different than "Set MYVAR 1").
80 | - Function names ("Function Reload()" is different than "Function RELOAD()")
81 | - Escape characters ("\n" is different than "\N").
82 | - Syntax that is not case-sensetive:
83 | - Command names ("SET" is equivalent to "set").
84 |
85 | - In the case the app encounters an error, the output will display some information about the first error encountered:
86 | - The type of error (see below),
87 | - The line that produced it,
88 | - The line number,
89 | - The traceback, which provides information about the sequence of commands that led to the point where the error occurred
90 | (useful when there're function calls and/or "Include" commands).
91 | The following is a list of possible errors:
92 | - CLPS2C errors:
93 | - UNKNOWN_COMMAND
94 | An unknown command has been detected. Check the list of commands supported in the documentation -> "List of commands" section.
95 | - WRONG_SYNTAX
96 | There is something wrong with the command's syntax. Check the list of commands and their syntaxes in the documentation -> "List of commands" section.
97 | - ADDRESS_INVALID
98 | The (ADDRESS) argument was invalid. Check the conditions for a valid (ADDRESS) in the documentation -> "Description and Settings" section.
99 | - VALUE_INVALID
100 | The (VALUE) argument was invalid. Check the conditions for a valid (VALUE) in the documentation -> "Description and Settings" section.
101 | - MISS_ENDIF
102 | An "If" scope was opened but not closed. An "If" command must always have an "EndIf" command.
103 | - MISS_ASM_START
104 | An "ASM_END" command was detected but no matching "ASM_START" command is present. An "ASM_END" command must always have an "ASM_START" command.
105 | - MISS_ASM_END
106 | An "ASM_START" scope was opened but not closed. An "ASM_START" command must always have an "ASM_END" command.
107 | - MISS_FUNCTION
108 | An "EndFunction" command was detected but no matching "Function" command is present. An "EndFunction" command must always have a "Function" command.
109 | - MISS_ENDFUNCTION
110 | A "Function" scope was opened but not closed. A "Function" command must always have an "EndFunction" command.
111 | - FUNCTION_COMMAND_INSIDE_FUNCTION_DEFINITION
112 | A "Function" command was detected inside a "Function" definition. A "Function" scope must not have a "Function" command inside.
113 | - FUNCTION_ALREADY_DEFINED
114 | A "Function" command with the same (NAME) has already been defined. A function must not be defined more than once.
115 | - INCLUDE_COMMAND_INSIDE_FUNCTION_DEFINITION
116 | An "Include" command was detected inside a "Function" definition. A "Function" scope must not have an "Include" command inside.
117 | - INCLUDE_STACK_OVERFLOW
118 | An "Include" command was trying to include an already included file. This would create infinite recursion and result in a StackOverflowException.
119 | A file must not include itself, or include another file which includes one of the previous files.
120 | - CALL_STACK_OVERFLOW
121 | A "Call" command was trying to call the function in which it is defined. This would create infinite recursion and result in a StackOverflowException.
122 | Recursive functions are not allowed.
123 | - ARGUMENT_COUNT_MISMATCH
124 | The count of the arguments in the "Function" definition and the count of the arguments passed to the function with the "Call" command are not equal.
125 | The count of the arguments in the "Function" command and the ones in the "Call" command must be equal.
126 | - Keystone engine (assembly) errors:
127 | - KS_ERR_ASM_SYMBOL_MISSING
128 | The Keystone engine could not find a symbol. This usually occurs because there's a branch/jump instruction to a label which has not been defined.
129 | - KS_ERR_ASM_MNEMONICFAIL
130 | The Keystone engine could not recognize an opcode. Note that not all opcodes supported by the PS2's MIPS R5900 CPU are supported in Keystone.
131 | - KS_ERR_ASM_INVALIDOPERAND
132 | The Keystone engine could not correctly parse the assembly instruction.
133 | This usually occurs because the dollar sign ("$") symbol is missing before referencing a register ("t1" instead of "$t1"),
134 | or because of an invalid number (for example, in the line "lw $t1,0xq", "0xq" is not a valid hexadecimal number).
135 |
136 | ///////////////////////////////////////////////////////////////////////
137 |
138 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
139 | (2) List of commands
140 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
141 |
142 | The following is a list of commands supported in CLPS2C, in which () are the arguments and [] are the optional arguments.
143 | Some commands might have an abbreviation. This is indicated with the pipe ("|") symbol.
144 |
145 | Unique
146 | Set (NAME) (VALUE)
147 | SetEncoding|SE (VALUE)
148 | SendRaw|SR (VALUE)
149 | SendRawWeight|SRW (VALUE)
150 | ASM_START (ADDRESS)
151 | ASM_END
152 | Include (VALUE)
153 | Function (NAME)([ARGUMENTS])
154 | EndFunction
155 | Call (NAME)([ARGUMENTS])
156 | Write
157 | Write8|W8 (ADDRESS) (VALUE)
158 | Write16|W16 (ADDRESS) (VALUE)
159 | Write32|W32 (ADDRESS) (VALUE)
160 | WriteFloat|WF (ADDRESS) (VALUE)
161 | WriteString|WS (ADDRESS) (VALUE)
162 | WriteBytes|WB (ADDRESS) (VALUE)
163 | WritePointer8|WP8 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
164 | WritePointer16|WP16 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
165 | WritePointer32|WP32 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
166 | WritePointerFloat|WPF (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
167 | CopyBytes|CB (ADDRESS1) (ADDRESS2) (VALUE)
168 | Fill8|F8 (ADDRESS) (VALUE1) (VALUE2)
169 | Fill16|F16 (ADDRESS) (VALUE1) (VALUE2)
170 | Fill32|F32 (ADDRESS) (VALUE1) (VALUE2)
171 | Increment / Decrement
172 | Increment8|I8 (ADDRESS) (VALUE)
173 | Increment16|I16 (ADDRESS) (VALUE)
174 | Increment32|I32 (ADDRESS) (VALUE)
175 | Decrement8|D8 (ADDRESS) (VALUE)
176 | Decrement16|D16 (ADDRESS) (VALUE)
177 | Decrement32|D32 (ADDRESS) (VALUE)
178 | Boolean Operations
179 | OR8 (ADDRESS) (VALUE)
180 | OR16 (ADDRESS) (VALUE)
181 | AND8 (ADDRESS) (VALUE)
182 | AND16 (ADDRESS) (VALUE)
183 | XOR8 (ADDRESS) (VALUE)
184 | XOR16 (ADDRESS) (VALUE)
185 | Conditional
186 | If (ADDRESS) (CONDITION)(DATATYPE) (VALUE) [&& (ADDRESS) (CONDITION)(DATATYPE) (VALUE)]
187 | EndIf|EI
188 |
189 | ///////////////////////////////////////////////////////////////////////
190 |
191 | Set (NAME) (VALUE)
192 | Declares a variable with the name (NAME) and
193 | assigns the value (VALUE) to it.
194 | Once a variable is declared, declaring it once again
195 | will replace its value.
196 | A variable can assume the value of an already declared variable.
197 | NOTE: This command does not output a cheat line.
198 |
199 | Arguments:
200 | (NAME) Name of the variable
201 | (VALUE) Value to assign to the variable
202 |
203 | Usage:
204 | Set MapID 0x4AF8A4
205 | Set TEMP 0x3A8B78
206 | Set myVar 1000 // Equivalent to "Set myVar 0x3E8"
207 | Set CharacterName "muse" // Will be converted to the array of bytes "6D 75 73 65"
208 | Set ProfileName "muse\0" // Will be converted to the array of bytes "6D 75 73 65 00"
209 |
210 | Set CharacterHP 0x12345678 // Now CharacterHP has the value of 0x12345678
211 | Set CharacterHP 0xDEADBEEF // Now CharacterHP has the value of 0xDEADBEEF
212 |
213 | Set myVar1 123
214 | Set myVar2 myVar1 // both myVar1 and myVar2 now equals to 123
215 |
216 | Set myVar 123
217 | Set myString "Value of myVar: " + myVar
218 |
219 | ///////////////////////////////////////////////////////////////////////
220 |
221 | SetEncoding|SE (VALUE)
222 | Sets the current encoding (VALUE) to be used for the WriteString command.
223 | The encoding chosen will be used until another SetEncoding command is encountered.
224 | NOTE: This command does not output a cheat line.
225 |
226 | Arguments:
227 | (VALUE)
228 | UTF-8 (default)
229 | UTF-16
230 |
231 | Usage:
232 | SetEncoding UTF-8
233 | WriteString 20E98100 "park" // Will be converted to the array of bytes "70 61 72 6B"
234 |
235 | SE UTF-16
236 | WriteString 20E98100 "park" // Will be converted to the array of bytes "70 00 61 00 72 00 6B 00"
237 |
238 | ///////////////////////////////////////////////////////////////////////
239 |
240 | SendRaw|SR (VALUE)
241 | Writes a raw string (VALUE) to the output.
242 | Condition for (VALUE): Always use the double quotes symbol (") as the prefix and suffix when not using a declared variable.
243 |
244 | Arguments:
245 | (VALUE) Value to write
246 |
247 | Usage:
248 | SendRaw "// Is there a better way to do this?"
249 | SendRaw "park\n"
250 |
251 | Set myStr "// All her doubts were someone else's point of view"
252 | SR myStr
253 |
254 | // Output the sentence "You're living in a fantasy world"
255 | Set lastWord "world"
256 | SendRaw "You're living" + " in a fantasy " + lastWord
257 |
258 | ///////////////////////////////////////////////////////////////////////
259 |
260 | SendRawWeight|SRW (VALUE)
261 | Writes a raw string (VALUE) to the output.
262 | Same as "SendRaw" but carries a "weight" value:
263 | "If" commands will consider this a "valid" cheat line and will take it into account when calculating how many lines to execute.
264 | By default, the command has a weight value of 1. For each '\n' character in (VALUE) the weight value gets incremented by 1.
265 | Condition for (VALUE): Always use the double quotes symbol (") as the prefix and suffix when not using a declared variable.
266 |
267 | Arguments:
268 | (VALUE) Value to write
269 |
270 | Usage:
271 | SendRawWeight "// Is there a better way to do this?"
272 |
273 | Set myStr "20FB1580 12345678"
274 | If 0x3E8110 =: 0xFF // This "If" command will consider "20FB1580 12345678" as a "valid" cheat line
275 | SRW myStr
276 | EndIf
277 |
278 | // This "If" command will consider "20FB1580 12345678\n20E98110 DEADBEEF" as 2 "valid" cheat lines
279 | // This means that the line count for the "If" command will be 2
280 | If 0x3E8110 =: 0xFF
281 | SRW "20FB1580 12345678\n20E98110 DEADBEEF"
282 | EndIf
283 |
284 | // Output the sentence "You're living in a fantasy world"
285 | Set firstWord "20FB1580"
286 | If 1 =: 2
287 | SendRawWeight firstWord + " 00000001"
288 | EndIf
289 |
290 | ///////////////////////////////////////////////////////////////////////
291 |
292 | ASM_START (ADDRESS)
293 | ASM_END
294 | Defines the beginning and ending of an assembly scope.
295 | While in this scope, all the other CLPS2C commands can't be executed (with the exception of the ASM_END command).
296 | While in this scope, values set with the Set command will not be applied, with the exception of the "J" and "JAL" opcodes.
297 | Every register must be prefixed with the dollar sign ($).
298 | Labels can be used, but the first instruction must be on the same line as the label ("myLabel: li $t0,1").
299 | Always have an ASM_END command to indicate the termination of the assembly scope.
300 | NOTE: You must manually add the branch delay slot after any branch instruction.
301 |
302 | Arguments:
303 | (ADDRESS) Starting address
304 |
305 | Usage:
306 | ASM_START 003D1000
307 | addi $t2,$t1,0x0058 // $t2 = $t1 + 0x58
308 | ASM_END
309 |
310 | Set Cave 203D1000
311 | ASM_START Cave
312 | /*Load immediate ($t0 = 0x003D10A0). Equivalent to "lui $t0,0x003D; ori $t0,$t0,0x10A0".*/
313 | li $t0,0x003D10A0
314 |
315 | /*Load word ($t0 = *0x003D10A0). Reads 4 bytes at the specified address and stores the value in the specified register.*/
316 | /*Equivalent to "lui $t0,0x003D; lw $t0,0x10A0($t0)".*/
317 | lw $t0,0x003D10A0
318 |
319 | /*Load immediate in a float register. Loads 60f in the $f4 register.*/
320 | li $t0,60 // load 60 as int in $t0.
321 | mtc1 $t0,$f4 // move to coprocessor 1 (FPU)'s register $f4.
322 | cvt.s.w $f4,$f4 // converts a word to a floating point (60 -> 60f).
323 |
324 | /*Load immediate in a float register. Loads 1f in the $f12 register.*/
325 | lui $t0,0x3F80 // load 0x3F800000 in $t0 (0x3F800000 is 1 in float).
326 | mtc1 $t0,$f12 // move to coprocessor 1 (FPU)'s register $f12.
327 | ASM_END
328 |
329 | /* Example with JAL instruction that uses a set variable */
330 | Set myFunction 0xF0EE0
331 | ASM_START 0x1A761C // hook
332 | jal myFunction // values set with the Set command are only available for the "J" and "JAL" opcodes
333 | nop
334 | ASM_END
335 | ASM_START myFunction // codecave
336 | // increment frame counter
337 | lw $v0,-0x1AC8($s1)
338 | addiu $v0,$v0,0x1
339 | jr $ra
340 | nop
341 | ASM_END
342 |
343 | /* Example with J instruction that uses a set variable */
344 | Set hook 0x1A761C
345 | Set codeCave 0xF0EE0
346 | ASM_START hook
347 | j codeCave // values set with the Set command are only available for the "J" and "JAL" opcodes
348 | nop
349 | ASM_END
350 | ASM_START codeCave
351 | // increment frame counter
352 | lw $v0,-0x1AC8($s1)
353 | addiu $v0,$v0,0x1
354 | j hook+0x8 // go to hook + 0x8 (0x8 = 0x4 + 0x4 = "j codeCave" + the delay slot)
355 | nop
356 | ASM_END
357 |
358 | ASM_START 200FF000 + 0x10
359 | // check flag
360 | lw $t0,0x003D0D00
361 | li $at,0x1
362 | beq $t0,$at,DisableFlag // if flag == 1
363 | nop
364 | b Exit
365 | nop
366 | DisableFlag: li $at,0 // disable flag
367 | lui $t0,0x003D
368 | sw $at,0xD00($t0) // can also get the value 0 from the register $zero instead of loading the value in the register $at
369 | Exit: jr $ra // return
370 | nop
371 | ASM_END
372 |
373 | ///////////////////////////////////////////////////////////////////////
374 |
375 | Include (VALUE)
376 | Parses a specific file.
377 | Condition for (VALUE): Always use the double quotes symbol (") as the prefix and suffix.
378 | It's possible that an Include command is present in an included file:
379 | For example, let the file "Engine.txt" have this line of code: Include "Player.txt"
380 | By including the "Engine.txt" file, it will also parse the line above, and so, also include the "Player.txt" file.
381 | NOTE: A file must not include itself, or include another file which includes one of the previous files.
382 | For example, let the file "Engine.txt" have this line of code: Include "Engine.txt"
383 | This will create infinite recursion, running that same Include command until a StackOverflowException happens.
384 | The app will detect this happening and will stop executing, displaying an INCLUDE_STACK_OVERFLOW error.
385 | NOTE: The addition operator is not supported for this command.
386 | NOTE: The (VALUE) argument can't be replaced with a variable.
387 |
388 | Arguments:
389 | (VALUE)
390 | 1) Absolute path: "C:\Users\admin\Desktop\CLPS2C\IncludeExample\Sly2\NTSC\Engine.txt"
391 | 2) Relative path to the input file path (same folder as the input file): "Engine.txt"
392 | 3) Relative path to the input file path (sub-folder(s) from the input file): "IncludeExample\Sly2\NTSC\Engine.txt"
393 | 4) Relative path to the most recent included file path: "C:\Users\admin\Desktop\CLPS2C\IncludeExample\Sly2\NTSC\Engine.txt"
394 | includes "Gui.txt" (in the folder C:\Users\admin\Desktop\CLPS2C\IncludeExample\Sly2\NTSC)
395 |
396 | Usage:
397 | // Absolute path
398 | Include "C:\Users\admin\Desktop\CLPS2C\IncludeExample\Sly2\NTSC\Engine.txt"
399 | Write32 MapID 1 // MapID is a variable set in the file referenced above.
400 |
401 | // Relative path to the input file path (same folder as the input file)
402 | Include "Sly2NTSC.txt"
403 | Write32 CharHP CharHPMax // CharHP and CharHPMax are variables set in the file referenced above.
404 |
405 | // Relative path to the input file path (sub-folder(s) from the input file)
406 | Include "IncludeExample/Sly2/NTSC/Entity.txt"
407 | WritePointerFloat g_psly,Trans2Off,XCoordOff 0 // g_psly, Trans2Off and XCoordOff are variables set in the file referenced above.
408 |
409 | // This will display a WRONG_SYNTAX error. The (VALUE) argument can't be replaced with a variable.
410 | Set MyFile "IncludeExample/Sly2/NTSC/Engine.txt"
411 | Include MyFile
412 |
413 | ///////////////////////////////////////////////////////////////////////
414 |
415 | Function (NAME)([ARGUMENTS])
416 | EndFunction
417 | Call (NAME)([ARGUMENTS])
418 | Defines a function (a collection of commands) which can be executed by the "Call" command.
419 | It is possible to pass arguments, separated by a comma (","), to the function.
420 | Always have an "EndFunction" command to indicate the termination of the function scope.
421 | NOTE: A "Function" scope must not have a "Function" command inside.
422 | NOTE: A "Function" scope must not have an "Include" command inside.
423 | NOTE: Recursive functions are not allowed. A "Call" command must not invoke the function they are a part of.
424 | NOTE: A function must not be defined more than once.
425 | NOTE: The addition operator is not supported for the "Function" command,
426 | but it is for the commands inside the function and the "Call" command.
427 |
428 | Arguments:
429 | (NAME) The name of the function
430 | ([ARGUMENTS]) List of arguments separated by a comma (",") to be passed to the function
431 |
432 | Usage:
433 | Function Reload()
434 | Write32 3E1080 1
435 | EndFunction
436 | Call Reload() // Gets replaced with Write32 3E1080 1
437 |
438 | Set g_pcoingui 0x3E103C
439 | Function ToggleGui(gui, value)
440 | WritePointer32 gui,0x64 value
441 | EndFunction
442 | Call ToggleGui(g_pcoingui, 1) // Gets replaced with WritePointer32 0x3E103C,0x64 1
443 |
444 | Set g_pjt 0x2E1E40
445 | Function WriteXYZ(base, valueX, valueY, valueZ)
446 | WritePointerFloat base,58,30 valueX
447 | WritePointerFloat base,58,34 valueY
448 | WritePointerFloat base,58,38 valueZ
449 | EndFunction
450 | Call WriteXYZ(g_pjt, -2740, -3637, 1500) // Gets replaced with WritePointerFloat 0x2E1E40,58,30 -2740...
451 |
452 | Function WriteText(str)
453 | WriteString 20FB1580 str
454 | EndFunction
455 | Call WriteText("park") // Gets replaced with WriteString 20FB1580 "park"
456 |
457 | Function PopulateStruct(address, value)
458 | Write32 address value
459 | Write32 address + 0x4 value + 0x10
460 | Write32 address + 0x8 value + 0x20
461 | Write32 address + 0xC value + 0x30
462 | EndFunction
463 | Call PopulateStruct(20FB1580, 0x1000 + 1)
464 |
465 | ///////////////////////////////////////////////////////////////////////
466 |
467 | Write8|W8 (ADDRESS) (VALUE)
468 | Writes the 8-bit (1 byte) value (VALUE) to the address (ADDRESS).
469 | Condition for (VALUE): 0x00 <= (VALUE) <= 0xFF
470 |
471 | Arguments:
472 | (ADDRESS) The address to which the value will be written to
473 | (VALUE) The value to write
474 |
475 | Usage:
476 | Write8 21F2E740 40 // Writes 40 to the memory address 0x21F2E740
477 | Write8 21F2E740 0x40 // Writes 64 to the memory address 0x21F2E740
478 |
479 | Set MapID 0x004AF8A4
480 | Write8 MapID 6 // Writes 6 to the memory address 0x004AF8A4
481 |
482 | Set MapID 0x004AF8A4
483 | Set TargetValue 127 + 1
484 | W8 MapID TargetValue // Writes 128 to the memory address 0x004AF8A4
485 |
486 | ///////////////////////////////////////////////////////////////////////
487 |
488 | Write16|W16 (ADDRESS) (VALUE)
489 | Writes the 16-bit (2 bytes) value (VALUE) to the address (ADDRESS).
490 | Condition for (VALUE): 0x0000 <= (VALUE) <= 0xFFFF
491 |
492 | Arguments:
493 | (ADDRESS) The address to which the value will be written to
494 | (VALUE) The value to write
495 |
496 | Usage:
497 | Write16 21F2E740 123 // Writes 40 to the memory address 0x01F2E740
498 | Write16 21F2E740 0x123 // Writes 291 to the memory address 0x01F2E740
499 |
500 | Set CharacterID 0x20390018
501 | Write16 CharacterID 0xDEAD // Writes 57005 to the memory address 0x00390018
502 |
503 | Set MapID 0x004AF8A4
504 | Set TargetValue 29827
505 | W16 MapID TargetValue + 2 // Writes 29829 to the memory address 0x004AF8A4
506 |
507 | ///////////////////////////////////////////////////////////////////////
508 |
509 | Write32|W32 (ADDRESS) (VALUE)
510 | Writes the 32-bit (4 bytes) value (VALUE) to the address (ADDRESS).
511 | Condition for (VALUE): 0x00000000 <= (VALUE) <= 0xFFFFFFFF
512 |
513 | Arguments:
514 | (ADDRESS) The address to which the value will be written to
515 | (VALUE) The value to write
516 |
517 | Usage:
518 | Write32 21F2E740 123 // Writes 40 to the memory address 0x01F2E740
519 | Write32 21F2E740 0x123 // Writes 291 to the memory address 0x01F2E740
520 |
521 | Set CharacterID 0x20390018
522 | Write32 CharacterID 0xDEADDEAD // Writes 3735936685 to the memory address 0x00390018
523 |
524 | Set MapID 0x004AF8A4
525 | Set TargetValue 0x12345678 + 1
526 | W32 MapID TargetValue + 2 // Writes 0x1234567B (305419899) to the memory address 0x004AF8A4
527 |
528 | ///////////////////////////////////////////////////////////////////////
529 |
530 | WriteFloat|WF (ADDRESS) (VALUE)
531 | Writes the 32-bit floating-point value (VALUE) to the address (ADDRESS).
532 | If (VALUE) is an hexadecimal number, it will be parsed as one.
533 |
534 | Arguments:
535 | (ADDRESS) The address to which the value will be written to
536 | (VALUE) The value to write
537 |
538 | Usage:
539 | WriteFloat 21F2E740 123 // Writes 123 in float to the memory address 0x01F2E740. Equivalent to "Write32 01F2E740 0x42F60000"
540 |
541 | Set XCoord 0x20390018
542 | WriteFloat XCoord -5000 // Writes -5000 in float to the memory address 0x00390018. Equivalent to "Write32 00390018 0xC59C4000"
543 |
544 | Set XCoord 0x20390018
545 | Set TargetValue 1.5
546 | WriteFloat XCoord TargetValue // Writes 1.5 in float to the memory address 0x00390018. Equivalent to "Write32 00390018 0x3FC00000"
547 |
548 | WriteFloat 20FB1580 0x123 // Equivalent to "Write32 00FB1580 0x123"
549 |
550 | WF 20390018 Infinity // Writes +Infinity in float to the memory address 0x00390018. Equivalent to "Write32 00390018 0x7F800000"
551 | WF 20390018 -Infinity // Writes -Infinity in float to the memory address 0x00390018. Equivalent to "Write32 00390018 0xFF800000"
552 | WF 20390018 NaN // Writes NaN in float to the memory address 0x00390018. Equivalent to "Write32 00390018 0xFFC00000"
553 |
554 | WriteFloat 20FB1580 1 + 0.5 // Equivalent to "Write32 20FB1580 3FC00000"
555 |
556 | ///////////////////////////////////////////////////////////////////////
557 |
558 | WriteString|WS (ADDRESS) (VALUE)
559 | Writes the string (VALUE) to the address (ADDRESS) with the current encoding (can be changed with the SetEncoding command).
560 | Condition for (VALUE): Always use the double quotes symbol (") as the prefix and suffix when not using a declared variable.
561 | NOTE: Append "\0" at the end of the string to add a null terminator character.
562 | NOTE: When ((VALUE).Length % 4 != 0), more writes of different data types are needed:
563 | "park" -> Write32.
564 | "parko" -> Write32+Write8.
565 | "parkou" -> Write32+Write16.
566 | "parkour" -> Write32+Write16+Write8.
567 |
568 | Arguments:
569 | (ADDRESS) The address to which the value will be written to
570 | (VALUE) The value to write
571 |
572 | Usage:
573 | WriteString 01F2E740 "parkour_start" // Writes "parkour_start" in string form to the memory address 0x01F2E740
574 | WriteString 01F2E740 "parkour_start\0" // Writes "parkour_start" in string form to the memory address 0x01F2E740 and appends a 0x00 at the end.
575 |
576 | Set myAddr 0x01F2E740
577 | Set TargetValue "Thanks for playing this map!\n\nPress any key to exit.\0"
578 | WS myAddr TargetValue // Writes "Thanks for playing this map!\n\nPress any key to exit.\0", to the memory address 0x01F2E740
579 |
580 | // Write "parkour_start", "parkour_mid", "parkour_prelast", "parkour_last" and "parkour_ending"
581 | Set prefix "parkour_"
582 | Set address 20FB1580
583 | WriteString address prefix + "start\0"
584 | WriteString address + 0x10 prefix + "mid\0"
585 | WriteString address + 0x20 prefix + "prelast\0"
586 | WriteString address + 0x30 prefix + "last\0"
587 | WriteString address + 0x40 prefix + "ending\0"
588 |
589 | ///////////////////////////////////////////////////////////////////////
590 |
591 | WriteBytes|WB (ADDRESS) (VALUE)
592 | Writes the byte array (VALUE) to the address (ADDRESS).
593 | Condition for (VALUE): Always use the double quotes symbol (") as the prefix and suffix when not using a declared variable.
594 | NOTE: When ((VALUE).Length % 4 != 0), more writes of different data types are needed:
595 | "00 11 22 33" -> Write32.
596 | "00 11 22 33 44" -> Write32+Write8.
597 | "00 11 22 33 44 55" -> Write32+Write16.
598 | "00 11 22 33 44 55 66" -> Write32+Write16+Write8.
599 |
600 | Arguments:
601 | (ADDRESS) The address to which the value will be written to
602 | (VALUE) The value to write
603 |
604 | Usage:
605 | WriteBytes 00764590 "00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF"
606 |
607 | Set myAddr 0x01F2E740
608 | Set TargetValue "e4 7b bc 08 17 f5 7f a4 d2 2a 06 e8 74 82 29 d4 7e 0f 7d 86 c6 41 e4 a1 85 00"
609 | WB myAddr TargetValue
610 |
611 | Set myByte "44"
612 | WriteBytes 20FB1580 "00 11 22" + " 33" + " " + myByte // Writes the array of bytes "00 11 22 33 44" at address 20FB1580
613 |
614 | ///////////////////////////////////////////////////////////////////////
615 |
616 | WritePointer8|WP8 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
617 | Writes the 8-bit (1 byte) value (VALUE) to the address calculated by
618 | loading the base (ADDRESS1) and adding (ADDRESS2) and [,ADDRESSN].
619 | Each (ADDRESS) must be separated by a comma (,).
620 | Condition for (VALUE): 0x00 <= (VALUE) <= 0xFF
621 |
622 | Arguments:
623 | (ADDRESS1),(ADDRESS2)[,ADDRESSN] The pointer chain to which the value will be written to
624 | (VALUE) The value to write
625 |
626 | Usage:
627 | WritePointer8 21F2E740,48 40 // Writes 40 to the memory address pointed by (the base from address 0x21F2E740 and adding the offset 0x48)
628 | WritePointer8 21F2E740,0x1C,0x70 0x40 // Writes 64 to the memory address poined by (the base from address 0x21F2E740 and adding the offsets 0x1C and 0x70)
629 |
630 | Set CharBase 0x004AF8A4
631 | Set StatsOff 0x20
632 | Set HPOff 0x30
633 | WP8 CharBase,StatsOff,HPOff 1
634 |
635 | WritePointer8 20FB1580,0x58,0x30+0x100 0
636 |
637 | ///////////////////////////////////////////////////////////////////////
638 |
639 | WritePointer16|WP16 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
640 | Writes the 16-bit (2 bytes) value (VALUE) to the address calculated by
641 | loading the base (ADDRESS1) and adding (ADDRESS2) and [,ADDRESSN].
642 | Each (ADDRESS) must be separated by a comma (,).
643 | Condition for (VALUE): 0x0000 <= (VALUE) <= 0xFFFF
644 |
645 | Arguments:
646 | (ADDRESS1),(ADDRESS2)[,ADDRESSN] The pointer chain to which the value will be written to
647 | (VALUE) The value to write
648 |
649 | Usage:
650 | WritePointer16 21F2E740,48 40 // Writes 40 to the memory address pointed by (the base from address 0x21F2E740 and adding the offset 0x48)
651 | WritePointer16 21F2E740,0x1C,0x70 0x40 // Writes 64 to the memory address poined by (the base from address 0x21F2E740 and adding the offsets 0x1C and 0x70)
652 |
653 | Set CharBase 0x004AF8A4
654 | Set StatsOff 0x20
655 | Set HPOff 0x30
656 | WP16 CharBase,StatsOff,HPOff 1
657 |
658 | WritePointer16 20FB1580,0x58,0x30+0x110 0x14
659 |
660 | ///////////////////////////////////////////////////////////////////////
661 |
662 | WritePointer32|WP32 (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
663 | Writes the 32-bit (4 bytes) value (VALUE) to the address calculated by
664 | loading the base (ADDRESS1) and adding (ADDRESS2) and [,ADDRESSN].
665 | Each (ADDRESS) must be separated by a comma (,).
666 | Condition for (VALUE): 0x00000000 <= (VALUE) <= 0xFFFFFFFF
667 |
668 | Arguments:
669 | (ADDRESS1),(ADDRESS2)[,ADDRESSN] The pointer chain to which the value will be written to
670 | (VALUE) The value to write
671 |
672 | Usage:
673 | WritePointer32 21F2E740,48 40 // Writes 40 to the memory address pointed by (the base from address 0x21F2E740 and adding the offset 0x48)
674 | WritePointer32 21F2E740,0x1C,0x70 0x40 // Writes 64 to the memory address poined by (the base from address 0x21F2E740 and adding the offsets 0x1C and 0x70)
675 |
676 | Set CharBase 0x004AF8A4
677 | Set StatsOff 0x20
678 | Set HPOff 0x30
679 | WP32 CharBase,StatsOff,HPOff 1
680 |
681 | WritePointer32 20FB1580,0x58+4,0x30+0x120 0x28
682 |
683 | ///////////////////////////////////////////////////////////////////////
684 |
685 | WritePointerFloat|WPF (ADDRESS1),(ADDRESS2)[,ADDRESSN] (VALUE)
686 | Writes the 32-bit floating-point value (VALUE) to the address calculated by
687 | loading the base (ADDRESS1) and adding (ADDRESS2) and [,ADDRESSN].
688 | Each (ADDRESS) must be separated by a comma (,).
689 | If (VALUE) is an hexadecimal number, it will be parsed as one.
690 |
691 | Arguments:
692 | (ADDRESS1),(ADDRESS2)[,ADDRESSN] The pointer chain to which the value will be written to
693 | (VALUE) The value to write
694 |
695 | Usage:
696 | WritePointerFloat 21F2E740,48 1.5 // Writes 1.5 to the memory address pointed by (the base from address 0x21F2E740 and adding the offset 0x48)
697 | WritePointerFloat 21F2E740,0x1C,0x70 100 // Writes 100 to the memory address poined by (the base from address 0x21F2E740 and adding the offsets 0x1C and 0x70)
698 |
699 | Set CharBase 0x004AF8A4
700 | Set TransOff 0x58
701 | Set XCoord 0x30
702 | WPF CharBase,TransOff,XCoord Infinity
703 |
704 | WritePointerFloat 20FB1580,0x58+4,0x30+0x120 0.66
705 |
706 | ///////////////////////////////////////////////////////////////////////
707 |
708 | CopyBytes|CB (ADDRESS1) (ADDRESS2) (VALUE)
709 | Copies a block of (VALUE) bytes from source address (ADDRESS1) to destination address (ADDRESS2).
710 |
711 | Arguments:
712 | (ADDRESS1) Source address
713 | (ADDRESS2) Destination address
714 | (VALUE) Length in bytes
715 |
716 | Usage:
717 | CopyBytes 15E6CB4 15E6CB8 4 // Copies 4 bytes from 0x015E6CB4 to 0x015E6CB8
718 |
719 | Set source 0x004AF8A4
720 | Set dest 0x01F2E740
721 | CB source dest 0x40 // Copies 64 bytes from 0x004AF8A4 to 0x01F2E740
722 |
723 | // Copies 16 bytes from 0x00FB1580 to 0x003E1210
724 | CopyBytes 00FB1580 003E1110 + 100 0x10
725 |
726 | ///////////////////////////////////////////////////////////////////////
727 |
728 | Fill8|F8 (ADDRESS) (VALUE1) (VALUE2)
729 | Writes the 8-bit (1 byte) value (VALUE1) for (VALUE2) bytes starting from the address (ADDRESS).
730 | Condition for (VALUE1): 0x00 <= (VALUE1) <= 0xFF
731 | Condition for (VALUE2): 0x00 <= (VALUE2) <= 0xFFFF
732 | NOTE: This command outputs a 8-type code ("8-bit constant serial write").
733 | Latest PCSX2 (v2.2.0) does not support 8-type codes.
734 |
735 | Arguments:
736 | (ADDRESS) Starting address
737 | (VALUE1) Value to write
738 | (VALUE2) Length in bytes
739 |
740 | Usage:
741 | Fill8 20FB1580 0x12 0x100 // Writes the value 0x12, starting from address 0xFB1580, for 0x100 bytes
742 |
743 | Set Addr 0x004AF8A4
744 | Set ValueToWrite 0x34
745 | Set Len 0x40
746 | F8 Addr ValueToWrite Len // Writes the value 0x34, starting from address 0x004AF8A4, for 0x40 bytes
747 |
748 | // Writes the value 0, starting from address 0xFB1590, for 0x10 bytes
749 | Fill8 00FB1580+10 0 0x10
750 |
751 | ///////////////////////////////////////////////////////////////////////
752 |
753 | Fill16|F16 (ADDRESS) (VALUE1) (VALUE2)
754 | Writes the 16-bit (2 bytes) value (VALUE1) for (VALUE2) bytes starting from the address (ADDRESS).
755 | Condition for (VALUE1): 0x00 <= (VALUE1) <= 0xFFFF
756 | Condition for (VALUE2): 0x00 <= (VALUE2) <= 0x1FFFE
757 | NOTE: (VALUE2) must be divisible by 2.
758 | NOTE: This command outputs a 8-type code ("16-bit constant serial write").
759 | Latest PCSX2 (v2.2.0) does not support 8-type codes.
760 |
761 | Arguments:
762 | (ADDRESS) Starting address
763 | (VALUE1) Value to write
764 | (VALUE2) Length in bytes
765 |
766 | Usage:
767 | Fill16 20FB1580 0x1234 0x100 // Writes the value 0x1234, starting from address 0xFB1580, for 0x100 bytes
768 |
769 | Set Addr 0x004AF8A4
770 | Set ValueToWrite 0x1234
771 | Set Length 0x40
772 | F16 Addr ValueToWrite Length // Writes the value 0x1234, starting from address 0x4AF8A4, for 0x40 bytes
773 |
774 | // Writes the value 0, starting from address 0xFB15A0, for 0x10 bytes
775 | Fill16 00FB1580+20 0 0x10
776 |
777 | ///////////////////////////////////////////////////////////////////////
778 |
779 | Fill32|F32 (ADDRESS) (VALUE1) (VALUE2)
780 | Writes the 32-bit (4 bytes) value (VALUE1) for (VALUE2) bytes starting from the address (ADDRESS).
781 | Condition for (VALUE1): 0x00 <= (VALUE1) <= 0xFFFFFFFF
782 | Condition for (VALUE2): 0x00 <= (VALUE2) <= 0x3FFFC
783 | NOTE: (VALUE2) must be divisible by 4.
784 |
785 | Arguments:
786 | (ADDRESS) Starting address
787 | (VALUE1) Value to write
788 | (VALUE2) Length in bytes
789 |
790 | Usage:
791 | Fill32 20FB1580 0x12345678 0x100 // Writes the value 0x12345678, starting from address 0xFB1580, for 0x100 bytes
792 |
793 | Set Addr 0x004AF8A4
794 | Set ValueToWrite 0
795 | Set Length 0x40
796 | F32 Addr ValueToWrite Length // Writes the value 0, starting from address 0x4AF8A4, for 0x40 bytes
797 |
798 | // Writes the value 0, starting from address 0xFB15B0, for 0x10 bytes
799 | Fill32 00FB1580+30 0 0x10
800 |
801 | ///////////////////////////////////////////////////////////////////////
802 |
803 | Increment8|I8 (ADDRESS) (VALUE)
804 | Increments the 8-bit (1 byte) value at address (ADDRESS) by the 8-bit (1 byte) value (VALUE).
805 |
806 | Arguments:
807 | (ADDRESS) The address to which the value will be read from and written to
808 | (VALUE) The value that will be added to the existing value at the specified address
809 |
810 | Usage:
811 | Increment8 20E98100 1 // Increments the value at address 0xE98100 by 1
812 |
813 | Set Addr 0xA73910
814 | Set Val 100
815 | I8 Addr Val
816 |
817 | Set Val 100
818 | Increment8 20E98100 Val + 1
819 |
820 | ///////////////////////////////////////////////////////////////////////
821 |
822 | Increment16|I16 (ADDRESS) (VALUE)
823 | Increments the 16-bit (2 bytes) value at address (ADDRESS) by the 16-bit (2 bytes) value (VALUE).
824 |
825 | Arguments:
826 | (ADDRESS) The address to which the value will be read from and written to
827 | (VALUE) The value that will be added to the existing value at the specified address
828 |
829 | Usage:
830 | Increment16 20E98100 1 // Increments the value at address 0xE98100 by 1
831 |
832 | Set Addr 0xA73910
833 | Set Val 100
834 | I16 Addr Val
835 |
836 | Set Val 110
837 | Increment16 20E98100 Val + 2
838 |
839 | ///////////////////////////////////////////////////////////////////////
840 |
841 | Increment32|I32 (ADDRESS) (VALUE)
842 | Increments the 32-bit (4 bytes) value at address (ADDRESS) by the 32-bit (4 bytes) value (VALUE).
843 |
844 | Arguments:
845 | (ADDRESS) The address to which the value will be read from and written to
846 | (VALUE) The value that will be added to the existing value at the specified address
847 |
848 | Usage:
849 | Increment32 20E98100 1 // Increments the value at address 0xE98100 by 1
850 |
851 | Set Addr 0xA73910
852 | Set Val 100
853 | I32 Addr Val
854 |
855 | Set Val 120
856 | Increment32 20E98100 Val + 3
857 |
858 | ///////////////////////////////////////////////////////////////////////
859 |
860 | Decrement8|D8 (ADDRESS) (VALUE)
861 | Decrements the 8-bit (1 byte) value at address (ADDRESS) by the 8-bit (1 byte) value (VALUE).
862 |
863 | Arguments:
864 | (ADDRESS) The address to which the value will be read from and written to
865 | (VALUE) The value that will be subtracted to the existing value at the specified address
866 |
867 | Usage:
868 | Decrement8 20E98100 1 // Decrements the value at address 0xE98100 by 1
869 |
870 | Set Addr 0xA73910
871 | Set Val 100
872 | D8 Addr Val
873 |
874 | Set Val 100
875 | Decrement8 20E98100 Val + 1
876 |
877 | ///////////////////////////////////////////////////////////////////////
878 |
879 | Decrement16|D16 (ADDRESS) (VALUE)
880 | Decrements the 16-bit (2 bytes) value at address (ADDRESS) by the 16-bit (2 bytes) value (VALUE).
881 |
882 | Arguments:
883 | (ADDRESS) The address to which the value will be read from and written to
884 | (VALUE) The value that will be subtracted to the existing value at the specified address
885 |
886 | Usage:
887 | Decrement16 20E98100 1 // Decrements the value at address 0xE98100 by 1
888 |
889 | Set Addr 0xA73910
890 | Set Val 100
891 | D16 Addr Val
892 |
893 | Set Val 110
894 | Decrement16 20E98100 Val + 2
895 |
896 | ///////////////////////////////////////////////////////////////////////
897 |
898 | Decrement32|D32 (ADDRESS) (VALUE)
899 | Decrements the 32-bit (4 bytes) value at address (ADDRESS) by the 32-bit (4 bytes) value (VALUE).
900 |
901 | Arguments:
902 | (ADDRESS) The address to which the value will be read from and written to
903 | (VALUE) The value that will be subtracted to the existing value at the specified address
904 |
905 | Usage:
906 | Decrement32 20E98100 1 // Decrements the value at address 0xE98100 by 1
907 |
908 | Set Addr 0xA73910
909 | Set Val 100
910 | D32 Addr Val
911 |
912 | Set Val 120
913 | Decrement32 20E98100 Val + 3
914 |
915 | ///////////////////////////////////////////////////////////////////////
916 |
917 | OR8 (ADDRESS) (VALUE)
918 | Bitwise 8-bit (1 byte) OR operation between the value stored at address (ADDRESS) and (VALUE).
919 | Store the result at the address (ADDRESS).
920 |
921 | Arguments:
922 | (ADDRESS) The address to which the value will be read from and written to
923 | (VALUE) The value that will be OR'ed to the existing value at the specified address
924 |
925 | Usage:
926 | OR8 90A64C 4
927 |
928 | Set Addr 90A64C
929 | Set Val 4
930 | OR8 Addr Val
931 |
932 | Set address FB1580
933 | OR8 address + 0x10 0x80
934 |
935 | ///////////////////////////////////////////////////////////////////////
936 |
937 | OR16 (ADDRESS) (VALUE)
938 | Bitwise 16-bit (2 bytes) OR operation between the value stored at address (ADDRESS) and (VALUE).
939 | Store the result at the address (ADDRESS).
940 |
941 | Arguments:
942 | (ADDRESS) The address to which the value will be read from and written to
943 | (VALUE) The value that will be OR'ed to the existing value at the specified address
944 |
945 | Usage:
946 | OR16 90A64C 4
947 |
948 | Set Addr 90A64C
949 | Set Val 4
950 | OR16 Addr Val
951 |
952 | Set address FB1580
953 | OR16 address + 0x20 0x80
954 |
955 | ///////////////////////////////////////////////////////////////////////
956 |
957 | AND8 (ADDRESS) (VALUE)
958 | Bitwise 8-bit (1 byte) AND operation between the value stored at address (ADDRESS) and (VALUE).
959 | Store the result at the address (ADDRESS).
960 |
961 | Arguments:
962 | (ADDRESS) The address to which the value will be read from and written to
963 | (VALUE) The value that will be AND'ed to the existing value at the specified address
964 |
965 | Usage:
966 | AND8 90A64C 4
967 |
968 | Set Addr 90A64C
969 | Set Val 4
970 | AND8 Addr Val
971 |
972 | Set address FB1580
973 | AND8 address + 0x30 0x80
974 |
975 | ///////////////////////////////////////////////////////////////////////
976 |
977 | AND16 (ADDRESS) (VALUE)
978 | Bitwise 16-bit (2 bytes) AND operation between the value stored at address (ADDRESS) and (VALUE).
979 | Store the result at the address (ADDRESS).
980 |
981 | Arguments:
982 | (ADDRESS) The address to which the value will be read from and written to
983 | (VALUE) The value that will be AND'ed to the existing value at the specified address
984 |
985 | Usage:
986 | AND16 90A64C 4
987 |
988 | Set Addr 90A64C
989 | Set Val 4
990 | AND16 Addr Val
991 |
992 | Set address FB1580
993 | AND16 address + 0x40 0x80
994 |
995 | ///////////////////////////////////////////////////////////////////////
996 |
997 | XOR8 (ADDRESS) (VALUE)
998 | Bitwise 8-bit (1 byte) XOR operation between the value stored at address (ADDRESS) and (VALUE).
999 | Store the result at the address (ADDRESS).
1000 |
1001 | Arguments:
1002 | (ADDRESS) The address to which the value will be read from and written to
1003 | (VALUE) The value that will be XOR'ed to the existing value at the specified address
1004 |
1005 | Usage:
1006 | XOR8 90A64C 4
1007 |
1008 | Set Addr 90A64C
1009 | Set Val 4
1010 | XOR8 Addr Val
1011 |
1012 | Set address FB1580
1013 | XOR8 address + 0x50 0x80
1014 |
1015 | ///////////////////////////////////////////////////////////////////////
1016 |
1017 | XOR16 (ADDRESS) (VALUE)
1018 | Bitwise 16-bit (2 bytes) XOR operation between the value stored at address (ADDRESS) and (VALUE).
1019 | Store the result at the address (ADDRESS).
1020 |
1021 | Arguments:
1022 | (ADDRESS) The address to which the value will be read from and written to
1023 | (VALUE) The value that will be XOR'ed to the existing value at the specified address
1024 |
1025 | Usage:
1026 | XOR16 90A64C 4
1027 |
1028 | Set Addr 90A64C
1029 | Set Val 4
1030 | XOR16 Addr Val
1031 |
1032 | Set address FB1580
1033 | XOR16 address + 0x60 0x80
1034 |
1035 | ///////////////////////////////////////////////////////////////////////
1036 |
1037 | If (ADDRESS) (CONDITION)(DATATYPE) (VALUE) [&& (ADDRESS) (CONDITION)(DATATYPE) (VALUE)]
1038 | EndIf|EI
1039 | Compares the value at address (ADDRESS) with (VALUE), by using the condition (CONDITION).
1040 | Always specify whether to check for 1 byte or 2 bytes with (DATATYPE).
1041 | Always have an EndIf command to indicate the termination of the If scope.
1042 | It is possible to have multiple conditions in a single If command through the use of the logical AND operator ("&&").
1043 | NOTE: One E-type code (or D-type code) has a maximum of 0xFF lines that they can execute.
1044 | If more than 0xFF produced lines are present in an If scope, the If command(s) will be repeated as many times as needed.
1045 |
1046 | Arguments:
1047 | (ADDRESS) The address which contains the first operand
1048 | (CONDITION) The comparison condition
1049 | = equality
1050 | ! inequality
1051 | < less than
1052 | > greater than
1053 | ~& NAND
1054 | & AND
1055 | ~| NOR
1056 | | OR
1057 | (DATATYPE) The datatype to be used for the comparison
1058 | . 8-bit (1 byte)
1059 | : 16-bit (2 bytes)
1060 | (VALUE) The value to be compared against (second operand)
1061 | [&&] Logical AND
1062 |
1063 | Usage:
1064 | If 004AF8A4 =. 0xFF // If 0x4AF8A4's value equals to 0xFF (only check 1 byte)
1065 | Write32 01F2E740 1
1066 | EndIf
1067 |
1068 | Set MapID 004AF8A4
1069 | If MapID =: 6 // If 0x4AF8A4's value equals to 6 (check 2 bytes)
1070 | Write32 01F2E740 1
1071 | EndIf
1072 |
1073 | Set MapID 0x004AF8A4
1074 | Set ParisID 3
1075 | If MapID !: ParisID // If 0x4AF8A4's value is NOT equal to 3 (check 2 bytes)
1076 | Write32 01F2E740 1
1077 | EndIf
1078 |
1079 | If 004AF8A4 <: 6
1080 | Write32 01F2E740 1 // If 0x4AF8A4's value is less than 6 (check 2 bytes)
1081 | EndIf
1082 |
1083 | If 004AF8A4 >: 0x12
1084 | Write32 01F2E740 1 // If 0x4AF8A4's value is greater than 0x12 (check 2 bytes)
1085 | EndIf
1086 |
1087 | If 3E1110 =: 3 && 2DEB44 !. 0xFF // If 0x3E1110's value is equal to 3 (check 2 bytes) and if 0x2DEB44's value is not equal to 0xFF (check 1 byte)
1088 | Write32 443740 1
1089 | EndIf
1090 | // Equivalent to:
1091 | If 3E1110 =: 3 // If 0x3E1110's value is equal to 3 (check 2 bytes)
1092 | If 2DEB44 !. 0xFF // If 0x2DEB44's value is not equal to 0xFF (check 1 byte)
1093 | Write32 443740 1
1094 | EndIf
1095 | EndIf
1096 |
1097 | // All the possible conditions: equality, inequality, less than, greater than, NAND, AND, NOR, OR
1098 | If 1 =. 2 && 3 !. 4 && 5 <. 6 && 7 >. 8 && 9 ~&. 10 && 11 &. 12 && 13 ~|. 14 && 15 |. 16
1099 | Write32 DEADBEEF 0x12345678
1100 | EndIf
1101 |
1102 | // Check if a specific bit in a byte is set, and if so, set that bit to 0
1103 | // 0b00000001 = 0x1
1104 | // 0b00000010 = 0x2
1105 | // 0b00000100 = 0x4
1106 | // 0b00001000 = 0x8
1107 | // 0b00010000 = 0x10
1108 | // 0b00100000 = 0x20
1109 | // 0b01000000 = 0x40
1110 | // 0b10000000 = 0x80
1111 | Set Gadget1 003D4AFC
1112 | If Gadget1 &. 0x80 // If (*Gadget1 & 0x80 == 0x80) (check the last bit)
1113 | XOR8 Gadget1 0x80 // Flip bit to 0
1114 | EndIf
1115 |
1116 | Set myVar 100
1117 | If FB1580 + 0x10 =: myVar + 1
1118 | Write32 FB1580 0
1119 | EndIf
1120 |
1121 | ///////////////////////////////////////////////////////////////////////
1122 |
1123 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1124 | (3) Example code (CLPS2C)
1125 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1126 |
1127 | Below is a CLPS2C example code with its output.
1128 |
1129 | // Declaration of variables which will be used later
1130 | Set MapID 0x3E1110
1131 | Set JobID 0x67381C
1132 | Set Player 0x2E1E40
1133 | Set CharHP 3D4AB0
1134 | Set CharHPMax 40
1135 | Set CoinCount 3D4B00
1136 | Set MyStr "Parkour_Start\0"
1137 |
1138 | // Function to teleport the player to a location
1139 | Function WriteXYZ(base, valueX, valueY, valueZ)
1140 | WritePointerFloat base,58,30 valueX
1141 | WritePointerFloat base,58,34 valueY
1142 | WritePointerFloat base,58,38 valueZ
1143 | EndFunction
1144 |
1145 | // Main code
1146 | If MapID =: 3 // If in world 3
1147 | Write32 FB1580 0x123
1148 | If JobID !. 0xFF && CoinCount =: 0 // If not in a job and the player has 0 coins
1149 | Call WriteXYZ(Player, 1500, 2000, 600) // Warp player on top of the house
1150 | EndIf
1151 | Write32 CharHP CharHPMax // Write 40 to the player's hp
1152 | WriteString 0x87310 MyStr
1153 | EndIf
1154 |
1155 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1156 | (3B) Output:
1157 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1158 |
1159 | E0110003 003E1110
1160 | 20FB1580 00000123
1161 | E10A00FF 1067381C
1162 | E0090000 003D4B00
1163 | 602E1E40 44BB8000
1164 | 00020002 00000058
1165 | 00000030 00000000
1166 | 602E1E40 44FA0000
1167 | 00020002 00000058
1168 | 00000034 00000000
1169 | 602E1E40 44160000
1170 | 00020002 00000058
1171 | 00000038 00000000
1172 | 203D4AB0 00000028
1173 | 20087310 6B726150
1174 | 20087314 5F72756F
1175 | 20087318 72617453
1176 | 1008731C 00000074
1177 |
1178 | With the argument "-p" (Pnach-formatted) enabled:
1179 | patch=1,EE,E0110003,extended,003E1110
1180 | patch=1,EE,20FB1580,extended,00000123
1181 | patch=1,EE,E10A00FF,extended,1067381C
1182 | patch=1,EE,E0090000,extended,003D4B00
1183 | patch=1,EE,602E1E40,extended,44BB8000
1184 | patch=1,EE,00020002,extended,00000058
1185 | patch=1,EE,00000030,extended,00000000
1186 | patch=1,EE,602E1E40,extended,44FA0000
1187 | patch=1,EE,00020002,extended,00000058
1188 | patch=1,EE,00000034,extended,00000000
1189 | patch=1,EE,602E1E40,extended,44160000
1190 | patch=1,EE,00020002,extended,00000058
1191 | patch=1,EE,00000038,extended,00000000
1192 | patch=1,EE,203D4AB0,extended,00000028
1193 | patch=1,EE,20087310,extended,6B726150
1194 | patch=1,EE,20087314,extended,5F72756F
1195 | patch=1,EE,20087318,extended,72617453
1196 | patch=1,EE,1008731C,extended,00000074
1197 |
1198 | With the argument "-d" (D-type code) enabled:
1199 | D03E1110 11000003
1200 | 20FB1580 00000123
1201 | D067381C 0A1100FF
1202 | D03D4B00 09000000
1203 | 602E1E40 44BB8000
1204 | 00020002 00000058
1205 | 00000030 00000000
1206 | 602E1E40 44FA0000
1207 | 00020002 00000058
1208 | 00000034 00000000
1209 | 602E1E40 44160000
1210 | 00020002 00000058
1211 | 00000038 00000000
1212 | 203D4AB0 00000028
1213 | 20087310 6B726150
1214 | 20087314 5F72756F
1215 | 20087318 72617453
1216 | 1008731C 00000074
1217 |
1218 | With the arguments "-p -d" (Pnach-formatted and D-type code) enabled:
1219 | patch=1,EE,D03E1110,extended,11000003
1220 | patch=1,EE,20FB1580,extended,00000123
1221 | patch=1,EE,D067381C,extended,0A1100FF
1222 | patch=1,EE,D03D4B00,extended,09000000
1223 | patch=1,EE,602E1E40,extended,44BB8000
1224 | patch=1,EE,00020002,extended,00000058
1225 | patch=1,EE,00000030,extended,00000000
1226 | patch=1,EE,602E1E40,extended,44FA0000
1227 | patch=1,EE,00020002,extended,00000058
1228 | patch=1,EE,00000034,extended,00000000
1229 | patch=1,EE,602E1E40,extended,44160000
1230 | patch=1,EE,00020002,extended,00000058
1231 | patch=1,EE,00000038,extended,00000000
1232 | patch=1,EE,203D4AB0,extended,00000028
1233 | patch=1,EE,20087310,extended,6B726150
1234 | patch=1,EE,20087314,extended,5F72756F
1235 | patch=1,EE,20087318,extended,72617453
1236 | patch=1,EE,1008731C,extended,00000074
1237 |
1238 | ///////////////////////////////////////////////////////////////////////
1239 |
1240 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1241 | (4) Example code (CLPS2C - Assembly)
1242 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1243 |
1244 | Below is a CLPS2C example code that uses assembly with its output.
1245 |
1246 | // Write the active character's XYZ coordinates (accessed by a pointer)
1247 | // to a specific address (003D0E10/4/8)
1248 | // If the value at 003D0D00 is 1, then get the values from 003D0E10/4/8
1249 | // and write them to the active character's coordinates
1250 | // - 002DE2F0,0x58,0x30/4/8 active character's coords
1251 | // - 003D1000 address to store our assembly code (codecave)
1252 | // - 003D0E10/4/8 address to store a copy of the coords
1253 | // - 003D0D00 custom flag. If it's 1, get the values from 003D0E00/4/8 and write them to the active character's coords
1254 | Set Cave 003D1000
1255 | ASM_START Cave
1256 | // Go to the active character's transformation component
1257 | lw $t1,0x2DE2F0 // read active character pointer
1258 | addi $t2,$t1,0x58 // add transformation offset
1259 | lw $t2,($t2) // read the transformation pointer
1260 | // Our target address (where we want to store the coords) is at 003D0E10
1261 | lui $at,0x3D // All of our custom addresses are at 003Dnnnn. Load 003D0000
1262 | lw $t3,0x30($t2) // get x coord
1263 | lw $t4,0x34($t2) // get y coord
1264 | lw $t5,0x38($t2) // get z coord
1265 | sw $t3,0xE10($at) // store x coord at custom address
1266 | sw $t4,0xE14($at) // store y coord at custom address
1267 | sw $t5,0xE18($at) // store z coord at custom address
1268 | // Check flag
1269 | lw $t0,0xD00($at)
1270 | li $t1,0x1
1271 | beq $t0,$t1,SetCustomCoords // if the value at 003D0D00 == 1, then branch to SetCustomCoords
1272 | nop // delay slot. Before taking the branch, the cpu will execute this line. Let's place a nop so it doesn't do anything.
1273 | b Exit // else, branch to Exit
1274 | nop // delay slot
1275 | SetCustomCoords: sw $zero,0xD00($at) // set flag to 0
1276 | lw $t3,0xE00($at) // load custom x coord
1277 | lw $t4,0xE04($at) // load custom y coord
1278 | lw $t5,0xE08($at) // load custom z coord
1279 | sw $t3,0x30($t2) // store x coord
1280 | sw $t4,0x34($t2) // store y coord
1281 | sw $t5,0x38($t2) // store z coord
1282 | Exit: jr $ra // return
1283 | nop // delay slot
1284 | ASM_END
1285 |
1286 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1287 | (4B) Output:
1288 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1289 |
1290 | 203D1000 3C09002E
1291 | 203D1004 8D29E2F0
1292 | 203D1008 212A0058
1293 | 203D100C 8D4A0000
1294 | 203D1010 3C01003D
1295 | 203D1014 8D4B0030
1296 | 203D1018 8D4C0034
1297 | 203D101C 8D4D0038
1298 | 203D1020 AC2B0E10
1299 | 203D1024 AC2C0E14
1300 | 203D1028 AC2D0E18
1301 | 203D102C 8C280D00
1302 | 203D1030 24090001
1303 | 203D1034 11090003
1304 | 203D1038 00000000
1305 | 203D103C 10000008
1306 | 203D1040 00000000
1307 | 203D1044 AC200D00
1308 | 203D1048 8C2B0E00
1309 | 203D104C 8C2C0E04
1310 | 203D1050 8C2D0E08
1311 | 203D1054 AD4B0030
1312 | 203D1058 AD4C0034
1313 | 203D105C AD4D0038
1314 | 203D1060 03E00008
1315 | 203D1064 00000000
1316 |
1317 | With the argument "-p" (Pnach-formatted) enabled:
1318 | patch=1,EE,203D1000,extended,3C09002E
1319 | patch=1,EE,203D1004,extended,8D29E2F0
1320 | patch=1,EE,203D1008,extended,212A0058
1321 | patch=1,EE,203D100C,extended,8D4A0000
1322 | patch=1,EE,203D1010,extended,3C01003D
1323 | patch=1,EE,203D1014,extended,8D4B0030
1324 | patch=1,EE,203D1018,extended,8D4C0034
1325 | patch=1,EE,203D101C,extended,8D4D0038
1326 | patch=1,EE,203D1020,extended,AC2B0E10
1327 | patch=1,EE,203D1024,extended,AC2C0E14
1328 | patch=1,EE,203D1028,extended,AC2D0E18
1329 | patch=1,EE,203D102C,extended,8C280D00
1330 | patch=1,EE,203D1030,extended,24090001
1331 | patch=1,EE,203D1034,extended,11090003
1332 | patch=1,EE,203D1038,extended,00000000
1333 | patch=1,EE,203D103C,extended,10000008
1334 | patch=1,EE,203D1040,extended,00000000
1335 | patch=1,EE,203D1044,extended,AC200D00
1336 | patch=1,EE,203D1048,extended,8C2B0E00
1337 | patch=1,EE,203D104C,extended,8C2C0E04
1338 | patch=1,EE,203D1050,extended,8C2D0E08
1339 | patch=1,EE,203D1054,extended,AD4B0030
1340 | patch=1,EE,203D1058,extended,AD4C0034
1341 | patch=1,EE,203D105C,extended,AD4D0038
1342 | patch=1,EE,203D1060,extended,03E00008
1343 | patch=1,EE,203D1064,extended,00000000
1344 |
1345 | ///////////////////////////////////////////////////////////////////////
1346 |
1347 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1348 | (5) Credits
1349 | _/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\_
1350 |
1351 | Author:
1352 | - NiV-L-A
1353 |
1354 | Special thanks:
1355 | - Sly Cooper Modding Discord Server: https://discord.gg/2GSXcEzPJA
1356 | - Luigi Auriemma's QuickBMS: http://aluigi.altervista.org/quickbms.htm
1357 | - Icon made by Cooper941: https://www.youtube.com/@Cooper941
1358 | - TheOnlyZac for suggesting how to handle certain scenarios: https://github.com/TheOnlyZac
1359 | - Testing done by zzamizz: https://github.com/zzamizz
1360 | - MIPS assembler engine from Keystone-engine: https://github.com/NiV-L-A/keystone
1361 | - commandline by commandlineparser: https://github.com/commandlineparser/commandline
1362 |
1363 | Useful links:
1364 | - https://slymods.info/wiki/Guide:Writing_pnach_files
1365 | - https://github.com/mlafeldt/ps2rd/blob/master/Documentation/code_types.txt
1366 | - https://github.com/zzamizz/weed-sheet/wiki/PNACH-Code-Types
1367 | - https://github.com/root670/CheatDevicePS2/wiki/Code-Types
1368 | - https://github.com/PCSX2/pcsx2/blob/master/pcsx2/Patch.cpp
1369 | - https://github.com/root670/CheatDevicePS2/blob/master/engine/engine_asm.S
1370 | - https://math-atlas.sourceforge.net/devel/assembly/mips-iv.pdf
1371 | - https://psi-rockin.github.io/ps2tek/
1372 |
1373 | ///////////////////////////////////////////////////////////////////////
--------------------------------------------------------------------------------
/Example/CLPS2C-ExampleCode.txt:
--------------------------------------------------------------------------------
1 | // Declaration of variables which will be used later
2 | Set MapID 0x3E1110
3 | Set JobID 0x67381C
4 | Set Player 0x2E1E40
5 | Set CharHP 3D4AB0
6 | Set CharHPMax 40
7 | Set CoinCount 3D4B00
8 | Set MyStr "Parkour_Start\0"
9 |
10 | // Function to teleport the player to a location
11 | Function WriteXYZ(base, valueX, valueY, valueZ)
12 | WritePointerFloat base,58,30 valueX
13 | WritePointerFloat base,58,34 valueY
14 | WritePointerFloat base,58,38 valueZ
15 | EndFunction
16 |
17 | // Main code
18 | If MapID =: 3 // If in world 3
19 | Write32 FB1580 0x123
20 | If JobID !. 0xFF && CoinCount =: 0 // If not in a job and the player has 0 coins
21 | Call WriteXYZ(Player, 1500, 2000, 600) // Warp player on top of the house
22 | EndIf
23 | Write32 CharHP CharHPMax // Set the player's hp to 40
24 | WriteString 0x87310 MyStr
25 | EndIf
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/All.txt:
--------------------------------------------------------------------------------
1 | Include "Engine.txt"
2 | Include "Entity.txt"
3 | Include "Gui.txt"
4 | Include "Player.txt"
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/Engine.txt:
--------------------------------------------------------------------------------
1 | Set MapID 0x3E1110
2 | Set JobID 0x2DEB44
3 | Set Reload 0x3E1080
4 | Set ResetCamera 0x2DE240
5 | Set EngineUpTime 0x2DDF0C
6 | Set LevelUpTime 0x2DDED0
7 | Set DrawDistance 0x2DDF5C
8 | Set GuardAiFlag 0x3E1214
9 | Set EpisodesUnlocked 0x5975E8
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/Entity.txt:
--------------------------------------------------------------------------------
1 | // Global (g_) pointers (p) to entity structs
2 | // Gang
3 | Set g_pactchar 0x2DE2F0 // active character
4 | Set g_pjt 0x2E1E40 // Sly
5 | Set g_pbentley 0x2DD5BC // Bentley
6 | Set g_pmurray 0x2F7900 // Murray
7 |
8 | // Other characters
9 | Set g_pcarmelita 0x3E07BC // Carmelita
10 | Set g_pneyla 0x3E0798 // Neyla
11 | Set g_pdimitri 0x3E078C // Dimitri
12 | Set g_pcontessa 0x3E07C8 // Contessa
13 | Set g_pjeanbison 0x3E07B0 // Jean Bison
14 | Set g_parpeggio 0x3E07D4 // Arpeggio
15 |
16 | // Function to teleport the player to a location
17 | Function WriteXYZ(base, valueX, valueY, valueZ)
18 | WritePointerFloat base,58,30 valueX
19 | WritePointerFloat base,58,34 valueY
20 | WritePointerFloat base,58,38 valueZ
21 | EndFunction
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/Gui.txt:
--------------------------------------------------------------------------------
1 | // Global (g_) pointers (p) to gui structs
2 | Set g_pganghpgui 0x3D9EB8
3 | Set g_pcoingui 0x3E103C
4 | Set g_pbottlegui 0x3E1048
5 | Set g_pdiscejectgui 0x3DA514
6 | Set g_pblackbargui 0x2E1E60
7 | Set g_pinfoboxgui 0x3DA0E8
8 | Set g_pmasktransitiongui 0x443794
9 | Set g_pjobfailgui 0x3E0ABC
10 | Set g_pthiefnetgui 0x3DA174
11 |
12 | // Struct's fields
13 | Set GuiElementIDOff 0x14
14 | Set GuiNextGuiOff 0x20
15 | Set GuiPrevGuiOff 0x28
16 | Set GuiActiveFlagOff 0x64
17 | Set GuiActiveTimerOff 0x88
18 | Set GuiHPosOff 0x9C
19 | Set GuiVPosOff 0xA0
20 | Set GuiLayerOff 0xA4
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/Player.txt:
--------------------------------------------------------------------------------
1 | // Gang's hp
2 | Set g_cjthp 0x3D4AB0
3 | Set g_cbentleyhp 0x3D4AC8
4 | Set g_cmurrayhp 0x3D4AE0
5 |
6 | // Misc global variables
7 | Set g_cactcharid 0x3D4A6C
8 | Set g_ccoin 0x3D4B00
9 | Set g_gadget1 0x3D4AF8
10 | Set g_gadget2 0x3D4AFC
--------------------------------------------------------------------------------
/Example/IncludeExample/Sly2/NTSC/README.md:
--------------------------------------------------------------------------------
1 | Check the command "Include (VALUE)" in the "List of commands" section in the [CLPS2C Documentation](/CLPS2C-Documentation.txt) file for more information.
2 | All addresses listed in these example files are from the Sly Cooper Memory Addresses sheet:
3 | https://docs.google.com/spreadsheets/d/1ISxw587iICRDdaLJfLaTvJUaYkjGBReH4NY-yKN-Ip0
4 |
5 | "Engine.txt", "Entity.txt", "Gui.txt" and "Player.txt" are example files to test the "Include" command.
6 | To include these files, write the following commands:
7 | ```
8 | Include "IncludeExample/Sly2/NTSC/Engine.txt"
9 | Include "IncludeExample/Sly2/NTSC/Entity.txt"
10 | Include "IncludeExample/Sly2/NTSC/Gui.txt"
11 | Include "IncludeExample/Sly2/NTSC/Player.txt"
12 | ```
13 | or, you can include the "All.txt" file like this:
14 | ```
15 | Include "IncludeExample/Sly2/NTSC/All.txt"
16 | ```
17 | which will include the 4 .txt files above.
18 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CLPS2C (Custom Language for PlayStation 2 Cheats) - Compiler
2 |
3 |
4 |
5 |
6 | ## Description
7 | CLPS2C is a domain-specific language, built specifically for writing PS2 cheat codes.
8 | Please, refer to the [CLPS2C Documentation](/CLPS2C-Documentation.txt) file for more information.
9 | Please, refer to the [CLPS2C Changelog](/CLPS2C-Changelog.txt) file for information about changes for each version.
10 |
11 | ## Goal and intention
12 | The main goal of the project is to have better managment and readability when cheats become too big/complex.
13 | The app supports, among other things:
14 | - Write all code types supported by ps2rd and Cheat Device
15 | - Output RAW or pnach-formatted cheat lines
16 | - Write MIPS Assembly
17 | - Automatic calculation for how many lines to execute in "If" commands
18 | - Support for logical AND in "If" commands
19 | - Set local variables to be referenced by name
20 | - Define functions with arguments and call them
21 | - Include CLPS2C files in other CLPS2C files
22 |
23 | ## Example code
24 | ```
25 | // Variables which will be used later
26 | Set MapID 0x3E1110
27 | Set JobID 0x67381C
28 | Set Player 0x2E1E40
29 | Set CharHP 3D4AB0
30 | Set CharHPMax 40
31 | Set CoinCount 3D4B00
32 | Set MyStr "Parkour_Start\0"
33 |
34 | // Function to teleport the player to a location
35 | Function WriteXYZ(base, valueX, valueY, valueZ)
36 | WritePointerFloat base,58,30 valueX
37 | WritePointerFloat base,58,34 valueY
38 | WritePointerFloat base,58,38 valueZ
39 | EndFunction
40 |
41 | // Main code
42 | If MapID =: 3 // If in world 3
43 | Write32 20FB1580 0x123
44 | If JobID !. 0xFF && CoinCount =: 0 // If not in a job and the player has 0 coins
45 | Call WriteXYZ(Player, 1500, 2000, 600) // Warp player on top of the house
46 | EndIf
47 | Write32 CharHP CharHPMax // Set the player's hp to 40
48 | WriteString 0x87310 MyStr
49 | EndIf
50 | ```
51 | Output:
52 | ```
53 | E0110003 003E1110
54 | 20FB1580 00000123
55 | E10A00FF 1067381C
56 | E0090000 003D4B00
57 | 602E1E40 44BB8000
58 | 00020002 00000058
59 | 00000030 00000000
60 | 602E1E40 44FA0000
61 | 00020002 00000058
62 | 00000034 00000000
63 | 602E1E40 44160000
64 | 00020002 00000058
65 | 00000038 00000000
66 | 203D4AB0 00000028
67 | 20087310 6B726150
68 | 20087314 5F72756F
69 | 20087318 72617453
70 | 1008731C 00000074
71 | ```
72 |
73 | ## How to run / Troubleshooting
74 | **IMPORTANT:** .NET Desktop Runtime 8.0 must be installed in order to run this program.
75 | https://dotnet.microsoft.com/en-us/download/dotnet/8.0
76 |
77 | Usage:
78 | ```
79 | CLPS2C-Compiler.exe
80 | -i, --input The file to be parsed. Example: -i "C:\Users\admin\Desktop\CLPS2C\Test1.txt"
81 | -o, --output The file in which the output will be written to. Example: -o "C:\Users\admin\Desktop\pcsx2\cheats\SCUS-97316_07652DD9testmod.pnach"
82 | If not passed, the output file path will be defaulted to the input's folder, with the same file name as the input file, and appending "-Output" to it.
83 | (e.g. "C:\Users\admin\Desktop\CLPS2C\Test1-Output.txt")
84 | -p, --pnach The app, by default, produces RAW lines. Enabling this option will convert them to Pnach-formatted lines.
85 | -d, --dtype The app, by default, converts "If" commands to E-type codes. Enabling this option will convert them to D-type codes.
86 | --help Display an help screen.
87 | --version Display version information.
88 | ```
89 |
90 | It is recommended to use [vscode-clps2c](https://github.com/NiV-L-A/vscode-clps2c), a Visual Studio Code extension for .clps2c files.
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | ## TO-DO
99 | - WritePointerString, WritePointerBytes and FillBytes commands.
100 | - If commands with logical OR (||) operator.
101 | - The (VALUE) for the SendRaw and WriteString commands will always be printed as decimal if it's a variable. Add ":X8" or some way to force it hexadecimal.
102 |
103 | ## Build instructions
104 | CLPS2C-Compiler uses a [modified version of keystone](https://github.com/NiV-L-A/keystone) to parse the MIPS assembly instructions.
105 | The modification is a removal of an automatic addition of a "nop" instruction after any branch and jump instructions that act as a delay slot (see [issue #405](https://github.com/keystone-engine/keystone/issues/405) ), among other fixes for the PS2 Emotion Engine CPU.
106 | 1. Clone the CLPS2C-Compiler repository by clicking on the "Code" button and selecting "Open with Visual Studio".
107 | 2. Download "keystone.dll" and "Keystone.Net.dll" from the ["Releases" page of this fork of keystone](https://github.com/NiV-L-A/keystone/releases).
108 | 3. Place the 2 .dll files in the CLPS2C-Compiler/CLPS2C-Compiler folder (where the .csproj file is). They should appear in the Solution Explorer window in Visual Studio.
109 | 4. Visual Studio should recognize the files and the project should accept the "Keystone" namespace.
110 | - If keystone-related errors are still present in the project:
111 | 5. In the Solution Explorer window, expand the project entry, right click on "Dependencies" and select "Add Project Reference...".
112 | 6. In the window that pops up, click on "Browse" on the left side and then click on "Browse..." at the bottom right.
113 | 7. Add the "Keystone.Net.dll" file and make sure its checkbox is checked. Click "OK".
114 |
115 | ## Credits
116 | Author:
117 | - NiV-L-A
118 |
119 | Special thanks:
120 | - Sly Cooper Modding Discord Server: https://discord.gg/2GSXcEzPJA
121 | - Luigi Auriemma's QuickBMS: http://aluigi.altervista.org/quickbms.htm
122 | - Icon made by Cooper941: https://www.youtube.com/@Cooper941
123 | - TheOnlyZac for suggesting how to handle certain scenarios: https://github.com/TheOnlyZac
124 | - Testing done by zzamizz: https://github.com/zzamizz
125 | - MIPS assembler engine from Keystone-engine: https://github.com/NiV-L-A/keystone
126 | - commandline by commandlineparser: https://github.com/commandlineparser/commandline
--------------------------------------------------------------------------------