SkyTemple / py-desmume

Python Library and GUI for DeSmuME, the Nintendo DS emulator
GNU General Public License v3.0
25 stars 5 forks source link

emu.savestate.save() and emu.savestate.load() not working #6

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello! I am trying to save and load from the Desmume slots. It works fine when saving and loading using the "save_file and load_file" but it does not work when using only "save(1)" and load(1)". Is there futher set-up that I need to do for it to work with save and load?

from desmume.emulator import DeSmuME
from desmume.controls import keymask, Keys

emu = DeSmuME()
emu.open('D:\\Dropbox\\Speed Run\\DeSmuME 9.11\\Roms\\ROMs\\NA\\0561 - Harvest Moon DS (U)(Legacy).nds')

window = emu.create_sdl_window()

frame = 0
emu.input.keypad_rm_key(Keys.KEY_A)
while not window.has_quit():

    frame += 1

    if frame == 500:
        emu.savestate.save_file("test.dsm")
        print("Save to file")

    if frame == 500:
        emu.savestate.save(1)
        print("Save to slot #1")

    if frame == 2000:
        emu.savestate.load_file("test.dsm")
        print("Load from file")

    if frame == 3000:
        emu.savestate.load(1)
        print("Load from slot #1")

    window.process_input()    

    emu.cycle()
    window.draw()
theCapypara commented 3 years ago

There's a bug under Windows where Desmume tries to write savestates and battery to the directory it's installed to. It probably doesn't have permission.

ghost commented 3 years ago

Again, thank you very much. That was exactly it! I copied the packaged installed by pip to the local folder where I am running my application, and deleted the pip package.