├── .classpath
├── .gitattributes
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── Module.manifest
├── README.md
├── build.gradle
├── data
└── README.txt
├── extension.properties
├── ghidra_scripts
└── README.txt
├── lib
└── README.txt
├── os
├── linux64
│ └── README.txt
├── osx64
│ └── README.txt
└── win64
│ └── README.txt
└── src
├── main
├── help
│ └── help
│ │ ├── TOC_Source.xml
│ │ ├── shared
│ │ └── Frontpage.css
│ │ └── topics
│ │ └── c64loaderwv
│ │ └── help.html
├── java
│ └── c64loaderwv
│ │ ├── BasicLine.java
│ │ ├── C64LoaderWVLoader.java
│ │ └── D64Image.java
└── resources
│ └── images
│ └── README.txt
└── test
└── java
└── README.test.txt
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | C64LoaderWV
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
19 | Ghidra
20 | 2
21 | C:/Users/wv/Desktop/ghidra
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java/c64loaderwv/BasicLine.java=UTF-8
3 | encoding/=UTF-8
4 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
3 | org.eclipse.jdt.core.compiler.compliance=11
4 | org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
5 | org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
6 | org.eclipse.jdt.core.compiler.problem.deprecation=warning
7 | org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
8 | org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
9 | org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
10 | org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
11 | org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
12 | org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
13 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
14 | org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
15 | org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
16 | org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
17 | org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
18 | org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
19 | org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
20 | org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
21 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
22 | org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
23 | org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
24 | org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
25 | org.eclipse.jdt.core.compiler.problem.nullReference=warning
26 | org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
27 | org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
28 | org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
29 | org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
30 | org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
31 | org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
32 | org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
33 | org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
34 | org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
35 | org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
36 | org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
37 | org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
38 | org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
39 | org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
40 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
41 | org.eclipse.jdt.core.compiler.problem.unusedImport=warning
42 | org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
43 | org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
44 | org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
45 | org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
46 | org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
47 | org.eclipse.jdt.core.compiler.source=11
48 |
--------------------------------------------------------------------------------
/Module.manifest:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zeroKilo/C64LoaderWV/564320fdad3d4aacfb81b60c5ea43535be224a1b/Module.manifest
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # C64 ROM Loader for Ghidra by Warranty Voider
2 |
3 | this is a loader module for ghidra for C64 disks (.d64)
4 |
5 | [](https://www.youtube.com/watch?v=thl6VciaUzg)
6 |
7 |
8 | ## Build problem with gradle wrapper
9 |
10 | EDIT:2025.04.05
11 |
12 | it seems you have to update
13 |
14 | ```(Ghidra Install Dir)\Ghidra\application.properties```
15 |
16 | and upgrade the gradle version like this
17 |
18 | ```application.gradle.min=8.10```
19 |
20 | if you have problems with building from source in eclipse with the gradle wrapper.
21 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Builds a Ghidra Extension for a given Ghidra installation.
2 | //
3 | // An absolute path to the Ghidra installation directory must be supplied either by setting the
4 | // GHIDRA_INSTALL_DIR environment variable or Gradle project property:
5 | //
6 | // > export GHIDRA_INSTALL_DIR=
7 | // > gradle
8 | //
9 | // or
10 | //
11 | // > gradle -PGHIDRA_INSTALL_DIR=
12 | //
13 | // Gradle should be invoked from the directory of the project to build. Please see the
14 | // application.gradle.version property in /Ghidra/application.properties
15 | // for the correction version of Gradle to use for the Ghidra installation you specify.
16 |
17 | //----------------------START "DO NOT MODIFY" SECTION------------------------------
18 | def ghidraInstallDir
19 |
20 | if (System.env.GHIDRA_INSTALL_DIR) {
21 | ghidraInstallDir = System.env.GHIDRA_INSTALL_DIR
22 | }
23 | else if (project.hasProperty("GHIDRA_INSTALL_DIR")) {
24 | ghidraInstallDir = project.getProperty("GHIDRA_INSTALL_DIR")
25 | }
26 |
27 | if (ghidraInstallDir) {
28 | apply from: new File(ghidraInstallDir).getCanonicalPath() + "/support/buildExtension.gradle"
29 | }
30 | else {
31 | throw new GradleException("GHIDRA_INSTALL_DIR is not defined!")
32 | }
33 | //----------------------END "DO NOT MODIFY" SECTION-------------------------------
34 |
--------------------------------------------------------------------------------
/data/README.txt:
--------------------------------------------------------------------------------
1 | The "data" directory is intended to hold data files that will be used by this module and will
2 | not end up in the .jar file, but will be present in the zip or tar file. Typically, data
3 | files are placed here rather than in the resources directory if the user may need to edit them.
4 |
5 | An optional data/languages directory can exist for the purpose of containing various Sleigh language
6 | specification files and importer opinion files.
7 |
8 | The data/buildLanguage.xml is used for building the contents of the data/languages directory.
9 |
10 | The skel language definition has been commented-out within the skel.ldefs file so that the
11 | skeleton language does not show-up within Ghidra.
12 |
13 | See the Sleigh language documentation (docs/languages/index.html) for details Sleigh language
14 | specification syntax.
15 |
--------------------------------------------------------------------------------
/extension.properties:
--------------------------------------------------------------------------------
1 | name=@extname@
2 | description=The extension description can be customized by editing the extension.properties file.
3 | author=
4 | createdOn=
5 | version=@extversion@
6 |
--------------------------------------------------------------------------------
/ghidra_scripts/README.txt:
--------------------------------------------------------------------------------
1 | Java source directory to hold module-specific Ghidra scripts.
2 |
--------------------------------------------------------------------------------
/lib/README.txt:
--------------------------------------------------------------------------------
1 | The "lib" directory is intended to hold Jar files which this module
2 | is dependent upon. This directory may be eliminated from a specific
3 | module if no other Jar files are needed.
4 |
--------------------------------------------------------------------------------
/os/linux64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/linux64" directory is intended to hold Linux native binaries
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/os/osx64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/osx64" directory is intended to hold macOS (OS X) native binaries
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/os/win64/README.txt:
--------------------------------------------------------------------------------
1 | The "os/win64" directory is intended to hold MS Windows native binaries (.exe)
2 | which this module is dependent upon. This directory may be eliminated for a specific
3 | module if native binaries are not provided for the corresponding platform.
4 |
--------------------------------------------------------------------------------
/src/main/help/help/TOC_Source.xml:
--------------------------------------------------------------------------------
1 |
2 |
49 |
50 |
51 |
52 |
57 |
58 |
--------------------------------------------------------------------------------
/src/main/help/help/shared/Frontpage.css:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | WARNING!
18 | This file is copied to all help directories. If you change this file, you must copy it
19 | to each src/main/help/help/shared directory.
20 |
21 |
22 | Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but
23 | px (pixel) or with no type marking.
24 |
25 | */
26 |
27 | body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 10px; } /* some padding to improve readability */
28 | li { font-family:times new roman; font-size:14pt; }
29 | h1 { color:#000080; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; }
30 | h2 { margin: 10px; margin-top: 20px; color:#984c4c; font-family:times new roman; font-size:18pt; font-weight:bold; }
31 | h3 { margin-left: 10px; margin-top: 20px; color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; }
32 | h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; }
33 |
34 | /*
35 | P tag code. Most of the help files nest P tags inside of blockquote tags (the was the
36 | way it had been done in the beginning). The net effect is that the text is indented. In
37 | modern HTML we would use CSS to do this. We need to support the Ghidra P tags, nested in
38 | blockquote tags, as well as naked P tags. The following two lines accomplish this. Note
39 | that the 'blockquote p' definition will inherit from the first 'p' definition.
40 | */
41 | p { margin-left: 40px; font-family:times new roman; font-size:14pt; }
42 | blockquote p { margin-left: 10px; }
43 |
44 | p.providedbyplugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
45 | p.ProvidedByPlugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px }
46 | p.relatedtopic { color:#800080; margin-left: 10px; font-size:14pt; }
47 | p.RelatedTopic { color:#800080; margin-left: 10px; font-size:14pt; }
48 |
49 | /*
50 | We wish for a tables to have space between it and the preceding element, so that text
51 | is not too close to the top of the table. Also, nest the table a bit so that it is clear
52 | the table relates to the preceding text.
53 | */
54 | table { margin-left: 20px; margin-top: 10px; width: 80%;}
55 | td { font-family:times new roman; font-size:14pt; vertical-align: top; }
56 | th { font-family:times new roman; font-size:14pt; font-weight:bold; background-color: #EDF3FE; }
57 |
58 | code { color: black; font-family: courier new; font-size: 14pt; }
59 |
--------------------------------------------------------------------------------
/src/main/help/help/topics/c64loaderwv/help.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
12 | Skeleton Help File for a Module
13 |
14 |
15 |
16 |
17 |
Skeleton Help File for a Module
18 |
19 |
This is a simple skeleton help topic. For a better description of what should and should not
20 | go in here, see the "sample" Ghidra extension in the Extensions/Ghidra directory, or see your
21 | favorite help topic. In general, language modules do not have their own help topics.
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/java/c64loaderwv/BasicLine.java:
--------------------------------------------------------------------------------
1 | package c64loaderwv;
2 |
3 | import ghidra.app.util.bin.BinaryReader;
4 | import ghidra.app.util.bin.StructConverter;
5 | import ghidra.program.model.data.Structure;
6 | import ghidra.program.model.data.StructureDataType;
7 |
8 | public class BasicLine {
9 | static class TokenType
10 | {
11 | int id;
12 | String desc;
13 | TokenType(int i, String d)
14 | {
15 | id = i;
16 | desc = d;
17 | }
18 | }
19 | private static TokenType[] tokenList = {
20 | new TokenType( 0x80, "END" ),
21 | new TokenType( 0x81, "FOR" ),
22 | new TokenType( 0x82, "NEXT" ),
23 | new TokenType( 0x83, "DATA" ),
24 | new TokenType( 0x84, "INPUT#" ),
25 | new TokenType( 0x85, "INPUT" ),
26 | new TokenType( 0x86, "DIM" ),
27 | new TokenType( 0x87, "READ" ),
28 | new TokenType( 0x88, "LET" ),
29 | new TokenType( 0x89, "GOTO" ),
30 | new TokenType( 0x8A, "RUN" ),
31 | new TokenType( 0x8B, "IF" ),
32 | new TokenType( 0x8C, "RESTORE"),
33 | new TokenType( 0x8D, "GOSUB" ),
34 | new TokenType( 0x8E, "RETURN" ),
35 | new TokenType( 0x8F, "REM" ),
36 | new TokenType( 0x90, "STOP" ),
37 | new TokenType( 0x91, "ON" ),
38 | new TokenType( 0x92, "WAIT" ),
39 | new TokenType( 0x93, "LOAD" ),
40 | new TokenType( 0x94, "SAVE" ),
41 | new TokenType( 0x95, "VERIFY" ),
42 | new TokenType( 0x96, "DEF" ),
43 | new TokenType( 0x97, "POKE" ),
44 | new TokenType( 0x98, "PRINT#" ),
45 | new TokenType( 0x99, "PRINT" ),
46 | new TokenType( 0x9A, "CONT" ),
47 | new TokenType( 0x9B, "LIST" ),
48 | new TokenType( 0x9C, "CLR" ),
49 | new TokenType( 0x9D, "CMD" ),
50 | new TokenType( 0x9E, "SYS" ),
51 | new TokenType( 0x9F, "OPEN" ),
52 | new TokenType( 0xA0, "CLOSE" ),
53 | new TokenType( 0xA1, "GET" ),
54 | new TokenType( 0xA2, "NEW" ),
55 | new TokenType( 0xA3, "TAB(" ),
56 | new TokenType( 0xA4, "TO" ),
57 | new TokenType( 0xA5, "FN" ),
58 | new TokenType( 0xA6, "SPC(" ),
59 | new TokenType( 0xA7, "THEN" ),
60 | new TokenType( 0xA8, "NOT" ),
61 | new TokenType( 0xA9, "STEP" ),
62 | new TokenType( 0xAA, "+" ),
63 | new TokenType( 0xAB, "−" ),
64 | new TokenType( 0xAC, "*" ),
65 | new TokenType( 0xAD, "/" ),
66 | new TokenType( 0xAE, "^" ),
67 | new TokenType( 0xAF, "AND" ),
68 | new TokenType( 0xB0, "OR" ),
69 | new TokenType( 0xB1, ">" ),
70 | new TokenType( 0xB2, "=" ),
71 | new TokenType( 0xB3, "<" ),
72 | new TokenType( 0xB4, "SGN" ),
73 | new TokenType( 0xB5, "INT" ),
74 | new TokenType( 0xB6, "ABS" ),
75 | new TokenType( 0xB7, "USR" ),
76 | new TokenType( 0xB8, "FRE" ),
77 | new TokenType( 0xB9, "POS" ),
78 | new TokenType( 0xBA, "SQR" ),
79 | new TokenType( 0xBB, "RND" ),
80 | new TokenType( 0xBC, "LOG" ),
81 | new TokenType( 0xBD, "EXP" ),
82 | new TokenType( 0xBE, "COS" ),
83 | new TokenType( 0xBF, "SIN" ),
84 | new TokenType( 0xC0, "TAN" ),
85 | new TokenType( 0xC1, "ATN" ),
86 | new TokenType( 0xC2, "PEEK" ),
87 | new TokenType( 0xC3, "LEN" ),
88 | new TokenType( 0xC4, "STR$" ),
89 | new TokenType( 0xC5, "VAL" ),
90 | new TokenType( 0xC6, "ASC" ),
91 | new TokenType( 0xC7, "CHR$" ),
92 | new TokenType( 0xC8, "LEFT$" ),
93 | new TokenType( 0xC9, "RIGHT$" ),
94 | new TokenType( 0xCA, "MID$" ),
95 | new TokenType( 0xCB, "GO" ),
96 | };
97 | public int linePos;
98 | public int nextLine;
99 | public int lineNumber;
100 | public int tokenSize;
101 | public String text;
102 | public BasicLine(BinaryReader br, int pos, int loadAddress) throws Exception
103 | {
104 | linePos = pos;
105 | int tpos = pos - loadAddress;
106 | nextLine = br.readShort(tpos) & 0xFFFF;
107 | lineNumber = br.readShort(tpos + 2) & 0xFFFF;
108 | text = "";
109 | ReadLine(br, tpos + 4);
110 | }
111 |
112 | private void ReadLine(BinaryReader br, int pos) throws Exception
113 | {
114 | tokenSize = 0;
115 | while(true)
116 | {
117 | byte b = br.readByte(pos++);
118 | tokenSize++;
119 | if(b > 0)
120 | text += (char)b;
121 | else if(b < 0)
122 | text += DecodeToken(b);
123 | else
124 | break;
125 | }
126 | text = text.trim();
127 | }
128 |
129 | private String DecodeToken(byte b)
130 | {
131 | String result = "[UNKNOWN TOKEN]";
132 | for(TokenType t : tokenList)
133 | if(t.id == (b & 0xFF))
134 | {
135 | result = " " + t.desc + " ";
136 | break;
137 | }
138 | return result;
139 | }
140 |
141 | public Structure getDataStructure()
142 | {
143 | Structure header_struct = new StructureDataType("L" + lineNumber, 0);
144 | header_struct.add(StructConverter.WORD, 0x02, "Next Line Address", null);
145 | header_struct.add(StructConverter.WORD, 0x02, "Line Number", null);
146 | header_struct.add(StructConverter.STRING, tokenSize, text, null);
147 | return header_struct;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/src/main/java/c64loaderwv/C64LoaderWVLoader.java:
--------------------------------------------------------------------------------
1 | /* ###
2 | * IP: GHIDRA
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package c64loaderwv;
17 |
18 | import java.io.ByteArrayOutputStream;
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 | import java.util.*;
22 |
23 | import org.python.jline.internal.Log;
24 |
25 | import c64loaderwv.D64Image.D64Entry;
26 | import ghidra.app.util.MemoryBlockUtils;
27 | import ghidra.app.util.Option;
28 | import ghidra.app.util.bin.BinaryReader;
29 | import ghidra.app.util.bin.ByteArrayProvider;
30 | import ghidra.app.util.bin.ByteProvider;
31 | import ghidra.app.util.importer.MessageLog;
32 | import ghidra.app.util.opinion.AbstractLibrarySupportLoader;
33 | import ghidra.app.util.opinion.LoadSpec;
34 | import ghidra.framework.model.DomainObject;
35 | import ghidra.program.model.address.Address;
36 | import ghidra.program.model.address.AddressOverflowException;
37 | import ghidra.program.model.data.DataUtilities;
38 | import ghidra.program.model.data.DataUtilities.ClearDataMode;
39 | import ghidra.program.model.lang.LanguageCompilerSpecPair;
40 | import ghidra.program.model.listing.Program;
41 | import ghidra.program.model.mem.MemoryBlock;
42 | import ghidra.util.Msg;
43 | import ghidra.util.exception.CancelledException;
44 | import ghidra.util.task.TaskMonitor;
45 |
46 | public class C64LoaderWVLoader extends AbstractLibrarySupportLoader {
47 |
48 | public D64Image image;
49 | public int loadAddress = 0;
50 | private MemoryBlock block;
51 | @Override
52 | public String getName() {
53 | return "C64 Loader by Warranty Voider";
54 | }
55 |
56 | @Override
57 | public Collection findSupportedLoadSpecs(ByteProvider provider) throws IOException {
58 | List loadSpecs = new ArrayList<>();
59 | BinaryReader br = new BinaryReader(provider, false);
60 | if(br.length() == 0x2AB00)
61 | {
62 | try
63 | {
64 | image = new D64Image(br);
65 | loadSpecs.add(new LoadSpec(this, 0, new LanguageCompilerSpecPair("6502:LE:16:default", "default"), true));
66 | }
67 | catch(Exception ex) {
68 | Log.error(ex.getMessage());
69 | }
70 | }
71 | return loadSpecs;
72 | }
73 |
74 | @Override
75 | protected void load(ByteProvider provider, LoadSpec loadSpec, List