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 hardware 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.
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
(Our program code)
$2000
$3FFF
Graphics
Screen
Page 1
$4000
$5FFF
Graphics
Screen
Page 2 (We use this)
$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
Reading from the ports will also have the same effect!
Address
Code
Details
C050
TXTCLR
Display
Graphics
C051
TXTSET
Display
Text
C052
MIXCLR
Display
Full
Screen
C053
MIXSET
Display
Split
Screen
C054
TXTPAGE1
Display
Page
1
C055
TXTPAGE2
Display
Page
2
C056
LORES
Display
LoRes
Graphics
C057
HIRES
Display
HiRes
Graphics
Highres Screen - Screen Colors
Colors on the Apple II are effectively an 'Artifact' of the
screen...
certain combinations of Off (0) and On (1) pixels will appear
colored... this is known as Composite Artifact colors...
Unlike pretty much every system in existance, 8 bits of a byte draw
7 pixels!.... the top bit is a 'Color
bit'... selecting 'Palette 0 or 1
The remaining 7 bits are the 7
pixels of bitmap data... because each line is 40 bytes
wide, the Apple II screen is a rather odd resolution of 280�192
Bitnum
7
6
5
4
3
2
1
0
Function
Color
Pixel
1
Pixel
2
Pixel
3
Pixel
4
Pixel
5
Pixel
6
Pixel
7
Pixel Pair
Color Bit
00
01
10
11
0
00
01
10
11
1
00
01
10
11
Because of these artifacts, a '2 color' bitmap will show colors
depending on the combination of the pixels...
My Akusprite editor offers a half horizontal resolution mode, where
the 4 colors will be converted to the correct bit combinations
Normal
Pixel data - 2 color
Half Horizontal
resolution
- 4 color
Highres Screen Mode 2 -
Memory map
Memory addresses for Screen Mode 2 is
split into 3 chunks,also, every 8 lines we effectively 'reset' our
high memory address and add $80
1st Third
Lines 0-63
2nd Third
Lines 64-127
3rd Third
Lines 128-191
Pixels in Each line are in normal Left->Right format, however
remember 7 pixels are defined by each byte, with 1 bit defining the
color palette.
We can calculate the address of the start of a line by splitting the
bits of the Y line number...
On the Apple 2, we'll be using Analog Joysticks... these return a
value for the X and Y axis in a range of 0-100
0,0 is Top,Left.... 100,100 is Bottom,Right
We're going to read these in and convert them to Digital Values
There are several ports we need to know about on the
Apple II
Reading Analogs on the Apple II is a pain... we reset the analogs
with $C070, then count up until bit 0 of $C064 (or one of the other
analogs) becomes 1 - this value in our count is the analog position
In thory the Apple II as 4 switches (0-3) but we can only easily use
0 and 1
Each Joystick will use Two Analogs, 0 & 1 for Joystick 1, and 2
& 3 for Joystick 2