I noticed yesterday that my memory detection code that pokes in register 28 is disruptive. Memory gets corrupted after switching back and forth to test the memory capacity and even if I clear the memory just after there is a chance that artifacts will be visible on the screen a short while before the memory is cleared. So I'm looking for a way to blank the screen during this short period. Is there some way to do that, preferrably without the monitor desyncing?
Have you tried blanking the screen using HBLANK(VDC registers 34 and 35)? Setting both of them to the same value should blank the screen. Another trick is to set register 34 to a value greater than the total horizontal character positions.
As stated from Mapping the Commodore 128 the blanking only covers the text, doesn't erase implies it is safe for the monitor. It doesn't change any frequencies so should be safe for any monitor. I've tested multiple times on my 1084 with no issues.
34 $22 35 $23 Horizontal blanking positions The VDC can adjust its horizontal blanking interval to blank a portion of the screen. These locations control the horizontal width and position of the blanked area. If the blanked area extends onto the active portion of the screen, any text under the blanked area is only covered, not erased. The value in register 34/$22 determines the rightmost blanked column, and the value in register 35/$23 determines the leftmost blanked column. The blanked area extends the entire height of the screen.
The value in register 34/$22 must be less than the value in register 0/$00; otherwise, the entire display will be blanked. The value in 34/$22 here must also be greater than the value in register 35/$23 to prevent an entirely blank display. The default values for these locations are 125/S7D and 100/$64, respectively. This positions the blanking interval entirely outside the active screen area. For purposes of blanking an area of the screen, a value of 6/$06 in these registers corresponds to the leftmost column of the standard screen and a value of 85/$55 corresponds to the rightmost column.
Another option to turn the screen black is discussed here
In summary:- The screen turns black if:-
horizontal smooth scroll (bits 0-3 of VDC register 25) is greater than the character width (bits 4-7 of VDC register 22) for single pixel mode.
horizontal smooth scroll (bits 0-3 of VDC register 25) is greater than or equal to the character width (bits 4-7 of VDC register 22) for double pixel mode.
Another method is to disable attributes (reg #25 bit 6 = 0) and then set the foreground and background colours to black (reg #26 = 0), making everything black..
Nice! This won’t change the screen mode and this can also be used instead of a memory clear when the graphic mode is taken over.
Yes it's screen mode/size independent, and unlike the other methods suggested you can blank the screen to any colour, much like $d011 blanking on the VIC-II.
btw the blanking with registers 34/35 is not quite what the documentation says, e.g. setting #34=#35 only blanks if they are both <= reg #0. If they are both > #0 then it has no effect. Setting #34 > #0 and #35 <= #0 seems a reliable way to blank to black.
But... I prefer my method, no mucking around with what values are in what. It's first couple of steps in vdc101 setup so I know it works