vgkintsugi / ghidra-segasaturn-loader Goto Github PK
View Code? Open in Web Editor NEWA Sega Saturn loader for Ghidra
License: Apache License 2.0
A Sega Saturn loader for Ghidra
License: Apache License 2.0
Command & Conquer for the Saturn is a example of a game this plugin can't load.
The game needs to be ripped as bin/cue to retain the CD audio it has.
It has a single binary called 0_CNCSAT.BIN that holds all the game code.
The list of Mednafen save state sections has significantly changed. Look into updating. For the time being the MSS_MAX_SECTIONS check has been disabled.
CyberWarriorX previously created Sega Saturn library signatures for use with IDA. Research into how to do that for Ghidra.
//
// CD registers taken from: https://wiki.yabause.org/index.php5?title=CDBlock
//
final int CD_BASE = 0x20100000;
CD_BASE should be 0x25890000 according to the Yabause link referenced in the code. Credit user @Ced2911
Add support for on-chip registers. According to https://wiki.yabause.org/index.php5?title=SH-2CPU there in the region 0xFFFFFE00-0xFFFFFFFF.
Here is a Mednafen save state for Dungeons & Dragons Collection, Disc 1. It fails to load with this error:
----- Loading /C:/Games/Mednafen/mcs/Dungeons & Dragons Collection (Japan) (Disc 1) (Tower of Doom).458e98aeae4d21ae821a665722d2e5b9.mc0 -----
Too many sections big!!
java.io.IOException: Too many sections big!!
at segasaturnloader.SegaSaturnLoader.mssMakeSectionMap(SegaSaturnLoader.java:1325)
at segasaturnloader.SegaSaturnLoader.loadMednafenSaveState(SegaSaturnLoader.java:1689)
at segasaturnloader.SegaSaturnLoader.load(SegaSaturnLoader.java:128)
at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:724)
at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:98)
at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:126)
at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:368)
at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351)
at ghidra.util.task.TaskBuilder$TaskBuilderTask.run(TaskBuilder.java:306)
at ghidra.util.task.Task.monitoredRun(Task.java:134)
at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Failed to parse MSS sections!
java.io.IOException: Failed to parse MSS sections!
at segasaturnloader.SegaSaturnLoader.loadMednafenSaveState(SegaSaturnLoader.java:1692)
at segasaturnloader.SegaSaturnLoader.load(SegaSaturnLoader.java:128)
at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:724)
at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:98)
at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:126)
at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:368)
at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:351)
at ghidra.util.task.TaskBuilder$TaskBuilderTask.run(TaskBuilder.java:306)
at ghidra.util.task.Task.monitoredRun(Task.java:134)
at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Presumably this has something to do with the game's support for the 4MB RAM cartridge. I tried disabling the emulation of that, but got the same error.
Is there anything else I can do to work around this?
Thanks for reading, and for making this loader - I use it all the time!
Research into how to support mirrored memory regions. Currently the loader is simply over-defining a memory region.
Ghidra has the ability to set certain memory regions as volatile. Enable it for the memory mapped registers.
Add support for loading save states created by the Mednafen emulator.
CyberWarriorX extracts the MSH2 PC address and sets IDA to highlight that address. Do something similar for Ghidra.
Split the memory map code into a separate script. Call it from the loader.
Create a memory map for the SH-1 as well.
Look at various map.h files in https://github.com/ijacquez/libyaul/ and create labels for them.
Currently the loader assumes the Saturn has a 32-bit address space. This isn't the case. If certain bits are set the reads go to a cache. See https://wiki.yabause.org/index.php5?title=SH-2CPU for reference.
Similar to ISO, be able to load from Bin/Cue file.
When labelling the VDP2 registers the names of the SCU registers are used by mistake. The correct names can be found here: https://github.com/ijacquez/libyaul/blob/develop/libyaul/scu/bus/b/vdp/vdp2/map.h
Detect and load the BIOS if supplied by the user. It should be sufficient to check the first 12 bytes of the file.
Also consider a method to load the BIOS in addition to a save state or ISO specified by the user.
The Saturn SDK examples(entry.s) show bss start and end locations, perhaps this can be used to reconstruct at least some sections?
I haven't checked Saturn binaries with symbols much, but maybe something refs text and data section ranges as well?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.