65c02 Assembly programming for the Apple IIe

The Apple II saw many generations of it's hardware, from the early Apple II to the final Apple IIgs the hardware remained mostly compatible, however the harfdware was heavily upgraded, moving from a 4k 6502, to a 8mb 16 bit 65816

The most curious thing from our point of view is that the Apple II used 3 generations of the 6502, and it's the Apple IIe with its enhanced 8 bit 65C02 we'll cover in these tutorials
There are many versions of the Apple 2, we're only going to cover the Apple IIe in these tutorials.
Apple II Apple IIe Apple IIgs
Cpu 1mhz 6502
1mhz 65C02 2mhz 65C816 (16 bit)
Ram 4k  48k up to 8mb
Resolution Text Only 280×192 320x200
Sound beeper beeper Ensonique 5503

Apple IIe Memory Map
The Apple IIc memory map is pretty typical.

We'll use Graphics Mode, and Page 2 - this means for our purposes the area $0C00-$3FFF can be used for our main program code.

Notice that the area $C000-$FFFF allows us to access the hardware...

Each "Port" has a different purpose, but rather strangely  when we want to do something like set the graphics mode, we write ANY value to the graphics port... the value makes no difference!
From To Purpose
$0000 $00FF Zero page
$0100 $01FF Stack
$0200 $02FF GETLN buffer
$0300 $03CF Free Space
$03D0 $03FF DOS & Interrupt vectors
$0400 $07FF Text Screen Page 1
$0800 $0BFF Text Screen Page 2
$0C00 $1FFF Free space
$2000 $3FFF Graphics Screen Page 1
$4000 $5FFF Graphics Screen Page 2
$6000 $95FF Applesoft String Data
$9600 $BFFF Operating System Memory
$C000 $FFFF System Harware ports

Hardware Ports Memory Map
Writing any value to these memory addreses causes the hardware change.

For example, to change the system to graphics mode:

    lda #0
    sta $C050 ; Text off
    sta $C052 ; Mixed Mode off
    sta $c057  ; Display hires
    sta $C055 ; Hires screen 2
       
Port Name Description
$C050 TXTCLR Display Graphics
$C051 TXTSET Display Text
$C052 MIXCLR Display Full Screen
$C053 MIXSET Display Split SCreen
$C054 TXTPAGE1 Show Text/Grapics Page1
$C055 TXTPAGE2 Show Text/Grapics Page2
$C056 LORES Display LoRes Grahics
$C057 HIRES Display Res Grahics