About OpenMSX and measuring time

Por rjp

Master (193)

Imagen del rjp

12-05-2020, 17:35

Hi, I'm using OpenMSX to develop software for MSX. So, I made up a simple "integrated development environment", using Linux, Geany, OpenMSX and some TCL and shell scripts. So I write the Pascal code in Geany, and when I press F9, it runs and overclocked (10000%, hehehe) MSX 2 in OpenMSX, which compiles my code, using Turbo Pascal 3.0 or TP33F, from CPU. Here is some excerpts from my project, here and here. The github page is here (sorry, there aren't any English versions yet, only Portuguese).

My shell script counts how many lines does the program (and its includes) have, so I can have an idea of how much time does the OpenMSX should be running overclocked, in order to compile my code. It would be very nice if OpenMSX has its speed lowered to 100% when the compile ends. But I don't know how much time does it will spend.

Here goes an excerpt of my tcl script:
set power on
after boot "set speed 10000"
##
after time 16 "type d:compila.bat ; type \\r"
after time %%TIME2%% "diskmanipulator export hda4 /home/ricardo/MSX/programacao/dev/sandbox"
after time %%TIME3%% "set speed 100"

My script changes %%TIME2%% and %%TIME3%% tags to the time I need to lower the clock of the emulated MSX and export the drive D (which is my sandbox) to another directory. But I don't know how much time does it will spend.

Finally, is there a way of measuring this time in OpenMSX, in order to make my script more precise?

Thanks!

Login sesión o register para postear comentarios

Por FiXato

Scribe (1742)

Imagen del FiXato

12-05-2020, 17:43

Instead of time-based, couldn't you watch for a specific memory address being addressed at the end of the compilation?

Por rjp

Master (193)

Imagen del rjp

12-05-2020, 17:56

Maybe it's an idea, but I don't know how can I do it. I was thinking about changing to after realtime, instead of after time, in the TCL script.

Por Manuel

Ascended (19332)

Imagen del Manuel

12-05-2020, 19:49

Why would you change to realtime?

I'd go for Fixato's idea. If there is some state of the MSX in which you can see that compilation has ended (e.g. some hook that is called, or some text that appears on screen), you can let a script set the speed back to 100%.

Por rjp

Master (193)

Imagen del rjp

12-05-2020, 21:25

Well, it's a better idea, to use the after . But I don't know which event can I monitor? Really, I don't know that much to know which event can be monitored. But I've got an idea, about using bind command... Let me see...

Por pgimeno

Champion (328)

Imagen del pgimeno

12-05-2020, 23:21

You could generate your own event, e.g. make a short program that writes a byte to an otherwise unused system variable, and run it at the end of the compilation. Then with Tcl, you set a watchpoint that monitors that variable.

Por rjp

Master (193)

Imagen del rjp

13-05-2020, 00:59

Well, I'm a OpenMSX noob, and I'm trying to figure how can I trigger this event. I'm trying to do these scripts as a automatic routine. , and as I saw, I'll need to use OpenMSX debug features, and I really don't know how to use it.

Por pgimeno

Champion (328)

Imagen del pgimeno

13-05-2020, 12:35

I've tested the method with this program:

		org	0100h
		ld	hl,0FFFDh
		di
		inc	(hl)
		ei
		dec	(hl)
		rst	0

which I assembled to a .com file called trigger.com.

Then in your Tcl script, you can write:

set mywp [debug set_watchpoint write_mem 0xfffd {} {variable mywp; debug remove_watchpoint $mywp; set throttle on}]

That assumes that you're using 'set throttle off' instead of 'set speed 10000' but feel free to change the above to 'set speed 100' instead of 'set throttle on'. I just think that completely removing the throttle is easier.

Edit: Or maybe you don't need to clear the watchpoint, you can just leave it installed so that every time you call the .com file, the throttle is reenabled:

debug set_watchpoint write_mem 0xfffd {} {set throttle on}