001- What programming languages are available for the Apple II?
002- Where can I find out about Apple II programming?
003- How can I find out more about using my Apple II?
004- Where can I find PEEKs & POKEs and monitor routine info?
005- How can I see and edit what's in a Text file?
006- How do I save a BASIC program in ASCII text form?
007- Where and how do I get System 6.0.1 from an ftp site?
008- Where can I get Applesoft shape table info and programs?
009- What Operating System environments does the GS support?
010- How do I write programs for the Apple Graphics Tablet?
011- How do I read the joystick on a GS in native mode?
012- How do I write programs which use the mouse?
013- Where can I get Apple II languages and programming software?
014- How can I view and enter code using the "monitor"?
015- What memory areas should a user be careful about modifying?
016- Can I do multi-tasking on a IIgs? or What is GNO/ME?
017- Where can I find manuals and other resources for the CP/M OS?
Csa2 Programmer FAQs
Feel free to email comments, suggestions, and materials.
Jeff Hurlburt
ruby...@swbell.net
__________________________
001- What programming languages are available for the Apple II?
Quite a few. Apple Integer BASIC (in-ROM on the first Apple II's), can be
loaded into II+ and later models. Applesoft, a floating point BASIC, is in-ROM
on all models starting with the II+. Older Apple II's can load-in Applesoft or,
via a plug-in board, access it from ROM.
Then, there is MD BASIC, the BASIC-like MacroSoft from MicroSparc, a beta
version of Apple's GS BASIC, and the new (1998) Byte Works GS BASIC! Users who
want to speed up their AppleSoft programs can use a BASIC compiler such as TASC
or Einstein.
Other Apple II languages are Apple Fortran, USCD Pascal, Orca (ByteWorks)
Pascal, Terrapin Logo, Apple Logo, two Logos from ByteWorks, Isys Forth, Master
Forth, (and many other Forths), Modula2, Aztec C, Orca/C, ... . Hyperstudio and
HyperCard let you create stacks.
To the above you can add several assemblers including Merlin, Orca/M, an
assembler from Ninja Force, and the MicroSparc Assembler.
You can find a comprehensive listing in Larry Virden's "Apple II Programmer's
Catalog of Languages and Toolkits" at
http://www.tclfaq.wservice.com/Misc/apple2-languages.txt.
For Orca manuals and to order the Orca languages contact Byte Works:
505-898-8183; http://www.byteworks.org . --Rubywand
__________________________
002- Where can I find out about Apple II programming?
All Apple II's come with some version of BASIC installed in-ROM on the
motherboard. The original Apple II's have Integer BASIC. Starting with the II+
model, all Apple II's have floating-point Applesoft in-ROM. Owners of early
Apple II's can load in Applesoft or plug in a card with Applesoft ROMs.
All Apple II's include a "monitor" program in ROM. Entering CALL-151 from the
BASIC prompt puts you 'in' the monitor. Here you can view and change values in
key memory locations and enter machine language routines.
Besides these built-in languages, many others can be loaded in and used (see
above).
There are several good places on the net to find out about programming:
Apple Cabi.net
ACN Florida
ftp://24.96.48.134:6502/Cabi_Archives/FAQs.and.INFO/LanguagesAndProgramming/
ftp://24.96.48.134:6502/Cabi_Archives/Languages.Programming/
ACN Tarnover
ftp://tarnover.dyndns.org/cabi/FAQs.and.INFO/LanguagesAndProgramming/
ftp://tarnover.dyndns.org/cabi/Languages.Programming/
Apple II Lessons & Software (Applesoft)
http://www.iglou.com/qwerty/kb/dlfiles.html
Apple II Textfiles
http://www.textfiles.com/apple/
Ground
ftp://ground.ecn.uiowa.edu/2/apple2/MiscInfo/Applesoft/
ftp://ground.ecn.uiowa.edu/apple2/MiscInfo/Programming/
ftp://ground.ecn.uiowa.edu/2/apple2/apple8/Beagle.Oldies/
ftp://ground.ecn.uiowa.edu/apple2/MiscInfo/
Home of the Apple II
http://www.educate.net.au/~apple2/
http://www.xs4all.nl/~fjkraan/comp/apple2faq/
Niel Parker's Home Page- Apple IIgs Progamming information
http://axis.llx.com/~nparker/a2/
Texas II- Appleworks products, Y2k patches, and information;
home site for the Apple II Mail Group (A2MG)
http://members.aol.com/A2MG/
Apple II DOS and ProDOS mini manual
http://home.swbell.net/rubywand/Csa2DOSMM.html
Apple II game authoring links
http://home.swbell.net/rubywand/A2FAQs7GAMESITES.html#004
More Apple II links
http://home.swbell.net/rubywand/A2FAQs4MAJORSITES.html
"A2Pro" forum- programming information & lessons
http://forums.delphi.com/a2pro
The comp.sys.apple2.programmer USENET newsgroup
The comp.sys.apple2 USENET newsgroup
Be sure to keep a look out for Apple II books, charts, software packages, etc.
when you visit used book stores, swap meets, school sales, ..., or peruse
comp.sys.apple2 marketplace.
Applesoft BASIC
The #1 Applesoft information source is the Basic Programming Reference Manual
from Apple. Here are some other good Applesoft materials to look for ...
Apple II User's Guide by Poole, Martin, and Cook
Apple II Reference Manual from Apple
Peeks, Pokes, and monitor routines info (see below)
DOS & ProDOS books (see below)
Assembly Language and Machine Language Coding
Machine coding is when you enter 6502 (65816, ...) instructions directly-- as
in going to the Apple II monitor (CALL-151) and typing in hexadecimal codes at
specific addresses, like 300:A9 7F (instruction to load Accumulator with the
value $7F entered at address $300).
Assembly coding substitutes easy-to-remember text for the numeric codes-- as in
LDA#7F to load the Accumulator with the value $7F. Assembly coding is done
using assembler software (like Merlin or Orca/M). A major advantage of assembly
coding is that routines and other places in your program can be tagged with
text labels and referenced this way in your program. The assembler software
figures out things like Jump addresses.
Assembly Lines: The Book by Wagner
Beagle Bros "Peeks, Pokes, and Pointers" (poster)
Programming the 65816 Including the 6502, 65C02, and 65802
by David Eyes and Ron Lichty
65816/65802 Assembly Language Programming by Fischer
What's Where in the Apple II? by William F. Luebbert
Other Languages
Apple Pascal: a hands-on approach by Luehrmann & Peckham
Learning to Program in C by Mike Westerfield (Byte Works)
Learning to Program in GSoft BASIC by Mike Westerfield
(Byte Works)
Learning to Program in Pascal by Mike Westerfield (Byte Works)
Logo Plus manual from Terrapin
DOS, ProDOS, and GS/OS
Apple IIgs GS/OS Technical Reference (Apple/ Addison-Wesley)
Apple IIgs Toolbox Reference v. 1-3 (Apple/ Addison-Wesley)
Beneath Apple DOS by Worth & Lechner
Beneath Apple ProDOS by Worth & Lechner
Exploring Apple GS/OS and ProDOS 8 by Little
ProDOS Inside and Out by Doms and Weishaar
ProDOS Technical Reference Manual (Apple/ Addison-Wesley)
The DOS Manual from Apple
Toolbox Programming in C by Mike Westerfield (Byte Works)
Toolbox Programming in Pascal by Mike Westerfield (Byte Works)
One of the best ways to learn programming is to find some old game you like and
experiment with customizing it. This works especially well for learning
Applesoft BASIC and machine language coding.
If your Apple II is an enhanced //e or later machine, be sure to get Program
Writer. It's a vintage Applesoft program editing utility from Beagle which
makes writing and debugging BASIC programs much easier.
--Rubywand, Terence J. Boldt
__________________________
003- How can I find out more about using my Apple II?
Here are a few good places to look on the net:
Gabriel Morales's Apple II Beginner's Guide at
http://www.concentric.net/~Togega/Apple2/
Terry Allen's Home of the Apple II at
http://www.educate.net.au/~apple2/
Charles 'Dr. Tom' Turley's huge collection of Apple II info on the
Apple Cabi.net archives at
Florida- ftp://24.96.48.134:6502/Cabi_Archives/FAQs.and.INFO/
Comp.sys.apple2's Apple II FAQs:
Pure Text on Ground, MIT, and Utrecht
ftp://ground.ecn.uiowa.edu/apple2/Faqs/
ftp://rtfm.mit.edu/pub/usenet/news.answers/apple2/faq/
http://ftp.cs.ruu.nl/pub/NEWS.ANSWERS/apple2/faq/
Line-length formatted Text on Tarnover, Florida, and USA2WUG
ftp://tarnover.dyndns.org/cabi/FAQs.and.INFO/A2.Csa2.FAQs/
ftp://24.96.48.134:6502/Cabi_Archives/FAQs.and.INFO/A2.Csa2.FAQs/
http://www.grin.net/~cturley/A2.FAQs.and.INFO/CSA2.FAQs/
HTML web site versions on II Computing and Help Page
http://home.swbell.net/rubywand/A2FAQs1START.html
http://members.xoom.com/apple_II/faqs.html (under construction)
There is really no substitute for having the technical manual for your
particular Apple II or clone. The manual for the ][ and ][+ is the Apple ][
Reference Manual. For the IIe and IIc you want Apple's Technical Reference
Manual for your machine. For the IIgs you will want, at least, the IIgs
Hardware Reference and IIgs Firmware Reference.
Here are some other general-coverage materials for Apple II computers:
Apple II User's Guide by Poole, Martin, and Cook
Apple IIgs Technical Reference by Michael Fischer
Exploring the Apple IIgs by Gary Little
Beagle Bros "Peeks, Pokes, and Pointers" (poster) by Beagle Bros
Understanding the Apple ][ by Jim Sather
Some technical manuals and other materials can be obtained in original or
reprint form from Byte Works (http://www.byteworks.org/) and Kula Soft (
http://www.angelfire.com/hi/kulasoft/ ). Major book sellers, such as Amazon
(http://www.amazon.com) list many Apple II books. Though most are out of print,
the sellers will search for and, with luck, locate the book you want.
Apple II manuals and other books also turn up for sale on Csa2 newsgroups like
comp.sys.apple2.marketplace, at used book shops, and at local Users Group swap
meets; and, some manuals are now available on-line at Terry Allen's Home of the
Apple II at http://www.educate.net.au/~apple2/. A few items, such as Reference
Cards and posters, can be downloaded in Text or HTML form from Apple II
archives.
You may be able to find a local Apple II users' group or a group on-line that
you like. Besides knowledgeable users, you will often find a software library
stocked with useful software. (See Csa2USERGRP.txt.)
Another good resource is a subscription to an Apple II newsletter or magazine;
and, don't overlook collections of major Apple II magazines published through
the 1980's (e.g. inCider, Nibble, Computist, etc.). They are virtual
encyclopedias covering many areas of II computing. For current publishers and
net sites which offer on-line copies of back issues see the Apple II Publishers
listing at http://home.swbell.net/rubywand/A2FAQs3VENDORS.html#021 .
Often, the easiest, quickest way to an answer for some Apple II question is to
'just ask it' on comp.sys.apple2 and/or another Csa2 family newsgroup. There
are no Csa2 rules about posting to just a newsgroup which deals with a
particular topic or making sure your question is hard enough or reading the
FAQs first. Supplying information is the main purpose of the newsgroups.
--Rubywand, David Wilson
__________________________
004- I'd like to do some 'serious' Apple II programming. Where can I
find a information about soft switches (i.e. "PEEKs & POKEs"),
monitor routines, and standard names used for these?
Most of the names (assembler "equate" names) are listed in pairs, and the
comment on the first one often represents what the second actually does, but
refers to with what function the softswitch pair are associated.
SOFTSWITCHES
KEYBOARD = $C000 ;keyboard data (latched) (Read)
Bit 7 is set to indicate a keypress is waiting, with the ASCII
code in bits 6-0.
CLR80STORE = $C000 ;use 80-column memory mapping (Write)
SET80STORE = $C001 ; (WR-only)
CLRAUXRD = $C002 ;read from auxilliary 48K (WR-only)
SETAUXRD = $C003 ; (WR-only)
CLRAUXWR = $C004 ;write to auxilliary 48K (WR-only)
SETAUXWR = $C005 ; (WR-only)
CLRCXROM = $C006 ;use external slot ROM (WR-only)
SETCXROM = $C007 ; (WR-only)
CLRAUXZP = $C008 ;use aux ZP, stack, & LC (WR-only)
SETAUXZP = $C009 ; (WR-only)
CLRC3ROM = $C00A ;use external slot C3 ROM (WR-only)
SETC3ROM = $C00B ; (WR-only)
CLR80VID = $C00C ;use 80-column display mode (WR-only)
SET80VID = $C00D ; (WR-only)
CLRALTCH = $C00E ;use alt character set ROM (WR-only)
SETALTCH = $C00F ; (WR-only)
STROBE = $C010 ;clear bit 7 of keyboard data ($C000)
If read, it also provides an "any key down" flag in bit 7, with
the keycode in the remaining bits. (These features only apply to
the IIe and later machines.)
Bit seven of these "RD..." locations is 1 if the condition is true
RDLCBNK2 = $C011 ;reading from LC bank $Dx 2
RDLCRAM = $C012 ;reading from LC RAM
RDRAMRD = $C013 ;reading from auxilliary 48K
RDRAMWR = $C014 ;writing to auxilliary 48K
RDCXROM = $C015 ;using external slot ROM
RDAUXZP = $C016 ;using auxilliary ZP, stack, & LC
RDC3ROM = $C017 ;using external slot C3 ROM
RD80COL = $C018 ;using 80-column memory mapping
RDVBLBAR = $C019 ;not VBL (VBL signal low)
RDTEXT = $C01A ;using text mode
RDMIXED = $C01B ;using mixed mode
RDPAGE2 = $C01C ;using text/graphics page2
RDHIRES = $C01D ;using Hi-res graphics mode
RDALTCH = $C01E ;using alternate character set ROM
RD80VID = $C01F ;using 80-column display mode
TAPEOUT = $C020 ;toggle the cassette output.
SPEAKER = $C030 ;toggle speaker diaphragm
STROBE = $C040 ;generate .5 uS low pulse @ Game pin 5
If read, you get one half-microsecond low pulse on the Game I/O
STROBE pin; if write, you get two pulses. (IIe and ][+ only, not
available on the IIgs).
CLRTEXT = $C050 ;display graphics
SETTEXT = $C051 ;display text
CLRMIXED = $C052 ;enable full graphics
SETMIXED = $C053 ;enable graphics/text mixed mode
PAGE1 = $C054 ;select text/graphics page1
PAGE2 = $C055 ;select text/graphics page2
See IIe, IIc, IIgs manual for details on how these switches
affect 80-col bank selection.
CLRHIRES = $C056 ;select Lo-res
SETHIRES = $C057 ;select Hi-res
SETAN0 = $C058 ;Set annunciator-0 output to 0
CLRAN0 = $C059 ;Set annunciator-0 output to 1
SETAN1 = $C05A ;Set annunciator-1 output to 0
CLRAN1 = $C05B ;Set annunciator-1 output to 1
SETAN2 = $C05C ;Set annunciator-2 output to 0
CLRAN2 = $C05D ;Set annunciator-2 output to 1
SETAN3 = $C05E ;Set annunciator-3 output to 0
CLRAN3 = $C05F ;Set annunciator-3 output to 1
Note: "0" is near 0V, "1" is near 5V.
SETDHIRES = $C05E ;if IOUDIS Set, turn on double-hires
CLRDHIRES = $C05F ;if IOUDIS Set, turn off double-hires
TAPEIN or = $C060 ;bit 7 = data from cassette on Apple II,
PB3 II+, IIe. On IIgs bit 7 reflects the
status of Game Port Pushbutton 3--
closed= 1. (read)
OPNAPPLE = $C061 ;open apple (command) key data (read)
CLSAPPLE = $C062 ;closed apple (option) key data (read)
These are actually the first two game Pushbutton inputs (PB0
and PB1) which are borrowed by the Open Apple and Closed Apple
keys. Bit 7 is set (=1) in these locations if the game switch or
corresponding key is pressed.
PB2 = $C063 ;game Pushbutton 2 (read)
This input has an option to be connected to the shift key on
the keyboard. (See info on the 'shift key mod'.)
PADDLE0 = $C064 ;bit 7 = status of pdl-0 timer (read)
PADDLE1 = $C065 ;bit 7 = status of pdl-1 timer (read)
PADDLE2 = $C066 ;bit 7 = status of pdl-2 timer (read)
PADDLE3 = $C067 ;bit 7 = status of pdl-3 timer (read)
PDLTRIG = $C070 ;trigger paddles
Read this to start paddle countdown, then time the period until
$C064-$C067 bit 7 becomes set to determine the paddle position.
This takes up to three milliseconds if the paddle is at its maximum
extreme (reading of 255 via the standard firmware routine).
SETIOUDIS = $C07E ;enable DHIRES & disable $C058-5F (W)
CLRIOUDIS = $C07E ;disable DHIRES & enable $C058-5F (W)
For WR-enable LC RAM, the softswitch REQUIRES two successive reads
$C080 ;RD LC RAM bank2, WR-protect LC RAM
ROMIN = $C081 ;RD ROM, WR-enable LC RAM
$C082 ;RD ROM, WR-protect LC RAM
LCBANK2 = $C083 ;RD LC RAM bank2, WR-enable LC RAM
$C088 ;RD LC RAM bank1, WR-protect LC RAM
$C089 ;RD ROM, WR-enable LC RAM
$C08A ;RD ROM, WR-protect LC RAM
LCBANK1 = $C08B ;RD LC RAM bank1, WR-enable LC RAM
$C084-$C087 are echoes of $C080-$C083
$C08C-$C08F are echoes of $C088-$C08B
Bank 1 and Bank 2 here are the 4K banks at $D000-$DFFF. The
remaining area from $E000-$FFFF is the same for both
sets of switches.
CLRC8ROM = $CFFF ;disable Slot card C8 ROM
Reading any location from $Cn00-$CnFF (where n is the Slot) will
enable the $C800-$CFFF area for that card, if the card supports
this feature. Reading $CFFF disables this area for all cards.
Example: To enable double Hi-res graphics, the following code will
accomplish this:
STA SETHIRES
STA SETAN3
STA CLRMIXED
STA CLRTEXT
JSR $C300
--kbu...@pts.mot.com and David Empson
----------------------------
You can find listings of Apple II soft switches and popular monitor routines in
a manual for your computer-- e.g. the Apple II Reference Manual (for II and
II+), the IIe Technical Reference Manual, the Apple IIgs Firmware Reference
Manual, etc..
An excellent guide to many PEEKs & POKEs and monitor routines is the famous
"Peeks, Pokes, and Pointers" poster from Beagle Bros (early 1980's). A fairly
exhaustive guide to important memory locations in the Apple II is What's Where
in the Apple II: An Atlas to the Apple Computer by William Luebbert (1981).
On-line lists of PEEKs & POKEs + Monitor Routines are available at
Apple II Textfiles
http://www.textfiles.com/apple/ as well as
Apple Cabi.net archives at
Florida- ftp://24.96.48.134:6502/Cabi_Archives/FAQs.and.INFO/
With very few exceptions, soft switches, monitor routines, and important
vectors have remained stable since early Apple II models. So, although an old
chart or listing may be missing some which are available on a newer Apple II,
the ones shown will almost always work. --Rubywand and Mookie
__________________________
005- How can I see and edit what's in a Text file?
A handy utility for quickly viewing Text files under DOS 3.3 or ProDOS is Copy
II Plus.
On the IIgs under the system Finder (the usual "desktop" display showing
drives, folders, etc.) you can, probably, double-click on a text file to start
up an application (program) which will display the Text and let you make
changes.
Note: If you get an error message about not being able to find an application,
you will want to think about setting up a link between Text type files and some
Text editor program such as Teach. Some Text editor New Desk Accessories (like
Shadowrite) will automatically establish a linkage.
Another way to view and edit Text files is to run a Text editor or word
processor program and load in the file. On 8-bit Apple II's, some choices
include Screenwriter II, AppleWriter, and, depending upon machine, some
versions of Appleworks. On the IIgs you have many choices including Teach,
Shadowrite NDA, CoolWriter, and Appleworks. --Rubywand
__________________________
006- How do I save a BASIC program in ASCII text form?
The following line added to the front of your Applesoft BASIC program will save
it in a Text file named "LISTFILE". It works in DOS 3.3 or ProDOS.
1 HOME:PRINT CHR$(4)"OPEN LISTFILE": PRINT CHR$(4)"WRITE LISTFILE": POKE 33,33:
LIST 2,: PRINT CHR$(4)"CLOSE": END
If you have a line 1 which you'd like to leave alone, you can enter the above
at Line 0 and change LIST 2, to LIST 1,.
POKE 33,33 causes the text display routine to not insert any unneccessary
spacing into your BASIC program listing, which cleans up the text file output
nicely.
--David Cross
__________________________
007- Where and how do I get System 6.0.1 from an ftp site?
You can download the System 6.0.1 disks from Apple Computer at ...
ftp://ftp.apple.com/Apple_Support_Area/Apple_Software_Updates/
Look in the US/Apple_II/Apple_IIGS_System_6.0.1/ folder.
Each disk is in the from of a Macintosh self-extracting archive (.sea) of a
Disk Copy 800K ProDOS disk image. According to Apple's directions: " To use,
download, double-click the downloaded file (this decompresses it), and use Disk
Copy to create a disk Disk Copy can be found in the Utilities folder posted
here."
A possible hitch is that Mac .sea files are not IIgs-compatible! (GS-ShrinkIt
can create and compress .sea files; but, these are not the same as Mac .sea
files.)
Fortunately, users can download the shrinked disk files and Install directions
from Apple Cabi.net at ...
ftp://24.96.48.134:6502/Cabi_Archives/System/Sys601INSTALL/
There is a text file with installation directions plus the six System disks in
plain shrinked disk form. The .sdk files just need to be unshrinked to 3.5"
diskettes via GS-ShrinkIt or 8-bit ShrinkIt. --Rubywand
__________________________
008- Where can I get Applesoft shape table info and programs?
Go to the Ground archive's Beagle Bros folder at ...
ftp://ground.ecn.uiowa.edu/2/apple2/apple8/Beagle.Oldies/
and download SHAPE.MECH1.SHK and SHAPE.MECH2.SHK. --Rubywand
__________________________
009- What Operating System environments does the GS support?
The GS can support several. Some of the more popular OS environments include
...
DOS 3.3- usually Beagle's Prontodos or some other speeded version of the
original DOS 3.3. This is the 5.25" diskette-based disk operating system used
for years on earlier Apple II's. It's commands are designed for use from BASIC
programs or from the keyboard. Many old Apple II games and other wares are on
5.25" diskettes which boot DOS 3.3.
ProDOS 8- e.g. ProDOS v2.0.3. This is a disk operating system which supports a
variety of devices (e.g. 3.5" drives, hard drives, etc.) and allows
sub-directories. Commands are very similar to DOS 3.3 and are designed for use
in BASIC programs or from the keyboard. BASIC and 'system' programs can also
utilize direct CALLs to well-defined ProDOS Machine Language Interface
routines.
Apple Pascal- This is an early 1980's implementation of USCD Pascal which can
run on 40-column and 80-column Apple II's.
System- Originally called "ProDOS 16" and later "GS/OS", the collection of
'system stuff' (which includes GS/OS) is today called "System". The System
Finder utilizes Toolbox routines to supply a super-res desktop, Windows-like
environment. Both ProDOS 8 programs and 'GS Applications' (i.e. wares that need
GS/OS to run) can be started from the desktop. Depending upon factors such as
installed RAM and presence of a hard disk, System will usually be System 5.0.4
or System 6.0.1. System 5.0.4 is appropriate for 1.25MB or smaller non-hard
disk GS's. System 6.0.1 is recommended for larger memory GS's with a hard disk.
--Rubywand and David Empson
GNO- GNO is a UNIX-like multitasking environment for the Apple IIgs which runs
on top of the native operating system, GS/OS.
--Rubywand, David Empson, Devin Reade
__________________________
010- How do I write programs for the Apple Graphics Tablet?
The Apple Graphics Tablet I know of is rather large and heavy; its pen is
attached to it with a (too short) cable; it makes funny sounds that change when
the pen is moved in/out the reach of of the tablet.
A long time ago I patched a few programs to make use of this tablet. To make it
clear in the first place - I don't have these patched versions available
anymore :-(.
But I found a listing from which I can tell you this:
To detect the interface card, I looped over all slots to check in its firmware
for
$B0 at location $Cx01 and
$20 at location $Cx09
x being the slot number. I never found this 'signature' in any other firmware.
To check for the pen position one has to poll the tablet (again x being the
slot number):
LDA $CFFF ; switch off all extension ROMS
LDA $Cx00 ; switch on the extension ROM of the tablet
LDA #$Cx
STA $07F8 ; initialize some hidden text screen data area for the tablet
firmware
JSR $CBB9 ; call well known location ;-) in tablet firmware
When the pen is in reach of the tablet (up or down) this routine will return
immediatly. Else it will block - fortunatly the routine checks the keyboard
strobe ($C010) too and will also return if a key is pressed, even if the pen
remains out of the tablet's reach.
After the routine has returned one can get the information:
$0280 contains the state of the pen (up or down), I don't know excatly any more
wich bit it is nor if one can distiguish between 'pen up' and 'pen out of reach
but key pressed'
$0281, $0282 contains the absolute X position of the pen
$0283, $0284 contains the absolute Y position of the pen
As far as I can remember the values have about 12 bit resolution (!). Usually I
needed screen coordinates (280 x 192), so I dropped the 4 least significant
bits and did some additional adjustment. Unfortunatly I can't remember either
what coordinates will be there in the 'out of reach but key pressed' case.
--Oliver Schmidt
__________________________
011- A while ago someone posted about how to read the joystick on
a GS in native mode. They said that it was possible to read
both paddles at once and therefore get much more accurate
readings?
Only the high bit of these locations is valid. When the high bit of either
location becomes 0 then the corresponding analog input has timed out.
You will actually get more accurate results by reading them one after the other
with the accumulator set to 8 bits wide and the index registers used to hold
the counts (16 bits wide). This allows for a much faster loop, giving better
resolution. Assuming that this routine is called from full native mode, the
following code will do the trick:
strobe equ $C070 ; analog input timing reset
pdl0 equ $C064 ; analog input 0
pdl1 equ $C065 ; analog input 1
start php ; save processor status register
phb ; and data bank register
sep #%100000 ; make accumulator 8 bits wide
lda #0 ; make data bank = 0
pha
plb
ldx #0 ; initialize the counters
txy
lda strobe ; strobe the timing reset
loop1 inx ; increment pdl0 count
lda pdl0 ; is high bit = 0?
bmi loop1 ; no, keep checking
lda strobe ; yes, strobe the timing reset again
loop2 iny ; increment pdl1 counter
lda pdl1 ; is high bit = 0?
bmi loop2 ; no, keep checking
plb ; yes, restore data bank
plp ; and processor status register
rts ; return to caller (could be RTL)
Notice that the actual counting loops are only 9 cycles long. This gives the
best possible resolution. You will need your counters to be 16 bits wide as the
results will easily overflow the capacity of an 8 bit counter.
Using memory locations as counters will only serve to slow the counting loop
down. If X and Y contain valid data before entry, you will need to save them
off to the stack and pull them back in after interpreting the joystick results.
I have used this exact method to read the analog inputs on my Science Toolkit
box which connects to the joystick port.
The results have been extremely accurate (much more than would be needed for a
game which reads the joystick). --tg...@pro-gumbo.cts.com (System
Administrator)
__________________________
012- How do I write programs which use the mouse?
The assembly language interface to the mouse firmware is documented in three
places:
- the reference material that was supplied with the AppleMouse card for the
IIe.
- the IIc Technical Reference Manual.
- the IIgs Firmware Reference Manual.
Interfacing to the mouse is somewhat complicated, especially if you want to
implement some kind of mouse cursor (usually requires writing an interrupt
handler).
The first problem is locating the mouse firmware. It could be in any slot for a
IIe or IIgs, or either of two slots for the IIc. The safest method is just to
do a slot search, looking for the mouse ID bytes:
$Cn05 = $38
$Cn07 = $18
$Cn0B = $01
$Cn0C = $20
$CnFB = $D6
On a ROM 3 IIgs, it is possible that the mouse firmware will not be available,
because this doesn't prevent the use of the mouse from GS/OS (the Miscellaneous
Toolset or Event Manager can still be used). An AppleMouse card, if installed,
is not used by the toolbox.
On a ROM 1 IIgs, the slot mouse firmware is used by the toolbox, so slot 4 must
be set to "Mouse Port", or an AppleMouse card may be installed in any slot.
Using the mouse firmware consists of calling the various parameters provided by
the firmware. An entry point table is provided in the mouse slot. The routines
common to all implementations are:
$Cn12 SETMOUSE Sets mouse mode
$Cn13 SERVEMOUSE Services mouse interrupt
$Cn14 READMOUSE Reads mouse position
$Cn15 CLEARMOUSE Clears mouse position to 0 (for delta mode)
$Cn16 POSMOUSE Sets mouse position to a user-defined pos
$Cn17 CLAMPMOUSE Sets mouse bounds in a window
$Cn18 HOMEMOUSE Sets mouse to upper-left corner of clamp win
$Cn19 INITMOUSE Resets mouse clamps to default values;
sets mouse position to 0,0
Each of the above locations contains the low byte of the entry point for the
routine. The high byte is $Cn. The usual method for calling these routines is
to set up a single subroutine which is patched with the location of the
appropriate routine as required. You could also set up a series of subroutines
for calling each routine.
The general logic would be as follows:
Locate the mouse slot by searching for the ID bytes described earlier. Patch
the slot into the following routine:
TOMOUSE LDX #$C1 ; Patch operand byte with slot in $Cn form
LDY #$10 ; Patch operand byte with slot in $n0 form
JMP $C100 ; Patch high byte of operand with slot in
; $Cn form. Low byte of operand must be
; patched with entry point from table above
You should also set up a pair of locations on zero page containing $Cn00, which
will be used to look up the table. You can then have code as follows to call
each of the routines:
MOUSEPTR EQU $00 ; (or some other pair of zero page locations)
SETMOUSE
LDY #$12 ; Offset to entry point
BNE GOMOUSE ; Go to the mouse routine - always taken
SERVEMOUSE
LDY #$13 ; Offset to entry point
BNE GOMOUSE ; Go to the mouse routine - always taken
[etc. - one routine for each mouse call you will be using]
GOMOUSE TAX ; Preserve the value in A
LDA (MOUSEPTR),Y ; Get the routine entry point
STA TOMOUSE+5 ; Patch the JMP instruction
TXA ; Restore the value in A
; The following operand bytes must be patched by the
; initialization code which detects the mouse.
TOMOUSE LDX #$C1 ; Set up slot in $Cn form in X
LDY #$10 ; Set up slot in $n0 form in Y
JMP $C100 ; Go to the mouse routine
With code like the above, your program can just use JSR INITMOUSE, etc. to call
the appropriate routine.
The mouse routines make use of screen holes for the slot containing the mouse
interface firmware/card. The screen holes are as follows:
$0478 + slot Low byte of absolute X position
$04F8 + slot Low byte of absolute Y position
$0578 + slot High byte of absolute X position
$05F8 + slot High byte of absolute Y position
$0678 + slot Reserved and used by the firmware
$06F8 + slot Reserved and used by the firmware
$0778 + slot Button 0/1 interrupt status byte
$07F8 + slot Mode byte
You can access the screen holes by getting the mouse slot number in the $Cn
form (LDX TOMOUSE+1), then indexing off the above locations minus $C0 with X
(or just AND the value with $0F and use the base addresses directly).
The screen holes should be used only as specified by the mouse routines below.
You should never write to them, except as specified by POSMOUSE.
The interrupt status byte is defined as follows:
Bit 7 6 5 4 3 2 1 0
| | | | | | | |
| | | | | | | \--- Previously, button 1 was up (0) or down (1)
| | | | | | \----- Movement interrupt
| | | | | \------- Button 0/1 interrupt
| | | | \--------- VBL interrupt
| | | \----------- Currently, button 1 is up (0) or down (1)
| | \------------- X/Y moved since last READMOUSE
| \--------------- Previously, button 0 was up (0) or down (1)
\----------------- Currently, button 0 is up (0) or down (1)
(Button 1 is not physically present on the mouse, and is probably
only supported for an ADB mouse on the IIgs.)
The mode byte is defined as follows.
Bit 7 6 5 4 3 2 1 0
| | | | | | | |
| | | | | | | \--- Mouse off (0) or on (1)
| | | | | | \----- Interrupt if mouse is moved
| | | | | \------- Interrupt if button is pressed
| | | | \--------- Interrupt on VBL
| | | \----------- Reserved
| | \------------- Reserved
| \--------------- Reserved
\----------------- Reserved
The button and movement status are only valid after calling READMOUSE.
Interrupt status bits are only valid after SERVEMOUSE and are cleared by
READMOUSE. The appropriate screen hole information must be copied elsewhere
before enabling interrupts with CLI or PLP.
The routines are used as follows. X and Y must be set up with $Cn and $n0 in
all cases. Interrupts must be disabled before calling any of these routines.
Assume all registers are scrambled on exit unless otherwise noted.
SETMOUSE
Sets mouse operation mode.
Entry: A = mouse operation mode ($00 to $0F) - see mode byte.
Exit: C = 1 if illegal mode entered.
Screen hole mode byte is updated.
SERVEMOUSE
Tests for interrupt from mouse and resets mouse's
interrupt line.
Exit: C = 0 if mouse interrupt occurred.
Screen hole interrupt status bits are updated to show
current status.
READMOUSE
Reads delta (X/Y) positions, updates absolute X/Y pos,
and reads button statuses from the mouse.
Exit: C = 0 (always).
Screen hole positions and button/movement status bits are
updated, interrupt status bits are cleared.
CLEARMOUSE
Resets buttons, movement and interrupt status 0.
(This routine is intended to be used for delta mouse
positioning instead of absolute positioning.)
Exit: C = 0 (always).
Screen hole positions and button/movement status bits are
updated, interrupt status bits are cleared.
POSMOUSE
Allows caller to change current mouse position.
Entry: Caller places new absolute X/Y positions directly in
appropriate screen holes.
Exit: C = 0 (always).
Screen hole positions may be updated if necessary (e.g.
clamping).
CLAMPMOUSE
Sets up clamping window for mouse user. Power up default
values are 0 to 1023 ($0000 to $03FF).
Entry: A = 0 if entering X clamps, 1 if entering Y clamps.
Clamps are entered in slot 0 screen holes as follows.
NOTE: these are NOT indexed by the mouse slot number.
$0478 = low byte of low clamp.
$04F8 = low byte of high clamp.
$0578 = high byte of low clamp.
$05F8 = high byte of high clamp.
Exit: C = 0 (always).
Screen hole position is set to top left corner of clamping
window for the IIgs.
Note: The IIgs automatically homes the mouse when this call is
made, but this doesn't happen for the IIc and AppleMouse
card.
HOMEMOUSE
Sets the absolute position to upper-left corner of
clamping window.
Exit: C = 0 (always).
Screen hole positions are updated.
INITMOUSE
Sets screen holes to default values and sets clamping win
to default value of 0 to 1023 in both X and Y directions,
resets hardware.
Exit: C = 0 (always).
Screen holes are updated.
The general method of using the mouse firmware is as follows:
- Call SETMOUSE specifying a mode of 1 (enabled, no interrupts).
- Call INITMOUSE.
- Call CLAMPMOUSE to set up the required clamps (once per ea axis).
- If necessary, call SETMOUSE again with the actual mode you want.
You must set up a ProDOS interrupt handler if you want to use the
interrupt modes.
If you are using polled mode, call READMOUSE as required to update the mouse
position and button status information.
If you are using interrupt mode, your interrupt handler should call SERVEMOUSE
to check for a mouse interrupt. If none occurred, return to ProDOS with C=1. If
one did occur, note the type of interrupt (if necessary), then call READMOUSE
to the new position information, and copy the data elsewhere. Finally, return
to ProDOS with C=0.
When your program is finished, it should disable the mouse by using SETMOUSE
with A=0, and remove the interrupt handler (if necessary). --David Empson
__________________________
013- Where can I get Apple II languages and programming software?
Byte Works (505-898-8183; http://www.byteworks.org ) develops and publishes the
Orca series of Apple II and IIgs languages including Pascal, C, Assembler, and
the new IIgs BASIC. Byte Works also sells manuals, learning packages, and other
language materials.
You can find very good collections of Apple II languages and related software
on the net at ...
Apple Cabi.net sites
ACN Florida
ftp://24.96.48.134:6502/Cabi_Archives/Languages.Programming/
ACN Tarnover
ftp://tarnover.dyndns.org/cabi/Languages.Programming/
Apple II Programmer's Archive
Apple II Programmer's Archive Mirror on ACN Florida
ftp://24.96.48.134:6502/Cabi_Archives/Languages.Programming/A2.Programmer%27s.Archive/
Apple II Programmer's Archive Mirror on ACN Tarnover
ftp://tarnover.dyndns.org/cabi/Languages.Programming/A2.Programmers.Archive/
Asimov
ftp://ftp.apple.asimov.net/pub/apple_II/images/utility/programming/
Ground
ftp://ground.ecn.uiowa.edu/apple2/apple8/Languages/
ftp://ground.ecn.uiowa.edu/apple2/apple8/Beagle.Oldies/
ftp://ground.ecn.uiowa.edu/apple2/apple16/Languages/
ftp://ground.ecn.uiowa.edu/apple2/Collections/SoWhat/
ftp://ground.ecn.uiowa.edu/apple2/Collections/Phoenyx/
Apple II game authoring software links
http://home.swbell.net/rubywand/A2FAQs7GAMESITES.html#004
Ninja Force Downloads- Apple IIgs utilities
http://www.igd.fhg.de/~girschik/nfc/anthology.html
More software links
http://home.swbell.net/rubywand/A2FAQs4MAJORSITES.html
--Rubywand
__________________________
014- How can I view and enter code using the "monitor"?
Every Apple II has a built in "System Monitor", which lets you play around with
memory contents.
To get into it, start in BASIC and type CALL-151.
You then get an * prompt to indicate you are in the monitor. To get back to
BASIC at a later point, press Control-C then return (on a line by itself).
The monitor has a lot of commands and the syntax is rather cryptic. Everything
is entered and displayed in hexadecimal (base 16).
The simplest commands are a single letter. For example, the "I" command sets
the display to inverse, and "N" sets it to normal.
The next level up in complexity are commands which expect a single address
parameter. The address must be entered first, followed by the command letter.
In some cases, the monitor remembers the last address used, so you can
continue where you left off by using the command letter by itself.
An example of this is the "L" command (list) which disassembles 20
instructions.
The normal usage is to enter the start address followed by an "L". After you've
seen one screenful, type "L" by itself and you get another screenful continuing
from the next address.
e.g.
E000L
L
The first command will list the first page of code for the Applesoft
BASIC interpreter, and the second command will list the second page.
You can use multiple commands on the same line, as long as you know what
you are doing. If you don't mind pausing and resuming the scrolling
output (use Ctrl-S to pause, any key to resume), you can do something
like:
E000LLLLLLL
to get several pages of disassembly at once.
Moving up another step are commands that accept a range of addresses.
The address range is entered, with the start and end address separated
by a period (fullstop), and the command letter (if any) goes on the end.
The best example of this is a memory dump, which doesn't have a command
letter. If you want to display a range of bytes as a hex dump, use
something like this:
E000.E07F
The monitor displays eight bytes per line, with the address at the
beginning of each line. If you don't start on a multiple of eight, then
the first line will have less than eight bytes and subsequent lines will
be aligned on eight byte boundaries.
There are variations on the memory dump that can be used for special
cases:
1. You can press return on a blank line to display the next eight bytes.
2. If you enter an address and press return, one location is displayed.
3. You can continue from the end of the previous dump to a specified
address by entering a dot followed by the end address.
You can also display scattered locations by entering them as separate
commands. For example:
E000 E003 E006
will display the three specified locations, one per line.
The third layer of command complexity are the commands which expect a
destination address and a source address range. The destination address
goes first, then a less-than sign, then the source range (with a dot in
the middle), and finally the command letter. The main example of this
is a memory move ("M"):
4000<6000.7FFFM
This will move 8192 (2000 hex) bytes from locations 6000 through 7FFF
down to 4000.
If your source and destination ranges overlap, the move will work
correctly if you are moving data to a lower memory location, but if
moving to a higher location you will get a repeating pattern of the data
from the start of the source range.
There is one major command that breaks the rules above: the "set memory"
command. The general syntax for this is the start address followed by a
colon, then a space-separated list of bytes to be entered into memory.
If you enter more than two digits for the data bytes, only the low order
two digits are used.
If you are entering a lot of data, you can continue the command on
subsequent lines by starting the command with a colon (no address).
The rest of the command line after the colon is regarded as part of the
data to be entered, unless the monitor encounters a single letter
command first.
For example, the following single line command will enter a short
machine code program and disassemble it. The "N" command (normal) is
used as a dummy command to force the data entry to terminate.
300:20 58 FC A9 C8 20 ED FD A9 E9 20 ED FD 20 8E FD 60 N 300L
Having got all that out of the way, here are the major monitor commands,
each given in example form.
<return> Display next line of hex dump
1000 Hex dump one location
1000.101F Hex dump a range of locations
.102F Continue hex dump to specified address
1000:1 2 3 50 Set memory
:51 52 53 Continue set memory
300G Go - call subroutine at specified location
G Go again - call same address as last time
I Inverse
300L List - disassemble 20 lines
L List again - continue disassembly
1000<2000.207FM Move - copy range to destination address
N Normal
1000<2000.207FV Verify - compare range to destination address
There are also several commands that use control characters:
Ctrl-B Cold start BASIC (avoid this)
Ctrl-C Warm start BASIC
Ctrl-E Display the saved CPU registers
Ctrl-K Set input to specified slot (preceded by slot number)
Ctrl-P Set output to specified slot (preceded by slot number)
Ctrl-Y User command
The Ctrl-E command also lets you set the saved CPU registers, which will
be used on a subsequent G (go) command. Type Ctrl-E then a colon,
followed by the data to place into the A, X and Y registers.
The Ctrl-K and Ctrl-P commands should be avoided if you are running
under DOS 3.3 or ProDOS, because they may cause DOS to be disconnected
from the I/O. Use PR#n or IN#n instead.
Ctrl-Y is an "escape hatch", which allows third-party code to hook into
the monitor for this one command.
On the Apple IIgs, IIc (with UniDisk ROM or later), and enhanced IIe there is
also a mini-assembler which can be accessed from the monitor by typing an
exclamation mark as a monitor command. While in the mini-assembler you enter
lines of the form Address:Instruction, or to enter instructions in sequence,
type a space then the instruction. (You must specify the address for the first
instruction, or you could be writing anywhere.) Press <return> on a blank line
to get back to the monitor.
e.g. starting in the monitor, type in the following:
!
1000:JSR FC58
LDA #C8
JSR FDED
LDA #E9
JSR FDED
JSR FD8E
RTS
<return>
1000L
1000G
This is the same program I gave above as an example of the set memory command,
loaded at a different location.
--David Empson
__________________________
015- What parts of Apple II memory should a user be careful
about modifying using the monitor?
It is important to keep in mind that you can do all sorts of nasty things to
the computer if you play around in the monitor and don't know where things are
located in memory.
The safest bet if you want to have a play would be to start the computer with
no disk in the drive, then get into the monitor.
Don't play around with the following memory areas at all (unless you know
exactly what you are doing):
0020-004F Zero page memory area used by the monitor
0100-01FF Stack
0200-02FF Input buffer
03D0-03FF System vectors
C000-C0FF I/O space. Don't even read memory in this area
unless you know what you are doing.
C100-C7FF I/O firmware (usually ROM on cards in slots, or
emultated slots). Some I/O cards may have I/O
ports in this area (but not for the IIc).
C800-CFFF Bank-switched area used by I/O cards. It is safe
to read this area in the IIc, but it has to be
handled carefully in other machines.
The following areas must be handled carefully to avoid problems:
0050-00FF Zero page memory area used by Applesoft BASIC
0400-07FF Text screen and "screen holes", which contain
system data
D000-FFFF ROM and bank-switched RAM ("language card").
Don't write anything into this area, especially
if you are running under ProDOS.
Other memory areas that you may need to be aware of:
0800-???? Applesoft BASIC programs normally go here,
followed by variables
2000-3FFF Hires graphics buffer for page 1
4000-5FFF Hires graphics buffer for page 2
9600-BFFF Normally used by DOS 3.3 or ProDOS
????-95FF Normally used for strings in Applesoft BASIC
The hires graphics buffers are only an issue if you need to use them. Under DOS
3.3 or ProDOS, the upper memory limit (9600) may change depending on the use of
the MAXFILES command under DOS or the number of open files under ProDOS.
This leaves you with the following areas that you can usually play with to your
heart's content. There are _some_ exceptions, but I've covered enough for one
article.
0000-001F This isn't entirely free, but is usually OK.
0300-03CF Often used for small machine code programs.
1000(ish)-7FFF(ish)
The last area varies wildly depending on the size of any BASIC program and its
variables.
--David Empson
__________________________
016- Can I do multi-tasking on a IIgs? or What is GNO/ME?
GNO/ME is a programming shell (a command line environment) for the Apple IIgs.
Designed as a replacement for the ORCA Shell, GNO/ME works in a manner similar
to the Unix operating system, providing preemptive multitasking of multiple
text programs, as well as many Unix commands and library functions.
For more information about GNO/ME, see
GNO/ME USENET newsgroup (comp.sys.apple2.gno) and FAQs at
ftp://rtfm.mit.edu/pub/usenet/news.answers/apple2/GNO-faq
Trenco archive
http://trenco.myrias.com:80/%7Egno/
--Bryan Ogawa
__________________________
017- Where can I find manuals and other resources for the CP/M
operating system?
One good link is CP/M (with Gary Kildall history and excellent link
collection):
http://www.maxframe.com/cpm.htm
This next site is listed on the link above, but it is imho the BEST site for
CP/M related downloads:
http://www.iso.port.ac.uk/~mike/interests/chistory/documents/cpm-22-manual/
The CP/M area of Tarnover is now open:
ftp://tarnover.dyndns.org/tarnover/Files/CPM/
http://tarnover.dyndns.org/tarnover/Files/CPM
The following applications currently available:
MicroPro's StarCard software
MicroPro's WordStar for CP/M
Borland's Turbo Pascal
Borland's Turbo Pascal Database Toolbox
--Bart, Celt