[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Synchronising code with the scan line
In article <1993May30.234956.8424@labtam.labtam.oz.au> philip@labtam.labtam.oz.au (Philip Stephens) writes:
> I have a question for you hardware gurus out there.
> I don't have the Apple //GS hardware reference, but I do have _Inside the
>Apple //GS_. It listed $C02E as something akin to the scan line counter,
>but was coy about it's real function and said only the firmware uses it.
>Is this what I'm looking for, and if so, what does it do exactly and what
>are the cavets in using it?
Look up the Stripes demo, which is available here at cco.caltech.edu
in the pub/apple2/demos directory. It has a copy of the IIGS Technote (#17 ?)
an explanation of how to use $c02e, and a bunch of source. Basically, here's
a shortened version of how to use it:
[Long Accum on]
lda >$01c02e
and #$FF ;mask out $c029-- horizontal posn counter
rol a ;v-counter is 9-bits long; masked out bit that was in c02e
cmp #256+WantPos
bge PastPosn ;bge=bcs
Here's some explanation: The v-counter is a 9-bit number representing the
position on the screen. When it's 256, it's at line 0, the top line on the
screen. 455 is similarly the bottom of the screen. Unfortunately, the 9
nits are not nicely split between the two bytes of $c02e-2f; to quickly read
the position to within a line or two, use this code. As the 65816 can't do
"cmp #256+Wantpos" (Not too many systems I know can, though), make a variable
to be that.
One warning: This is apparently for NTSC mode; if you have a PAL system
(Europe and other 50Hz systems), the line offsets are different. Check out
the technote; it's got the full set of info.
Nathan Mates
--
* Nathan Mates nathan@cco.caltech.edu * MSC #850, Pasadena CA 91126
* No fancy quote, no disclaimers for irate employers, no .sig-- oops,
* Too late for that! Several Megabyte joke collector and IIGS hacker
* operating out of Caltech, the world's best place for an education!