mirror of
https://github.com/jtauber/applepy.git
synced 2024-11-29 20:49:21 +00:00
better error message
This commit is contained in:
parent
30f23c8bff
commit
f23b145d94
@ -16,10 +16,15 @@ class ROMBase(object):
|
||||
def load_file(self, address, filename):
|
||||
with open(filename, "rb") as f:
|
||||
for offset, datum in enumerate(f.read()):
|
||||
self._mem[address - self.start + offset] = ord(datum)
|
||||
index = address - self.start + offset
|
||||
try:
|
||||
self._mem[index] = ord(datum)
|
||||
except IndexError:
|
||||
raise IndexError("ROM file %s bigger than: %s" % (filename, hex(index)))
|
||||
|
||||
|
||||
def read_byte(self, address):
|
||||
assert self.start <= address <= self.end
|
||||
assert self.start <= address <= self.end, "Read %s from %s is not in range %s-%s" % (hex(address), self.__class__.__name__, hex(self.start), hex(self.end))
|
||||
return self._mem[address - self.start]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user