cff531af |
1 | /* |
2 | * PicoDrive |
3 | * (C) notaz, 2007 |
4 | * |
5 | * This work is licensed under the terms of MAME license. |
6 | * See COPYING file in the top-level directory. |
7 | */ |
4f65685b |
8 | #include <stdio.h> |
9 | |
10 | typedef struct |
11 | { |
12 | unsigned int addr_min, addr_max; |
13 | int r8, r16, r32, w8, w16, w32; |
14 | } io_log_location; |
15 | |
16 | static io_log_location io_locations[] = |
17 | { |
18 | { 0x400000, 0x9FFFFF, 0, }, // unused |
19 | { 0xa00000, 0xa03fff, 0, }, // z80 RAM |
20 | { 0xa04000, 0xa05fff, 0, }, // ym2612 |
21 | { 0xa06000, 0xa060ff, 0, }, // bank reg |
22 | { 0xa06100, 0xa07eff, 0, }, // unused |
23 | { 0xa07f00, 0xa07fff, 0, }, // vdp |
24 | { 0xa08000, 0xa0ffff, 0, }, // 0xa00000-0xa07fff mirror |
25 | { 0xa10000, 0xa1001f, 0, }, // i/o |
26 | { 0xa10020, 0xa10fff, 0, }, // expansion |
27 | { 0xa11000, 0xa110ff, 0, }, // expansion |
28 | { 0xa11100, 0xa11101, 0, }, // z80 busreq |
29 | { 0xa11102, 0xa111ff, 0, }, // expansion |
30 | { 0xa11200, 0xa11201, 0, }, // z80 reset |
31 | { 0xa11202, 0xbfffff, 0, }, // expansion |
32 | { 0xc00000, 0xc00003, 0, }, // vdp data port |
33 | { 0xc00004, 0xc00007, 0, }, // vdp control |
34 | { 0xc00009, 0xc0000f, 0, }, // hv counter |
35 | { 0xc00010, 0xc00017, 0, }, // PSG |
36 | { 0xc00018, 0xc0001f, 0, }, // unused |
37 | { 0xc00020, 0xdfffff, 0, } // vdp mirrors |
38 | }; |
39 | |
40 | |
41 | void log_io(unsigned int a, int bits, int is_write) |
42 | { |
43 | int i; |
44 | a &= 0x00ffffff; |
45 | if (bits > 8) a&=~1; |
46 | |
47 | for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) |
48 | { |
49 | if (a >= io_locations[i].addr_min && a <= io_locations[i].addr_max) |
50 | { |
51 | switch (bits|(is_write<<8)) { |
52 | case 0x008: io_locations[i].r8 ++; break; |
53 | case 0x010: io_locations[i].r16++; break; |
54 | case 0x020: io_locations[i].r32++; break; |
55 | case 0x108: io_locations[i].w8 ++; break; |
56 | case 0x110: io_locations[i].w16++; break; |
57 | case 0x120: io_locations[i].w32++; break; |
58 | default: printf("%06x %i %i\n", a, bits, is_write); break; |
59 | } |
60 | } |
61 | } |
62 | } |
63 | |
64 | void log_io_clear(void) |
65 | { |
66 | int i; |
67 | for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) |
68 | { |
69 | io_log_location *iol = &io_locations[i]; |
70 | iol->r8 = iol->r16 = iol->r32 = iol->w8 = iol->w16 = iol->w32 = 0; |
71 | } |
72 | } |
73 | |
74 | void log_io_dump(void) |
75 | { |
76 | int i; |
77 | printf(" range : r8 r16 r32 w8 w16 w32\n"); |
78 | for (i = 0; i < sizeof(io_locations)/sizeof(io_locations[0]); i++) |
79 | { |
80 | io_log_location *iol = &io_locations[i]; |
81 | if (iol->r8 == 0 && iol->r16 == 0 && iol->r32 == 0 && iol->w8 == 0 && iol->w16 == 0 && iol->w32 == 0) |
82 | continue; |
83 | printf("%06x - %06x : %8i %8i %8i %8i %8i %8i\n", iol->addr_min, iol->addr_max, |
84 | iol->r8, iol->r16, iol->r32, iol->w8, iol->w16, iol->w32); |
85 | } |
86 | printf("\n"); |
87 | } |
88 | |