├── .gitignore ├── DisassemblyTools.sln ├── LICENSE ├── MapDumper ├── App.config ├── GetImageFunctions.vb ├── GetNameFunctions.vb ├── HexFunctions.vb ├── INI.vb ├── LZ77.vb ├── MapDumper.vbproj ├── MnFrm.Designer.vb ├── MnFrm.resx ├── MnFrm.vb ├── My Project │ ├── Application.Designer.vb │ ├── Application.myapp │ ├── AssemblyInfo.vb │ ├── Resources.Designer.vb │ ├── Resources.resx │ ├── Settings.Designer.vb │ └── Settings.settings ├── NSELZZ.vb ├── WichuRomFunctions.vb ├── WichuSpriteFunctions.vb ├── mMain.vb └── modTextSapp.vb ├── README.md └── aseriestodis ├── App.config ├── HexFunctions.vb ├── LZ77.vb ├── Module1.vb ├── My Project ├── Application.Designer.vb ├── Application.myapp ├── AssemblyInfo.vb ├── Resources.Designer.vb ├── Resources.resx ├── Settings.Designer.vb └── Settings.settings ├── NSELZZ.vb ├── WichuRomFunctions.vb ├── WichuSpriteFunctions.vb ├── aseriestodis.vbproj └── mMain.vb /.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 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Nuget personal access tokens and Credentials 210 | # nuget.config 211 | 212 | # Microsoft Azure Build Output 213 | csx/ 214 | *.build.csdef 215 | 216 | # Microsoft Azure Emulator 217 | ecf/ 218 | rcf/ 219 | 220 | # Windows Store app package directories and files 221 | AppPackages/ 222 | BundleArtifacts/ 223 | Package.StoreAssociation.xml 224 | _pkginfo.txt 225 | *.appx 226 | *.appxbundle 227 | *.appxupload 228 | 229 | # Visual Studio cache files 230 | # files ending in .cache can be ignored 231 | *.[Cc]ache 232 | # but keep track of directories ending in .cache 233 | !?*.[Cc]ache/ 234 | 235 | # Others 236 | ClientBin/ 237 | ~$* 238 | *~ 239 | *.dbmdl 240 | *.dbproj.schemaview 241 | *.jfm 242 | *.pfx 243 | *.publishsettings 244 | orleans.codegen.cs 245 | 246 | # Including strong name files can present a security risk 247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 248 | #*.snk 249 | 250 | # Since there are multiple workflows, uncomment next line to ignore bower_components 251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 252 | #bower_components/ 253 | 254 | # RIA/Silverlight projects 255 | Generated_Code/ 256 | 257 | # Backup & report files from converting an old project file 258 | # to a newer Visual Studio version. Backup files are not needed, 259 | # because we have git ;-) 260 | _UpgradeReport_Files/ 261 | Backup*/ 262 | UpgradeLog*.XML 263 | UpgradeLog*.htm 264 | ServiceFabricBackup/ 265 | *.rptproj.bak 266 | 267 | # SQL Server files 268 | *.mdf 269 | *.ldf 270 | *.ndf 271 | 272 | # Business Intelligence projects 273 | *.rdl.data 274 | *.bim.layout 275 | *.bim_*.settings 276 | *.rptproj.rsuser 277 | *- [Bb]ackup.rdl 278 | *- [Bb]ackup ([0-9]).rdl 279 | *- [Bb]ackup ([0-9][0-9]).rdl 280 | 281 | # Microsoft Fakes 282 | FakesAssemblies/ 283 | 284 | # GhostDoc plugin setting file 285 | *.GhostDoc.xml 286 | 287 | # Node.js Tools for Visual Studio 288 | .ntvs_analysis.dat 289 | node_modules/ 290 | 291 | # Visual Studio 6 build log 292 | *.plg 293 | 294 | # Visual Studio 6 workspace options file 295 | *.opt 296 | 297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 298 | *.vbw 299 | 300 | # Visual Studio LightSwitch build output 301 | **/*.HTMLClient/GeneratedArtifacts 302 | **/*.DesktopClient/GeneratedArtifacts 303 | **/*.DesktopClient/ModelManifest.xml 304 | **/*.Server/GeneratedArtifacts 305 | **/*.Server/ModelManifest.xml 306 | _Pvt_Extensions 307 | 308 | # Paket dependency manager 309 | .paket/paket.exe 310 | paket-files/ 311 | 312 | # FAKE - F# Make 313 | .fake/ 314 | 315 | # CodeRush personal settings 316 | .cr/personal 317 | 318 | # Python Tools for Visual Studio (PTVS) 319 | __pycache__/ 320 | *.pyc 321 | 322 | # Cake - Uncomment if you are using it 323 | # tools/** 324 | # !tools/packages.config 325 | 326 | # Tabs Studio 327 | *.tss 328 | 329 | # Telerik's JustMock configuration file 330 | *.jmconfig 331 | 332 | # BizTalk build output 333 | *.btp.cs 334 | *.btm.cs 335 | *.odx.cs 336 | *.xsd.cs 337 | 338 | # OpenCover UI analysis results 339 | OpenCover/ 340 | 341 | # Azure Stream Analytics local run output 342 | ASALocalRun/ 343 | 344 | # MSBuild Binary and Structured Log 345 | *.binlog 346 | 347 | # NVidia Nsight GPU debugger configuration file 348 | *.nvuser 349 | 350 | # MFractors (Xamarin productivity tool) working folder 351 | .mfractor/ 352 | 353 | # Local History for Visual Studio 354 | .localhistory/ 355 | 356 | # BeatPulse healthcheck temp database 357 | healthchecksdb 358 | 359 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 360 | MigrationBackup/ 361 | 362 | # Ionide (cross platform F# VS Code tools) working folder 363 | .ionide/ 364 | 365 | # Fody - auto-generated XML schema 366 | FodyWeavers.xsd 367 | 368 | # VS Code files for those working on multiple tools 369 | .vscode/* 370 | !.vscode/settings.json 371 | !.vscode/tasks.json 372 | !.vscode/launch.json 373 | !.vscode/extensions.json 374 | *.code-workspace 375 | 376 | # Local History for Visual Studio Code 377 | .history/ 378 | 379 | # Windows Installer files from build outputs 380 | *.cab 381 | *.msi 382 | *.msix 383 | *.msm 384 | *.msp 385 | 386 | # JetBrains Rider 387 | .idea/ 388 | *.sln.iml 389 | -------------------------------------------------------------------------------- /DisassemblyTools.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31729.503 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "aseriestodis", "aseriestodis\aseriestodis.vbproj", "{93B1A145-0896-43BE-8AB8-84FADC0E87C5}" 7 | EndProject 8 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MapDumper", "MapDumper\MapDumper.vbproj", "{628E87B0-2AF0-4E17-866D-6B2CAF85D4C6}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {93B1A145-0896-43BE-8AB8-84FADC0E87C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {93B1A145-0896-43BE-8AB8-84FADC0E87C5}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {93B1A145-0896-43BE-8AB8-84FADC0E87C5}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {93B1A145-0896-43BE-8AB8-84FADC0E87C5}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {628E87B0-2AF0-4E17-866D-6B2CAF85D4C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {628E87B0-2AF0-4E17-866D-6B2CAF85D4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {628E87B0-2AF0-4E17-866D-6B2CAF85D4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {628E87B0-2AF0-4E17-866D-6B2CAF85D4C6}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {4263D832-E8FC-48B6-B1EC-B7FDDA697C42} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /MapDumper/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MapDumper/GetNameFunctions.vb: -------------------------------------------------------------------------------- 1 | Option Strict Off 2 | Option Explicit Off 3 | 4 | Module GetNameFunctions 5 | 6 | Public Function GetAbilityName(ByVal Index As Integer) 7 | Dim offvar As Integer 8 | Dim b As String = "" 9 | 10 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "AbilityNames", "")), System.Globalization.NumberStyles.HexNumber) 11 | 12 | If header3 = "J" Then 13 | 14 | Else 15 | 16 | FileNum = FreeFile() 17 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 18 | Dim AbilityName As String = "xxxxxxxxxxxxxx" 19 | FileGet(FileNum, AbilityName, offvar + 1 + (13 * Index)) 20 | b = Sapp2Asc(AbilityName, False) 21 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 22 | b = LSet(b, Len(b) - 1) 23 | 24 | 25 | End If 26 | FileClose(FileNum) 27 | GetAbilityName = b 28 | End Function 29 | 30 | Public Function GetItemName(ByVal Index As Integer) 31 | Dim offvar As Integer 32 | Dim b As String = "" 33 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "ItemData", "")), System.Globalization.NumberStyles.HexNumber) 34 | 35 | If header3 = "J" Then 36 | 37 | Else 38 | 39 | FileNum = FreeFile() 40 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 41 | Dim ItemName As String = "xxxxxxxxxxxxxx" 42 | FileGet(FileNum, ItemName, offvar + 1 + (44 * Index)) 43 | b = Sapp2Asc(ItemName, False) 44 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 45 | b = LSet(b, Len(b) - 1) 46 | 47 | 48 | End If 49 | FileClose(FileNum) 50 | GetItemName = b 51 | End Function 52 | 53 | Public Function GetPokemonName(ByVal Index As Integer) 54 | Dim offvar As Integer 55 | 56 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "PokemonNames", "")), System.Globalization.NumberStyles.HexNumber) 57 | 58 | If header3 = "J" Then 59 | 60 | FileNum = FreeFile() 61 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 62 | Dim JapPokeName As String = "xxxxxx" 63 | FileGet(FileNum, JapPokeName, offvar + 1 + (6 * Index)) 64 | b$ = Sapp2Asc(JapPokeName, True) 65 | While InStr(1, b$, "\x") : b$ = LSet(b$, Len(b$) - 1) : End While 66 | b$ = LSet(b$, Len(b$) - 1) 67 | 68 | 69 | Else 70 | 71 | FileNum = FreeFile() 72 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 73 | Dim PokeName As String = "xxxxxxxxxxx" 74 | FileGet(FileNum, PokeName, offvar + 1 + (11 * Index)) 75 | b$ = Sapp2Asc(PokeName, False) 76 | While InStr(1, b$, "\x") : b$ = LSet(b$, Len(b$) - 1) : End While 77 | b$ = LSet(b$, Len(b$) - 1) 78 | 79 | 80 | End If 81 | FileClose(FileNum) 82 | GetPokemonName = b$ 83 | End Function 84 | 85 | Public Function GetMapLabelName(ByVal Index As Integer) As String 86 | Dim offvar As Integer 87 | Dim stringvar As String 88 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "MapLabelData", "")), System.Globalization.NumberStyles.HexNumber) 89 | 90 | If header2 = "BPR" Or header2 = "BPG" Then 91 | offvar = "&H" & Hex(Val("&H" & ReverseHEX(ReadHEX(LoadedROM, offvar + (4 * Index), 4))) - &H8000000) 92 | Else 93 | 94 | offvar = "&H" & Hex(Val("&H" & ReverseHEX(ReadHEX(LoadedROM, offvar + (8 * Index), 4))) - &H8000000) 95 | End If 96 | 97 | If header3 = "J" Then 98 | 99 | stringvar = "not supported" 100 | 101 | Else 102 | 103 | FileNum = FreeFile() 104 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 105 | Dim LabelName As String = "xxxxxxxxxxxxxxxxxxxxxx" 106 | 107 | 108 | 109 | FileGet(FileNum, LabelName, offvar + 1) 110 | stringvar = Sapp2Asc(LabelName, False) 111 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 112 | stringvar = LSet(stringvar, Len(stringvar) - 1) 113 | 114 | 115 | End If 116 | FileClose(FileNum) 117 | GetMapLabelName = stringvar 118 | End Function 119 | 120 | Public Function GetAttackName(ByVal Index As Integer) 121 | Dim offvar As Integer 122 | Dim b As String = "" 123 | 124 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "AttackNames", "")), System.Globalization.NumberStyles.HexNumber) 125 | 126 | If header3 = "J" Then 127 | 128 | Else 129 | 130 | FileNum = FreeFile() 131 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 132 | Dim AttackName As String = "xxxxxxxxxxxxx" 133 | FileGet(FileNum, AttackName, offvar + 1 + (13 * Index)) 134 | b = Sapp2Asc(AttackName, False) 135 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 136 | b = LSet(b, Len(b) - 1) 137 | 138 | 139 | End If 140 | FileClose(FileNum) 141 | GetAttackName = b 142 | End Function 143 | 144 | Public Function GetBattleFrontierTrainerName(ByVal Index As Integer) As String 145 | Dim offvar As Integer 146 | Dim stringvar As String = "" 147 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "BattleFrontierTrainers", "")), System.Globalization.NumberStyles.HexNumber) 148 | 149 | If header2 = "BPE" Then 150 | If header3 = "J" Then 151 | Else 152 | offvar = offvar + 4 + (Index * 52) 153 | FileNum = FreeFile() 154 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 155 | Dim LabelName As String = "xxxxxxxx" 156 | 157 | 158 | 159 | FileGet(FileNum, LabelName, offvar + 1) 160 | stringvar = Sapp2Asc(LabelName, False) 161 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 162 | stringvar = LSet(stringvar, Len(stringvar) - 1) 163 | 164 | End If 165 | 166 | FileClose(FileNum) 167 | Else 168 | MsgBox("What did you do?") 169 | End 170 | End If 171 | 172 | 173 | 174 | GetBattleFrontierTrainerName = stringvar 175 | End Function 176 | 177 | Public Function GetSlateportBattleTentTrainerName(ByVal Index As Integer) As String 178 | Dim offvar As Integer 179 | Dim stringvar As String = "" 180 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "SlateportBattleTentTrainers", "")), System.Globalization.NumberStyles.HexNumber) 181 | 182 | If header2 = "BPE" Then 183 | If header3 = "J" Then 184 | Else 185 | offvar = offvar + 4 + (Index * 52) 186 | FileNum = FreeFile() 187 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 188 | Dim LabelName As String = "xxxxxxxx" 189 | 190 | 191 | 192 | FileGet(FileNum, LabelName, offvar + 1) 193 | stringvar = Sapp2Asc(LabelName, False) 194 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 195 | stringvar = LSet(stringvar, Len(stringvar) - 1) 196 | 197 | End If 198 | 199 | FileClose(FileNum) 200 | Else 201 | MsgBox("What did you do?") 202 | End 203 | End If 204 | 205 | 206 | 207 | GetSlateportBattleTentTrainerName = stringvar 208 | End Function 209 | 210 | Public Function GetVerdanturfBattleTentTrainerName(ByVal Index As Integer) As String 211 | Dim offvar As Integer 212 | Dim stringvar As String = "" 213 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "VerdanturfBattleTentTrainers", "")), System.Globalization.NumberStyles.HexNumber) 214 | 215 | If header2 = "BPE" Then 216 | If header3 = "J" Then 217 | Else 218 | offvar = offvar + 4 + (Index * 52) 219 | FileNum = FreeFile() 220 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 221 | Dim LabelName As String = "xxxxxxxx" 222 | 223 | 224 | 225 | FileGet(FileNum, LabelName, offvar + 1) 226 | stringvar = Sapp2Asc(LabelName, False) 227 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 228 | stringvar = LSet(stringvar, Len(stringvar) - 1) 229 | 230 | End If 231 | 232 | FileClose(FileNum) 233 | Else 234 | MsgBox("What did you do?") 235 | End 236 | End If 237 | 238 | 239 | 240 | GetVerdanturfBattleTentTrainerName = stringvar 241 | End Function 242 | 243 | Public Function GetFallarborBattleTentTrainerName(ByVal Index As Integer) As String 244 | Dim offvar As Integer 245 | Dim stringvar As String = "" 246 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "FallarborBattleTentTrainers", "")), System.Globalization.NumberStyles.HexNumber) 247 | 248 | If header2 = "BPE" Then 249 | If header3 = "J" Then 250 | Else 251 | offvar = offvar + 4 + (Index * 52) 252 | FileNum = FreeFile() 253 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 254 | Dim LabelName As String = "xxxxxxxx" 255 | 256 | 257 | 258 | FileGet(FileNum, LabelName, offvar + 1) 259 | stringvar = Sapp2Asc(LabelName, False) 260 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 261 | stringvar = LSet(stringvar, Len(stringvar) - 1) 262 | 263 | End If 264 | 265 | FileClose(FileNum) 266 | Else 267 | MsgBox("What did you do?") 268 | End 269 | End If 270 | 271 | 272 | 273 | GetFallarborBattleTentTrainerName = stringvar 274 | End Function 275 | 276 | Public Function GetTrainerClass(ByVal Index As Integer) 277 | Dim offvar As Integer 278 | Dim b As String = "" 279 | 280 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "TrainerClasses", "")), System.Globalization.NumberStyles.HexNumber) 281 | 282 | If header3 = "J" Then 283 | 284 | Else 285 | 286 | FileNum = FreeFile() 287 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 288 | Dim Name As String = "xxxxxxxxxxxxx" 289 | FileGet(FileNum, Name, offvar + 1 + (13 * Index)) 290 | b = Sapp2Asc(Name, False) 291 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 292 | b = LSet(b, Len(b) - 1) 293 | 294 | 295 | End If 296 | FileClose(FileNum) 297 | GetTrainerClass = b 298 | End Function 299 | 300 | Public Function GetPokedexTypeName(ByVal Index As Integer) 301 | Dim offvar As Integer 302 | Dim b As String = "" 303 | 304 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "PokedexData", "")), System.Globalization.NumberStyles.HexNumber) 305 | 306 | If header3 = "J" Then 307 | 308 | If header2 = "AXP" Or header2 = "AXV" Then 309 | SkipVar = "36" 310 | ElseIf header2 = "BPR" Or header2 = "BPG" Then 311 | SkipVar = "36" 312 | ElseIf header2 = "BPE" Then 313 | SkipVar = "32" 314 | End If 315 | 316 | Else 317 | If header2 = "AXP" Or header2 = "AXV" Then 318 | SkipVar = "36" 319 | ElseIf header2 = "BPR" Or header2 = "BPG" Then 320 | SkipVar = "36" 321 | ElseIf header2 = "BPE" Then 322 | SkipVar = "32" 323 | End If 324 | End If 325 | 326 | 327 | 328 | If header3 = "J" Then 329 | 330 | Else 331 | 332 | FileNum = FreeFile() 333 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 334 | Dim PokeType As String = "xxxxxxxxxxxx" 335 | FileGet(FileNum, PokeType, offvar + 1 + (SkipVar * Index)) 336 | b = Sapp2Asc(PokeType, False) 337 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 338 | b = LSet(b, Len(b) - 1) 339 | 340 | 341 | End If 342 | FileClose(FileNum) 343 | GetPokedexTypeName = b 344 | End Function 345 | 346 | Public Function GetTradeNickName(ByVal Index As Integer) As String 347 | Dim offvar As Integer 348 | Dim stringvar As String = "" 349 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "TradeData", "")), System.Globalization.NumberStyles.HexNumber) 350 | 351 | 352 | If header3 = "J" Then 353 | Else 354 | offvar = offvar + 0 + (Index * 60) 355 | FileNum = FreeFile() 356 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 357 | Dim LabelName As String = "xxxxxxxxxxxx" 358 | 359 | 360 | 361 | FileGet(FileNum, LabelName, offvar + 1) 362 | stringvar = Sapp2Asc(LabelName, False) 363 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 364 | stringvar = LSet(stringvar, Len(stringvar) - 1) 365 | 366 | End If 367 | 368 | FileClose(FileNum) 369 | 370 | 371 | 372 | GetTradeNickName = stringvar 373 | End Function 374 | 375 | Public Function GetTradeOTName(ByVal Index As Integer) As String 376 | Dim offvar As Integer 377 | Dim stringvar As String = "" 378 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "TradeData", "")), System.Globalization.NumberStyles.HexNumber) 379 | 380 | 381 | If header3 = "J" Then 382 | Else 383 | offvar = offvar + 43 + (Index * 60) 384 | FileNum = FreeFile() 385 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 386 | Dim LabelName As String = "xxxxxxxx" 387 | 388 | 389 | 390 | FileGet(FileNum, LabelName, offvar + 1) 391 | stringvar = Sapp2Asc(LabelName, False) 392 | While InStr(1, stringvar, "\x") : stringvar = LSet(stringvar, Len(stringvar) - 1) : End While 393 | stringvar = LSet(stringvar, Len(stringvar) - 1) 394 | 395 | End If 396 | 397 | FileClose(FileNum) 398 | 399 | 400 | 401 | GetTradeOTName = stringvar 402 | End Function 403 | 404 | Public Function GetTrainerName(ByVal Index As Integer) 405 | Dim offvar As Integer 406 | Dim b As String = "" 407 | 408 | offvar = Int32.Parse((GetString(GetINIFileLocation(), header, "TrainerTable", "")), System.Globalization.NumberStyles.HexNumber) 409 | 410 | If header3 = "J" Then 411 | 412 | Else 413 | 414 | FileNum = FreeFile() 415 | FileOpen(FileNum, LoadedROM, OpenMode.Binary) 416 | Dim Name As String = "xxxxxxxxxxx" 417 | FileGet(FileNum, Name, offvar + 1 + 4 + (40 * Index)) 418 | b = Sapp2Asc(Name, False) 419 | While InStr(1, b, "\x") : b = LSet(b, Len(b) - 1) : End While 420 | b = LSet(b, Len(b) - 1) 421 | 422 | 423 | End If 424 | FileClose(FileNum) 425 | GetTrainerName = b 426 | End Function 427 | 428 | End Module 429 | -------------------------------------------------------------------------------- /MapDumper/HexFunctions.vb: -------------------------------------------------------------------------------- 1 | Option Strict Off 2 | Option Explicit On 3 | Module HexFunctions 4 | ' ------------------------------------------------ 5 | ' ---------------------------------------------------- 6 | ' -------------------------------------------------------- 7 | ' |----------HEX Editing Functions by: Darthatron----------| 8 | ' -------------------------------------------------------- 9 | ' |--When using these functions I must be credited fully.--| 10 | ' |--Check on Darthatron.Com for updates of this function--| 11 | ' |--as these are merely the BETA forms and may need some--| 12 | ' |--updates. If you find any bugs, please email them to:--| 13 | ' |--info@darthatron.com, thankyou: Regards, Darthatron.--| 14 | ' -------------------------------------------------------- 15 | ' ---------------------------------------------------- 16 | ' ------------------------------------------------ 17 | ' ------------------------------------------------ 18 | ' ----------You can't handle the truth!!---------- 19 | ' ------------------------------------------------ 20 | ' ------------------------------------------------ 21 | ' ---------------------------------------------------- 22 | ' -------------------------------------------------------- 23 | ' |----------Update 001: Sunday 18th May 2008----------| 24 | ' -------------------------------------------------------- 25 | ' |----Pretty much just fixed the WriteHEX Function, it----| 26 | ' |----------should be reasonably faster now. :)----------| 27 | ' -------------------------------------------------------- 28 | ' ---------------------------------------------------- 29 | ' ------------------------------------------------ 30 | 31 | Public Function ReverseHEX(ByRef HEXData As String) As String 32 | Dim iNum As Integer 33 | Dim HEXHolder As String = "" 34 | If Len(HEXData) / 2 <> Int(Len(HEXData) / 2) Then HEXData = "0" & HEXData 35 | 36 | For iNum = 0 To Len(HEXData) + 1 37 | If Len(HEXData) <= 1 Then GoTo EndNow 38 | HEXHolder = HEXHolder & Right(HEXData, 2) 39 | HEXData = Left(HEXData, Len(HEXData) - 2) 40 | Next iNum 41 | EndNow: 42 | ReverseHEX = HEXHolder 43 | End Function 44 | 45 | Public Function ReadHEX(ByRef FilePath As String, ByRef Start2 As Integer, ByRef Length As Integer) As String 46 | On Error GoTo ErrHandle 47 | Dim iFile As Integer 48 | Dim bytHex As Byte 49 | Dim sHex As String 50 | Dim i As Integer 51 | Dim Start As Integer 52 | 53 | Start = Start2 + 1 54 | 55 | iFile = FreeFile() 56 | sHex = "" 57 | i = 0 58 | FileOpen(iFile, FilePath, OpenMode.Binary) 59 | For i = Start To (Start + Length - 1) 60 | 'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 61 | FileGet(iFile, bytHex, i) 62 | sHex = sHex & Right("00" & Hex(bytHex), 2) 63 | Next i 64 | FileClose(iFile) 65 | ReadHEX = sHex 66 | Exit Function 67 | ErrHandle: 68 | MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error: " & Err.Number) 69 | End Function 70 | 71 | Public Function WriteHEX(ByRef FilePath As String, ByRef Start As Integer, ByRef Data As String) As Object 72 | On Error GoTo ErrHandle 73 | WriteHEX = 0 74 | Dim iFile As Integer 75 | Dim sPost As Integer 76 | Dim bytHex As Byte 77 | ' Start = Start + 1 78 | iFile = FreeFile 79 | sPost = 0 80 | 81 | If Len(Data) <> Int(Len(Data) / 2) * 2 Then Data = "0" & Data 82 | 83 | FileOpen(iFile, FilePath, OpenMode.Binary) 84 | 85 | Do While Len(Data) > 0 86 | bytHex = Int32.Parse((Mid(Data, 1, 2)), System.Globalization.NumberStyles.HexNumber) 87 | 'UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 88 | FilePut(iFile, bytHex, Start + 1 + sPost) 89 | Data = Right(Data, Len(Data) - 2) 90 | sPost = sPost + 1 91 | Loop 92 | FileClose(iFile) 93 | WriteHEX = 1 94 | Exit Function 95 | ErrHandle: 96 | MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error: " & Err.Number) 97 | 98 | End Function 99 | End Module -------------------------------------------------------------------------------- /MapDumper/INI.vb: -------------------------------------------------------------------------------- 1 | Module INI 2 | Private Declare Ansi Function GetPrivateProfileString _ 3 | Lib "kernel32.dll" Alias "GetPrivateProfileStringA" _ 4 | (ByVal lpApplicationName As String, _ 5 | ByVal lpKeyName As String, ByVal lpDefault As String, _ 6 | ByVal lpReturnedString As System.Text.StringBuilder, _ 7 | ByVal nSize As Integer, ByVal lpFileName As String) _ 8 | As Integer 9 | Private Declare Ansi Function WritePrivateProfileString _ 10 | Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _ 11 | (ByVal lpApplicationName As String, _ 12 | ByVal lpKeyName As String, ByVal lpString As String, _ 13 | ByVal lpFileName As String) As Integer 14 | Private Declare Ansi Function GetPrivateProfileInt _ 15 | Lib "kernel32.dll" Alias "GetPrivateProfileIntA" _ 16 | (ByVal lpApplicationName As String, _ 17 | ByVal lpKeyName As String, ByVal nDefault As Integer, _ 18 | ByVal lpFileName As String) As Integer 19 | Private Declare Ansi Function FlushPrivateProfileString _ 20 | Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _ 21 | (ByVal lpApplicationName As Integer, _ 22 | ByVal lpKeyName As Integer, ByVal lpString As Integer, _ 23 | ByVal lpFileName As String) As Integer 24 | 25 | Public Function GetString(ByVal strFilename As String, ByVal Section As String, 26 | ByVal Key As String, ByVal [Default] As String) As String 27 | 28 | GetString = "" 29 | 30 | Dim intCharCount As Integer 31 | Dim objResult As New System.Text.StringBuilder(256) 32 | intCharCount = GetPrivateProfileString(Section, Key, 33 | [Default], objResult, objResult.Capacity, strFilename) 34 | If intCharCount > 0 Then GetString = 35 | Left(objResult.ToString, intCharCount) 36 | 37 | 38 | 'This should probably be commented out if used for another program! 39 | If LoadedROM <> "" Then 40 | If GetString = "" And GetINIFileLocation() = strFilename Then 41 | OutPutError("Error! " & Key & " is missing for ROM " & Section & "!") 42 | End If 43 | End If 44 | 45 | End Function 46 | 47 | Public Function WriteString(ByVal strFilename As String, ByVal Section As String, _ 48 | ByVal Key As String, ByVal Value As String) 49 | WritePrivateProfileString(Section, Key, Value, strFilename) 50 | Flush(strFilename) 51 | WriteString = "" 52 | End Function 53 | 54 | Private Sub Flush(ByVal thing As String) 55 | FlushPrivateProfileString(0, 0, 0, thing) 56 | End Sub 57 | 58 | End Module 59 | -------------------------------------------------------------------------------- /MapDumper/LZ77.vb: -------------------------------------------------------------------------------- 1 | Module LZ77 2 | Public LastStructSize As Integer 3 | 4 | Public Function Inc(ByVal variable As Long, Optional ByVal value As Integer = 1) 5 | Inc = variable 6 | variable = variable + value 7 | End Function 8 | 9 | Private Function Dec(ByVal Source As Long) 10 | Dec = Source 11 | Source = Source - 1 12 | End Function 13 | 14 | 'Decompress LZ77 data with the below function. 15 | Public Function LZ77UnComp(ByVal Source() As Byte, ByVal Dest() As Byte) As Integer 16 | On Error Resume Next 17 | Dim header As Integer 18 | header = (Source(0) Or (Source(1) * CInt(256)) Or (Source(2) * CInt(2 ^ 16)) Or (Source(3) * CInt(2 ^ 24))) 19 | Dim i As Integer 20 | Dim j As Integer 21 | Dim xIn As Integer = 4 22 | Dim xOut As Integer = 0 23 | Dim length As Integer 24 | Dim Offset As Integer 25 | Dim windowOffset As Integer 26 | Dim xLen As Integer = header \ 256 27 | Dim retLen As Integer = xLen 28 | Dim d As Byte 29 | Dim data As Integer 30 | retLen = xLen 31 | Do While xLen > 0 32 | d = Source(xIn) 33 | xIn = xIn + 1 34 | For i = 0 To 7 35 | If (d And &H80) <> 0 Then 36 | data = ((Source(xIn) * (2 ^ 8)) Or Source(xIn + 1)) 37 | 38 | xIn = xIn + 2 39 | length = (data \ 4096) + 3 '(2 ^ 12)) + 3 40 | Offset = (data And &HFFF) 41 | windowOffset = xOut - Offset - 1 42 | For j = 0 To length - 1 43 | dest(xOut) = dest(windowOffset) 44 | xOut = xOut + 1 45 | windowOffset = windowOffset + 1 46 | 47 | xLen = xLen - 1 48 | If xLen = 0 Then 49 | LZ77UnComp = retLen 50 | Exit Function 51 | End If 52 | Next j 53 | Else 54 | dest(xOut) = Source(xIn) 55 | xOut = xOut + 1 56 | xIn = xIn + 1 57 | 58 | xLen = xLen - 1 59 | If xLen = 0 Then 60 | LZ77UnComp = retLen 61 | Exit Function 62 | End If 63 | End If 64 | d = (d * 2) Mod 256 65 | Next i 66 | Loop 67 | LZ77UnComp = retLen 68 | LastStructSize = xIn 69 | End Function 70 | 71 | 'Compress data to the LZ77 format with the below function. 72 | Public Function LZ77Comp(ByVal decmpsize As Integer, ByVal Source() As Byte, ByVal dest() As Byte) As Integer 73 | Dim i As Integer 74 | Dim j As Integer 75 | Dim xIn As Integer 76 | Dim xOut As Integer 77 | 78 | Dim length As Integer 79 | Dim Offset As Integer 80 | Dim tmplen As Integer 81 | Dim tmpoff As Integer 82 | Dim tmpxin As Integer 83 | Dim tmpxout As Integer 84 | Dim bufxout As Integer 85 | Dim ctrl As Byte 86 | Dim xdata(0 To 7, 0 To 1) As Byte 87 | On Error GoTo endme 88 | dest(0) = &H10 'unknown byte? 89 | dest(1) = (decmpsize Mod 256) 90 | dest(2) = ((decmpsize \ 256) Mod 256) 91 | dest(3) = ((decmpsize \ (2 ^ 16)) Mod 256) 92 | 93 | Do While (decmpsize > tmpxin) 94 | ctrl = 0 95 | For i = 7 To 0 Step -1 96 | If (xIn < &H1000) Then 97 | j = xIn 98 | Else 99 | j = &H1000 100 | End If 101 | length = 0 102 | Offset = 0 103 | Do While (j > 1) 104 | tmpxin = xIn 105 | tmpxout = (xIn - j) 106 | Do While Source(Inc(tmpxin)) = Source(Inc(tmpxout)) 107 | If (tmpxin >= decmpsize) Then Exit Do 108 | Loop 109 | tmplen = (tmpxin - xIn - 1) 110 | tmpoff = (tmpxin - tmpxout - 1) 111 | If (tmplen > length) Then 112 | length = tmplen 113 | Offset = tmpoff 114 | End If 115 | If (length >= &H12) Then Exit Do 116 | Inc(j, -1) 117 | Loop 118 | If (length >= 3) Then 119 | ctrl = ctrl Or (1 * (2 ^ i)) 120 | If (length >= &H12) Then length = &H12 121 | xdata(i, 0) = (((length - 3) * (2 ^ 4)) Or (Offset \ 256)) 122 | xdata(i, 1) = (Offset Mod 256) 123 | Inc(xIn, length) 124 | Inc(bufxout, 2) 125 | Else 126 | xdata(i, 0) = Source(Inc(xIn)) 127 | Inc(bufxout) 128 | End If 129 | Next i 130 | dest(Inc(xOut) + 4) = ctrl 131 | For i = 7 To 0 Step -1 132 | dest(Inc(xOut) + 4) = xdata(i, 0) 133 | If ((ctrl And &H80) <> 0) Then dest(Inc(xOut) + 4) = xdata(i, 1) 134 | ctrl = (ctrl * 2) Mod 256 135 | If (decmpsize < tmpxin) Then Exit For 136 | Next i 137 | Loop 138 | endme: 139 | LZ77Comp = xOut + 4 140 | End Function 141 | End Module 142 | -------------------------------------------------------------------------------- /MapDumper/MapDumper.vbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {628E87B0-2AF0-4E17-866D-6B2CAF85D4C6} 8 | WinExe 9 | MapDumper.My.MyApplication 10 | MapDumper 11 | MapDumper 12 | 512 13 | WindowsForms 14 | v4.5 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | true 21 | true 22 | bin\Debug\ 23 | MapDumper.xml 24 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | false 30 | true 31 | true 32 | bin\Release\ 33 | MapDumper.xml 34 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 35 | 36 | 37 | On 38 | 39 | 40 | Binary 41 | 42 | 43 | Off 44 | 45 | 46 | On 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 | Form 79 | 80 | 81 | MnFrm.vb 82 | Form 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | True 91 | Application.myapp 92 | 93 | 94 | True 95 | True 96 | Resources.resx 97 | 98 | 99 | True 100 | Settings.settings 101 | True 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | MnFrm.vb 110 | 111 | 112 | VbMyResourcesResXFileCodeGenerator 113 | Resources.Designer.vb 114 | My.Resources 115 | Designer 116 | 117 | 118 | 119 | 120 | MyApplicationCodeGenerator 121 | Application.Designer.vb 122 | 123 | 124 | SettingsSingleFileGenerator 125 | My 126 | Settings.Designer.vb 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /MapDumper/MnFrm.Designer.vb: -------------------------------------------------------------------------------- 1 |  _ 2 | Partial Class MnFrm 3 | Inherits System.Windows.Forms.Form 4 | 5 | 'Form overrides dispose to clean up the component list. 6 | _ 7 | Protected Overrides Sub Dispose(ByVal disposing As Boolean) 8 | Try 9 | If disposing AndAlso components IsNot Nothing Then 10 | components.Dispose() 11 | End If 12 | Finally 13 | MyBase.Dispose(disposing) 14 | End Try 15 | End Sub 16 | 17 | 'Required by the Windows Form Designer 18 | Private components As System.ComponentModel.IContainer 19 | 20 | 'NOTE: The following procedure is required by the Windows Form Designer 21 | 'It can be modified using the Windows Form Designer. 22 | 'Do not modify it using the code editor. 23 | _ 24 | Private Sub InitializeComponent() 25 | Me.LoadButton = New System.Windows.Forms.Button() 26 | Me.fileOpenDialog = New System.Windows.Forms.OpenFileDialog() 27 | Me.GroupBox4 = New System.Windows.Forms.GroupBox() 28 | Me.ROMNameLabel = New System.Windows.Forms.Label() 29 | Me.MapNameList = New System.Windows.Forms.ComboBox() 30 | Me.MapsAndBanks = New System.Windows.Forms.TreeView() 31 | Me.ExportBttn = New System.Windows.Forms.Button() 32 | Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() 33 | Me.PictureBox1 = New System.Windows.Forms.PictureBox() 34 | Me.GroupBox4.SuspendLayout() 35 | CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit() 36 | Me.SuspendLayout() 37 | ' 38 | 'LoadButton 39 | ' 40 | Me.LoadButton.Location = New System.Drawing.Point(12, 12) 41 | Me.LoadButton.Name = "LoadButton" 42 | Me.LoadButton.Size = New System.Drawing.Size(136, 35) 43 | Me.LoadButton.TabIndex = 0 44 | Me.LoadButton.Text = "Load ROM" 45 | Me.LoadButton.UseVisualStyleBackColor = True 46 | ' 47 | 'fileOpenDialog 48 | ' 49 | Me.fileOpenDialog.FileName = "OpenFileDialog1" 50 | ' 51 | 'GroupBox4 52 | ' 53 | Me.GroupBox4.Controls.Add(Me.ROMNameLabel) 54 | Me.GroupBox4.Location = New System.Drawing.Point(13, 63) 55 | Me.GroupBox4.Margin = New System.Windows.Forms.Padding(4) 56 | Me.GroupBox4.Name = "GroupBox4" 57 | Me.GroupBox4.Padding = New System.Windows.Forms.Padding(4) 58 | Me.GroupBox4.Size = New System.Drawing.Size(179, 78) 59 | Me.GroupBox4.TabIndex = 13 60 | Me.GroupBox4.TabStop = False 61 | Me.GroupBox4.Text = "Game Loaded" 62 | ' 63 | 'ROMNameLabel 64 | ' 65 | Me.ROMNameLabel.Location = New System.Drawing.Point(8, 31) 66 | Me.ROMNameLabel.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) 67 | Me.ROMNameLabel.Name = "ROMNameLabel" 68 | Me.ROMNameLabel.Size = New System.Drawing.Size(137, 33) 69 | Me.ROMNameLabel.TabIndex = 0 70 | ' 71 | 'MapNameList 72 | ' 73 | Me.MapNameList.FormattingEnabled = True 74 | Me.MapNameList.Location = New System.Drawing.Point(12, 159) 75 | Me.MapNameList.Name = "MapNameList" 76 | Me.MapNameList.Size = New System.Drawing.Size(121, 24) 77 | Me.MapNameList.TabIndex = 15 78 | ' 79 | 'MapsAndBanks 80 | ' 81 | Me.MapsAndBanks.Location = New System.Drawing.Point(199, 12) 82 | Me.MapsAndBanks.Name = "MapsAndBanks" 83 | Me.MapsAndBanks.Size = New System.Drawing.Size(309, 368) 84 | Me.MapsAndBanks.TabIndex = 16 85 | ' 86 | 'ExportBttn 87 | ' 88 | Me.ExportBttn.Location = New System.Drawing.Point(514, 12) 89 | Me.ExportBttn.Name = "ExportBttn" 90 | Me.ExportBttn.Size = New System.Drawing.Size(71, 52) 91 | Me.ExportBttn.TabIndex = 17 92 | Me.ExportBttn.Text = "Export" 93 | Me.ExportBttn.UseVisualStyleBackColor = True 94 | ' 95 | 'PictureBox1 96 | ' 97 | Me.PictureBox1.Location = New System.Drawing.Point(597, 12) 98 | Me.PictureBox1.Name = "PictureBox1" 99 | Me.PictureBox1.Size = New System.Drawing.Size(252, 466) 100 | Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage 101 | Me.PictureBox1.TabIndex = 18 102 | Me.PictureBox1.TabStop = False 103 | ' 104 | 'MnFrm 105 | ' 106 | Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!) 107 | Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font 108 | Me.ClientSize = New System.Drawing.Size(861, 393) 109 | Me.Controls.Add(Me.PictureBox1) 110 | Me.Controls.Add(Me.ExportBttn) 111 | Me.Controls.Add(Me.MapsAndBanks) 112 | Me.Controls.Add(Me.MapNameList) 113 | Me.Controls.Add(Me.GroupBox4) 114 | Me.Controls.Add(Me.LoadButton) 115 | Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle 116 | Me.MaximizeBox = False 117 | Me.Name = "MnFrm" 118 | Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen 119 | Me.Text = "Map Dumper" 120 | Me.GroupBox4.ResumeLayout(False) 121 | CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit() 122 | Me.ResumeLayout(False) 123 | 124 | End Sub 125 | 126 | Friend WithEvents LoadButton As Button 127 | Friend WithEvents fileOpenDialog As OpenFileDialog 128 | Friend WithEvents GroupBox4 As GroupBox 129 | Friend WithEvents ROMNameLabel As Label 130 | Friend WithEvents MapNameList As ComboBox 131 | Friend WithEvents MapsAndBanks As TreeView 132 | Friend WithEvents ExportBttn As Button 133 | Friend WithEvents FolderBrowserDialog1 As FolderBrowserDialog 134 | Friend WithEvents PictureBox1 As PictureBox 135 | End Class 136 | -------------------------------------------------------------------------------- /MapDumper/MnFrm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 176, 17 125 | 126 | -------------------------------------------------------------------------------- /MapDumper/My Project/Application.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | 'NOTE: This file is auto-generated; do not modify it directly. To make changes, 18 | ' or if you encounter build errors in this file, go to the Project Designer 19 | ' (go to Project Properties or double-click the My Project node in 20 | ' Solution Explorer), and make changes on the Application tab. 21 | ' 22 | Partial Friend Class MyApplication 23 | 24 | _ 25 | Public Sub New() 26 | MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) 27 | Me.IsSingleInstance = false 28 | Me.EnableVisualStyles = true 29 | Me.SaveMySettingsOnExit = true 30 | Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses 31 | End Sub 32 | 33 | _ 34 | Protected Overrides Sub OnCreateMainForm() 35 | Me.MainForm = Global.MapDumper.MnFrm 36 | End Sub 37 | End Class 38 | End Namespace 39 | -------------------------------------------------------------------------------- /MapDumper/My Project/Application.myapp: -------------------------------------------------------------------------------- 1 |  2 | 3 | true 4 | Form1 5 | false 6 | 0 7 | true 8 | 0 9 | 0 10 | true 11 | 12 | -------------------------------------------------------------------------------- /MapDumper/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Reflection 3 | Imports System.Runtime.InteropServices 4 | 5 | ' General Information about an assembly is controlled through the following 6 | ' set of attributes. Change these attribute values to modify the information 7 | ' associated with an assembly. 8 | 9 | ' Review the values of the assembly attributes 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 'The following GUID is for the ID of the typelib if this project is exposed to COM 21 | 22 | 23 | ' Version information for an assembly consists of the following four values: 24 | ' 25 | ' Major Version 26 | ' Minor Version 27 | ' Build Number 28 | ' Revision 29 | ' 30 | ' You can specify all the values or you can default the Build and Revision Numbers 31 | ' by using the '*' as shown below: 32 | ' 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /MapDumper/My Project/Resources.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My.Resources 16 | 17 | 'This class was auto-generated by the StronglyTypedResourceBuilder 18 | 'class via a tool like ResGen or Visual Studio. 19 | 'To add or remove a member, edit your .ResX file then rerun ResGen 20 | 'with the /str option, or rebuild your VS project. 21 | ''' 22 | ''' A strongly-typed resource class, for looking up localized strings, etc. 23 | ''' 24 | _ 28 | Friend Module Resources 29 | 30 | Private resourceMan As Global.System.Resources.ResourceManager 31 | 32 | Private resourceCulture As Global.System.Globalization.CultureInfo 33 | 34 | ''' 35 | ''' Returns the cached ResourceManager instance used by this class. 36 | ''' 37 | _ 38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 39 | Get 40 | If Object.ReferenceEquals(resourceMan, Nothing) Then 41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("MapDumper.Resources", GetType(Resources).Assembly) 42 | resourceMan = temp 43 | End If 44 | Return resourceMan 45 | End Get 46 | End Property 47 | 48 | ''' 49 | ''' Overrides the current thread's CurrentUICulture property for all 50 | ''' resource lookups using this strongly typed resource class. 51 | ''' 52 | _ 53 | Friend Property Culture() As Global.System.Globalization.CultureInfo 54 | Get 55 | Return resourceCulture 56 | End Get 57 | Set(ByVal value As Global.System.Globalization.CultureInfo) 58 | resourceCulture = value 59 | End Set 60 | End Property 61 | End Module 62 | End Namespace 63 | -------------------------------------------------------------------------------- /MapDumper/My Project/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /MapDumper/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.MapDumper.My.MySettings 68 | Get 69 | Return Global.MapDumper.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /MapDumper/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MapDumper/NSELZZ.vb: -------------------------------------------------------------------------------- 1 | Imports System.Collections.Generic 2 | Imports System.Linq 3 | Imports System.Text 4 | 5 | Module NSELZZ 6 | 7 | Public Enum CheckLz77Type 8 | Sprite 9 | Palette 10 | End Enum 11 | 12 | 13 | Public Function DecompressBytes(Data__1 As Byte()) As Byte() 14 | Dim data__2 As Byte() 15 | If Data__1(0) = &H10 Then 16 | Dim DataLength As Integer = BitConverter.ToInt32(New [Byte]() {Data__1(1), Data__1(2), Data__1(3), &H0}, 0) 17 | data__2 = New [Byte](DataLength - 1) {} 18 | 19 | Dim Offset As Integer = 4 20 | 21 | Dim watch As String = "" 22 | Dim i As Integer = 0 23 | Dim pos As Byte = 8 24 | 25 | While i < DataLength 26 | 'br.BaseStream.Seek(Offset, SeekOrigin.Begin); 27 | If pos <> 8 Then 28 | If watch(pos) = "0"(0) Then 29 | 'data[i] = br.ReadByte(); 30 | data__2(i) = Data__1(Offset) 31 | Else 32 | 'byte[] r = br.ReadBytes(2); 33 | Dim r As Byte() = New Byte() {Data__1(Offset), Data__1(Offset + 1)} 34 | Dim length As Integer = r(0) >> 4 35 | Dim start As Integer = ((r(0) - ((r(0) >> 4) << 4)) << 8) + r(1) 36 | AmmendArray(data__2, i, i - start - 1, length + 3) 37 | Offset += 1 38 | End If 39 | Offset += 1 40 | i += 1 41 | 42 | pos += 1 43 | Else 44 | 'watch = Convert.ToString(br.ReadByte(), 2); 45 | watch = Convert.ToString(Data__1(Offset), 2) 46 | While watch.Length <> 8 47 | watch = Convert.ToString("0") & watch 48 | End While 49 | Offset += 1 50 | pos = 0 51 | End If 52 | End While 53 | 'br.Close(); 54 | 55 | 56 | Return data__2 57 | Else 58 | Throw New Exception("This data is not Lz77 compressed!") 59 | End If 60 | End Function 61 | 62 | Private Sub AmmendArray(ByRef Bytes As Byte(), ByRef Index As Integer, Start As Integer, Length As Integer) 63 | Dim a As Integer = 0 64 | ' Act 65 | Dim r As Integer = 0 66 | ' Rel 67 | Dim Backup As Byte = 0 68 | 69 | If Index > 0 Then 70 | Backup = Bytes(Index - 1) 71 | End If 72 | 73 | While a <> Length 74 | If Index + r >= 0 AndAlso Start + r >= 0 AndAlso Index + a < Bytes.Length Then 75 | If Start + r >= Index Then 76 | r = 0 77 | Bytes(Index + a) = Bytes(Start + r) 78 | Else 79 | Bytes(Index + a) = Bytes(Start + r) 80 | Backup = Bytes(Index + r) 81 | End If 82 | End If 83 | a += 1 84 | r += 1 85 | End While 86 | 87 | Index += Length - 1 88 | End Sub 89 | 90 | 91 | ' For picking what type of Compression Look-up we want 92 | Public Enum CompressionMode 93 | Old 94 | ' Good 95 | [New] 96 | ' Perfect! 97 | End Enum 98 | 99 | Public Function CompressBytes(Data As Byte(), Optional Mode As CompressionMode = CompressionMode.[New]) As Byte() 100 | Dim header As Byte() = BitConverter.GetBytes(Data.Length) 101 | Dim Bytes As New List(Of Byte)() 102 | Dim PreBytes As New List(Of Byte)() 103 | Dim Watch As Byte = 0 104 | Dim ShortPosition As Byte = 2 105 | Dim ActualPosition As Integer = 2 106 | Dim match As Integer = -1 107 | 108 | Dim BestLength As Integer = 0 109 | 110 | ' Adds the Lz77 header to the bytes 0x10 3 bytes size reversed 111 | Bytes.Add(&H10) 112 | Bytes.Add(header(0)) 113 | Bytes.Add(header(1)) 114 | Bytes.Add(header(2)) 115 | 116 | ' Lz77 Compression requires SOME starting data, so we provide the first 2 bytes 117 | PreBytes.Add(Data(0)) 118 | PreBytes.Add(Data(1)) 119 | 120 | ' Compress everything 121 | While ActualPosition < Data.Length 122 | 'If we've compressed 8 of 8 bytes 123 | If ShortPosition = 8 Then 124 | ' Add the Watch Mask 125 | ' Add the 8 steps in PreBytes 126 | Bytes.Add(Watch) 127 | Bytes.AddRange(PreBytes) 128 | 129 | Watch = 0 130 | PreBytes.Clear() 131 | 132 | ' Back to 0 of 8 compressed bytes 133 | ShortPosition = 0 134 | Else 135 | ' If we are approaching the end 136 | If ActualPosition + 1 < Data.Length Then 137 | ' Old NSE 1.x compression lookup 138 | If Mode = CompressionMode.Old Then 139 | match = SearchBytesOld(Data, ActualPosition, Math.Min(4096, ActualPosition)) 140 | ElseIf Mode = CompressionMode.[New] Then 141 | ' New NSE 2.x compression lookup 142 | match = SearchBytes(Data, ActualPosition, Math.Min(4096, ActualPosition), BestLength) 143 | End If 144 | Else 145 | match = -1 146 | End If 147 | 148 | ' If we have NOT found a match in the compression lookup 149 | If match = -1 Then 150 | ' Add the byte 151 | PreBytes.Add(Data(ActualPosition)) 152 | ' Add a 0 to the mask 153 | Watch = BitConverter.GetBytes(CInt(Watch) << 1)(0) 154 | 155 | ActualPosition += 1 156 | Else 157 | ' How many bytes match 158 | Dim length As Integer = -1 159 | 160 | Dim start As Integer = match 161 | If Mode = CompressionMode.Old OrElse BestLength = -1 Then 162 | ' Old look-up technique 163 | '#Region "GetLength_Old" 164 | start = match 165 | 166 | Dim Compatible As Boolean = True 167 | 168 | While Compatible = True AndAlso length < 18 AndAlso length + ActualPosition < Data.Length - 1 169 | length += 1 170 | If Data(ActualPosition + length) <> Data(ActualPosition - start + length) Then 171 | Compatible = False 172 | End If 173 | '#End Region 174 | End While 175 | ElseIf Mode = CompressionMode.[New] Then 176 | ' New lookup (Perfect Compression!) 177 | length = BestLength 178 | End If 179 | 180 | ' Add the rel-compression pointer (P) and length of bytes to copy (L) 181 | ' Format: L P P P 182 | Dim b As Byte() = BitConverter.GetBytes(((length - 3) << 12) + (start - 1)) 183 | 184 | b = New Byte() {b(1), b(0)} 185 | PreBytes.AddRange(b) 186 | 187 | ' Move to the next position 188 | ActualPosition += length 189 | 190 | ' Add a 1 to the bit Mask 191 | Watch = BitConverter.GetBytes((CInt(Watch) << 1) + 1)(0) 192 | End If 193 | 194 | ' We've just compressed 1 more 8 195 | ShortPosition += 1 196 | 197 | 198 | End If 199 | End While 200 | 201 | ' Finnish off the compression 202 | If ShortPosition <> 0 Then 203 | 'Tyeing up any left-over data compression 204 | Watch = BitConverter.GetBytes(CInt(Watch) << (8 - ShortPosition))(0) 205 | 206 | Bytes.Add(Watch) 207 | Bytes.AddRange(PreBytes) 208 | End If 209 | 210 | ' Return the Compressed bytes as an array! 211 | Return Bytes.ToArray() 212 | End Function 213 | 214 | Private Function SearchBytesOld(Data As Byte(), Index As Integer, Length As Integer) As Integer 215 | Dim found As Integer = -1 216 | Dim pos As Integer = 2 217 | 218 | If Index + 2 < Data.Length Then 219 | While pos < Length + 1 AndAlso found = -1 220 | If Data(Index - pos) = Data(Index) AndAlso Data(Index - pos + 1) = Data(Index + 1) Then 221 | 222 | If Index > 2 Then 223 | If Data(Index - pos + 2) = Data(Index + 2) Then 224 | found = pos 225 | Else 226 | pos += 1 227 | End If 228 | Else 229 | found = pos 230 | 231 | 232 | End If 233 | Else 234 | pos += 1 235 | End If 236 | End While 237 | 238 | Return found 239 | Else 240 | Return -1 241 | End If 242 | 243 | End Function 244 | 245 | Private Function SearchBytes(Data As Byte(), Index As Integer, Length As Integer, ByRef match As Integer) As Integer 246 | 247 | Dim pos As Integer = 2 248 | match = 0 249 | Dim found As Integer = -1 250 | 251 | If Index + 2 < Data.Length Then 252 | While pos < Length + 1 AndAlso match <> 18 253 | If Data(Index - pos) = Data(Index) AndAlso Data(Index - pos + 1) = Data(Index + 1) Then 254 | 255 | If Index > 2 Then 256 | If Data(Index - pos + 2) = Data(Index + 2) Then 257 | Dim _match As Integer = 2 258 | Dim Compatible As Boolean = True 259 | While Compatible = True AndAlso _match < 18 AndAlso _match + Index < Data.Length - 1 260 | _match += 1 261 | If Data(Index + _match) <> Data(Index - pos + _match) Then 262 | Compatible = False 263 | End If 264 | End While 265 | If _match > match Then 266 | match = _match 267 | found = pos 268 | 269 | End If 270 | End If 271 | pos += 1 272 | Else 273 | found = pos 274 | match = -1 275 | pos += 1 276 | 277 | 278 | End If 279 | Else 280 | pos += 1 281 | End If 282 | End While 283 | 284 | Return found 285 | Else 286 | Return -1 287 | End If 288 | 289 | End Function 290 | 291 | 292 | 293 | 'Public Shared Function CheckLz77(read As Read, Offset As Integer, Type As CheckLz77Type) As Integer 294 | ' Return CheckLz77(read.ReadBytes(Offset, 5), Type) 295 | 'End Function 296 | 297 | Public Function CheckLz77(Header5Bytes As Byte(), Type As CheckLz77Type) As Integer 298 | If Header5Bytes(0) = &H10 Then 299 | Dim length As Integer = BitConverter.ToInt32(New [Byte]() {Header5Bytes(1), Header5Bytes(2), Header5Bytes(3), &H0}, 0) 300 | 301 | If Type = CheckLz77Type.Sprite AndAlso Header5Bytes(4) <= 63 AndAlso length >= 64 AndAlso length Mod 8 = 0 Then 302 | Return length 303 | ElseIf Type = CheckLz77Type.Palette AndAlso length = &H20 AndAlso Header5Bytes(4) <= 63 Then 304 | Return length 305 | Else 306 | Return -1 307 | 308 | 309 | End If 310 | Else 311 | Return -1 312 | End If 313 | End Function 314 | 315 | '======================================================= 316 | 'Service provided by Telerik (www.telerik.com) 317 | 'Conversion powered by NRefactory. 318 | 'Twitter: @telerik 319 | 'Facebook: facebook.com/telerik 320 | '======================================================= 321 | 322 | End Module 323 | -------------------------------------------------------------------------------- /MapDumper/WichuRomFunctions.vb: -------------------------------------------------------------------------------- 1 | Imports Microsoft.VisualBasic 2 | Imports Microsoft.VisualBasic.CompilerServices 3 | Imports System 4 | Imports System.IO 5 | Imports System.Runtime.CompilerServices 6 | Imports System.Text 7 | 8 | 'The following functions were extracted from A-series. All credit goes to it's programmer Wichu! 9 | 10 | Module WichuRomFunctions 11 | Public Function CompressLz77(ByRef data As Byte()) As Collection 12 | Dim position As Integer = 0 13 | Dim length As Integer = data.Length 14 | Dim collection3 As New Collection 15 | Dim collection As New Collection 16 | collection.Add(&H10, Nothing, Nothing, Nothing) 17 | collection.Add((length And &HFF), Nothing, Nothing, Nothing) 18 | collection.Add(((length >> 8) And &HFF), Nothing, Nothing, Nothing) 19 | collection.Add(((length >> &H10) And &HFF), Nothing, Nothing, Nothing) 20 | Do While (position < length) 21 | Dim item As Byte = 0 22 | collection3.Clear() 23 | Dim num4 As Integer = 0 24 | Do 25 | Dim numArray As Integer() = Lz77Search(data, position) 26 | If (numArray(0) > 2) Then 27 | collection3.Add(((((numArray(0) - 3) And 15) << 4) Or (((numArray(1) - 1) >> 8) And 15)), Nothing, Nothing, Nothing) 28 | collection3.Add(((numArray(1) - 1) And &HFF), Nothing, Nothing, Nothing) 29 | position = (position + numArray(0)) 30 | item = CByte((item Or (CInt(1) << (7 - num4)))) 31 | Else 32 | If (numArray(0) < 0) Then 33 | Exit Do 34 | End If 35 | collection3.Add(data(position), Nothing, Nothing, Nothing) 36 | position += 1 37 | End If 38 | num4 += 1 39 | Loop While (num4 <= 7) 40 | collection.Add(item, Nothing, Nothing, Nothing) 41 | Dim count As Integer = collection3.Count 42 | Dim i As Integer = 1 43 | Do While (i <= count) 44 | collection.Add(RuntimeHelpers.GetObjectValue(collection3.Item(i)), Nothing, Nothing, Nothing) 45 | i += 1 46 | Loop 47 | Loop 48 | Return collection 49 | End Function 50 | 51 | Public Function CompressLz77String(ByRef srcString As String) As String 52 | Dim length As Integer = 1 53 | Dim num3 As UInt32 = Len(CStr(srcString)) 54 | Dim str2 As String = (ChrW(16) & Conversions.ToString(Strings.Chr(CInt((num3 And &HFF)))) & Conversions.ToString(Strings.Chr(CInt(((num3 >> 8) And &HFF)))) & Conversions.ToString(Strings.Chr(CInt(((num3 >> &H10) And &HFF))))) 55 | Do While (length <= num3) 56 | Dim charCode As Byte = 0 57 | Dim str3 As String = "" 58 | Dim num5 As Integer = 0 59 | Do 60 | If (length > num3) Then 61 | Exit Do 62 | End If 63 | Dim num6 As Integer = &H12 64 | Dim num4 As Integer = Strings.InStr(1, Strings.Left(srcString, length), Strings.Mid(srcString, length, num6), CompareMethod.Binary) 65 | If ((num4 > 0) And ((length + num6) <= num3)) Then 66 | num4 = (length - num4) 67 | str3 = (str3 & Conversions.ToString(Strings.Chr(((((num6 - 3) And 15) << 4) + (((num4 - 1) >> 8) And 15)))) & Conversions.ToString(Strings.Chr(((num4 - 1) And &HFF)))) 68 | length = (length + num6) 69 | charCode = CByte((charCode Or (CInt(1) << (7 - num5)))) 70 | Else 71 | str3 = (str3 & Strings.Mid(srcString, length, 1)) 72 | length += 1 73 | End If 74 | num5 += 1 75 | Loop While (num5 <= 7) 76 | str2 = (str2 & Conversions.ToString(Strings.Chr(charCode)) & str3) 77 | Loop 78 | Do While ((str2.Length Mod 4) > 0) 79 | str2 = (str2 & ChrW(0)) 80 | Loop 81 | Return str2 82 | End Function 83 | 84 | Public Function ConvertByteArrayToString(ByRef ary As Byte()) As String 85 | Dim str2 As String = "" 86 | Dim num2 As Integer = (ary.Length - 1) 87 | Dim i As Integer = 0 88 | Do While (i <= num2) 89 | str2 = (str2 & Conversions.ToString(Strings.Chr(ary(i)))) 90 | i += 1 91 | Loop 92 | Return str2 93 | End Function 94 | 95 | Public Function ConvertCollectionToByteArray(ByRef col As Collection) As Byte() 96 | Dim buffer2 As Byte() = New Byte(((col.Count - 1) + 1) - 1) {} 97 | Dim count As Integer = col.Count 98 | Dim i As Integer = 1 99 | Do While (i <= count) 100 | buffer2((i - 1)) = Conversions.ToByte(col.Item(i)) 101 | i += 1 102 | Loop 103 | Return buffer2 104 | End Function 105 | 106 | Public Function ConvertStringToByteArray(ByRef str As String) As Byte() 107 | Dim buffer2 As Byte() = New Byte(((str.Length - 1) + 1) - 1) {} 108 | Dim num2 As Integer = (str.Length - 1) 109 | Dim i As Integer = 0 110 | Do While (i <= num2) 111 | buffer2(i) = CByte(Strings.Asc(Strings.Mid(str, (i + 1), 1))) 112 | i += 1 113 | Loop 114 | Return buffer2 115 | End Function 116 | 117 | Public Function FindNextFreeSpace(ByRef Stream As FileStream, ByVal length As Integer) As Integer 118 | Do While (Stream.Position < Stream.Length) 119 | Dim num As Byte = CByte(Stream.ReadByte) 120 | If ((num = 0) Or (num = &HFF)) Then 121 | Dim num3 As Integer = 1 122 | Dim num4 As Integer = CInt((Stream.Position - 1)) 123 | Do While ((num3 < length) And (Stream.Position < Stream.Length)) 124 | num = CByte(Stream.ReadByte) 125 | If ((num <> &HFF) And (num <> 0)) Then 126 | Exit Do 127 | End If 128 | num3 += 1 129 | Loop 130 | If (num3 = length) Then 131 | Return num4 132 | End If 133 | End If 134 | Do While ((Stream.Position Mod 4) > 0) 135 | Stream.ReadByte() 136 | Loop 137 | Loop 138 | Return -1 139 | End Function 140 | 141 | Public Function FromRSChar(ByVal ch As Byte) As Object 142 | Dim array As Byte() = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HFE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HAB, 0, 0, &HB7, &H5B, 0, 180, &H5C, &H5D, &HB9, &H2E, &HB8, &HAE, &HAD, &HBA, &HA1, &HA2, &HA3, &HA4, &HA5, &HA6, &HA7, &HA8, &HA9, 170, 240, &H36, 0, &H35, 0, &HAC, 0, &HBB, &HBC, &HBD, 190, &HBF, &HC0, &HC1, &HC2, &HC3, &HC4, &HC5, &HC6, &HC7, 200, &HC9, &HCA, &HCB, &HCC, &HCD, &HCE, &HCF, &HD0, &HD1, 210, &HD3, &HD4, 0, 0, 0, 0, 0, &HB3, &HD5, &HD6, &HD7, &HD8, &HD9, &HDA, &HDB, 220, &HDD, &HDE, &HDF, &HE0, &HE1, &HE2, &HE3, &HE4, &HE5, 230, &HE7, &HE8, &HE9, &HEA, &HEB, &HEC, &HED, &HEE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H52, 0, 0, 0, 0, 0, 0, 0, 0, &H2B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H2A, 0, 0, 0, 0, &H51, 1, 2, 0, 0, &HF1, 0, 0, 4, 5, 6, 7, 8, 9, 90, 11, 12, 0, 20, 13, 14, 15, 0, &HF2, 0, 0, &H11, &H12, &H13, &HF3, 0, 0, &H15, &H16, &H17, &H68, 0, &HF4, 0, 0, &H19, &H1A, &H1B, &H1C, &H1D, 30, &H6F, &H20, &H21, 0, &H29, &H22, &H23, &H24, 0, &HF5, 0, 0, &H26, &H27, 40, &HF6, 0, 0, 0, 0} 143 | 'Dim index As Integer = array.IndexOf(Of Byte)(array, ch) 144 | Dim index As Integer = System.Array.IndexOf(array, ch) 145 | If (index = -1) Then 146 | index = 0 147 | End If 148 | Return Strings.Chr(index) 149 | End Function 150 | 151 | Public Function GetDoublePointerTable(ByRef Stream As FileStream, ByVal length As Integer) As UInt32() 152 | Dim numArray2 As UInt32() = New UInt32(((length - 1) + 1) - 1) {} 153 | Dim num3 As Integer = (length - 1) 154 | Dim i As Integer = 0 155 | Do While (i <= num3) 156 | Dim streamvar As Stream = Stream 157 | streamvar = DirectCast(streamvar, FileStream) 158 | Dim num As UInt32 = Conversions.ToUInteger(GetDWord(streamvar)) 159 | If (num > &H8000000) Then 160 | numArray2(i) = (num - &H8000000) 161 | streamvar.Seek(4, SeekOrigin.Current) 162 | End If 163 | i += 1 164 | Loop 165 | Return numArray2 166 | End Function 167 | 168 | Public Function GetDWord(ByRef streaminput As Stream) As Object 169 | Dim num As UInt32 = streaminput.ReadByte 170 | num = (num Or (Convert.ToUInt32(streaminput.ReadByte) << 8)) 171 | num = (num Or (Convert.ToUInt32(streaminput.ReadByte) << &H10)) 172 | Return (num Or (Convert.ToUInt32(streaminput.ReadByte) << &H18)) 173 | End Function 174 | 175 | Public Function GetGameCode(ByRef filename As String) As String 176 | Dim stream As New FileStream(filename, FileMode.Open) 177 | Dim reader As New StreamReader(stream, Encoding.ASCII) 178 | Dim str As String = "" 179 | stream.Seek(&HAC, SeekOrigin.Begin) 180 | Dim num As Integer = 0 181 | Do 182 | str = (str & Conversions.ToString(Strings.Chr(reader.Read))) 183 | num += 1 184 | Loop While (num <= 3) 185 | reader.Close() 186 | stream.Close() 187 | Return str 188 | End Function 189 | 190 | Public Function GetLz77UncompressedLength(ByRef stream As FileStream) As Integer 191 | Dim num2 As Integer = 0 192 | If (stream.ReadByte <> &H10) Then 193 | Interaction.MsgBox("Data is not LZ77 compressed!", MsgBoxStyle.ApplicationModal, Nothing) 194 | Return 0 195 | End If 196 | num2 = (stream.ReadByte + (stream.ReadByte << 8)) 197 | Return (num2 + (stream.ReadByte << &H10)) 198 | End Function 199 | 200 | Public Function GetSinglePointerTable(ByRef streaminput As FileStream, ByVal length As Integer) As UInt32() 201 | Dim numArray2 As UInt32() = New UInt32(((length - 1) + 1) - 1) {} 202 | Dim num3 As Integer = (length - 1) 203 | Dim i As Integer = 0 204 | Do While (i <= num3) 205 | Dim stream As Stream = streaminput 206 | stream = DirectCast(stream, FileStream) 207 | Dim num As UInt32 = Conversions.ToUInteger(GetDWord(stream)) 208 | If (num > &H8000000) Then 209 | numArray2(i) = (num - (&H8000000)) 210 | End If 211 | i += 1 212 | Loop 213 | Return numArray2 214 | End Function 215 | 216 | Public Function GetWord(ByRef stream As Stream) As Object 217 | Dim num As UInt16 = CUShort(stream.ReadByte) 218 | Return CUShort((num Or CUShort((Convert.ToUInt16(stream.ReadByte) << 8)))) 219 | End Function 220 | 221 | Public Function LoadString(ByRef Stream As FileStream, ByVal length As Integer) As Object 222 | Dim chArray As Char() = New Char(((length - 1) + 1) - 1) {} 223 | Dim flag As Boolean = False 224 | Dim num3 As Integer = (length - 1) 225 | Dim i As Integer = 0 226 | Do While (i <= num3) 227 | Dim ch As Byte = CByte(Stream.ReadByte) 228 | If Not flag Then 229 | Select Case ch 230 | Case &HFF 231 | flag = True 232 | Continue Do 233 | Case 0 234 | chArray(i) = "?"c 235 | Continue Do 236 | End Select 237 | chArray(i) = Conversions.ToChar(FromRSChar(ch)) 238 | End If 239 | i += 1 240 | Loop 241 | Return Convert.ToString(New String(chArray)) 242 | End Function 243 | 244 | Public Function Lz77Search(ByRef data As Byte(), ByVal position As Integer) As Integer() 245 | Dim length As Integer = data.Length 246 | Dim numArray2 As Integer() = New Integer(2 - 1) {} 247 | Dim collection As New Collection 248 | If ((position < 3) Or ((length - position) < 3)) Then 249 | numArray2(0) = 0 250 | numArray2(1) = 0 251 | Return numArray2 252 | End If 253 | If (position >= length) Then 254 | numArray2(0) = -1 255 | numArray2(1) = 0 256 | Return numArray2 257 | End If 258 | Dim num4 As Integer = &H1000 259 | If (num4 > position) Then 260 | num4 = position 261 | End If 262 | Dim num6 As Integer = (num4 - 1) 263 | Dim i As Integer = 0 264 | Do While (i <= num6) 265 | If (data(((position - i) - 1)) = data(position)) Then 266 | collection.Add((i + 1), Nothing, Nothing, Nothing) 267 | End If 268 | i += 1 269 | Loop 270 | If (collection.Count = 0) Then 271 | numArray2(0) = 0 272 | numArray2(1) = 0 273 | Return numArray2 274 | End If 275 | Dim left As Byte = 0 276 | Dim flag As Boolean = False 277 | Do While (left < &H12) 278 | left = CByte((left + 1)) 279 | Dim j As Integer 280 | For j = 0 To collection.Count - 1 281 | If ((position + left) >= data.Length) Then 282 | flag = True 283 | ElseIf (data((position + left)) <> data(Conversions.ToInteger(Operators.AddObject(Operators.SubtractObject(position, collection.Item((j + 1))), Operators.ModObject(left, collection.Item((j + 1))))))) Then 284 | If (collection.Count > 1) Then 285 | collection.Remove(CInt((j + 1))) 286 | j -= 1 287 | Else 288 | flag = True 289 | End If 290 | End If 291 | If flag Then 292 | Exit For 293 | End If 294 | Next j 295 | If flag Then 296 | Exit Do 297 | End If 298 | Loop 299 | numArray2(0) = left 300 | numArray2(1) = Conversions.ToInteger(collection.Item(1)) 301 | Return numArray2 302 | End Function 303 | 304 | Public Sub SetDWord(ByRef stream As Stream, ByVal dword As UInt32) 305 | stream.WriteByte(CByte((dword And &HFF))) 306 | stream.WriteByte(CByte(((dword >> 8) And &HFF))) 307 | stream.WriteByte(CByte(((dword >> &H10) And &HFF))) 308 | stream.WriteByte(CByte(((dword >> 0) And &HFF))) 309 | End Sub 310 | 311 | Public Sub SetOffset(ByRef stream As Stream, ByVal offset As UInt32) 312 | stream.WriteByte(CByte((offset And &HFF))) 313 | stream.WriteByte(CByte(((offset >> 8) And &HFF))) 314 | stream.WriteByte(CByte(((offset >> &H10) And &HFF))) 315 | stream.WriteByte(8) 316 | End Sub 317 | 318 | Public Sub SetWord(ByRef stream As Stream, ByVal word As UInt16) 319 | stream.WriteByte(CByte((word And &HFF))) 320 | stream.WriteByte(CByte((CUShort((word >> 8)) And &HFF))) 321 | End Sub 322 | 323 | Public Sub ToNextValidOffset(ByRef Stream As FileStream) 324 | Do While ((Stream.Position Mod 4) > 0) 325 | Stream.ReadByte() 326 | Loop 327 | End Sub 328 | 329 | Public Function ToRSChar(ByVal [chr] As Char) As Object 330 | Dim buffer As Byte() = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HFE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HAB, 0, 0, &HB7, &H5B, 0, 180, &H5C, &H5D, &HB9, &H2E, &HB8, &HAE, &HAD, &HBA, &HA1, &HA2, &HA3, &HA4, &HA5, &HA6, &HA7, &HA8, &HA9, 170, 240, &H36, 0, &H35, 0, &HAC, 0, &HBB, &HBC, &HBD, 190, &HBF, &HC0, &HC1, &HC2, &HC3, &HC4, &HC5, &HC6, &HC7, 200, &HC9, &HCA, &HCB, &HCC, &HCD, &HCE, &HCF, &HD0, &HD1, 210, &HD3, &HD4, 0, 0, 0, 0, 0, &HB3, &HD5, &HD6, &HD7, &HD8, &HD9, &HDA, &HDB, 220, &HDD, &HDE, &HDF, &HE0, &HE1, &HE2, &HE3, &HE4, &HE5, 230, &HE7, &HE8, &HE9, &HEA, &HEB, &HEC, &HED, &HEE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H52, 0, 0, 0, 0, 0, 0, 0, 0, &H2B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H2A, 0, 0, 0, 0, &H51, 1, 2, 0, 0, &HF1, 0, 0, 4, 5, 6, 7, 8, 9, 90, 11, 12, 0, 20, 13, 14, 15, 0, &HF2, 0, 0, &H11, &H12, &H13, &HF3, 0, 0, &H15, &H16, &H17, &H68, 0, &HF4, 0, 0, &H19, &H1A, &H1B, &H1C, &H1D, 30, &H6F, &H20, &H21, 0, &H29, &H22, &H23, &H24, 0, &HF5, 0, 0, &H26, &H27, 40, &HF6, 0, 0, 0, 0} 331 | Return buffer(Strings.Asc([chr])) 332 | End Function 333 | 334 | Public Function UncompressLZ77(ByRef Stream As FileStream) As Byte() 335 | Return UncompressLZ77(Stream, True) 336 | End Function 337 | 338 | Public Function UncompressLZ77(ByRef Stream As FileStream, ByVal message As Boolean) As Byte() 339 | Dim num7 As UInt32 340 | Dim array As Byte() = New Byte(0 - 1) {} 341 | If (Stream.ReadByte <> &H10) Then 342 | If message Then 343 | Interaction.MsgBox("Data is not LZ77 compressed!", MsgBoxStyle.ApplicationModal, Nothing) 344 | End If 345 | Return array 346 | End If 347 | Dim num6 As UInt32 = Stream.ReadByte 348 | num6 = (num6 + (Stream.ReadByte << 8)) 349 | num6 = (num6 + (Stream.ReadByte << &H10)) 350 | If (num6 > &H2404) Then 351 | If message Then 352 | Interaction.MsgBox("Invalid LZ77 offset", MsgBoxStyle.ApplicationModal, Nothing) 353 | End If 354 | Return array 355 | End If 356 | array.Resize(array, CInt(num6)) 357 | Do While (num7 < num6) 358 | Dim num3 As Byte = CByte(Stream.ReadByte) 359 | Dim num8 As Integer = 0 360 | Do 361 | If ((num3 And &H80) > 0) Then 362 | Dim num2 As UInt32 = Stream.ReadByte 363 | Dim num5 As UInt32 = Stream.ReadByte 364 | Dim num4 As UInt32 = ((((num2 << 8) + num5) And &HFFF) + CULng(1)) 365 | Dim num As UInt32 = (CULng(3) + ((num2 >> 4) And 15)) 366 | If (num4 > num7) Then 367 | Return array 368 | End If 369 | Dim num10 As Long = (num - 1) 370 | Dim i As Long = 0 371 | Do While (i <= num10) 372 | If ((num7 + i) >= num6) Then 373 | Exit Do 374 | End If 375 | array(CInt((num7 + i))) = array(CInt(((num7 - num4) + (i Mod CULng(num4))))) 376 | i = (i + 1) 377 | Loop 378 | num7 = (num7 + num) 379 | Else 380 | array(num7) = CByte(Stream.ReadByte) 381 | 382 | num7 = (num7 + 1) 383 | End If 384 | If (num7 >= num6) Then 385 | Return array 386 | End If 387 | num3 = CByte((num3 << 1)) 388 | num8 += 1 389 | Loop While (num8 <= 7) 390 | Loop 391 | Return array 392 | End Function 393 | End Module 394 | -------------------------------------------------------------------------------- /MapDumper/WichuSpriteFunctions.vb: -------------------------------------------------------------------------------- 1 | Imports Microsoft.VisualBasic 2 | Imports Microsoft.VisualBasic.CompilerServices 3 | Imports System 4 | Imports System.Drawing 5 | Imports System.IO 6 | Imports System.Linq 7 | 8 | 'The following functions were extracted from A-series. All credit goes to it's programmer Wichu! 9 | 10 | Module WichuSpriteFunctions 11 | 12 | Public Sub BitmapBLT(ByRef srcBitmap As Bitmap, ByRef destBitmap As Bitmap, ByVal destX As Integer, ByVal destY As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal width As Integer, ByVal height As Integer) 13 | Dim num As Integer = 0 14 | Dim i As Integer = 0 15 | Do While (num < width) 16 | Do While (i < height) 17 | If ((((((((((srcX + num) >= 0) And ((srcY + i) >= 0)) And ((destX + num) >= 0)) And ((destY + i) >= 0)) And ((srcX + num) < srcBitmap.Width)) And ((srcY + i) < srcBitmap.Height)) And ((destX + num) < destBitmap.Width)) And ((destY + i) < destBitmap.Height)) AndAlso (srcBitmap.GetPixel((srcX + num), (srcY + i)).A >= &H80)) Then 18 | destBitmap.SetPixel((destX + num), (destY + i), srcBitmap.GetPixel((srcX + num), (srcY + i))) 19 | End If 20 | i += 1 21 | Loop 22 | num += 1 23 | i = 0 24 | Loop 25 | End Sub 26 | 27 | Public Sub BitmapBLT(ByRef srcBitmap As Bitmap, ByRef destBitmap As Bitmap, ByVal destX As Integer, ByVal destY As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal width As Integer, ByVal height As Integer, ByRef bgcolor As Color) 28 | Dim num As Integer = 0 29 | Dim i As Integer = 0 30 | Do While (num < width) 31 | Do While (i < height) 32 | If (((((((((srcX + num) >= 0) And ((srcY + i) >= 0)) And ((destX + num) >= 0)) And ((destY + i) >= 0)) And ((srcX + num) < srcBitmap.Width)) And ((srcY + i) < srcBitmap.Height)) And ((destX + num) < destBitmap.Width)) And ((destY + i) < destBitmap.Height)) Then 33 | If (srcBitmap.GetPixel((srcX + num), (srcY + i)).A >= &H80) Then 34 | destBitmap.SetPixel((destX + num), (destY + i), srcBitmap.GetPixel((srcX + num), (srcY + i))) 35 | Else 36 | destBitmap.SetPixel((destX + num), (destY + i), bgcolor) 37 | End If 38 | End If 39 | i += 1 40 | Loop 41 | num += 1 42 | i = 0 43 | Loop 44 | End Sub 45 | 46 | Public Sub ClearBitmap(ByRef bitmap As Bitmap) 47 | FillBitmap(bitmap, Color.Transparent) 48 | End Sub 49 | 50 | Public Function ColorToRGB16(ByRef ARGBColor As Color) As UInt16 51 | Dim num4 As UInt16 = CByte((ARGBColor.R >> 3)) 52 | Dim num3 As UInt16 = CByte((ARGBColor.G >> 3)) 53 | Dim num As UInt16 = CByte((ARGBColor.B >> 3)) 54 | Return CUShort((CUShort((num4 + CUShort((num3 << 5)))) + CUShort((num << 10)))) 55 | End Function 56 | 57 | Public Sub ConvertBitmapToPalette(ByRef sprite As Bitmap, ByRef palette As Color(), ByVal AutoTransparency As Boolean) 58 | Dim pixel As Color 59 | Dim destinationArray As Color() = New Color(((palette.Length - 2) + 1) - 1) {} 60 | If AutoTransparency Then 61 | Array.Copy(palette, 1, destinationArray, 0, (palette.Length - 1)) 62 | pixel = sprite.GetPixel(0, 0) 63 | End If 64 | Dim num3 As Integer = (sprite.Width - 1) 65 | Dim i As Integer = 0 66 | Do While (i <= num3) 67 | Dim num4 As Integer = (sprite.Height - 1) 68 | Dim j As Integer = 0 69 | Do While (j <= num4) 70 | Dim col As Color = sprite.GetPixel(i, j) 71 | If AutoTransparency Then 72 | If (col = pixel) Then 73 | sprite.SetPixel(i, j, palette(0)) 74 | Else 75 | sprite.SetPixel(i, j, destinationArray(GetClosestColorFromPalette(col, destinationArray))) 76 | End If 77 | Else 78 | sprite.SetPixel(i, j, palette(GetClosestColorFromPalette(col, palette))) 79 | End If 80 | j += 1 81 | Loop 82 | i += 1 83 | Loop 84 | End Sub 85 | 86 | Public Sub ConvertBitmapToPalette2(ByRef sprite As Bitmap, ByRef palette As Color(), ByVal AutoTransparency As Boolean) 87 | Dim pixel As Color 88 | Dim destinationArray As Color() = New Color(((palette.Length - 2) + 1) - 1) {} 89 | If AutoTransparency Then 90 | Array.Copy(palette, 1, destinationArray, 0, (palette.Length - 1)) 91 | pixel = sprite.GetPixel(0, 0) 92 | End If 93 | Dim num3 As Integer = (sprite.Width - 1) 94 | Dim i As Integer = 0 95 | Do While (i <= num3) 96 | Dim num4 As Integer = (sprite.Height - 1) 97 | Dim j As Integer = 0 98 | Do While (j <= num4) 99 | Dim col As Color = sprite.GetPixel(i, j) 100 | If AutoTransparency Then 101 | If (col = pixel) Then 102 | sprite.SetPixel(i, j, palette(0)) 103 | Else 104 | sprite.SetPixel(i, j, destinationArray(GetClosestColorFromPalette2(col, destinationArray))) 105 | End If 106 | Else 107 | sprite.SetPixel(i, j, palette(GetClosestColorFromPalette2(col, palette))) 108 | End If 109 | j += 1 110 | Loop 111 | i += 1 112 | Loop 113 | End Sub 114 | 115 | Public Function ConvertPaletteToByteArray(ByRef palette As Color()) As Byte() 116 | Dim buffer2 As Byte() = New Byte(&H20 - 1) {} 117 | Dim index As Integer = 0 118 | Do 119 | Dim num As Integer = ColorToRGB16(palette(index)) 120 | buffer2((index * 2)) = CByte((num And &HFF)) 121 | buffer2(((index * 2) + 1)) = CByte(((num >> 8) And &HFF)) 122 | index += 1 123 | Loop While (index <= 15) 124 | Return buffer2 125 | End Function 126 | 127 | Public Function ConvertPaletteToString(ByRef palette As Color()) As String 128 | Dim str2 As String = "" 129 | Dim index As Integer = 0 130 | Do 131 | Dim num As UInt16 = ColorToRGB16(palette(index)) 132 | str2 = (str2 & Conversions.ToString(Strings.Chr((num And &HFF))) & Conversions.ToString(Strings.Chr((CUShort((num >> 8)) And &HFF)))) 133 | index += 1 134 | Loop While (index <= 15) 135 | Return str2 136 | End Function 137 | 138 | Public Sub CopyBitmap(ByRef srcBitmap As Bitmap, ByRef destBitmap As Bitmap) 139 | Dim x As Integer = 0 140 | Dim i As Integer = 0 141 | Do While (x < destBitmap.Width) 142 | Do While (i < destBitmap.Height) 143 | Dim pixel As Color = srcBitmap.GetPixel(x, i) 144 | If (pixel.A > &H7F) Then 145 | destBitmap.SetPixel(x, i, pixel) 146 | End If 147 | i += 1 148 | Loop 149 | x += 1 150 | i = 0 151 | Loop 152 | End Sub 153 | 154 | Public Sub FillBitmap(ByRef bitmap As Bitmap, ByRef color As Color) 155 | Dim x As Integer = 0 156 | Dim i As Integer = 0 157 | Do While (x < bitmap.Width) 158 | Do While (i < bitmap.Height) 159 | bitmap.SetPixel(x, i, color) 160 | i += 1 161 | Loop 162 | x += 1 163 | i = 0 164 | Loop 165 | End Sub 166 | 167 | Public Sub FillRect(ByRef bitmap As Bitmap, ByRef color As Color, ByVal ox As Integer, ByVal oy As Integer, ByVal width As Integer, ByVal height As Integer) 168 | Dim num As Integer = 0 169 | Dim num2 As Integer = 0 170 | If (width > (bitmap.Width - ox)) Then 171 | width = (bitmap.Width - ox) 172 | End If 173 | If (height > (bitmap.Width - oy)) Then 174 | height = (bitmap.Width - oy) 175 | End If 176 | Do While (num < width) 177 | Do While (num2 < height) 178 | bitmap.SetPixel((num + ox), (num2 + oy), color) 179 | num2 += 1 180 | Loop 181 | num += 1 182 | num2 = 0 183 | Loop 184 | End Sub 185 | 186 | Public Function GetBitmapPalette(ByRef sprite As Bitmap) As Color() 187 | Dim source As Color() = New Color(&H10 - 1) {} 188 | Dim index As Byte = 0 189 | Dim num4 As Integer = (sprite.Width - 1) 190 | Dim i As Integer = 0 191 | Do While (i <= num4) 192 | Dim num5 As Integer = (sprite.Height - 1) 193 | Dim j As Integer = 0 194 | Do While (j <= num5) 195 | Dim pixel As Color = sprite.GetPixel(i, j) 196 | If Not Enumerable.Contains(Of Color)(source, pixel) Then 197 | source(index) = pixel 198 | index = CByte((index + 1)) 199 | End If 200 | If (index > 15) Then 201 | Return source 202 | End If 203 | j += 1 204 | Loop 205 | i += 1 206 | Loop 207 | Return source 208 | End Function 209 | 210 | Public Function GetBottom(ByRef bitmap As Bitmap) As Integer 211 | Dim num As Integer 212 | Dim height As Integer = bitmap.Height 213 | Dim i As Integer = 1 214 | Do While (i <= height) 215 | Dim num5 As Integer = (bitmap.Height - 1) 216 | Dim j As Integer = 0 217 | Do While (j <= num5) 218 | If (bitmap.GetPixel(j, (bitmap.Height - i)).A > 0) Then 219 | Return (bitmap.Height - i) 220 | End If 221 | j += 1 222 | Loop 223 | i += 1 224 | Loop 225 | Return num 226 | End Function 227 | 228 | Public Function GetClosestColorFromPalette(ByRef col As Color, ByRef palette As Color()) As Byte 229 | Dim num2 As Integer 230 | Dim num As Integer = &H2FD 231 | col = QuantizeColor(col) 232 | Dim num6 As Integer = (palette.Length - 1) 233 | Dim i As Integer = 0 234 | Do While (i <= num6) 235 | Dim colorDifference As Integer = GetColorDifference(col, palette(i)) 236 | If (colorDifference < num) Then 237 | num = colorDifference 238 | num2 = i 239 | End If 240 | i += 1 241 | Loop 242 | Return CByte(num2) 243 | End Function 244 | 245 | Public Function GetClosestColorFromPalette2(ByRef col As Color, ByRef palette As Color()) As Byte 246 | Dim num2 As Integer 247 | Dim num As Integer = &H2FD 248 | 'col = QuantizeColor(col) 249 | Dim num6 As Integer = (palette.Length - 1) 250 | Dim i As Integer = 0 251 | Do While (i <= num6) 252 | If (col = palette(i)) Then 253 | num2 = i 254 | End If 255 | i += 1 256 | Loop 257 | Return CByte(num2) 258 | End Function 259 | 260 | Public Function GetClosestIndexedPixel(ByRef sprite As Bitmap, ByRef palette As Color(), ByVal x As UInt32, ByVal y As UInt32) As Byte 261 | Dim num As Byte 262 | Return num 263 | End Function 264 | 265 | Public Function GetClosestPalette(ByRef sprite As Bitmap, ByRef palettes As Color()()) As Byte 266 | Dim num2 As Byte 267 | Dim bitmapPalette As Color() = GetBitmapPalette(sprite) 268 | Dim num As Integer = -1 269 | Dim num7 As Integer = (palettes.Length - 1) 270 | Dim i As Integer = 0 271 | Do While (i <= num7) 272 | Dim num4 As Integer = 0 273 | Dim num8 As Integer = (bitmapPalette.Length - 1) 274 | Dim j As Integer = 0 275 | Do While (j <= num8) 276 | num4 = (num4 + GetColorDifference(bitmapPalette(j), palettes(i)(GetClosestColorFromPalette(bitmapPalette(j), palettes(i))))) 277 | j += 1 278 | Loop 279 | If ((num4 < num) Or (num < 0)) Then 280 | num = num4 281 | num2 = CByte(i) 282 | End If 283 | i += 1 284 | Loop 285 | Return num2 286 | End Function 287 | 288 | Public Function GetColorDifference(ByRef color1 As Color, ByRef color2 As Color) As Integer 289 | Dim r As Integer = color1.R 290 | Dim g As Integer = color1.G 291 | Dim b As Integer = color1.B 292 | r = (r - color2.R) 293 | g = (g - color2.G) 294 | b = (b - color2.B) 295 | Return (((r * r) + (g * g)) + (b * b)) 296 | End Function 297 | 298 | Public Function GetIndexedPixel(ByRef sprite As Bitmap, ByRef palette As Color(), ByVal x As UInt32, ByVal y As UInt32) As Byte 299 | Dim num As Byte 300 | Return num 301 | End Function 302 | 303 | Public Function GetNumColors(ByRef sprite As Bitmap) As Byte 304 | Dim source As Color() = New Color(&H10 - 1) {} 305 | Dim index As Byte = 0 306 | Dim num5 As Integer = (sprite.Width - 1) 307 | Dim i As Integer = 0 308 | Do While (i <= num5) 309 | Dim num6 As Integer = (sprite.Height - 1) 310 | Dim j As Integer = 0 311 | Do While (j <= num6) 312 | Dim pixel As Color = sprite.GetPixel(i, j) 313 | If Not Enumerable.Contains(Of Color)(source, pixel) Then 314 | source(index) = pixel 315 | index = CByte((index + 1)) 316 | End If 317 | If (index > 15) Then 318 | Return &H10 319 | End If 320 | j += 1 321 | Loop 322 | i += 1 323 | Loop 324 | Return index 325 | End Function 326 | 327 | Public Function GetQuantizedPixel(ByRef sprite As Bitmap, ByVal x As UInt32, ByVal y As UInt32) As Color 328 | Return QuantizeColor(sprite.GetPixel(CInt(x), CInt(y))) 329 | End Function 330 | 331 | Public Function GetTop(ByRef bitmap As Bitmap) As Integer 332 | Dim num As Integer 333 | Dim num4 As Integer = (bitmap.Height - 1) 334 | Dim i As Integer = 0 335 | Do While (i <= num4) 336 | Dim num5 As Integer = (bitmap.Height - 1) 337 | Dim j As Integer = 0 338 | Do While (j <= num5) 339 | If (bitmap.GetPixel(j, i).A > 0) Then 340 | Return i 341 | End If 342 | j += 1 343 | Loop 344 | i += 1 345 | Loop 346 | Return num 347 | End Function 348 | 349 | Public Sub LoadBitmapFromArray(ByRef ary As Byte(), ByRef palette As Color(), ByRef bitmap As Bitmap, ByVal width As Integer, ByVal height As Integer) 350 | Dim num7 As Double = ((CDbl(bitmap.Height) / 8) - 1) 351 | Dim i As Double = 0 352 | Do While (i <= num7) 353 | Dim num8 As Double = ((CDbl(bitmap.Width) / 8) - 1) 354 | Dim j As Double = 0 355 | Do While (j <= num8) 356 | Dim num5 As Integer = 0 357 | Do 358 | Dim num6 As Integer = 0 359 | Do 360 | If ((((i * 8) + num5) < height) And ((((j * 8) + (num6 * 2)) + 1) < width)) Then 361 | Dim num2 As Integer 362 | Dim num As Byte = ary(num2) 363 | bitmap.SetPixel(CInt(Math.Round(CDbl((((j * 8) + (num6 * 2)) + 1)))), CInt(Math.Round(CDbl(((i * 8) + num5)))), palette(CByte((num >> 4)))) 364 | bitmap.SetPixel(CInt(Math.Round(CDbl(((j * 8) + (num6 * 2))))), CInt(Math.Round(CDbl(((i * 8) + num5)))), palette((num And 15))) 365 | num2 += 1 366 | Else 367 | bitmap.SetPixel(CInt(Math.Round(CDbl((((j * 8) + (num6 * 2)) + 1)))), CInt(Math.Round(CDbl(((i * 8) + num5)))), Color.Transparent) 368 | bitmap.SetPixel(CInt(Math.Round(CDbl(((j * 8) + (num6 * 2))))), CInt(Math.Round(CDbl(((i * 8) + num5)))), Color.Transparent) 369 | End If 370 | num6 += 1 371 | Loop While (num6 <= 3) 372 | num5 += 1 373 | Loop While (num5 <= 7) 374 | j += 1 375 | Loop 376 | i += 1 377 | Loop 378 | End Sub 379 | 380 | Public Sub LoadBitmapFromArray(ByRef ary As Byte(), ByVal offset As UInt32, ByRef palette As Color(), ByRef bitmap As Bitmap, ByVal width As Integer, ByVal height As Integer) 381 | Dim index As Integer = CInt(offset) 382 | Dim num7 As Double = ((CDbl(bitmap.Height) / 8) - 1) 383 | Dim i As Double = 0 384 | Do While (i <= num7) 385 | Dim num8 As Double = ((CDbl(bitmap.Width) / 8) - 1) 386 | Dim j As Double = 0 387 | Do While (j <= num8) 388 | Dim num5 As Integer = 0 389 | Do 390 | Dim num6 As Integer = 0 391 | Do 392 | If ((((i * 8) + num5) < height) And ((((j * 8) + (num6 * 2)) + 1) < width)) Then 393 | Dim num As Byte = ary(index) 394 | bitmap.SetPixel(CInt(Math.Round(CDbl((((j * 8) + (num6 * 2)) + 1)))), CInt(Math.Round(CDbl(((i * 8) + num5)))), palette(CByte((num >> 4)))) 395 | bitmap.SetPixel(CInt(Math.Round(CDbl(((j * 8) + (num6 * 2))))), CInt(Math.Round(CDbl(((i * 8) + num5)))), palette((num And 15))) 396 | index += 1 397 | Else 398 | bitmap.SetPixel(CInt(Math.Round(CDbl((((j * 8) + (num6 * 2)) + 1)))), CInt(Math.Round(CDbl(((i * 8) + num5)))), Color.Transparent) 399 | bitmap.SetPixel(CInt(Math.Round(CDbl(((j * 8) + (num6 * 2))))), CInt(Math.Round(CDbl(((i * 8) + num5)))), Color.Transparent) 400 | End If 401 | num6 += 1 402 | Loop While (num6 <= 3) 403 | num5 += 1 404 | Loop While (num5 <= 7) 405 | j += 1 406 | Loop 407 | i += 1 408 | Loop 409 | End Sub 410 | 411 | 'Public Function LoadLz77CompressedPalette(ByRef Stream As FileStream, ByVal message As Boolean) As Color() 412 | ' Dim colorArray2 As Color() = New Color(&H10 - 1) {} 413 | ' Dim buffer As Byte() = RomFunctions.UncompressLZ77(Stream, message) 414 | ' If (buffer.Length <> 0) Then 415 | ' Dim index As Integer = 0 416 | ' Do 417 | ' Dim num As Integer = buffer(((index * 2) + 1)) 418 | ' num = (num << 8) 419 | ' num = (num Or buffer((index * 2))) 420 | ' colorArray2(index) = .RGB16ToColor(num) 421 | ' index += 1 422 | ' Loop While (index <= 15) 423 | ' End If 424 | ' Return colorArray2 425 | 'End Function 426 | 427 | 'Public Sub LoadLz77CompressedSprite(ByRef Stream As FileStream, ByVal offset As Integer, ByVal palette As Color(), ByRef bitmap As Bitmap) 428 | ' Dim ary As Byte() = RomFunctions.UncompressLZ77(Stream) 429 | ' LoadBitmapFromArray(ary, palette, bitmap, &H40, CInt(Math.Round(CDbl((CDbl(ary.Length) / 32))))) 430 | 'End Sub 431 | 432 | Public Function LoadPaletteFromROM(ByRef streaminput As FileStream) As Color() 433 | Dim colorArray2 As Color() = New Color(&H10 - 1) {} 434 | Dim index As Integer = 0 435 | Do 436 | Dim streamvar As Stream = streaminput 437 | streamvar = DirectCast(streamvar, FileStream) 438 | colorArray2(index) = RGB16ToColor(Conversions.ToInteger(GetWord(streamvar))) 439 | index += 1 440 | Loop While (index <= 15) 441 | Return colorArray2 442 | End Function 443 | 444 | Public Function QuantizeColor(ByRef col As Color) As Color 445 | If (col.A < &H80) Then 446 | Return Color.FromArgb(&HFF, &H70, &HC0, 160) 447 | End If 448 | Dim r As Byte = col.R 449 | Dim g As Byte = col.G 450 | Dim b As Byte = col.B 451 | r = CByte((r >> 3)) 452 | g = CByte((g >> 3)) 453 | b = CByte((b >> 3)) 454 | r = CByte((r << 3)) 455 | g = CByte((g << 3)) 456 | b = CByte((b << 3)) 457 | Return Color.FromArgb(&HFF, r, g, b) 458 | End Function 459 | 460 | Public Function RGB16ToColor(ByVal RGB16 As Integer) As Color 461 | Dim red As Byte = CByte(((RGB16 And &H1F) << 3)) 462 | Dim green As Byte = CByte((((RGB16 >> 5) And &H1F) << 3)) 463 | Dim blue As Byte = CByte((((RGB16 >> 10) And &H1F) << 3)) 464 | Return Color.FromArgb(&HFF, red, green, blue) 465 | End Function 466 | 467 | Public Function SaveBitmapToArray(ByRef bitmap As System.Drawing.Bitmap, ByRef palette As Color()) As Object 468 | Dim num As Integer = 0 469 | Dim numArray(CInt(Math.Round(CDbl((bitmap.Height * bitmap.Width)) / 2 - 1)) + 1 - 1) As Byte 470 | Dim height As Double = CDbl(bitmap.Height) / 8 - 1 471 | Dim num1 As Double = 0 472 | Do 473 | Dim width As Double = CDbl(bitmap.Width) / 8 - 1 474 | Dim num2 As Double = 0 475 | Do 476 | Dim num3 As Integer = 0 477 | Do 478 | Dim num4 As Integer = 0 479 | Do 480 | Dim num5 As Byte = CByte(Array.IndexOf(Of Color)(palette, bitmap.GetPixel(CInt(Math.Round(num2 * 8 + CDbl((num4 * 2)))), CInt(Math.Round(num1 * 8 + CDbl(num3)))))) 481 | Dim num6 As Byte = CByte(Array.IndexOf(Of Color)(palette, bitmap.GetPixel(CInt(Math.Round(num2 * 8 + CDbl((num4 * 2)) + 1)), CInt(Math.Round(num1 * 8 + CDbl(num3)))))) 482 | numArray(num) = CByte((num6 << 4)) Or num5 483 | num = num + 1 484 | num4 = num4 + 1 485 | Loop While num4 <= 3 486 | num3 = num3 + 1 487 | Loop While num3 <= 7 488 | num2 += 1 489 | Loop While num2 <= width 490 | num1 += 1 491 | Loop While num1 <= height 492 | Return numArray 493 | End Function 494 | 495 | Public Sub TransparentBitmap(ByRef bitmap As Bitmap) 496 | Dim x As Integer = 0 497 | Dim y As Integer = 0 498 | Dim pixel As Color = bitmap.GetPixel(0, 0) 499 | Do While (x < bitmap.Width) 500 | Do While (y < bitmap.Height) 501 | If (bitmap.GetPixel(x, y) = pixel) Then 502 | bitmap.SetPixel(x, y, Color.Transparent) 503 | End If 504 | y += 1 505 | Loop 506 | x += 1 507 | y = 0 508 | Loop 509 | End Sub 510 | 511 | 512 | End Module 513 | -------------------------------------------------------------------------------- /MapDumper/mMain.vb: -------------------------------------------------------------------------------- 1 | Imports System.IO 2 | 3 | 4 | 5 | Module mMain 6 | 7 | Public LoadedROM As String 8 | 'Public ledrom As ROM 9 | Public AppPath As String = System.AppDomain.CurrentDomain.BaseDirectory() & IIf(Right(System.AppDomain.CurrentDomain.BaseDirectory(), 1) = "\", "", "\") 10 | Public i As Integer 11 | Public FileNum As Integer 12 | Public header As String = "xxxx" 13 | Public header2 As String 14 | Public header3 As String 15 | Public lwut As String 16 | Public SkipVar As Integer 17 | Public x As Integer 18 | 19 | Public ExportName As String 20 | 21 | Public SelectedPath As String 22 | 23 | Public Point2MapBankPointers As Integer 24 | Public MapBankPointers As Integer 25 | Public BankPointer As Integer 26 | Public HeaderPointer As Integer 27 | Public MapBank As Integer 28 | Public MapNumber As Integer 29 | Public BankOffset As Integer 30 | Public HeaderOffset As Integer 31 | Public MapData As String 32 | Public Const TileSetSize As Integer = 16 33 | Public Const TileSize As Integer = 8 'constant used for tile sizes. 34 | Public Const TileWidth As Integer = 8 35 | Public Const TilesPerRow As Integer = 16 36 | 37 | Public Map_Footer As Integer 38 | Public Map_Events As Integer 39 | Public Map_Level_Scripts As Integer 40 | Public Map_Connection_Header As Integer 41 | 42 | Public LevelScript2Pointer As Integer 43 | Public LevelScript4Pointer As Integer 44 | 45 | Public Connection_Pointer As Integer 46 | Public Connection_Num As Integer 47 | 48 | Public NPC_Num As Integer 49 | Public Warp_Num As Integer 50 | Public Script_Event_Num As Integer 51 | Public SignPost_Num As Integer 52 | 53 | Public NPC_Pointer As Integer 54 | Public Warp_Pointer As Integer 55 | Public Script_Event_Pointer As Integer 56 | Public SignPost_Pointer As Integer 57 | 58 | Public MapHeight As Integer 59 | Public MapWidth As Integer 60 | Public BorderPointer As Integer 61 | Public MapDataPointer As Integer 62 | Public PrimaryTilesetPointer As Integer 63 | Public SecondaryTilesetPointer As Integer 64 | Public BorderHeight As Integer 65 | Public BorderWidth As Integer 66 | 67 | Public PrimaryTilesetCompression As Integer 68 | Public SecondaryTilesetCompression As Integer 69 | Public PrimaryImagePointer As Integer 70 | Public SecondaryImagePointer As Integer 71 | Public PrimaryPalPointer As Integer 72 | Public SecondaryPalPointer As Integer 73 | Public PrimaryBlockSetPointer As Integer 74 | Public SecondaryBlockSetPointer As Integer 75 | Public PrimaryBehaviourPointer As Integer 76 | Public SecondaryBehaviourPointer As Integer 77 | 78 | Public PrimaryPals As String 79 | Public SecondaryPals As String 80 | 81 | Public PrimaryTilesImg As String 82 | Public SecondaryTilesImg As String 83 | 84 | Public PrimaryBlocks As String 85 | Public SecondaryBlocks As String 86 | 87 | Public PrimaryBehaviors As String 88 | Public SecondaryBehaviors As String 89 | 90 | Public BorderData As String 91 | Public MapPermData As String 92 | 93 | Public Function GetINIFileLocation() 94 | 95 | If System.IO.File.Exists((LoadedROM).Substring(0, LoadedROM.Length - 4) & ".ini") = True Then 96 | 97 | Return (LoadedROM).Substring(0, LoadedROM.Length - 4) & ".ini" 98 | Else 99 | 100 | Return AppPath & "ini\roms.ini" 101 | End If 102 | 103 | End Function 104 | 105 | Public Function MakeFreeSpaceString(NeededLength As Integer, Optional NeedByteString As String = "FF") 106 | 107 | Dim PrivLoopVar As Integer 108 | Dim OutBuffThing As String = "" 109 | 110 | PrivLoopVar = 0 111 | 112 | While (PrivLoopVar < NeededLength) 113 | 114 | OutBuffThing = OutBuffThing & NeedByteString 115 | 116 | PrivLoopVar = PrivLoopVar + 1 117 | End While 118 | 119 | MakeFreeSpaceString = OutBuffThing 120 | End Function 121 | 122 | Public Function DecapString(input As String) As String 123 | 124 | Dim LoopVar As Integer 125 | Dim outputstring As String = "" 126 | Dim capflag As Boolean = True 127 | 128 | LoopVar = 0 129 | 130 | While LoopVar < Len(input) 131 | 132 | LoopVar = LoopVar + 1 133 | 134 | If GetChar(input, LoopVar) = " " Then 135 | outputstring = outputstring & " " 136 | capflag = True 137 | Else 138 | If capflag = True Then 139 | 140 | outputstring = outputstring & UCase(GetChar(input, LoopVar)) 141 | capflag = False 142 | 143 | ElseIf capflag = False Then 144 | 145 | outputstring = outputstring & LCase(GetChar(input, LoopVar)) 146 | 147 | End If 148 | End If 149 | 150 | End While 151 | 152 | DecapString = outputstring 153 | End Function 154 | 155 | Public Sub OutPutError(message As String) 156 | 157 | Dim errorfile As String = AppPath & "errors.txt" 158 | 159 | System.IO.File.AppendAllText(errorfile, message & vbCrLf) 160 | 161 | End Sub 162 | 163 | Public Function ByteToSignedInt(InputByte As Byte) As Integer 164 | Dim ReturnVar As Integer 165 | 166 | 167 | If InputByte > &H7F Then 168 | Dim BinaryVar As String = (Convert.ToString(InputByte, 2)) 169 | ReturnVar = ((Convert.ToInt32(Mid(BinaryVar, 2, 7), 2)) - 128) 170 | Else 171 | ReturnVar = InputByte 172 | End If 173 | 174 | ByteToSignedInt = ReturnVar 175 | 176 | End Function 177 | 178 | Public Function SignedIntToHex(InputInt As Integer) As String 179 | 180 | Dim ReturnVar As String 181 | 182 | 183 | If InputInt < 0 Then 184 | 185 | Dim BinaryVar As String = (Convert.ToString(InputInt + 128, 2)) 186 | BinaryVar = "1" & BinaryVar 187 | ReturnVar = Hex((Convert.ToInt32(BinaryVar, 2))) 188 | 189 | Else 190 | ReturnVar = Hex(InputInt) 191 | End If 192 | 193 | SignedIntToHex = ReturnVar 194 | 195 | End Function 196 | 197 | Public Function ByteArrayToHexString(inputarray As Byte()) As String 198 | 199 | Dim HexString As String = "" 200 | 201 | For Each b As Byte In inputarray 202 | HexString = HexString & MakeProperByte(b) 203 | Next 204 | 205 | ByteArrayToHexString = HexString 206 | End Function 207 | 208 | Public Function MakeProperByte(DaByte As Byte) As String 209 | Dim OutputByte As String 210 | 211 | 212 | If Len(Hex(DaByte)) = 1 Then 213 | OutputByte = "0" & Hex(DaByte) 214 | Else 215 | OutputByte = Hex(DaByte) 216 | End If 217 | 218 | MakeProperByte = OutputByte 219 | 220 | End Function 221 | 222 | 223 | 224 | Public Function Get2Bytes(bytesin As Byte(), local As Integer) As String 225 | 226 | Get2Bytes = MakeProperByte(bytesin(local)) & MakeProperByte(bytesin(local + 1)) 227 | 228 | End Function 229 | 230 | Public Function HexStringToByteArray(input As String) As Byte() 231 | 232 | Dim output((input.Length / 2) - 1) As Byte 233 | Dim loopvar As Integer 234 | 235 | loopvar = 0 236 | 237 | While loopvar < (input.Length / 2) 238 | 239 | If loopvar = 0 Then 240 | output(loopvar) = "&H" & input.Substring(loopvar * 2, 2) 241 | Else 242 | output(loopvar) = "&H" & input.Substring(loopvar * 2, 2) 243 | End If 244 | 245 | loopvar = loopvar + 1 246 | 247 | End While 248 | 249 | 250 | 251 | HexStringToByteArray = output 252 | End Function 253 | 254 | Public Function ColorToPalText(inputcolor As Color()) As String 255 | Dim output As String = "" 256 | Dim palsaveloop As Integer = 0 257 | 258 | output = output & "JASC-PAL" & vbCrLf 259 | output = output & "0100" & vbCrLf 260 | output = output & "16" & vbCrLf 261 | 262 | While palsaveloop < inputcolor.Count 263 | 264 | output = output & inputcolor(palsaveloop).R & " " & inputcolor(palsaveloop).G & " " & inputcolor(palsaveloop).B & vbCrLf 265 | 266 | palsaveloop = palsaveloop + 1 267 | End While 268 | 269 | Return output 270 | End Function 271 | 272 | 273 | End Module 274 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Please note that this is still in it's early stages and I have a full time job! If there is an issue, please create an issue on Github and be patient. Otherwise pull requests are always welcome! 2 | 3 | # Disassembly Tools 4 | Simple tools for working with decomps. These are made to fill needs I have and shared for others that may find them useful. 5 | 6 | aseriestodis - Converts an Aseries format image for use with the disassemblies. 7 | 8 | MapDumper - Exports maps from Fire Red or Emerald for use with Pokeemerald. 9 | -------------------------------------------------------------------------------- /aseriestodis/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /aseriestodis/HexFunctions.vb: -------------------------------------------------------------------------------- 1 | Option Strict Off 2 | Option Explicit On 3 | Module HexFunctions 4 | ' ------------------------------------------------ 5 | ' ---------------------------------------------------- 6 | ' -------------------------------------------------------- 7 | ' |----------HEX Editing Functions by: Darthatron----------| 8 | ' -------------------------------------------------------- 9 | ' |--When using these functions I must be credited fully.--| 10 | ' |--Check on Darthatron.Com for updates of this function--| 11 | ' |--as these are merely the BETA forms and may need some--| 12 | ' |--updates. If you find any bugs, please email them to:--| 13 | ' |--info@darthatron.com, thankyou: Regards, Darthatron.--| 14 | ' -------------------------------------------------------- 15 | ' ---------------------------------------------------- 16 | ' ------------------------------------------------ 17 | ' ------------------------------------------------ 18 | ' ----------You can't handle the truth!!---------- 19 | ' ------------------------------------------------ 20 | ' ------------------------------------------------ 21 | ' ---------------------------------------------------- 22 | ' -------------------------------------------------------- 23 | ' |----------Update 001: Sunday 18th May 2008----------| 24 | ' -------------------------------------------------------- 25 | ' |----Pretty much just fixed the WriteHEX Function, it----| 26 | ' |----------should be reasonably faster now. :)----------| 27 | ' -------------------------------------------------------- 28 | ' ---------------------------------------------------- 29 | ' ------------------------------------------------ 30 | 31 | Public Function ReverseHEX(ByRef HEXData As String) As String 32 | Dim iNum As Integer 33 | Dim HEXHolder As String = "" 34 | If Len(HEXData) / 2 <> Int(Len(HEXData) / 2) Then HEXData = "0" & HEXData 35 | 36 | For iNum = 0 To Len(HEXData) + 1 37 | If Len(HEXData) <= 1 Then GoTo EndNow 38 | HEXHolder = HEXHolder & Right(HEXData, 2) 39 | HEXData = Left(HEXData, Len(HEXData) - 2) 40 | Next iNum 41 | EndNow: 42 | ReverseHEX = HEXHolder 43 | End Function 44 | 45 | Public Function ReadHEX(ByRef FilePath As String, ByRef Start2 As Integer, ByRef Length As Integer) As String 46 | On Error GoTo ErrHandle 47 | Dim iFile As Integer 48 | Dim bytHex As Byte 49 | Dim sHex As String 50 | Dim i As Integer 51 | Dim Start As Integer 52 | 53 | Start = Start2 + 1 54 | 55 | iFile = FreeFile() 56 | sHex = "" 57 | i = 0 58 | FileOpen(iFile, FilePath, OpenMode.Binary) 59 | For i = Start To (Start + Length - 1) 60 | 'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 61 | FileGet(iFile, bytHex, i) 62 | sHex = sHex & Right("00" & Hex(bytHex), 2) 63 | Next i 64 | FileClose(iFile) 65 | ReadHEX = sHex 66 | Exit Function 67 | ErrHandle: 68 | MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error: " & Err.Number) 69 | End Function 70 | 71 | Public Function WriteHEX(ByRef FilePath As String, ByRef Start As Integer, ByRef Data As String) As Object 72 | On Error GoTo ErrHandle 73 | WriteHEX = 0 74 | Dim iFile As Integer 75 | Dim sPost As Integer 76 | Dim bytHex As Byte 77 | ' Start = Start + 1 78 | iFile = FreeFile 79 | sPost = 0 80 | 81 | If Len(Data) <> Int(Len(Data) / 2) * 2 Then Data = "0" & Data 82 | 83 | FileOpen(iFile, FilePath, OpenMode.Binary) 84 | 85 | Do While Len(Data) > 0 86 | bytHex = Int32.Parse((Mid(Data, 1, 2)), System.Globalization.NumberStyles.HexNumber) 87 | 'UPGRADE_WARNING: Put was upgraded to FilePut and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 88 | FilePut(iFile, bytHex, Start + 1 + sPost) 89 | Data = Right(Data, Len(Data) - 2) 90 | sPost = sPost + 1 91 | Loop 92 | FileClose(iFile) 93 | WriteHEX = 1 94 | Exit Function 95 | ErrHandle: 96 | MsgBox(Err.Description, MsgBoxStyle.OkOnly, "Error: " & Err.Number) 97 | 98 | End Function 99 | End Module -------------------------------------------------------------------------------- /aseriestodis/LZ77.vb: -------------------------------------------------------------------------------- 1 | Module LZ77 2 | Public LastStructSize As Integer 3 | 4 | Public Function Inc(ByVal variable As Long, Optional ByVal value As Integer = 1) 5 | Inc = variable 6 | variable = variable + value 7 | End Function 8 | 9 | Private Function Dec(ByVal Source As Long) 10 | Dec = Source 11 | Source = Source - 1 12 | End Function 13 | 14 | 'Decompress LZ77 data with the below function. 15 | Public Function LZ77UnComp(ByVal Source() As Byte, ByVal Dest() As Byte) As Integer 16 | On Error Resume Next 17 | Dim header As Integer 18 | header = (Source(0) Or (Source(1) * CInt(256)) Or (Source(2) * CInt(2 ^ 16)) Or (Source(3) * CInt(2 ^ 24))) 19 | Dim i As Integer 20 | Dim j As Integer 21 | Dim xIn As Integer = 4 22 | Dim xOut As Integer = 0 23 | Dim length As Integer 24 | Dim Offset As Integer 25 | Dim windowOffset As Integer 26 | Dim xLen As Integer = header \ 256 27 | Dim retLen As Integer = xLen 28 | Dim d As Byte 29 | Dim data As Integer 30 | retLen = xLen 31 | Do While xLen > 0 32 | d = Source(xIn) 33 | xIn = xIn + 1 34 | For i = 0 To 7 35 | If (d And &H80) <> 0 Then 36 | data = ((Source(xIn) * (2 ^ 8)) Or Source(xIn + 1)) 37 | 38 | xIn = xIn + 2 39 | length = (data \ 4096) + 3 '(2 ^ 12)) + 3 40 | Offset = (data And &HFFF) 41 | windowOffset = xOut - Offset - 1 42 | For j = 0 To length - 1 43 | dest(xOut) = dest(windowOffset) 44 | xOut = xOut + 1 45 | windowOffset = windowOffset + 1 46 | 47 | xLen = xLen - 1 48 | If xLen = 0 Then 49 | LZ77UnComp = retLen 50 | Exit Function 51 | End If 52 | Next j 53 | Else 54 | dest(xOut) = Source(xIn) 55 | xOut = xOut + 1 56 | xIn = xIn + 1 57 | 58 | xLen = xLen - 1 59 | If xLen = 0 Then 60 | LZ77UnComp = retLen 61 | Exit Function 62 | End If 63 | End If 64 | d = (d * 2) Mod 256 65 | Next i 66 | Loop 67 | LZ77UnComp = retLen 68 | LastStructSize = xIn 69 | End Function 70 | 71 | 'Compress data to the LZ77 format with the below function. 72 | Public Function LZ77Comp(ByVal decmpsize As Integer, ByVal Source() As Byte, ByVal dest() As Byte) As Integer 73 | Dim i As Integer 74 | Dim j As Integer 75 | Dim xIn As Integer 76 | Dim xOut As Integer 77 | 78 | Dim length As Integer 79 | Dim Offset As Integer 80 | Dim tmplen As Integer 81 | Dim tmpoff As Integer 82 | Dim tmpxin As Integer 83 | Dim tmpxout As Integer 84 | Dim bufxout As Integer 85 | Dim ctrl As Byte 86 | Dim xdata(0 To 7, 0 To 1) As Byte 87 | On Error GoTo endme 88 | dest(0) = &H10 'unknown byte? 89 | dest(1) = (decmpsize Mod 256) 90 | dest(2) = ((decmpsize \ 256) Mod 256) 91 | dest(3) = ((decmpsize \ (2 ^ 16)) Mod 256) 92 | 93 | Do While (decmpsize > tmpxin) 94 | ctrl = 0 95 | For i = 7 To 0 Step -1 96 | If (xIn < &H1000) Then 97 | j = xIn 98 | Else 99 | j = &H1000 100 | End If 101 | length = 0 102 | Offset = 0 103 | Do While (j > 1) 104 | tmpxin = xIn 105 | tmpxout = (xIn - j) 106 | Do While Source(Inc(tmpxin)) = Source(Inc(tmpxout)) 107 | If (tmpxin >= decmpsize) Then Exit Do 108 | Loop 109 | tmplen = (tmpxin - xIn - 1) 110 | tmpoff = (tmpxin - tmpxout - 1) 111 | If (tmplen > length) Then 112 | length = tmplen 113 | Offset = tmpoff 114 | End If 115 | If (length >= &H12) Then Exit Do 116 | Inc(j, -1) 117 | Loop 118 | If (length >= 3) Then 119 | ctrl = ctrl Or (1 * (2 ^ i)) 120 | If (length >= &H12) Then length = &H12 121 | xdata(i, 0) = (((length - 3) * (2 ^ 4)) Or (Offset \ 256)) 122 | xdata(i, 1) = (Offset Mod 256) 123 | Inc(xIn, length) 124 | Inc(bufxout, 2) 125 | Else 126 | xdata(i, 0) = Source(Inc(xIn)) 127 | Inc(bufxout) 128 | End If 129 | Next i 130 | dest(Inc(xOut) + 4) = ctrl 131 | For i = 7 To 0 Step -1 132 | dest(Inc(xOut) + 4) = xdata(i, 0) 133 | If ((ctrl And &H80) <> 0) Then dest(Inc(xOut) + 4) = xdata(i, 1) 134 | ctrl = (ctrl * 2) Mod 256 135 | If (decmpsize < tmpxin) Then Exit For 136 | Next i 137 | Loop 138 | endme: 139 | LZ77Comp = xOut + 4 140 | End Function 141 | End Module 142 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Application.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Application.myapp: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | false 5 | 0 6 | true 7 | 0 8 | 2 9 | true 10 | 11 | -------------------------------------------------------------------------------- /aseriestodis/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Reflection 3 | Imports System.Runtime.InteropServices 4 | 5 | ' General Information about an assembly is controlled through the following 6 | ' set of attributes. Change these attribute values to modify the information 7 | ' associated with an assembly. 8 | 9 | ' Review the values of the assembly attributes 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 'The following GUID is for the ID of the typelib if this project is exposed to COM 21 | 22 | 23 | ' Version information for an assembly consists of the following four values: 24 | ' 25 | ' Major Version 26 | ' Minor Version 27 | ' Build Number 28 | ' Revision 29 | ' 30 | ' You can specify all the values or you can default the Build and Revision Numbers 31 | ' by using the '*' as shown below: 32 | ' 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Resources.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | Imports System 15 | 16 | Namespace My.Resources 17 | 18 | 'This class was auto-generated by the StronglyTypedResourceBuilder 19 | 'class via a tool like ResGen or Visual Studio. 20 | 'To add or remove a member, edit your .ResX file then rerun ResGen 21 | 'with the /str option, or rebuild your VS project. 22 | ''' 23 | ''' A strongly-typed resource class, for looking up localized strings, etc. 24 | ''' 25 | _ 29 | Friend Module Resources 30 | 31 | Private resourceMan As Global.System.Resources.ResourceManager 32 | 33 | Private resourceCulture As Global.System.Globalization.CultureInfo 34 | 35 | ''' 36 | ''' Returns the cached ResourceManager instance used by this class. 37 | ''' 38 | _ 39 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 40 | Get 41 | If Object.ReferenceEquals(resourceMan, Nothing) Then 42 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("aseriestodis.Resources", GetType(Resources).Assembly) 43 | resourceMan = temp 44 | End If 45 | Return resourceMan 46 | End Get 47 | End Property 48 | 49 | ''' 50 | ''' Overrides the current thread's CurrentUICulture property for all 51 | ''' resource lookups using this strongly typed resource class. 52 | ''' 53 | _ 54 | Friend Property Culture() As Global.System.Globalization.CultureInfo 55 | Get 56 | Return resourceCulture 57 | End Get 58 | Set 59 | resourceCulture = value 60 | End Set 61 | End Property 62 | End Module 63 | End Namespace 64 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.aseriestodis.My.MySettings 68 | Get 69 | Return Global.aseriestodis.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /aseriestodis/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /aseriestodis/NSELZZ.vb: -------------------------------------------------------------------------------- 1 | Imports System.Collections.Generic 2 | Imports System.Linq 3 | Imports System.Text 4 | 5 | Module NSELZZ 6 | 7 | Public Enum CheckLz77Type 8 | Sprite 9 | Palette 10 | End Enum 11 | 12 | 13 | Public Function DecompressBytes(Data__1 As Byte()) As Byte() 14 | Dim data__2 As Byte() 15 | If Data__1(0) = &H10 Then 16 | Dim DataLength As Integer = BitConverter.ToInt32(New [Byte]() {Data__1(1), Data__1(2), Data__1(3), &H0}, 0) 17 | data__2 = New [Byte](DataLength - 1) {} 18 | 19 | Dim Offset As Integer = 4 20 | 21 | Dim watch As String = "" 22 | Dim i As Integer = 0 23 | Dim pos As Byte = 8 24 | 25 | While i < DataLength 26 | 'br.BaseStream.Seek(Offset, SeekOrigin.Begin); 27 | If pos <> 8 Then 28 | If watch(pos) = "0"(0) Then 29 | 'data[i] = br.ReadByte(); 30 | data__2(i) = Data__1(Offset) 31 | Else 32 | 'byte[] r = br.ReadBytes(2); 33 | Dim r As Byte() = New Byte() {Data__1(Offset), Data__1(Offset + 1)} 34 | Dim length As Integer = r(0) >> 4 35 | Dim start As Integer = ((r(0) - ((r(0) >> 4) << 4)) << 8) + r(1) 36 | AmmendArray(data__2, i, i - start - 1, length + 3) 37 | Offset += 1 38 | End If 39 | Offset += 1 40 | i += 1 41 | 42 | pos += 1 43 | Else 44 | 'watch = Convert.ToString(br.ReadByte(), 2); 45 | watch = Convert.ToString(Data__1(Offset), 2) 46 | While watch.Length <> 8 47 | watch = Convert.ToString("0") & watch 48 | End While 49 | Offset += 1 50 | pos = 0 51 | End If 52 | End While 53 | 'br.Close(); 54 | 55 | 56 | Return data__2 57 | Else 58 | Throw New Exception("This data is not Lz77 compressed!") 59 | End If 60 | End Function 61 | 62 | Private Sub AmmendArray(ByRef Bytes As Byte(), ByRef Index As Integer, Start As Integer, Length As Integer) 63 | Dim a As Integer = 0 64 | ' Act 65 | Dim r As Integer = 0 66 | ' Rel 67 | Dim Backup As Byte = 0 68 | 69 | If Index > 0 Then 70 | Backup = Bytes(Index - 1) 71 | End If 72 | 73 | While a <> Length 74 | If Index + r >= 0 AndAlso Start + r >= 0 AndAlso Index + a < Bytes.Length Then 75 | If Start + r >= Index Then 76 | r = 0 77 | Bytes(Index + a) = Bytes(Start + r) 78 | Else 79 | Bytes(Index + a) = Bytes(Start + r) 80 | Backup = Bytes(Index + r) 81 | End If 82 | End If 83 | a += 1 84 | r += 1 85 | End While 86 | 87 | Index += Length - 1 88 | End Sub 89 | 90 | 91 | ' For picking what type of Compression Look-up we want 92 | Public Enum CompressionMode 93 | Old 94 | ' Good 95 | [New] 96 | ' Perfect! 97 | End Enum 98 | 99 | Public Function CompressBytes(Data As Byte(), Optional Mode As CompressionMode = CompressionMode.[New]) As Byte() 100 | Dim header As Byte() = BitConverter.GetBytes(Data.Length) 101 | Dim Bytes As New List(Of Byte)() 102 | Dim PreBytes As New List(Of Byte)() 103 | Dim Watch As Byte = 0 104 | Dim ShortPosition As Byte = 2 105 | Dim ActualPosition As Integer = 2 106 | Dim match As Integer = -1 107 | 108 | Dim BestLength As Integer = 0 109 | 110 | ' Adds the Lz77 header to the bytes 0x10 3 bytes size reversed 111 | Bytes.Add(&H10) 112 | Bytes.Add(header(0)) 113 | Bytes.Add(header(1)) 114 | Bytes.Add(header(2)) 115 | 116 | ' Lz77 Compression requires SOME starting data, so we provide the first 2 bytes 117 | PreBytes.Add(Data(0)) 118 | PreBytes.Add(Data(1)) 119 | 120 | ' Compress everything 121 | While ActualPosition < Data.Length 122 | 'If we've compressed 8 of 8 bytes 123 | If ShortPosition = 8 Then 124 | ' Add the Watch Mask 125 | ' Add the 8 steps in PreBytes 126 | Bytes.Add(Watch) 127 | Bytes.AddRange(PreBytes) 128 | 129 | Watch = 0 130 | PreBytes.Clear() 131 | 132 | ' Back to 0 of 8 compressed bytes 133 | ShortPosition = 0 134 | Else 135 | ' If we are approaching the end 136 | If ActualPosition + 1 < Data.Length Then 137 | ' Old NSE 1.x compression lookup 138 | If Mode = CompressionMode.Old Then 139 | match = SearchBytesOld(Data, ActualPosition, Math.Min(4096, ActualPosition)) 140 | ElseIf Mode = CompressionMode.[New] Then 141 | ' New NSE 2.x compression lookup 142 | match = SearchBytes(Data, ActualPosition, Math.Min(4096, ActualPosition), BestLength) 143 | End If 144 | Else 145 | match = -1 146 | End If 147 | 148 | ' If we have NOT found a match in the compression lookup 149 | If match = -1 Then 150 | ' Add the byte 151 | PreBytes.Add(Data(ActualPosition)) 152 | ' Add a 0 to the mask 153 | Watch = BitConverter.GetBytes(CInt(Watch) << 1)(0) 154 | 155 | ActualPosition += 1 156 | Else 157 | ' How many bytes match 158 | Dim length As Integer = -1 159 | 160 | Dim start As Integer = match 161 | If Mode = CompressionMode.Old OrElse BestLength = -1 Then 162 | ' Old look-up technique 163 | '#Region "GetLength_Old" 164 | start = match 165 | 166 | Dim Compatible As Boolean = True 167 | 168 | While Compatible = True AndAlso length < 18 AndAlso length + ActualPosition < Data.Length - 1 169 | length += 1 170 | If Data(ActualPosition + length) <> Data(ActualPosition - start + length) Then 171 | Compatible = False 172 | End If 173 | '#End Region 174 | End While 175 | ElseIf Mode = CompressionMode.[New] Then 176 | ' New lookup (Perfect Compression!) 177 | length = BestLength 178 | End If 179 | 180 | ' Add the rel-compression pointer (P) and length of bytes to copy (L) 181 | ' Format: L P P P 182 | Dim b As Byte() = BitConverter.GetBytes(((length - 3) << 12) + (start - 1)) 183 | 184 | b = New Byte() {b(1), b(0)} 185 | PreBytes.AddRange(b) 186 | 187 | ' Move to the next position 188 | ActualPosition += length 189 | 190 | ' Add a 1 to the bit Mask 191 | Watch = BitConverter.GetBytes((CInt(Watch) << 1) + 1)(0) 192 | End If 193 | 194 | ' We've just compressed 1 more 8 195 | ShortPosition += 1 196 | 197 | 198 | End If 199 | End While 200 | 201 | ' Finnish off the compression 202 | If ShortPosition <> 0 Then 203 | 'Tyeing up any left-over data compression 204 | Watch = BitConverter.GetBytes(CInt(Watch) << (8 - ShortPosition))(0) 205 | 206 | Bytes.Add(Watch) 207 | Bytes.AddRange(PreBytes) 208 | End If 209 | 210 | ' Return the Compressed bytes as an array! 211 | Return Bytes.ToArray() 212 | End Function 213 | 214 | Private Function SearchBytesOld(Data As Byte(), Index As Integer, Length As Integer) As Integer 215 | Dim found As Integer = -1 216 | Dim pos As Integer = 2 217 | 218 | If Index + 2 < Data.Length Then 219 | While pos < Length + 1 AndAlso found = -1 220 | If Data(Index - pos) = Data(Index) AndAlso Data(Index - pos + 1) = Data(Index + 1) Then 221 | 222 | If Index > 2 Then 223 | If Data(Index - pos + 2) = Data(Index + 2) Then 224 | found = pos 225 | Else 226 | pos += 1 227 | End If 228 | Else 229 | found = pos 230 | 231 | 232 | End If 233 | Else 234 | pos += 1 235 | End If 236 | End While 237 | 238 | Return found 239 | Else 240 | Return -1 241 | End If 242 | 243 | End Function 244 | 245 | Private Function SearchBytes(Data As Byte(), Index As Integer, Length As Integer, ByRef match As Integer) As Integer 246 | 247 | Dim pos As Integer = 2 248 | match = 0 249 | Dim found As Integer = -1 250 | 251 | If Index + 2 < Data.Length Then 252 | While pos < Length + 1 AndAlso match <> 18 253 | If Data(Index - pos) = Data(Index) AndAlso Data(Index - pos + 1) = Data(Index + 1) Then 254 | 255 | If Index > 2 Then 256 | If Data(Index - pos + 2) = Data(Index + 2) Then 257 | Dim _match As Integer = 2 258 | Dim Compatible As Boolean = True 259 | While Compatible = True AndAlso _match < 18 AndAlso _match + Index < Data.Length - 1 260 | _match += 1 261 | If Data(Index + _match) <> Data(Index - pos + _match) Then 262 | Compatible = False 263 | End If 264 | End While 265 | If _match > match Then 266 | match = _match 267 | found = pos 268 | 269 | End If 270 | End If 271 | pos += 1 272 | Else 273 | found = pos 274 | match = -1 275 | pos += 1 276 | 277 | 278 | End If 279 | Else 280 | pos += 1 281 | End If 282 | End While 283 | 284 | Return found 285 | Else 286 | Return -1 287 | End If 288 | 289 | End Function 290 | 291 | 292 | 293 | 'Public Shared Function CheckLz77(read As Read, Offset As Integer, Type As CheckLz77Type) As Integer 294 | ' Return CheckLz77(read.ReadBytes(Offset, 5), Type) 295 | 'End Function 296 | 297 | Public Function CheckLz77(Header5Bytes As Byte(), Type As CheckLz77Type) As Integer 298 | If Header5Bytes(0) = &H10 Then 299 | Dim length As Integer = BitConverter.ToInt32(New [Byte]() {Header5Bytes(1), Header5Bytes(2), Header5Bytes(3), &H0}, 0) 300 | 301 | If Type = CheckLz77Type.Sprite AndAlso Header5Bytes(4) <= 63 AndAlso length >= 64 AndAlso length Mod 8 = 0 Then 302 | Return length 303 | ElseIf Type = CheckLz77Type.Palette AndAlso length = &H20 AndAlso Header5Bytes(4) <= 63 Then 304 | Return length 305 | Else 306 | Return -1 307 | 308 | 309 | End If 310 | Else 311 | Return -1 312 | End If 313 | End Function 314 | 315 | '======================================================= 316 | 'Service provided by Telerik (www.telerik.com) 317 | 'Conversion powered by NRefactory. 318 | 'Twitter: @telerik 319 | 'Facebook: facebook.com/telerik 320 | '======================================================= 321 | 322 | End Module 323 | -------------------------------------------------------------------------------- /aseriestodis/WichuRomFunctions.vb: -------------------------------------------------------------------------------- 1 | Imports Microsoft.VisualBasic 2 | Imports Microsoft.VisualBasic.CompilerServices 3 | Imports System 4 | Imports System.IO 5 | Imports System.Runtime.CompilerServices 6 | Imports System.Text 7 | 8 | 'The following functions were extracted from A-series. All credit goes to it's programmer Wichu! 9 | 10 | Module WichuRomFunctions 11 | Public Function CompressLz77(ByRef data As Byte()) As Collection 12 | Dim position As Integer = 0 13 | Dim length As Integer = data.Length 14 | Dim collection3 As New Collection 15 | Dim collection As New Collection 16 | collection.Add(&H10, Nothing, Nothing, Nothing) 17 | collection.Add((length And &HFF), Nothing, Nothing, Nothing) 18 | collection.Add(((length >> 8) And &HFF), Nothing, Nothing, Nothing) 19 | collection.Add(((length >> &H10) And &HFF), Nothing, Nothing, Nothing) 20 | Do While (position < length) 21 | Dim item As Byte = 0 22 | collection3.Clear() 23 | Dim num4 As Integer = 0 24 | Do 25 | Dim numArray As Integer() = Lz77Search(data, position) 26 | If (numArray(0) > 2) Then 27 | collection3.Add(((((numArray(0) - 3) And 15) << 4) Or (((numArray(1) - 1) >> 8) And 15)), Nothing, Nothing, Nothing) 28 | collection3.Add(((numArray(1) - 1) And &HFF), Nothing, Nothing, Nothing) 29 | position = (position + numArray(0)) 30 | item = CByte((item Or (CInt(1) << (7 - num4)))) 31 | Else 32 | If (numArray(0) < 0) Then 33 | Exit Do 34 | End If 35 | collection3.Add(data(position), Nothing, Nothing, Nothing) 36 | position += 1 37 | End If 38 | num4 += 1 39 | Loop While (num4 <= 7) 40 | collection.Add(item, Nothing, Nothing, Nothing) 41 | Dim count As Integer = collection3.Count 42 | Dim i As Integer = 1 43 | Do While (i <= count) 44 | collection.Add(RuntimeHelpers.GetObjectValue(collection3.Item(i)), Nothing, Nothing, Nothing) 45 | i += 1 46 | Loop 47 | Loop 48 | Return collection 49 | End Function 50 | 51 | Public Function CompressLz77String(ByRef srcString As String) As String 52 | Dim length As Integer = 1 53 | Dim num3 As UInt32 = Len(CStr(srcString)) 54 | Dim str2 As String = (ChrW(16) & Conversions.ToString(Strings.Chr(CInt((num3 And &HFF)))) & Conversions.ToString(Strings.Chr(CInt(((num3 >> 8) And &HFF)))) & Conversions.ToString(Strings.Chr(CInt(((num3 >> &H10) And &HFF))))) 55 | Do While (length <= num3) 56 | Dim charCode As Byte = 0 57 | Dim str3 As String = "" 58 | Dim num5 As Integer = 0 59 | Do 60 | If (length > num3) Then 61 | Exit Do 62 | End If 63 | Dim num6 As Integer = &H12 64 | Dim num4 As Integer = Strings.InStr(1, Strings.Left(srcString, length), Strings.Mid(srcString, length, num6), CompareMethod.Binary) 65 | If ((num4 > 0) And ((length + num6) <= num3)) Then 66 | num4 = (length - num4) 67 | str3 = (str3 & Conversions.ToString(Strings.Chr(((((num6 - 3) And 15) << 4) + (((num4 - 1) >> 8) And 15)))) & Conversions.ToString(Strings.Chr(((num4 - 1) And &HFF)))) 68 | length = (length + num6) 69 | charCode = CByte((charCode Or (CInt(1) << (7 - num5)))) 70 | Else 71 | str3 = (str3 & Strings.Mid(srcString, length, 1)) 72 | length += 1 73 | End If 74 | num5 += 1 75 | Loop While (num5 <= 7) 76 | str2 = (str2 & Conversions.ToString(Strings.Chr(charCode)) & str3) 77 | Loop 78 | Do While ((str2.Length Mod 4) > 0) 79 | str2 = (str2 & ChrW(0)) 80 | Loop 81 | Return str2 82 | End Function 83 | 84 | Public Function ConvertByteArrayToString(ByRef ary As Byte()) As String 85 | Dim str2 As String = "" 86 | Dim num2 As Integer = (ary.Length - 1) 87 | Dim i As Integer = 0 88 | Do While (i <= num2) 89 | str2 = (str2 & Conversions.ToString(Strings.Chr(ary(i)))) 90 | i += 1 91 | Loop 92 | Return str2 93 | End Function 94 | 95 | Public Function ConvertCollectionToByteArray(ByRef col As Collection) As Byte() 96 | Dim buffer2 As Byte() = New Byte(((col.Count - 1) + 1) - 1) {} 97 | Dim count As Integer = col.Count 98 | Dim i As Integer = 1 99 | Do While (i <= count) 100 | buffer2((i - 1)) = Conversions.ToByte(col.Item(i)) 101 | i += 1 102 | Loop 103 | Return buffer2 104 | End Function 105 | 106 | Public Function ConvertStringToByteArray(ByRef str As String) As Byte() 107 | Dim buffer2 As Byte() = New Byte(((str.Length - 1) + 1) - 1) {} 108 | Dim num2 As Integer = (str.Length - 1) 109 | Dim i As Integer = 0 110 | Do While (i <= num2) 111 | buffer2(i) = CByte(Strings.Asc(Strings.Mid(str, (i + 1), 1))) 112 | i += 1 113 | Loop 114 | Return buffer2 115 | End Function 116 | 117 | Public Function FindNextFreeSpace(ByRef Stream As FileStream, ByVal length As Integer) As Integer 118 | Do While (Stream.Position < Stream.Length) 119 | Dim num As Byte = CByte(Stream.ReadByte) 120 | If ((num = 0) Or (num = &HFF)) Then 121 | Dim num3 As Integer = 1 122 | Dim num4 As Integer = CInt((Stream.Position - 1)) 123 | Do While ((num3 < length) And (Stream.Position < Stream.Length)) 124 | num = CByte(Stream.ReadByte) 125 | If ((num <> &HFF) And (num <> 0)) Then 126 | Exit Do 127 | End If 128 | num3 += 1 129 | Loop 130 | If (num3 = length) Then 131 | Return num4 132 | End If 133 | End If 134 | Do While ((Stream.Position Mod 4) > 0) 135 | Stream.ReadByte() 136 | Loop 137 | Loop 138 | Return -1 139 | End Function 140 | 141 | Public Function FromRSChar(ByVal ch As Byte) As Object 142 | Dim array As Byte() = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HFE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HAB, 0, 0, &HB7, &H5B, 0, 180, &H5C, &H5D, &HB9, &H2E, &HB8, &HAE, &HAD, &HBA, &HA1, &HA2, &HA3, &HA4, &HA5, &HA6, &HA7, &HA8, &HA9, 170, 240, &H36, 0, &H35, 0, &HAC, 0, &HBB, &HBC, &HBD, 190, &HBF, &HC0, &HC1, &HC2, &HC3, &HC4, &HC5, &HC6, &HC7, 200, &HC9, &HCA, &HCB, &HCC, &HCD, &HCE, &HCF, &HD0, &HD1, 210, &HD3, &HD4, 0, 0, 0, 0, 0, &HB3, &HD5, &HD6, &HD7, &HD8, &HD9, &HDA, &HDB, 220, &HDD, &HDE, &HDF, &HE0, &HE1, &HE2, &HE3, &HE4, &HE5, 230, &HE7, &HE8, &HE9, &HEA, &HEB, &HEC, &HED, &HEE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H52, 0, 0, 0, 0, 0, 0, 0, 0, &H2B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H2A, 0, 0, 0, 0, &H51, 1, 2, 0, 0, &HF1, 0, 0, 4, 5, 6, 7, 8, 9, 90, 11, 12, 0, 20, 13, 14, 15, 0, &HF2, 0, 0, &H11, &H12, &H13, &HF3, 0, 0, &H15, &H16, &H17, &H68, 0, &HF4, 0, 0, &H19, &H1A, &H1B, &H1C, &H1D, 30, &H6F, &H20, &H21, 0, &H29, &H22, &H23, &H24, 0, &HF5, 0, 0, &H26, &H27, 40, &HF6, 0, 0, 0, 0} 143 | 'Dim index As Integer = array.IndexOf(Of Byte)(array, ch) 144 | Dim index As Integer = System.Array.IndexOf(array, ch) 145 | If (index = -1) Then 146 | index = 0 147 | End If 148 | Return Strings.Chr(index) 149 | End Function 150 | 151 | Public Function GetDoublePointerTable(ByRef Stream As FileStream, ByVal length As Integer) As UInt32() 152 | Dim numArray2 As UInt32() = New UInt32(((length - 1) + 1) - 1) {} 153 | Dim num3 As Integer = (length - 1) 154 | Dim i As Integer = 0 155 | Do While (i <= num3) 156 | Dim streamvar As Stream = Stream 157 | streamvar = DirectCast(streamvar, FileStream) 158 | Dim num As UInt32 = Conversions.ToUInteger(GetDWord(streamvar)) 159 | If (num > &H8000000) Then 160 | numArray2(i) = (num - &H8000000) 161 | streamvar.Seek(4, SeekOrigin.Current) 162 | End If 163 | i += 1 164 | Loop 165 | Return numArray2 166 | End Function 167 | 168 | Public Function GetDWord(ByRef streaminput As Stream) As Object 169 | Dim num As UInt32 = streaminput.ReadByte 170 | num = (num Or (Convert.ToUInt32(streaminput.ReadByte) << 8)) 171 | num = (num Or (Convert.ToUInt32(streaminput.ReadByte) << &H10)) 172 | Return (num Or (Convert.ToUInt32(streaminput.ReadByte) << &H18)) 173 | End Function 174 | 175 | Public Function GetGameCode(ByRef filename As String) As String 176 | Dim stream As New FileStream(filename, FileMode.Open) 177 | Dim reader As New StreamReader(stream, Encoding.ASCII) 178 | Dim str As String = "" 179 | stream.Seek(&HAC, SeekOrigin.Begin) 180 | Dim num As Integer = 0 181 | Do 182 | str = (str & Conversions.ToString(Strings.Chr(reader.Read))) 183 | num += 1 184 | Loop While (num <= 3) 185 | reader.Close() 186 | stream.Close() 187 | Return str 188 | End Function 189 | 190 | Public Function GetLz77UncompressedLength(ByRef stream As FileStream) As Integer 191 | Dim num2 As Integer = 0 192 | If (stream.ReadByte <> &H10) Then 193 | Interaction.MsgBox("Data is not LZ77 compressed!", MsgBoxStyle.ApplicationModal, Nothing) 194 | Return 0 195 | End If 196 | num2 = (stream.ReadByte + (stream.ReadByte << 8)) 197 | Return (num2 + (stream.ReadByte << &H10)) 198 | End Function 199 | 200 | Public Function GetSinglePointerTable(ByRef streaminput As FileStream, ByVal length As Integer) As UInt32() 201 | Dim numArray2 As UInt32() = New UInt32(((length - 1) + 1) - 1) {} 202 | Dim num3 As Integer = (length - 1) 203 | Dim i As Integer = 0 204 | Do While (i <= num3) 205 | Dim stream As Stream = streaminput 206 | stream = DirectCast(stream, FileStream) 207 | Dim num As UInt32 = Conversions.ToUInteger(GetDWord(stream)) 208 | If (num > &H8000000) Then 209 | numArray2(i) = (num - (&H8000000)) 210 | End If 211 | i += 1 212 | Loop 213 | Return numArray2 214 | End Function 215 | 216 | Public Function GetWord(ByRef stream As Stream) As Object 217 | Dim num As UInt16 = CUShort(stream.ReadByte) 218 | Return CUShort((num Or CUShort((Convert.ToUInt16(stream.ReadByte) << 8)))) 219 | End Function 220 | 221 | Public Function LoadString(ByRef Stream As FileStream, ByVal length As Integer) As Object 222 | Dim chArray As Char() = New Char(((length - 1) + 1) - 1) {} 223 | Dim flag As Boolean = False 224 | Dim num3 As Integer = (length - 1) 225 | Dim i As Integer = 0 226 | Do While (i <= num3) 227 | Dim ch As Byte = CByte(Stream.ReadByte) 228 | If Not flag Then 229 | Select Case ch 230 | Case &HFF 231 | flag = True 232 | Continue Do 233 | Case 0 234 | chArray(i) = "?"c 235 | Continue Do 236 | End Select 237 | chArray(i) = Conversions.ToChar(FromRSChar(ch)) 238 | End If 239 | i += 1 240 | Loop 241 | Return Convert.ToString(New String(chArray)) 242 | End Function 243 | 244 | Public Function Lz77Search(ByRef data As Byte(), ByVal position As Integer) As Integer() 245 | Dim length As Integer = data.Length 246 | Dim numArray2 As Integer() = New Integer(2 - 1) {} 247 | Dim collection As New Collection 248 | If ((position < 3) Or ((length - position) < 3)) Then 249 | numArray2(0) = 0 250 | numArray2(1) = 0 251 | Return numArray2 252 | End If 253 | If (position >= length) Then 254 | numArray2(0) = -1 255 | numArray2(1) = 0 256 | Return numArray2 257 | End If 258 | Dim num4 As Integer = &H1000 259 | If (num4 > position) Then 260 | num4 = position 261 | End If 262 | Dim num6 As Integer = (num4 - 1) 263 | Dim i As Integer = 0 264 | Do While (i <= num6) 265 | If (data(((position - i) - 1)) = data(position)) Then 266 | collection.Add((i + 1), Nothing, Nothing, Nothing) 267 | End If 268 | i += 1 269 | Loop 270 | If (collection.Count = 0) Then 271 | numArray2(0) = 0 272 | numArray2(1) = 0 273 | Return numArray2 274 | End If 275 | Dim left As Byte = 0 276 | Dim flag As Boolean = False 277 | Do While (left < &H12) 278 | left = CByte((left + 1)) 279 | Dim j As Integer 280 | For j = 0 To collection.Count - 1 281 | If ((position + left) >= data.Length) Then 282 | flag = True 283 | ElseIf (data((position + left)) <> data(Conversions.ToInteger(Operators.AddObject(Operators.SubtractObject(position, collection.Item((j + 1))), Operators.ModObject(left, collection.Item((j + 1))))))) Then 284 | If (collection.Count > 1) Then 285 | collection.Remove(CInt((j + 1))) 286 | j -= 1 287 | Else 288 | flag = True 289 | End If 290 | End If 291 | If flag Then 292 | Exit For 293 | End If 294 | Next j 295 | If flag Then 296 | Exit Do 297 | End If 298 | Loop 299 | numArray2(0) = left 300 | numArray2(1) = Conversions.ToInteger(collection.Item(1)) 301 | Return numArray2 302 | End Function 303 | 304 | Public Sub SetDWord(ByRef stream As Stream, ByVal dword As UInt32) 305 | stream.WriteByte(CByte((dword And &HFF))) 306 | stream.WriteByte(CByte(((dword >> 8) And &HFF))) 307 | stream.WriteByte(CByte(((dword >> &H10) And &HFF))) 308 | stream.WriteByte(CByte(((dword >> 0) And &HFF))) 309 | End Sub 310 | 311 | Public Sub SetOffset(ByRef stream As Stream, ByVal offset As UInt32) 312 | stream.WriteByte(CByte((offset And &HFF))) 313 | stream.WriteByte(CByte(((offset >> 8) And &HFF))) 314 | stream.WriteByte(CByte(((offset >> &H10) And &HFF))) 315 | stream.WriteByte(8) 316 | End Sub 317 | 318 | Public Sub SetWord(ByRef stream As Stream, ByVal word As UInt16) 319 | stream.WriteByte(CByte((word And &HFF))) 320 | stream.WriteByte(CByte((CUShort((word >> 8)) And &HFF))) 321 | End Sub 322 | 323 | Public Sub ToNextValidOffset(ByRef Stream As FileStream) 324 | Do While ((Stream.Position Mod 4) > 0) 325 | Stream.ReadByte() 326 | Loop 327 | End Sub 328 | 329 | Public Function ToRSChar(ByVal [chr] As Char) As Object 330 | Dim buffer As Byte() = New Byte() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HFE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &HAB, 0, 0, &HB7, &H5B, 0, 180, &H5C, &H5D, &HB9, &H2E, &HB8, &HAE, &HAD, &HBA, &HA1, &HA2, &HA3, &HA4, &HA5, &HA6, &HA7, &HA8, &HA9, 170, 240, &H36, 0, &H35, 0, &HAC, 0, &HBB, &HBC, &HBD, 190, &HBF, &HC0, &HC1, &HC2, &HC3, &HC4, &HC5, &HC6, &HC7, 200, &HC9, &HCA, &HCB, &HCC, &HCD, &HCE, &HCF, &HD0, &HD1, 210, &HD3, &HD4, 0, 0, 0, 0, 0, &HB3, &HD5, &HD6, &HD7, &HD8, &HD9, &HDA, &HDB, 220, &HDD, &HDE, &HDF, &HE0, &HE1, &HE2, &HE3, &HE4, &HE5, 230, &HE7, &HE8, &HE9, &HEA, &HEB, &HEC, &HED, &HEE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H52, 0, 0, 0, 0, 0, 0, 0, 0, &H2B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &H2A, 0, 0, 0, 0, &H51, 1, 2, 0, 0, &HF1, 0, 0, 4, 5, 6, 7, 8, 9, 90, 11, 12, 0, 20, 13, 14, 15, 0, &HF2, 0, 0, &H11, &H12, &H13, &HF3, 0, 0, &H15, &H16, &H17, &H68, 0, &HF4, 0, 0, &H19, &H1A, &H1B, &H1C, &H1D, 30, &H6F, &H20, &H21, 0, &H29, &H22, &H23, &H24, 0, &HF5, 0, 0, &H26, &H27, 40, &HF6, 0, 0, 0, 0} 331 | Return buffer(Strings.Asc([chr])) 332 | End Function 333 | 334 | Public Function UncompressLZ77(ByRef Stream As FileStream) As Byte() 335 | Return UncompressLZ77(Stream, True) 336 | End Function 337 | 338 | Public Function UncompressLZ77(ByRef Stream As FileStream, ByVal message As Boolean) As Byte() 339 | Dim num7 As UInt32 340 | Dim array As Byte() = New Byte(0 - 1) {} 341 | If (Stream.ReadByte <> &H10) Then 342 | If message Then 343 | Interaction.MsgBox("Data is not LZ77 compressed!", MsgBoxStyle.ApplicationModal, Nothing) 344 | End If 345 | Return array 346 | End If 347 | Dim num6 As UInt32 = Stream.ReadByte 348 | num6 = (num6 + (Stream.ReadByte << 8)) 349 | num6 = (num6 + (Stream.ReadByte << &H10)) 350 | If (num6 > &H2404) Then 351 | If message Then 352 | Interaction.MsgBox("Invalid LZ77 offset", MsgBoxStyle.ApplicationModal, Nothing) 353 | End If 354 | Return array 355 | End If 356 | array.Resize(array, CInt(num6)) 357 | Do While (num7 < num6) 358 | Dim num3 As Byte = CByte(Stream.ReadByte) 359 | Dim num8 As Integer = 0 360 | Do 361 | If ((num3 And &H80) > 0) Then 362 | Dim num2 As UInt32 = Stream.ReadByte 363 | Dim num5 As UInt32 = Stream.ReadByte 364 | Dim num4 As UInt32 = ((((num2 << 8) + num5) And &HFFF) + CULng(1)) 365 | Dim num As UInt32 = (CULng(3) + ((num2 >> 4) And 15)) 366 | If (num4 > num7) Then 367 | Return array 368 | End If 369 | Dim num10 As Long = (num - 1) 370 | Dim i As Long = 0 371 | Do While (i <= num10) 372 | If ((num7 + i) >= num6) Then 373 | Exit Do 374 | End If 375 | array(CInt((num7 + i))) = array(CInt(((num7 - num4) + (i Mod CULng(num4))))) 376 | i = (i + 1) 377 | Loop 378 | num7 = (num7 + num) 379 | Else 380 | array(num7) = CByte(Stream.ReadByte) 381 | 382 | num7 = (num7 + 1) 383 | End If 384 | If (num7 >= num6) Then 385 | Return array 386 | End If 387 | num3 = CByte((num3 << 1)) 388 | num8 += 1 389 | Loop While (num8 <= 7) 390 | Loop 391 | Return array 392 | End Function 393 | End Module 394 | -------------------------------------------------------------------------------- /aseriestodis/aseriestodis.vbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {93B1A145-0896-43BE-8AB8-84FADC0E87C5} 8 | Exe 9 | aseriestodis.Module1 10 | aseriestodis 11 | aseriestodis 12 | 512 13 | Console 14 | v4.5.2 15 | 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | true 22 | true 23 | bin\Debug\ 24 | aseriestodis.xml 25 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | false 31 | true 32 | true 33 | bin\Release\ 34 | aseriestodis.xml 35 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 36 | 37 | 38 | On 39 | 40 | 41 | Binary 42 | 43 | 44 | Off 45 | 46 | 47 | On 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 | True 79 | Application.myapp 80 | 81 | 82 | True 83 | True 84 | Resources.resx 85 | 86 | 87 | True 88 | Settings.settings 89 | True 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | VbMyResourcesResXFileCodeGenerator 98 | Resources.Designer.vb 99 | My.Resources 100 | Designer 101 | 102 | 103 | 104 | 105 | MyApplicationCodeGenerator 106 | Application.Designer.vb 107 | 108 | 109 | SettingsSingleFileGenerator 110 | My 111 | Settings.Designer.vb 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /aseriestodis/mMain.vb: -------------------------------------------------------------------------------- 1 | Imports System.IO 2 | 3 | 4 | 5 | Module mMain 6 | 7 | Public LoadedROM As String 8 | 'Public ledrom As ROM 9 | Public AppPath As String = System.AppDomain.CurrentDomain.BaseDirectory() & IIf(Right(System.AppDomain.CurrentDomain.BaseDirectory(), 1) = "\", "", "\") 10 | Public i As Integer 11 | Public FileNum As Integer 12 | Public header As String = "xxxx" 13 | Public header2 As String 14 | Public header3 As String 15 | Public lwut As String 16 | Public SkipVar As Integer 17 | Public x As Integer 18 | 19 | 20 | Public Function GetINIFileLocation() 21 | 22 | If System.IO.File.Exists((LoadedROM).Substring(0, LoadedROM.Length - 4) & ".ini") = True Then 23 | 24 | Return (LoadedROM).Substring(0, LoadedROM.Length - 4) & ".ini" 25 | Else 26 | 27 | Return AppPath & "ini\roms.ini" 28 | End If 29 | 30 | End Function 31 | 32 | Public Function MakeFreeSpaceString(NeededLength As Integer, Optional NeedByteString As String = "FF") 33 | 34 | Dim PrivLoopVar As Integer 35 | Dim OutBuffThing As String = "" 36 | 37 | PrivLoopVar = 0 38 | 39 | While (PrivLoopVar < NeededLength) 40 | 41 | OutBuffThing = OutBuffThing & NeedByteString 42 | 43 | PrivLoopVar = PrivLoopVar + 1 44 | End While 45 | 46 | MakeFreeSpaceString = OutBuffThing 47 | End Function 48 | 49 | Public Function DecapString(input As String) As String 50 | 51 | Dim LoopVar As Integer 52 | Dim outputstring As String = "" 53 | Dim capflag As Boolean = True 54 | 55 | LoopVar = 0 56 | 57 | While LoopVar < Len(input) 58 | 59 | LoopVar = LoopVar + 1 60 | 61 | If GetChar(input, LoopVar) = " " Then 62 | outputstring = outputstring & " " 63 | capflag = True 64 | Else 65 | If capflag = True Then 66 | 67 | outputstring = outputstring & UCase(GetChar(input, LoopVar)) 68 | capflag = False 69 | 70 | ElseIf capflag = False 71 | 72 | outputstring = outputstring & LCase(GetChar(input, LoopVar)) 73 | 74 | End If 75 | End If 76 | 77 | End While 78 | 79 | DecapString = outputstring 80 | End Function 81 | 82 | Public Sub OutPutError(message As String) 83 | 84 | Dim errorfile As String = AppPath & "errors.txt" 85 | 86 | System.IO.File.AppendAllText(errorfile, message & vbCrLf) 87 | 88 | End Sub 89 | 90 | Public Function ByteToSignedInt(InputByte As Byte) As Integer 91 | Dim ReturnVar As Integer 92 | 93 | 94 | If InputByte > &H7F Then 95 | Dim BinaryVar As String = (Convert.ToString(InputByte, 2)) 96 | ReturnVar = ((Convert.ToInt32(Mid(BinaryVar, 2, 7), 2)) - 128) 97 | Else 98 | ReturnVar = InputByte 99 | End If 100 | 101 | ByteToSignedInt = ReturnVar 102 | 103 | End Function 104 | 105 | Public Function SignedIntToHex(InputInt As Integer) As String 106 | 107 | Dim ReturnVar As String 108 | 109 | 110 | If InputInt < 0 Then 111 | 112 | Dim BinaryVar As String = (Convert.ToString(InputInt + 128, 2)) 113 | BinaryVar = "1" & BinaryVar 114 | ReturnVar = Hex((Convert.ToInt32(BinaryVar, 2))) 115 | 116 | Else 117 | ReturnVar = Hex(InputInt) 118 | End If 119 | 120 | SignedIntToHex = ReturnVar 121 | 122 | End Function 123 | 124 | Public Function ByteArrayToHexString(inputarray As Byte()) As String 125 | 126 | Dim HexString As String = "" 127 | 128 | For Each b As Byte In inputarray 129 | HexString = HexString & MakeProperByte(b) 130 | Next 131 | 132 | ByteArrayToHexString = HexString 133 | End Function 134 | 135 | Public Function MakeProperByte(DaByte As Byte) As String 136 | Dim OutputByte As String 137 | 138 | 139 | If Len(Hex(DaByte)) = 1 Then 140 | OutputByte = "0" & Hex(DaByte) 141 | Else 142 | OutputByte = Hex(DaByte) 143 | End If 144 | 145 | MakeProperByte = OutputByte 146 | 147 | End Function 148 | 149 | 150 | 151 | Public Function Get2Bytes(bytesin As Byte(), local As Integer) As String 152 | 153 | Get2Bytes = MakeProperByte(bytesin(local)) & MakeProperByte(bytesin(local + 1)) 154 | 155 | End Function 156 | 157 | Public Function HexStringToByteArray(input As String) As Byte() 158 | 159 | Dim output((input.Length / 2) - 1) As Byte 160 | Dim loopvar As Integer 161 | 162 | loopvar = 0 163 | 164 | While loopvar < (input.Length / 2) 165 | 166 | If loopvar = 0 Then 167 | output(loopvar) = "&H" & input.Substring(loopvar * 2, 2) 168 | Else 169 | output(loopvar) = "&H" & input.Substring(loopvar * 2, 2) 170 | End If 171 | 172 | loopvar = loopvar + 1 173 | 174 | End While 175 | 176 | 177 | 178 | HexStringToByteArray = output 179 | End Function 180 | 181 | 182 | End Module 183 | --------------------------------------------------------------------------------