![]() |
One of the Apple II's most endearing
features is its ease of programming. Although quite limited by modern
standards, the Apple II's built-in AppleSoft BASIC and Mini-Assembler
can be used to create some very interesting and useful programs. Of course
more advanced languages and tools are available (see below),
but since this page is geared toward the beginner we'll try to stick to
the basics here. |
Apple II Programming Examples |
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
| |
|
|
|
You need to BLOAD each sound file at its own unique (non-overlapping, of course) address. When you want to play a sound, POKE its begin address into locations 6 and 7, and its end address into locations 8 and 9. Then call the PLAY routine at $8C00.There you have it... simplicity itself! So here is a complete listing of a program that will do nothing less than load and play a 2K audio file:Of course all addresses need to be converted to decimal for BASIC to POKE and CALL them (no problem with 6,7,8,and 9--they're already in both hex and decimal! ;-), and since the addresses POKEd into low memory are two-byte addresses, they need to be split into their high and low bytes, and POKEd into memory low-byte first.
For example, say that you want to play a sound BLOADed at $8000 with a length of 600 bytes (decimal). Then the start address is 32768 (decimal) and the end address is 32768+600, or 33368.
The high byte of the start address is INT(32768/256), or 128, and the low byte of the start address is 32768-256*INT(32768/256), or 0.
So you would need to POKE 6,0: POKE 7,128 to set up the start address.
Similarly, you would POKE 8,88: POKE 9,130 to set up the end address.
Then to play the sound, you call $8C00 by executing CALL 35840 (that's 8*4096 + 12*256 + 0*16 + 0, if you see what I mean).
Of course, all of this can be done by a few BASIC statements that you call with a GOSUB after setting up variables for the start and end addresses (I used SA and EN in SOUND.EDITOR for these variables, and another GOSUB subroutine to do the 2-byte POKEs, to save space and make the program structure more logical. -MJM
Beagle Brothers' Program Writer is essentially
just a text editor for AppleSoft programs. Anyone who's gone much
beyond PRINT "HELLO WORLD"
has undoubtedly discovered the limitations of AppleSoft's built-in
editor. Program Writer actually makes writing code fun, and can drastically
simplify revisions of existing code.
Program Writer
Program Writer Docs