[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mental challenge: the rainbow



On 02/10/2012 04:21 PM, BLuRry wrote:
> Is it possible to sync with VBL such that during VBL, and during the majority of each HBL the apple is put in a text mode but during active signal output throw it back to graphics?  That should fake out the apple to not send a color bust, right?   Would be interesting to get a grayscale mode... really just for kicks if nothing else.

To see the effect, just write some simple loop that takes exactly 64
cycles and repeatedly switches back and forth between graphics and text.
If you just start it by hand several times, you'll get color in some
cases and no color in others, depending on whether graphics are active
or not during the color burst phase of each line.

The problem with this is that it's hard to do anything else at the same
time. You can stop the switching (stay in text mode, do your processing)
during VBL, but I assume it's difficult to get back up again at the end
of VBL at the right moment, unless your whole processing code is also
cycle counted.

If you have a cyclical interrupt source such as a Mockingboard or other
MOS6522 card available, it would help with restarting the switching in
time. First you'd have to perfectly align the 6522 with the video
scanner. That takes some tricky code, testing the VBL condition (via
vaporlock techniques, or directly on the //e and above) on several
consecutive frames and shifting the alignment up or down as necessary,
since you can't test it every cycle. AFAIK it can be done with three
frame times of testing, if you get it right.

After this, then the Mockingboard would interrupt the CPU on exactly the
same, known spot in every frame, shortly before the end of VBL. But
you'd still end up some cycles off, since interrupts on the 6502 family
don't interrupt within instructions, only in between them. I guess you
could read the re-started counter from the 6522 and use the value you
read to go down six different code paths (I think six is the highest
number of cycles any 6502 instruction takes, right?), each of them
taking one cycle longer than the one before, then re-converging. That
way you could shift your switching code back and forth so that it aligns
in lock-step with the color burst generation. The whole process is
similar to the FLI and IFLI modes used in some of the later C64 stuff.
Also similar in spirit to ZX81 or Atari 2600 programming.

Oh, and no, I've never written such a program.

-- 
Linards Ticmanis