TCL scritping to figure out line-interrupt timings?

By Sandy Brand

Champion (301)

Sandy Brand's picture

09-09-2019, 23:40

Hey everyone!

Does anyone know if there is a way to read out the current screen line that the VDP is drawing using using TCL?

This would be very useful information for optimizing VDP utilization using line-interrupts with VDP R19. Ideally, I would like to be able to measure things such as:

  • How many lines does it take to perform the interrupt handler.
  • And how many lines does it take from the beginning of the interrupt handler to the completion of a VDP command that was started in that handler.

I have been searching through some of other people's TCL scripts, but so far the only thing I have found is something like this:

debug probe set_bp z80.acceptIRQ ........

For measuring the time inside the handler we could use the same trick as used in Grauw's TCL profiler script whereby we detect the 'exit' point of the interrupt handler by checking when the stack pointer is the same as at the moment of entry.

This is a good start but I am missing some other vital scripting elements such as reading the current screen line and detecting when VDP commands are completed (or started even).

I took a quick look at some of the openMSX source code, but I don't immediately see anything like this being exposed to TCL?

Any tips and/or suggestions would be very welcome :)

Login or register to post comments

By ricbit

Champion (438)

ricbit's picture

10-09-2019, 06:26

There is [machine_info VDP_msx_y_pos]. I discovered it by browsing the source code.

By Grauw

Ascended (10768)

Grauw's picture

10-09-2019, 08:44

It would be really nice if openMSX had a probe to signal the VDP command completion... Then I could accurately measure and chart that.

By nikodr

Paladin (750)

nikodr's picture

10-09-2019, 11:11

I suppose sdl2 would easily offer such feature for the openmsx?
Or rather the debugger of openmsx should have it to assist debugging info regarding vdp access and timings?

By wouter_

Hero (525)

wouter_'s picture

10-09-2019, 19:07

@Sandy Brand: openMSX has the following info topics to indicate where the VDP is 'drawing':

   VDP_cycle_in_frame
   VDP_cycle_in_line
   VDP_frame_count
   VDP_line_in_frame
   VDP_msx_x256_pos
   VDP_msx_x512_pos
   VDP_msx_y_pos

'VDP_line_in_frame' counts absolute line numbers from the start of the frame, thus including vertical border lines. 'VDP_msx_y_pos' compensates for vertical set-adjust so that you get the same numbers as the usual msx-coordinates.

Alternatively you can query the 'time' info topic twice and subtract to measure a time period in seconds (as a floating point value). And multiply by the clock frequency to get a value in clock cycles.

To discover other info topis execute the commands 'machine_info' or 'openmsx_info' without parameters. Or use something like "join [lsort [machine_info]] \n" to more nicely format it.

@Grauw: A probe on VDP command completion (and command start) was very easy to implement. See this patch (see example usage in the commit message).

@nikodr: I don't see how any of this is related to SDL2.

By Grauw

Ascended (10768)

Grauw's picture

10-09-2019, 19:39

@wouter_ Ha that’s awesome! I’ll start using it straight away! Big smile

(This could also make the built-in openMSX toggle_vdp_busy more accurate.)