Calculating the correct value for horizontal sync position seems difficult. Something is missing and I don't know what.
Currently I do it like this.
hsync_pos = (total_pixels/2 + visible_columns/2*character_spacing)/character_spacing That is, I calculate the pixel where I want the hsync to be in the row (center plus half visible screen area), then divide by character width. Total pixels is 1024 in PAL, visible_columns is 80 in my example and character spacing is 8. This equals 104, but that isn't centered. 101 is. Is the position calculated with an offset or something that makes this a bit off?
It's about time somebody made a little java app to do all this for us
Yes, this is basically what I’m trying to do. Not in Java though. I’m programming in the assembler meta-language so I can define sensible values like width, height and other meaningful properties and get registers for a correctly centered screen. However, I’m starting to give up. I don’t have the means to validate that the resulting signal is according to the TV-standard so whatever I do may be completely wrong but just happens to display correctly on my monitor.
Maybe it is because of the "+1"-rule the VDC-chip applies to some registers? The C128 PRG says:
"R7 VERTICAL SYNC POSITION The number of character rows, plus 1, from the first displayed character row to the start of the vertical sync pulse. This number should be greater than the number in R6 (vertical displayed)."
For some reason the C128 PRG is mostly correct (apart from register 5...)