| 1 |
namespace eval trace { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
user_setting create boolean vdpcmdtrace "VDP command tracing on/off" false |
| 6 |
|
| 7 |
proc trace_vdpcmd {} { |
| 8 |
set cmd [debug probe read "VDP.command"] |
| 9 |
if {$cmd eq ""} return |
| 10 |
puts stderr $cmd |
| 11 |
} |
| 12 |
|
| 13 |
variable probe_bp_id |
| 14 |
proc vdp_setting_changed {name1 name2 op} { |
| 15 |
variable probe_bp_id |
| 16 |
|
| 17 |
if {$::vdpcmdtrace} {; |
| 18 |
set probe_bp_id [debug probe set_bp "VDP.command" 1 [namespace code trace_vdpcmd]] |
| 19 |
} else { ; |
| 20 |
catch { debug probe remove_bp $probe_bp_id } |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
trace add variable ::vdpcmdtrace "write" [namespace code vdp_setting_changed] |
| 25 |
vdp_setting_changed ::vdpcmdtrace {} write |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
user_setting create boolean my_cputrace "CPU tracing on/off" false |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
proc trace_cpu {} { |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
set hex [binary encode hex [debug read_block "CPU regs" 0 24]] |
| 40 |
set af [string range $hex 0 3] |
| 41 |
set bc [string range $hex 4 7] |
| 42 |
set de [string range $hex 8 11] |
| 43 |
set hl [string range $hex 12 15] |
| 44 |
set ix [string range $hex 32 35] |
| 45 |
set iy [string range $hex 36 39] |
| 46 |
set pc [string range $hex 40 43] |
| 47 |
set sp [string range $hex 44 47] |
| 48 |
set instr [lindex [debug disasm "0x$pc"] 0] |
| 49 |
puts stderr "$pc : $instr AF=$af BC=$bc DE=$de HL=$hl IX=$ix IY=$iy SP=$sp" |
| 50 |
} |
| 51 |
|
| 52 |
variable cond_id |
| 53 |
proc cpu_setting_changed {name1 name2 op} { |
| 54 |
variable cond_id |
| 55 |
|
| 56 |
if {$::my_cputrace} {; |
| 57 |
set cond_id [debug condition create -command [namespace code trace_cpu]] |
| 58 |
} else { ; |
| 59 |
catch { debug condition remove $cond_id } |
| 60 |
} |
| 61 |
} |
| 62 |
trace add variable ::my_cputrace "write" [namespace code cpu_setting_changed] |
| 63 |
cpu_setting_changed ::my_cputrace {} write |
| 64 |
|
| 65 |
} ; |