Jump to content
  • 1
Geehaf

Determine current raster line?

Question

I think the answer to my question is NO but does anybody know if there is a way to determine the "current" raster line being rendered by VERA?

On the C64 you could simply issue a:

LDA $D012

(with the MSB being held in the $D011 register)

Thanks,

G
 

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
14 hours ago, Johan Kårlin said:

I don't think so, but as you might know you can have an interrupt triggered at a certain line as described in the VERA's Programmer's Reference.

Thanks Johan - Yes I'm currently using the line interrupts but was curious about the above. Cheers.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Is it possible to get the current line in the emulator (rather than in code)? I want to see how much of a frame my code that should be run every frame is using (or is there a better way to measure that than counting scanlines?)

Share this post


Link to post
Share on other sites
  • 0

Maybe you could have a look at the "CPU Meter".

The idea is to create a loop at the end of your code that counts the cycles it waits for a vertical blank, and use that number to remap it to a CPU use percentage.

Hope it helps.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, lamb-duh said:

Is it possible to get the current line in the emulator (rather than in code)? I want to see how much of a frame my code that should be run every frame is using (or is there a better way to measure that than counting scanlines?)

I mean, if you're looking at modifying the emulator (or else setting a breakpoint or some such), then yes you can absolutely get the current line. Look at scan_pos_y in video.c. Just beware that to get the actual visible line you'll need to subtract VGA_FRONT_PORCH_Y, and the value will periodically exceed 480. The reason for this is because the VGA specification includes v-blank periods before and after the 480 visible lines.

Also, when it comes to understanding how long your code is running, the emulator keeps track of the number of clock cycles that have elapsed since the system was turned on, in clockticks6502 (see also cpu/fake6502.h).

clockticks6502 is also exposed to the X16 via ports $9fb8, $9fb9, $9fba, and $9fbb. Note that this is behavior specific to the emulator and likely will not exist on the actual hardware. The value is in little-endian order: $9fb8 is the least significant byte and $9fbb is the most significant byte.

Share this post


Link to post
Share on other sites
  • 0
14 minutes ago, kliepatsch said:

Maybe you could have a look at the "CPU Meter".

The idea is to create a loop at the end of your code that counts the cycles it waits for a vertical blank, and use that number to remap it to a CPU use percentage.

Hope it helps.

that's more code than I want to deal with for this, but the idea given by Johan Kårlin in that thread to change a background colour would work perfectly to give a visual idea of how long different sections of your code are taking

 

14 minutes ago, StephenHorn said:

I mean, if you're looking at modifying the emulator (or else setting a breakpoint or some such), then yes you can absolutely get the current line. Look at scan_pos_y in video.c. Just beware that to get the actual visible line you'll need to subtract VGA_FRONT_PORCH_Y, and the value will periodically exceed 480. The reason for this is because the VGA specification includes v-blank periods before and after the 480 visible lines.

I was hoping to find something in the debugger without having to make any changes. But the emulator's cycle counter could do what I want. It doesn't need to work an actual hardware, I just want to time how long different sections of code take to execute

Share this post


Link to post
Share on other sites
  • 0

I am still changing a color. I read somewhere that C64 game developers often just did inc $D020 to change the border color in the beginning and in the end of the interrupt handler. Very easy and useful. On the X16 it’s an easy solution too. Most of the times you don’t need an exact value, you just want to make sure that you have a lot more cycles to spend. But still it’s surely interesting that there is a counter at $9fb8, I had no idea.

Edited by Johan Kårlin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use