Classic Computer Magazine Archive COMPUTE! ISSUE 17 / OCTOBER 1981 / PAGE 79

Switching Cleanly From Text To Graphics

Brian Nakagawa
Fresno, CA

It is very distracting to watch the Apple II switch from TEXT to GRAPHICS mode or vice versa. Colored squares and grey lines appear briefly when switching from TEXT to LORES graphics while a screen full of inverse characters, usually @ signs, appear when switching from LORES graphics to TEXT. In going from TEXT to HIRES graphics, one sometimes sees the previous HIRES display flash on the screen then dissolve away. In most programs, the extra flash of graphics or characters is merely a distraction. However, to switch cleanly between TEXT and GRAPHICS mode would give the appearance of a more polished program.

This article will show the routines that switch cleanly from TEXT to LORES or HIRES graphics using Applesoft commands and machine level routines already available on the Apple II.

The commands given below can be typed in the immediate mode or run in a program.

TEXT To HIRES Graphics

The simplest way to turn on page 1 of HIRES graphics is to use the command HGR. This first turns the screen to that page then erases the graphics displayed. Type in the following sequence of commands to see this.

HPLOT 40, 140 TO 240, 60 TO 40, 60 TO 240, 140 TO 140, 20, TO 40, 140

Notice that when you typed in the last HGR the star reappeared briefly then was erased.

Now try these commands. (It is assumed that you are still in HIRES graphics.)

HPLOT 40, 140 TO 240, 60 TO 40, 60 TO 240, 140 TO 140, 20 TO 40, 140
POKE 230, 32: CALL 62450: HGR

Notice that the screen went blank without the brief appearance by the star.

POKE 230,32 sets the HIRES page pointer to page one without changing the current screen display. CALL 62450 is a machine language routine in APPLESOFT that clears the HIRES page indicated by memory location 230. HGR then turns on page one of HIRES graphics.

HIRES page two can be switched to using similar commands. Use the above example and substitute "HGR2" for "HGR" and "POKE 230,64" for "POKE 230,32". Be aware that the text window at the bottom will not be seen.

Switching from HIRES graphics, page one or two, TEXT is easily accomplished typing in the "TEXT" command. If you wish to clear the text page first then use "HOME: TEXT".

TEXT To LORES Graphics

Fill the TEXT screen with text then type in the command "GR". The distracting display of grey lines and colored squares when switching from TEXT to LORES graphics can be avoided with the following commands. Fill the text screen with text before typing in the commands.

POKE 230,32: CALL 62450: HGR: CALL -1994: GR

If you wish to clear the text window at the bottom of the screen, type in "HOME" or add it to the end of the string of commands as follows:

POKE 230,32: CALL 62450: HGR: CALL -1994: GR: HOME

Notice that it is first necessary to clear HIRES page one and go into that page just as was done in the TEXT to HIRES discussion. CALL -1994 changes the text page to inverse @ signs and GR put the screen into LORES page one.

If you are still in LORES graphics type in "TEXT: HOME" which will return you to a clear TEXT page. Did you notice the flash of inverse @ signs? This does not happen all the time so it may be necessary for you to go back into LORES page one with the "GR" command then type in "TEXT: HOME" again.

To avoid this, type in the following commands:


GR puts the screen into LORES page one, HOME then clears the text window at the bottom, HGR puts the screen into HIRES page one which is assumed to be clear, POKE 34,0 sets the top of the text window to the top of the screen, HOME clears the text page, and TEXT puts the screen into text mode.


The code to switch from text to graphics takes more memory and executes slower. You may have noticed the pause when switching between TEXT and GRAPHICS. In a program that switches between TEXT and GRAPHICS often, one can put the switching code in a subroutine to save memory.

The additional code and slightly slower execution speed to switch cleanly is a very small price to pay for the more polished appearance of a program.


All of the above commands are documented in the Applesoft Basic Programming Reference Manual. Selected commands and the page number they appear on are listed below. POKE 230,32 and POKE 230,64 are documented as general use high resolution graphics locations on page 141. Decimal location 230 is equal to hexadecimal $E6. CALL 62450 and CALL -1994 are on page 134 and POKE 34,0 is on page 29.