Path: news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!news.sprintlink.net!hookup!newshost.marcam.com!uunet!nntp.cac.washington.edu!news.uoregon.edu!cie-2.uoregon.edu!nparker From: nparker@cie-2.uoregon.edu (Neil Parker) Newsgroups: comp.sys.apple2.programmer Subject: Re: IIgs screen colors Date: 20 Mar 1995 10:42:00 GMT Organization: University of Oregon Campus Information Exchange Lines: 87 Message-ID: <3kjm5o$nbo@pith.uoregon.edu> References: NNTP-Posting-Host: cie-2.uoregon.edu In article g.wright@pro-applepi.wap.org (Geraldine Wright) writes: >I am writing an 8-bit program for use primarily on IIe's and IIc's, although >I would like it to be usable on a IIgs. I am having a slight problem with the >program when run on a IIgs. The program uses the mixed text/graphics mode. >When I turn on the graphics, the graphics portion clears to black, but the >text portion at the bottom remains the same color as the background color >which was set in the control panel. Are there some PEEK's and POKE's I can do >to accomplish the following things: > >1. Read the current text color and background color, so I can store these >values in variables. > >2. Temporarily change the background color to black and the text color to >white. > >3. Return the text and background colors to their original values at the end >of the program. Yes. The text and background colors are in memory location $C022 (decimal 49186). The low four bits are the background color, and the high four bits are the text color. 10 X = PEEK (49186): REM Get the color byte 20 TC = INT (X / 16) * 16: REM Get text color 30 BC = X - TC: REM Get background color To change the colors, simply poke the new values back into the same location. 40 POKE 49186,TC * 16 + BC: REM Set new text and bg colors You can also look at the border color. The border color is stored in the low four bits of location $C034 (decimal 49204). 50 X = PEEK (49204): REM Get border color byte 60 DC = X - INT (X / 16) * 16: REM Get border color You need to be careful when changing the border color. The high four bits at $C034 are used by the battery RAM and clock, and must not be changed. 70 ZZ = INT ( PEEK (49204) / 16) * 16: REM Preserve reserved bits 80 POKE 49204,ZZ * 16 + DC: REM Set new border color For each of these three colors, the color values are the same as the lo-res graphics colors. Note that any color change you make by this method will be undone and restored to the default colors whenever control-reset is pressed or the Control Panel is accessed, unless you also change the saved color settings in the battery RAM (via the Display menu in the Control Panel, for example). Before trying to access the text, background, and border colors, it is wise to make sure you're running on a IIGS. This can only be done by calling a machine-language subroutine. Here's some code that does the IIGS test: 10 GS = 0 20 IF PEEK (64435) < > 6 THEN 60: REM Skip if not at least IIe 30 FOR X = 0 TO 10: READ Y: POKE 768 + X,Y: NEXT : REM Poke ML 40 CALL 768: IF PEEK (6) = 0 THEN GS = 1 50 DATA 56,32,31,254,8,104,41,1,133,6,96 60 REM At this point GS=1 on a IIGS, or 0 on any other Apple II The machine language in line 50 disassembles as follows: 38 SEC 20 1F FE JSR $FE1F 08 PHP 68 PLA 29 01 AND #1 85 06 STA 6 60 RTS The secret is that on a IIGS, the subroutine at $FE1F returns with the carry flag clear. On all other Apples the carry flag comes back unchanged. - Neil Parker P.S Warning: All the BASIC code above was created directly in my UNIX text editor, without actually testing it on an Apple II. Beware of typos! -- Neil Parker No cute ASCII art...no cute quote...no cute nparker@cie-2.uoregon.edu disclaimer...no deposit, no return... nparker@cie.uoregon.edu (This space intentionally left blank: )