diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-10-26 22:38:47 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-10-26 22:38:47 -0700 |
commit | 7e61eaa7225bf025af42f88d0598aff8412f4144 (patch) | |
tree | bd19c2e555fc997065eba51715459185db566878 /analyze_olp.py | |
parent | 4788b58c7290ad4a4a161d6bc69bc184acc2ef66 (diff) | |
parent | b8dc9d69563379341f127af571b4bec1312f4ca0 (diff) |
Update opengl branch from default. Fix build breakage unrelated to merge
--HG--
branch : opengl
Diffstat (limited to 'analyze_olp.py')
-rwxr-xr-x | analyze_olp.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/analyze_olp.py b/analyze_olp.py new file mode 100755 index 0000000..652edc4 --- /dev/null +++ b/analyze_olp.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +from zipfile import ZipFile +from sys import exit, argv + +def detect_rise(last, sample, bit): + mask = 1 << bit + return (not last & mask) and (sample & mask) + +def detect_fall(last, sample, bit): + mask = 1 << bit + return (last & mask) and (not sample & mask) + +def detect_high(sample, bit): + mask = 1 << bit + return sample & mask + +def detect_low(sample, bit): + mask = 1 << bit + return not sample & mask + +def analyze_delays(chanmap, datafile): + m68k_clk = chanmap['M68K CLK'] + m_as = chanmap['!AS'] + last = False + clks = 0 + as_start = 0 + for line in datafile.readlines(): + line = line.strip() + if line and not line.startswith(';'): + sample,_,num = line.partition('@') + sample = int(sample, 16) + if not (last is False): + if detect_rise(last, sample, m68k_clk): + clks = clks + 1 + if detect_rise(last, sample, m_as): + as_clks = clks - as_start + if as_clks > 2: + print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks + elif detect_fall(last, sample, m_as): + as_start = clks + last = sample + +def main(args): + if len(args) < 2: + print 'Usage: analyze_olp.py filename' + exit(1) + olpfile = ZipFile(args[1], "r") + channelfile = olpfile.open('channel.labels') + channels = [line.strip() for line in channelfile.readlines()] + channelfile.close() + chanmap = {} + for i in xrange(0, len(channels)): + chanmap[channels[i]] = i + datafile = olpfile.open('data.ols') + analyze_delays(chanmap, datafile) + + +if __name__ == '__main__': + main(argv) |