Wavicle wrote: ↑Thu May 15, 2025 6:45 pm
You seem to be holding context in your head that you aren't expressing here. There are HSCROLL and VSCROLL registers, but you are using language "scroll register Y" and "scroll register X" which creates ambiguity as to whether you are using "scroll register Y" to mean "VSCROLL" or if it means "some arbitrary scroll register other than X". I need a bit more precision to investigate this.
What I mean when I say any scroll Y register, I mean them all:
L0_VSCROLL_L also called V-Scroll (7:0), and L0_VSCROLL_H also called V-Scroll (11:8),
And L1_VSCROLL_L also called V-Scroll (7:0), and finally L1_VSCROLL_H also called V-Scroll (11:8).
Once you get control of execution from an IRQLINE_L (Write only) also called IRQ line (7:0) and IEN scan line (8), the raster beam of the CRT has already started drawing for that requested scanline. That is understandable since the IRQ vector is in ROM code, and for some design reason, the LINE interrupt is fired at the beginning of the active display instead of at the end.
But now there is the problem of all of those registers I said in the smaller size above, as you get control of your interrupt, and must first save all the states of VERA, and then check for what interrupt you are servicing, changing the registers will affect the next scanline, or the scanline next to the next scanline? DC_VSCALE also known as Active Display V-Scale is set to $40, so sometimes half of the scaled pixels are cut in half by the scroll change (which should be impossible), which is not the same for horizontal scrolling when DC_HSCALE also known as Active Display H-Scale is set to $40.
What all this means is that whenever CPU speed is increased in the future, or cycles changes because of an upgraded CPU type (the 16-bit variant running in its 8-bit mode), all the games that rely on tight timings of LINE interrupts will fail. And when HDMI is added, will that also affect timings like how NTSC is different from VGA?
The demo on the SD card coming with the computer called "SONIC.PRG" has been updated to work with the newer VERA timings, but it fails in NTSC, and you can see errors in the timings in VGA (see my first post screenshots in this thread). This demo was one of the first demos written for this computer, and it had to be maintained by someone every time the computer changed. If downloaded from the internet, an older broken version will most likely fall into your hands. I am trying to not get that some situation with my game.
Oh, and "DEMOS/SONIC.PRG" only changes L0_HSCROLL_L also known as H-Scroll (7:0) + (8).
Official documentation states:
Note that VERA renders lines ahead of scanout such that line 1 is being rendered while line 0 is being scanned
out
So in VGA, with DC_HSCALE and DC_VSCALE set to $40, setting L0_HSCROLL_L while SCANLINE_L (Read only) is $02 and IEN scan line (8) is $0 will guarantee that the change happens when SCANLINE_L (Read only) is $03.
Remember that scale is in effect, so one unit of scroll is 2 pixels! So we are now scrolling on half a pixel, which won't be noticeable until SCANLINE_L (Read only) is $04. Great, no harm. But what about L0_VSCROLL_L? Well, that one will cut the pixel in half. Timings and order of these registers are very tricky and precise to get the output desired. By that information alone, I would say L0_HSCROLL_L has priority over L0_VSCROLL_L because of discrimination: My game scrolls horizontal so it is more important than yours that scrolls vertically. But the truth is most likely that there are no official software yet that uses vertical scrolling, so I need to get my game out there ASAP. Once I do, I believe I will be the one who locks these issues in place rather than helping to fix them. That's why I am doing this thread now.
It might be hard to see how you can scroll something vertically by using a LINE interrupt. But this is something many games do to make 3D effects, by scrolling to hide every other scanline, or duplicate them.
MooingLemur wrote: ↑Fri May 16, 2025 12:57 am
Could the issue be simply that on VGA, you will get 480 visible lines (525 total lines) in 1 frame, and on NTSC and RGB, you get 525 total lines (or 526 in 240p) in two frames. Therefore, each scanline scans out at (approximately) half the speed?
Therefore 63 NOPs would only consume half a line, as expected.
Yea, it was the case combined with the fact that VGA scans out 2 scanlines and NTSC skips one scanline because of progressive mode. So even if something takes longer to do, the rules are so different that you can't use the same code for both modes. VGA gets the color change on an odd scanline (which looks bad if you notice it), and NTSC gets the color change in the middle of the screen with the jitter and 16-bit writes mismatch colors all visible. For scroll register though, many games would benefit from a well defined behavior when writing to the registers that gets latched at some point during the scanout.
Once NTSC 240p is done with a scanline, it doesn't just wait for a blank scanline but rather start a new one. In VGA, once you have reached the first scanline, you have one more scanline to do, and that gives time to get out of the interrupt and continue the game for a few cycles before being interrupted again.
All of my game logic is done outside of vblank, and I am surprised how powerful the 65C02 is at doing extreme stuff that 8-bit computers shouldn't be able to do, all of that while still being interrupted so often just to set a few scroll registers and update the backdrop (I would say over 50% of the frame time is interrupted code and not game code). But if you WAI for the next scanline inside the LINE interrupt code, then you have to run all the game logic inside vblank, and that is truly a waste and bad game design in general.
If I had designed this computer (which I am not qualified to do), I would have put aside an area in VRAM for line scroll tables (that could be turned on or off when needed), and have VERA fetch those on new scanlines automatically. It would have been like the SNES's HDMA. That wouldn't have helped with the color change though, but many developers wouldn't even think about extending colors beyond the 256 limit on a frame. I just want the color change because it is cooooool.