From 815467a8a0672f18266537c902c7ad6a6a937505 Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Fri, 29 Jan 2021 18:21:44 +0530 Subject: [PATCH] Initial Commit --- README.md | 20 ++++++++++++++++++++ dr2mds.py | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 README.md create mode 100755 dr2mds.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..379a76b --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +## Drastic to MelonDS + +This script will convert the dsv save from drastic emulator to a melonDS save file + +How this works ? + +MelonDS determines save type using exact byte count in the save file +Which needs to be a power of 2 as mentioned [here](http://melonds.kuribo64.net/faq.php). +This script calculates the closest power of 2 to the save file and removes the padding + +This can be easily done manually by removing the padding using a hex editor. +Or using dd like this + +```bash +dd if=Pokemon.dsv of=Pokemon.sav bs=1 count=524288 +``` + +This will make a 4KiB EEPROM save from drastic to melonDS save. + +I will add argparse later. diff --git a/dr2mds.py b/dr2mds.py new file mode 100755 index 0000000..18fc91a --- /dev/null +++ b/dr2mds.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 + +from math import log +import os + +DRASTIC_SAVE="Pokemon Black.dsv" +MELONDS_SAVE="Pokemon Black.sav" + +def st_size(path): + return os.stat(path).st_size + +def closest2pow(n): + return 2**int(log(n) / log(2)) + +def drastic2melonds(infile,outfile): + with open(infile,"rb") as inf, open(outfile,"wb") as ouf: + + ouf.write(inf.read(closest2pow(st_size(infile)))) + +if __name__ == "__main__": + drastic2melonds(DRASTIC_SAVE,MELONDS_SAVE)