Emulation for develping SW that works on real HW: FEATURE REQUEST (Emulation MSX Forum)MSX Resource Center               
              
English Nederlands Espa�ol Portugu�s Russian French         

MSX Forum


MSX Forum

Emulation - Emulation for develping SW that works on real HW: FEATURE REQUEST

Goto page ( 1 | 2 | 3 | 4 Next Page )
Author

Emulation for develping SW that works on real HW: FEATURE REQUEST

ARTRAG
online
msx guru
Posts: 2229
Posted: June 06 2009, 11:28   
Hi,
I would greatly appreciate if bluemsx or openmsx teams would consider the possibility to add a tool/feature able to spot the possible loss of I/O data to from the VRAM

It would be sufficent to spot the sections of code where the successive outs are spaced < that 26cycles!!

Please!!!
:-)
hap

msx professional
Posts: 688
Posted: June 06 2009, 11:49   
It should be possible with an openMSX TCL script. Mayhaps somebody with a bit of knowledge there can make you one.
ARTRAG
online
msx guru
Posts: 2229
Posted: June 06 2009, 14:42   
well
in the emulator you should only add a function that counts the cycles btween successive outs
it would be a great help in teh debugger to have a way to enlight these cases

manuel
msx legend
Posts: 4321
Posted: June 06 2009, 18:01   
I think I would be able to make a script that checks if the time between two writes on I/O port 0x98 is smaller than a certain value and put the result in the console or a file. Would that help?
If so, I'll make an attempt to write such a script. You can help by precalculating the time
ARTRAG
online
msx guru
Posts: 2229
Posted: June 06 2009, 18:11   
Great! The time should be 26 cycles!

Hem... how do you return where the suspicious outs are?

The best would be to have automatic breakpoints in the debugger that trigger at the location of the out that incurs in the condition.
It should also be possible to disable these breakpoints individually in case of valid I/O (e.g. when in Vblank)

manuel
msx legend
Posts: 4321
Posted: June 06 2009, 18:21   
I'm going to make a small script, not going to change the debugger GUI. Consider it a proof of concept. 26 cycles is nice, but I need it in (micro)seconds

When such an out occurs, I could simply print the current PC.

If you give me a sample program with some known 'bad outs', I can use it to test the implementation.
Please join #openMSX to continue this discussion more easily (e.g. via http://openmsx.sf.net/mibbit.php )
ARTRAG
online
msx guru
Posts: 2229
Posted: June 06 2009, 19:16   
well, 26 cycles is 26/3579545 sec = 7.2635e-006sec = 7.2635e us (microsec)
wouter_
msx user
Posts: 41
Posted: June 06 2009, 22:37   
This very simple script should get you started, you can tweak it till it matches exactly your needs. To use it, save it to some file e.g. vdp-timing.tcl and then in the openMSX console type
source vdp-timing.tcl


set last_vdp_time 0

proc vdp_io_write {} {
        global last_vdp_time
        set now [machine_info time]
        set min_diff [expr 26.0 / 3579545]
        if {($now - $last_vdp_time) < $min_diff} {
                # tweak this line to generate the logging you like
                puts stderr "Too fast VDP access detected (pc = [reg pc])"
                # uncomment this line if you want to break at this point
                # debug break
        }
        set last_vdp_time $now
}

debug set_watchpoint write_io 0x98 true vdp_io_write


Manuel is still working on a more extended script. For example to ignore timing problems when screen is disabled, or to only log an error once for the same instruction.
manuel
msx legend
Posts: 4321
Posted: June 06 2009, 22:44   
I've already finished it in the mean time. It has the code wouter pasted as core, but some more luxury around it

Let me know if you want it, or if you want it posted here. (I already sent it by mail to ARTRAG.)
ARTRAG
online
msx guru
Posts: 2229
Posted: June 07 2009, 00:09   
manuel, your script ROCKS!!!
I haven't jet tested the new DDA code after the patches, but without your script it would have been a pain find all the criticalities !
THANKS!!
ARTRAG
online
msx guru
Posts: 2229
Posted: June 07 2009, 10:38   
PS
manuel, you should pubblish this script, it helps a lot the msx1 developers
sjoerd
msx addict
Posts: 457
Posted: June 07 2009, 11:19   
Yes, it would be very helpfull.

Is it also possible to take the vblank in account?
manuel
msx legend
Posts: 4321
Posted: June 07 2009, 11:30   
OK, here is the more luxurious script. You can enable checking on too fast VDP writes by typing "toggle_vdp_write_test" in the console. For this to work, put the script in your share/scripts directory of your openMSX installation. Of course you can tweak the script yourself (for ease of doing that I put the I/O port and the amount of cycles to check for at the top). The script will show the list of addresses where too fast VDP I/O is done after each newly found value. Toggle off and on to reset this list. All results are displayed in the console. Enjoy!

Oh, there's also a debug flag. If you set it to 'true', you'll also see *good* writes. But that tends to give a lot of output

namespace eval vdp_write_test {

# you can tweak these to test for other stuff
variable ioport 0x98
variable cycle_max 26
# if you set this to true, you can also see OK writes, but there are many of those!
variable debug false

variable last_write_time 0
variable is_enabled false
variable watchpoint_id
variable address_list

proc check_time {} {
	variable last_write_time
	variable cycle_max
	variable debug
	variable address_list

	set current_time [machine_info time]
	set cycles [expr round($::z80_freq*($current_time - $last_write_time))]
	set screen_enabled [expr [debug read "VDP regs" 1] & 64]
	set pc [format "%04x" [reg PC]]
	if {($cycles < $cycle_max) && $screen_enabled} {
		if {[lsearch -exact $address_list $pc] == -1} {
			puts [format "VDP I/O write too fast on address: 0x%s, took $cycles cycles (< $cycle_max)" $pc]
			lappend address_list $pc
			puts "List of addresses where too fast I/O is done: $address_list"
		}
	} else {
		if {$debug} {
			if { !$screen_enabled } {
				set reason "screen is disabled"
			} else {
				set reason "took $cycles cycles, > $cycle_max"
			}
			puts "VDP I/O write OK on address: 0x$pc, $reason"
		}
	}
	set last_write_time $current_time
}

proc toggle_vdp_write_test {} {
	variable is_enabled
	variable watchpoint_id
	variable address_list
	variable ioport

	if {!$is_enabled} {
		set watchpoint_id [debug set_watchpoint write_io $ioport {} vdp_write_test::check_time]
		set is_enabled true
		set address_list [list]
	} else {
		debug remove_watchpoint $watchpoint_id
		set is_enabled false
	}
}

namespace export toggle_vdp_write_test

} ;# namespace vdp_write_test

namespace import vdp_write_test::*


I hope you guys can look at these scripts and learn how to write similar things yourself. It's not that hard, really.

If you have questions about it, please ask.

A great intro in Tcl is here: http://www.beedub.com/book/2nd/tclintro.doc.html
Huey
msx professional
Posts: 858
Posted: June 07 2009, 11:56   
Big thanks Manuel!!
manuel
msx legend
Posts: 4321
Posted: June 07 2009, 12:17   
sjoerd: taking the vblank into account is a bit tricky, because there isn't a way (yet) to check if vblank is currently active.

Huey: you're welcome! Make sure you guys look at the scripts and use it to learn how to come up with this yourself That makes you less dependent on people like me ;-) (And publish your cool scripts, of course!)
 
Goto page ( 1 | 2 | 3 | 4 Next Page )
 







(c) 1994 - 2010 MSX Resource Center Foundation. MSX is a trademark of MSX Licensing Corporation.