mirror of
https://github.com/jtauber/applepy.git
synced 2024-10-31 13:08:22 +00:00
attempt to skip to data part of tape
This commit is contained in:
parent
6951db69ad
commit
b8c7949d8e
11
applepy.py
11
applepy.py
@ -294,9 +294,18 @@ class Cassette:
|
|||||||
def __init__(self, fn):
|
def __init__(self, fn):
|
||||||
wav = wave.open(fn, "r")
|
wav = wave.open(fn, "r")
|
||||||
self.raw = wav.readframes(wav.getnframes())
|
self.raw = wav.readframes(wav.getnframes())
|
||||||
|
self.start_cycle = 0
|
||||||
|
self.start_offset = 0
|
||||||
|
|
||||||
|
for i, b in enumerate(self.raw):
|
||||||
|
if ord(b) > 0xA0:
|
||||||
|
self.start_offset = i
|
||||||
|
break
|
||||||
|
|
||||||
def read_byte(self, cycle):
|
def read_byte(self, cycle):
|
||||||
offset = cycle * 22000 / 1000000
|
if self.start_cycle == 0:
|
||||||
|
self.start_cycle = cycle
|
||||||
|
offset = self.start_offset + (cycle - self.start_cycle) * 22000 / 1000000
|
||||||
return ord(self.raw[offset]) if offset < len(self.raw) else 0x80
|
return ord(self.raw[offset]) if offset < len(self.raw) else 0x80
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user