Subject: Re: Hires calculations Path: lobby!newstf02.news.aol.com!portc01.blue.aol.com!news-peer.gip.net!news.gsl.net!gip.net!howland.erols.net!newsfeed.wli.net!su-news-hub1.bbnplanet.com!denver-news-feed1.bbnplanet.com!news.gtei.net!namche.sun.com!news2me.EBay.Sun.COM!engnews1.eng.sun.com!not-for-mail From: Charles Stephens Newsgroups: comp.sys.apple2 Date: 04 May 1999 12:01:28 -0700 Organization: Sun Microsystems, Inc. Lines: 43 Message-ID: References: <7gigif$gtu$1@nnrp1.dejanews.com> NNTP-Posting-Host: brak.eng.sun.com X-Face: (xx[.&.0Swozm=m{+3EKI~Wiz/bZn}xO&',E2Q)s!4BVkO"5Warsdm>3E}5uY'wkp%(zm{p1>A>>>> "BR" == bobryan9 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