[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hires calculations
- Subject: Re: Hires calculations
- From: Charles Stephens <devnull@dobbs.eng.sun.com>
- Date: 1999/05/04
- Newsgroups: comp.sys.apple2
- Organization: Sun Microsystems, Inc.
- References: <7gigif$gtu$1@nnrp1.dejanews.com>
>>>>> "BR" == bobryan9 <bobryan9@my-dejanews.com> writes:
BR> How do I calculate the MEMORY LOCATION of a byte on the LEFT SIDE
BR> of the Hires screen, given the Y location?
BR> I would like something like:
BR> MEMLOC=Y (insert math here)
To find a memory location for a given hi-res coordinate, use this
handy formula (remember everything is integer math):
location = base+(40 * cluster)+(128 * clusteroffset)+(1024 * line) + pixelgroup
base = 8192 (for page 1) or 16384 (for page 2)
pixelgroup = x / 7
row = y / 8
line = y mod 8
clusteroffset = row mod 8
cluster = row / 8
Example, you want to find the address for 100,75 on Hi-Res page 1:
base = 8192
pixelgroup = 14
row = 9
line = 3
clusteroffset = 1
cluster = 1
Now, plug it all in:
location = 8192 + (40 * 1) + (128 * 1) + (1024 * 3) + 14
location = 11446 or $2CB6
cfs
--
Charles F. Stephens = "I don't like the cores,
Software Psychic and Illuminary = but the cores like me!"
Solaris Directory Service = -- Marilyn Manson, paraphrased
Solaris Software = "We don't make mistakes, we make
Sun Microsystems, Inc. = happy accidents."
Menlo Park, California, USA = -- Bob Ross