hachoir / hachoir-parser / hachoir_parser / program / nds.py

Diff from to

hachoir-parser/hachoir_parser/program/nds.py

 - http://imrannazar.com/The-Smallest-NDS-File
 - http://darkfader.net/ds/files/ndstool.cpp
 - http://crackerscrap.com/docs/dsromstructure.html
+- http://nocash.emubase.de/gbatek.htm
 """
 
 from hachoir_parser import Parser
         yield String(self, "title_es", 256, charset="UTF-16-LE", truncate="\0")
 
 
+class Overlay(FieldSet):
+    static_size = 8*4*8
+    def createFields(self):
+        yield UInt32(self, "id")
+        yield textHandler(UInt32(self, "ram_address"), hexadecimal)
+        yield UInt32(self, "ram_size")
+        yield UInt32(self, "bss_size")
+        yield textHandler(UInt32(self, "init_start_address"), hexadecimal)
+        yield textHandler(UInt32(self, "init_end_address"), hexadecimal)
+        yield UInt32(self, "file_id")
+        yield RawBytes(self, "reserved[]", 4)
+
+    def createDescription(self):
+        return "file #%d, %d (+%d) bytes to 0x%08x" % (
+            self["file_id"].value, self["ram_size"].value, self["bss_size"].value, self["ram_address"].value)
+
+
 class DeviceSize(UInt8):
     def createDescription(self):
         return "%d Mbit" % ((2**(20+self.value)) / (1024*1024))
             self.seekByte(self["header"]["banner_offset"].value, relative=False)
             yield Banner(self, "banner")
 
+        # ARM9 overlays
+        if self["header"]["arm9_overlay_src"].value > 0:
+            self.seekByte(self["header"]["arm9_overlay_src"].value, relative=False)
+            numOvls = self["header"]["arm9_overlay_size"].value / (8*4)
+            for i in range(numOvls):
+                yield Overlay(self, "arm9_overlay[]")
+
         # files
         if self["header"]["fat_size"].value > 0:
             for field in self["fat_content"]:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.