Mercurial > repos > blastem
annotate analyze_olp.py @ 723:7178d750efbd
Process events while waiting for 68K debugger input. This prevents "not responsive" dialogs when sitting in the debugger
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 21 May 2015 18:37:41 -0700 |
parents | be9c7b3e25ee |
children | b290343e5664 |
rev | line source |
---|---|
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 from zipfile import ZipFile |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 from sys import exit, argv |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 def detect_rise(last, sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 return (not last & mask) and (sample & mask) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 def detect_fall(last, sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 return (last & mask) and (not sample & mask) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 def detect_high(sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 return sample & mask |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 def detect_low(sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 return not sample & mask |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 def analyze_delays(chanmap, datafile): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 m68k_clk = chanmap['M68K CLK'] |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 m_as = chanmap['!AS'] |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 last = False |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 clks = 0 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 as_start = 0 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 for line in datafile.readlines(): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 line = line.strip() |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 if line and not line.startswith(';'): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 sample,_,num = line.partition('@') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 sample = int(sample, 16) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 if not (last is False): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 if detect_rise(last, sample, m68k_clk): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 clks = clks + 1 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 if detect_rise(last, sample, m_as): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 as_clks = clks - as_start |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 if as_clks > 2: |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 elif detect_fall(last, sample, m_as): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 as_start = clks |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 last = sample |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 def main(args): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 if len(args) < 2: |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 print 'Usage: analyze_olp.py filename' |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 exit(1) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 olpfile = ZipFile(args[1], "r") |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 channelfile = olpfile.open('channel.labels') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 channels = [line.strip() for line in channelfile.readlines()] |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 channelfile.close() |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 chanmap = {} |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 for i in xrange(0, len(channels)): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 chanmap[channels[i]] = i |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 datafile = olpfile.open('data.ols') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 analyze_delays(chanmap, datafile) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 if __name__ == '__main__': |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 main(argv) |