fix: fix wav loading
This commit is contained in:
parent
3bd5c9ddc1
commit
94bc7f7401
1 changed files with 8 additions and 4 deletions
12
orao/cpu.py
12
orao/cpu.py
|
@ -85,7 +85,7 @@ class CPU(object):
|
||||||
|
|
||||||
def get_word(self, addr): return 256 * self.get_byte(addr + 1) + self.get_byte(addr)
|
def get_word(self, addr): return 256 * self.get_byte(addr + 1) + self.get_byte(addr)
|
||||||
|
|
||||||
def get_filename(self): return 'wav/{0}.WAV'.format(str(self.memory[592:602]).rstrip())
|
def get_filename(self): return 'wav/{0}.WAV'.format(str(self.memory[592:602], 'ASCII').rstrip())
|
||||||
|
|
||||||
def speaker(self):
|
def speaker(self):
|
||||||
self.flipflop ^= 1
|
self.flipflop ^= 1
|
||||||
|
@ -95,14 +95,18 @@ class CPU(object):
|
||||||
self.sndbuf += [255] * self.samples + [0] * self.samples
|
self.sndbuf += [255] * self.samples + [0] * self.samples
|
||||||
self.last_sound_cycles = self.cycles
|
self.last_sound_cycles = self.cycles
|
||||||
|
|
||||||
|
def tape_load_gen(self):
|
||||||
|
for i in wave.open(self.get_filename()).readframes(2 ** 24):
|
||||||
|
for j in 2 * [i]:
|
||||||
|
yield 255 * (j > 128)
|
||||||
|
|
||||||
def get_byte(self, addr):
|
def get_byte(self, addr):
|
||||||
if addr == 0x87FF: # Adresa ulaza kasetofona
|
if addr == 0x87FF: # Adresa ulaza kasetofona
|
||||||
if not self.tape:
|
if not self.tape:
|
||||||
self.tape = (255*(ord(j)>128) for i in \
|
self.tape = self.tape_load_gen()
|
||||||
wave.open(self.get_filename()).readframes(2**24) for j in 2*i)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.tape.next()
|
return next(self.tape)
|
||||||
|
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
self.tape = None
|
self.tape = None
|
||||||
|
|
Loading…
Reference in a new issue