├── Module.manifest ├── ghidra_scripts └── README.txt ├── example_signatures.txt ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── src ├── main │ ├── resources │ │ ├── pifdata.bin │ │ └── images │ │ │ └── README.txt │ ├── java │ │ └── n64loaderwv │ │ │ ├── SigPattern.java │ │ │ ├── N64Header.java │ │ │ └── N64LoaderWVLoader.java │ └── help │ │ └── help │ │ ├── topics │ │ └── n64loaderwv │ │ │ └── help.html │ │ ├── TOC_Source.xml │ │ └── shared │ │ └── Frontpage.css └── test │ └── java │ └── README.test.txt ├── extension.properties ├── .antProperties.xml ├── os ├── linux64 │ └── README.txt ├── osx64 │ └── README.txt └── win64 │ └── README.txt ├── data ├── sleighArgs.txt ├── languages │ ├── skel.opinion │ ├── skel.ldefs │ ├── skel.pspec │ ├── skel.slaspec │ ├── skel.cspec │ └── skel.sinc ├── README.txt └── build.xml ├── .project ├── README.md ├── example_n64sym.txt └── .classpath /Module.manifest: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ghidra_scripts/README.txt: -------------------------------------------------------------------------------- 1 | Java source directory to hold module-specific Ghidra scripts. 2 | -------------------------------------------------------------------------------- /example_signatures.txt: -------------------------------------------------------------------------------- 1 | osContInt 27BDFF803C0E????8DCE????AFBF0024AFA40080AFA50084AFA6008811c00003 -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /src/main/resources/pifdata.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeroKilo/N64LoaderWV/HEAD/src/main/resources/pifdata.bin -------------------------------------------------------------------------------- /src/main/resources/images/README.txt: -------------------------------------------------------------------------------- 1 | The "src/resources/images" directory is intended to hold all image/icon files used by 2 | this module. 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/test/java/README.test.txt: -------------------------------------------------------------------------------- 1 | The "test" directory is intended to hold unit test cases. The package structure within 2 | this folder should correspond to that found in the "src" folder. 3 | -------------------------------------------------------------------------------- /.antProperties.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /data/sleighArgs.txt: -------------------------------------------------------------------------------- 1 | # Add sleigh compiler options to this file (one per line) which will 2 | # be used when compiling each language within this module. 3 | # All options should start with a '-' character. 4 | # 5 | # IMPORTANT: The -a option should NOT be specified 6 | # -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | N64LoaderWV 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 | -------------------------------------------------------------------------------- /data/languages/skel.opinion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /data/languages/skel.ldefs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/n64loaderwv/SigPattern.java: -------------------------------------------------------------------------------- 1 | package n64loaderwv; 2 | 3 | public class SigPattern { 4 | 5 | public String name; 6 | public int[] pattern; 7 | public SigPattern(String n, String p) { 8 | name = n; 9 | pattern = new int[p.length() / 2]; 10 | for(int i = 0; i < p.length() / 2; i ++) 11 | { 12 | int pos = i * 2; 13 | String sub = p.substring(pos, pos + 2); 14 | if(sub.equals("??")) 15 | pattern[i] = -1; 16 | else 17 | pattern[i] = Integer.parseInt(sub, 16); 18 | } 19 | } 20 | 21 | public Boolean Match(byte[] buff, int index) 22 | { 23 | for(int i = 0; i < pattern.length; i++) 24 | { 25 | if(pattern[i] != -1 && (byte)pattern[i] != buff[i + index]) 26 | return false; 27 | } 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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/build.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/sleigh.htm or sleigh.pdf) for details 14 | on Sleigh language specification syntax. 15 | 16 | -------------------------------------------------------------------------------- /data/languages/skel.pspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/help/help/topics/n64loaderwv/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 | -------------------------------------------------------------------------------- /data/languages/skel.slaspec: -------------------------------------------------------------------------------- 1 | # sleigh specification file for Skeleton Processor 2 | # >> see docs/languages/sleigh.htm or sleigh.pdf for Sleigh syntax 3 | # Other language modules (see Ghidra/Processors) may provide better examples 4 | # when creating a new language module. 5 | 6 | define endian=little; 7 | define alignment=1; 8 | 9 | define space ram type=ram_space size=2 default; 10 | 11 | define space io type=ram_space size=2; 12 | define space register type=register_space size=1; 13 | 14 | define register offset=0x00 size=1 [ F A C B E D L H I R ]; 15 | define register offset=0x00 size=2 [ AF BC DE HL ]; 16 | define register offset=0x20 size=1 [ A_ F_ B_ C_ D_ E_ H_ L_ ]; # Alternate registers 17 | define register offset=0x20 size=2 [ AF_ BC_ DE_ HL_ ]; # Alternate registers 18 | 19 | define register offset=0x40 size=2 [ _ PC SP IX IY ]; 20 | 21 | define register offset=0x50 size=1 [ rCBAR rCBR rBBR ]; 22 | 23 | # Define context bits (if defined, size must be multiple of 4-bytes) 24 | define register offset=0xf0 size=4 contextreg; 25 | 26 | define context contextreg 27 | assume8bitIOSpace = (0,0) 28 | ; 29 | 30 | # Flag bits (?? manual is very confusing - could be typos!) 31 | @define C_flag "F[0,1]" # C: Carry 32 | @define N_flag "F[1,1]" # N: Add/Subtract 33 | @define PV_flag "F[2,1]" # PV: Parity/Overflow 34 | @define H_flag "F[4,1]" # H: Half Carry 35 | @define Z_flag "F[6,1]" # Z: Zero 36 | @define S_flag "F[7,1]" # S: Sign 37 | 38 | # Include contents of skel.sinc file 39 | @include "skel.sinc" 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # N64 ROM Loader for Ghidra by Warranty Voider 2 | 3 | this is a loader module for ghidra for N64 roms (.z64, .n64, .v64) 4 | - fixes endianess (little, big, mixed) at loading 5 | - loads ram, rom and boot section into ghidra 6 | - it can use a signature/pattern file to scan for symbol hints for ghidra 7 | 8 | this allows a rom to be labeled, disassembled and decompiled 9 | 10 | credits: 11 | - [blackgamma7](https://github.com/blackgamma7) for fixing memory layout stuff, adding register symbols and various small changes [see merge commit](https://github.com/zeroKilo/N64LoaderWV/commit/46137048775a41f4b54c08cf3c3fab1bcb962219) 12 | - [dmattia](https://github.com/dmattia) for adding build instructions for mac 13 | 14 | requires JDK 17 15 | 16 | [![Alt text](https://img.youtube.com/vi/3d3a39LuCwc/0.jpg)](https://www.youtube.com/watch?v=3d3a39LuCwc) 17 | 18 | [![Alt text](https://img.youtube.com/vi/fhI3Vpw7FVk/0.jpg)](https://www.youtube.com/watch?v=fhI3Vpw7FVk) 19 | 20 | ## Build from Source (Mac) 21 | 22 | ```bash 23 | brew install java 24 | brew install gradle 25 | brew cask install ghidra 26 | 27 | export GHIDRA_INSTALL_DIR=`brew cask ls ghidra | grep ghidra | sed 's/^.*-> \(.*\)ghidraRun.*/\1/'` 28 | ``` 29 | 30 | Then whenever you're ready to build, run 31 | 32 | ```bash 33 | gradle 34 | ``` 35 | 36 | and it will create a zip file in `/dist` that you can use that file as the extension in Ghidra 37 | 38 | ## Build problem with gradle wrapper 39 | 40 | EDIT:2025.04.05 41 | 42 | it seems you have to update 43 | 44 | ```(Ghidra Install Dir)\Ghidra\application.properties``` 45 | 46 | and upgrade the gradle version like this 47 | 48 | ```application.gradle.min=8.10``` 49 | 50 | if you have problems with building from source in eclipse with the gradle wrapper. 51 | -------------------------------------------------------------------------------- /data/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/n64loaderwv/N64Header.java: -------------------------------------------------------------------------------- 1 | package n64loaderwv; 2 | 3 | import java.io.IOException; 4 | import java.util.zip.CRC32; 5 | 6 | import ghidra.app.util.bin.BinaryReader; 7 | import ghidra.app.util.bin.ByteArrayProvider; 8 | import ghidra.app.util.bin.StructConverter; 9 | import ghidra.program.model.data.Structure; 10 | import ghidra.program.model.data.StructureDataType; 11 | import ghidra.util.Msg; 12 | 13 | public class N64Header { 14 | public byte[] raw; 15 | public int magic; 16 | public long loadAddress; 17 | public String title; 18 | public String gameCode; 19 | public byte maskRomVersion; 20 | 21 | public N64Header(byte[] data) { 22 | raw = data; 23 | BinaryReader b = new BinaryReader(new ByteArrayProvider(data), false); 24 | try { 25 | magic = b.readInt(0); 26 | loadAddress = b.readInt(8) & 0xFFFFFFFFL; 27 | title = b.readAsciiString(0x20, 0x14); 28 | gameCode = b.readAsciiString(0x3c, 0x2); 29 | maskRomVersion = b.readByte(0x3F); 30 | byte[] bootLoader = b.readByteArray(0x40, 0xFC0); 31 | CRC32 crc32 = new CRC32(); 32 | crc32.update(bootLoader); 33 | long value = crc32.getValue(); 34 | if(value == 0x0B050EE0L) //"ntsc-name": "6103", "pal-name": "7103" 35 | loadAddress -= 0x100000; 36 | if(value == 0xACC8580AL) //"ntsc-name": "6106", "pal-name": "7106" 37 | loadAddress -= 0x200000; 38 | } catch (IOException e) { 39 | Msg.error(this, e); 40 | } 41 | } 42 | 43 | public static Structure getDataStructure() 44 | { 45 | Structure header_struct = new StructureDataType("Internal_Header", 0); 46 | header_struct.add(StructConverter.DWORD, 0x04, "Magic", null); 47 | header_struct.add(StructConverter.DWORD, 0x04, "Clock Rate", null); 48 | header_struct.add(StructConverter.DWORD, 0x04, "Load Address", null); 49 | header_struct.add(StructConverter.DWORD, 0x04, "Release Offset", null); 50 | header_struct.add(StructConverter.DWORD, 0x04, "CRC1", null); 51 | header_struct.add(StructConverter.DWORD, 0x04, "CRC2", null); 52 | header_struct.add(StructConverter.DWORD, 0x04, "Unknown 5", null); 53 | header_struct.add(StructConverter.DWORD, 0x04, "Unknown 6", null); 54 | header_struct.add(StructConverter.STRING, 0x14, "Game Title", null); 55 | header_struct.add(StructConverter.DWORD, 0x04, "Zeroed", null); 56 | header_struct.add(StructConverter.WORD, 0x02, "Zeroed", null); 57 | header_struct.add(StructConverter.BYTE, 0x01, "Zeroed", null); 58 | header_struct.add(StructConverter.BYTE, 0x01, "Media Type", null); 59 | header_struct.add(StructConverter.STRING, 0x02, "Game Code", null); 60 | header_struct.add(StructConverter.BYTE, 0x01, "Region", null); 61 | header_struct.add(StructConverter.BYTE, 0x01, "Mask ROM Version", null); 62 | return header_struct; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /data/languages/skel.cspec: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /data/languages/skel.sinc: -------------------------------------------------------------------------------- 1 | # sleigh include file for Skeleton language instructions 2 | 3 | define token opbyte (8) 4 | op0_8 = (0,7) 5 | op6_2 = (6,7) 6 | 7 | dRegPair4_2 = (4,5) 8 | pRegPair4_2 = (4,5) 9 | sRegPair4_2 = (4,5) 10 | qRegPair4_2 = (4,5) 11 | qRegPair4_2a = (4,5) 12 | qRegPair4_2b = (4,5) 13 | rRegPair4_2 = (4,5) 14 | 15 | reg3_3 = (3,5) 16 | bits3_3 = (3,5) 17 | 18 | bits0_4 = (0,3) 19 | 20 | reg0_3 = (0,2) 21 | bits0_3 = (0,2) 22 | ; 23 | 24 | define token data8 (8) 25 | imm8 = (0,7) 26 | sign8 = (7,7) 27 | simm8 = (0,7) signed 28 | ; 29 | 30 | define token data16 (16) 31 | timm4 = (12,15) 32 | imm16 = (0,15) 33 | sign16 = (15,15) 34 | simm16 = (0,15) signed 35 | ; 36 | 37 | attach variables [ reg0_3 reg3_3 ] [ B C D E H L _ A ]; 38 | 39 | attach variables [ sRegPair4_2 dRegPair4_2 ] [ BC DE HL SP ]; 40 | 41 | attach variables [ qRegPair4_2 ] [ BC DE HL AF ]; 42 | attach variables [ qRegPair4_2a ] [ B D H A ]; 43 | attach variables [ qRegPair4_2b ] [ C E L F ]; 44 | 45 | attach variables [ pRegPair4_2 ] [ BC DE IX SP ]; 46 | attach variables [ rRegPair4_2 ] [ BC DE IY SP ]; 47 | 48 | ################################################################ 49 | # Macros 50 | ################################################################ 51 | 52 | macro setResultFlags(result) { 53 | $(Z_flag) = (result == 0); 54 | $(S_flag) = (result s< 0); 55 | } 56 | 57 | macro setAddCarryFlags(op1,op2) { 58 | $(C_flag) = (carry(op1,zext($(C_flag))) || carry(op2,op1 + zext($(C_flag)))); 59 | } 60 | 61 | macro setAddFlags(op1,op2) { 62 | $(C_flag) = carry(op1,op2); 63 | } 64 | 65 | macro setSubtractCarryFlags(op1,op2) { 66 | notC = ~$(C_flag); 67 | $(C_flag) = ((op1 < sext(notC)) || (op2 < (op1 - sext(notC)))); 68 | } 69 | 70 | macro setSubtractFlags(op1,op2) { 71 | $(C_flag) = (op1 < op2); 72 | } 73 | 74 | macro push16(val16) { 75 | SP = SP - 2; 76 | *:2 SP = val16; 77 | } 78 | 79 | macro pop16(ret16) { 80 | ret16 = *:2 SP; 81 | SP = SP + 2; 82 | } 83 | 84 | macro push8(val8) { 85 | SP = SP - 1; 86 | ptr:2 = SP; 87 | *:1 ptr = val8; 88 | } 89 | 90 | macro pop8(ret8) { 91 | ptr:2 = SP; 92 | ret8 = *:1 ptr; 93 | SP = SP + 1; 94 | } 95 | 96 | ################################################################ 97 | 98 | ixMem8: (IX+simm8) is IX & simm8 { ptr:2 = IX + simm8; export *:1 ptr; } 99 | ixMem8: (IX-val) is IX & simm8 & sign8=1 [ val = -simm8; ] { ptr:2 = IX + simm8; export *:1 ptr; } 100 | 101 | iyMem8: (IY+simm8) is IY & simm8 { ptr:2 = IY + simm8; export *:1 ptr; } 102 | iyMem8: (IY-val) is IY & simm8 & sign8=1 [ val = -simm8; ] { ptr:2 = IY + simm8; export *:1 ptr; } 103 | 104 | Addr16: imm16 is imm16 { export *:1 imm16; } 105 | 106 | Mem16: (imm16) is imm16 { export *:2 imm16; } 107 | 108 | RelAddr8: loc is simm8 [ loc = inst_next + simm8; ] { export *:1 loc; } 109 | 110 | cc: "NZ" is bits3_3=0x0 { c:1 = ($(Z_flag) == 0); export c; } 111 | cc: "Z" is bits3_3=0x1 { c:1 = $(Z_flag); export c; } 112 | cc: "NC" is bits3_3=0x2 { c:1 = ($(C_flag) == 0); export c; } 113 | cc: "C" is bits3_3=0x3 { c:1 = $(C_flag); export c; } 114 | cc: "PO" is bits3_3=0x4 { c:1 = ($(PV_flag) == 0); export c; } 115 | cc: "PE" is bits3_3=0x5 { c:1 = $(PV_flag); export c; } 116 | cc: "P" is bits3_3=0x6 { c:1 = ($(S_flag) == 0); export c; } 117 | cc: "M" is bits3_3=0x7 { c:1 = $(S_flag); export c; } 118 | 119 | cc2: "NZ" is bits3_3=0x4 { c:1 = ($(Z_flag) == 0); export c; } 120 | cc2: "Z" is bits3_3=0x5 { c:1 = $(Z_flag); export c; } 121 | cc2: "NC" is bits3_3=0x6 { c:1 = ($(C_flag) == 0); export c; } 122 | cc2: "C" is bits3_3=0x7 { c:1 = $(C_flag); export c; } 123 | 124 | ################################################################ 125 | 126 | 127 | :LD IX,Mem16 is op0_8=0xdd & IX; op0_8=0x2a; Mem16 { 128 | IX = Mem16; 129 | } 130 | 131 | :LD IY,Mem16 is op0_8=0xfd & IY; op0_8=0x2a; Mem16 { 132 | IY = Mem16; 133 | } 134 | 135 | :LD Mem16,HL is op0_8=0x22 & HL; Mem16 { 136 | Mem16 = HL; 137 | } 138 | 139 | :LD Mem16,dRegPair4_2 is op0_8=0xed; op6_2=0x1 & dRegPair4_2 & bits0_4=0x3; Mem16 { 140 | Mem16 = dRegPair4_2; 141 | } 142 | 143 | :LD Mem16,IX is op0_8=0xdd & IX; op0_8=0x22; Mem16 { 144 | Mem16 = IX; 145 | } 146 | 147 | :LD Mem16,IY is op0_8=0xfd & IY; op0_8=0x22; Mem16 { 148 | Mem16 = IY; 149 | } 150 | 151 | :NEG is op0_8=0xed; op0_8=0x44 { 152 | $(PV_flag) = (A == 0x80); 153 | $(C_flag) = (A != 0); 154 | A = -A; 155 | setResultFlags(A); 156 | } 157 | 158 | :SET bits3_3,ixMem8 is op0_8=0xdd; op0_8=0xcb; ixMem8; op6_2=0x3 & bits3_3 & bits0_3=0x6 { 159 | mask:1 = (1 << bits3_3); 160 | val:1 = ixMem8; 161 | ixMem8 = val | mask; 162 | } 163 | 164 | :SET bits3_3,iyMem8 is op0_8=0xfd; op0_8=0xcb; iyMem8; op6_2=0x3 & bits3_3 & bits0_3=0x6 { 165 | mask:1 = (1 << bits3_3); 166 | val:1 = iyMem8; 167 | iyMem8 = val | mask; 168 | } 169 | 170 | :JP Addr16 is op0_8=0xc3; Addr16 { 171 | goto Addr16; 172 | } 173 | 174 | :JP cc,Addr16 is op6_2=0x3 & cc & bits0_3=0x2; Addr16 { 175 | if (!cc) goto Addr16; 176 | } 177 | 178 | :JR RelAddr8 is op0_8=0x18; RelAddr8 { 179 | goto RelAddr8; 180 | } 181 | 182 | :JR cc2,RelAddr8 is op6_2=0x0 & cc2 & bits0_3=0x0; RelAddr8 { 183 | if (cc2) goto RelAddr8; 184 | } 185 | 186 | :JP (HL) is op0_8=0xe9 & HL { 187 | goto [HL]; 188 | } 189 | 190 | :JP (IX) is op0_8=0xdd & IX; op0_8=0xe9 { 191 | goto [IX]; 192 | } 193 | 194 | :JP (IY) is op0_8=0xfd & IY; op0_8=0xe9 { 195 | goto [IY]; 196 | } 197 | 198 | :CALL Addr16 is op0_8=0xcd; Addr16 { 199 | push16(&:2 inst_next); 200 | call Addr16; 201 | } 202 | 203 | :CALL cc,Addr16 is op6_2=0x3 & cc & bits0_3=0x4; Addr16 { 204 | if (!cc) goto inst_next; 205 | push16(&:2 inst_next); 206 | call Addr16; 207 | } 208 | 209 | :RET is op0_8=0xc9 { 210 | pop16(PC); 211 | ptr:2 = zext(PC); 212 | return [ptr]; 213 | } 214 | 215 | :RET cc is op6_2=0x3 & cc & bits0_3=0x0 { 216 | if (!cc) goto inst_next; 217 | pop16(PC); 218 | ptr:2 = zext(PC); 219 | return [ptr]; 220 | } 221 | -------------------------------------------------------------------------------- /example_n64sym.txt: -------------------------------------------------------------------------------- 1 | 70002ACC rmonmisc_text_010C 2 | 70003698 __osSpSetPc 3 | 700081AC n_alLoadParam 4 | 7006A1EC guRotateRPYF 5 | 7006BAC4 __osPiRelAccess 6 | 7006BBE8 __osGIORawInterrupt 7 | 7006BF18 n_alSynRemovePlayer 8 | 7006D340 __osPiGetAccess 9 | 7007A390 sqrtf 10 | 7007A3A0 cosf 11 | 7007A4E8 cosf_text_0148 12 | 7007AC00 guMtxF2L 13 | 7007AC98 guMtxL2F 14 | 7007AD40 guMtxIdentF 15 | 7007AE80 guMtxCatF 16 | 7007AF5C guMtxXFMF 17 | 7007B280 perspective_text_0170 18 | 7007B438 perspective_text_0328 19 | 7007BB70 sinf 20 | 7007BC48 sinf_text_00D8 21 | 7007BD08 sinf_text_0198 22 | 7007C1A0 osGetCount 23 | 7007C1B0 osInvalDCache 24 | 7007C2C0 osSetIntMask 25 | 7007C3B0 osWritebackDCache 26 | 7007C430 osWritebackDCacheAll 27 | 7007C460 osCreateMesgQueue 28 | 7007C490 osCreateThread 29 | 7007C5A8 destroythread_text_0048 30 | 7007C5F8 destroythread_text_0098 31 | 7007C630 osGetTime 32 | 7007C8BC initialize_text_01FC 33 | 7007C8D0 osRecvMesg 34 | 7007C9D4 recvmesg_text_0104 35 | 7007CA00 osSendMesg 36 | 7007CB0C sendmesg_text_010C 37 | 7007CB30 osSetEventMesg 38 | 7007CB90 osStartThread 39 | 7007CC34 startthread_text_00A4 40 | 7007CC88 startthread_text_00F8 41 | 7007CD48 stopthread_text_0098 42 | 7007CD70 __osDequeueThread 43 | 7007CD9C thread_text_002C 44 | 7007CDB0 __osTimerServicesInit 45 | 7007CE04 __osTimerInterrupt 46 | 7007CE24 timerintr_text_0074 47 | 7007CF30 timerintr_text_0180 48 | 7007CF40 __osSetTimerIntr 49 | 7007CFA0 __osInsertTimer 50 | 7007D008 timerintr_text_0300 51 | 7007D0B0 osVirtualToPhysical 52 | 7007D0F8 virtualtophysical_text_0048 53 | 7007D110 osYieldThread 54 | 7007D1B0 init_lpfilter 55 | 7007D254 alFxNew 56 | 7007D32C drvrnew_text_017C 57 | 7007D58C drvrnew_text_03DC 58 | 7007D6A4 drvrnew_text_04F4 59 | 7007D6EC alEnvmixerNew 60 | 7007D7A4 alLoadNew 61 | 7007D854 alResampleNew 62 | 7007D8E0 alAuxBusNew 63 | 7007D93C alMainBusNew 64 | 7007D998 alSaveNew 65 | 7007DAAC load_text_00CC 66 | 7007DB14 load_text_0134 67 | 7007DD50 load_text_0370 68 | 7007DD9C load_text_03BC 69 | 7007DDC0 load_text_03E0 70 | 7007DDF4 load_text_0414 71 | 7007DEF4 load_text_0514 72 | 7007DFB4 load_text_05D4 73 | 7007E128 load_text_0748 74 | 7007E198 load_text_07B8 75 | 7007E1C0 alLoadParam 76 | 7007E358 load_text_0978 77 | 7007E360 load_text_0980 78 | 7007E36C load_text_098C 79 | 7007E420 load_text_0A40 80 | 7007E5CC alAuxBusParam 81 | 7007E7F4 env_text_01F4 82 | 7007E90C env_text_030C 83 | 7007EA3C env_text_043C 84 | 7007EAA8 env_text_04A8 85 | 7007EB4C alEnvmixerParam 86 | 7007EBF8 env_text_05AC 87 | 7007EC08 env_text_05BC 88 | 7007EC10 env_text_05C4 89 | 7007EC20 env_text_0620 90 | 7007EEC8 env_text_08C8 91 | 7007EEFC env_text_08FC 92 | 7007EFF8 env_text_0980 93 | 7007F024 env_text_0A24 94 | 7007F29C env_text_0C24 95 | 7007F2A4 env_text_0CA4 96 | 7007F320 env_text_0CA8 97 | 7007F330 alFilterNew 98 | 7007F490 alMainBusParam 99 | 7007F688 resample_text_01C8 100 | 7007F6AC alResampleParam 101 | 7007F754 resample_text_0294 102 | 7007F75C resample_text_029C 103 | 7007F90C reverb_text_019C 104 | 7007FB20 alFxParam 105 | 7007FD14 reverb_text_0568 106 | 7007FD24 reverb_text_05B4 107 | 7007FF08 reverb_text_075C 108 | 7007FF3C reverb_text_07CC 109 | 70080054 reverb_text_08A8 110 | 700800AC reverb_text_093C 111 | 700801E8 reverb_text_0A3C 112 | 7008021C reverb_text_0AAC 113 | 700802B8 reverb_text_0B0C 114 | 70080450 alSaveParam 115 | 70080470 save_text_00C8 116 | 700804DC alLink 117 | 700804FC alUnlink 118 | 70080550 heapinit_text_0020 119 | 70080570 alHeapDBAlloc 120 | 700805C0 alCopy 121 | 70080600 alSynNew 122 | 70080760 synthesizer_text_0160 123 | 70080A48 synthesizer_text_0448 124 | 70080A7C __allocParam 125 | 70080AA8 __freeParam 126 | 70080AC0 synthesizer_text_04C0 127 | 70080B14 _freePVoice 128 | 70080B54 synthesizer_text_0554 129 | 70080B9C _timeToSamples 130 | 70080BE8 synthesizer_text_05E8 131 | 70080C90 alSynDelete 132 | 70080DEC synallocvoice_text_00FC 133 | 70080E18 synallocvoice_text_0128 134 | 70080EB8 synallocvoice_text_01C8 135 | 70081260 alSynAllocFX 136 | 7008139C aisetfreq_text_008C 137 | 7008148C aisetnextbuf_text_004C 138 | 70081540 __osSpSetPc 139 | 70081568 spsetpc_text_0028 140 | 70081570 osSpTaskLoad 141 | 7008177C osSpTaskStartGo 142 | 700817B0 osSpTaskYield 143 | 700817D0 osSpTaskYielded 144 | 70081820 osViGetCurrentFramebuffer 145 | 70081860 osViGetNextFramebuffer 146 | 700818A0 osCreateViManager 147 | 70081A8C vimgr_text_01EC 148 | 70081BD0 osViSetEvent 149 | 70081C30 osViSetMode 150 | 70081DF0 osViSwapBuffer 151 | 70081E40 __osViSwapContext 152 | 70081EC4 viswapcontext_text_0084 153 | 70081F58 viswapcontext_text_0118 154 | 70081F8C viswapcontext_text_014C 155 | 70082130 osViBlack 156 | 70082174 viblack_text_0044 157 | 70082190 __osSiRawReadIo 158 | 70082220 __osSiRawWriteIo 159 | 70082454 contreaddata_text_0124 160 | 70082684 controller_text_0174 161 | 700826AC __osContGetInitData 162 | 70082760 controller_text_0250 163 | 70082820 osPfsChecker 164 | 70082980 pfschecker_text_0160 165 | 700829D0 pfschecker_text_01B0 166 | 70082C38 pfschecker_text_0418 167 | 70082C40 pfschecker_text_0420 168 | 70082C6C pfschecker_text_044C 169 | 70082DC4 pfschecker_text_05A4 170 | 700831AC pfsallocatefile_text_027C 171 | 70083290 pfsallocatefile_text_0360 172 | 700832C0 pfsallocatefile_text_0390 173 | 70083360 pfsallocatefile_text_0430 174 | 7008345C pfsallocatefile_text_052C 175 | 7008348C pfsallocatefile_text_055C 176 | 70083728 pfsdeletefile_text_0208 177 | 7008374C pfsdeletefile_text_022C 178 | 700837C0 pfsdeletefile_text_02A0 179 | 700838EC pfsdeletefile_text_03CC 180 | 7008399C pfsdeletefile_text_0474 181 | 70083D40 pfsreadwritefile_text_0380 182 | 70083DC8 pfsreadwritefile_text_0408 183 | 70083F74 pfsfilestate_text_0184 184 | 70084000 pfsfilestate_text_0210 185 | 70084030 osPfsFindFile 186 | 7008410C pfssearchfile_text_00DC 187 | 7008414C pfssearchfile_text_011C 188 | 70084190 pfssearchfile_text_0160 189 | 70084298 pfsisplug_text_00D8 190 | 7008433C pfsisplug_text_017C 191 | 700843E0 pfsisplug_text_0240 192 | 700844A0 osPfsFreeBlocks 193 | 7008458C pfsfreeblocks_text_00EC 194 | 70084690 pfsnumfiles_text_00E0 195 | 70084860 pfsinitpak_text_01B0 196 | 70084A20 pfsrepairid_text_01A0 197 | 70084A40 __osPfsGetStatus 198 | 70084B04 pfsgetstatus_text_00C4 199 | 70084B20 pfsgetstatus_text_00E0 200 | 70084BB0 pfsgetstatus_text_0170 201 | 70084D80 motor_text_0150 202 | 7008529C motor_text_066C 203 | 7008541C motor_text_07EC 204 | 7008545C motor_text_082C 205 | 70085480 osPiRawReadIo 206 | 700856B0 osEPiRawStartDma 207 | 700857E8 epirawdma_text_0138 208 | 70085854 epirawdma_text_01A4 209 | 70085860 epirawdma_text_01B0 210 | 700858B8 epidma_text_0038 211 | 70085904 epidma_text_0084 212 | 70085BF0 devmgr_text_0030 213 | 70085F18 devmgr_text_0358 214 | 70085F80 __osPiCreateAccessQueue 215 | 70086108 pidma_text_0098 216 | 70086120 bcopy 217 | 70086440 bzero 218 | 700864E0 strchr 219 | 70086510 string_text_0030 220 | 70086518 strlen 221 | 7008653C memcpy 222 | 7008683C sched_text_020C 223 | 700868A0 sched_text_0270 224 | 7008696C sched_text_033C 225 | 7008699C sched_text_036C 226 | 70086A30 sched_text_0400 227 | 70086A6C sched_text_043C 228 | 70086B24 sched_text_04F4 229 | 70086B7C sched_text_0564 230 | 70086C9C sched_text_0634 231 | 70086CB0 sched_text_0680 232 | 70086D60 sched_text_0714 233 | 70086DE4 sched_text_07B4 234 | 70086E0C sched_text_07DC 235 | 70086F40 sched_text_0848 236 | 70086F78 sched_text_0948 237 | 70087144 sched_text_0A4C 238 | 70087190 guNormalize 239 | 700878A4 __osEnqueueAndYield 240 | 700879AC __osEnqueueThread 241 | 700879F4 __osPopThread 242 | 70087A04 __osDispatchThread 243 | 70087B90 __osGetSR 244 | 70087BA0 osInvalICache 245 | 70087C20 __osDisableInt 246 | 70087C40 __osRestoreInt 247 | 70087C60 __osProbeTLB 248 | 70087D20 __osSetCompare 249 | 70087D30 __osSetFpcCsr 250 | 70087D40 __osSetSR 251 | 70087D50 osMapTLBRdb 252 | 70087DB0 osGetThreadPri 253 | 70087DD0 osJamMesg 254 | 70087EE0 jammesg_text_0110 255 | 70087F10 __osResetGlobalIntMask 256 | 70087F60 __osSetGlobalIntMask 257 | 70087FA0 osSetThreadPri 258 | 70088070 osSetTimer 259 | 70088110 __assert 260 | 70088120 __osAiDeviceBusy 261 | 70088140 osDpSetNextBuffer 262 | 700881E0 __osSpDeviceBusy 263 | 70088200 __osSpGetStatus 264 | 70088210 __osSpSetStatus 265 | 70088220 __osSpRawStartDma 266 | 700882F0 sprawdma_text_00D0 267 | 70088320 __osViInit 268 | 700883B4 vi_text_0094 269 | 70088430 __osViGetCurrentContext 270 | 70088440 __osSiDeviceBusy 271 | 70088460 __osSiRawStartDma 272 | 700884E0 sirawdma_text_0080 273 | 70088520 __osSiCreateAccessQueue 274 | 70088574 __osSiGetAccess 275 | 700885E0 __osSiRelAccess 276 | 70088610 __osContAddressCrc 277 | 70088658 __osContDataCrc 278 | 700886C0 __osContRamRead 279 | 70088818 contramread_text_0158 280 | 700888A8 contramread_text_01E8 281 | 700888AC contramread_text_01EC 282 | 700888F4 contramread_text_0234 283 | 70088A40 contramread_text_0380 284 | 70088A90 __osContRamWrite 285 | 70088C08 contramwrite_text_0178 286 | 70088CB0 contramwrite_text_0220 287 | 70088E08 contramwrite_text_0378 288 | 70088E50 __osSumcalc 289 | 70088E88 __osIdCheckSum 290 | 70088ECC contpfs_text_007C 291 | 70089184 contpfs_text_0334 292 | 700891AC contpfs_text_035C 293 | 700892EC contpfs_text_049C 294 | 70089310 __osGetId 295 | 700894DC contpfs_text_068C 296 | 700894F0 __osCheckId 297 | 700895A4 contpfs_text_0754 298 | 700895B4 __osPfsRWInode 299 | 70089700 contpfs_text_08B0 300 | 7008985C contpfs_text_0A0C 301 | 7008988C __osPfsSelectBank 302 | 7008998C pirawdma_text_00AC 303 | 70089998 pirawdma_text_00B8 304 | 700899B0 osPiGetCmdQueue 305 | 700899D0 osEPiRawReadIo 306 | 70089B18 epirawread_text_0148 307 | 70089B60 osEPiRawWriteIo 308 | 70089C74 epirawwrite_text_0114 309 | 7008A0A0 leointerrupt_text_03F0 310 | 7008A194 leointerrupt_text_04E4 311 | 7008A198 leointerrupt_text_04E8 312 | 7008A1A4 leointerrupt_text_04F4 313 | 7008A1BC leointerrupt_text_050C 314 | 7008A28C leointerrupt_text_05DC 315 | 7008A340 _Printf 316 | 7008A37C xprintf_text_003C 317 | 7008A38C xprintf_text_004C 318 | 7008A3E8 xprintf_text_00A8 319 | 7008A4C0 xprintf_text_0180 320 | 7008A568 xprintf_text_0228 321 | 7008A590 xprintf_text_0250 322 | 7008A8B0 xprintf_text_0570 323 | 7008A998 xprintf_text_0658 324 | 7008AA34 xprintf_text_06F4 325 | 7008AA98 xprintf_text_0758 326 | 7008AAC8 xprintf_text_0788 327 | 7008AB2C xprintf_text_07EC 328 | 7008ABD8 xprintf_text_0898 329 | 7008AD5C xprintf_text_0A1C 330 | 7008AD70 __osDpDeviceBusy 331 | 7008AD90 _Litob 332 | 7008AE04 xlitob_text_0074 333 | 7008AEB4 xlitob_text_0124 334 | 7008AFE0 _Ldtob 335 | 7008B054 xldtob_text_0074 336 | 7008B1B4 xldtob_text_01D4 337 | 7008B200 xldtob_text_0220 338 | 7008B294 xldtob_text_02B4 339 | 7008B324 xldtob_text_0344 340 | 7008B3D0 xldtob_text_03F0 341 | 7008B3F0 xldtob_text_0410 342 | 7008B420 xldtob_text_0440 343 | 7008B4B0 xldtob_text_04DC 344 | 7008B4B8 xldtob_text_04D8 345 | 7008B8E0 xldtob_text_0900 346 | 7008B9E8 xldtob_text_0A08 347 | 7008BA60 ldiv 348 | 7008BAE4 lldiv 349 | 7008D3E0 __divdi3 350 | 7008D550 __udivdi3 351 | 7008D570 __umoddi3 352 | 80000300 osTvType 353 | 80000308 osRomBase 354 | 8000030C osResetType 355 | 8000031C osAppNMIBuffer 356 | 80000450 aspMainTextStart 357 | 80001270 rspbootTextStart 358 | 80002ACC __rmonPanic 359 | 800031E0 n_alSeqpDelete 360 | 80008F38 __dummy 361 | 80009430 __osGetActiveQueue 362 | 8000D7C4 ptstart 363 | 80014A70 osAfterPreNMI 364 | 8001850C MusPtrBankGetCurrent 365 | 80023F7C myfree 366 | 80028B30 osViExtendVStart 367 | 8003B708 n_alResampleParam 368 | 8003B728 __udiv_w_sdiv 369 | 8003D2D8 osBbUsbDevGetHandle 370 | 80069360 osSetTime 371 | 8006A360 guRotateRPY 372 | 8006BA90 __osGIOInterrupt 373 | 8006D3DC __osSiGetAccess 374 | 8006D418 __osSiRelAccess 375 | 80075C8C Fstereo 376 | 80075CEC Fprint 377 | 80076E88 MusFxBankNumberOfEffects 378 | 80076EB4 MusFxBankSetPtrBank 379 | 80076EBC MusFxBankGetPtrBank 380 | 80076F14 osGetRegionBufSize 381 | 8007A390 _nsqrtf 382 | 8007A3A0 __cosf 383 | 8007A4F0 guLookAtF 384 | 8007A870 guLookAt 385 | 8007AC00 guMtxF2L 386 | 8007AC98 guMtxL2F 387 | 8007AD40 guMtxIdentF 388 | 8007AD90 guMtxIdent 389 | 8007AE80 guMtxCatF 390 | 8007AF5C guMtxXFMF 391 | 8007B010 guMtxCatL 392 | 8007B084 guMtxXFML 393 | 8007B110 guPerspectiveF 394 | 8007B2C0 guPerspective 395 | 8007B490 guRotateF 396 | 8007B5EC guRotate 397 | 8007B770 guRotateRPYF 398 | 8007B8F8 guRotateRPY 399 | 8007BA90 guScaleF 400 | 8007BAF0 guScale 401 | 8007BB70 __sinf 402 | 8007BD10 guTranslateF 403 | 8007BD64 guTranslate 404 | 8007BDE0 guPositionF 405 | 8007BFB8 guPosition 406 | 8007C1A0 osGetCount 407 | 8007C2C0 osSetIntMask 408 | 8007C360 osUnmapTLBAll 409 | 8007C430 osWritebackDCacheAll 410 | 8007C460 osCreateMesgQueue 411 | 8007C490 osCreateThread 412 | 8007C560 osDestroyThread 413 | 8007C630 osGetTime 414 | 8007C6C0 osInitialize 415 | 8007C8D0 osRecvMesg 416 | 8007CA00 osSendMesg 417 | 8007CB30 osSetEventMesg 418 | 8007CB90 osStartThread 419 | 8007CCB0 osStopThread 420 | 8007CD70 __osDequeueThread 421 | 8007CDB0 __osTimerServicesInit 422 | 8007CE04 __osTimerInterrupt 423 | 8007CF40 __osSetTimerIntr 424 | 8007CFA0 __osInsertTimer 425 | 8007D0B0 osVirtualToPhysical 426 | 8007D110 osYieldThread 427 | 8007D160 osGetMemSize 428 | 8007D1B0 init_lpfilter 429 | 8007D254 alFxNew 430 | 8007D6EC alEnvmixerNew 431 | 8007D7A4 alLoadNew 432 | 8007D854 alResampleNew 433 | 8007D8E0 alAuxBusNew 434 | 8007D93C alMainBusNew 435 | 8007D998 alSaveNew 436 | 8007D9E0 alAdpcmPull 437 | 8007DE24 load_text_0444 438 | 8007E1C0 alLoadParam 439 | 8007E36C _decodeChunk 440 | 8007E4F0 alAuxBusPull 441 | 8007E5CC alAuxBusParam 442 | 8007E600 alEnvmixerPull 443 | 8007EB4C alEnvmixerParam 444 | 8007EC20 _pullSubFrame 445 | 8007EF20 _frexpf 446 | 8007F000 _ldexpf 447 | 8007F024 _getRate 448 | 8007F2A4 _getVol 449 | 8007F330 alFilterNew 450 | 8007F350 alMainBusPull 451 | 8007F490 alMainBusParam 452 | 8007F4C0 alResamplePull 453 | 8007F6AC alResampleParam 454 | 8007F770 alFxPull 455 | 8007FB20 alFxParam 456 | 8007FB34 alFxParamHdl 457 | 8007FD24 _loadOutputBuffer 458 | 8007FF3C _loadBuffer 459 | 800800AC _saveBuffer 460 | 8008021C _filterBuffer 461 | 800802B8 _doModFunc 462 | 80080350 alSavePull 463 | 80080450 alSaveParam 464 | 80080480 alInit 465 | 800804AC alClose 466 | 800804DC alLink 467 | 800804FC alUnlink 468 | 80080530 alHeapInit 469 | 80080570 alHeapDBAlloc 470 | 800805C0 alCopy 471 | 80080600 alSynNew 472 | 800808CC alAudioFrame 473 | 80080A7C __allocParam 474 | 80080AA8 __freeParam 475 | 80080AC0 _collectPVoices 476 | 80080B14 _freePVoice 477 | 80080B54 _timeToSamplesNoRound 478 | 80080B9C _timeToSamples 479 | 80080BE8 __nextSampleTime 480 | 80080C90 alSynDelete 481 | 80080CA0 alSynAddPlayer 482 | 80080CF0 alSynAllocVoice 483 | 80080E18 _allocatePVoice 484 | 80080ED0 alSynStopVoice 485 | 80080F50 alSynStartVoice 486 | 80080FF0 alSynSetPitch 487 | 80081080 alSynSetVol 488 | 80081140 alSynSetFXMix 489 | 800811D0 alSynSetPan 490 | 80081260 alSynAllocFX 491 | 80081300 osAiGetLength 492 | 80081310 osAiSetFrequency 493 | 80081440 osAiSetNextBuffer 494 | 800814E0 osDpSetStatus 495 | 800814F0 osDpGetCounters 496 | 80081540 __osSpSetPc 497 | 80081570 osSpTaskLoad 498 | 8008177C osSpTaskStartGo 499 | 800817B0 osSpTaskYield 500 | 800817D0 osSpTaskYielded 501 | 80081820 osViGetCurrentFramebuffer 502 | 800818A0 osCreateViManager 503 | 80081A38 vimgr_text_0198 504 | 80081BD0 osViSetEvent 505 | 80081C30 osViSetMode 506 | 80081C80 osViSetSpecialFeatures 507 | 80081DF0 osViSwapBuffer 508 | 80081E40 __osViSwapContext 509 | 80082130 osViBlack 510 | 80082190 __osSpRawReadIo 511 | 80082220 __osSiRawWriteIo 512 | 80082290 osContStartQuery 513 | 80082310 osContGetQuery 514 | 80082330 osContStartReadData 515 | 800823B8 osContGetReadData 516 | 80082454 __osPackReadData 517 | 80082510 osContInit 518 | 800826AC __osContGetInitData 519 | 80082760 __osPackRequestData 520 | 80082820 osPfsChecker 521 | 80082C6C corrupted_init 522 | 80082DC4 corrupted 523 | 80082F30 osPfsAllocateFile 524 | 800832C0 __osPfsDeclearPage 525 | 8008348C __osClearPage 526 | 80083520 osPfsDeleteFile 527 | 8008374C __osPfsReleasePages 528 | 800838EC __osBlockSum 529 | 800839C0 osPfsReadWriteFile 530 | 80083DF0 osPfsFileState 531 | 80084030 osPfsFindFile 532 | 800841C0 osPfsIsPlug 533 | 8008433C __osPfsRequestData 534 | 800844A0 osPfsFreeBlocks 535 | 800845B0 osPfsNumFiles 536 | 800846B0 osPfsInitPak 537 | 80084880 osPfsRepairId 538 | 80084A40 __osPfsGetStatus 539 | 80084B20 __osPfsRequestOneChannel 540 | 80084BB0 __osPfsGetOneChannelData 541 | 80084C30 osMotorStop 542 | 80084FB0 osMotorInit 543 | 80085480 osPiRawReadIo 544 | 80085520 osCreatePiManager 545 | 800856B0 osEPiRawStartDma 546 | 80085880 osEPiStartDma 547 | 80085920 osCartRomInit 548 | 80085A00 osLeoDiskInit 549 | 80085B00 osDriveRomInit 550 | 80085BC0 __osDevMgrMain 551 | 80085F80 __osSiCreateAccessQueue 552 | 80085FD4 __osSiGetAccess 553 | 80086070 osPiStartDma 554 | 80086120 _bcopy 555 | 80086440 _bzero 556 | 800864E0 strchr 557 | 80086518 strlen 558 | 8008653C memcpy 559 | 80086570 sprintf 560 | 800865C8 proutSprintf 561 | 80086614 osSyncPrintf 562 | 80086630 osCreateScheduler 563 | 80086778 osScAddClient 564 | 800867D0 osScRemoveClient 565 | 80086860 osScGetCmdQ 566 | 80086868 sched_text_0238 567 | 8008696C __scHandleRetrace 568 | 80086A6C __scHandleRSP 569 | 80086B7C __scHandleRDP 570 | 80086C5C __scTaskReady 571 | 80086CB0 __scTaskComplete 572 | 80086D60 __scAppendList 573 | 80086E0C __scExec 574 | 80086F40 __scYield 575 | 80086F78 __scSchedule 576 | 80087190 guNormalize 577 | 80087240 __osExceptionPreamble 578 | 80087250 __osException 579 | 80087870 handle_CpU 580 | 800879F4 __osPopThread 581 | 80087B80 __osCleanupThread 582 | 80087B90 __osGetSR 583 | 80087C20 __osDisableInt 584 | 80087C40 __osRestoreInt 585 | 80087C60 __osProbeTLB 586 | 80087D20 __osSetCompare 587 | 80087D30 __osSetFpcCsr 588 | 80087D40 __osSetSR 589 | 80087D50 osMapTLBRdb 590 | 80087DB0 osGetThreadPri 591 | 80087DD0 osJamMesg 592 | 80087F10 __osResetGlobalIntMask 593 | 80087F60 __osSetGlobalIntMask 594 | 80087FA0 osSetThreadPri 595 | 80088070 osSetTimer 596 | 80088120 __osAiDeviceBusy 597 | 80088140 osDpSetNextBuffer 598 | 800881E0 __osSpDeviceBusy 599 | 80088200 __osSpGetStatus 600 | 80088210 __osSpSetStatus 601 | 80088220 __osSpRawStartDma 602 | 80088320 __osViInit 603 | 80088440 __osSiDeviceBusy 604 | 80088460 __osSiRawStartDma 605 | 80088610 __osContAddressCrc 606 | 80088658 __osContDataCrc 607 | 800886C0 __osContRamRead 608 | 800888F4 __osPackRamReadData 609 | 80088A90 __osContRamWrite 610 | 80088CB0 __osPackRamWriteData 611 | 80088E50 __osSumcalc 612 | 80088E88 __osIdCheckSum 613 | 80088ECC __osRepairPackId 614 | 800891AC __osCheckPackId 615 | 80089310 __osGetId 616 | 800894F0 __osCheckId 617 | 800895B4 __osPfsRWInode 618 | 8008988C __osPfsSelectBank 619 | 800898E0 osPiRawStartDma 620 | 800899B0 osPiGetCmdQueue 621 | 800899D0 osEPiRawReadIo 622 | 80089B60 osEPiRawWriteIo 623 | 80089CB0 __osLeoInterrupt 624 | 8008A1BC __osLeoAbnormalResume 625 | 8008A28C __osLeoResume 626 | 8008A340 _Printf 627 | 8008A8B0 _Putfld 628 | 8008AD70 __osDpDeviceBusy 629 | 8008AD90 _Litob 630 | 8008AFE0 _Ldtob 631 | 8008B420 _Ldunscale 632 | 8008B4B8 _Genld 633 | 8008BA60 ldiv 634 | 8008BAE4 lldiv 635 | 8008E598 __osActiveQueue 636 | 8008EE20 __additional_scanline 637 | 800911A4 __osCurrentTime 638 | 80091270 __osSiAccessQueueEnabled 639 | 800915B0 rotate_data_0000 640 | 800915C0 rotaterpy_data_0000 641 | 800915D0 position_data_0000 642 | 800915E0 initialize_data_0000 643 | 800915E4 initialize_data_0004 644 | 800915E8 osViClock 645 | 800915F0 __OSGlobalIntMask 646 | 80091600 __osThreadTail 647 | 80091608 __osRunQueue 648 | 8009160C __osActiveQueue 649 | 80091610 __osRunningThread 650 | 80091620 timerintr_data_0000 651 | 80091630 drvrnew_data_0000 652 | 80091698 drvrnew_data_0068 653 | 80091720 drvrnew_data_00F0 654 | 80091748 drvrnew_data_0118 655 | 80091770 drvrnew_data_0140 656 | 80091798 drvrnew_data_0168 657 | 800917C0 env_data_0000 658 | 800918E0 alGlobals 659 | 800918F0 aisetnextbuf_data_0000 660 | 80091900 vimgr_data_0000 661 | 80091904 vimgr_data_0004 662 | 80091908 vimgr_data_0008 663 | 8009190C vimgr_data_000C 664 | 80091910 vimgr_data_0010 665 | 80091914 vimgr_data_0014 666 | 80091918 vimgr_data_0018 667 | 80091920 osViModeTable 668 | 80092640 controller_data_0000 669 | 80092650 motor_data_0000 670 | 80092660 pimgr_data_0000 671 | 80092664 pimgr_data_0004 672 | 80092668 pimgr_data_0008 673 | 8009266C pimgr_data_000C 674 | 80092670 pimgr_data_0010 675 | 80092674 pimgr_data_0014 676 | 80092678 pimgr_data_0018 677 | 8009267C __osPiTable 678 | 80092680 __osCurrentHandle 679 | 80092690 __osPiAccessQueueEnabled 680 | 800926A4 sched_data_0004 681 | 800926A8 sched_data_0008 682 | 800926AC sched_data_000C 683 | 800926D0 vi_data_0000 684 | 800926D2 vi_data_0002 685 | 800926D4 vi_data_0004 686 | 80092702 vi_data_0032 687 | 80092704 vi_data_0034 688 | 80092708 vi_data_0038 689 | 80092730 __osViCurr 690 | 80092734 __osViNext 691 | 80092750 osViModeNtscLan1 692 | 800927A0 osViModePalLan1 693 | 800927F0 osViModeMpalLan1 694 | 80092840 xprintf_data_0000 695 | 80092864 xprintf_data_0024 696 | 80092890 xlitob_data_0000 697 | 800928A4 xlitob_data_0014 698 | 80095E78 cosf_rodata_0008 699 | 80095E80 cosf_rodata_0010 700 | 80095E88 cosf_rodata_0018 701 | 80095E90 cosf_rodata_0020 702 | 80095E98 cosf_rodata_0028 703 | 80095EA0 cosf_rodata_0030 704 | 80095EA8 cosf_rodata_0038 705 | 80095EB0 cosf_rodata_0040 706 | 80095EB8 cosf_rodata_0048 707 | 80095EC0 cosf_rodata_0050 708 | 80095ED0 lookat_rodata_0000 709 | 80095EE0 lookat_rodata_0010 710 | 80095EF0 perspective_rodata_0000 711 | 80095EF8 perspective_rodata_0008 712 | 80095F00 perspective_rodata_0010 713 | 80095F08 perspective_rodata_0018 714 | 80095F10 perspective_rodata_0020 715 | 80095F18 perspective_rodata_0028 716 | 80095F20 perspective_rodata_0030 717 | 80095F28 perspective_rodata_0038 718 | 80095F38 sinf_rodata_0008 719 | 80095F40 sinf_rodata_0010 720 | 80095F48 sinf_rodata_0018 721 | 80095F50 sinf_rodata_0020 722 | 80095F58 sinf_rodata_0028 723 | 80095F60 sinf_rodata_0030 724 | 80095F68 sinf_rodata_0038 725 | 80095F70 sinf_rodata_0040 726 | 80095F78 sinf_rodata_0048 727 | 80095F80 sinf_rodata_0050 728 | 80095F90 __osRcpImTable 729 | 80096010 drvrnew_rodata_0000 730 | 80096018 drvrnew_rodata_0008 731 | 80096030 drvrnew_rodata_0020 732 | 80096038 drvrnew_rodata_0028 733 | 80096040 drvrnew_rodata_0030 734 | 80096050 env_rodata_0000 735 | 80096054 env_rodata_0004 736 | 80096060 env_rodata_0010 737 | 800960A8 env_rodata_0048 738 | 800960B0 env_rodata_0050 739 | 800960B8 env_rodata_0058 740 | 800960C0 env_rodata_0060 741 | 80096100 env_rodata_00A0 742 | 80096108 env_rodata_00A8 743 | 80096110 env_rodata_00B0 744 | 80096118 env_rodata_00B8 745 | 80096120 env_rodata_00C0 746 | 80096128 env_rodata_00C8 747 | 80096130 env_rodata_00D0 748 | 80096138 env_rodata_00D8 749 | 80096140 env_rodata_00E0 750 | 80096148 env_rodata_00E8 751 | 80096150 resample_rodata_0000 752 | 80096158 resample_rodata_0008 753 | 80096180 reverb_rodata_0000 754 | 80096184 reverb_rodata_0004 755 | 80096190 reverb_rodata_0000 756 | 800961B0 reverb_rodata_0020 757 | 800961B8 reverb_rodata_0028 758 | 800961C0 reverb_rodata_0030 759 | 800961C8 reverb_rodata_0038 760 | 800961D0 reverb_rodata_0040 761 | 800961D8 reverb_rodata_0048 762 | 800961E0 save_rodata_0000 763 | 800961E4 save_rodata_0004 764 | 800961F0 synthesizer_rodata_0000 765 | 800961F8 synthesizer_rodata_0008 766 | 80096200 synthesizer_rodata_0010 767 | 80096208 synthesizer_rodata_0018 768 | 80096210 synthesizer_rodata_0020 769 | 80096214 synthesizer_rodata_0024 770 | 80096230 aisetfreq_rodata_0000 771 | 80096240 viswapcontext_rodata_0000 772 | 80096250 sprawread_rodata_0000 773 | 80096254 sprawread_rodata_0004 774 | 80096260 sirawwrite_rodata_0000 775 | 80096264 sirawwrite_rodata_0004 776 | 80096274 pirawread_rodata_0000 777 | 80096278 pirawread_rodata_0004 778 | 80096288 devmgr_rodata_0000 779 | 800962A8 sched_rodata_0000 780 | 800962AC sched_rodata_0004 781 | 800962B8 sched_rodata_0000 782 | 800962E0 __libm_qnan_f 783 | 80096340 sprawdma_rodata_0000 784 | 80096344 sprawdma_rodata_0004 785 | 80096350 sirawdma_rodata_0000 786 | 80096354 sirawdma_rodata_0004 787 | 80096360 epirawread_rodata_0000 788 | 80096364 epirawread_rodata_0004 789 | 80096378 xprintf_rodata_0000 790 | 80096380 xprintf_rodata_0008 791 | 80096398 xprintf_rodata_0020 792 | 800963A0 xprintf_rodata_0028 793 | 800964F0 xldtob_rodata_0000 794 | 80096538 xldtob_rodata_0048 795 | 8009653C xldtob_rodata_004C 796 | 80096540 xldtob_rodata_0050 797 | 80096548 xldtob_rodata_0058 798 | 80096550 xldtob_rodata_0060 799 | 8009BC08 __osSiAccessQueue 800 | 8009BDB4 lookat_rodata_0008 801 | 8009BDD4 lookat_rodata_0018 802 | 8009C110 sptask_bss_0000 803 | 8009C114 sptask_bss_0004 804 | 8009C120 sptask_bss_0010 805 | 8009C128 sptask_bss_0018 806 | 8009C12C sptask_bss_001C 807 | 8009C130 sptask_bss_0020 808 | 8009C138 sptask_bss_0028 809 | 8009C13C sptask_bss_002C 810 | 8009C140 sptask_bss_0030 811 | 8009C148 sptask_bss_0038 812 | 8009C14C sptask_bss_003C 813 | 8009C150 vimgr_bss_0000 814 | 8009C158 vimgr_bss_0008 815 | 8009D310 vimgr_bss_11C0 816 | 8009D328 vimgr_bss_11D8 817 | 8009D340 vimgr_bss_11F0 818 | 8009D342 vimgr_bss_11F2 819 | 8009D344 vimgr_bss_11F4 820 | 8009D358 vimgr_bss_1208 821 | 8009D35A vimgr_bss_120A 822 | 8009D35C vimgr_bss_120C 823 | 8009D370 pimgr_bss_0000 824 | 8009E520 pimgr_bss_11B0 825 | 8009E538 pimgr_bss_11C8 826 | 8009E540 siacs_bss_0000 827 | 8009ED78 __osBaseCounter 828 | 8009ED80 DriveRomHandle 829 | 8009EDF8 _motorstopbuf 830 | 800ACE00 __osContPifRam 831 | 800ACE3C __osContPifRam 832 | 800AFE80 __osViIntrCount 833 | 800B19D8 _MotorStartData 834 | 800B1AE0 _motorstartbuf 835 | 800B51E0 __osDiskHandle 836 | 800B5D68 __osMaxControllers 837 | 800B5DEC __osCurrentTime 838 | 800BBF24 gzip_data_0000 839 | 800BC298 __osPiAccessQueue 840 | 800BF648 __osContLastCmd 841 | 800BF64C __osEepromTimerMsg 842 | 800BFB40 __osTimerCounter 843 | 800C09AC player_bss_003C 844 | 800C0A80 LeoDiskHandle 845 | 800C6940 _MotorStopData 846 | 800C6A50 __osEventStateTab 847 | 800C6A94 __osEventStateTab 848 | 800C72C0 __osFinalrom 849 | 800C72E0 __osPfsPifRam 850 | 800C731C __osPfsPifRam 851 | 800C8740 __osEepromTimerQ 852 | 800C9F98 CartRomHandle 853 | -------------------------------------------------------------------------------- /src/main/java/n64loaderwv/N64LoaderWVLoader.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 n64loaderwv; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.nio.file.Files; 21 | import java.nio.file.Paths; 22 | import java.util.*; 23 | 24 | import org.apache.commons.lang3.exception.ExceptionUtils; 25 | import org.python.jline.internal.Log; 26 | 27 | import ghidra.app.util.MemoryBlockUtils; 28 | import ghidra.app.util.Option; 29 | import ghidra.app.util.bin.BinaryReader; 30 | import ghidra.app.util.bin.ByteArrayProvider; 31 | import ghidra.app.util.bin.ByteProvider; 32 | import ghidra.app.util.importer.MessageLog; 33 | import ghidra.app.util.opinion.AbstractLibrarySupportLoader; 34 | import ghidra.app.util.opinion.LoadSpec; 35 | import ghidra.framework.model.DomainObject; 36 | import ghidra.program.model.address.Address; 37 | import ghidra.program.model.data.DataUtilities; 38 | import ghidra.program.model.data.Structure; 39 | import ghidra.program.model.data.DataUtilities.ClearDataMode; 40 | import ghidra.program.model.lang.LanguageCompilerSpecPair; 41 | import ghidra.program.model.listing.Program; 42 | import ghidra.program.model.mem.MemoryBlock; 43 | import ghidra.program.model.symbol.SourceType; 44 | import ghidra.program.model.symbol.SymbolUtilities; 45 | import ghidra.util.Msg; 46 | import ghidra.util.exception.CancelledException; 47 | import ghidra.util.exception.InvalidInputException; 48 | import ghidra.util.task.TaskMonitor; 49 | 50 | public class N64LoaderWVLoader extends AbstractLibrarySupportLoader { 51 | 52 | class BlockInfo { 53 | long start, end; 54 | String desc, name; 55 | 56 | BlockInfo(long s, long e, String n, String d) { 57 | start = s; 58 | end = e; 59 | desc = d; 60 | name = n; 61 | } 62 | } 63 | 64 | ArrayList blocks = new ArrayList(); 65 | ArrayList initSections = new ArrayList() { 66 | { 67 | add(new BlockInfo(0xA3F00000, 0xA3F00027, "RDRAM Registers", ".rdreg")); 68 | add(new BlockInfo(0xa4040000, 0xa404001f, "SP Registers", ".spreg")); 69 | add(new BlockInfo(0xa4080000, 0xa4080003, "SP_PC_Reg", ".spcreg")); 70 | add(new BlockInfo(0xA4100000, 0xA410001F, "DP Command Registers", ".dpcreg")); 71 | add(new BlockInfo(0xA4200000, 0xa420000F, "DP Span Registers", ".dpsreg")); 72 | add(new BlockInfo(0xa4300000, 0xa430000F, "MIPS Interface (MI) Registers", ".mireg")); 73 | add(new BlockInfo(0xa4400000, 0xa4400037, "Video Interface (VI) Registers", ".vireg")); 74 | add(new BlockInfo(0xa4500000, 0xa4500017, "Audio Interface (AI) Registers", ".aireg")); 75 | add(new BlockInfo(0xa4600000, 0xa4600034, "Peripheral Interface (PI) Registers", ".pireg")); 76 | add(new BlockInfo(0xa4700000, 0xa470001F, "RDRAM Interface (RI) Registers", ".rireg")); 77 | add(new BlockInfo(0xa4800000, 0xa480001b, "Serial Interface (SI) Registers", ".sireg")); 78 | add(new BlockInfo(0xa5000500, 0xa500054b, "N64 Disk Drive (DD) Registers", ".ddreg")); 79 | add(new BlockInfo(0x1FC00000, 0x1FC007BF, "PIF Boot ROM", ".pifrom")); 80 | add(new BlockInfo(0x1FC007C0, 0x1FC007FF, "PIF RAM", ".pifram")); 81 | add(new BlockInfo(0x80000000, 0x800003FF, "Interrupt Vector Table", ".ivt")); 82 | } 83 | }; 84 | 85 | @Override 86 | public String getName() { 87 | return "N64 Loader by Warranty Voider"; 88 | } 89 | 90 | @Override 91 | public Collection findSupportedLoadSpecs(ByteProvider provider) throws IOException { 92 | List loadSpecs = new ArrayList<>(); 93 | Log.info("N64 Loader: Checking Signature"); 94 | BinaryReader br = new BinaryReader(provider, false); 95 | int header = br.readInt(0); 96 | boolean valid = false; 97 | switch (header) { 98 | case 0x80371240: 99 | case 0x80270740: 100 | Log.info("N64 Loader: Found matching header for big endian"); 101 | valid = true; 102 | break; 103 | case 0x37804012: 104 | Log.info("N64 Loader: Found matching header for mixed endian"); 105 | valid = true; 106 | break; 107 | case 0x40123780: 108 | Log.info("N64 Loader: Found matching header for little endian"); 109 | valid = true; 110 | break; 111 | default: 112 | Log.info(String.format("N64 Loader: Found unknown header 0x%08X", header)); 113 | break; 114 | } 115 | if (valid) 116 | loadSpecs.add(new LoadSpec(this, 0, new LanguageCompilerSpecPair("MIPS:BE:64:64-32addr", "o32"), true)); 117 | return loadSpecs; 118 | } 119 | 120 | @Override 121 | protected void load(Program program, ImporterSettings settings) throws CancelledException, IOException { 122 | this.load(settings.provider(), settings.loadSpec(), settings.options(), program, settings.monitor(), settings.log()); 123 | } 124 | 125 | protected void load(ByteProvider provider, LoadSpec loadSpec, List