Пример #1
0
def main():
    path = os.path.abspath(os.path.dirname(__file__))

    # Load desmume
    emu = DeSmuME()

    # Init joysticks
    emu.input.joy_init()

    # Load Builder and Window
    builder = Gtk.Builder()
    builder.add_from_file(os.path.join(path, "PyDeSmuMe.glade"))
    main_window: Window = builder.get_object("wMainW")
    main_window.set_role("PyDeSmuME")
    GLib.set_application_name("PyDeSmuME")
    GLib.set_prgname("pydesmume")
    # TODO: Deprecated but the only way to set the app title on GNOME...?
    main_window.set_wmclass("PyDeSmuME", "PyDeSmuME")

    # Load main window + controller
    MainController(builder, main_window, emu)

    main_window.present()
    Gtk.main()
    del emu
Пример #2
0
 def impl(cls, emu: DeSmuME) -> 'AbstractRenderer':
     from desmume.frontend.gtk_drawing_impl.opengl import OpenGLRenderer
     from desmume.frontend.gtk_drawing_impl.software import SoftwareRenderer
     # TODO: Implement OpenGL renderer
     if False and emu.has_opengl():
         return OpenGLRenderer(emu)
     else:
         return SoftwareRenderer(emu)
    def __init__(self, parent, override_dll = None):
        if self.__class__._instance is not None:
            raise RuntimeError("Only one instance of EmulatorThread can exist at a time. "
                               "Be sure to call end() on old instances.")
        self.__class__._instance = self
        Thread.__init__(self)
        self.loop: asyncio.AbstractEventLoop = None
        if self.__class__._emu is None:
            self.__class__._emu = DeSmuME(override_dll)
        self._thread_instance = None
        self.registered_main_loop = False
        self.parent = parent
        self._display_buffer = None

        self._fps_frame_count = 0
        self._fps_sec_start = 0
        self._fps = 0
        self._ticks_prev_frame = 0
        self._ticks_cur_frame = 0
        self._boost = False
                    f"but it was already watched by {self.watched_memory_regions[addr]}"
                )
        return ok

    def probe_unregister_memory(self, probe: AbstractMemoryProbe, start: int,
                                length: int):
        for addr in range(start, start + length):
            if addr in self.watched_memory_regions and self.watched_memory_regions[
                    addr] == probe:
                del self.watched_memory_regions[addr]
                self.emu.memory.register_write(addr, None)


if __name__ == '__main__':
    emu = DeSmuME(
        "../../../../desmume/desmume/src/frontend/interface/.libs/libdesmume.so"
    )

    emu.open("../../../skyworkcopy_edit.nds")
    win = emu.create_sdl_window(use_opengl_if_possible=True)

    emu.volume_set(0)
    """
    Interesting memory locations to watch:
    - 0x02325834: Pointer to: Script engine loader state -> POINTS TO MAIN SCRIPT STRUCT! [Length at least 0xf0?]
    - 0x02325838: Pointer to: ???               [12 bytes per ???]
    - 0x0232583C: Pointer to: Actor data?       [0x250 bytes per Actor] -> STARTING AT 0x38: Actor script struct
    - 0x02325840: Pointer to: Object data?      [0x218 per Object]      -> STARTING AT 0x3C: Object script struct
    - 0x02325844: Pointer to: Performer data?   [0x214 per Performer]   -> STARTING AT 0x3C: Perf. script struct
    - 0x02325848: Pointer to: Event data...?    [0x32 per event?]
    - 0x020a8890: Pointer to?: ? Related to actors?
    print("Traps:")
    start += DUNGEON_ENTITIES__LEN_ITEMS
    for i in range(start, start + DUNGEON_ENTITIES__LEN_TRAPS):
        epnt = print_generic_entity_data(addr_entities, i)
        if epnt is not None:
            print_trap_data(epnt)

    print_and_output_tiledata(addr_entities, addr_tiledata)


def hook__debug_enable_branch(emu, address, size):
    emu.memory.register_arm9.r0 = 1 if emu.memory.register_arm9.r0 == 0 else 0


if __name__ == '__main__':
    emu = DeSmuME()

    emu.open("../../../skyworkcopy_us.nds")
    win = emu.create_sdl_window()

    emu.volume_set(0)

    emu.memory.register_exec(
        pmd2data.binaries['overlay/overlay_0011.bin'].
        symbols['ScriptCommandParsing'].begin_absolute + 0x15C8,
        partial(hook__debug_enable_branch, emu))

    fc = 0
    while not win.has_quit():
        fc += 1
        win.process_input()