From the Apple IIe Technical Reference Manual, pages 37-39: Secondary Inputs and Outputs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to the primary I/O devices - the keyboard and display - there are several secondary input and output devices in the Apple IIe. These devices are the speaker (output) cassette input and output annunciator output strobe output switch inputs analog (hand-control) inputs. These devices are similiar in operation to the soft switches described in the previous section: you control them by reading or writing to dedicated memory locations. Action takes place any time your program reads or writes to one of these locations; information written is ignored. Important! Some of these devices toggle - change state - each time they are accessed. If you write using an indexed store operation, the Apple IIe's microprocessor activates the address bus twice during successive clock cycles, causing a device that toggles each time it is addressed to end up back in its original state. For this reason, you should read, rather than write, to such devices. The Speaker ~~~~~~~~~~~ The Apple IIe has a small speaker mounted toward the front of the bottom plate. The speaker is connected to a soft switch that toggles; it has two states, off and on, and it changes from one to the other each time it is accessed. (At low frequencies, less than 400 Hz or so, the speaker clicks only on every other access.) If you switch the speaker once, it emits a click; to make longer sounds, you access the speaker repeatedly. You should always use a read operation to toggle the speaker. If you write to this soft switch, it switches twice in rapid succession. The resulting pulse is so short that the speaker doesn't have time to respond; it doesn't make a sound. The soft switch for the speaker uses memory location 49200 (hexadecimal $C030). From Integer BASIC, use the complementary address -16336. You can make various tones and buzzes with the speaker by using combinations of timing loops in your program. There is also a routine in the built-in firmware to make a beep through the speaker. The routine is called BELL1. (Electrical specifications of the speaker curcuit appear in Chapter 7. BELL1 is described in Appendix B.) Cassette Input and Output ~~~~~~~~~~~~~~~~~~~~~~~~~ There are two miniature phone jacks on the back panel of the Apple IIe. You can use a pair of standard cables with miniature phone plugs to connect an ordinary cassette tape recorder to the Apple IIe and save programs and data on audio cassettes. The phone jack marked with a picture of an arrow pointing towards a cassette is the output jack. It is connected to a toggled soft switch, like the speaker switch described above. The signal at the phone jack switches from zero to 25 millivolts or from 25 millivolts to zero each time you access the soft switch. (Detalied electrical specifications for the cassette input and output are given in Chapter 7.) If you connect a cable from this jack to the microphone input of a cassette tape recorder and switch the recorder to record mode, the signal changes you produce by accessing this soft switch will be recorded on the tape. The cassette output switch uses memory location 49184 (hexadecimal $C020; complementary value -16352). Like the speaker, the output will toggle twice if you write to it, so you should only use read operations to control the cassette output. The standard method for writing computer data on audio tapes uses tones with two different pitches to represent the binary states zero and one. To store data, you convert the data into a stream of bits and convert the bits into the appropriate tones. To save you the trouble of actually programming the tones, and to ensure consistency among all Apple II cassette tapes, there is a built-in routine called WRITE for producing cassette data output. (WRITE is described in Appendix B.) The phone jack marked with a picture of an arrow coming from a cassette is the input jack. It accepts a cable from the cassette recorder's earphone jack. The signal from the cassette is 1 volt (peak-to-peak) audio. Each time the instantaneous value of this audio signal changes from positive to negative, or vice-versa, the state of the cassette input curcuit changes from zero to one or vice-versa. You can read the state of this curcuit at memory location 49248 (hexadecimal $C060, or complementary decimal -16288). When you read this location, you get a byte, but only the high-order bit (bit 7) is valid. If you are programming in machine language, this is the sign bit, so you can perform a Branch Plus or Branch Minus immediately after reading this byte. BASIC is too slow to keep up with the audio tones used for data recording on tape, but you don't need to write the program: there is a built-in routine called READ for reading data from a cassette. (READ is described in Appendix B.)