Subject: Re: Flashing POKEd characters in Applesoft
From: [email-masked] (Neil Parker)
Date: 22 Jan 1997 10:22:43 GMT
Newsgroups: comp.sys.apple2.programmer

In article <[email-masked]>
[email-masked] (Dark_Dude) writes:
>I always wondered how to go back to the 40 columns mode. Can I poke, or is
>there another command in Basic?

From the keyboard, you can type "ESC 4" and "ESC 8" to toggle between 40-
column and 80-column mode.  "ESC 4" switches to 40-column mode but leaves
the 80-column firmware active, so you can still use the fancy 80-column
screen controls.  Pressing "ESC Q" will switch to 40 columns and turn off
the 80-column firmware.

From inside a BASIC program, you can PRINT CHR$(17) to switch to 40
columns, and PRINT CHR$(18) to switch back to 80 columns (these work
exactly like the keyboard-only commands ESC 4 and ESC 8).  To switch back
to 40 columns and turn off the 80-column firmware, PRINT CHR$(21) (this
works like ESC Q).

Once you've done ESC Q or PRINT CHR$(21), the only way to get back to 80
columns is with PR#3.  (On the IIGS, "ESC 8" does a "PR#3" if you type
it when the 80-column firmware is off.)

For those of you who want to manipulate the hardware without the 80-column
firmware's assistance, here are the memory locations you need:

In BASIC      In ML      What it does
--------      -----      ------------
POKE 49152,0  STA $C000  Turn off 80-column bank switching
POKE 49153,0  STA $C001  Turn on 80-column bank switching
POKE 49164,0  STA $C00C  Turn on 40-column display
POKE 49165,0  STA $C00D  Turn on 80-column display
POKE 49166,0  STA $C00E  Display flashing characters
POKE 49167,0  STA $C00F  Display mousetext & inverse lowercase chars
POKE 49236,0  LDA $C054  Switch in main text page (cols 1, 3, 5, etc.)
POKE 49237,0  LDA $C055  Switch in auxiliary text page (cols 0, 2, 4, etc.)

Note the the main/aux text page switch only behaves like this when
80-column bank switching is turned on with POKE 49153,0 or STA $C001.  If
80-column bank switching is off, the main/aux switch reverts to its old
"display page 1 or page 2" function, and you can only get at the aux-bank
half of the text screen by using using the standard (and ridiculously
inconvenient) bank switching controls (the payoff for that extra
inconvenience is that you can then display the normally-invisible and
little-known 80-column text page 2).

If you want to program double-resolution graphics, the following
additional controls are necessary:

POKE 49232,0  LDA $C050  Display graphics
POKE 49233,0  LDA $C051  Display text
POKE 49234,0  LDA $C052  Graphics are full-screen
POKE 49235,0  LDA $C053  Graphics have four lines of text at the bottom
POKE 49238,0  LDA $C056  Display low-res graphics
POKE 49239,0  LDA $C057  Display hi-res graphics
POKE 49246,0  LDA $C05E  Display double-res graphics
POKE 49247,0  LDA $C05F  Display single-res graphics

The single/double-res graphics switch only works if the 80-column display
is active (i.e. after POKE 49165,0 or STA $C00D).  In 40-column mode, only
single-res graphics can be displayed.

On a IIGS, the following are also of interest:

POKE 49193,33   LDA #$21;STA $C029  Make double-hires mode black-and-white
POKE 49193,193  LDA #$C1;STA $C029  Turn on super-hires graphics
POKE 49193,1    LDA #1;STA $C029    Turn off B&W or super-hires

Never use these last three unless you know for sure you're on a IIGS.  All
of them will crash a IIc.  If you *are* on a IIGS, never POKE an even
number into location 49193, unless you like to see your computer crash
spectacularly.

               - Neil Parker
-- 
Neil Parker                       | Unsolicited commercial e-mail to my
[email-masked]         | address is not welcome, and will be
[email-masked]           | discarded unread.
http://cie-2.uoregon.edu/~nparker |