Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!howland.erols.net!cam-news-hub1.bbnplanet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!news.pbi.net!news.infonex.net!myriad!mail From: stevee@onix.com Newsgroups: comp.sys.apple2.programmer Subject: Re: Programming IIGS Options From BASIC Date: 3 Apr 1997 00:43:54 -0500 Organization: Mail to Usenet Gateway Lines: 33 Message-ID: To: comp.sys.apple2.programmer@myriad.alias.net bchsteve@aol.com (Bch Steve) asked: > How do you change the screen color & border color on a IIGS from > BASIC? The background color of the main part of screen is controlled by bits 0 through 3 of memory position 49186 (hex C022). The other 4 bits of byte 49186 control the text color. The border colors are controlled by bits 0 through 3 of memory position 49204 (hex C034). The other 4 bits of byte 49204 control clock data transfers and are usually set to zero. If the above description is a bit too technical, go into immediate mode and play with POKEs of values between 0 and 256 into 49186 and values of between 0 and 15 into 49204; the patterns should become evident. For example, after you: POKE 49186,100 the screen should show blue letters on a green background. If your finished program is going to be distributed to others, you probably should make sure not to change bits 4 to 7 of 49204. Feel free to repost if you need to know how to do this (hint: you would need a PEEK to get the initial value of 49204). By the way, I wrote a simple toddler exploration program a few years ago ("BabySoft", should still be in the GEnie library) which uses these bytes. One feature caused the values of both these bytes to change with the joystick position. Steve Eisenberg stevee@onix.com Pennsylvania, U.S.A. Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!math.ohio-state.edu!howland.erols.net!ix.netcom.com!newsfeeds.sol.net!hammer.uoregon.edu!news.uoregon.edu!cie-2.uoregon.edu!nparker From: nparker@cie-2.uoregon.edu (Neil Parker) Newsgroups: comp.sys.apple2.programmer Subject: Re: Programming IIGS Options From BASIC Date: 3 Apr 1997 08:31:44 GMT Organization: University of Oregon Campus Information Exchange Lines: 80 Message-ID: <5hvptg$nko@pith.uoregon.edu> References: <19970402222101.RAA03835@ladder01.news.aol.com> NNTP-Posting-Host: cie-2.uoregon.edu NNTP-Posting-User: nparker In article <19970402222101.RAA03835@ladder01.news.aol.com> bchsteve@aol.com (Bch Steve) writes: > > How do you change the screen color & border color on a IIGS from >BASIC? It's done by PEEKing and POKEing the appropriate memory locations. Below is some information (slightly edited) that I posted on this subject a while back: [...] 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 + 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 vital 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 | Unsolicited commercial e-mail to my nparker@cie-2.uoregon.edu | address is not welcome, and will be nparker@cie.uoregon.edu | discarded unread. http://cie-2.uoregon.edu/~nparker |