Path: info.curtin.edu.au!uniwa!munnari.oz.au!news.Hawaii.Edu!ames!haven.umd.edu!darwin.sura.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!valthoff
From: valthoff@magnus.acs.ohio-state.edu (Victoria M Althoff)
Newsgroups: comp.sys.apple2.programmer
Subject: Hi-res Graphics
Date: 11 Oct 1993 05:07:29 GMT
Organization: The Ohio State University
Lines: 75
Message-ID: <29apmh$der@charm.magnus.acs.ohio-state.edu>
NNTP-Posting-Host: bottom.magnus.acs.ohio-state.edu
Disclaimer:  "Apple" is a registered tm. of You-Know-Who

I have received an EMAIL request to expound upon the design of the Apple ][ 
hi-res/double hi-res screen.  In case others are interested, I post it here.  
As usual, comments, additions, corrections, etc. are encouraged L8-)

You-Know-Who's hi-res pages begin at $2000.  Each occupies 8k of memory; two 
can be displayed.  Hires page 3 ($6000-$7FFF) exists only in the minds of 
certain programmers, as it cannot be displayed.
QUESTION:  Why does hi-res start, inconveniently, in the middle of BASIC 
program workspace (which starts at $800)?
ANSWER:  So that you can display hi-res graphics on an Apple ][ with only 16k 
memory (much more common in 1975 than it is today!)

Those 8k of graphic space are mapped out in a strange way.  If you display the 
hi-res page 1 and start filling the memory spaces from $2000-$3FFF with $FF's, 
you will see the screen begin to fill with white.  First the top line, then a 
line about 1/3 of the way down, then a line near the bottom.  Then the EIGHTH 
line from the top, eight lines below the second line filled, eight lines below 
the third line, then the 16th line.
QUESTION:  WHY?????
ANSWER:  Lots of 6502 graphics programmer would like to know.  Actually, it 
involves saving a couple of chips in the display hardware.  That means saving 
1975-era dollars when chips were expensive.

If you perform the experiment above (from APPLESOFT, try...
]HGR:POKE-16302,0:FOR X = 8192 TO 16383:POKE X,255:NEXT),
you will notice that each line fills in chunks...40 chunks per line, to be 
exact.  Funny how everything on the screen seems to be in 40's!  Each chunk is 
seven pixels, so 7*40=280.  Now for the trickery:  This is (a) how you can 
display four different colors using only 1 bit per pixel, and (b) why BLACK and
WHITE appear twice in the hi-res color chart.

The screen is laid out so that the horizontal position of a pixel will 
determine its color.  All EVEN horizontal positions will be either VIOLET or 
BLUE, and all ODD horizontal positions will be either GREEN or ORANGE.  And, 
there is no such thing as a WHITE point.  Try this:  Using HCOLOR=3 (white), 
try HPLOT 0,0 TO 0,191.  You should get a violet line running down the left 
edge of the screen.  If you then issue a "HGR:HPLOT 1,0 TO 1,191" you should 
get a green line running down the left edge.  Notice that in both cases, you 
use HCOLOR=3, which the Applesoft ][ manual says should be WHITE.  Instead of 
white, you get violet or green!
QUESTION:  How do you get white?
ANSWER:  Plot two pixels side-by-side!  Try this:
]HGR:HCOLOR=1:HPLOT 1,0 TO 1,191:REM You get a green line.
]HCOLOR=2:HPLOT 0,0 TO 0,191:REM Adding the violet line makes both lines appear
white.
This means that you cannot display green and violet in adjacent pixels...the 
result will look white.  This also means that the HCOLOR= command just 
restricts the horizontal positions where pixels will be turned on.
QUESTION:  What about orange and blue?
ANSWER:  Remember that a standard byte is 8 bits?  Remember how only 7 are used
to represent the pixels on the screen?  The 8th bit (128's place) is used to 
select the color set.  This is why white and black appear twice in the color 
pallette:  HCOLOR = 0 and 3 leave the 128's bit cleared, while HCOLOR=4 and 7 
will set the high bit.  Try this:
]HGR:HCOLOR=3:HPLOT 1,0 TO 1,191:REM Plots a green line.
]HPLOT 4,0 TO 4,191:REM Plots a violet line
]HCOLOR=4:HPLOT 3,0 TO 3,191
How's that?  You plot a black line between the violet and green; the green 
turns orange, and the violet turns blue.  The lines also shift a half-pixel to 
one side.  All you did was to turn on the 128's bit in all 192 bytes along the 
left edge of the screen.  That shifted your color set.
OKAY, LET'S REVIEW THE RULES:
1.  Odd columns will ALWAYS be either GREEN or ORANGE.
2.  Even columns will ALWAYS be either VIOLET or BLUE.
3.  When two adjacent columns are turned on, the result will be WHITE.
4.  All pixels in any given byte MUST be EITHER GREEN/VIOLET or ORANGE/BLUE.  
You CANNOT display Green and Blue, Green and Orange, Violet and Orange, or 
Violet and Blue within the same BYTE.  Each byte has its own color-select bit, 
so all four (six if you count black and white) colors may be displayed at once 
on the same screen.

That's the basics of standard hi-res.  I need to get some sleep, so I'll 
briefly mention double hi-res next time (unless someone beats me to it 8-) !)
--Dave Althoff, Jr.
(tired Applesoft Ace)

Path: info.curtin.edu.au!uniwa!munnari.oz.au!news.Hawaii.Edu!ames!agate!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!valthoff
From: valthoff@magnus.acs.ohio-state.edu (Victoria M Althoff)
Newsgroups: comp.sys.apple2.programmer
Subject: Re: Hi-res Graphics
Date: 12 Oct 1993 03:41:52 GMT
Organization: The Ohio State University
Lines: 36
Message-ID: <29d920$gqs@charm.magnus.acs.ohio-state.edu>
References: <29apmh$der@charm.magnus.acs.ohio-state.edu>
NNTP-Posting-Host: bottom.magnus.acs.ohio-state.edu
Summary: Part Two:  Double Hi-Res
Disclaimer:  "Apple" is a registered tm. of You-Know-Who.

Okay, so I talked about hires graphics.  Now, about Double Hi-Res Graphics.

First, you need a ][e or later; a ][e must NOT have a Rev. A motherboard.  You 
also need at least 128k.  Furthermore, simply sticking one of those big Apple 
memory cards into a 64k ][e won't do it...you MUST have 64k on the 80-column 
card in the auxiliary slot.  And, the jumper on the two pins on the end of the 
card must be installed.  If you have one of the later E's (including all of the
grey ones with the numeric keypads) with the miniature 80-column card, there is
no jumper.

1.  How do you activate DHR?
First, activate the 80-column card (yes, that's "PR#3").
Then, enter high-resolution graphics (uh huh..."HGR").
Now, the procedure differs from that listed in official Apple publications, 
which instruct you to turn the paddle port Annunciator #3 "on".  This is 
rubbish.  Instead, you turn it OFF by accessing location 49247 (sorry, I'm not 
sure what that is in $hex).

2.  What is the pixel set/reset protocol?
Same as for HGR.  I'm not sure exactly how the colors are mapped, though, since
the 560 x 192 mode is supposed to offer 15 colors.

Okay, here's where it gets tough.  The DHR screen is 80 bytes wide, but those 
80 bytes only occupy 40 addresses.  The first byte and second byte BOTH have 
the addess $2000.  But the first byte is in 'aux' (80-column card) memory, and 
the second is in normal memory.  The bytes continue to alternate like that all 
the way across the screen.
To make things more difficult, the Applesoft hires graphics commands completely
ignore the extra screen pixels, so any normal hi-res Applesoft program running 
in DHR will leave unsightly gaps.  Also, there is no second hires page in DHR.

Getting results takes some page flipping,which I don't have time to discuss 
here.  But you get the general idea.

--Dave Althoff, Jr.
(Maybe I'll come back to this...)

