Fix variable names and return false if memory not found
This commit is contained in:
parent
d4c3b72ce2
commit
dd1f33ab53
1 changed files with 12 additions and 9 deletions
19
memorylib.py
19
memorylib.py
|
@ -116,7 +116,7 @@ SOFTWARE."""
|
||||||
class Dolphin(object):
|
class Dolphin(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.pid = -1
|
self.pid = -1
|
||||||
self.shmem = None
|
self.memory = None
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.pid = -1
|
self.pid = -1
|
||||||
|
@ -151,13 +151,17 @@ class Dolphin(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def init_shared_memory(self):
|
def init_shared_memory(self):
|
||||||
self.mem = shared_memory.SharedMemory('dolphin-emu.'+str(self.pid))
|
try:
|
||||||
|
self.memory = shared_memory.SharedMemory('dolphin-emu.'+str(self.pid))
|
||||||
|
return True
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
|
||||||
def read_ram(self, offset, size):
|
def read_ram(self, offset, size):
|
||||||
return self.mem.buf[offset:offset+size]
|
return self.memory.buf[offset:offset+size]
|
||||||
|
|
||||||
def write_ram(self, offset, data):
|
def write_ram(self, offset, data):
|
||||||
self.mem.buf[offset:offset+len(data)] = data
|
self.memory.buf[offset:offset+len(data)] = data
|
||||||
|
|
||||||
def read_uint32(self, addr):
|
def read_uint32(self, addr):
|
||||||
assert addr >= 0x80000000
|
assert addr >= 0x80000000
|
||||||
|
@ -198,11 +202,10 @@ if __name__ == "__main__":
|
||||||
print(dolphin.pid)
|
print(dolphin.pid)
|
||||||
|
|
||||||
dolphin.init_shared_memory()
|
dolphin.init_shared_memory()
|
||||||
"""
|
if dolphin.init_shared_memory():
|
||||||
if dolphin.get_emu_info():
|
print("We found MEM1 and/or MEM2!")
|
||||||
print("We found MEM1 and/or MEM2!", dolphin.address_start, dolphin.mem2_start)
|
|
||||||
else:
|
else:
|
||||||
print("We didn't find it...")"""
|
print("We didn't find it...")
|
||||||
|
|
||||||
import random
|
import random
|
||||||
randint = random.randint
|
randint = random.randint
|
||||||
|
|
Loading…
Reference in a new issue