def saveandrepoint(self, button):
     #The user wants to save, but there is no space
     # -> Save and repoint.
     r = self.callback.compilestring(self.stringeditor.edit.toPlainText())
     newpointer = self.callback.saveandrepoint(self.offset, r)
     showInfo(self, "Saved string at 0x%X, updated all pointers to this text."%newpointer)
     self.callback.selectString(newpointer)
 def saveandrepoint(self, button):
     #The user wants to save, but there is no space
     # -> Save and repoint.
     r = self.callback.compilestring(self.stringeditor.edit.toPlainText())
     newpointer = self.callback.saveandrepoint(self.offset, r)
     showInfo(
         self, "Saved string at 0x%X, updated all pointers to this text." %
         newpointer)
     self.callback.selectString(newpointer)
 def save(self, button):
     #The user wants to save the script, is it wise? If yes: save...
     r = self.callback.compilestring(self.stringeditor.edit.toPlainText())
     if self.pointerscount == 0 and len(r.bytestring()) != self.oldsize+1:
         if not showYesNo(self, "There are no pointers to this text. Updating the text with a new one of a different length may lead to data corruption. Are you sure you want to continue?", "Warning!"):
             return
     
     newpointer = self.callback.save(self.offset, r)
     showInfo(self, "Saved string at 0x%X."%newpointer)
 def startEmulator(self):
     '''Starts the loaded ROM in an emulator.'''
     print(self.config)
     if not 'emulator' in self.config:
         showInfo(self.mainview, "No emulator is set in the config file! Can not emulate the ROM.")
         return
     try:
         command = [x if x != "%u" else self.rom.filename for x in shlex.split(self.config['emulator'])]
         subprocess.Popen(command)
     except Exception as e:
         showError(self.mainview, "Could not start the emulator:\n"+repr(e))
    def save(self, button):
        #The user wants to save the script, is it wise? If yes: save...
        r = self.callback.compilestring(self.stringeditor.edit.toPlainText())
        if self.pointerscount == 0 and len(r.bytestring()) != self.oldsize + 1:
            if not showYesNo(
                    self,
                    "There are no pointers to this text. Updating the text with a new one of a different length may lead to data corruption. Are you sure you want to continue?",
                    "Warning!"):
                return

        newpointer = self.callback.save(self.offset, r)
        showInfo(self, "Saved string at 0x%X." % newpointer)
 def findStartpoint(self, offset):
     while offset >= 0:
         if self.rom.readByte(offset)[1] == 0xff:
             break
             
         offset -= 1
         if self.rom.find(array('B', offsetToGBA(offset)), 0) > -1:
             self.selectString(offset)
             showInfo(self.view, "Start of text found at offset 0x%X!"%offset)
             return
     
     #Very unlike to be seen.
     showInfo(self.view, "There was no valid startpoint found for the given text.")
Beispiel #7
0
    def findStartpoint(self, offset):
        while offset >= 0:
            if self.rom.readByte(offset)[1] == 0xff:
                break

            offset -= 1
            if self.rom.find(array('B', offsetToGBA(offset)), 0) > -1:
                self.selectString(offset)
                showInfo(self.view,
                         "Start of text found at offset 0x%X!" % offset)
                return

        #Very unlike to be seen.
        showInfo(self.view,
                 "There was no valid startpoint found for the given text.")
Beispiel #8
0
    def burnScript(self):
        '''Compiles the source, if succesful updates the in-game scripts.'''
        sg = self._compileandtest()
        if sg == None:
            return

        try:
            try:
                pointers = self.currentScriptgroup.getPointerlist()
            except:
                pointers = {}
            rom = self.rom

            #set pointers in new scriptgroup related to old scriptgroup
            for varname in sg.getPointerlist():
                if varname in pointers:
                    sg.setPointer(varname, pointers[varname])

            print("______________________")
            print("Burning")
            b = ScriptBurner(rom)
            _ = b.burn(sg)  #newpointers

            print("______________________")
            print("Update script pointers")
            pointerslist = sg.getPointerlist()
            for varname, resource in self.startvars.items():
                try:
                    resource.scriptpointer = pointerslist[varname]
                except:
                    resource.scriptpointer = 0
                self.rom.getRM().store(resource)

            print("")
            print("!! All done! Script injection was succesful!")
            self.currentScriptgroup = sg
            showInfo(self.mainview,
                     "Script was succesfully written to the ROM.")

        except Exception as e:
            showError(
                self.mainview,
                "The script compiled succesfully, but writing the changes to the ROM failed.\n\nDEBUG: "
                + str(e))
            raise e
Beispiel #9
0
 def startEmulator(self):
     '''Starts the loaded ROM in an emulator.'''
     print(self.config)
     if not 'emulator' in self.config:
         showInfo(
             self.mainview,
             "No emulator is set in the config file! Can not emulate the ROM."
         )
         return
     try:
         command = [
             x if x != "%u" else self.rom.filename
             for x in shlex.split(self.config['emulator'])
         ]
         subprocess.Popen(command)
     except Exception as e:
         showError(self.mainview,
                   "Could not start the emulator:\n" + repr(e))
 def burnScript(self):
     '''Compiles the source, if succesful updates the in-game scripts.'''
     sg = self._compileandtest()
     if sg == None:
         return
     
     try:
         try:
             pointers = self.currentScriptgroup.getPointerlist()
         except:
             pointers = {}
         rom = self.rom
         
         #set pointers in new scriptgroup related to old scriptgroup
         for varname in sg.getPointerlist():
             if varname in pointers:
                 sg.setPointer(varname, pointers[varname])
         
         print("______________________")
         print("Burning")
         b = ScriptBurner(rom)
         _ = b.burn(sg) #newpointers
         
         print("______________________")
         print("Update script pointers")
         pointerslist = sg.getPointerlist()
         for varname, resource in self.startvars.items():
             try:
                 resource.scriptpointer = pointerslist[varname]
             except:
                 resource.scriptpointer = 0
             self.rom.getRM().store(resource)
         
         print("")
         print("!! All done! Script injection was succesful!")
         self.currentScriptgroup = sg
         showInfo(self.mainview, "Script was succesfully written to the ROM.")
         
     except Exception as e:
         showError(self.mainview, "The script compiled succesfully, but writing the changes to the ROM failed.\n\nDEBUG: "+str(e))
         raise e
Beispiel #11
0
 def testScript(self):
     '''Try to compile the script in the sourceview.'''
     sg = self._compileandtest()
     if sg != None:
         showInfo(self.mainview, "Test OK, the script contains no errors.")
 def testScript(self):
     '''Try to compile the script in the sourceview.'''
     sg = self._compileandtest()
     if sg != None:
         showInfo(self.mainview, "Test OK, the script contains no errors.")